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 <vcl/fixed.hxx>
30 #include <vcl/field.hxx>
31 #include <boost/scoped_ptr.hpp>
32 #include <boost/scoped_array.hpp>
33 #include "sidebar/ColorPopup.hxx"
34 #include "LineStylePopup.hxx"
35 #include "LineWidthPopup.hxx"
36 
37 
38 namespace svx { class ToolboxButtonColorUpdater; }
39 class SvxLineColorPage;
40 class SvxLineStylePage;
41 class SvxLineWidthPage;
42 class XLineStyleItem;
43 class XLineDashItem;
44 class XLineStartItem;
45 class XLineEndItem;
46 class LineEndLB_LPP;
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::SidebarPanelBase::ContextChangeReceiverInterface,
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     void ShowMenu (void);
124 
125     void SetLineDashItem(XLineDashItem* pDash);
126     void SetLineStyleItem(XLineStyleItem* pStyle);
127 
128     void SetWidth(long nWidth);
129     void SetWidthIcon(int n);
130     void SetWidthIcon();
131 
132     void EndLineStylePopupMode (void);
133     void EndLineWidthPopupMode (void);
134 
135 private:
136     //ui controls
137     ::boost::scoped_ptr< FixedText >                        mpFTWidth;
138     ::boost::scoped_ptr< Window >                           mpTBWidthBackground;
139     ::boost::scoped_ptr< ToolBox >                          mpTBWidth;
140     ::boost::scoped_ptr< FixedText >                        mpFTColor;
141     ::boost::scoped_ptr< Window >                           mpTBColorBackground;
142     ::boost::scoped_ptr< ToolBox >                          mpTBColor;
143     ::boost::scoped_ptr< FixedText >                        mpFTStyle;
144     ::boost::scoped_ptr< Window >                           mpTBStyleBackground;
145     ::boost::scoped_ptr< ToolBox >                          mpTBStyle;
146     ::boost::scoped_ptr< FixedText >                        mpFTTrancparency;
147     ::boost::scoped_ptr< MetricField >                      mpMFTransparent;
148     ::boost::scoped_ptr< FixedText >                        mpFTArrow;
149     ::boost::scoped_ptr< LineEndLB_LPP >                    mpLBStart;
150     ::boost::scoped_ptr< LineEndLB_LPP >                    mpLBEnd;
151     ::boost::scoped_ptr< FixedText >                        mpFTEdgeStyle;
152     ::boost::scoped_ptr< ListBox >                          mpLBEdgeStyle;
153     ::boost::scoped_ptr< FixedText >                        mpFTCapStyle;
154     ::boost::scoped_ptr< ListBox >                          mpLBCapStyle;
155 
156     //ControllerItem
157     ::sfx2::sidebar::ControllerItem                         maStyleControl;
158     ::sfx2::sidebar::ControllerItem                         maDashControl;
159     ::sfx2::sidebar::ControllerItem                         maWidthControl;
160     ::sfx2::sidebar::ControllerItem                         maColorControl;
161     ::sfx2::sidebar::ControllerItem                         maStartControl;
162     ::sfx2::sidebar::ControllerItem                         maEndControl;
163     ::sfx2::sidebar::ControllerItem                         maLineEndListControl;
164     ::sfx2::sidebar::ControllerItem                         maTransControl;
165     ::sfx2::sidebar::ControllerItem                         maEdgeStyle;
166     ::sfx2::sidebar::ControllerItem                         maCapStyle;
167 
168     Color                                                   maColor;
169     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
170     ::boost::scoped_ptr< XLineStyleItem >                   mpStyleItem;
171     ::boost::scoped_ptr< XLineDashItem >                    mpDashItem;
172     sal_uInt16                                              mnTrans;
173     SfxMapUnit                                              meMapUnit;
174     sal_Int32                                               mnWidthCoreValue;
175     XLineEndList*                                           mpLineEndList;
176     ::boost::scoped_ptr< XLineStartItem >                   mpStartItem;
177     ::boost::scoped_ptr< XLineEndItem >                     mpEndItem;
178 
179     //popup windows
180     ColorPopup maColorPopup;
181     LineStylePopup maLineStylePopup;
182     LineWidthPopup maLineWidthPopup;
183 
184     // images from ressource
185     Image                                                   maIMGColor;
186     Image                                                   maIMGNone;
187 
188     // multi-images
189     ::boost::scoped_array<Image>                            mpIMGStyleIcon;
190     ::boost::scoped_array<Image>                            mpIMGWidthIcon;
191     ::boost::scoped_array<Image>                            mpIMGStyleIconH;	//high contrast
192     ::boost::scoped_array<Image>                            mpIMGWidthIconH;	//high contrast
193 
194     cssu::Reference< css::frame::XFrame >                   mxFrame;
195     ::sfx2::sidebar::EnumContext                            maContext;
196     SfxBindings*                                            mpBindings;
197 
198     /// bitfield
199 	bool				mbColorAvailable : 1;
200 	bool				mbStyleAvailable : 1;
201 	bool				mbDashAvailable : 1;
202 	bool				mbTransAvailable : 1;
203 	bool				mbWidthValuable : 1;
204 	bool				mbStartAvailable : 1;
205 	bool				mbEndAvailable : 1;
206 
207     void SetupIcons(void);
208 	void Initialize();
209 	void FillLineEndList();
210 	void SelectEndStyle(bool bStart);
211 
212 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
213 	DECL_LINK(ImplWidthPopupModeEndHdl, FloatingWindow* );
214 	DECL_LINK(ToolboxColorSelectHdl, ToolBox*);
215 	DECL_LINK(ToolboxStyleSelectHdl, ToolBox*);
216 	DECL_LINK(ToolboxWidthSelectHdl, ToolBox*);
217 	DECL_LINK(ChangeTransparentHdl , void *);
218 	DECL_LINK(ChangeStartHdl, void *);
219 	DECL_LINK(ChangeEndHdl, void *);
220 	DECL_LINK(ChangeEdgeStyleHdl, void *);
221 	DECL_LINK(ChangeCapStyleHdl, void *);
222 
223     // constructor/destuctor
224     LinePropertyPanel(
225         Window* pParent,
226         const cssu::Reference<css::frame::XFrame>& rxFrame,
227         SfxBindings* pBindings);
228     virtual ~LinePropertyPanel(void);
229 
230     void SetStyleIcon();
231     void SetColor(
232         const String& rsColorName,
233         const Color aColor);
234 
235     PopupControl* CreateColorPopupControl (PopupContainer* pParent);
236     PopupControl* CreateLineStylePopupControl (PopupContainer* pParent);
237     PopupControl* CreateLineWidthPopupControl (PopupContainer* pParent);
238 };
239 
240 } } // end of namespace svx::sidebar
241 
242 #endif
243