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