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