From 97b4a5904a989e216b1fbb4d0a55b7340bd7f88a Mon Sep 17 00:00:00 2001 From: pixel Date: Tue, 31 Jan 2006 17:02:39 +0000 Subject: Way too much changes - all over. --- lib/widgets.cc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'lib/widgets.cc') diff --git a/lib/widgets.cc b/lib/widgets.cc index 0bc1d2e..1f98597 100644 --- a/lib/widgets.cc +++ b/lib/widgets.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: widgets.cc,v 1.16 2005-12-02 16:21:59 pixel Exp $ */ +/* $Id: widgets.cc,v 1.17 2006-01-31 17:02:39 pixel Exp $ */ #include #include @@ -54,7 +54,8 @@ class widget_mouse_event : public mogltk::engine::mouseevent { Uint32 old_click; }; -widget_mouse_event::widget_mouse_event(mogltk::widget * _root) : root(_root), mouse_down(false), mouse_drag(false) { +widget_mouse_event::widget_mouse_event(mogltk::widget * _root) : + root(_root), mouse_down(false), mouse_drag(false) { } void widget_mouse_event::move(SDL_MouseMotionEvent m) { @@ -210,6 +211,7 @@ mogltk::widget * mogltk::widget::focused = 0; mogltk::widget::widget(widget * _father, int _x, int _y, int _sx, int _sy, int _type, String _name, mogltk::shape * _sh) : x(_x), y(_y), sx(_sx), sy(_sy), father(_father), prev(0), child(0), last(0), panel(0), type(_type), name(_name), sh(_sh), exclusive(0), visible(true), enabled(true) { + LOCK; if (!father) { root = this; father = this; @@ -227,6 +229,7 @@ mogltk::widget::widget(widget * _father, int _x, int _y, int _sx, int _sy, int _ father->child = this; root = father->root; } + UNLOCK; computeabs(); } @@ -235,6 +238,7 @@ mogltk::widget::~widget() { while(child) delete child; + LOCK; if (prev) prev->next = next; else @@ -262,12 +266,14 @@ mogltk::widget::~widget() { } } +#if 0 for (iw = to_delete.begin(); iw != to_delete.end(); iw++) { if (*iw == this) { to_delete.erase(iw); iw = to_delete.begin(); } } +#endif for (it = timed_events.begin(); it != timed_events.end(); it++) { if (it->w == this) { @@ -275,6 +281,7 @@ mogltk::widget::~widget() { it = timed_events.begin(); } } + UNLOCK; } void mogltk::widget::computeabs() { @@ -815,18 +822,7 @@ mogltk::widgets::SmartBoxClose::SmartBoxClose(mogltk::shape * sh, mogltk::widget * The MessageBox child * ***********************/ -class MessageBoxAction : public mogltk::widgets::action { - public: - MessageBoxAction(mogltk::widget * _parent) : parent(_parent) { } - virtual void do_action(mogltk::widget *) { - delete parent; - delete this; - } - private: - mogltk::widget * parent; -}; - -mogltk::widgets::MsgBox::MsgBox(shape * sh, mogltk::widget * father, const String & caption, const String & text, mogltk::font * _font) : SmartBox(sh, father, 0, 0, 0, 0, caption), msgbox_font(_font) { +mogltk::widgets::MsgBox::MsgBox(action * a, shape * sh, mogltk::widget * father, const String & caption, const String & text, mogltk::font * _font) : SmartBox(sh, father, 0, 0, 0, 0, caption), msgbox_font(_font) { rect size = msgbox_font->size(text); rect lsize = size; @@ -836,7 +832,7 @@ mogltk::widgets::MsgBox::MsgBox(shape * sh, mogltk::widget * father, const Strin resize(size.w, size.h); center(); - new Button(new MessageBoxAction(this), sh, this, size.w / 2 - 25, size.h - 30, 50, 24, "Ok"); + new Button(new ActionAndDelete(this, a), sh, this, size.w / 2 - 25, size.h - 30, 50, 24, "Ok"); new Label(sh, this, 6, 24, lsize.w, lsize.h, text, BLACK, msgbox_font); set_exclusive(father); -- cgit v1.2.3