create();
}
-RenderColor::RenderColor(int screen, unsigned char red,
- unsigned char green, unsigned char blue)
- : _screen(screen),
- _red(red),
- _green(green),
- _blue(blue),
- _gc(0)
-{
- create();
-}
-
RenderColor::RenderColor(int screen, RGB rgb)
: _screen(screen),
_red(rgb.r),
namespace otk {
class RenderColor {
+public:
struct RGB {
int r;
int g;
g((color >> 8) & 0xff),
b((color) & 0xff) {}
};
-
+
+private:
struct CacheItem {
GC gc;
int count;
#endif // HAVE_CONFIG_H
#include "renderstyle.hh"
-#include "rendercolor.hh"
-#include "rendertexture.hh"
namespace otk {
-RenderStyle(int screen, const std::string &stylefile)
+RenderStyle::RenderStyle(int screen, const std::string &stylefile)
: _screen(screen),
_file(stylefile)
{
- _text_focus_color = new RenderColor(_screen, 0x272a2f);
- _text_unfocus_color = new RenderColor(_screen, 0x676869);
+ _text_color_focus = new RenderColor(_screen, 0x272a2f);
+ _text_color_unfocus = new RenderColor(_screen, 0x676869);
+
+ _button_color_focus = new RenderColor(_screen, 0x96ba86);
+ _button_color_unfocus = new RenderColor(_screen, 0x676869);
_frame_border_color = new RenderColor(_screen, 0x181f24);
_frame_border_width = 1;
_client_border_color_unfocus = new RenderColor(_screen, 0x555657);
_client_border_width = 1;
- _titlebar_focus = new RenderTexture(false,
+ _titlebar_focus = new RenderTexture(_screen,
+ false,
RenderTexture::Flat,
RenderTexture::Bevel1,
false,
0x858687,
0x373a3f,
0x0,
- 0x0,
- 0x0,
0x0);
- _titlebar_unfocus = new RenderTexture(false,
+ _titlebar_unfocus = new RenderTexture(_screen,
+ false,
RenderTexture::Flat,
RenderTexture::Bevel1,
false,
0x555657,
0x171a1f,
0x0,
- 0x0,
- 0x0,
0x0);
- _label_focus = new RenderTexture(false,
+ _label_focus = new RenderTexture(_screen,
+ false,
RenderTexture::Flat,
RenderTexture::Bevel1,
true,
false,
0x858687,
0x373a3f,
- 0x0,
- 0x0,
0x181f24,
0x0);
- _label_unfocus = new RenderTexture(false,
+ _label_unfocus = new RenderTexture(_screen,
+ false,
RenderTexture::Sunken,
RenderTexture::Bevel1,
false,
false,
0x555657,
0x272a2f,
- //XXX,
- //XXX,
0x0,
0x0);
- _handle_focus = new RenderTexture(false,
+ _handle_focus = new RenderTexture(_screen,
+ false,
RenderTexture::Flat,
RenderTexture::Bevel1,
true,
0x858687,
0x373a3f,
0x0,
- 0x0,
- 0x0,
0x0);
- _handle_unfocus = new RenderTexture(false,
+ _handle_unfocus = new RenderTexture(_screen,
+ false,
RenderTexture::Flat,
RenderTexture::Bevel1,
false,
0x555657,
0x171a1f,
0x0,
- 0x0,
- 0x0,
0x0);
+
+ _button_unpress_focus = new RenderTexture(_screen,
+ false,
+ RenderTexture::Raised,
+ RenderTexture::Bevel2,
+ false,
+ RenderTexture::CrossDiagonal,
+ false,
+ 0x858687,
+ 0x272a2f,
+ 0x0,
+ 0x0);
+ _button_unpress_unfocus = new RenderTexture(_screen,
+ false,
+ RenderTexture::Raised,
+ RenderTexture::Bevel2,
+ false,
+ RenderTexture::CrossDiagonal,
+ false,
+ 0x555657,
+ 0x171a1f,
+ 0x0,
+ 0x0);
+
+ _button_press_focus = new RenderTexture(_screen,
+ false,
+ RenderTexture::Sunken,
+ RenderTexture::Bevel2,
+ false,
+ RenderTexture::CrossDiagonal,
+ false,
+ 0x96ba86,
+ 0x5a724c,
+ 0x0,
+ 0x0);
+ _button_press_unfocus = new RenderTexture(_screen,
+ false,
+ RenderTexture::Sunken,
+ RenderTexture::Bevel2,
+ false,
+ RenderTexture::CrossDiagonal,
+ false,
+ 0x555657,
+ 0x171a1f,
+ 0x0,
+ 0x0);
+
+ _grip_focus = new RenderTexture(_screen,
+ false,
+ RenderTexture::Flat,
+ RenderTexture::Bevel1,
+ false,
+ RenderTexture::Vertical,
+ false,
+ 0x96ba86,
+ 0x5a724c,
+ 0x0,
+ 0x0);
+ _grip_unfocus = new RenderTexture(_screen,
+ false,
+ RenderTexture::Flat,
+ RenderTexture::Bevel1,
+ false,
+ RenderTexture::Vertical,
+ false,
+ 0x555657,
+ 0x171a1f,
+ 0x0,
+ 0x0);
+
+ _label_font = new Font(_screen, "Arial,Sans-9:bold", true, 1, 0x40);
}
-virtual ~RenderStyle()
+RenderStyle::~RenderStyle()
{
+ delete _text_color_focus;
+ delete _text_color_unfocus;
+
+ delete _button_color_focus;
+ delete _button_color_unfocus;
+
+ delete _frame_border_color;
+
+ delete _client_border_color_focus;
+ delete _client_border_color_unfocus;
+
+ delete _titlebar_focus;
+ delete _titlebar_unfocus;
+
+ delete _label_focus;
+ delete _label_unfocus;
+
+ delete _handle_focus;
+ delete _handle_unfocus;
+
+ delete _button_unpress_focus;
+ delete _button_unpress_unfocus;
+ delete _button_press_focus;
+ delete _button_press_unfocus;
+
+ delete _grip_focus;
+ delete _grip_unfocus;
+
+ delete _label_font;
}
}
#define __renderstyle_hh
#include "rendertexture.hh"
+#include "rendercolor.hh"
+#include "font.hh"
#include <string>
int _screen;
std::string _file;
- RenderColor *_text_focus_color;
- RenderColor *_text_unfocus_color;
+ RenderColor *_text_color_focus;
+ RenderColor *_text_color_unfocus;
+
+ RenderColor *_button_color_focus;
+ RenderColor *_button_color_unfocus;
RenderColor *_frame_border_color;
- int _frame_border_wirth;
+ int _frame_border_width;
+
RenderColor *_client_border_color_focus;
RenderColor *_client_border_color_unfocus;
int _client_border_width;
inline RenderColor *textFocusColor() const { return _text_color_focus; }
inline RenderColor *textUnfocusColor() const { return _text_color_unfocus; }
+ inline RenderColor *buttonFocusColor() const { return _button_color_focus; }
+ inline RenderColor *buttonUnfocusColor() const
+ { return _button_color_unfocus; }
+
inline RenderColor *frameBorderColor() const { return _frame_border_color; }
- inline int frameBorderWidth() const { return _frame_border_wirth; }
+ inline int frameBorderWidth() const { return _frame_border_width; }
+
inline RenderColor *clientBorderFocusColor() const
{ return _client_border_color_focus; }
inline RenderColor *clientBorderUnfocusColor() const
inline RenderTexture *labelFocusBackground() const { return _label_focus; }
inline RenderTexture *labelUnfocusBackground() const { return _label_unfocus;}
- inline RenderTexture *handleFocusBackground() const { _handle_focus; }
- inline RenderTexture *handleUnfocusBackground() const { _handle_unfocus; }
+ inline RenderTexture *handleFocusBackground() const { return _handle_focus; }
+ inline RenderTexture *handleUnfocusBackground() const
+ { return _handle_unfocus; }
inline RenderTexture *buttonUnpressFocusBackground() const
{ return _button_unpress_focus; }
};
private:
+ int _screen;
+
//! If true, the texture is not rendered at all, so all options are ignored
bool _parent_relative;
//! The relief type of the texture
const RenderColor *_interlace_color;
public:
- RenderTexture(bool parent_relative, ReliefType relief, BevelType bevel,
+ RenderTexture(int screen,
+ bool parent_relative, ReliefType relief, BevelType bevel,
bool border, GradientType gradient, bool interlaced,
const RenderColor::RGB &color,
const RenderColor::RGB &secondary_color,
- const RenderColor::RGB &bevel_dark_color,
- const RenderColor::RGB &bevel_light_color,
const RenderColor::RGB &border_color,
const RenderColor::RGB &interlace_color)
- : _parent_relative(parent_relative),
+ : _screen(screen),
+ _parent_relative(parent_relative),
_relief(relief),
_bevel(bevel),
_border(border),
_gradient(gradient),
_interlaced(interlaced),
- _color(new RenderColor(color)),
- _secondary_color(new RenderColor(secondary_color)),
- _bevel_dark_color(new RenderColor(bevel_dark_color)),
- _bevel_light_color(new RenderColor(bevel_light_color)),
- _border_color(new RenderColor(border_color)),
- _interlace_color(new RenderColor(interlace_color))
+ _color(new RenderColor(screen, color)),
+ _secondary_color(new RenderColor(screen, secondary_color)),
+ _bevel_dark_color(0),
+ _bevel_light_color(0),
+ _border_color(new RenderColor(screen, border_color)),
+ _interlace_color(new RenderColor(screen, interlace_color))
{
+ if (_relief != Flat) {
+ unsigned char r, g, b;
+
+ // calculate the light bevel color
+ r = _color->red() + _color->red() / 2;
+ g = _color->green() + _color->green() / 2;
+ b = _color->blue() + _color->blue() / 2;
+ // watch for wraparound
+ if (r < _color->red()) r = 0xff;
+ if (g < _color->green()) g = 0xff;
+ if (b < _color->blue()) b = 0xff;
+ _bevel_dark_color = new RenderColor(screen, r, g, b);
+
+ // calculate the dark bevel color
+ r = _color->red() / 4 + _color->red() / 2;
+ g = _color->green() / 4 + _color->green() / 2;
+ b = _color->blue() / 4 + _color->blue() / 2;
+ _bevel_light_color = new RenderColor(screen, r, g, b);
+ }
+
assert(_relief == Flat || (_bevel_dark_color && _bevel_light_color));
assert(!_border || _border_color);
assert(!_interlaced || _interlace_color);
virtual ~RenderTexture() {
delete _color;
delete _secondary_color;
- delete _bevel_dark_color;
- delete _bevel_light_color;
+ if (_bevel_dark_color) delete _bevel_dark_color;
+ if (_bevel_dark_color) delete _bevel_light_color;
delete _border_color;
delete _interlace_color;
}