]>
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
,
73 const RenderColor::RGB
&color
,
74 const RenderColor::RGB
&secondary_color
,
75 const RenderColor::RGB
&border_color
,
76 const RenderColor::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
);
117 virtual ~RenderTexture() {
119 delete _secondary_color
;
120 if (_bevel_dark_color
) delete _bevel_dark_color
;
121 if (_bevel_dark_color
) delete _bevel_light_color
;
122 delete _border_color
;
123 delete _interlace_color
;
126 //! If true, the texture is not rendered at all, so all options are ignored
127 inline bool parentRelative() const { return _parent_relative
; }
128 //! The relief type of the texture
129 inline ReliefType
relief() const { return _relief
; }
130 //! The way the bevel should be drawn
131 inline BevelType
bevel() const { return _bevel
; }
132 //! If a flat border is drawn on the outside, ignored for all ReliefType
133 //! values except ReliefType::Flat
134 inline bool border() const { return _border
; }
135 //! The type of gradient to fill the texture with (if any)
136 inline GradientType
gradient() const { return _gradient
; }
137 //! If interlace lines should be drawn over the texture
138 inline bool interlaced() const { return _interlaced
; }
140 //! The base color for the texture, the only color when the texture is solid.
141 //! This must always be defined
142 inline const RenderColor
& color() const { return *_color
; }
143 //! The secondary color for gradient textures.
144 //! This is only defined for gradients
145 inline const RenderColor
& secondary_color() const
146 { return *_secondary_color
; }
147 //! The shadow color for the bevel. This must be defined if
148 //! RenderTexture::_relief is not RenderTexture::ReliefType::Flat
149 inline const RenderColor
& bevelDarkColor() const
150 { return *_bevel_dark_color
; }
151 //! The light color for the bevel. This must be defined if
152 //! RenderTexture::)relief is not RenderTexture::ReliefType::Flat
153 inline const RenderColor
& bevelLightColor() const
154 { return *_bevel_light_color
; }
155 //! The color for the flat border if RenderTexture::_border is true. This
156 //! must be defined if it is true
157 inline const RenderColor
& borderColor() const { return *_border_color
; }
158 //! The color for the interlace lines if RenderTexture. This must be defined
160 inline const RenderColor
& interlaceColor() const
161 { return *_interlace_color
; }
166 #endif // __rendertexture_hh
This page took 0.044979 seconds and 4 git commands to generate.