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 
64     virtual void DataChanged (const DataChangedEvent& rEvent);
65     ::sfx2::sidebar::ControllerItem& GetSpaceController();
66     long GetSelFontSize();
67     void SetSpacing(long nKern);
68     void EndSpacingPopupMode (void);
69     void EndUnderlinePopupMode (void);
70 	void SetFontColor (const String& rsColorName,const Color aColor);
71 	void SetBrushColor (const String& rsColorName,const Color aColor);
72 	void SetUnderline(FontUnderline	eUnderline);
73 	Color& GetUnderlineColor();
74 	void SetDefaultUnderline(FontUnderline eUnderline);
75 
76 
77     enum ColorType
78     {
79         FONT_COLOR = 1,
80         BACK_COLOR = 2
81     };
82 
83     virtual void HandleContextChange (
84         const ::sfx2::sidebar::EnumContext aContext);
85 
86 
87     // ControllerItem::ItemUpdateReceiverInterface
88 
89     virtual void NotifyItemUpdate(
90         const sal_uInt16 nSId,
91         const SfxItemState eState,
92         const SfxPoolItem* pState,
93         const bool bIsEnabled);
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 	FontWeight					meWeight;
134 	FontItalic					meItalic;
135 	FontUnderline				meUnderline;
136 	Color						meUnderlineColor;  //
137 	bool						mbShadow;
138 	FontStrikeout				meStrike;
139 	bool mbWeightAvailable;
140 	bool mbPostureAvailable;
141 	Color						maColor;
142 	bool mbColorAvailable;
143 	Color						maBackColor;
144 	bool mbBackColorAvailable;
145 	ColorType meColorType;
146 	SvxEscapement				meEscape;  //for sw
147 	bool						mbSuper;
148 	bool						mbSub;
149 	bool						mbKernAvailable;
150 	bool						mbKernLBAvailable;
151 	long						mlKerning;
152 	SvxFontHeightItem*			mpHeightItem;
153 
154 	const FontList* mpFontList;
155 	bool mbMustDelete;
156 	bool mbFocusOnFontSizeCtrl;
157 	TextCharacterSpacingPopup maCharSpacePopup;
158 	TextUnderlinePopup maUnderlinePopup;
159 	ColorPopup maFontColorPopup;
160 	ColorPopup maBrushColorPopup;
161 
162     cssu::Reference<css::frame::XFrame> mxFrame;
163     ::sfx2::sidebar::EnumContext maContext;
164     SfxBindings* mpBindings;
165 
166     TextPropertyPanel (
167         Window* pParent,
168         const cssu::Reference<css::frame::XFrame>& rxFrame,
169         SfxBindings* pBindings);
170 	virtual ~TextPropertyPanel (void);
171 
172 
173 	PopupControl* CreateCharacterSpacingControl (PopupContainer* pParent);
174 	PopupControl* CreateFontColorPopupControl (PopupContainer* pParent);
175 	PopupControl* CreateBrushColorPopupControl (PopupContainer* pParent);
176 	PopupControl* CreateUnderlinePopupControl (PopupContainer* pParent);
177 	DECL_LINK(SpacingClickHdl, ToolBox*);
178 	DECL_LINK(ToolBoxFontColorDropHdl, ToolBox *); //for new color picker
179 	DECL_LINK(ToolBoxHighlightDropHdl, ToolBox *);
180 	DECL_LINK(ToolBoxUnderlineClickHdl, ToolBox* );
181 
182 	void Initialize (void);
183     void SetupToolboxItems (void);
184 	void InitToolBoxFont();
185 	void InitToolBoxIncDec();
186 	void InitToolBoxFontColor();
187 	void InitToolBoxScript();
188 	void InitToolBoxHighlight();
189 	void InitToolBoxSpacing();
190 
191 	DECL_LINK(FontSelHdl, FontNameBox *);
192 	DECL_LINK(FontSizeModifyHdl, FontSizeBox *);
193 	DECL_LINK(FontSizeSelHdl, FontSizeBox *);
194 	DECL_LINK(FontSizeLoseFocus, FontSizeBox *);
195 	DECL_LINK(ToolboxFontSelectHandler, ToolBox *);
196 	DECL_LINK(ToolboxIncDecSelectHdl, ToolBox *);
197 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
198 	DECL_LINK(ToolBoxSwScriptSelectHdl, ToolBox *);
199 	DECL_LINK(ToolBoxScriptSelectHdl, ToolBox *);
200 
201     void UpdateItem (const sal_uInt16 nSlotId);
202 };
203 
204 } } // end of namespace ::svx::sidebar
205 
206 #endif
207