]>
Dogcows Code - chaz/openbox/blob - otk/rendertexture.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __rendertexture_hh
3 #define __rendertexture_hh
5 #include "rendercolor.hh"
9 //! Superclass for all the Textures
36 //! If true, the texture is not rendered at all, so all options are ignored
37 bool _parent_relative
;
38 //! The relief type of the texture
40 //! The way the bevel should be drawn
42 //! If a flat border is drawn on the outside, ignored for all ReliefType
43 //! values except ReliefType::Flat
45 //! The type of gradient to fill the texture with (if any)
46 GradientType _gradient
;
47 //! If interlace lines should be drawn over the texture
50 //! The base color for the texture, the only color when the texture is solid.
51 //! This must always be defined
52 const RenderColor
*_color
;
53 //! The secondary color for a gradient texture.
54 //! This is only defined for gradients
55 const RenderColor
*_secondary_color
;
56 //! The shadow color for the bevel. This must be defined if
57 //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
58 const RenderColor
*_bevel_dark_color
;
59 //! The light color for the bevel. This must be defined if
60 //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
61 const RenderColor
*_bevel_light_color
;
62 //! The color for the flat border if RenderTexture::_border is true. This
63 //! must be defined if it is true
64 const RenderColor
*_border_color
;
65 //! The color for the interlace lines if RenderTexture. This must be defined
67 const RenderColor
*_interlace_color
;
70 RenderTexture(int screen
,
71 bool parent_relative
, ReliefType relief
, BevelType bevel
,
72 bool border
, GradientType gradient
, bool interlaced
,
74 const RGB
&secondary_color
,
75 const RGB
&border_color
,
76 const RGB
&interlace_color
)
78 _parent_relative(parent_relative
),
83 _interlaced(interlaced
),
84 _color(new RenderColor(screen
, color
)),
85 _secondary_color(new RenderColor(screen
, secondary_color
)),
87 _bevel_light_color(0),
88 _border_color(new RenderColor(screen
, border_color
)),
89 _interlace_color(new RenderColor(screen
, interlace_color
))
91 if (_relief
!= Flat
) {
92 unsigned char r
, g
, b
;
94 // calculate the light bevel color
95 r
= _color
->red() + _color
->red() / 2;
96 g
= _color
->green() + _color
->green() / 2;
97 b
= _color
->blue() + _color
->blue() / 2;
98 // watch for wraparound
99 if (r
< _color
->red()) r
= 0xff;
100 if (g
< _color
->green()) g
= 0xff;
101 if (b
< _color
->blue()) b
= 0xff;
102 _bevel_dark_color
= new RenderColor(screen
, r
, g
, b
);
104 // calculate the dark bevel color
105 r
= _color
->red() / 4 + _color
->red() / 2;
106 g
= _color
->green() / 4 + _color
->green() / 2;
107 b
= _color
->blue() / 4 + _color
->blue() / 2;
108 _bevel_light_color
= new RenderColor(screen
, r
, g
, b
);
111 assert(_relief
== Flat
|| (_bevel_dark_color
&& _bevel_light_color
));
112 //assert(!_border || _border_color);
113 //assert(!_interlaced || _interlace_color);
115 assert(_secondary_color
);
116 assert(_border_color
);
117 assert(_interlace_color
);
120 virtual ~RenderTexture() {
122 delete _secondary_color
;
123 if (_bevel_dark_color
) delete _bevel_dark_color
;
124 if (_bevel_dark_color
) delete _bevel_light_color
;
125 delete _border_color
;
126 delete _interlace_color
;
129 //! If true, the texture is not rendered at all, so all options are ignored
130 inline bool parentRelative() const { return _parent_relative
; }
131 //! The relief type of the texture
132 inline ReliefType
relief() const { return _relief
; }
133 //! The way the bevel should be drawn
134 inline BevelType
bevel() const { return _bevel
; }
135 //! If a flat border is drawn on the outside, ignored for all ReliefType
136 //! values except ReliefType::Flat
137 inline bool border() const { return _border
; }
138 //! The type of gradient to fill the texture with (if any)
139 inline GradientType
gradient() const { return _gradient
; }
140 //! If interlace lines should be drawn over the texture
141 inline bool interlaced() const { return _interlaced
; }
143 //! The base color for the texture, the only color when the texture is solid.
144 //! This must always be defined
145 inline const RenderColor
& color() const { return *_color
; }
146 //! The secondary color for gradient textures.
147 //! This is only defined for gradients
148 inline const RenderColor
& secondary_color() const
149 { return *_secondary_color
; }
150 //! The shadow color for the bevel. This must be defined if
151 //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
152 inline const RenderColor
& bevelDarkColor() const
153 { return *_bevel_dark_color
; }
154 //! The light color for the bevel. This must be defined if
155 //! RenderTexture::)relief is not RenderTexture::ReliefType::Flat
156 inline const RenderColor
& bevelLightColor() const
157 { return *_bevel_light_color
; }
158 //! The color for the flat border if RenderTexture::_border is true. This
159 //! must be defined if it is true
160 inline const RenderColor
& borderColor() const { return *_border_color
; }
161 //! The color for the interlace lines if RenderTexture. This must be defined
163 inline const RenderColor
& interlaceColor() const
164 { return *_interlace_color
; }
169 #endif // __rendertexture_hh
This page took 0.039206 seconds and 4 git commands to generate.