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