make stuff draw on expose events
This commit is contained in:
parent
ed4696f691
commit
b3822fcfb1
5 changed files with 21 additions and 4 deletions
|
@ -57,12 +57,12 @@ void OtkButton::update(void)
|
|||
|
||||
OtkFocusWidget::resize(ft.measureString(_text) + bevel * 2,
|
||||
ft.height() + bevel * 2);
|
||||
ft.drawString(getWindow(), bevel, bevel, *text_color, _text);
|
||||
|
||||
OtkFocusWidget::update();
|
||||
}
|
||||
|
||||
_dirty = false;
|
||||
ft.drawString(getWindow(), bevel, bevel, *text_color, _text);
|
||||
} else
|
||||
OtkFocusWidget::update();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
std::string _text;
|
||||
//OtkPixmap _pixmap;
|
||||
bool _pressed;
|
||||
bool _dirty;
|
||||
// bool _dirty;
|
||||
|
||||
BTexture *_pressed_focus_tx;
|
||||
BTexture *_pressed_unfocus_tx;
|
||||
|
|
|
@ -59,6 +59,8 @@ int main(void) {
|
|||
if (XPending(otk::OBDisplay::display)) {
|
||||
XEvent e;
|
||||
XNextEvent(otk::OBDisplay::display, &e);
|
||||
if (e.type == Expose)
|
||||
foo.expose(e.xexpose);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -390,4 +390,16 @@ void OtkWidget::removeChild(OtkWidget *child)
|
|||
_children.erase(it);
|
||||
}
|
||||
|
||||
void OtkWidget::expose(const XExposeEvent &e)
|
||||
{
|
||||
if (e.window == _window) {
|
||||
_dirty = true;
|
||||
update();
|
||||
} else {
|
||||
OtkWidgetList::iterator it = _children.begin(), end = _children.end();
|
||||
for (; it != end; ++it)
|
||||
(*it)->expose(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public:
|
|||
|
||||
virtual void update(void);
|
||||
|
||||
void expose(const XExposeEvent &e);
|
||||
|
||||
inline Window getWindow(void) const { return _window; }
|
||||
inline const OtkWidget *getParent(void) const { return _parent; }
|
||||
inline const OtkWidgetList &getChildren(void) const { return _children; }
|
||||
|
@ -124,6 +126,7 @@ private:
|
|||
bool _fixed_width;
|
||||
bool _fixed_height;
|
||||
|
||||
protected:
|
||||
bool _dirty;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue