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