change how the widgets' _dirty flag works so that all inheritence levels of the widget class can use it
This commit is contained in:
parent
d4d15160fe
commit
77342413ef
6 changed files with 23 additions and 60 deletions
|
@ -3,7 +3,7 @@
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
OtkFocusLabel::OtkFocusLabel(OtkWidget *parent)
|
OtkFocusLabel::OtkFocusLabel(OtkWidget *parent)
|
||||||
: OtkFocusWidget(parent), _text(""), _dirty(false)
|
: OtkFocusWidget(parent), _text("")
|
||||||
{
|
{
|
||||||
setTexture(getStyle()->getLabelFocus());
|
setTexture(getStyle()->getLabelFocus());
|
||||||
setUnfocusTexture(getStyle()->getLabelUnfocus());
|
setUnfocusTexture(getStyle()->getLabelUnfocus());
|
||||||
|
@ -55,21 +55,6 @@ void OtkFocusLabel::update(void)
|
||||||
ft.drawString(getWindow(), x, bevel, *text_color, t);
|
ft.drawString(getWindow(), x, bevel, *text_color, t);
|
||||||
} else
|
} else
|
||||||
OtkFocusWidget::update();
|
OtkFocusWidget::update();
|
||||||
|
|
||||||
_dirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OtkFocusLabel::exposeHandler(const XExposeEvent &e)
|
|
||||||
{
|
|
||||||
_dirty = true;
|
|
||||||
return OtkFocusWidget::exposeHandler(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
int OtkFocusLabel::configureHandler(const XConfigureEvent &e)
|
|
||||||
{
|
|
||||||
if (!(e.width == width() && e.height == height()))
|
|
||||||
_dirty = true;
|
|
||||||
return OtkFocusWidget::configureHandler(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,10 @@ public:
|
||||||
void setText(const std::string &text) { _text = text; _dirty = true; }
|
void setText(const std::string &text) { _text = text; _dirty = true; }
|
||||||
|
|
||||||
void update(void);
|
void update(void);
|
||||||
int exposeHandler(const XExposeEvent &e);
|
|
||||||
int configureHandler(const XConfigureEvent &e);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _text;
|
std::string _text;
|
||||||
bool _dirty;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
17
otk/label.cc
17
otk/label.cc
|
@ -3,7 +3,7 @@
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
OtkLabel::OtkLabel(OtkWidget *parent)
|
OtkLabel::OtkLabel(OtkWidget *parent)
|
||||||
: OtkWidget(parent), _text(""), _dirty(false)
|
: OtkWidget(parent), _text("")
|
||||||
{
|
{
|
||||||
setTexture(getStyle()->getLabelUnfocus());
|
setTexture(getStyle()->getLabelUnfocus());
|
||||||
}
|
}
|
||||||
|
@ -52,21 +52,6 @@ void OtkLabel::update(void)
|
||||||
ft.drawString(getWindow(), x, bevel, *getStyle()->getTextUnfocus(), t);
|
ft.drawString(getWindow(), x, bevel, *getStyle()->getTextUnfocus(), t);
|
||||||
} else
|
} else
|
||||||
OtkWidget::update();
|
OtkWidget::update();
|
||||||
|
|
||||||
_dirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OtkLabel::exposeHandler(const XExposeEvent &e)
|
|
||||||
{
|
|
||||||
_dirty = true;
|
|
||||||
return OtkWidget::exposeHandler(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
int OtkLabel::configureHandler(const XConfigureEvent &e)
|
|
||||||
{
|
|
||||||
if (!(e.width == width() && e.height == height()))
|
|
||||||
_dirty = true;
|
|
||||||
return OtkWidget::configureHandler(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,10 @@ public:
|
||||||
void setText(const std::string &text) { _text = text; _dirty = true; }
|
void setText(const std::string &text) { _text = text; _dirty = true; }
|
||||||
|
|
||||||
void update(void);
|
void update(void);
|
||||||
int exposeHandler(const XExposeEvent &e);
|
|
||||||
int configureHandler(const XConfigureEvent &e);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _text;
|
std::string _text;
|
||||||
bool _dirty;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace otk {
|
||||||
|
|
||||||
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
||||||
: OtkEventHandler(),
|
: OtkEventHandler(),
|
||||||
|
_dirty(false),
|
||||||
_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),
|
_ignore_config(0),
|
||||||
|
@ -17,7 +18,7 @@ OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
||||||
_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),
|
||||||
_screen(parent->getScreen()), _fixed_width(false), _fixed_height(false),
|
_screen(parent->getScreen()), _fixed_width(false), _fixed_height(false),
|
||||||
_dirty(false), _event_dispatcher(parent->getEventDispatcher())
|
_event_dispatcher(parent->getEventDispatcher())
|
||||||
{
|
{
|
||||||
parent->addChild(this);
|
parent->addChild(this);
|
||||||
create();
|
create();
|
||||||
|
@ -27,12 +28,13 @@ OtkWidget::OtkWidget(OtkWidget *parent, Direction direction)
|
||||||
OtkWidget::OtkWidget(OtkApplication *app, Direction direction,
|
OtkWidget::OtkWidget(OtkApplication *app, Direction direction,
|
||||||
Cursor cursor, int bevel_width)
|
Cursor cursor, int bevel_width)
|
||||||
: OtkEventHandler(),
|
: OtkEventHandler(),
|
||||||
|
_dirty(false),
|
||||||
_parent(0), _style(app->getStyle()), _direction(direction), _cursor(cursor),
|
_parent(0), _style(app->getStyle()), _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),
|
||||||
_bg_pixmap(0), _bg_pixel(0), _screen(app->getStyle()->getScreen()),
|
_bg_pixmap(0), _bg_pixel(0), _screen(app->getStyle()->getScreen()),
|
||||||
_fixed_width(false), _fixed_height(false), _dirty(false),
|
_fixed_width(false), _fixed_height(false),
|
||||||
_event_dispatcher(app)
|
_event_dispatcher(app)
|
||||||
{
|
{
|
||||||
assert(app);
|
assert(app);
|
||||||
|
@ -43,12 +45,13 @@ OtkWidget::OtkWidget(OtkApplication *app, Direction direction,
|
||||||
OtkWidget::OtkWidget(Style *style, Direction direction,
|
OtkWidget::OtkWidget(Style *style, Direction direction,
|
||||||
Cursor cursor, int bevel_width)
|
Cursor cursor, int bevel_width)
|
||||||
: OtkEventHandler(),
|
: OtkEventHandler(),
|
||||||
|
_dirty(false),
|
||||||
_parent(0), _style(style), _direction(direction), _cursor(cursor),
|
_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),
|
||||||
_bg_pixmap(0), _bg_pixel(0), _screen(style->getScreen()),
|
_bg_pixmap(0), _bg_pixel(0), _screen(style->getScreen()),
|
||||||
_fixed_width(false), _fixed_height(false), _dirty(false)
|
_fixed_width(false), _fixed_height(false)
|
||||||
{
|
{
|
||||||
assert(style);
|
assert(style);
|
||||||
create();
|
create();
|
||||||
|
@ -426,18 +429,14 @@ void OtkWidget::setEventDispatcher(OtkEventDispatcher *disp)
|
||||||
int OtkWidget::exposeHandler(const XExposeEvent &e)
|
int OtkWidget::exposeHandler(const XExposeEvent &e)
|
||||||
{
|
{
|
||||||
OtkEventHandler::exposeHandler(e);
|
OtkEventHandler::exposeHandler(e);
|
||||||
if (e.window == _window) {
|
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OtkWidget::configureHandler(const XConfigureEvent &e)
|
int OtkWidget::configureHandler(const XConfigureEvent &e)
|
||||||
{
|
{
|
||||||
OtkEventHandler::configureHandler(e);
|
OtkEventHandler::configureHandler(e);
|
||||||
if (e.window == _window) {
|
|
||||||
if (_ignore_config) {
|
if (_ignore_config) {
|
||||||
_ignore_config--;
|
_ignore_config--;
|
||||||
} else {
|
} else {
|
||||||
|
@ -447,10 +446,8 @@ int OtkWidget::configureHandler(const XConfigureEvent &e)
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,10 @@ public:
|
||||||
{ return _event_dispatcher; }
|
{ return _event_dispatcher; }
|
||||||
void setEventDispatcher(OtkEventDispatcher *disp);
|
void setEventDispatcher(OtkEventDispatcher *disp);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool _dirty;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void create(void);
|
void create(void);
|
||||||
|
@ -139,8 +143,6 @@ private:
|
||||||
bool _fixed_width;
|
bool _fixed_width;
|
||||||
bool _fixed_height;
|
bool _fixed_height;
|
||||||
|
|
||||||
bool _dirty;
|
|
||||||
|
|
||||||
OtkEventDispatcher *_event_dispatcher;
|
OtkEventDispatcher *_event_dispatcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue