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