summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--otk/Makefile.am53
-rw-r--r--otk/application.cc38
-rw-r--r--otk/application.hh10
-rw-r--r--otk/appwidget.cc53
-rw-r--r--otk/appwidget.hh31
-rw-r--r--otk/button.cc8
-rw-r--r--otk/button.hh4
-rw-r--r--otk/eventhandler.cc3
-rw-r--r--otk/eventhandler.hh69
-rw-r--r--otk/focuswidget.cc14
-rw-r--r--otk/focuswidget.hh4
-rw-r--r--otk/otk_test.cc5
-rw-r--r--otk/widget.cc37
-rw-r--r--otk/widget.hh14
14 files changed, 197 insertions, 146 deletions
diff --git a/otk/Makefile.am b/otk/Makefile.am
index b35b7d9a..3f32a45e 100644
--- a/otk/Makefile.am
+++ b/otk/Makefile.am
@@ -9,7 +9,7 @@ libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
texture.cc timer.cc timerqueuemanager.cc style.cc \
configuration.cc util.cc widget.cc focuswidget.cc \
button.cc eventhandler.cc eventdispatcher.cc \
- label.cc focuslabel.cc application.cc
+ label.cc focuslabel.cc application.cc appwidget.cc
MAINTAINERCLEANFILES= Makefile.in
@@ -20,26 +20,51 @@ otk_test: libotk.a otk_test.cc
$(CXX) $(CPPFLAGS) -DHAVE_CONFIG_H -I. -I. -I.. -I../src $(XFT_CFLAGS) -Wall -W -pedantic -DNDEBUG -g -O2 -o otk_test otk_test.cc $(XFT_LIBS) ./libotk.a
# local dependencies
-button.o: button.cc button.hh focuswidget.hh widget.hh rect.hh \
- point.hh texture.hh color.hh util.hh style.hh font.hh image.hh \
- screeninfo.hh timer.hh configuration.hh
+application.o: application.cc application.hh eventdispatcher.hh \
+ eventhandler.hh display.hh configuration.hh timerqueuemanager.hh \
+ timerqueue.hh timer.hh image.hh color.hh screeninfo.hh rect.hh \
+ point.hh style.hh font.hh texture.hh util.hh widget.hh
+appwidget.o: appwidget.cc appwidget.hh widget.hh rect.hh point.hh \
+ texture.hh color.hh util.hh style.hh font.hh image.hh screeninfo.hh \
+ timer.hh configuration.hh eventdispatcher.hh eventhandler.hh \
+ application.hh display.hh timerqueuemanager.hh timerqueue.hh
+button.o: button.cc button.hh focuslabel.hh focuswidget.hh widget.hh \
+ rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \
+ image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
+ eventhandler.hh application.hh display.hh timerqueuemanager.hh \
+ timerqueue.hh
color.o: color.cc color.hh display.hh screeninfo.hh rect.hh point.hh
configuration.o: configuration.cc configuration.hh util.hh
+eventdispatcher.o: eventdispatcher.cc eventdispatcher.hh \
+ eventhandler.hh display.hh
+eventhandler.o: eventhandler.cc eventhandler.hh
+focuslabel.o: focuslabel.cc focuslabel.hh focuswidget.hh widget.hh \
+ rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \
+ image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
+ eventhandler.hh application.hh display.hh timerqueuemanager.hh \
+ timerqueue.hh
focuswidget.o: focuswidget.cc focuswidget.hh widget.hh rect.hh \
point.hh texture.hh color.hh util.hh style.hh font.hh image.hh \
- screeninfo.hh timer.hh configuration.hh
-font.o: font.cc font.hh util.hh display.hh display.hh color.hh \
- screeninfo.hh rect.hh point.hh
+ screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
+ eventhandler.hh application.hh display.hh timerqueuemanager.hh \
+ timerqueue.hh
+font.o: font.cc font.hh util.hh display.hh color.hh screeninfo.hh \
+ rect.hh point.hh
gccache.o: gccache.cc gccache.hh display.hh color.hh assassin.hh \
screeninfo.hh rect.hh point.hh
image.o: image.cc display.hh gccache.hh color.hh image.hh \
screeninfo.hh rect.hh point.hh timer.hh texture.hh util.hh
imagecontrol.o: imagecontrol.cc display.hh color.hh image.hh \
screeninfo.hh rect.hh point.hh timer.hh texture.hh util.hh
-otk_test.o: otk_test.cc focuswidget.hh widget.hh rect.hh point.hh \
- texture.hh color.hh util.hh style.hh font.hh image.hh screeninfo.hh \
- timer.hh configuration.hh button.hh display.hh timerqueuemanager.hh \
- timerqueue.hh
+label.o: label.cc label.hh widget.hh rect.hh point.hh texture.hh \
+ color.hh util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \
+ configuration.hh eventdispatcher.hh eventhandler.hh application.hh \
+ display.hh timerqueuemanager.hh timerqueue.hh
+otk_test.o: otk_test.cc application.hh eventdispatcher.hh \
+ eventhandler.hh display.hh configuration.hh timerqueuemanager.hh \
+ timerqueue.hh timer.hh image.hh color.hh screeninfo.hh rect.hh \
+ point.hh style.hh font.hh texture.hh util.hh focuswidget.hh widget.hh \
+ appwidget.hh button.hh focuslabel.hh
property.o: property.cc property.hh screeninfo.hh rect.hh point.hh \
display.hh
rect.o: rect.cc rect.hh point.hh
@@ -56,7 +81,5 @@ timerqueuemanager.o: timerqueuemanager.cc timerqueuemanager.hh \
util.o: util.cc util.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 \
- configuration.hh display.hh assassin.hh
-eventhandler.o: eventhandler.cc eventhandler.hh
-eventdispatcher.o: eventdispatcher.cc eventdispatcher.hh
-application.o: application.cc application.hh
+ configuration.hh eventdispatcher.hh eventhandler.hh application.hh \
+ display.hh timerqueuemanager.hh timerqueue.hh assassin.hh
diff --git a/otk/application.cc b/otk/application.cc
index 2530fdd1..886b0033 100644
--- a/otk/application.cc
+++ b/otk/application.cc
@@ -3,8 +3,6 @@
#include "widget.hh"
extern "C" {
-#include <X11/Xlib.h>
-
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
@@ -15,13 +13,16 @@ extern "C" {
namespace otk {
OtkApplication::OtkApplication(int argc, char **argv)
- : OtkEventDispatcher(), _main_widget(0), _dockable(false)
+ : OtkEventDispatcher(),
+ _dockable(false),
+ _appwidget_count(0)
{
argc = argc;
argv = argv;
OBDisplay::initialize(0);
- const ScreenInfo *s_info = OBDisplay::screenInfo(DefaultScreen(OBDisplay::display));
+ const ScreenInfo *s_info =
+ OBDisplay::screenInfo(DefaultScreen(OBDisplay::display));
_timer_manager = new OBTimerQueueManager();
_img_ctrl = new BImageControl(_timer_manager, s_info, True, 4, 5, 200);
@@ -55,36 +56,17 @@ void OtkApplication::loadStyle(void)
void OtkApplication::exec(void)
{
- if (!_main_widget) {
- std::cerr << "ERROR: No main widget set. You must create a main " <<
- "OtkWidget for the OtkApplication before calling " <<
+ if (_appwidget_count <= 0) {
+ std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
+ "an OtkAppWidget for the OtkApplication before calling " <<
"OtkApplication::exec().\n";
::exit(1);
}
- while (1) {
+
+ while (_appwidget_count > 0) {
dispatchEvents();
_timer_manager->fire(); // fire pending events
}
}
-bool OtkApplication::setMainWidget(const OtkWidget *main_widget)
-{
- // ignore it if it has already been set
- if (_main_widget) {
- std::cerr << "WARNING: More than one main OtkWidget being created for " <<
- "the OtkApplication!\n";
- return false;
- }
-
- _main_widget = main_widget;
-
- // set WM Protocols on the window
- Atom protocols[2];
- protocols[0] = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
- protocols[1] = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false);
- XSetWMProtocols(OBDisplay::display, _main_widget->getWindow(), protocols, 2);
-
- return true;
-}
-
}
diff --git a/otk/application.hh b/otk/application.hh
index d6f1ed8d..7696e73d 100644
--- a/otk/application.hh
+++ b/otk/application.hh
@@ -10,7 +10,7 @@
namespace otk {
-class OtkWidget;
+class OtkAppWidget;
class OtkApplication : public OtkEventDispatcher {
@@ -28,20 +28,18 @@ public:
inline Style *getStyle(void) const { return _style; }
// more accessors
-protected:
- bool setMainWidget(const OtkWidget *main_widget);
-
private:
void loadStyle(void);
- const OtkWidget *_main_widget;
OBTimerQueueManager *_timer_manager;
BImageControl *_img_ctrl;
Configuration *_style_conf;
Style *_style;
bool _dockable;
- friend class OtkWidget; // for access to setMainWidget
+ int _appwidget_count;
+
+ friend class OtkAppWidget;
};
}
diff --git a/otk/appwidget.cc b/otk/appwidget.cc
new file mode 100644
index 00000000..f406c654
--- /dev/null
+++ b/otk/appwidget.cc
@@ -0,0 +1,53 @@
+#include "appwidget.hh"
+#include "application.hh"
+
+extern "C" {
+#include <X11/Xlib.h>
+}
+
+namespace otk {
+
+OtkAppWidget::OtkAppWidget(OtkApplication *app, Direction direction,
+ Cursor cursor, int bevel_width)
+ : OtkWidget(app, app->getStyle(), direction, cursor, bevel_width),
+ _application(app)
+{
+ assert(app);
+
+ _wm_protocols = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
+ _wm_delete = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false);
+
+ // set WM Protocols on the window
+ Atom protocols[2];
+ protocols[0] = _wm_protocols;
+ protocols[1] = _wm_delete;
+ XSetWMProtocols(OBDisplay::display, getWindow(), protocols, 2);
+}
+
+OtkAppWidget::~OtkAppWidget()
+{
+}
+
+void OtkAppWidget::show(void)
+{
+ OtkWidget::show();
+
+ _application->_appwidget_count++;
+}
+
+void OtkAppWidget::hide(void)
+{
+ OtkWidget::hide();
+
+ _application->_appwidget_count--;
+}
+
+void OtkAppWidget::clientMessageHandler(const XClientMessageEvent &e)
+{
+ OtkEventHandler::clientMessageHandler(e);
+ if (e.message_type == _wm_protocols &&
+ static_cast<Atom>(e.data.l[0]) == _wm_delete)
+ hide();
+}
+
+}
diff --git a/otk/appwidget.hh b/otk/appwidget.hh
new file mode 100644
index 00000000..d33f2caa
--- /dev/null
+++ b/otk/appwidget.hh
@@ -0,0 +1,31 @@
+#ifndef __appwidget_hh
+#define __appwidget_hh
+
+#include "widget.hh"
+
+namespace otk {
+
+class OtkApplication;
+
+class OtkAppWidget : public OtkWidget {
+
+public:
+ OtkAppWidget(OtkApplication *app, Direction direction = Horizontal,
+ Cursor cursor = 0, int bevel_width = 1);
+ virtual ~OtkAppWidget();
+
+ virtual void show(void);
+ virtual void hide(void);
+
+ virtual void clientMessageHandler(const XClientMessageEvent &e);
+
+private:
+
+ OtkApplication *_application;
+ Atom _wm_protocols;
+ Atom _wm_delete;
+};
+
+}
+
+#endif // __appwidget_hh
diff --git a/otk/button.cc b/otk/button.cc
index f080c769..1b2ef7ce 100644
--- a/otk/button.cc
+++ b/otk/button.cc
@@ -51,18 +51,18 @@ void OtkButton::setUnfocusTexture(BTexture *texture)
_unpr_unfocus_tx = texture;
}
-int OtkButton::buttonPressHandler(const XButtonEvent &e)
+void OtkButton::buttonPressHandler(const XButtonEvent &e)
{
press(e.button);
update();
- return OtkFocusWidget::buttonPressHandler(e);
+ OtkFocusWidget::buttonPressHandler(e);
}
-int OtkButton::buttonReleaseHandler(const XButtonEvent &e)
+void OtkButton::buttonReleaseHandler(const XButtonEvent &e)
{
release(e.button);
update();
- return OtkFocusWidget::buttonReleaseHandler(e);
+ OtkFocusWidget::buttonReleaseHandler(e);
}
}
diff --git a/otk/button.hh b/otk/button.hh
index c5b9d963..a5f93690 100644
--- a/otk/button.hh
+++ b/otk/button.hh
@@ -29,8 +29,8 @@ public:
void press(unsigned int mouse_button);
void release(unsigned int mouse_button);
- int buttonPressHandler(const XButtonEvent &e);
- int buttonReleaseHandler(const XButtonEvent &e);
+ void buttonPressHandler(const XButtonEvent &e);
+ void buttonReleaseHandler(const XButtonEvent &e);
private:
diff --git a/otk/eventhandler.cc b/otk/eventhandler.cc
index cab95e17..9d37bcff 100644
--- a/otk/eventhandler.cc
+++ b/otk/eventhandler.cc
@@ -13,7 +13,7 @@ OtkEventHandler::~OtkEventHandler()
}
-int OtkEventHandler::handle(const XEvent &e)
+void OtkEventHandler::handle(const XEvent &e)
{
switch(e.type){
case KeyPress:
@@ -79,7 +79,6 @@ int OtkEventHandler::handle(const XEvent &e)
case SelectionRequest:
return selectionRequestHandler(e.xselectionrequest);
};
- return 0;
}
}
diff --git a/otk/eventhandler.hh b/otk/eventhandler.hh
index ea273ef4..05dfac3b 100644
--- a/otk/eventhandler.hh
+++ b/otk/eventhandler.hh
@@ -10,104 +10,103 @@ namespace otk {
class OtkEventHandler{
public:
//! Dispatches events to one of the other handlers based on their type.
- virtual int handle(const XEvent &e);
+ virtual void handle(const XEvent &e);
//! Called whenever any key is pressed.
- virtual int keyPressHandler(const XKeyEvent &) {return 1;}
+ virtual void keyPressHandler(const XKeyEvent &) {}
//! Called whenever any key is released.
- virtual int keyReleaseHandler(const XKeyEvent &) {return 1;}
+ virtual void keyReleaseHandler(const XKeyEvent &) {}
//! Called whenever a button of the pointer is pressed.
- virtual int buttonPressHandler(const XButtonEvent &) {return 1;}
+ virtual void buttonPressHandler(const XButtonEvent &) {}
//! Called whenever a button of the pointer is released.
- virtual int buttonReleaseHandler(const XButtonEvent &) {return 1;}
+ virtual void buttonReleaseHandler(const XButtonEvent &) {}
//! Called whenever the pointer enters a window.
- virtual int enterHandler(const XCrossingEvent &) {return 1;}
+ virtual void enterHandler(const XCrossingEvent &) {}
//! Called whenever the pointer leaves a window.
- virtual int leaveHandler(const XCrossingEvent &) {return 1;}
+ virtual void leaveHandler(const XCrossingEvent &) {}
//! Called when a window gains focus.
- virtual int focusHandler(const XFocusChangeEvent &) {return 1;}
+ virtual void focusHandler(const XFocusChangeEvent &) {}
//! Called when a window looses focus.
- virtual int unfocusHandler(const XFocusChangeEvent &) {return 1;}
+ virtual void unfocusHandler(const XFocusChangeEvent &) {}
//! Called when a window becomes visible to the user.
- virtual int exposeHandler(const XExposeEvent &) {return 1;}
+ virtual void exposeHandler(const XExposeEvent &) {}
//! Called to handle GraphicsExpose events.
- virtual int graphicsExposeHandler(const XGraphicsExposeEvent &) {return 1;}
+ virtual void graphicsExposeHandler(const XGraphicsExposeEvent &) {}
//! Called to handle NoExpose events.
- virtual int noExposeEventHandler(const XNoExposeEvent &) {return 1;}
+ virtual void noExposeEventHandler(const XNoExposeEvent &) {}
//! Called when the window requests a change in its z-order.
- virtual int circulateRequestHandler(const XCirculateRequestEvent &)
- {return 1;}
+ virtual void circulateRequestHandler(const XCirculateRequestEvent &)
+ {}
//! Called when a different client initiates a configure window request.
- virtual int configureRequestHandler(const XConfigureRequestEvent &)
- {return 1;}
+ virtual void configureRequestHandler(const XConfigureRequestEvent &)
+ {}
//! Called when a different client tries to map a window.
- virtual int mapRequestHandler(const XMapRequestEvent &) {return 1;}
+ virtual void mapRequestHandler(const XMapRequestEvent &) {}
//! Called when another client attemps to change the size of a window.
- virtual int resizeRequestHandler(const XResizeRequestEvent &) {return 1;}
+ virtual void resizeRequestHandler(const XResizeRequestEvent &) {}
//! Called when the z-order of the window has changed.
- virtual int circulateHandler(const XCirculateEvent &) {return 1;}
+ virtual void circulateHandler(const XCirculateEvent &) {}
//! Called when the window as been reconfigured.
- virtual int configureHandler(const XConfigureEvent &) {return 1;}
+ virtual void configureHandler(const XConfigureEvent &) {}
//! Called when a window is created.
- virtual int createHandler(const XCreateWindowEvent &) {return 1;}
+ virtual void createHandler(const XCreateWindowEvent &) {}
//! Called when a window is destroyed.
- virtual int destroyHandler(const XDestroyWindowEvent &) {return 1;}
+ virtual void destroyHandler(const XDestroyWindowEvent &) {}
//! Called when a window is moved because of a change in the size of its
//! parent.
- virtual int gravityHandler(const XGravityEvent &) {return 1;}
+ virtual void gravityHandler(const XGravityEvent &) {}
//! Called when a window is mapped.
- virtual int mapHandler(const XMapEvent &) {return 1;}
+ virtual void mapHandler(const XMapEvent &) {}
//! Called when the server generats a MappingNotify event
- virtual int mappingHandler(const XMappingEvent &) {return 1;}
+ virtual void mappingHandler(const XMappingEvent &) {}
//! Called when a window is reparented
- virtual int reparentHandler(const XReparentEvent &) {return 1;}
+ virtual void reparentHandler(const XReparentEvent &) {}
//! Called when a window is unmapped
- virtual int unmapHandler(const XUnmapEvent &) {return 1;}
+ virtual void unmapHandler(const XUnmapEvent &) {}
//! Called when a the visibilty of a window changes
- virtual int visibilityHandler(const XVisibilityEvent &) {return 1;}
+ virtual void visibilityHandler(const XVisibilityEvent &) {}
//! Called when the colormap changes, or is installed or unistalled
- virtual int colorMapHandler(const XColormapEvent &) {return 1;}
+ virtual void colorMapHandler(const XColormapEvent &) {}
//! Called when a client calls XSendEvent
- virtual int clientMessageHandler(const XClientMessageEvent &) {return 1;}
+ virtual void clientMessageHandler(const XClientMessageEvent &) {}
//! Called when a property of a window changes
- virtual int propertyHandler(const XPropertyEvent &) {return 1;}
+ virtual void propertyHandler(const XPropertyEvent &) {}
//! Called when the client loses ownership of a selection
- virtual int selectionClearHandler(const XSelectionClearEvent &) {return 1;}
+ virtual void selectionClearHandler(const XSelectionClearEvent &) {}
//! Called when a ConvertSelection protocol request is sent
- virtual int selectionHandler(const XSelectionEvent &) {return 1;}
+ virtual void selectionHandler(const XSelectionEvent &) {}
//! Called when a SelectionEvent occurs
- virtual int selectionRequestHandler(const XSelectionRequestEvent &)
- {return 1;}
+ virtual void selectionRequestHandler(const XSelectionRequestEvent &) {}
virtual ~OtkEventHandler();
diff --git a/otk/focuswidget.cc b/otk/focuswidget.cc
index ffbaeb7e..c21697ce 100644
--- a/otk/focuswidget.cc
+++ b/otk/focuswidget.cc
@@ -8,20 +8,6 @@ OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
_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,
- Cursor cursor, int bevel_width)
- : OtkWidget(style, direction, cursor, bevel_width),
- _unfocus_texture(0), _focused(true)
-{
-}
-
OtkFocusWidget::~OtkFocusWidget()
{
}
diff --git a/otk/focuswidget.hh b/otk/focuswidget.hh
index e6bcb876..d33d2abf 100644
--- a/otk/focuswidget.hh
+++ b/otk/focuswidget.hh
@@ -11,10 +11,6 @@ class OtkFocusWidget : public OtkWidget {
public:
OtkFocusWidget(OtkWidget *parent, Direction = Horizontal);
- OtkFocusWidget(OtkApplication *app, Direction direction = Horizontal,
- Cursor cursor = 0, int bevel_width = 1);
- OtkFocusWidget(Style *style, Direction direction = Horizontal,
- Cursor cursor = 0, int bevel_width = 1);
virtual ~OtkFocusWidget();
virtual void focus(void);
diff --git a/otk/otk_test.cc b/otk/otk_test.cc
index 987563ad..39baa7f6 100644
--- a/otk/otk_test.cc
+++ b/otk/otk_test.cc
@@ -1,15 +1,16 @@
#include "application.hh"
#include "focuswidget.hh"
+#include "appwidget.hh"
#include "button.hh"
int main(int argc, char **argv) {
otk::OtkApplication app(argc, argv);
- otk::OtkFocusWidget foo(&app);
+ otk::OtkAppWidget foo(&app);
foo.resize(600, 500);
foo.setTexture(app.getStyle()->getTitleFocus());
- foo.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
+// foo.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
foo.setBevelWidth(2);
foo.setDirection(otk::OtkWidget::Horizontal);
diff --git a/otk/widget.cc b/otk/widget.cc
index 130bafea..0e5eaf15 100644
--- a/otk/widget.cc
+++ b/otk/widget.cc
@@ -18,33 +18,16 @@ OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
_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())
+ _event_dispatcher(parent->getEventDispatcher()), _application(0)
{
+ assert(parent);
parent->addChild(this);
create();
_event_dispatcher->registerHandler(_window, this);
}
-OtkWidget::OtkWidget(OtkApplication *app, Direction direction,
- Cursor cursor, int bevel_width)
- : OtkEventHandler(),
- _dirty(false),
- _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),
- _event_dispatcher(app)
-{
- assert(app);
- create();
- _event_dispatcher->registerHandler(_window, this);
- app->setMainWidget(this);
-}
-
-OtkWidget::OtkWidget(Style *style, Direction direction,
- Cursor cursor, int bevel_width)
+OtkWidget::OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
+ Direction direction, Cursor cursor, int bevel_width)
: OtkEventHandler(),
_dirty(false),
_parent(0), _style(style), _direction(direction), _cursor(cursor),
@@ -52,10 +35,13 @@ OtkWidget::OtkWidget(Style *style, Direction direction,
_focused(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)
+ _fixed_width(false), _fixed_height(false),
+ _event_dispatcher(event_dispatcher), _application(0)
{
+ assert(event_dispatcher);
assert(style);
create();
+ _event_dispatcher->registerHandler(_window, this);
}
OtkWidget::~OtkWidget()
@@ -427,15 +413,14 @@ void OtkWidget::setEventDispatcher(OtkEventDispatcher *disp)
_event_dispatcher->registerHandler(_window, this);
}
-int OtkWidget::exposeHandler(const XExposeEvent &e)
+void OtkWidget::exposeHandler(const XExposeEvent &e)
{
OtkEventHandler::exposeHandler(e);
_dirty = true;
update();
- return true;
}
-int OtkWidget::configureHandler(const XConfigureEvent &e)
+void OtkWidget::configureHandler(const XConfigureEvent &e)
{
OtkEventHandler::configureHandler(e);
if (_ignore_config) {
@@ -447,8 +432,6 @@ int OtkWidget::configureHandler(const XConfigureEvent &e)
}
update();
}
-
- return true;
}
}
diff --git a/otk/widget.hh b/otk/widget.hh
index fb3b1e37..cbf2f9c5 100644
--- a/otk/widget.hh
+++ b/otk/widget.hh
@@ -8,7 +8,7 @@
#include "point.hh"
#include "texture.hh"
#include "style.hh"
-#include "eventhandler.hh"
+#include "eventdispatcher.hh"
#include "application.hh"
namespace otk {
@@ -22,17 +22,16 @@ public:
typedef std::list<OtkWidget *> OtkWidgetList;
OtkWidget(OtkWidget *parent, Direction = Horizontal);
- OtkWidget(OtkApplication *app, Direction direction = Horizontal,
- Cursor cursor = 0, int bevel_width = 1);
- OtkWidget(Style *style, Direction direction = Horizontal,
- Cursor cursor = 0, int bevel_width = 1);
+ OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
+ Direction direction = Horizontal, Cursor cursor = 0,
+ int bevel_width = 1);
virtual ~OtkWidget();
virtual void update(void);
- int exposeHandler(const XExposeEvent &e);
- int configureHandler(const XConfigureEvent &e);
+ void exposeHandler(const XExposeEvent &e);
+ void configureHandler(const XConfigureEvent &e);
inline Window getWindow(void) const { return _window; }
inline const OtkWidget *getParent(void) const { return _parent; }
@@ -144,6 +143,7 @@ private:
bool _fixed_height;
OtkEventDispatcher *_event_dispatcher;
+ OtkApplication *_application;
};
}