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 #include "svx/sidebar/PopupControl.hxx"
23 
24 #include <svtools/valueset.hxx>
25 #include <boost/function.hpp>
26 #include <svx/SvxColorValueSet.hxx>
27 
28 class Window;
29 class SfxBindings;
30 class RedId;
31 class FloatingWindow;
32 
33 
34 namespace svx { namespace sidebar {
35 
36 /** The ColorControl uses a ValueSet control for displaying all named
37     colors in a matrix.
38 */
39 class SVX_DLLPUBLIC ColorControl
40     : public PopupControl
41 {
42 public:
43     /** Create a new ColorControl object.
44         @param rControlResId
45             The resource id for the whole color control.
46         @param rNoColorGetter
47             A functor for getting the color which will be returned when the
48             WB_NONEFIELD is used and got selected
49         @param rColorSetter
50             A functor for setting the color that is selected by the
51             user.
52         @param pNoColorStringResId
53             Resource id of an optional string for the "no color"
54             string.  When a value is given then a
55             field/button is created above the color matrix for
56             selecting "no color" ie. transparent.
57             When zero is given then no such field is created.
58     */
59 	ColorControl (
60         Window* pParent,
61         SfxBindings* pBindings,
62         const ResId& rControlResId,
63         const ResId& rValueSetResId,
64         const ::boost::function<Color(void)>& rNoColorGetter,
65         const ::boost::function<void(String&,Color)>& rColorSetter,
66         FloatingWindow* pFloatingWindow,
67         const ResId* pNoColorStringResId);
68     virtual ~ColorControl (void);
69 
70 	void GetFocus (void);
71 	void SetCurColorSelect (
72         const Color aCol,
73         const bool bAvl);
74 
75 private:
76 	SfxBindings* mpBindings;
77 	SvxColorValueSet maVSColor;
78     FloatingWindow* mpFloatingWindow;
79     const String msNoColorString;
80     ::boost::function<Color(void)> maNoColorGetter;
81     ::boost::function<void(String&,Color)> maColorSetter;
82 
83 	void FillColors (void);
84 	DECL_LINK(VSSelectHdl, void *);
85 };
86 
87 } } // end of namespace svx::sidebar
88