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         const bool bIsEnabled);
84 
85     SfxBindings* GetBindings();
86 
87     void SetWidth(long nWidth);
88     void SetWidthIcon(int n);
89     void SetWidthIcon();
90 
91     void EndLineWidthPopupMode (void);
92 
93 private:
94     //ui controls
95     ::boost::scoped_ptr< FixedText >                        mpFTWidth;
96     ::boost::scoped_ptr< Window >                           mpTBWidthBackground;
97     ::boost::scoped_ptr< ToolBox >                          mpTBWidth;
98     ::boost::scoped_ptr< FixedText >                        mpFTColor;
99     ::boost::scoped_ptr< Window >                           mpTBColorBackground;
100     ::boost::scoped_ptr< ToolBox >                          mpTBColor;
101     ::boost::scoped_ptr< FixedText >                        mpFTStyle;
102     ::boost::scoped_ptr< ListBox >                          mpLBStyle;
103     ::boost::scoped_ptr< FixedText >                        mpFTTrancparency;
104     ::boost::scoped_ptr< MetricField >                      mpMFTransparent;
105     ::boost::scoped_ptr< FixedText >                        mpFTArrow;
106     ::boost::scoped_ptr< ListBox >                          mpLBStart;
107     ::boost::scoped_ptr< ListBox >                          mpLBEnd;
108     ::boost::scoped_ptr< FixedText >                        mpFTEdgeStyle;
109     ::boost::scoped_ptr< ListBox >                          mpLBEdgeStyle;
110     ::boost::scoped_ptr< FixedText >                        mpFTCapStyle;
111     ::boost::scoped_ptr< ListBox >                          mpLBCapStyle;
112 
113     //ControllerItem
114     ::sfx2::sidebar::ControllerItem                         maStyleControl;
115     ::sfx2::sidebar::ControllerItem                         maDashControl;
116     ::sfx2::sidebar::ControllerItem                         maWidthControl;
117     ::sfx2::sidebar::ControllerItem                         maColorControl;
118     ::sfx2::sidebar::ControllerItem                         maStartControl;
119     ::sfx2::sidebar::ControllerItem                         maEndControl;
120     ::sfx2::sidebar::ControllerItem                         maLineEndListControl;
121     ::sfx2::sidebar::ControllerItem                         maLineStyleListControl;
122     ::sfx2::sidebar::ControllerItem                         maTransControl;
123     ::sfx2::sidebar::ControllerItem                         maEdgeStyle;
124     ::sfx2::sidebar::ControllerItem                         maCapStyle;
125 
126     Color                                                   maColor;
127     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpColorUpdater;
128     ::boost::scoped_ptr< XLineStyleItem >                   mpStyleItem;
129     ::boost::scoped_ptr< XLineDashItem >                    mpDashItem;
130     sal_uInt16                                              mnTrans;
131     SfxMapUnit                                              meMapUnit;
132     sal_Int32                                               mnWidthCoreValue;
133     XLineEndList*                                           mpLineEndList;
134     XDashList*                                              mpLineStyleList;
135     ::boost::scoped_ptr< XLineStartItem >                   mpStartItem;
136     ::boost::scoped_ptr< XLineEndItem >                     mpEndItem;
137 
138     //popup windows
139     ColorPopup maColorPopup;
140     LineWidthPopup maLineWidthPopup;
141 
142     // images from ressource
143     Image                                                   maIMGColor;
144     Image                                                   maIMGNone;
145 
146     // multi-images
147     ::boost::scoped_array<Image>                            mpIMGWidthIcon;
148     ::boost::scoped_array<Image>                            mpIMGWidthIconH;	//high contrast
149 
150     cssu::Reference< css::frame::XFrame >                   mxFrame;
151     SfxBindings*                                            mpBindings;
152 
153     /// bitfield
154 	bool				mbColorAvailable : 1;
155 	bool				mbWidthValuable : 1;
156 
157     void SetupIcons(void);
158 	void Initialize();
159 	void FillLineEndList();
160 	void FillLineStyleList();
161 	void SelectEndStyle(bool bStart);
162 	void SelectLineStyle();
163 
164 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
165 	DECL_LINK(ImplWidthPopupModeEndHdl, FloatingWindow* );
166 	DECL_LINK(ToolboxColorSelectHdl, ToolBox*);
167 	DECL_LINK(ChangeLineStyleHdl, ToolBox*);
168 	DECL_LINK(ToolboxWidthSelectHdl, ToolBox*);
169 	DECL_LINK(ChangeTransparentHdl , void *);
170 	DECL_LINK(ChangeStartHdl, void *);
171 	DECL_LINK(ChangeEndHdl, void *);
172 	DECL_LINK(ChangeEdgeStyleHdl, void *);
173 	DECL_LINK(ChangeCapStyleHdl, void *);
174 
175     // constructor/destuctor
176     LinePropertyPanel(
177         Window* pParent,
178         const cssu::Reference<css::frame::XFrame>& rxFrame,
179         SfxBindings* pBindings);
180     virtual ~LinePropertyPanel(void);
181 
182     void SetColor(
183         const String& rsColorName,
184         const Color aColor);
185 
186     PopupControl* CreateColorPopupControl (PopupContainer* pParent);
187     PopupControl* CreateLineWidthPopupControl (PopupContainer* pParent);
188 };
189 
190 } } // end of namespace svx::sidebar
191 
192 #endif
193 
194 // eof
195