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 SC_PROPERTYPANEL_APPEARANCE_HXX
23 #define SC_PROPERTYPANEL_APPEARANCE_HXX
24 
25 #include <sfx2/sidebar/ControllerItem.hxx>
26 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
27 #include <boost/scoped_ptr.hpp>
28 #include <svx/sidebar/ColorPopup.hxx>
29 
30 class FixedText;
31 namespace svx { class ToolboxButtonColorUpdater; }
32 namespace sc { namespace sidebar {
33     class CellLineStylePopup;
34     class CellBorderStylePopup;
35     class CellLineStyleControl;
36     class CellBorderUpdater;
37 }}
38 class ToolBox;
39 class CheckBox;
40 
41 namespace sc { namespace sidebar {
42 
43 class CellAppearancePropertyPanel
44 :   public Control,
45     public ::sfx2::sidebar::IContextChangeReceiver,
46     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
47 {
48 private:
49     friend class CellLineStyleControl;
50     friend class CellBorderStyleControl;
51 
52 public:
53     static CellAppearancePropertyPanel* Create(
54         Window* pParent,
55         const cssu::Reference<css::frame::XFrame>& rxFrame,
56         SfxBindings* pBindings);
57 
58     virtual void DataChanged(
59         const DataChangedEvent& rEvent);
60 
61     virtual void HandleContextChange(
62         const ::sfx2::sidebar::EnumContext aContext);
63 
64     virtual void NotifyItemUpdate(
65         const sal_uInt16 nSId,
66         const SfxItemState eState,
67         const SfxPoolItem* pState,
68         const bool bIsEnabled);
69 
70     SfxBindings* GetBindings();
71 
72     virtual void Resize (void);
73 
74 private:
75     //ui controls
76     ::boost::scoped_ptr< FixedText >        mpFTFillColor;
77     ::boost::scoped_ptr< Window >           mpTBFillColorBackground;
78     ::boost::scoped_ptr< ToolBox >          mpTBFillColor;
79     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpFillColorUpdater;
80 
81     ::boost::scoped_ptr< FixedText >        mpFTCellBorder;
82     ::boost::scoped_ptr< Window >           mpTBCellBorderBackground;
83     ::boost::scoped_ptr< ToolBox >          mpTBCellBorder;
84     ::boost::scoped_ptr< CellBorderUpdater > mpCellBorderUpdater;
85 
86     ::boost::scoped_ptr< Window >           mpTBLineStyleBackground;
87     ::boost::scoped_ptr< ToolBox >          mpTBLineStyle;
88 
89     ::boost::scoped_ptr< Window >           mpTBLineColorBackground;
90     ::boost::scoped_ptr< ToolBox >          mpTBLineColor;
91     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > mpLineColorUpdater;
92 
93     ::boost::scoped_ptr< CheckBox >         mpCBXShowGrid;
94 
95     ::sfx2::sidebar::ControllerItem         maBackColorControl;
96     ::sfx2::sidebar::ControllerItem         maLineColorControl;
97     ::sfx2::sidebar::ControllerItem         maLineStyleControl;
98     ::sfx2::sidebar::ControllerItem         maBorderOuterControl;
99     ::sfx2::sidebar::ControllerItem         maBorderInnerControl;
100     ::sfx2::sidebar::ControllerItem         maGridShowControl;
101     ::sfx2::sidebar::ControllerItem         maBorderTLBRControl;
102     ::sfx2::sidebar::ControllerItem         maBorderBLTRControl;
103 
104     // images
105     Image                                   maIMGBKColor;
106     Image                                   maIMGCellBorder;
107     Image                                   maIMGLineColor;
108     Image                                   maIMGLineStyle1;
109     Image                                   maIMGLineStyle2;
110     Image                                   maIMGLineStyle3;
111     Image                                   maIMGLineStyle4;
112     Image                                   maIMGLineStyle5;
113     Image                                   maIMGLineStyle6;
114     Image                                   maIMGLineStyle7;
115     Image                                   maIMGLineStyle8;
116     Image                                   maIMGLineStyle9;
117 
118     // high contrast images
119     Image                                   maIMGBKColorH;
120     Image                                   maIMGLineStyle0H;
121     Image                                   maIMGLineStyle1H;
122     Image                                   maIMGLineStyle2H;
123     Image                                   maIMGLineStyle3H;
124     Image                                   maIMGLineStyle4H;
125     Image                                   maIMGLineStyle5H;
126     Image                                   maIMGLineStyle6H;
127     Image                                   maIMGLineStyle7H;
128     Image                                   maIMGLineStyle8H;
129     Image                                   maIMGLineStyle9H;
130 
131     // cell background color
132     Color                                   maBackColor;
133 
134     // cell line color(s)
135     Color                                   maLineColor;
136     Color                                   maTLBRColor;
137     Color                                   maBLTRColor;
138 
139     // BorderStyle defines
140     sal_uInt16                              mnIn;
141     sal_uInt16                              mnOut;
142     sal_uInt16                              mnDis;
143     sal_uInt16                              mnTLBRIn;
144     sal_uInt16                              mnTLBROut;
145     sal_uInt16                              mnTLBRDis;
146     sal_uInt16                              mnBLTRIn;
147     sal_uInt16                              mnBLTROut;
148     sal_uInt16                              mnBLTRDis;
149 
150     /// bitfield
151     bool                                    mbBackColorAvailable : 1;
152     bool                                    mbLineColorAvailable : 1;
153     bool                                    mbBorderStyleAvailable : 1;
154 
155     // CellBorder defines
156     bool                                    mbLeft : 1;
157     bool                                    mbRight : 1;
158     bool                                    mbTop : 1;
159     bool                                    mbBottom : 1;
160     bool                                    mbVer : 1;
161     bool                                    mbHor : 1;
162 
163     bool                                    mbOuterBorder : 1; // mbLeft || mbRight || mbTop || mbBottom
164     bool                                    mbInnerBorder : 1; // mbVer || mbHor || bLeft || bRight || bTop || bBottom
165 
166     bool                                    mbTLBR : 1;
167     bool                                    mbBLTR : 1;
168 
169     // popups
170     svx::sidebar::ColorPopup                maFillColorPopup;
171     svx::sidebar::ColorPopup                maLineColorPopup;
172     ::boost::scoped_ptr< CellLineStylePopup > mpCellLineStylePopup;
173     ::boost::scoped_ptr< CellBorderStylePopup > mpCellBorderStylePopup;
174 
175     cssu::Reference<css::frame::XFrame>     mxFrame;
176     ::sfx2::sidebar::EnumContext            maContext;
177     SfxBindings*                            mpBindings;
178 
179     DECL_LINK(TbxBKColorSelectHdl, ToolBox*);
180     DECL_LINK(TbxLineColorSelectHdl, ToolBox*);
181     DECL_LINK(TbxCellBorderSelectHdl, ToolBox*);
182     DECL_LINK(TbxLineStyleSelectHdl, ToolBox*);
183     DECL_LINK(CBOXGridShowClkHdl, void*);
184 
185     // for fill color picker
186     svx::sidebar::PopupControl* CreateFillColorPopupControl(svx::sidebar::PopupContainer* pParent);
187     void SetFillColor(const String& rsColorName, const Color aColor);
188 
189     // for line color picker
190     svx::sidebar::PopupControl* CreateLineColorPopupControl(svx::sidebar::PopupContainer* pParent);
191     void SetLineColor(const String& rsColorName, const Color aColor);
192 
193     // for CellLineStyle popup
194     svx::sidebar::PopupControl* CreateCellLineStylePopupControl(svx::sidebar::PopupContainer* pParent);
195     void EndCellLineStylePopupMode(void);
196 
197     // for CellBorderStyle popup
198     svx::sidebar::PopupControl* CreateCellBorderStylePopupControl(svx::sidebar::PopupContainer* pParent);
199     void EndCellBorderStylePopupMode(void);
200 
201     // constructor/destuctor
202     CellAppearancePropertyPanel(
203         Window* pParent,
204         const cssu::Reference<css::frame::XFrame>& rxFrame,
205         SfxBindings* pBindings);
206     virtual ~CellAppearancePropertyPanel();
207 
208     void Initialize();
209     void SetStyleIcon();
210     void UpdateControlState();
211 };
212 
213 } } // end of namespace ::sc::sidebar
214 
215 #endif
216 // eof
217