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