(void)argc;
(void)argv;
- const ScreenInfo *s_info = _display.screenInfo(DefaultScreen(*_display));
-
Timer::initialize();
RenderColor::initialize();
Property::initialize();
- _img_ctrl = new ImageControl(s_info, True, 4, 5, 200);
- _style_conf = new Configuration(False);
- _style = new Style(_img_ctrl);
+ _style = new RenderStyle(DefaultScreen(*_display), ""); // XXX: get a path!
loadStyle();
}
Application::~Application()
{
- delete _style_conf;
- delete _img_ctrl;
delete _style;
RenderColor::destroy();
Timer::destroy();
void Application::loadStyle(void)
{
- // find the style name as a property
+ // XXX: find the style name as a property
std::string style = "/usr/local/share/openbox/styles/artwiz";
- _style_conf->setFile(style);
- if (!_style_conf->load()) {
- std::cerr << "ERROR: Unable to load style \"" << style << "\".\n";
- ::exit(1);
- }
- _style->load(*_style_conf);
+ //_style->load(style);
}
void Application::run(void)
#include "eventdispatcher.hh"
#include "display.hh"
-#include "configuration.hh"
-#include "image.hh"
-#include "style.hh"
+#include "renderstyle.hh"
namespace otk {
void setDockable(bool dockable) { _dockable = dockable; }
inline bool isDockable(void) const { return _dockable; }
- inline Style *getStyle(void) const { return _style; }
+ inline RenderStyle *getStyle(void) const { return _style; }
// more accessors
private:
void loadStyle(void);
Display _display;
- ImageControl *_img_ctrl;
- Configuration *_style_conf;
- Style *_style;
+ RenderStyle *_style;
bool _dockable;
int _appwidget_count;
namespace otk {
AppWidget::AppWidget(Application *app, Direction direction,
- Cursor cursor, int bevel_width)
+ Cursor cursor, int bevel_width)
: Widget(app, app->getStyle(), direction, cursor, bevel_width),
_application(app)
{
}
-void Button::setStyle(Style *style)
+void Button::setStyle(RenderStyle *style)
{
FocusLabel::setStyle(style);
- // XXX: do this again
- //setTexture(style->getButtonFocus());
- //setUnfocusTexture(style->getButtonUnfocus());
- //_pressed_focus_tx = style->getButtonPressedFocus();
- //_pressed_unfocus_tx = style->getButtonPressedUnfocus();
+ setTexture(style->buttonUnpressFocusBackground());
+ setUnfocusTexture(style->buttonUnpressUnfocusBackground());
+ _pressed_focus_tx = style->buttonPressFocusBackground();
+ _pressed_unfocus_tx = style->buttonPressUnfocusBackground();
}
void buttonPressHandler(const XButtonEvent &e);
void buttonReleaseHandler(const XButtonEvent &e);
- virtual void setStyle(Style *style);
+ virtual void setStyle(RenderStyle *style);
private:
}
-void FocusLabel::setStyle(Style *style)
+void FocusLabel::setStyle(RenderStyle *style)
{
FocusWidget::setStyle(style);
- // XXX: do this again
- //setTexture(style->getLabelFocus());
- //setUnfocusTexture(style->getLabelUnfocus());
+ setTexture(style->labelFocusBackground());
+ setUnfocusTexture(style->labelUnfocusBackground());
}
void FocusLabel::renderForeground(void)
{
- const Font *ft = style()->getFont();
- Color *text_color = (isFocused() ? style()->getTextFocus()
- : style()->getTextUnfocus());
- unsigned int sidemargin = style()->getBevelWidth() * 2;
+ const Font *ft = style()->labelFont();
+ RenderColor *text_color = (isFocused() ? style()->textFocusColor()
+ : style()->textUnfocusColor());
+ unsigned int sidemargin = style()->bevelWidth() * 2;
ustring t = _text; // the actual text to draw
int x = sidemargin; // x coord for the text
} while (length > max_length && text_len-- > 0);
// justify the text
- switch (style()->textJustify()) {
- case Style::RightJustify:
+ switch (style()->labelTextJustify()) {
+ case RenderStyle::RightJustify:
x += max_length - length;
break;
- case Style::CenterJustify:
+ case RenderStyle::CenterJustify:
x += (max_length - length) / 2;
break;
- case Style::LeftJustify:
+ case RenderStyle::LeftJustify:
break;
}
}
void renderForeground(void);
- virtual void setStyle(Style *style);
+ virtual void setStyle(RenderStyle *style);
private:
//! Text displayed in the label
_focus_texture = texture;
}
-void FocusWidget::setBorderColor(const Color *color)
+void FocusWidget::setBorderColor(const RenderColor *color)
{
Widget::setBorderColor(color);
_focus_bcolor = color;
virtual void unfocus(void);
virtual void setTexture(RenderTexture *texture);
- virtual void setBorderColor(const Color *color);
+ virtual void setBorderColor(const RenderColor *color);
inline void setUnfocusTexture(RenderTexture *texture)
{ _unfocus_texture = texture; }
inline RenderTexture *getUnfocusTexture(void) const
{ return _unfocus_texture; }
- inline void setUnfocusBorderColor(const Color *color)
+ inline void setUnfocusBorderColor(const RenderColor *color)
{ _unfocus_bcolor = color; }
- inline const Color *getUnfocusBorderColor(void) const
+ inline const RenderColor *getUnfocusBorderColor(void) const
{ return _unfocus_bcolor; }
inline bool isFocused(void) const { return _focused; }
RenderTexture *_unfocus_texture;
RenderTexture *_focus_texture;
- const Color *_unfocus_bcolor;
- const Color *_focus_bcolor;
+ const RenderColor *_unfocus_bcolor;
+ const RenderColor *_focus_bcolor;
};
}
{
}
-void Label::setStyle(Style *style)
+void Label::setStyle(RenderStyle *style)
{
Widget::setStyle(style);
- // XXX: do this again
- //setTexture(style->getLabelUnfocus());
+ setTexture(style->labelUnfocusBackground());
}
void Label::renderForeground(void)
{
- const Font *ft = style()->getFont();
- unsigned int sidemargin = style()->getBevelWidth() * 2;
+ const Font *ft = style()->labelFont();
+ unsigned int sidemargin = style()->bevelWidth() * 2;
ustring t = _text; // the actual text to draw
int x = sidemargin; // x coord for the text
} while (length > max_length && text_len-- > 0);
// justify the text
- switch (style()->textJustify()) {
- case Style::RightJustify:
+ switch (style()->labelTextJustify()) {
+ case RenderStyle::RightJustify:
x += max_length - length;
break;
- case Style::CenterJustify:
+ case RenderStyle::CenterJustify:
x += (max_length - length) / 2;
break;
- case Style::LeftJustify:
+ case RenderStyle::LeftJustify:
break;
}
}
display->renderControl(_screen)->
- drawString(*_surface, *ft, x, 0, *style()->getTextUnfocus(), t);
+ drawString(*_surface, *ft, x, 0, *style()->textUnfocusColor(), t);
}
}
virtual void renderForeground(void);
- virtual void setStyle(Style *style);
+ virtual void setStyle(RenderStyle *style);
private:
//! Text to be displayed in the label
otk::AppWidget foo(&app);
foo.resize(600, 500);
- foo.setTexture(app.getStyle()->getTitleFocus());
-// foo.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
+ foo.setTexture(app.getStyle()->titlebarFocusBackground());
+// foo.setUnfocusTexture(app.getStyle()->titlebarUnfocusBackground());
foo.setBevelWidth(2);
foo.setDirection(otk::Widget::Horizontal);
left.setDirection(otk::Widget::Horizontal);
left.setStretchableVert(true);
left.setStretchableHorz(true);
- left.setTexture(app.getStyle()->getTitleFocus());
- left.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
+ left.setTexture(app.getStyle()->titlebarFocusBackground());
+ left.setUnfocusTexture(app.getStyle()->titlebarUnfocusBackground());
right.setDirection(otk::Widget::Vertical);
right.setBevelWidth(10);
right.setStretchableVert(true);
right.setWidth(300);
- right.setTexture(app.getStyle()->getTitleFocus());
- right.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
+ right.setTexture(app.getStyle()->titlebarFocusBackground());
+ right.setUnfocusTexture(app.getStyle()->titlebarUnfocusBackground());
otk::Button iconb(&left);
iconb.resize(40,20);
//label.setHeight(20);
label.setStretchableVert(true);
label.setStretchableHorz(true);
- label.setTexture(app.getStyle()->getLabelFocus());
- label.setUnfocusTexture(app.getStyle()->getLabelUnfocus());
+ label.setTexture(app.getStyle()->labelFocusBackground());
+ label.setUnfocusTexture(app.getStyle()->labelUnfocusBackground());
// fixed size
maxb.setText("bar");
rblef.setStretchableHorz(true);
rblef.setHeight(50);
- rblef.setTexture(app.getStyle()->getHandleFocus());
- rblef.setUnfocusTexture(app.getStyle()->getHandleUnfocus());
+ rblef.setTexture(app.getStyle()->handleFocusBackground());
+ rblef.setUnfocusTexture(app.getStyle()->handleUnfocusBackground());
rbutt1.setText("this is fucking tight");
rbutt2.setText("heh, WOOP");
foo.show();
- app.exec();
+ app.run();
return 0;
}
xcol.pixel = 0;
}
- gcv.foreground = xcol.pixel;
+ _pixel = xcol.pixel;
+ gcv.foreground = _pixel;
gcv.cap_style = CapProjecting;
_gc = XCreateGC(**display, info->rootWindow(),
GCForeground | GCCapStyle, &gcv);
unsigned char _red;
unsigned char _green;
unsigned char _blue;
+ unsigned long _pixel;
GC _gc;
inline unsigned char red() const { return _red; }
inline unsigned char green() const { return _green; }
inline unsigned char blue() const { return _blue; }
+ inline unsigned long pixel() const { return _pixel; }
inline GC gc() const { return _gc; }
};
#include "rendercontrol.hh"
#include "truerendercontrol.hh"
#include "rendertexture.hh"
+#include "rendercolor.hh"
#include "display.hh"
#include "screeninfo.hh"
#include "surface.hh"
-#include "color.hh"
#include "font.hh"
#include "ustring.hh"
}
void RenderControl::drawString(Surface& sf, const Font &font, int x, int y,
- const Color &color, const ustring &string) const
+ const RenderColor &color,
+ const ustring &string) const
{
assert(sf._screen == _screen);
XftDraw *d = sf._xftdraw;
class Surface;
class RenderTexture;
class Font;
-class Color;
+class RenderColor;
class ustring;
class RenderControl {
//! Draws a string onto a Surface
virtual void drawString(Surface& sf, const Font& font, int x, int y,
- const Color& color, const ustring& string) const;
+ const RenderColor& color,
+ const ustring& string) const;
//! Draws a background onto a Surface, as specified by a RenderTexture
virtual void drawBackground(Surface& sf,
RenderStyle(int screen, const std::string &stylefile);
virtual ~RenderStyle();
+ inline int screen() const { return _screen; }
+
inline RenderColor *textFocusColor() const { return _text_color_focus; }
inline RenderColor *textUnfocusColor() const { return _text_color_unfocus; }
{ return _button_unpress_unfocus; }
inline RenderTexture *buttonPressFocusBackground() const
{ return _button_press_focus; }
- inline RenderTexture *buttonPressUnfocusBackgrounf() const
+ inline RenderTexture *buttonPressUnfocusBackground() const
{ return _button_press_unfocus; }
inline RenderTexture *gripdFocusBackground() const { return _grip_focus; }
setStyle(_style); // let the widget initialize stuff
}
-Widget::Widget(EventDispatcher *event_dispatcher, Style *style,
- Direction direction, Cursor cursor, int bevel_width,
- bool override_redirect)
+Widget::Widget(EventDispatcher *event_dispatcher, RenderStyle *style,
+ Direction direction, Cursor cursor, int bevel_width,
+ bool override_redirect)
: EventHandler(),
_dirty(false),_focused(false),
_parent(0), _style(style), _direction(direction), _cursor(cursor),
_grabbed_mouse(false), _grabbed_keyboard(false),
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
_bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
- _screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
+ _screen(style->screen()), _fixed_width(false), _fixed_height(false),
_surface(0),
_event_dispatcher(event_dispatcher)
{
_children.erase(it);
}
-void Widget::setStyle(Style *style)
+void Widget::setStyle(RenderStyle *style)
{
assert(style);
_style = style;
void Widget::configureHandler(const XConfigureEvent &e)
{
EventHandler::configureHandler(e);
+
if (_ignore_config) {
_ignore_config--;
} else {
- if (!(e.width == _rect.width() && e.height == _rect.height())) {
+ int width = e.width;
+ int height = e.height;
+
+ XEvent ev;
+ while (XCheckTypedWindowEvent(**display, _window, ConfigureNotify, &ev)) {
+ width = ev.xconfigure.width;
+ height = ev.xconfigure.height;
+ }
+
+ if (!(width == _rect.width() && height == _rect.height())) {
_dirty = true;
- _rect.setSize(e.width, e.height);
+ _rect.setSize(width, height);
}
update();
}
#include "rect.hh"
#include "point.hh"
#include "rendertexture.hh"
-#include "style.hh"
+#include "renderstyle.hh"
#include "eventdispatcher.hh"
#include "display.hh"
#include "surface.hh"
typedef std::list<Widget *> WidgetList;
Widget(Widget *parent, Direction = Horizontal);
- Widget(EventDispatcher *event_dispatcher, Style *style,
+ Widget(EventDispatcher *event_dispatcher, RenderStyle *style,
Direction direction = Horizontal, Cursor cursor = 0,
int bevel_width = 1, bool override_redirect = false);
virtual void setTexture(RenderTexture *texture)
{ _texture = texture; _dirty = true; }
- inline const Color *borderColor(void) const { return _bcolor; }
- virtual void setBorderColor(const Color *color) {
+ inline const RenderColor *borderColor(void) const { return _bcolor; }
+ virtual void setBorderColor(const RenderColor *color) {
assert(color); _bcolor = color;
XSetWindowBorder(**display, _window, color->pixel());
}
inline Direction direction(void) const { return _direction; }
void setDirection(Direction dir) { _direction = dir; }
- inline Style *style(void) const { return _style; }
- virtual void setStyle(Style *style);
+ inline RenderStyle *style(void) const { return _style; }
+ virtual void setStyle(RenderStyle *style);
inline EventDispatcher *eventDispatcher(void)
{ return _event_dispatcher; }
Widget *_parent;
WidgetList _children;
- Style *_style;
+ RenderStyle *_style;
Direction _direction;
Cursor _cursor;
int _bevel_width;
Pixmap _bg_pixmap;
unsigned int _bg_pixel;
- const Color *_bcolor;
+ const RenderColor *_bcolor;
unsigned int _bwidth;
Rect _rect;