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 "LineWidthPopup.hxx"
35 
36 
37 namespace svx { class ToolboxButtonColorUpdater; }
38 class SvxLineColorPage;
39 class SvxLineStylePage;
40 class SvxLineWidthPage;
41 class XLineStyleItem;
42 class XLineDashItem;
43 class XLineStartItem;
44 class XLineEndItem;
45 class XLineEndList;
46 class XDashList;
47 class ListBox;
48 class ToolBox;
49 class FloatingWindow;
50 
51 namespace {
52     #define SIDEBAR_LINE_WIDTH_GLOBAL_VALUE String("PopupPanel_LineWidth", 20, RTL_TEXTENCODING_ASCII_US)
53 } //end of anonymous namespace
54 
55 namespace svx { namespace sidebar {
56 
57 class PopupContainer;
58 class ColorPopup;
59 class LineWidthControl;
60 
61 
62 class LinePropertyPanel
63 :   public Control,
64     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
65 {
66 private:
67     friend class ::SvxLineStylePage;
68     friend class ::SvxLineWidthPage;
69 
70 public:
71     static LinePropertyPanel* Create(
72         Window* pParent,
73         const cssu::Reference<css::frame::XFrame>& rxFrame,
74         SfxBindings* pBindings);
75 
76     virtual void DataChanged(
77         const DataChangedEvent& rEvent);
78 
79     virtual void NotifyItemUpdate(
80         const sal_uInt16 nSId,
81         const SfxItemState eState,
82         const SfxPoolItem* pState);
83 
84     SfxBindings* GetBindings();
85 
86     void SetWidth(long nWidth);
87     void SetWidthIcon(int n);
88     void SetWidthIcon();
89 
90     void EndLineWidthPopupMode (void);
91 
92 private:
93     //ui controls
94     ::boost::scoped_ptr< FixedText >                        mpFTWidth;
95     ::boost::scoped_ptr< Window >                           mpTBWidthBackground;
96     ::boost::scoped_ptr< ToolBox >                          mpTBWidth;
97     ::boost::scoped_ptr< FixedText >                        mpFTColor;
98     ::boost::scoped_ptr< Window >                           mpTBColorBackground;
99     ::boost::scoped_ptr< ToolBox >                          mpTBColor;
100     ::boost::scoped_ptr< FixedText >                        mpFTStyle;
101     ::boost::scoped_ptr< ListBox >                          mpLBStyle;
102     ::boost::scoped_ptr< FixedText >                        mpFTTrancparency;
103     ::boost::scoped_ptr< MetricField >                      mpMFTransparent;
104     ::boost::scoped_ptr< FixedText >                        mpFTArrow;
105     ::boost::scoped_ptr< ListBox >                          mpLBStart;
106     ::boost::scoped_ptr< ListBox >                          mpLBEnd;
107     ::boost::scoped_ptr< FixedText >                        mpFTEdgeStyle;
108     ::boost::scoped_ptr< ListBox >                          mpLBEdgeStyle;
109     ::boost::scoped_ptr< FixedText >                        mpFTCapStyle;
110     ::boost::scoped_ptr< ListBox >                          mpLBCapStyle;
111 
112     //ControllerItem
113     ::sfx2::sidebar::ControllerItem                         maStyleControl;
114     ::sfx2::sidebar::ControllerItem                         maDashControl;
115     ::sfx2::sidebar::ControllerItem                         maWidthControl;
116     ::sfx2::sidebar::ControllerItem                         maColorControl;
117     ::sfx2::sidebar::ControllerItem                         maStartControl;
118     ::sfx2::sidebar::ControllerItem                         maEndControl;
119     ::sfx2::sidebar::ControllerItem                         maLineEndListControl;
120     ::sfx2::sidebar::ControllerItem                         maLineStyleListControl;
121     ::sfx2::sidebar::ControllerItem                         maTransControl;
122     ::sfx2::sidebar::ControllerItem                         maEdgeStyle;
123     ::sfx2::sidebar::ControllerItem                         maCapStyle;
124 
125     Color                                                   maColor;
126     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
127     ::boost::scoped_ptr< XLineStyleItem >                   mpStyleItem;
128     ::boost::scoped_ptr< XLineDashItem >                    mpDashItem;
129     sal_uInt16                                              mnTrans;
130     SfxMapUnit                                              meMapUnit;
131     sal_Int32                                               mnWidthCoreValue;
132     XLineEndList*                                           mpLineEndList;
133     XDashList*                                              mpLineStyleList;
134     ::boost::scoped_ptr< XLineStartItem >                   mpStartItem;
135     ::boost::scoped_ptr< XLineEndItem >                     mpEndItem;
136 
137     //popup windows
138     ColorPopup maColorPopup;
139     LineWidthPopup maLineWidthPopup;
140 
141     // images from ressource
142     Image                                                   maIMGColor;
143     Image                                                   maIMGNone;
144 
145     // multi-images
146     ::boost::scoped_array<Image>                            mpIMGWidthIcon;
147     ::boost::scoped_array<Image>                            mpIMGWidthIconH;	//high contrast
148 
149     cssu::Reference< css::frame::XFrame >                   mxFrame;
150     SfxBindings*                                            mpBindings;
151 
152     /// bitfield
153 	bool				mbColorAvailable : 1;
154 	bool				mbStyleAvailable : 1;
155 	bool				mbDashAvailable : 1;
156 	bool				mbTransAvailable : 1;
157 	bool				mbWidthValuable : 1;
158 	bool				mbStartAvailable : 1;
159 	bool				mbEndAvailable : 1;
160 
161     void SetupIcons(void);
162 	void Initialize();
163 	void FillLineEndList();
164 	void FillLineStyleList();
165 	void SelectEndStyle(bool bStart);
166 	void SelectLineStyle();
167 
168 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
169 	DECL_LINK(ImplWidthPopupModeEndHdl, FloatingWindow* );
170 	DECL_LINK(ToolboxColorSelectHdl, ToolBox*);
171 	DECL_LINK(ChangeLineStyleHdl, ToolBox*);
172 	DECL_LINK(ToolboxWidthSelectHdl, ToolBox*);
173 	DECL_LINK(ChangeTransparentHdl , void *);
174 	DECL_LINK(ChangeStartHdl, void *);
175 	DECL_LINK(ChangeEndHdl, void *);
176 	DECL_LINK(ChangeEdgeStyleHdl, void *);
177 	DECL_LINK(ChangeCapStyleHdl, void *);
178 
179     // constructor/destuctor
180     LinePropertyPanel(
181         Window* pParent,
182         const cssu::Reference<css::frame::XFrame>& rxFrame,
183         SfxBindings* pBindings);
184     virtual ~LinePropertyPanel(void);
185 
186     void SetColor(
187         const String& rsColorName,
188         const Color aColor);
189 
190     PopupControl* CreateColorPopupControl (PopupContainer* pParent);
191     PopupControl* CreateLineWidthPopupControl (PopupContainer* pParent);
192 };
193 
194 } } // end of namespace svx::sidebar
195 
196 #endif
197 
198 // eof
199