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_SIDEBAR_TEXT_PROPERTY_PAGE_HXX
23 #define SVX_SIDEBAR_TEXT_PROPERTY_PAGE_HXX
24 
25 #include <vcl/ctrl.hxx>
26 #include <sfx2/sidebar/SidebarPanelBase.hxx>
27 #include <sfx2/sidebar/ControllerItem.hxx>
28 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
29 
30 #include <svtools/ctrlbox.hxx>
31 #include <svx/tbxcolorupdate.hxx>
32 #include <editeng/svxenum.hxx>
33 #include <editeng/fhgtitem.hxx>
34 
35 #include <com/sun/star/ui/XUIElement.hpp>
36 
37 #include <boost/scoped_ptr.hpp>
38 #include "TextCharacterSpacingPopup.hxx"
39 #include "TextUnderlinePopup.hxx"
40 #include "sidebar/ColorPopup.hxx"
41 #include <vcl/vclenum.hxx>
42 
43 class FloatingWindow;
44 class ToolBox;
45 
46 namespace svx { namespace sidebar {
47 
48 class SvxSBFontNameBox;
49 class PopupControl;
50 class PopupContainer;
51 
52 class TextPropertyPanel
53     : public Control,
54        public ::sfx2::sidebar::IContextChangeReceiver,
55       public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
56 {
57 public:
58     static TextPropertyPanel* Create (
59         Window* pParent,
60         const cssu::Reference<css::frame::XFrame>& rxFrame,
61         SfxBindings* pBindings);
62 
63     virtual void DataChanged (const DataChangedEvent& rEvent);
64     SfxBindings* GetBindings();
65     ::sfx2::sidebar::ControllerItem& GetSpaceController();
66     long GetSelFontSize();
67     void SetSpacing(long nKern);
68     void EndSpacingPopupMode (void);
69     void EndUnderlinePopupMode (void);
70 	Color GetFontColor (void) const;
71 	void SetFontColor (const String& rsColorName,const Color aColor);
72 	Color GetBrushColor (void) const;
73 	void SetBrushColor (const String& rsColorName,const Color aColor);
74 	void SetUnderline(FontUnderline	eUnderline);
75 	Color& GetUnderlineColor();
76 	void SetDefaultUnderline(FontUnderline eUnderline);
77 
78     //
79     //	USHORT GetCurrColorType();
80 
81     //	void SetBackColor(Color aCol);
82     //	void SetColor(Color aCol);
83     //
84     //	void SetSpacing(long nKern);
85 
86     /*
87 	SvxTextUnderlinePage* GetUnderlinePage();
88 	SfxPopupPanelWin* GetUnderlineFloatWin();
89 
90 	SvxTextFontColorPage* GetFontColorPage();
91 	SfxPopupPanelWin* GetFontColorFloatWin();
92 
93 	SvxTextSpacingPage* GetSpacingPage();
94 	SfxPopupPanelWin* GetSpacingFloatWin();
95     */
96     //	long GetSelFontSize();
97     //	SfxPropertyPageController GetSpaceController();
98 //	ToolBox* GetSpacingTB();		//removed
99     //	 //
100 //	void FontListChanged();
101 
102 
103 
104     enum ColorType
105     {
106         FONT_COLOR = 1,
107         BACK_COLOR = 2
108     };
109 
110     virtual void HandleContextChange (
111         const ::sfx2::sidebar::EnumContext aContext);
112 
113     virtual void NotifyItemUpdate(
114         const sal_uInt16 nSId,
115         const SfxItemState eState,
116         const SfxPoolItem* pState);
117 
118 private:
119 	//ui controls
120     ::boost::scoped_ptr<SvxSBFontNameBox> mpFontNameBox;
121 	FontSizeBox maFontSizeBox;
122 	::boost::scoped_ptr<Window> mpToolBoxIncDecBackground;
123 	::boost::scoped_ptr<ToolBox> mpToolBoxIncDec;
124 	::boost::scoped_ptr<Window> mpToolBoxFontBackground;
125 	::boost::scoped_ptr<ToolBox> mpToolBoxFont;
126 	::boost::scoped_ptr<Window> mpToolBoxFontColorBackground;
127 	::boost::scoped_ptr<ToolBox> mpToolBoxFontColor;
128 	::boost::scoped_ptr<Window> mpToolBoxScriptBackground;
129 	::boost::scoped_ptr<ToolBox> mpToolBoxScript;
130 	::boost::scoped_ptr<Window> mpToolBoxScriptSwBackground;
131 	::boost::scoped_ptr<ToolBox> mpToolBoxScriptSw;
132 	::boost::scoped_ptr<Window> mpToolBoxSpacingBackground;
133 	::boost::scoped_ptr<ToolBox> mpToolBoxSpacing;
134 	::boost::scoped_ptr<Window> mpToolBoxHighlightBackground;
135 	::boost::scoped_ptr<ToolBox> mpToolBoxHighlight;
136 	::boost::scoped_ptr<ToolboxButtonColorUpdater> mpFontColorUpdater;
137     ::boost::scoped_ptr<ToolboxButtonColorUpdater> mpHighlightUpdater;
138 
139 	//control items
140 	::sfx2::sidebar::ControllerItem maFontNameControl;
141 	::sfx2::sidebar::ControllerItem maFontSizeControl;
142 	::sfx2::sidebar::ControllerItem maWeightControl;
143 	::sfx2::sidebar::ControllerItem maItalicControl;
144 	::sfx2::sidebar::ControllerItem maUnderlineControl;
145 	::sfx2::sidebar::ControllerItem maStrikeControl;
146 	::sfx2::sidebar::ControllerItem maShadowControl;
147 	::sfx2::sidebar::ControllerItem maFontColorControl;
148 	::sfx2::sidebar::ControllerItem maScriptControlSw;
149 	::sfx2::sidebar::ControllerItem maSuperScriptControl;
150 	::sfx2::sidebar::ControllerItem maSubScriptControl;
151 	::sfx2::sidebar::ControllerItem maSpacingControl;
152 	::sfx2::sidebar::ControllerItem maHighlightControl;
153 	::sfx2::sidebar::ControllerItem maSDFontGrow;
154 	::sfx2::sidebar::ControllerItem maSDFontShrink;
155 
156 	//Images
157 	Image	maImgIncrease;
158 	Image	maImgDecrease;
159 	Image	maImgBold;
160 	Image	maImgItalic;
161 	Image	maImgUnderline;
162 	Image	maImgStrike;
163 	Image	maImgShadow;
164 	Image	maImgFontColor;
165 	Image	maImgSupScript;
166 	Image	maImgSubScript;
167 	Image   maImgHighlight;
168 
169 	Image				maImgNormalIcon;
170 
171 	Image	maImgIncreaseHigh;
172 	Image	maImgDecreaseHigh;
173 	Image	maImgBoldHigh;
174 	Image	maImgItalicHigh;
175 	Image	maImgUnderlineHigh;
176 	Image	maImgStrikeHigh;
177 	Image	maImgShadowHigh;
178 	Image	maImgFontColorHigh;
179 	Image	maImgSupScriptHigh;
180 	Image	maImgSubScriptHigh;
181 //	Image	maImgSpacingHigh;  //
182 	Image   maImgHighlightHigh;
183 
184 	FontWeight					meWeight;
185 	FontItalic					meItalic;
186 	FontUnderline				meUnderline;
187 	Color						meUnderlineColor;  //
188 	bool						mbShadow;
189 	FontStrikeout				meStrike;
190 	bool mbWeightAvailable;
191 	bool mbPostureAvailable;
192 	Color						maColor;
193 	bool mbColorAvailable;
194 	Color						maBackColor;
195 	bool mbBackColorAvailable;
196 	ColorType meColorType;
197 	SvxEscapement				meEscape;  //for sw
198 	bool						mbSuper;
199 	bool						mbSub;
200 	bool						mbKernAvailable;
201 	bool						mbKernLBAvailable;
202 	long						mlKerning;
203 	SvxFontHeightItem*			mpHeightItem;
204 
205 	const FontList* mpFontList;
206 	bool mbMustDelete;
207 	bool mbFocusOnFontSizeCtrl;
208 	TextCharacterSpacingPopup maCharSpacePopup;
209 	TextUnderlinePopup maUnderlinePopup;
210 	ColorPopup maFontColorPopup;
211 	ColorPopup maBrushColorPopup;
212 
213     cssu::Reference<css::frame::XFrame> mxFrame;
214     ::sfx2::sidebar::EnumContext maContext;
215     SfxBindings* mpBindings;
216 
217     TextPropertyPanel (
218         Window* pParent,
219         const cssu::Reference<css::frame::XFrame>& rxFrame,
220         SfxBindings* pBindings);
221 	virtual ~TextPropertyPanel (void);
222 
223 
224 	PopupControl* CreateCharacterSpacingControl (PopupContainer* pParent);
225 	DECL_LINK(SpacingClickHdl, ToolBox*);
226 	PopupControl* CreateFontColorPopupControl (PopupContainer* pParent);
227 	PopupControl* CreateBrushColorPopupControl (PopupContainer* pParent);
228 	PopupControl* CreateUnderlinePopupControl (PopupContainer* pParent);
229 	DECL_LINK(ToolBoxFontColorDropHdl, ToolBox *); //for new color picker
230 	DECL_LINK(ToolBoxHighlightDropHdl, ToolBox *);
231 	DECL_LINK(ToolBoxUnderlineClickHdl, ToolBox* );
232 
233 	void Initialize (void);
234     void SetupIcons (void);
235 	void InitToolBoxFont();
236 	void InitToolBoxIncDec();
237 	void InitToolBoxFontColor();
238 	void InitToolBoxScript();
239 	void InitToolBoxHighlight();
240 	void InitToolBoxSpacing();
241 
242 	void UpdateFontBold();
243 	void UpdateFontItalic();
244 	void UpdateFontUnderline();
245 	void UpdateFontStrikeOut();
246 	void UpdateFontShadowed();
247 	void UpdateFontScript();
248 
249     /*
250 	SfxPopupPanelWin*		mpFloatWinUnderline;
251 	class SvxTextUnderlinePage;
252 	SvxTextUnderlinePage*	mpPageUnderline;
253 
254 	SfxPopupPanelWin*		mpFloatWinFontColor;
255 	class SvxTextFontColorPage;
256 	SvxTextFontColorPage*	mpPageFontColor;
257 
258 	SfxPopupPanelWin*		mpFloatWinSpacing;
259 	class SvxTextSpacingPage;
260 	SvxTextSpacingPage*		mpPageSpacing;
261     */
262 	DECL_LINK(FontSelHdl, FontNameBox *);
263 	DECL_LINK(FontSizeModifyHdl, FontSizeBox *);
264 	DECL_LINK(FontSizeSelHdl, FontSizeBox *);
265 	DECL_LINK(FontSizeLoseFocus, FontSizeBox *);
266 	DECL_LINK(ToolboxFontSelectHandler, ToolBox *);
267 	DECL_LINK(ToolboxIncDecSelectHdl, ToolBox *);
268 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
269 	DECL_LINK(ToolBoxSwScriptSelectHdl, ToolBox *);
270 	DECL_LINK(ToolBoxScriptSelectHdl, ToolBox *);
271 
272 
273 
274 	void TextStyleChanged();
275 
276     Image GetIcon (const ::rtl::OUString& rsURL);
277 };
278 
279 } } // end of namespace ::svx::sidebar
280 
281 #endif
282