]> icculus.org git repositories - dana/openbox.git/blob - otk/rendertexture.hh
Added a secondary color for gradients
[dana/openbox.git] / otk / rendertexture.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __rendertexture_hh
3 #define __rendertexture_hh
4
5 #include "rendercolor.hh"
6
7 namespace otk {
8
9 //! Superclass for all the Textures
10 class RenderTexture {
11 public:
12   enum ReliefType {
13     Flat,
14     Raised,
15     Sunken
16   };
17   enum BevelType {
18     Bevel1,
19     Bevel2
20   };
21   enum GradientType {
22     Solid,
23     Horizontal,
24     Vertical,
25     Diagonal,
26     CrossDiagonal,
27     PipeCross,
28     Rectangle,
29     Pyramid,
30     Elliptic
31   };
32
33 private:
34   //! If true, the texture is not rendered at all, so all options are ignored
35   bool _parent_relative;
36   //! The relief type of the texture
37   ReliefType _relief;
38   //! The way the bevel should be drawn
39   BevelType _bevel;
40   //! If a flat border is drawn on the outside, ignored for all ReliefType
41   //! values except ReliefType::Flat
42   bool _border;
43   //! The type of gradient to fill the texture with (if any)
44   GradientType _gradient;
45   //! If interlace lines should be drawn over the texture
46   bool _interlaced;
47
48   //! The base color for the texture, the only color when the texture is solid.
49   //! This must always be defined
50   const RenderColor *_color;
51   //! The secondary color for a gradient texture.
52   //! This is only defined for gradients
53   const RenderColor *_secondary_color;
54   //! The shadow color for the bevel. This must be defined if
55   //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
56   const RenderColor *_bevel_dark_color;
57   //! The light color for the bevel. This must be defined if
58   //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
59   const RenderColor *_bevel_light_color;
60   //! The color for the flat border if RenderTexture::_border is true. This
61   //! must be defined if it is true
62   const RenderColor *_border_color;
63   //! The color for the interlace lines if RenderTexture. This must be defined
64   //! if it is true
65   const RenderColor *_interlace_color;
66
67 public:
68   RenderTexture(bool parent_relative, ReliefType relief, BevelType bevel,
69                 bool border, GradientType gradient, bool interlaced,
70                 const RenderColor *color, const RenderColor *secondary_color,
71                 const RenderColor *bevel_dark_color,
72                 const RenderColor *bevel_light_color,
73                 const RenderColor *border_color,
74                 const RenderColor *interlace_color)
75     : _parent_relative(parent_relative),
76       _relief(relief),
77       _bevel(bevel),
78       _border(border),
79       _gradient(gradient),
80       _interlaced(interlaced),
81       _color(color),
82       _secondary_color(secondary_color),
83       _bevel_dark_color(bevel_dark_color),
84       _bevel_light_color(bevel_light_color),
85       _border_color(border_color),
86       _interlace_color(interlace_color)
87     {
88       assert(_relief == Flat || (_bevel_dark_color && _bevel_light_color));
89       assert(!_border || _border_color);
90       assert(!_interlaced || _interlace_color);
91       assert(_color);
92     }
93
94   //! If true, the texture is not rendered at all, so all options are ignored
95   inline bool parentRelative() const { return _parent_relative; }
96   //! The relief type of the texture
97   inline ReliefType relief() const { return _relief; }
98   //! The way the bevel should be drawn
99   inline BevelType bevel() const { return _bevel; }
100   //! If a flat border is drawn on the outside, ignored for all ReliefType
101   //! values except ReliefType::Flat
102   inline bool border() const { return _border; }
103   //! The type of gradient to fill the texture with (if any)
104   inline GradientType gradient() const { return _gradient; }
105   //! If interlace lines should be drawn over the texture
106   inline bool interlaced() const { return _interlaced; }
107
108   //! The base color for the texture, the only color when the texture is solid.
109   //! This must always be defined
110   inline const RenderColor& color() const { return *_color; }
111   //! The secondary color for gradient textures.
112   //! This is only defined for gradients
113   inline const RenderColor& secondary_color() const
114     { return *_secondary_color; }
115   //! The shadow color for the bevel. This must be defined if
116   //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
117   inline const RenderColor& bevelDarkColor() const
118     { return *_bevel_dark_color; }
119   //! The light color for the bevel. This must be defined if
120   //! RenderTexture::)relief is not RenderTexture::ReliefType::Flat
121   inline const RenderColor& bevelLightColor() const
122     { return *_bevel_light_color; }
123   //! The color for the flat border if RenderTexture::_border is true. This
124   //! must be defined if it is true
125   inline const RenderColor& borderColor() const { return *_border_color; }
126   //! The color for the interlace lines if RenderTexture. This must be defined
127   //! if it is true
128   inline const RenderColor& interlaceColor() const
129     { return *_interlace_color; }
130 };
131
132 }
133
134 #endif // __rendertexture_hh