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