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_LINEPAGE_HXX
23 #define SVX_PROPERTYPANEL_LINEPAGE_HXX
24 
25 #include <svx/xdash.hxx>
26 #include <vcl/ctrl.hxx>
27 #include <sfx2/sidebar/SidebarPanelBase.hxx>
28 #include <sfx2/sidebar/ControllerItem.hxx>
29 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
30 #include <vcl/fixed.hxx>
31 #include <vcl/field.hxx>
32 #include <boost/scoped_ptr.hpp>
33 #include <boost/scoped_array.hpp>
34 #include <svx/sidebar/ColorPopup.hxx>
35 #include "LineStylePopup.hxx"
36 #include "LineWidthPopup.hxx"
37 
38 
39 namespace svx { class ToolboxButtonColorUpdater; }
40 class SvxLineColorPage;
41 class SvxLineStylePage;
42 class SvxLineWidthPage;
43 class XLineStyleItem;
44 class XLineDashItem;
45 class XLineStartItem;
46 class XLineEndItem;
47 class XLineEndList;
48 class ListBox;
49 class ToolBox;
50 class FloatingWindow;
51 
52 namespace {
53     const String Dash_Name[] =
54     {
55         String("Ultrafine dashed", 16,  RTL_TEXTENCODING_ASCII_US),				//0
56         String("Dashed (variable)", 17,RTL_TEXTENCODING_ASCII_US ),				//6
57         String("Fine dashed (variable)",22,  RTL_TEXTENCODING_ASCII_US),		//5
58         String("Fine dashed", 11, RTL_TEXTENCODING_ASCII_US),					//1
59         String("Fine dotted", 11, RTL_TEXTENCODING_ASCII_US),					//3
60         String("Ultrafine dotted (variable)",27, RTL_TEXTENCODING_ASCII_US),	//8
61         String("3 dashes 3 dots (variable)", 26, RTL_TEXTENCODING_ASCII_US),	//7
62         String("2 dots 1 dash",13,RTL_TEXTENCODING_ASCII_US  )	,				//9
63         String("Ultrafine 2 dots 3 dashes",  25, RTL_TEXTENCODING_ASCII_US),	//2
64         String("Line with fine dots", 19, RTL_TEXTENCODING_ASCII_US)			//4
65     };
66 
67 
68     const XDash Dash_Set[] =
69     {
70         //Dash, dots, dotlen, dash, dashlen, distance
71         XDash(XDASH_RECT, 1, 51, 1, 51, 51),									//0
72         XDash(XDASH_RECTRELATIVE, 1, 197, 0,0, 127),							//6
73         XDash(XDASH_RECTRELATIVE, 1, 197,0,0,197),								//5
74         XDash(XDASH_RECT, 1,508, 1,508, 508),									//1
75         XDash(XDASH_RECT, 1,  0, 0,  0, 457),									//3
76         XDash(XDASH_RECTRELATIVE, 1,  0, 0, 0, 50),								//8
77         XDash(XDASH_RECTRELATIVE, 3, 197, 3, 0, 100),							//7
78         XDash(XDASH_RECT, 2, 0, 1, 203,203)	,									//9
79         XDash(XDASH_RECT, 2, 51, 3,254, 127),									//2
80         XDash(XDASH_RECT, 1,2007,10, 0, 152)									//4
81     };
82 
83     #define SIDEBAR_LINE_WIDTH_GLOBAL_VALUE String("PopupPanel_LineWidth", 20, RTL_TEXTENCODING_ASCII_US)
84 
85 } //end of anonymous namespace
86 
87 
88 namespace svx { namespace sidebar {
89 
90 class PopupContainer;
91 class ColorPopup;
92 class LineStyleControl;
93 class LineWidthControl;
94 
95 
96 class LinePropertyPanel
97 :   public Control,
98     public ::sfx2::sidebar::IContextChangeReceiver,
99     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
100 {
101 private:
102     friend class ::SvxLineStylePage;
103     friend class ::SvxLineWidthPage;
104 
105 public:
106     static LinePropertyPanel* Create(
107         Window* pParent,
108         const cssu::Reference<css::frame::XFrame>& rxFrame,
109         SfxBindings* pBindings);
110 
111     virtual void DataChanged(
112         const DataChangedEvent& rEvent);
113 
114     virtual void HandleContextChange(
115         const ::sfx2::sidebar::EnumContext aContext);
116 
117     virtual void NotifyItemUpdate(
118         const sal_uInt16 nSId,
119         const SfxItemState eState,
120         const SfxPoolItem* pState);
121 
122     SfxBindings* GetBindings();
123 
124     void SetLineDashItem(XLineDashItem* pDash);
125     void SetLineStyleItem(XLineStyleItem* pStyle);
126 
127     void SetWidth(long nWidth);
128     void SetWidthIcon(int n);
129     void SetWidthIcon();
130 
131     void EndLineStylePopupMode (void);
132     void EndLineWidthPopupMode (void);
133 
134 private:
135     //ui controls
136     ::boost::scoped_ptr< FixedText >                        mpFTWidth;
137     ::boost::scoped_ptr< Window >                           mpTBWidthBackground;
138     ::boost::scoped_ptr< ToolBox >                          mpTBWidth;
139     ::boost::scoped_ptr< FixedText >                        mpFTColor;
140     ::boost::scoped_ptr< Window >                           mpTBColorBackground;
141     ::boost::scoped_ptr< ToolBox >                          mpTBColor;
142     ::boost::scoped_ptr< FixedText >                        mpFTStyle;
143     ::boost::scoped_ptr< Window >                           mpTBStyleBackground;
144     ::boost::scoped_ptr< ToolBox >                          mpTBStyle;
145     ::boost::scoped_ptr< FixedText >                        mpFTTrancparency;
146     ::boost::scoped_ptr< MetricField >                      mpMFTransparent;
147     ::boost::scoped_ptr< FixedText >                        mpFTArrow;
148     ::boost::scoped_ptr< ListBox >                          mpLBStart;
149     ::boost::scoped_ptr< ListBox >                          mpLBEnd;
150     ::boost::scoped_ptr< FixedText >                        mpFTEdgeStyle;
151     ::boost::scoped_ptr< ListBox >                          mpLBEdgeStyle;
152     ::boost::scoped_ptr< FixedText >                        mpFTCapStyle;
153     ::boost::scoped_ptr< ListBox >                          mpLBCapStyle;
154 
155     //ControllerItem
156     ::sfx2::sidebar::ControllerItem                         maStyleControl;
157     ::sfx2::sidebar::ControllerItem                         maDashControl;
158     ::sfx2::sidebar::ControllerItem                         maWidthControl;
159     ::sfx2::sidebar::ControllerItem                         maColorControl;
160     ::sfx2::sidebar::ControllerItem                         maStartControl;
161     ::sfx2::sidebar::ControllerItem                         maEndControl;
162     ::sfx2::sidebar::ControllerItem                         maLineEndListControl;
163     ::sfx2::sidebar::ControllerItem                         maTransControl;
164     ::sfx2::sidebar::ControllerItem                         maEdgeStyle;
165     ::sfx2::sidebar::ControllerItem                         maCapStyle;
166 
167     Color                                                   maColor;
168     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
169     ::boost::scoped_ptr< XLineStyleItem >                   mpStyleItem;
170     ::boost::scoped_ptr< XLineDashItem >                    mpDashItem;
171     sal_uInt16                                              mnTrans;
172     SfxMapUnit                                              meMapUnit;
173     sal_Int32                                               mnWidthCoreValue;
174     XLineEndList*                                           mpLineEndList;
175     ::boost::scoped_ptr< XLineStartItem >                   mpStartItem;
176     ::boost::scoped_ptr< XLineEndItem >                     mpEndItem;
177 
178     //popup windows
179     ColorPopup maColorPopup;
180     LineStylePopup maLineStylePopup;
181     LineWidthPopup maLineWidthPopup;
182 
183     // images from ressource
184     Image                                                   maIMGColor;
185     Image                                                   maIMGNone;
186 
187     // multi-images
188     ::boost::scoped_array<Image>                            mpIMGStyleIcon;
189     ::boost::scoped_array<Image>                            mpIMGWidthIcon;
190     ::boost::scoped_array<Image>                            mpIMGStyleIconH;	//high contrast
191     ::boost::scoped_array<Image>                            mpIMGWidthIconH;	//high contrast
192 
193     cssu::Reference< css::frame::XFrame >                   mxFrame;
194     ::sfx2::sidebar::EnumContext                            maContext;
195     SfxBindings*                                            mpBindings;
196 
197     /// bitfield
198 	bool				mbColorAvailable : 1;
199 	bool				mbStyleAvailable : 1;
200 	bool				mbDashAvailable : 1;
201 	bool				mbTransAvailable : 1;
202 	bool				mbWidthValuable : 1;
203 	bool				mbStartAvailable : 1;
204 	bool				mbEndAvailable : 1;
205 
206     void SetupIcons(void);
207 	void Initialize();
208 	void FillLineEndList();
209 	void SelectEndStyle(bool bStart);
210 
211 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
212 	DECL_LINK(ImplWidthPopupModeEndHdl, FloatingWindow* );
213 	DECL_LINK(ToolboxColorSelectHdl, ToolBox*);
214 	DECL_LINK(ToolboxStyleSelectHdl, ToolBox*);
215 	DECL_LINK(ToolboxWidthSelectHdl, ToolBox*);
216 	DECL_LINK(ChangeTransparentHdl , void *);
217 	DECL_LINK(ChangeStartHdl, void *);
218 	DECL_LINK(ChangeEndHdl, void *);
219 	DECL_LINK(ChangeEdgeStyleHdl, void *);
220 	DECL_LINK(ChangeCapStyleHdl, void *);
221 
222     // constructor/destuctor
223     LinePropertyPanel(
224         Window* pParent,
225         const cssu::Reference<css::frame::XFrame>& rxFrame,
226         SfxBindings* pBindings);
227     virtual ~LinePropertyPanel(void);
228 
229     void SetStyleIcon();
230     void SetColor(
231         const String& rsColorName,
232         const Color aColor);
233 
234     PopupControl* CreateColorPopupControl (PopupContainer* pParent);
235     PopupControl* CreateLineStylePopupControl (PopupContainer* pParent);
236     PopupControl* CreateLineWidthPopupControl (PopupContainer* pParent);
237 };
238 
239 } } // end of namespace svx::sidebar
240 
241 #endif
242 
243 // eof
244