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     ::sfx2::sidebar::ControllerItem& GetSpaceController();
67     long GetSelFontSize();
68     void SetSpacing(long nKern);
69     void EndSpacingPopupMode (void);
70     void EndUnderlinePopupMode (void);
71 	void SetFontColor (const String& rsColorName,const Color aColor);
72 	void SetBrushColor (const String& rsColorName,const Color aColor);
73 	void SetUnderline(FontUnderline	eUnderline);
74 	Color& GetUnderlineColor();
75 	void SetDefaultUnderline(FontUnderline eUnderline);
76 
77 
78     enum ColorType
79     {
80         FONT_COLOR = 1,
81         BACK_COLOR = 2
82     };
83 
84     virtual void HandleContextChange (
85         const ::sfx2::sidebar::EnumContext aContext);
86 
87 
88     // ControllerItem::ItemUpdateReceiverInterface
89 
90     virtual void NotifyItemUpdate(
91         const sal_uInt16 nSId,
92         const SfxItemState eState,
93         const SfxPoolItem* pState,
94         const bool bIsEnabled);
95 
96 private:
97 	//ui controls
98     ::boost::scoped_ptr<SvxSBFontNameBox> mpFontNameBox;
99 	FontSizeBox maFontSizeBox;
100 	::boost::scoped_ptr<Window> mpToolBoxIncDecBackground;
101 	::boost::scoped_ptr<ToolBox> mpToolBoxIncDec;
102 	::boost::scoped_ptr<Window> mpToolBoxFontBackground;
103 	::boost::scoped_ptr<ToolBox> mpToolBoxFont;
104 	::boost::scoped_ptr<Window> mpToolBoxFontColorBackground;
105 	::boost::scoped_ptr<ToolBox> mpToolBoxFontColor;
106 	::boost::scoped_ptr<Window> mpToolBoxScriptBackground;
107 	::boost::scoped_ptr<ToolBox> mpToolBoxScript;
108 	::boost::scoped_ptr<Window> mpToolBoxScriptSwBackground;
109 	::boost::scoped_ptr<ToolBox> mpToolBoxScriptSw;
110 	::boost::scoped_ptr<Window> mpToolBoxSpacingBackground;
111 	::boost::scoped_ptr<ToolBox> mpToolBoxSpacing;
112 	::boost::scoped_ptr<Window> mpToolBoxHighlightBackground;
113 	::boost::scoped_ptr<ToolBox> mpToolBoxHighlight;
114 	::boost::scoped_ptr<ToolboxButtonColorUpdater> mpFontColorUpdater;
115     ::boost::scoped_ptr<ToolboxButtonColorUpdater> mpHighlightUpdater;
116 
117 	//control items
118 	::sfx2::sidebar::ControllerItem maFontNameControl;
119 	::sfx2::sidebar::ControllerItem maFontSizeControl;
120 	::sfx2::sidebar::ControllerItem maWeightControl;
121 	::sfx2::sidebar::ControllerItem maItalicControl;
122 	::sfx2::sidebar::ControllerItem maUnderlineControl;
123 	::sfx2::sidebar::ControllerItem maStrikeControl;
124 	::sfx2::sidebar::ControllerItem maShadowControl;
125 	::sfx2::sidebar::ControllerItem maFontColorControl;
126 	::sfx2::sidebar::ControllerItem maScriptControlSw;
127 	::sfx2::sidebar::ControllerItem maSuperScriptControl;
128 	::sfx2::sidebar::ControllerItem maSubScriptControl;
129 	::sfx2::sidebar::ControllerItem maSpacingControl;
130 	::sfx2::sidebar::ControllerItem maHighlightControl;
131 	::sfx2::sidebar::ControllerItem maSDFontGrow;
132 	::sfx2::sidebar::ControllerItem maSDFontShrink;
133 
134 	FontWeight					meWeight;
135 	FontItalic					meItalic;
136 	FontUnderline				meUnderline;
137 	Color						meUnderlineColor;  //
138 	bool						mbShadow;
139 	FontStrikeout				meStrike;
140 	bool mbWeightAvailable;
141 	bool mbPostureAvailable;
142 	Color						maColor;
143 	bool mbColorAvailable;
144 	Color						maBackColor;
145 	bool mbBackColorAvailable;
146 	ColorType meColorType;
147 	SvxEscapement				meEscape;  //for sw
148 	bool						mbSuper;
149 	bool						mbSub;
150 	bool						mbKernAvailable;
151 	bool						mbKernLBAvailable;
152 	long						mlKerning;
153 	SvxFontHeightItem*			mpHeightItem;
154 
155 	const FontList* mpFontList;
156 	bool mbMustDelete;
157 	bool mbFocusOnFontSizeCtrl;
158 	TextCharacterSpacingPopup maCharSpacePopup;
159 	TextUnderlinePopup maUnderlinePopup;
160 	ColorPopup maFontColorPopup;
161 	ColorPopup maBrushColorPopup;
162 
163     cssu::Reference<css::frame::XFrame> mxFrame;
164     ::sfx2::sidebar::EnumContext maContext;
165     SfxBindings* mpBindings;
166     cssu::Reference<css::ui::XSidebar> mxSidebar;
167 
168     TextPropertyPanel (
169         Window* pParent,
170         const cssu::Reference<css::frame::XFrame>& rxFrame,
171         SfxBindings* pBindings,
172         const cssu::Reference<css::ui::XSidebar>& rxSidebar);
173 	virtual ~TextPropertyPanel (void);
174 
175 
176 	PopupControl* CreateCharacterSpacingControl (PopupContainer* pParent);
177 	PopupControl* CreateFontColorPopupControl (PopupContainer* pParent);
178 	PopupControl* CreateBrushColorPopupControl (PopupContainer* pParent);
179 	PopupControl* CreateUnderlinePopupControl (PopupContainer* pParent);
180 	DECL_LINK(SpacingClickHdl, ToolBox*);
181 	DECL_LINK(ToolBoxFontColorDropHdl, ToolBox *); //for new color picker
182 	DECL_LINK(ToolBoxHighlightDropHdl, ToolBox *);
183 	DECL_LINK(ToolBoxUnderlineClickHdl, ToolBox* );
184 
185 	void Initialize (void);
186     void SetupToolboxItems (void);
187 	void InitToolBoxFont();
188 	void InitToolBoxIncDec();
189 	void InitToolBoxFontColor();
190 	void InitToolBoxScript();
191 	void InitToolBoxHighlight();
192 	void InitToolBoxSpacing();
193 
194 	DECL_LINK(FontSelHdl, FontNameBox *);
195 	DECL_LINK(FontSizeModifyHdl, FontSizeBox *);
196 	DECL_LINK(FontSizeSelHdl, FontSizeBox *);
197 	DECL_LINK(FontSizeLoseFocus, FontSizeBox *);
198 	DECL_LINK(ToolboxFontSelectHandler, ToolBox *);
199 	DECL_LINK(ToolboxIncDecSelectHdl, ToolBox *);
200 	DECL_LINK(ImplPopupModeEndHdl, FloatingWindow* );
201 	DECL_LINK(ToolBoxSwScriptSelectHdl, ToolBox *);
202 	DECL_LINK(ToolBoxScriptSelectHdl, ToolBox *);
203 
204     void UpdateItem (const sal_uInt16 nSlotId);
205 };
206 
207 } } // end of namespace ::svx::sidebar
208 
209 #endif
210