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