12bdfcea1SArmin Le Grand /**************************************************************
22bdfcea1SArmin Le Grand  *
32bdfcea1SArmin Le Grand  * Licensed to the Apache Software Foundation (ASF) under one
42bdfcea1SArmin Le Grand  * or more contributor license agreements.  See the NOTICE file
52bdfcea1SArmin Le Grand  * distributed with this work for additional information
62bdfcea1SArmin Le Grand  * regarding copyright ownership.  The ASF licenses this file
72bdfcea1SArmin Le Grand  * to you under the Apache License, Version 2.0 (the
82bdfcea1SArmin Le Grand  * "License"); you may not use this file except in compliance
92bdfcea1SArmin Le Grand  * with the License.  You may obtain a copy of the License at
102bdfcea1SArmin Le Grand  *
112bdfcea1SArmin Le Grand  *   http://www.apache.org/licenses/LICENSE-2.0
122bdfcea1SArmin Le Grand  *
132bdfcea1SArmin Le Grand  * Unless required by applicable law or agreed to in writing,
142bdfcea1SArmin Le Grand  * software distributed under the License is distributed on an
152bdfcea1SArmin Le Grand  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162bdfcea1SArmin Le Grand  * KIND, either express or implied.  See the License for the
172bdfcea1SArmin Le Grand  * specific language governing permissions and limitations
182bdfcea1SArmin Le Grand  * under the License.
192bdfcea1SArmin Le Grand  *
202bdfcea1SArmin Le Grand  *************************************************************/
212bdfcea1SArmin Le Grand 
22d29c2fc2SAndre Fischer #include <sfx2/sidebar/ResourceDefinitions.hrc>
232bdfcea1SArmin Le Grand #include <sfx2/sidebar/Theme.hxx>
242bdfcea1SArmin Le Grand #include <sfx2/sidebar/ControlFactory.hxx>
25*6a606da0SAndre Fischer #include <sfx2/sidebar/Layouter.hxx>
262bdfcea1SArmin Le Grand #include <GraphicPropertyPanel.hxx>
272bdfcea1SArmin Le Grand #include <GraphicPropertyPanel.hrc>
282bdfcea1SArmin Le Grand #include <svx/dialogs.hrc>
292bdfcea1SArmin Le Grand #include <svx/dialmgr.hxx>
302bdfcea1SArmin Le Grand #include <vcl/field.hxx>
312bdfcea1SArmin Le Grand #include <vcl/lstbox.hxx>
322bdfcea1SArmin Le Grand #include <svl/intitem.hxx>
332bdfcea1SArmin Le Grand #include <sfx2/bindings.hxx>
342bdfcea1SArmin Le Grand #include <sfx2/dispatch.hxx>
3587ab04d0SAndre Fischer #include "svx/dialogs.hrc"
362bdfcea1SArmin Le Grand 
372bdfcea1SArmin Le Grand using namespace css;
382bdfcea1SArmin Le Grand using namespace cssu;
39*6a606da0SAndre Fischer using ::sfx2::sidebar::Layouter;
402bdfcea1SArmin Le Grand using ::sfx2::sidebar::Theme;
412bdfcea1SArmin Le Grand 
422bdfcea1SArmin Le Grand #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
432bdfcea1SArmin Le Grand 
442bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
45*6a606da0SAndre Fischer 
462bdfcea1SArmin Le Grand 
472bdfcea1SArmin Le Grand namespace svx { namespace sidebar {
482bdfcea1SArmin Le Grand 
492bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
502bdfcea1SArmin Le Grand 
GraphicPropertyPanel(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings)512bdfcea1SArmin Le Grand GraphicPropertyPanel::GraphicPropertyPanel(
522bdfcea1SArmin Le Grand     Window* pParent,
532bdfcea1SArmin Le Grand     const cssu::Reference<css::frame::XFrame>& rxFrame,
542bdfcea1SArmin Le Grand     SfxBindings* pBindings)
552bdfcea1SArmin Le Grand :   Control(
562bdfcea1SArmin Le Grand         pParent,
572bdfcea1SArmin Le Grand         SVX_RES(RID_SIDEBAR_GRAPHIC_PANEL)),
582bdfcea1SArmin Le Grand     mpFtBrightness(new FixedText(this, SVX_RES(FT_BRIGHTNESS))),
592bdfcea1SArmin Le Grand     mpMtrBrightness(new MetricField(this, SVX_RES(MTR_BRIGHTNESS))),
602bdfcea1SArmin Le Grand     mpFtContrast(new FixedText(this, SVX_RES(FT_CONTRAST))),
612bdfcea1SArmin Le Grand     mpMtrContrast(new MetricField(this, SVX_RES(MTR_CONTRAST))),
622bdfcea1SArmin Le Grand     mpFtColorMode(new FixedText(this, SVX_RES(FT_COLOR_MODE))),
632bdfcea1SArmin Le Grand     mpLBColorMode(new ListBox(this, SVX_RES(LB_COLOR_MODE))),
642bdfcea1SArmin Le Grand     mpFtTrans(new FixedText(this, SVX_RES(FT_TRANSPARENT))),
652bdfcea1SArmin Le Grand     mpMtrTrans(new MetricField(this, SVX_RES(MTR_TRANSPARENT))),
662bdfcea1SArmin Le Grand     mpMtrRed(new MetricField(this, SVX_RES(MF_RED))),
672bdfcea1SArmin Le Grand     mpMtrGreen(new MetricField(this, SVX_RES(MF_GREEN))),
682bdfcea1SArmin Le Grand     mpMtrBlue(new MetricField(this, SVX_RES(MF_BLUE))),
692bdfcea1SArmin Le Grand     mpMtrGamma(new MetricField(this, SVX_RES(MF_GAMMA))),
702bdfcea1SArmin Le Grand     maBrightControl(SID_ATTR_GRAF_LUMINANCE, *pBindings, *this),
712bdfcea1SArmin Le Grand     maContrastControl(SID_ATTR_GRAF_CONTRAST, *pBindings, *this),
722bdfcea1SArmin Le Grand     maTransparenceControl(SID_ATTR_GRAF_TRANSPARENCE, *pBindings, *this),
732bdfcea1SArmin Le Grand     maRedControl(SID_ATTR_GRAF_RED, *pBindings, *this),
742bdfcea1SArmin Le Grand     maGreenControl(SID_ATTR_GRAF_GREEN, *pBindings, *this),
752bdfcea1SArmin Le Grand     maBlueControl(SID_ATTR_GRAF_BLUE, *pBindings, *this),
762bdfcea1SArmin Le Grand     maGammaControl(SID_ATTR_GRAF_GAMMA, *pBindings, *this),
772bdfcea1SArmin Le Grand     maModeControl(SID_ATTR_GRAF_MODE, *pBindings, *this),
782bdfcea1SArmin Le Grand     maImgRed(this, SVX_RES(IMG_RED)),
792bdfcea1SArmin Le Grand     maImgGreen(this, SVX_RES(IMG_GREEN)),
802bdfcea1SArmin Le Grand     maImgBlue(this, SVX_RES(IMG_BLUE)),
812bdfcea1SArmin Le Grand     maImgGamma(this, SVX_RES(IMG_GAMMA)),
822bdfcea1SArmin Le Grand     mxFrame(rxFrame),
83*6a606da0SAndre Fischer     mpBindings(pBindings),
84*6a606da0SAndre Fischer     maLayouter(*this)
852bdfcea1SArmin Le Grand {
862bdfcea1SArmin Le Grand     Initialize();
872bdfcea1SArmin Le Grand     FreeResource();
88*6a606da0SAndre Fischer 
89*6a606da0SAndre Fischer     // Setup the grid layouter.
90*6a606da0SAndre Fischer     maLayouter.GetCell(0,0).SetControl(*mpFtBrightness).SetGridWidth(2);
91*6a606da0SAndre Fischer     maLayouter.GetCell(1,0).SetControl(*mpMtrBrightness).SetGridWidth(2);
92*6a606da0SAndre Fischer 
93*6a606da0SAndre Fischer     maLayouter.GetCell(0,3).SetControl(*mpFtContrast).SetGridWidth(2);
94*6a606da0SAndre Fischer     maLayouter.GetCell(1,3).SetControl(*mpMtrContrast).SetGridWidth(2);
95*6a606da0SAndre Fischer 
96*6a606da0SAndre Fischer     maLayouter.GetCell(2,0).SetControl(*mpFtColorMode).SetGridWidth(2);
97*6a606da0SAndre Fischer     maLayouter.GetCell(3,0).SetControl(*mpLBColorMode).SetGridWidth(2);
98*6a606da0SAndre Fischer 
99*6a606da0SAndre Fischer     maLayouter.GetCell(2,3).SetControl(*mpFtTrans).SetGridWidth(2);
100*6a606da0SAndre Fischer     maLayouter.GetCell(3,3).SetControl(*mpMtrTrans).SetGridWidth(2);
101*6a606da0SAndre Fischer 
102*6a606da0SAndre Fischer     maLayouter.GetCell(4,0).SetControl(maImgRed).SetFixedWidth();
103*6a606da0SAndre Fischer     maLayouter.GetCell(4,1).SetControl(*mpMtrRed);
104*6a606da0SAndre Fischer 
105*6a606da0SAndre Fischer     maLayouter.GetCell(5,0).SetControl(maImgBlue).SetFixedWidth();
106*6a606da0SAndre Fischer     maLayouter.GetCell(5,1).SetControl(*mpMtrBlue);
107*6a606da0SAndre Fischer 
108*6a606da0SAndre Fischer     maLayouter.GetCell(4,3).SetControl(maImgGreen).SetFixedWidth();
109*6a606da0SAndre Fischer     maLayouter.GetCell(4,4).SetControl(*mpMtrGreen);
110*6a606da0SAndre Fischer     maLayouter.GetCell(5,3).SetControl(maImgGamma).SetFixedWidth();
111*6a606da0SAndre Fischer     maLayouter.GetCell(5,4).SetControl(*mpMtrGamma);
112*6a606da0SAndre Fischer 
113*6a606da0SAndre Fischer     maLayouter.GetColumn(0)
114*6a606da0SAndre Fischer         .SetWeight(0)
115*6a606da0SAndre Fischer         .SetLeftPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
116*6a606da0SAndre Fischer     maLayouter.GetColumn(1)
117*6a606da0SAndre Fischer         .SetWeight(1)
118*6a606da0SAndre Fischer         .SetMinimumWidth(Layouter::MapWidth(*this, MBOX_WIDTH - 10));
119*6a606da0SAndre Fischer     maLayouter.GetColumn(2)
120*6a606da0SAndre Fischer         .SetWeight(0)
121*6a606da0SAndre Fischer         .SetMinimumWidth(Layouter::MapWidth(*this, CONTROL_SPACING_HORIZONTAL));
122*6a606da0SAndre Fischer     maLayouter.GetColumn(3)
123*6a606da0SAndre Fischer         .SetWeight(0);
124*6a606da0SAndre Fischer     maLayouter.GetColumn(4)
125*6a606da0SAndre Fischer         .SetWeight(1)
126*6a606da0SAndre Fischer         .SetMinimumWidth(Layouter::MapWidth(*this, MBOX_WIDTH - 10))
127*6a606da0SAndre Fischer         .SetRightPadding(Layouter::MapWidth(*this,SECTIONPAGE_MARGIN_HORIZONTAL));
128*6a606da0SAndre Fischer 
129*6a606da0SAndre Fischer     // Make controls that display text handle short widths more
130*6a606da0SAndre Fischer     // graceful.
131*6a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtBrightness);
132*6a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtContrast);
133*6a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtColorMode);
134*6a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtTrans);
1352bdfcea1SArmin Le Grand }
1362bdfcea1SArmin Le Grand 
1372bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
1382bdfcea1SArmin Le Grand 
~GraphicPropertyPanel()1392bdfcea1SArmin Le Grand GraphicPropertyPanel::~GraphicPropertyPanel()
1402bdfcea1SArmin Le Grand {
1412bdfcea1SArmin Le Grand }
1422bdfcea1SArmin Le Grand 
1432bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
1442bdfcea1SArmin Le Grand 
Initialize()1452bdfcea1SArmin Le Grand void GraphicPropertyPanel::Initialize()
1462bdfcea1SArmin Le Grand {
14737fee4fdSAndre Fischer     mpFtBrightness->SetBackground(Wallpaper());
14837fee4fdSAndre Fischer     mpFtContrast->SetBackground(Wallpaper());
14937fee4fdSAndre Fischer     mpFtColorMode->SetBackground(Wallpaper());
15037fee4fdSAndre Fischer     mpFtTrans->SetBackground(Wallpaper());
15137fee4fdSAndre Fischer 
15237fee4fdSAndre Fischer     mpMtrBrightness->SetModifyHdl( LINK( this, GraphicPropertyPanel, ModifyBrightnessHdl ) );
15387ab04d0SAndre Fischer     mpMtrBrightness->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Brightness")));
154d74d90d6SArmin Le Grand     mpMtrContrast->SetModifyHdl( LINK( this, GraphicPropertyPanel, ModifyContrastHdl ) );
15587ab04d0SAndre Fischer     mpMtrContrast->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Contrast")));
156d74d90d6SArmin Le Grand     mpMtrTrans->SetModifyHdl( LINK( this, GraphicPropertyPanel, ModifyTransHdl ) );
15787ab04d0SAndre Fischer     mpMtrTrans->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency")));
158d74d90d6SArmin Le Grand 
15987ab04d0SAndre Fischer     mpLBColorMode->InsertEntry(String(SVX_RES(RID_SVXSTR_GRAFMODE_STANDARD)));
16087ab04d0SAndre Fischer     mpLBColorMode->InsertEntry(String(SVX_RES(RID_SVXSTR_GRAFMODE_GREYS)));
16187ab04d0SAndre Fischer     mpLBColorMode->InsertEntry(String(SVX_RES(RID_SVXSTR_GRAFMODE_MONO)));
16287ab04d0SAndre Fischer     mpLBColorMode->InsertEntry(String(SVX_RES(RID_SVXSTR_GRAFMODE_WATERMARK)));
163d74d90d6SArmin Le Grand     mpLBColorMode->SetSelectHdl( LINK( this, GraphicPropertyPanel, ClickColorModeHdl ));
16487ab04d0SAndre Fischer     mpLBColorMode->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Color mode")));
165d74d90d6SArmin Le Grand 
166d74d90d6SArmin Le Grand     mpMtrRed->SetModifyHdl( LINK( this, GraphicPropertyPanel, RedHdl ) );
167d74d90d6SArmin Le Grand     mpMtrGreen->SetModifyHdl( LINK( this, GraphicPropertyPanel, GreenHdl ) );
168d74d90d6SArmin Le Grand     mpMtrBlue->SetModifyHdl( LINK( this, GraphicPropertyPanel, BlueHdl ) );
169d74d90d6SArmin Le Grand     mpMtrGamma->SetModifyHdl( LINK( this, GraphicPropertyPanel, GammaHdl ) );
17087ab04d0SAndre Fischer     mpMtrRed->SetAccessibleName(mpMtrRed->GetQuickHelpText());
17187ab04d0SAndre Fischer     mpMtrGreen->SetAccessibleName(mpMtrGreen->GetQuickHelpText());
17287ab04d0SAndre Fischer     mpMtrBlue->SetAccessibleName(mpMtrBlue->GetQuickHelpText());
17387ab04d0SAndre Fischer     mpMtrGamma->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Gamma value")));
1742bdfcea1SArmin Le Grand 
17589729eb3SArmin Le Grand     mpMtrRed->SetAccessibleRelationLabeledBy(mpMtrRed.get());
176d74d90d6SArmin Le Grand     mpMtrGreen->SetAccessibleRelationLabeledBy(mpMtrGreen.get());
177d74d90d6SArmin Le Grand     mpMtrBlue->SetAccessibleRelationLabeledBy(mpMtrBlue.get());
178d74d90d6SArmin Le Grand     mpMtrGamma->SetAccessibleRelationLabeledBy(mpMtrGamma.get());
17987ab04d0SAndre Fischer     mpMtrBrightness->SetAccessibleRelationLabeledBy(mpFtBrightness.get());
18087ab04d0SAndre Fischer     mpMtrContrast->SetAccessibleRelationLabeledBy(mpFtContrast.get());
18187ab04d0SAndre Fischer     mpMtrTrans->SetAccessibleRelationLabeledBy(mpFtTrans.get());
18287ab04d0SAndre Fischer     mpLBColorMode->SetAccessibleRelationLabeledBy(mpFtColorMode.get());
18387ab04d0SAndre Fischer 
18487ab04d0SAndre Fischer     // Fix left position of some controls that may be wrong due to
18587ab04d0SAndre Fischer     // rounding errors.
18687ab04d0SAndre Fischer     const sal_Int32 nRight0 (mpLBColorMode->GetPosPixel().X() + mpLBColorMode->GetSizePixel().Width());
18787ab04d0SAndre Fischer     const sal_Int32 nRight1 (mpMtrTrans->GetPosPixel().X() + mpMtrTrans->GetSizePixel().Width());
18887ab04d0SAndre Fischer     mpMtrRed->SetPosPixel(Point(
18987ab04d0SAndre Fischer             nRight0 - mpMtrRed->GetSizePixel().Width(),
19087ab04d0SAndre Fischer             mpMtrRed->GetPosPixel().Y()));
19187ab04d0SAndre Fischer     mpMtrBlue->SetPosPixel(Point(
19287ab04d0SAndre Fischer             nRight0 - mpMtrBlue->GetSizePixel().Width(),
19387ab04d0SAndre Fischer             mpMtrBlue->GetPosPixel().Y()));
19487ab04d0SAndre Fischer     mpMtrGreen->SetPosPixel(Point(
19587ab04d0SAndre Fischer             nRight1 - mpMtrGreen->GetSizePixel().Width(),
19687ab04d0SAndre Fischer             mpMtrGreen->GetPosPixel().Y()));
19787ab04d0SAndre Fischer     mpMtrGamma->SetPosPixel(Point(
19887ab04d0SAndre Fischer             nRight1 - mpMtrGamma->GetSizePixel().Width(),
19987ab04d0SAndre Fischer             mpMtrGamma->GetPosPixel().Y()));
2002bdfcea1SArmin Le Grand }
2012bdfcea1SArmin Le Grand 
20287ab04d0SAndre Fischer 
20387ab04d0SAndre Fischer 
20487ab04d0SAndre Fischer 
2052bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2062bdfcea1SArmin Le Grand 
IMPL_LINK(GraphicPropertyPanel,ModifyBrightnessHdl,void *,EMPTYARG)2072bdfcea1SArmin Le Grand IMPL_LINK( GraphicPropertyPanel, ModifyBrightnessHdl, void *, EMPTYARG )
2082bdfcea1SArmin Le Grand {
209d74d90d6SArmin Le Grand     const sal_Int16 nBright = mpMtrBrightness->GetValue();
210d74d90d6SArmin Le Grand     const SfxInt16Item aBrightItem( SID_ATTR_GRAF_LUMINANCE, nBright );
211d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_LUMINANCE, SFX_CALLMODE_RECORD, &aBrightItem, 0L);
212d74d90d6SArmin Le Grand     return 0L;
2132bdfcea1SArmin Le Grand }
2142bdfcea1SArmin Le Grand 
2152bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2162bdfcea1SArmin Le Grand 
IMPL_LINK(GraphicPropertyPanel,ModifyContrastHdl,void *,EMPTYARG)2172bdfcea1SArmin Le Grand IMPL_LINK( GraphicPropertyPanel, ModifyContrastHdl, void *, EMPTYARG )
2182bdfcea1SArmin Le Grand {
219d74d90d6SArmin Le Grand     const sal_Int16 nContrast = mpMtrContrast->GetValue();
220d74d90d6SArmin Le Grand     const SfxInt16Item aContrastItem( SID_ATTR_GRAF_CONTRAST, nContrast );
221d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_CONTRAST, SFX_CALLMODE_RECORD, &aContrastItem, 0L);
222d74d90d6SArmin Le Grand     return 0L;
2232bdfcea1SArmin Le Grand }
2242bdfcea1SArmin Le Grand 
2252bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2262bdfcea1SArmin Le Grand 
IMPL_LINK(GraphicPropertyPanel,ModifyTransHdl,void *,EMPTYARG)2272bdfcea1SArmin Le Grand IMPL_LINK( GraphicPropertyPanel, ModifyTransHdl, void *, EMPTYARG )
2282bdfcea1SArmin Le Grand {
229d74d90d6SArmin Le Grand     const sal_Int16 nTrans = mpMtrTrans->GetValue();
230d74d90d6SArmin Le Grand     const SfxInt16Item aTransItem( SID_ATTR_GRAF_TRANSPARENCE, nTrans );
231d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_TRANSPARENCE, SFX_CALLMODE_RECORD, &aTransItem, 0L);
232d74d90d6SArmin Le Grand     return 0L;
2332bdfcea1SArmin Le Grand }
2342bdfcea1SArmin Le Grand 
2352bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2362bdfcea1SArmin Le Grand 
237e89b8a96SPavel Janík IMPL_LINK( GraphicPropertyPanel, ClickColorModeHdl, ToolBox *, /* pBox */)
2382bdfcea1SArmin Le Grand {
239d74d90d6SArmin Le Grand     const sal_Int16 nTrans = mpLBColorMode->GetSelectEntryPos();
240d74d90d6SArmin Le Grand     const SfxInt16Item aTransItem( SID_ATTR_GRAF_MODE, nTrans );
241d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_MODE, SFX_CALLMODE_RECORD, &aTransItem, 0L);
242d74d90d6SArmin Le Grand     return 0L;
2432bdfcea1SArmin Le Grand }
2442bdfcea1SArmin Le Grand 
2452bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2462bdfcea1SArmin Le Grand 
IMPL_LINK(GraphicPropertyPanel,RedHdl,void *,EMPTYARG)2472bdfcea1SArmin Le Grand IMPL_LINK( GraphicPropertyPanel, RedHdl, void*, EMPTYARG )
2482bdfcea1SArmin Le Grand {
249d74d90d6SArmin Le Grand     const sal_Int16 nRed = mpMtrRed->GetValue();
250d74d90d6SArmin Le Grand     const SfxInt16Item aRedItem( SID_ATTR_GRAF_RED, nRed );
251d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_RED, SFX_CALLMODE_RECORD, &aRedItem, 0L);
252d74d90d6SArmin Le Grand     return 0L;
2532bdfcea1SArmin Le Grand }
2542bdfcea1SArmin Le Grand 
2552bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2562bdfcea1SArmin Le Grand 
IMPL_LINK(GraphicPropertyPanel,GreenHdl,void *,EMPTYARG)2572bdfcea1SArmin Le Grand IMPL_LINK( GraphicPropertyPanel, GreenHdl, void*, EMPTYARG )
2582bdfcea1SArmin Le Grand {
259d74d90d6SArmin Le Grand     const sal_Int16 nGreen = mpMtrGreen->GetValue();
260d74d90d6SArmin Le Grand     const SfxInt16Item aGreenItem( SID_ATTR_GRAF_GREEN, nGreen );
261d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_GREEN, SFX_CALLMODE_RECORD, &aGreenItem, 0L);
262d74d90d6SArmin Le Grand     return 0L;
2632bdfcea1SArmin Le Grand }
2642bdfcea1SArmin Le Grand 
2652bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2662bdfcea1SArmin Le Grand 
IMPL_LINK(GraphicPropertyPanel,BlueHdl,void *,EMPTYARG)2672bdfcea1SArmin Le Grand IMPL_LINK(GraphicPropertyPanel, BlueHdl, void *, EMPTYARG)
2682bdfcea1SArmin Le Grand {
269d74d90d6SArmin Le Grand     const sal_Int16 nBlue = mpMtrBlue->GetValue();
270d74d90d6SArmin Le Grand     const SfxInt16Item aBlueItem( SID_ATTR_GRAF_BLUE, nBlue );
271d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_BLUE, SFX_CALLMODE_RECORD, &aBlueItem, 0L);
272d74d90d6SArmin Le Grand     return 0L;
2732bdfcea1SArmin Le Grand }
2742bdfcea1SArmin Le Grand 
2752bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2762bdfcea1SArmin Le Grand 
IMPL_LINK(GraphicPropertyPanel,GammaHdl,void *,EMPTYARG)2772bdfcea1SArmin Le Grand IMPL_LINK(GraphicPropertyPanel, GammaHdl, void *, EMPTYARG)
2782bdfcea1SArmin Le Grand {
279d74d90d6SArmin Le Grand     const sal_Int32 nGamma = mpMtrGamma->GetValue();
280d74d90d6SArmin Le Grand     const SfxInt32Item nGammaItem( SID_ATTR_GRAF_GAMMA, nGamma );
281d74d90d6SArmin Le Grand     GetBindings()->GetDispatcher()->Execute(SID_ATTR_GRAF_GAMMA, SFX_CALLMODE_RECORD, &nGammaItem, 0L);
282d74d90d6SArmin Le Grand     return 0L;
2832bdfcea1SArmin Le Grand }
2842bdfcea1SArmin Le Grand 
2852bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2862bdfcea1SArmin Le Grand 
SetupIcons(void)2872bdfcea1SArmin Le Grand void GraphicPropertyPanel::SetupIcons(void)
2882bdfcea1SArmin Le Grand {
2892bdfcea1SArmin Le Grand     if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
2902bdfcea1SArmin Le Grand     {
2912bdfcea1SArmin Le Grand         // todo
2922bdfcea1SArmin Le Grand     }
2932bdfcea1SArmin Le Grand     else
2942bdfcea1SArmin Le Grand     {
2952bdfcea1SArmin Le Grand         // todo
2962bdfcea1SArmin Le Grand     }
2972bdfcea1SArmin Le Grand }
2982bdfcea1SArmin Le Grand 
2992bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
3002bdfcea1SArmin Le Grand 
Create(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings)3012bdfcea1SArmin Le Grand GraphicPropertyPanel* GraphicPropertyPanel::Create (
3022bdfcea1SArmin Le Grand     Window* pParent,
3032bdfcea1SArmin Le Grand     const cssu::Reference<css::frame::XFrame>& rxFrame,
3042bdfcea1SArmin Le Grand     SfxBindings* pBindings)
3052bdfcea1SArmin Le Grand {
3062bdfcea1SArmin Le Grand     if (pParent == NULL)
3072bdfcea1SArmin Le Grand         throw lang::IllegalArgumentException(A2S("no parent Window given to GraphicPropertyPanel::Create"), NULL, 0);
3082bdfcea1SArmin Le Grand     if ( ! rxFrame.is())
3092bdfcea1SArmin Le Grand         throw lang::IllegalArgumentException(A2S("no XFrame given to GraphicPropertyPanel::Create"), NULL, 1);
3102bdfcea1SArmin Le Grand     if (pBindings == NULL)
3112bdfcea1SArmin Le Grand         throw lang::IllegalArgumentException(A2S("no SfxBindings given to GraphicPropertyPanel::Create"), NULL, 2);
3122bdfcea1SArmin Le Grand 
3132bdfcea1SArmin Le Grand     return new GraphicPropertyPanel(
3142bdfcea1SArmin Le Grand         pParent,
3152bdfcea1SArmin Le Grand         rxFrame,
3162bdfcea1SArmin Le Grand         pBindings);
3172bdfcea1SArmin Le Grand }
3182bdfcea1SArmin Le Grand 
3192bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
3202bdfcea1SArmin Le Grand 
DataChanged(const DataChangedEvent & rEvent)3212bdfcea1SArmin Le Grand void GraphicPropertyPanel::DataChanged(
3222bdfcea1SArmin Le Grand     const DataChangedEvent& rEvent)
3232bdfcea1SArmin Le Grand {
3242bdfcea1SArmin Le Grand     (void)rEvent;
3252bdfcea1SArmin Le Grand 
3262bdfcea1SArmin Le Grand     SetupIcons();
3272bdfcea1SArmin Le Grand }
3282bdfcea1SArmin Le Grand 
3292bdfcea1SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
3302bdfcea1SArmin Le Grand 
NotifyItemUpdate(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState,const bool bIsEnabled)3312bdfcea1SArmin Le Grand void GraphicPropertyPanel::NotifyItemUpdate(
3322bdfcea1SArmin Le Grand     sal_uInt16 nSID,
3332bdfcea1SArmin Le Grand     SfxItemState eState,
33445da7d5eSAndre Fischer     const SfxPoolItem* pState,
33545da7d5eSAndre Fischer     const bool bIsEnabled)
3362bdfcea1SArmin Le Grand {
33745da7d5eSAndre Fischer     (void)bIsEnabled;
33845da7d5eSAndre Fischer 
339d74d90d6SArmin Le Grand     switch( nSID )
340d74d90d6SArmin Le Grand     {
341d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_LUMINANCE:
342d74d90d6SArmin Le Grand         {
343d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
344d74d90d6SArmin Le Grand             {
345d74d90d6SArmin Le Grand                 mpMtrBrightness->Enable();
346d74d90d6SArmin Le Grand                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
347d74d90d6SArmin Le Grand 
348d74d90d6SArmin Le Grand                 if(pItem)
349d74d90d6SArmin Le Grand                 {
350d74d90d6SArmin Le Grand                     const sal_Int64 nBright = pItem->GetValue();
351d74d90d6SArmin Le Grand                     mpMtrBrightness->SetValue(nBright);
352d74d90d6SArmin Le Grand                 }
353d74d90d6SArmin Le Grand             }
354d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
355d74d90d6SArmin Le Grand             {
356d74d90d6SArmin Le Grand                 mpMtrBrightness->Disable();
357d74d90d6SArmin Le Grand             }
358d74d90d6SArmin Le Grand             else
359d74d90d6SArmin Le Grand             {
360d74d90d6SArmin Le Grand                 mpMtrBrightness->Enable();
361d74d90d6SArmin Le Grand                 mpMtrBrightness->SetText(String());
362d74d90d6SArmin Le Grand             }
363d74d90d6SArmin Le Grand             break;
364d74d90d6SArmin Le Grand         }
365d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_CONTRAST:
366d74d90d6SArmin Le Grand         {
367d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
368d74d90d6SArmin Le Grand             {
369d74d90d6SArmin Le Grand                 mpMtrContrast->Enable();
370d74d90d6SArmin Le Grand                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
371d74d90d6SArmin Le Grand 
372d74d90d6SArmin Le Grand                 if(pItem)
373d74d90d6SArmin Le Grand                 {
374d74d90d6SArmin Le Grand                     const sal_Int64 nContrast = pItem->GetValue();
375d74d90d6SArmin Le Grand                     mpMtrContrast->SetValue(nContrast);
376d74d90d6SArmin Le Grand                 }
377d74d90d6SArmin Le Grand             }
378d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
379d74d90d6SArmin Le Grand             {
380d74d90d6SArmin Le Grand                 mpMtrContrast->Disable();
381d74d90d6SArmin Le Grand             }
382d74d90d6SArmin Le Grand             else
383d74d90d6SArmin Le Grand             {
384d74d90d6SArmin Le Grand                 mpMtrContrast->Enable();
385d74d90d6SArmin Le Grand                 mpMtrContrast->SetText(String());
386d74d90d6SArmin Le Grand             }
387d74d90d6SArmin Le Grand             break;
388d74d90d6SArmin Le Grand         }
389d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_TRANSPARENCE:
390d74d90d6SArmin Le Grand         {
391d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
392d74d90d6SArmin Le Grand             {
393d74d90d6SArmin Le Grand                 mpMtrTrans->Enable();
394d74d90d6SArmin Le Grand                 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
395d74d90d6SArmin Le Grand 
396d74d90d6SArmin Le Grand                 if(pItem)
397d74d90d6SArmin Le Grand                 {
398d74d90d6SArmin Le Grand                     const sal_Int64 nTrans = pItem->GetValue();
399d74d90d6SArmin Le Grand                     mpMtrTrans->SetValue(nTrans);
400d74d90d6SArmin Le Grand                 }
401d74d90d6SArmin Le Grand             }
402d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
403d74d90d6SArmin Le Grand             {
404d74d90d6SArmin Le Grand                 mpMtrTrans->Disable();
405d74d90d6SArmin Le Grand             }
406d74d90d6SArmin Le Grand             else
407d74d90d6SArmin Le Grand             {
408d74d90d6SArmin Le Grand                 mpMtrTrans->Enable();
409d74d90d6SArmin Le Grand                 mpMtrTrans->SetText(String());
410d74d90d6SArmin Le Grand             }
411d74d90d6SArmin Le Grand             break;
412d74d90d6SArmin Le Grand         }
413d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_MODE:
414d74d90d6SArmin Le Grand         {
415d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
416d74d90d6SArmin Le Grand             {
417d74d90d6SArmin Le Grand                 mpLBColorMode->Enable();
418d74d90d6SArmin Le Grand                 const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
419d74d90d6SArmin Le Grand 
420d74d90d6SArmin Le Grand                 if(pItem)
421d74d90d6SArmin Le Grand                 {
422d74d90d6SArmin Le Grand                     const sal_Int64 nTrans = pItem->GetValue();
423d74d90d6SArmin Le Grand                     mpLBColorMode->SelectEntryPos(nTrans);
424d74d90d6SArmin Le Grand                 }
425d74d90d6SArmin Le Grand             }
426d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
427d74d90d6SArmin Le Grand             {
428d74d90d6SArmin Le Grand                 mpLBColorMode->Disable();
429d74d90d6SArmin Le Grand             }
430d74d90d6SArmin Le Grand             else
431d74d90d6SArmin Le Grand             {
432d74d90d6SArmin Le Grand                 mpLBColorMode->Enable();
433d74d90d6SArmin Le Grand                 mpLBColorMode->SetNoSelection();
434d74d90d6SArmin Le Grand             }
435d74d90d6SArmin Le Grand             break;
436d74d90d6SArmin Le Grand         }
437d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_RED:
438d74d90d6SArmin Le Grand         {
439d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
440d74d90d6SArmin Le Grand             {
441d74d90d6SArmin Le Grand                 mpMtrRed->Enable();
442d74d90d6SArmin Le Grand                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
443d74d90d6SArmin Le Grand 
444d74d90d6SArmin Le Grand                 if(pItem)
445d74d90d6SArmin Le Grand                 {
446d74d90d6SArmin Le Grand                     const sal_Int64 nRed = pItem->GetValue();
447d74d90d6SArmin Le Grand                     mpMtrRed->SetValue( nRed );
448d74d90d6SArmin Le Grand                 }
449d74d90d6SArmin Le Grand             }
450d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
451d74d90d6SArmin Le Grand             {
452d74d90d6SArmin Le Grand                 mpMtrRed->Disable();
453d74d90d6SArmin Le Grand             }
454d74d90d6SArmin Le Grand             else
455d74d90d6SArmin Le Grand             {
456d74d90d6SArmin Le Grand                 mpMtrRed->Enable();
457d74d90d6SArmin Le Grand                 mpMtrRed->SetText(String());
458d74d90d6SArmin Le Grand             }
459d74d90d6SArmin Le Grand             break;
460d74d90d6SArmin Le Grand         }
461d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_GREEN:
462d74d90d6SArmin Le Grand         {
463d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
464d74d90d6SArmin Le Grand             {
465d74d90d6SArmin Le Grand                 mpMtrGreen->Enable();
466d74d90d6SArmin Le Grand                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
467d74d90d6SArmin Le Grand 
468d74d90d6SArmin Le Grand                 if(pItem)
469d74d90d6SArmin Le Grand                 {
470d74d90d6SArmin Le Grand                     const sal_Int64 nGreen = pItem->GetValue();
471d74d90d6SArmin Le Grand                     mpMtrGreen->SetValue( nGreen );
472d74d90d6SArmin Le Grand                 }
473d74d90d6SArmin Le Grand             }
474d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
475d74d90d6SArmin Le Grand             {
476d74d90d6SArmin Le Grand                 mpMtrGreen->Disable();
477d74d90d6SArmin Le Grand             }
478d74d90d6SArmin Le Grand             else
479d74d90d6SArmin Le Grand             {
480d74d90d6SArmin Le Grand                 mpMtrGreen->Enable();
481d74d90d6SArmin Le Grand                 mpMtrGreen->SetText(String());
482d74d90d6SArmin Le Grand             }
483d74d90d6SArmin Le Grand             break;
484d74d90d6SArmin Le Grand         }
485d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_BLUE:
486d74d90d6SArmin Le Grand         {
487d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
488d74d90d6SArmin Le Grand             {
489d74d90d6SArmin Le Grand                 mpMtrBlue->Enable();
490d74d90d6SArmin Le Grand                 const SfxInt16Item* pItem = dynamic_cast< const SfxInt16Item* >(pState);
491d74d90d6SArmin Le Grand 
492d74d90d6SArmin Le Grand                 if(pItem)
493d74d90d6SArmin Le Grand                 {
494d74d90d6SArmin Le Grand                     const sal_Int64 nBlue = pItem->GetValue();
495d74d90d6SArmin Le Grand                     mpMtrBlue->SetValue( nBlue );
496d74d90d6SArmin Le Grand                 }
497d74d90d6SArmin Le Grand             }
498d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
499d74d90d6SArmin Le Grand             {
500d74d90d6SArmin Le Grand                 mpMtrBlue->Disable();
501d74d90d6SArmin Le Grand             }
502d74d90d6SArmin Le Grand             else
503d74d90d6SArmin Le Grand             {
504d74d90d6SArmin Le Grand                 mpMtrBlue->Enable();
505d74d90d6SArmin Le Grand                 mpMtrBlue->SetText(String());
506d74d90d6SArmin Le Grand             }
507d74d90d6SArmin Le Grand             break;
508d74d90d6SArmin Le Grand         }
509d74d90d6SArmin Le Grand         case SID_ATTR_GRAF_GAMMA:
510d74d90d6SArmin Le Grand         {
511d74d90d6SArmin Le Grand             if(eState >= SFX_ITEM_AVAILABLE)
512d74d90d6SArmin Le Grand             {
513d74d90d6SArmin Le Grand                 mpMtrGamma->Enable();
514d74d90d6SArmin Le Grand                 const SfxUInt32Item* pItem = dynamic_cast< const SfxUInt32Item* >(pState);
515d74d90d6SArmin Le Grand 
516d74d90d6SArmin Le Grand                 if(pItem)
517d74d90d6SArmin Le Grand                 {
518d74d90d6SArmin Le Grand                     const sal_Int64 nGamma = pItem->GetValue();
519d74d90d6SArmin Le Grand                     mpMtrGamma->SetValue( nGamma );
520d74d90d6SArmin Le Grand                 }
521d74d90d6SArmin Le Grand             }
522d74d90d6SArmin Le Grand             else if(SFX_ITEM_DISABLED == eState)
523d74d90d6SArmin Le Grand             {
524d74d90d6SArmin Le Grand                 mpMtrGamma->Disable();
525d74d90d6SArmin Le Grand             }
526d74d90d6SArmin Le Grand             else
527d74d90d6SArmin Le Grand             {
528d74d90d6SArmin Le Grand                 mpMtrGamma->Enable();
529d74d90d6SArmin Le Grand                 mpMtrGamma->SetText(String());
530d74d90d6SArmin Le Grand             }
531d74d90d6SArmin Le Grand             break;
532d74d90d6SArmin Le Grand         }
533d74d90d6SArmin Le Grand     }
5342bdfcea1SArmin Le Grand }
5352bdfcea1SArmin Le Grand 
53645da7d5eSAndre Fischer 
53745da7d5eSAndre Fischer 
53845da7d5eSAndre Fischer 
GetBindings()5392bdfcea1SArmin Le Grand SfxBindings* GraphicPropertyPanel::GetBindings()
5402bdfcea1SArmin Le Grand {
5412bdfcea1SArmin Le Grand     return mpBindings;
5422bdfcea1SArmin Le Grand }
5432bdfcea1SArmin Le Grand 
5442bdfcea1SArmin Le Grand 
5452bdfcea1SArmin Le Grand 
546*6a606da0SAndre Fischer 
Resize(void)547*6a606da0SAndre Fischer void GraphicPropertyPanel::Resize (void)
548*6a606da0SAndre Fischer {
549*6a606da0SAndre Fischer     maLayouter.Layout();
550*6a606da0SAndre Fischer }
551*6a606da0SAndre Fischer 
552*6a606da0SAndre Fischer 
553*6a606da0SAndre Fischer 
554*6a606da0SAndre Fischer }} // end of namespace ::svx::sidebar
555