xref: /aoo42x/main/sfx2/source/sidebar/Paint.hxx (revision 95a18594)
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 SFX_SIDEBAR_PAINT_HXX
23 #define SFX_SIDEBAR_PAINT_HXX
24 
25 #include <tools/color.hxx>
26 #include <vcl/gradient.hxx>
27 #include <vcl/wall.hxx>
28 #include <com/sun/star/awt/Gradient.hpp>
29 
30 #include <boost/variant.hpp>
31 
32 namespace cssu = ::com::sun::star::uno;
33 
34 namespace sfx2 { namespace sidebar {
35 
36 /** Abstraction of different ways to fill outlines.
37     Can be
38      - none (empty: outline is not filled)
39      - singular color
40      - gradient
41 */
42 class Paint
43 {
44 public:
45     enum Type
46     {
47         NoPaint,
48         ColorPaint,
49         GradientPaint
50     };
51 
52     // Create a Paint object for an Any that may contain a color, a
53     // awt::Gradient, or nothing.
54     static Paint Create (const cssu::Any& rValue);
55 
56     // Create paint with type NoPaint.
57     explicit Paint (void);
58 
59     // Create a Paint object for the given color.
60     explicit Paint (const Color& rColor);
61 
62     // Create a Paint object for the given gradient.
63     explicit Paint (const Gradient& rGradient);
64 
65     void Set (const ::sfx2::sidebar::Paint& rOther);
66 
67     Type GetType (void) const;
68     const Color& GetColor (void) const;
69     const Gradient& GetGradient (void) const;
70 
71     Wallpaper GetWallpaper (void) const;
72 
73 private:
74     Type meType;
75     ::boost::variant<
76         Color,
77         Gradient
78     > maValue;
79 };
80 
81 
82 } } // end of namespace sfx2::sidebar
83 
84 #endif
85