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