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 #include <sfx2/sidebar/EnumContext.hxx>
30 
31 #include <svtools/ctrlbox.hxx>
32 #include <svx/tbxcolorupdate.hxx>
33 #include <editeng/svxenum.hxx>
34 #include <editeng/fhgtitem.hxx>
35 
36 #include <com/sun/star/ui/XSidebar.hpp>
37 #include <com/sun/star/frame/XToolbarController.hpp>
38 
39 #include <boost/scoped_ptr.hpp>
40 #include "TextCharacterSpacingPopup.hxx"
41 #include "TextUnderlinePopup.hxx"
42 #include <svx/sidebar/ColorPopup.hxx>
43 #include <vcl/vclenum.hxx>
44 
45 class FloatingWindow;
46 class ToolBox;
47 
48 namespace svx { namespace sidebar {
49 
50 class SvxSBFontNameBox;
51 class PopupControl;
52 class PopupContainer;
53 
54 class TextPropertyPanel
55     : public Control,
56       public ::sfx2::sidebar::IContextChangeReceiver,
57       public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
58 {
59 public:
60     static TextPropertyPanel* Create (
61         Window* pParent,
62         const cssu::Reference<css::frame::XFrame>& rxFrame,
63         SfxBindings* pBindings,
64         const ::sfx2::sidebar::EnumContext& rContext);
65 
66     virtual void DataChanged (const DataChangedEvent& rEvent);
67 
68     ::sfx2::sidebar::ControllerItem& GetSpaceController();
69     long GetSelFontSize();
70     void SetSpacing(long nKern);
71     void EndSpacingPopupMode (void);
72     void EndUnderlinePopupMode (void);
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 maScriptControlSw;
118     ::sfx2::sidebar::ControllerItem maSuperScriptControl;
119     ::sfx2::sidebar::ControllerItem maSubScriptControl;
120     ::sfx2::sidebar::ControllerItem maSpacingControl;
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     SvxEscapement				meEscape;  //for sw
133     bool						mbSuper;
134     bool						mbSub;
135     bool						mbKernAvailable;
136     bool						mbKernLBAvailable;
137     long						mlKerning;
138     SvxFontHeightItem*			mpHeightItem;
139 
140     const FontList* mpFontList;
141     bool mbMustDelete;
142     bool mbFocusOnFontSizeCtrl;
143     TextCharacterSpacingPopup maCharSpacePopup;
144     TextUnderlinePopup maUnderlinePopup;
145 
146     cssu::Reference<css::frame::XFrame> mxFrame;
147     ::sfx2::sidebar::EnumContext maContext;
148     SfxBindings* mpBindings;
149 
150     TextPropertyPanel (
151         Window* pParent,
152         const cssu::Reference<css::frame::XFrame>& rxFrame,
153         SfxBindings* pBindings,
154         const ::sfx2::sidebar::EnumContext& rContext);
155     virtual ~TextPropertyPanel (void);
156 
157 
158     PopupControl* CreateCharacterSpacingControl (PopupContainer* pParent);
159     PopupControl* CreateUnderlinePopupControl (PopupContainer* pParent);
160     DECL_LINK(SpacingClickHdl, ToolBox*);
161     DECL_LINK(ToolBoxUnderlineClickHdl, ToolBox* );
162 
163     void Initialize (void);
164     void SetupToolboxItems (void);
165     void InitToolBoxFont();
166     void InitToolBoxIncDec();
167     void InitToolBoxScript();
168     void InitToolBoxSpacing();
169 
170     DECL_LINK(FontSelHdl, FontNameBox *);
171     DECL_LINK(FontSizeModifyHdl, FontSizeBox *);
172     DECL_LINK(FontSizeSelHdl, FontSizeBox *);
173     DECL_LINK(FontSizeLoseFocus, FontSizeBox *);
174     DECL_LINK(ToolboxFontSelectHandler, ToolBox *);
175     DECL_LINK(ToolboxIncDecSelectHdl, ToolBox *);
176     DECL_LINK(ToolBoxSwScriptSelectHdl, ToolBox *);
177     DECL_LINK(ToolBoxScriptSelectHdl, ToolBox *);
178 
179     void UpdateItem (const sal_uInt16 nSlotId);
180 };
181 
182 } } // end of namespace ::svx::sidebar
183 
184 #endif
185