: OtkFocusLabel(parent), _pressed(false), _pressed_focus_tx(0),
_pressed_unfocus_tx(0), _unpr_focus_tx(0), _unpr_unfocus_tx(0)
{
- setStyle(getStyle());
}
OtkButton::~OtkButton()
const ScreenInfo *info = OBDisplay::screenInfo(getScreen());
_xftdraw = XftDrawCreate(OBDisplay::display, getWindow(), info->getVisual(),
info->getColormap());
- setStyle(getStyle());
}
OtkFocusLabel::~OtkFocusLabel()
namespace otk {
OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
- : OtkWidget(parent, direction), _unfocus_texture(0), _focused(true)
+ : OtkWidget(parent, direction), _unfocus_texture(0), _unfocus_bcolor(0)
{
+ _focused = true;
_focus_texture = parent->getTexture();
+ _focus_bcolor = parent->getBorderColor();
}
OtkFocusWidget::~OtkFocusWidget()
{
}
+#include <stdio.h>
void OtkFocusWidget::focus(void)
{
- if (_focused)
+ if (!isVisible() || _focused)
return;
- // XXX: what about OtkWidget::focus()
+ printf("FOCUS\n");
+ OtkWidget::focus();
+
+ if (_focus_bcolor)
+ OtkWidget::setBorderColor(_focus_bcolor);
- assert(_focus_texture);
OtkWidget::setTexture(_focus_texture);
OtkWidget::update();
-
- OtkWidget::OtkWidgetList children = OtkWidget::getChildren();
-
- OtkWidget::OtkWidgetList::iterator it = children.begin(),
- end = children.end();
-
- OtkFocusWidget *tmp = 0;
- for (; it != end; ++it) {
- tmp = dynamic_cast<OtkFocusWidget*>(*it);
- if (tmp) tmp->focus();
- }
}
void OtkFocusWidget::unfocus(void)
{
- if (! _focused)
+ if (!isVisible() || !_focused)
return;
- assert(_unfocus_texture);
+ printf("UNFOCUS\n");
+ OtkWidget::unfocus();
+
+ if (_unfocus_bcolor)
+ OtkWidget::setBorderColor(_unfocus_bcolor);
+
OtkWidget::setTexture(_unfocus_texture);
OtkWidget::update();
_focus_texture = texture;
}
+void OtkFocusWidget::setBorderColor(const BColor *color)
+{
+ OtkWidget::setBorderColor(color);
+ _focus_bcolor = color;
+}
+
}
virtual void focus(void);
virtual void unfocus(void);
- void setTexture(BTexture *texture);
+ virtual void setTexture(BTexture *texture);
+ virtual void setBorderColor(const BColor *color);
inline void setUnfocusTexture(BTexture *texture)
{ _unfocus_texture = texture; }
inline BTexture *getUnfocusTexture(void) const
{ return _unfocus_texture; }
+ inline void setUnfocusBorderColor(const BColor *color)
+ { _unfocus_bcolor = color; }
+ inline const BColor *getUnfocusBorderColor(void) const
+ { return _unfocus_bcolor; }
+
inline bool isFocused(void) const { return _focused; }
inline bool isUnfocused(void) const { return !_focused; }
BTexture *_unfocus_texture;
BTexture *_focus_texture;
- bool _focused;
+ const BColor *_unfocus_bcolor;
+ const BColor *_focus_bcolor;
};
}
const ScreenInfo *info = OBDisplay::screenInfo(getScreen());
_xftdraw = XftDrawCreate(OBDisplay::display, getWindow(), info->getVisual(),
info->getColormap());
-
- setStyle(getStyle());
}
OtkLabel::~OtkLabel()
void update(void);
virtual void setStyle(Style *style);
-
+
private:
//! Object used by Xft to render to the drawable
XftDraw *_xftdraw;
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
: OtkEventHandler(),
- _dirty(false),
+ _dirty(false), _focused(false),
_parent(parent), _style(parent->getStyle()), _direction(direction),
_cursor(parent->getCursor()), _bevel_width(parent->getBevelWidth()),
_ignore_config(0),
- _visible(false), _focused(false), _grabbed_mouse(false),
+ _visible(false), _grabbed_mouse(false),
_grabbed_keyboard(false), _stretchable_vert(false),
_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
- _screen(parent->getScreen()), _fixed_width(false), _fixed_height(false),
- _event_dispatcher(parent->getEventDispatcher()), _application(0)
+ _bcolor(0), _bwidth(0), _screen(parent->getScreen()), _fixed_width(false),
+ _fixed_height(false), _event_dispatcher(parent->getEventDispatcher())
{
assert(parent);
parent->addChild(this);
create();
_event_dispatcher->registerHandler(_window, this);
+ setStyle(_style); // let the widget initialize stuff
}
OtkWidget::OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
Direction direction, Cursor cursor, int bevel_width)
: OtkEventHandler(),
- _dirty(false),
+ _dirty(false),_focused(false),
_parent(0), _style(style), _direction(direction), _cursor(cursor),
_bevel_width(bevel_width), _ignore_config(0), _visible(false),
- _focused(false), _grabbed_mouse(false), _grabbed_keyboard(false),
+ _grabbed_mouse(false), _grabbed_keyboard(false),
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
- _bg_pixmap(0), _bg_pixel(0), _screen(style->getScreen()),
- _fixed_width(false), _fixed_height(false),
- _event_dispatcher(event_dispatcher), _application(0)
+ _bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0),
+ _screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
+ _event_dispatcher(event_dispatcher)
{
assert(event_dispatcher);
assert(style);
create();
_event_dispatcher->registerHandler(_window, this);
+ setStyle(_style); // let the widget initialize stuff
}
OtkWidget::~OtkWidget()
void OtkWidget::focus(void)
{
- if (! _visible)
+/* if (! _visible)
return;
XSetInputFocus(otk::OBDisplay::display, _window, RevertToPointerRoot,
- CurrentTime);
+ CurrentTime);*/
+
+ _focused = true;
+
+ OtkWidget::OtkWidgetList::iterator it = _children.begin(),
+ end = _children.end();
+ for (; it != end; ++it)
+ (*it)->focus();
+}
+
+void OtkWidget::unfocus(void)
+{
+ _focused = false;
+
+ OtkWidget::OtkWidgetList::iterator it = _children.begin(),
+ end = _children.end();
+ for (; it != end; ++it)
+ (*it)->unfocus();
}
bool OtkWidget::grabMouse(void)
if (it != _children.end())
_children.erase(it);
}
-
+#include <stdio.h>
void OtkWidget::setStyle(Style *style)
{
assert(style);
_style = style;
_dirty = true;
+
+ // reset textures/colors
+ if (_focused) {
+ unfocus();
+ focus();
+ } else {
+ focus();
+ unfocus();
+ }
+
OtkWidgetList::iterator it, end = _children.end();
for (it = _children.begin(); it != end; ++it)
(*it)->setStyle(style);
inline bool isFocused(void) const { return _focused; };
virtual void focus(void);
+ virtual void unfocus(void);
inline bool hasGrabbedMouse(void) const { return _grabbed_mouse; }
bool grabMouse(void);
inline BTexture *getTexture(void) const { return _texture; }
virtual void setTexture(BTexture *texture)
- { _texture = texture; _dirty = true; }
+ { _texture = texture; _dirty = true; }
+
+ inline const BColor *getBorderColor(void) const { return _bcolor; }
+ virtual void setBorderColor(const BColor *color) {
+ assert(color); _bcolor = color;
+ XSetWindowBorder(OBDisplay::display, _window, color->pixel());
+ }
+
+ inline int getBorderWidth(void) const { return _bwidth; }
+ void setBorderWidth(int width) {
+ _bwidth = width;
+ XSetWindowBorderWidth(OBDisplay::display, _window, width);
+ }
virtual void addChild(OtkWidget *child, bool front = false);
virtual void removeChild(OtkWidget *child);
protected:
bool _dirty;
+ bool _focused;
+
+ virtual void adjust(void);
private:
void create(void);
- void adjust(void);
void adjustHorz(void);
void adjustVert(void);
void internalResize(int width, int height);
int _ignore_config;
bool _visible;
- bool _focused;
bool _grabbed_mouse;
bool _grabbed_keyboard;
Pixmap _bg_pixmap;
unsigned int _bg_pixel;
+ const BColor *_bcolor;
+ unsigned int _bwidth;
+
Rect _rect;
unsigned int _screen;
bool _unmanaged;
OtkEventDispatcher *_event_dispatcher;
- OtkApplication *_application;
};
}
openbox3_LDADD=../otk/libotk.a @LIBINTL@
openbox3_SOURCES= actions.cc client.cc frame.cc openbox.cc screen.cc \
- main.cc rootwindow.cc
+ main.cc rootwindow.cc backgroundwidget.cc
MAINTAINERCLEANFILES= Makefile.in
--- /dev/null
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+#ifdef HAVE_CONFIG_H
+# include "../config.h"
+#endif
+
+#include "backgroundwidget.hh"
+
+namespace ob {
+
+OBBackgroundWidget::OBBackgroundWidget(otk::OtkWidget *parent,
+ OBWidget::WidgetType type)
+ : otk::OtkFocusWidget(parent),
+ OBWidget(type)
+{
+}
+
+
+OBBackgroundWidget::~OBBackgroundWidget()
+{
+}
+
+
+void OBBackgroundWidget::setStyle(otk::Style *style)
+{
+ switch (type()) {
+ case Type_Titlebar:
+ setTexture(style->getTitleFocus());
+ setUnfocusTexture(style->getTitleUnfocus());
+ setBorderColor(style->getBorderColor());
+ break;
+ case Type_Handle:
+ setTexture(style->getHandleFocus());
+ setUnfocusTexture(style->getHandleUnfocus());
+ setBorderColor(style->getBorderColor());
+ break;
+ case Type_Plate:
+ setBorderColor(&style->getFrameFocus()->color());
+ setUnfocusBorderColor(&style->getFrameUnfocus()->color());
+ break;
+ default:
+ assert(false); // there's no other background widgets!
+ }
+
+ otk::OtkFocusWidget::setStyle(style);
+}
+
+
+void OBBackgroundWidget::adjust()
+{
+ otk::OtkFocusWidget::adjust();
+
+ // XXX: adjust shit
+}
+
+
+}
--- /dev/null
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef __obbackgroundwidget_hh
+#define __obbackgroundwidget_hh
+
+#include "otk/focuswidget.hh"
+#include "widget.hh"
+
+namespace ob {
+
+class OBBackgroundWidget : public otk::OtkFocusWidget, public OBWidget
+{
+private:
+
+public:
+ OBBackgroundWidget(otk::OtkWidget *parent, OBWidget::WidgetType type);
+ virtual ~OBBackgroundWidget();
+
+ virtual void setStyle(otk::Style *style);
+
+ virtual void adjust();
+};
+
+}
+
+#endif // __obbackgroundwidget_hh
: otk::OtkWidget(Openbox::instance, style),
_client(client),
_screen(otk::OBDisplay::screenInfo(client->screen())),
- _plate(this),
- _titlebar(this),
+ _plate(this, OBWidget::Type_Plate),
+ _titlebar(this, OBWidget::Type_Titlebar),
_button_close(&_titlebar),
_button_iconify(&_titlebar),
_button_max(&_titlebar),
_button_stick(&_titlebar),
_label(&_titlebar),
- _handle(this),
+ _handle(this, OBWidget::Type_Handle),
_grip_left(&_handle),
_grip_right(&_handle),
_decorations(client->decorations())
_grip_left.setCursor(Openbox::instance->cursors().ll_angle);
_grip_right.setCursor(Openbox::instance->cursors().lr_angle);
- _plate.show();
-
_button_close.setText("X");
_button_iconify.setText("I");
_button_max.setText("M");
_style = 0;
setStyle(style);
+ //XXX: uncomment me unfocus(); // stuff starts out focused in otk
+
+ _plate.show(); // the other stuff is shown based on decor settings
+
grabClient();
}
_grip_right.setPressedFocusTexture(style->getGripFocus());
_grip_right.setPressedUnfocusTexture(style->getGripUnfocus());
- _titlebar.setTexture(style->getTitleFocus());
- _titlebar.setUnfocusTexture(style->getTitleUnfocus());
- _handle.setTexture(style->getHandleFocus());
- _handle.setUnfocusTexture(style->getHandleUnfocus());
-
// if a style was previously set, then 'replace' is true, cause we're
// replacing a style
bool replace = (_style);
_style = style;
// XXX: change when focus changes!
- XSetWindowBorder(otk::OBDisplay::display, _plate.getWindow(),
- _style->getFrameFocus()->color().pixel());
-
XSetWindowBorder(otk::OBDisplay::display, getWindow(),
_style->getBorderColor()->pixel());
- XSetWindowBorder(otk::OBDisplay::display, _titlebar.getWindow(),
- _style->getBorderColor()->pixel());
XSetWindowBorder(otk::OBDisplay::display, _grip_left.getWindow(),
_style->getBorderColor()->pixel());
XSetWindowBorder(otk::OBDisplay::display, _grip_right.getWindow(),
_style->getBorderColor()->pixel());
- XSetWindowBorder(otk::OBDisplay::display, _handle.getWindow(),
- _style->getBorderColor()->pixel());
-
+
// if !replace, then adjust() will get called after the client is grabbed!
if (replace) {
// size/position everything
cbwidth;
width = _client->area().width() + cbwidth * 2;
- XSetWindowBorderWidth(otk::OBDisplay::display, _plate.getWindow(), cbwidth);
-
- XSetWindowBorderWidth(otk::OBDisplay::display, getWindow(), bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _titlebar.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _grip_left.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _grip_right.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _handle.getWindow(), bwidth);
+ _plate.setBorderWidth(cbwidth);
+ setBorderWidth(bwidth);
+ _titlebar.setBorderWidth(bwidth);
+ _grip_left.setBorderWidth(bwidth);
+ _grip_right.setBorderWidth(bwidth);
+ _handle.setBorderWidth(bwidth);
+
if (_decorations & OBClient::Decor_Titlebar) {
// set the titlebar size
_titlebar.setGeometry(-bwidth,
}
#include "client.hh"
+#include "backgroundwidget.hh"
#include "otk/strut.hh"
#include "otk/rect.hh"
#include "otk/screeninfo.hh"
otk::Strut _innersize;
// decoration windows
- otk::OtkFocusWidget _plate; // sits entirely under the client window
- otk::OtkFocusWidget _titlebar;
+ OBBackgroundWidget _plate; // sits entirely under the client window
+ OBBackgroundWidget _titlebar;
otk::OtkButton _button_close;
otk::OtkButton _button_iconify;
otk::OtkButton _button_max;
otk::OtkButton _button_stick;
otk::OtkFocusLabel _label;
- otk::OtkFocusWidget _handle;
+ OBBackgroundWidget _handle;
otk::OtkButton _grip_left;
otk::OtkButton _grip_right;
--- /dev/null
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+#ifndef __obwidget_hh
+#define __obwidget_hh
+
+namespace ob {
+
+class OBWidget {
+public:
+ enum WidgetType {
+ Type_Titlebar,
+ Type_Handle,
+ Type_Plate
+ };
+
+private:
+ WidgetType _type;
+
+public:
+ OBWidget(WidgetType type) : _type(type) {}
+
+ inline WidgetType type() const { return _type; }
+};
+
+}
+
+#endif // __obwidget_hh