added otkapplication and event stuff, changed other files to accomodate for this, changed the test.
no idea if anything runs yet. it compiles =)
This commit is contained in:
parent
e53fbcf092
commit
a3d036f60e
8 changed files with 82 additions and 68 deletions
|
@ -7,7 +7,8 @@ noinst_LIBRARIES=libotk.a
|
||||||
libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc property.cc \
|
libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc property.cc \
|
||||||
imagecontrol.cc rect.cc screeninfo.cc texture.cc timer.cc \
|
imagecontrol.cc rect.cc screeninfo.cc texture.cc timer.cc \
|
||||||
timerqueuemanager.cc style.cc configuration.cc util.cc \
|
timerqueuemanager.cc style.cc configuration.cc util.cc \
|
||||||
widget.cc focuswidget.cc button.cc
|
widget.cc focuswidget.cc button.cc eventhandler.cc \
|
||||||
|
eventdispatcher.cc application.cc
|
||||||
|
|
||||||
MAINTAINERCLEANFILES= Makefile.in
|
MAINTAINERCLEANFILES= Makefile.in
|
||||||
|
|
||||||
|
@ -55,3 +56,6 @@ util.o: util.cc util.hh
|
||||||
widget.o: widget.cc widget.hh rect.hh point.hh texture.hh color.hh \
|
widget.o: widget.cc widget.hh rect.hh point.hh texture.hh color.hh \
|
||||||
util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \
|
util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \
|
||||||
configuration.hh display.hh assassin.hh
|
configuration.hh display.hh assassin.hh
|
||||||
|
eventhandler.o: eventhandler.cc eventhandler.hh
|
||||||
|
eventdispatcher.o: eventdispatcher.cc eventdispatcher.hh
|
||||||
|
application.o: application.cc application.hh
|
||||||
|
|
|
@ -66,17 +66,17 @@ void OtkButton::update(void)
|
||||||
_dirty = false;
|
_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OtkButton::expose(const XExposeEvent &e)
|
int OtkButton::exposeHandler(const XExposeEvent &e)
|
||||||
{
|
{
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
return OtkFocusWidget::expose(e);
|
return OtkFocusWidget::exposeHandler(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OtkButton::configure(const XConfigureEvent &e)
|
int OtkButton::configureHandler(const XConfigureEvent &e)
|
||||||
{
|
{
|
||||||
if (!(e.width == width() && e.height == height()))
|
if (!(e.width == width() && e.height == height()))
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
return OtkFocusWidget::configure(e);
|
return OtkFocusWidget::configureHandler(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#ifndef __button_hh
|
||||||
|
#define __button_hh
|
||||||
|
|
||||||
#include "focuswidget.hh"
|
#include "focuswidget.hh"
|
||||||
//#include "pixmap.hh"
|
//#include "pixmap.hh"
|
||||||
|
|
||||||
|
@ -33,9 +36,9 @@ public:
|
||||||
void press(void);
|
void press(void);
|
||||||
void release(void);
|
void release(void);
|
||||||
|
|
||||||
virtual void update(void);
|
void update(void);
|
||||||
virtual bool expose(const XExposeEvent &e);
|
int exposeHandler(const XExposeEvent &e);
|
||||||
virtual bool configure(const XConfigureEvent &e);
|
int configureHandler(const XConfigureEvent &e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -52,3 +55,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -8,6 +8,13 @@ OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
|
||||||
_focus_texture = parent->getTexture();
|
_focus_texture = parent->getTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OtkFocusWidget::OtkFocusWidget(OtkApplication *app, Direction direction,
|
||||||
|
Cursor cursor, int bevel_width)
|
||||||
|
: OtkWidget(app, direction, cursor, bevel_width),
|
||||||
|
_unfocus_texture(0), _focused(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
OtkFocusWidget::OtkFocusWidget(Style *style, Direction direction,
|
OtkFocusWidget::OtkFocusWidget(Style *style, Direction direction,
|
||||||
Cursor cursor, int bevel_width)
|
Cursor cursor, int bevel_width)
|
||||||
: OtkWidget(style, direction, cursor, bevel_width),
|
: OtkWidget(style, direction, cursor, bevel_width),
|
||||||
|
@ -15,6 +22,10 @@ OtkFocusWidget::OtkFocusWidget(Style *style, Direction direction,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OtkFocusWidget::~OtkFocusWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void OtkFocusWidget::focus(void)
|
void OtkFocusWidget::focus(void)
|
||||||
{
|
{
|
||||||
if (_focused)
|
if (_focused)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __focuswidget_hh
|
#define __focuswidget_hh
|
||||||
|
|
||||||
#include "widget.hh"
|
#include "widget.hh"
|
||||||
|
#include "application.hh"
|
||||||
|
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
|
@ -10,8 +11,11 @@ class OtkFocusWidget : public OtkWidget {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OtkFocusWidget(OtkWidget *parent, Direction = Horizontal);
|
OtkFocusWidget(OtkWidget *parent, Direction = Horizontal);
|
||||||
|
OtkFocusWidget(OtkApplication *app, Direction direction = Horizontal,
|
||||||
|
Cursor cursor = 0, int bevel_width = 1);
|
||||||
OtkFocusWidget(Style *style, Direction direction = Horizontal,
|
OtkFocusWidget(Style *style, Direction direction = Horizontal,
|
||||||
Cursor cursor = 0, int bevel_width = 1);
|
Cursor cursor = 0, int bevel_width = 1);
|
||||||
|
virtual ~OtkFocusWidget();
|
||||||
|
|
||||||
virtual void focus(void);
|
virtual void focus(void);
|
||||||
virtual void unfocus(void);
|
virtual void unfocus(void);
|
||||||
|
|
|
@ -1,32 +1,15 @@
|
||||||
|
#include "application.hh"
|
||||||
#include "focuswidget.hh"
|
#include "focuswidget.hh"
|
||||||
#include "button.hh"
|
#include "button.hh"
|
||||||
#include "display.hh"
|
|
||||||
#include "configuration.hh"
|
|
||||||
#include "timerqueuemanager.hh"
|
|
||||||
#include "image.hh"
|
|
||||||
#include "style.hh"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main(void) {
|
int main(int argc, char **argv) {
|
||||||
otk::OBDisplay::initialize(NULL);
|
otk::OtkApplication app(argc, argv);
|
||||||
otk::Configuration style_conf(False);
|
|
||||||
otk::OBTimerQueueManager *tm = new otk::OBTimerQueueManager();
|
|
||||||
const otk::ScreenInfo *s_info =
|
|
||||||
otk::OBDisplay::screenInfo(DefaultScreen(otk::OBDisplay::display));
|
|
||||||
otk::BImageControl *ctrl = new otk::BImageControl(tm, s_info, True, 4, 5, 200);
|
|
||||||
|
|
||||||
otk::Style *my_style = new otk::Style(ctrl);
|
otk::OtkFocusWidget foo(&app);
|
||||||
|
|
||||||
style_conf.setFile("/usr/local/share/openbox/styles/artwiz");
|
|
||||||
style_conf.load();
|
|
||||||
|
|
||||||
my_style->load(style_conf);
|
|
||||||
|
|
||||||
otk::OtkFocusWidget foo(my_style);
|
|
||||||
|
|
||||||
foo.resize(600, 500);
|
foo.resize(600, 500);
|
||||||
foo.setTexture(my_style->getTitleFocus());
|
foo.setTexture(app.getStyle()->getTitleFocus());
|
||||||
foo.setUnfocusTexture(my_style->getTitleUnfocus());
|
foo.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
|
||||||
|
|
||||||
foo.setBevelWidth(2);
|
foo.setBevelWidth(2);
|
||||||
foo.setDirection(otk::OtkWidget::Horizontal);
|
foo.setDirection(otk::OtkWidget::Horizontal);
|
||||||
|
@ -37,15 +20,15 @@ int main(void) {
|
||||||
left.setDirection(otk::OtkWidget::Horizontal);
|
left.setDirection(otk::OtkWidget::Horizontal);
|
||||||
left.setStretchableVert(true);
|
left.setStretchableVert(true);
|
||||||
left.setStretchableHorz(true);
|
left.setStretchableHorz(true);
|
||||||
left.setTexture(my_style->getTitleFocus());
|
left.setTexture(app.getStyle()->getTitleFocus());
|
||||||
left.setUnfocusTexture(my_style->getTitleUnfocus());
|
left.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
|
||||||
|
|
||||||
right.setDirection(otk::OtkWidget::Vertical);
|
right.setDirection(otk::OtkWidget::Vertical);
|
||||||
right.setBevelWidth(10);
|
right.setBevelWidth(10);
|
||||||
right.setStretchableVert(true);
|
right.setStretchableVert(true);
|
||||||
right.setWidth(300);
|
right.setWidth(300);
|
||||||
right.setTexture(my_style->getTitleFocus());
|
right.setTexture(app.getStyle()->getTitleFocus());
|
||||||
right.setUnfocusTexture(my_style->getTitleUnfocus());
|
right.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
|
||||||
|
|
||||||
otk::OtkButton iconb(&left);
|
otk::OtkButton iconb(&left);
|
||||||
otk::OtkFocusWidget label(&left);
|
otk::OtkFocusWidget label(&left);
|
||||||
|
@ -60,8 +43,8 @@ int main(void) {
|
||||||
//label.setHeight(20);
|
//label.setHeight(20);
|
||||||
label.setStretchableVert(true);
|
label.setStretchableVert(true);
|
||||||
label.setStretchableHorz(true);
|
label.setStretchableHorz(true);
|
||||||
label.setTexture(my_style->getLabelFocus());
|
label.setTexture(app.getStyle()->getLabelFocus());
|
||||||
label.setUnfocusTexture(my_style->getLabelUnfocus());
|
label.setUnfocusTexture(app.getStyle()->getLabelUnfocus());
|
||||||
|
|
||||||
// fixed size
|
// fixed size
|
||||||
maxb.setText("bar");
|
maxb.setText("bar");
|
||||||
|
@ -75,34 +58,18 @@ int main(void) {
|
||||||
|
|
||||||
rblef.setStretchableHorz(true);
|
rblef.setStretchableHorz(true);
|
||||||
rblef.setHeight(50);
|
rblef.setHeight(50);
|
||||||
rblef.setTexture(my_style->getHandleFocus());
|
rblef.setTexture(app.getStyle()->getHandleFocus());
|
||||||
rblef.setUnfocusTexture(my_style->getHandleUnfocus());
|
rblef.setUnfocusTexture(app.getStyle()->getHandleUnfocus());
|
||||||
|
|
||||||
rbutt1.setText("this is fucking tight");
|
rbutt1.setText("this is fucking tight");
|
||||||
rbutt2.setText("heh, WOOP");
|
rbutt2.setText("heh, WOOP");
|
||||||
|
|
||||||
// will recursively unfocus its children
|
// will recursively unfocus its children
|
||||||
//foo.unfocus();
|
//foo.unfocus();
|
||||||
foo.update();
|
|
||||||
foo.show();
|
foo.show();
|
||||||
|
|
||||||
while (1) {
|
app.exec();
|
||||||
if (XPending(otk::OBDisplay::display)) {
|
|
||||||
XEvent e;
|
|
||||||
XNextEvent(otk::OBDisplay::display, &e);
|
|
||||||
if (e.type == Expose) {
|
|
||||||
foo.expose(e.xexpose);
|
|
||||||
} else if (e.type == ConfigureNotify) {
|
|
||||||
foo.configure(e.xconfigure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete my_style;
|
|
||||||
delete tm;
|
|
||||||
delete ctrl;
|
|
||||||
|
|
||||||
otk::OBDisplay::destroy();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
||||||
: _parent(parent), _style(parent->getStyle()), _direction(direction),
|
: OtkEventHandler(),
|
||||||
|
_parent(parent), _style(parent->getStyle()), _direction(direction),
|
||||||
_cursor(parent->getCursor()), _bevel_width(parent->getBevelWidth()),
|
_cursor(parent->getCursor()), _bevel_width(parent->getBevelWidth()),
|
||||||
_ignore_config(0),
|
_ignore_config(0),
|
||||||
_visible(false), _focused(false), _grabbed_mouse(false),
|
_visible(false), _focused(false), _grabbed_mouse(false),
|
||||||
|
@ -22,9 +23,25 @@ OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OtkWidget::OtkWidget(OtkApplication *app, Direction direction,
|
||||||
|
Cursor cursor, int bevel_width)
|
||||||
|
: OtkEventHandler(),
|
||||||
|
_parent(0), _style(app->getStyle()), _direction(direction), _cursor(cursor),
|
||||||
|
_bevel_width(bevel_width), _ignore_config(0), _visible(false),
|
||||||
|
_focused(false), _grabbed_mouse(false), _grabbed_keyboard(false),
|
||||||
|
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
|
||||||
|
_bg_pixmap(0), _bg_pixel(0), _screen(app->getStyle()->getScreen()),
|
||||||
|
_fixed_width(false), _fixed_height(false), _dirty(false)
|
||||||
|
{
|
||||||
|
assert(app);
|
||||||
|
create();
|
||||||
|
app->registerHandler(_window, this);
|
||||||
|
}
|
||||||
|
|
||||||
OtkWidget::OtkWidget(Style *style, Direction direction,
|
OtkWidget::OtkWidget(Style *style, Direction direction,
|
||||||
Cursor cursor, int bevel_width)
|
Cursor cursor, int bevel_width)
|
||||||
: _parent(0), _style(style), _direction(direction), _cursor(cursor),
|
: OtkEventHandler(),
|
||||||
|
_parent(0), _style(style), _direction(direction), _cursor(cursor),
|
||||||
_bevel_width(bevel_width), _ignore_config(0), _visible(false),
|
_bevel_width(bevel_width), _ignore_config(0), _visible(false),
|
||||||
_focused(false), _grabbed_mouse(false), _grabbed_keyboard(false),
|
_focused(false), _grabbed_mouse(false), _grabbed_keyboard(false),
|
||||||
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
|
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
|
||||||
|
@ -396,8 +413,9 @@ void OtkWidget::removeChild(OtkWidget *child)
|
||||||
_children.erase(it);
|
_children.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OtkWidget::expose(const XExposeEvent &e)
|
int OtkWidget::exposeHandler(const XExposeEvent &e)
|
||||||
{
|
{
|
||||||
|
OtkEventHandler::exposeHandler(e);
|
||||||
if (e.window == _window) {
|
if (e.window == _window) {
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
update();
|
update();
|
||||||
|
@ -405,14 +423,15 @@ bool OtkWidget::expose(const XExposeEvent &e)
|
||||||
} else {
|
} else {
|
||||||
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
|
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
if ((*it)->expose(e))
|
if ((*it)->exposeHandler(e))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OtkWidget::configure(const XConfigureEvent &e)
|
int OtkWidget::configureHandler(const XConfigureEvent &e)
|
||||||
{
|
{
|
||||||
|
OtkEventHandler::configureHandler(e);
|
||||||
if (e.window == _window) {
|
if (e.window == _window) {
|
||||||
if (_ignore_config) {
|
if (_ignore_config) {
|
||||||
_ignore_config--;
|
_ignore_config--;
|
||||||
|
@ -428,7 +447,7 @@ bool OtkWidget::configure(const XConfigureEvent &e)
|
||||||
} else {
|
} else {
|
||||||
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
|
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
if ((*it)->configure(e))
|
if ((*it)->configureHandler(e))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __focus_hh
|
#ifndef __widget_hh
|
||||||
#define __focus_hh
|
#define __widget_hh
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -8,10 +8,12 @@
|
||||||
#include "point.hh"
|
#include "point.hh"
|
||||||
#include "texture.hh"
|
#include "texture.hh"
|
||||||
#include "style.hh"
|
#include "style.hh"
|
||||||
|
#include "eventhandler.hh"
|
||||||
|
#include "application.hh"
|
||||||
|
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
class OtkWidget {
|
class OtkWidget : public OtkEventHandler {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -20,6 +22,8 @@ public:
|
||||||
typedef std::list<OtkWidget *> OtkWidgetList;
|
typedef std::list<OtkWidget *> OtkWidgetList;
|
||||||
|
|
||||||
OtkWidget(OtkWidget *parent, Direction = Horizontal);
|
OtkWidget(OtkWidget *parent, Direction = Horizontal);
|
||||||
|
OtkWidget(OtkApplication *app, Direction direction = Horizontal,
|
||||||
|
Cursor cursor = 0, int bevel_width = 1);
|
||||||
OtkWidget(Style *style, Direction direction = Horizontal,
|
OtkWidget(Style *style, Direction direction = Horizontal,
|
||||||
Cursor cursor = 0, int bevel_width = 1);
|
Cursor cursor = 0, int bevel_width = 1);
|
||||||
|
|
||||||
|
@ -27,8 +31,8 @@ public:
|
||||||
|
|
||||||
virtual void update(void);
|
virtual void update(void);
|
||||||
|
|
||||||
virtual bool expose(const XExposeEvent &e);
|
int exposeHandler(const XExposeEvent &e);
|
||||||
virtual bool configure(const XConfigureEvent &e);
|
int configureHandler(const XConfigureEvent &e);
|
||||||
|
|
||||||
inline Window getWindow(void) const { return _window; }
|
inline Window getWindow(void) const { return _window; }
|
||||||
inline const OtkWidget *getParent(void) const { return _parent; }
|
inline const OtkWidget *getParent(void) const { return _parent; }
|
||||||
|
|
Loading…
Reference in a new issue