1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef SVX_PROPERTYPANEL_AREAPAGE_HXX
23 #define SVX_PROPERTYPANEL_AREAPAGE_HXX
24 
25 #include "sidebar/ColorPopup.hxx"
26 #include "AreaTransparencyGradientPopup.hxx"
27 #include <vcl/ctrl.hxx>
28 #include <sfx2/sidebar/SidebarPanelBase.hxx>
29 #include <sfx2/sidebar/ControllerItem.hxx>
30 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
31 #include <svx/xgrad.hxx>
32 #include <svx/itemwin.hxx>
33 #include <svx/xfillit0.hxx>
34 #include <svx/xflclit.hxx>
35 #include <svx/xflgrit.hxx>
36 #include <svx/xflhtit.hxx>
37 #include <svx/xbtmpit.hxx>
38 #include <svx/drawitem.hxx>
39 #include <vcl/lstbox.hxx>
40 #include <vcl/field.hxx>
41 #include <vcl/fixed.hxx>
42 #include <svl/intitem.hxx>
43 #include <svx/tbxcolorupdate.hxx>
44 #include <com/sun/star/ui/XUIElement.hpp>
45 #include <boost/scoped_ptr.hpp>
46 
47 
48 class XFillFloatTransparenceItem;
49 namespace svx { class ToolboxButtonColorUpdater; }
50 
51 
52 namespace svx { namespace sidebar {
53 
54 class PopupContainer;
55 class AreaTransparencyGradientControl;
56 
57 class AreaPropertyPanel
58 :   public Control,
59     public ::sfx2::sidebar::IContextChangeReceiver,
60     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
61 {
62 public:
63     static AreaPropertyPanel* Create(
64         Window* pParent,
65         const cssu::Reference<css::frame::XFrame>& rxFrame,
66         SfxBindings* pBindings);
67 
68     virtual void DataChanged(
69         const DataChangedEvent& rEvent);
70 
71     virtual void HandleContextChange(
72         const ::sfx2::sidebar::EnumContext aContext);
73 
74     virtual void NotifyItemUpdate(
75         const sal_uInt16 nSId,
76         const SfxItemState eState,
77         const SfxPoolItem* pState);
78 
79     SfxBindings* GetBindings();
80     void ShowMenu (void);
81 
82     const static sal_Int32 DEFAULT_CENTERX;
83     const static sal_Int32 DEFAULT_CENTERY;
84     const static sal_Int32 DEFAULT_ANGLE;
85     const static sal_Int32 DEFAULT_STARTVALUE;
86     const static sal_Int32 DEFAULT_ENDVALUE;
87     const static sal_Int32 DEFAULT_BORDER;
88 
89     XGradient GetGradient (const XGradientStyle eStyle) const;
90     void SetGradient (const XGradient& rGradient);
91     sal_Int32 GetSelectedTransparencyTypeIndex (void) const;
92 
93 private:
94     sal_uInt16                                          meLastXFS;
95     Color                                               maLastColor;
96 
97     sal_uInt16                                          mnLastPosGradient;
98     sal_uInt16                                          mnLastPosHatch;
99     sal_uInt16                                          mnLastPosBitmap;
100     sal_uInt16                                          mnLastTransSolid;
101 
102     XGradient                                           maGradientLinear;
103     XGradient                                           maGradientAxial;
104     XGradient                                           maGradientRadial;
105     XGradient                                           maGradientElliptical;
106     XGradient                                           maGradientSquare;
107     XGradient                                           maGradientRect;
108 
109     //ui controls
110     ::boost::scoped_ptr< FixedText >                    mpColorTextFT;
111     ::boost::scoped_ptr< SvxFillTypeBox >               mpLbFillType;
112     ::boost::scoped_ptr< SvxFillAttrBox >               mpLbFillAttr;
113     ::boost::scoped_ptr< Window >                       mpToolBoxColorBackground;
114     ::boost::scoped_ptr< ToolBox >                      mpToolBoxColor; // for new color picker
115     ::boost::scoped_ptr< FixedText >                    mpTrspTextFT;
116     ::boost::scoped_ptr< ListBox >                      mpLBTransType;
117     ::boost::scoped_ptr< MetricField >                  mpMTRTransparent;
118     ::boost::scoped_ptr< Window >                       mpBTNGradientBackground;
119     ::boost::scoped_ptr< ToolBox >                      mpBTNGradient;
120 
121     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
122 
123     ::boost::scoped_ptr< XFillStyleItem >               mpStyleItem;
124     ::boost::scoped_ptr< XFillColorItem >               mpColorItem;
125     ::boost::scoped_ptr< XFillGradientItem >            mpFillGradientItem;
126     ::boost::scoped_ptr< XFillHatchItem >               mpHatchItem;
127     ::boost::scoped_ptr< XFillBitmapItem >              mpBitmapItem;
128     ::boost::scoped_ptr< SvxColorTableItem >            mpColorTableItem;
129     ::boost::scoped_ptr< SvxGradientListItem >          mpGradientListItem;
130     ::boost::scoped_ptr< SvxHatchListItem >             mpHatchListItem;
131     ::boost::scoped_ptr< SvxBitmapListItem >            mpBitmapListItem;
132 
133     ::sfx2::sidebar::ControllerItem                     maStyleControl;
134     ::sfx2::sidebar::ControllerItem                     maColorControl;
135     ::sfx2::sidebar::ControllerItem                     maGradientControl;
136     ::sfx2::sidebar::ControllerItem                     maHatchControl;
137     ::sfx2::sidebar::ControllerItem                     maBitmapControl;
138     ::sfx2::sidebar::ControllerItem                     maColorTableControl;
139     ::sfx2::sidebar::ControllerItem                     maGradientListControl;
140     ::sfx2::sidebar::ControllerItem                     maHatchListControl;
141     ::sfx2::sidebar::ControllerItem                     maBitmapListControl;
142     ::sfx2::sidebar::ControllerItem                     maFillTransparenceController;
143     ::sfx2::sidebar::ControllerItem                     maFillFloatTransparenceController;
144 
145     Image                                               maImgAxial;
146     Image                                               maImgElli;
147     Image                                               maImgQuad;
148     Image                                               maImgRadial;
149     Image                                               maImgSquare;
150     Image                                               maImgLinear;
151     Image                                               maImgColor;
152 
153     //for high contract
154     Image                                               maImgAxialH;
155     Image                                               maImgElliH;
156     Image                                               maImgQuadH;
157     Image                                               maImgRadialH;
158     Image                                               maImgSquareH;
159     Image                                               maImgLinearH;
160     Image                                               maImgColorH;
161 
162     String                                              msHelpFillType;
163     String                                              msHelpFillAttr;
164 
165     AreaTransparencyGradientPopup maTrGrPopup;
166     ColorPopup maColorPopup;
167 
168     ::boost::scoped_ptr< XFillFloatTransparenceItem >   mpFloatTransparenceItem;
169     ::boost::scoped_ptr< SfxUInt16Item >                mpTransparanceItem;
170 
171     cssu::Reference<css::frame::XFrame>                 mxFrame;
172     ::sfx2::sidebar::EnumContext                        maContext;
173     SfxBindings*                                        mpBindings;
174 
175     /// bitfield
176     bool                                                mbTBShow : 1;
177     bool                                                mbColorAvail : 1;
178 
179     DECL_LINK(SelectFillTypeHdl, ListBox* );
180     DECL_LINK(SelectFillAttrHdl, ListBox* );
181     DECL_LINK(ChangeTrgrTypeHdl_Impl, void*);
182     DECL_LINK(ModifyTransparentHdl_Impl, void*);
183     DECL_LINK( ImplPopupModeEndHdl, FloatingWindow* );
184 
185     // for transparency gradient
186     PopupControl* CreateTransparencyGradientControl (PopupContainer* pParent);
187     DECL_LINK( ClickTrGrHdl_Impl, ToolBox* );
188 
189     // for color picker
190     PopupControl* CreateColorPopupControl (PopupContainer* pParent);
191     DECL_LINK(ToolBoxColorDropHdl, ToolBox *); //for new color picker
192 
193     // constructor/destuctor
194     AreaPropertyPanel(
195         Window* pParent,
196         const cssu::Reference<css::frame::XFrame>& rxFrame,
197         SfxBindings* pBindings);
198     virtual ~AreaPropertyPanel(void);
199 
200     void SetupIcons(void);
201     void Initialize();
202     void Update();
203     void ImpUpdateTransparencies();
204 
205     Color GetLastColor (void) const;
206     void SetColor (
207         const String& rsColorName,
208         const Color aColor);
209 };
210 
211 
212 } } // end of namespace ::svx::sidebar
213 
214 
215 
216 #endif // SVX_PROPERTYPANEL_AREAPAGE_HXX
217