This commit is contained in:
Dana Jansens 2002-11-15 03:10:34 +00:00
parent d97db16430
commit 0856b11de8
5 changed files with 42 additions and 7 deletions

View file

@ -57,7 +57,6 @@ void OtkButton::update(void)
OtkFocusWidget::resize(ft.measureString(_text) + bevel * 2, OtkFocusWidget::resize(ft.measureString(_text) + bevel * 2,
ft.height() + bevel * 2); ft.height() + bevel * 2);
OtkFocusWidget::update(); OtkFocusWidget::update();
ft.drawString(getWindow(), bevel, bevel, *text_color, _text); ft.drawString(getWindow(), bevel, bevel, *text_color, _text);
@ -73,4 +72,10 @@ bool OtkButton::expose(const XExposeEvent &e)
return OtkFocusWidget::expose(e); return OtkFocusWidget::expose(e);
} }
bool OtkButton::configure(const XConfigureEvent &e)
{
_dirty = true;
return OtkFocusWidget::configure(e);
}
} }

View file

@ -35,6 +35,7 @@ public:
virtual void update(void); virtual void update(void);
virtual bool expose(const XExposeEvent &e); virtual bool expose(const XExposeEvent &e);
virtual bool configure(const XConfigureEvent &e);
private: private:

View file

@ -5,6 +5,7 @@
#include "timerqueuemanager.hh" #include "timerqueuemanager.hh"
#include "image.hh" #include "image.hh"
#include "style.hh" #include "style.hh"
#include <iostream>
int main(void) { int main(void) {
otk::OBDisplay::initialize(NULL); otk::OBDisplay::initialize(NULL);
@ -59,8 +60,12 @@ int main(void) {
if (XPending(otk::OBDisplay::display)) { if (XPending(otk::OBDisplay::display)) {
XEvent e; XEvent e;
XNextEvent(otk::OBDisplay::display, &e); XNextEvent(otk::OBDisplay::display, &e);
if (e.type == Expose) if (e.type == Expose) {
foo.expose(e.xexpose); foo.expose(e.xexpose);
} else if (e.type == ConfigureNotify) {
std::cout << "configure\n";
foo.configure(e.xconfigure);
}
} }
} }

View file

@ -11,6 +11,7 @@ namespace otk {
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction) OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
: _parent(parent), _style(parent->getStyle()), _direction(direction), : _parent(parent), _style(parent->getStyle()), _direction(direction),
_cursor(parent->getCursor()), _bevel_width(parent->getBevelWidth()), _cursor(parent->getCursor()), _bevel_width(parent->getBevelWidth()),
_ignore_config(0),
_visible(false), _focused(false), _grabbed_mouse(false), _visible(false), _focused(false), _grabbed_mouse(false),
_grabbed_keyboard(false), _stretchable_vert(false), _grabbed_keyboard(false), _stretchable_vert(false),
_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0), _stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
@ -24,7 +25,7 @@ OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
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), : _parent(0), _style(style), _direction(direction), _cursor(cursor),
_bevel_width(bevel_width), _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),
_bg_pixmap(0), _bg_pixel(0), _screen(style->getScreen()), _bg_pixmap(0), _bg_pixel(0), _screen(style->getScreen()),
@ -124,6 +125,7 @@ void OtkWidget::setGeometry(int x, int y, int width, int height)
{ {
_rect = Rect(x, y, width, height); _rect = Rect(x, y, width, height);
_dirty = true; _dirty = true;
_ignore_config++;
XMoveResizeWindow(otk::OBDisplay::display, _window, x, y, width, height); XMoveResizeWindow(otk::OBDisplay::display, _window, x, y, width, height);
} }
@ -208,11 +210,9 @@ void OtkWidget::ungrabKeyboard(void)
void OtkWidget::render(void) void OtkWidget::render(void)
{ {
Pixmap old = _bg_pixmap;
_bg_pixmap = _texture->render(_rect.width(), _rect.height(), _bg_pixmap); _bg_pixmap = _texture->render(_rect.width(), _rect.height(), _bg_pixmap);
if (_bg_pixmap && _bg_pixmap != old) if (_bg_pixmap)
XSetWindowBackgroundPixmap(otk::OBDisplay::display, _window, _bg_pixmap); XSetWindowBackgroundPixmap(otk::OBDisplay::display, _window, _bg_pixmap);
else { else {
unsigned int pix = _texture->color().pixel(); unsigned int pix = _texture->color().pixel();
@ -405,4 +405,24 @@ bool OtkWidget::expose(const XExposeEvent &e)
return false; return false;
} }
bool OtkWidget::configure(const XConfigureEvent &e)
{
if (e.window == _window) {
if (_ignore_config) {
_ignore_config--;
} else {
_dirty = true;
_rect.setRect(e.x, e.y, e.width, e.height);
update();
}
return true;
} else {
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
for (; it != end; ++it)
if ((*it)->configure(e))
return true;
}
return false;
}
} }

View file

@ -28,6 +28,7 @@ public:
virtual void update(void); virtual void update(void);
virtual bool expose(const XExposeEvent &e); virtual bool expose(const XExposeEvent &e);
virtual bool configure(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; }
@ -41,6 +42,9 @@ public:
virtual void setWidth(int); virtual void setWidth(int);
virtual void setHeight(int); virtual void setHeight(int);
virtual int width() const { return _rect.width(); }
virtual int height() const { return _rect.height(); }
virtual void resize(const Point &to); virtual void resize(const Point &to);
virtual void resize(int x, int y); virtual void resize(int x, int y);
@ -106,6 +110,7 @@ private:
Direction _direction; Direction _direction;
Cursor _cursor; Cursor _cursor;
int _bevel_width; int _bevel_width;
int _ignore_config;
bool _visible; bool _visible;
bool _focused; bool _focused;
@ -126,7 +131,6 @@ private:
bool _fixed_width; bool _fixed_width;
bool _fixed_height; bool _fixed_height;
protected:
bool _dirty; bool _dirty;
}; };