From b0b10e31736df2a943ea6bc094350c9119b282e6 Mon Sep 17 00:00:00 2001 From: orphis Date: Tue, 29 Mar 2005 16:37:42 +0000 Subject: Ajout de SmartBoxClose et changement de MsgBox pour qu'il hérite de SmartBoxClose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/widgets.h | 9 +++++++-- lib/widgets.cc | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/include/widgets.h b/include/widgets.h index 2bf2300..8865f9c 100644 --- a/include/widgets.h +++ b/include/widgets.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: widgets.h,v 1.9 2004-12-27 18:47:24 pixel Exp $ */ +/* $Id: widgets.h,v 1.10 2005-03-29 16:37:42 orphis Exp $ */ #ifndef __WIDGETS_H__ #define __WIDGETS_H__ @@ -174,7 +174,12 @@ namespace mogltk { int ox, oy, oax, oay; }; - class MsgBox : public SmartBox { + class SmartBoxClose : public SmartBox { + public: + SmartBoxClose(shape *, widget * father, int x, int y, int w, int h, const String & caption); + }; + + class MsgBox : public SmartBoxClose { public: MsgBox(shape *, widget * father, const String & caption, const String & text); virtual ~MsgBox(); diff --git a/lib/widgets.cc b/lib/widgets.cc index 16899da..9851c10 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.11 2004-12-27 18:47:24 pixel Exp $ */ +/* $Id: widgets.cc,v 1.12 2005-03-29 16:38:06 orphis Exp $ */ #include #include @@ -708,6 +708,25 @@ mogltk::rect mogltk::widgets::SmartBox::GetDrawRect() { return r; } +/****************************************** +* The SmartBox window with a close button * +******************************************/ + +class SmartBoxCloseAction : public mogltk::widgets::action { + public: + SmartBoxCloseAction(mogltk::widget * _parent) : parent(_parent) { } + virtual void do_action(mogltk::widget *) { + delete parent; + delete this; + } + private: + mogltk::widget * parent; +}; + +mogltk::widgets::SmartBoxClose::SmartBoxClose(mogltk::shape * sh, mogltk::widget * father, int x, int y, int w, int h, const String & _caption) : SmartBox(sh, father, x, y, w, h, _caption) { + new mogltk::widgets::Button(new SmartBoxCloseAction(this), sh, this, 1, 1, 16, 16, "X"); +} + /*********************** * The MessageBox child * @@ -724,7 +743,7 @@ class MessageBoxAction : public mogltk::widgets::action { mogltk::widget * parent; }; -mogltk::widgets::MsgBox::MsgBox(shape * sh, mogltk::widget * father, const String & caption, const String & text) : SmartBox(sh, father, 0, 0, 0, 0, caption) { +mogltk::widgets::MsgBox::MsgBox(shape * sh, mogltk::widget * father, const String & caption, const String & text) : SmartBoxClose(sh, father, 0, 0, 0, 0, caption) { rect size = SystemFont->size(text); rect lsize = size; -- cgit v1.2.3