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/XSidebar.hpp>
36 
37 #include <boost/scoped_ptr.hpp>
38 #include "TextCharacterSpacingPopup.hxx"
39 #include "TextUnderlinePopup.hxx"
40 #include <svx/sidebar/ColorPopup.hxx>
41 #include <vcl/vclenum.hxx>
42 
43 class FloatingWindow;
44 class ToolBox;
45 
46 namespace svx { namespace sidebar {
47 
48 class SvxSBFontNameBox;
49 class PopupControl;
50 class PopupContainer;
51 
52 class TextPropertyPanel
53     : public Control,
54       public ::sfx2::sidebar::IContextChangeReceiver,
55       public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
56 {
57 public:
58     static TextPropertyPanel* Create (
59         Window* pParent,
60         const cssu::Reference<css::frame::XFrame>& rxFrame,
61         SfxBindings* pBindings);
62 
63     virtual void DataChanged (const DataChangedEvent& rEvent);
64     virtual void Resize (void);
65 
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     virtual void HandleContextChange (
79         const ::sfx2::sidebar::EnumContext aContext);
80 
81 
82     virtual void NotifyItemUpdate(
83         const sal_uInt16 nSId,
84         const SfxItemState eState,
85         const SfxPoolItem* pState,
86         const bool bIsEnabled);
87 
88 private:
89     //ui controls
90     ::boost::scoped_ptr<SvxSBFontNameBox> mpFontNameBox;
91     FontSizeBox maFontSizeBox;
92     ::boost::scoped_ptr<Window> mpToolBoxFontBackground;
93     ::boost::scoped_ptr<ToolBox> mpToolBoxFont;
94     ::boost::scoped_ptr<Window> mpToolBoxIncDecBackground;
95     ::boost::scoped_ptr<ToolBox> mpToolBoxIncDec;
96     ::boost::scoped_ptr<Window> mpToolBoxScriptBackground;
97     ::boost::scoped_ptr<ToolBox> mpToolBoxScript;
98     ::boost::scoped_ptr<Window> mpToolBoxScriptSwBackground;
99     ::boost::scoped_ptr<ToolBox> mpToolBoxScriptSw;
100     ::boost::scoped_ptr<Window> mpToolBoxSpacingBackground;
101     ::boost::scoped_ptr<ToolBox> mpToolBoxSpacing;
102     ::boost::scoped_ptr<Window> mpToolBoxFontColorBackground;
103     ::boost::scoped_ptr<ToolBox> mpToolBoxFontColor;
104     ::boost::scoped_ptr<Window> mpToolBoxHighlightBackground;
105     ::boost::scoped_ptr<ToolBox> mpToolBoxHighlight;
106     ::boost::scoped_ptr<ToolboxButtonColorUpdater> mpFontColorUpdater;
107     ::boost::scoped_ptr<ToolboxButtonColorUpdater> mpHighlightUpdater;
108 
109     //control items
110     ::sfx2::sidebar::ControllerItem maFontNameControl;
111     ::sfx2::sidebar::ControllerItem maFontSizeControl;
112     ::sfx2::sidebar::ControllerItem maWeightControl;
113     ::sfx2::sidebar::ControllerItem maItalicControl;
114     ::sfx2::sidebar::ControllerItem maUnderlineControl;
115     ::sfx2::sidebar::ControllerItem maStrikeControl;
116     ::sfx2::sidebar::ControllerItem maShadowControl;
117     ::sfx2::sidebar::ControllerItem maFontColorControl;
118     ::sfx2::sidebar::ControllerItem maScriptControlSw;
119     ::sfx2::sidebar::ControllerItem maSuperScriptControl;
120     ::sfx2::sidebar::ControllerItem maSubScriptControl;
121     ::sfx2::sidebar::ControllerItem maSpacingControl;
122     ::sfx2::sidebar::ControllerItem maHighlightControl;
123     ::sfx2::sidebar::ControllerItem maSDFontGrow;
124     ::sfx2::sidebar::ControllerItem maSDFontShrink;
125 
126     FontWeight					meWeight;
127     FontItalic					meItalic;
128     FontUnderline				meUnderline;
129     Color						meUnderlineColor;
130     bool						mbShadow;
131     FontStrikeout				meStrike;
132     bool mbWeightAvailable;
133     bool mbPostureAvailable;
134     Color						maColor;
135     bool mbColorAvailable;
136     Color						maBackColor;
137     bool mbBackColorAvailable;
138     SvxEscapement				meEscape;  //for sw
139     bool						mbSuper;
140     bool						mbSub;
141     bool						mbKernAvailable;
142     bool						mbKernLBAvailable;
143     long						mlKerning;
144     SvxFontHeightItem*			mpHeightItem;
145 
146     const FontList* mpFontList;
147     bool mbMustDelete;
148     bool mbFocusOnFontSizeCtrl;
149     TextCharacterSpacingPopup maCharSpacePopup;
150     TextUnderlinePopup maUnderlinePopup;
151     ColorPopup maFontColorPopup;
152     ColorPopup maBrushColorPopup;
153 
154     cssu::Reference<css::frame::XFrame> mxFrame;
155     ::sfx2::sidebar::EnumContext maContext;
156     SfxBindings* mpBindings;
157 
158     TextPropertyPanel (
159         Window* pParent,
160         const cssu::Reference<css::frame::XFrame>& rxFrame,
161         SfxBindings* pBindings);
162     virtual ~TextPropertyPanel (void);
163 
164 
165     PopupControl* CreateCharacterSpacingControl (PopupContainer* pParent);
166     PopupControl* CreateFontColorPopupControl (PopupContainer* pParent);
167     PopupControl* CreateBrushColorPopupControl (PopupContainer* pParent);
168     PopupControl* CreateUnderlinePopupControl (PopupContainer* pParent);
169     DECL_LINK(SpacingClickHdl, ToolBox*);
170     DECL_LINK(ToolBoxFontColorDropHdl, ToolBox *); //for new color picker
171     DECL_LINK(ToolBoxHighlightDropHdl, ToolBox *);
172     DECL_LINK(ToolBoxUnderlineClickHdl, ToolBox* );
173 
174     void Initialize (void);
175     void SetupToolboxItems (void);
176     void InitToolBoxFont();
177     void InitToolBoxIncDec();
178     void InitToolBoxFontColor();
179     void InitToolBoxScript();
180     void InitToolBoxHighlight();
181     void InitToolBoxSpacing();
182 
183     DECL_LINK(FontSelHdl, FontNameBox *);
184     DECL_LINK(FontSizeModifyHdl, FontSizeBox *);
185     DECL_LINK(FontSizeSelHdl, FontSizeBox *);
186     DECL_LINK(FontSizeLoseFocus, FontSizeBox *);
187     DECL_LINK(ToolboxFontSelectHandler, ToolBox *);
188     DECL_LINK(ToolboxIncDecSelectHdl, ToolBox *);
189     DECL_LINK(ToolBoxSwScriptSelectHdl, ToolBox *);
190     DECL_LINK(ToolBoxScriptSelectHdl, ToolBox *);
191 
192     void UpdateItem (const sal_uInt16 nSlotId);
193 };
194 
195 } } // end of namespace ::svx::sidebar
196 
197 #endif
198