From 6f594ad00a07365eec68e16d338151dde23bb648 Mon Sep 17 00:00:00 2001 From: pixel Date: Thu, 1 Dec 2005 13:48:12 +0000 Subject: Lots of fixes and adds in mogltk: -) fixed a compilation bug in the engine.h file (widget cyclic dependancy) -) fixed font system so to have unsigned chars instead of chars -) updated the shaper system so to have different fonts to print -) updated the widgets with: -) new methods: center, set_viewport, delete_me -) Label now has a font -) MsgBox now has a font -) InputText widget added -) InputDialog message box added -) fixed a bug in the engine causing unwanted mouse move events -) fixed a bug in the various lists of widgets (.clear != .empty) --- include/engine.h | 6 ++++-- include/font.h | 8 ++++---- include/shape.h | 7 ++++--- include/widgets.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 61 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/engine.h b/include/engine.h index 73d12dd..9d597b2 100644 --- a/include/engine.h +++ b/include/engine.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: engine.h,v 1.20 2004-11-27 21:48:01 pixel Exp $ */ +/* $Id: engine.h,v 1.21 2005-12-01 13:48:12 pixel Exp $ */ #ifndef __ENGINE_H__ #define __ENGINE_H__ @@ -27,9 +27,9 @@ #include #include #include -#include namespace mogltk { + class widget; class engine : public Base { public: class keyevent : public Base { @@ -98,4 +98,6 @@ namespace mogltk { }; }; +#include + #endif diff --git a/include/font.h b/include/font.h index 9530a37..6cf0e93 100644 --- a/include/font.h +++ b/include/font.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: font.h,v 1.10 2004-11-27 21:48:01 pixel Exp $ */ +/* $Id: font.h,v 1.11 2005-12-01 13:48:12 pixel Exp $ */ #ifndef __FONT_H__ #define __FONT_H__ @@ -40,8 +40,8 @@ namespace mogltk { void putcursor(int, int); void putentry(Uint16, ColorP = WHITE); void putentryontex(texture *, Uint16, ColorP = WHITE); - void drawchar(char, ColorP = WHITE); - void drawcharontex(texture *, char, ColorP = WHITE); + void drawchar(unsigned char, ColorP = WHITE); + void drawcharontex(texture *, unsigned char, ColorP = WHITE); void newline(void); int printf(const ugly_string &, ...); int printf(const char *, ...); @@ -58,7 +58,7 @@ namespace mogltk { void setcolor(ColorP); void setshadow(int); void setwspace(int); - int findchar(char) const; + int findchar(unsigned char) const; int singletextsize(const String &) const; protected: diff --git a/include/shape.h b/include/shape.h index 72feba2..b5c3d91 100644 --- a/include/shape.h +++ b/include/shape.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: shape.h,v 1.16 2004-11-27 21:48:01 pixel Exp $ */ +/* $Id: shape.h,v 1.17 2005-12-01 13:48:12 pixel Exp $ */ #ifndef __SHAPE_H__ #define __SHAPE_H__ @@ -27,6 +27,7 @@ #include #include #include +#include namespace mogltk { typedef enum { @@ -143,13 +144,13 @@ namespace mogltk { ColorP shade2 = DOS_GRAY); virtual void text(int x, int y, const String &, ColorP textcolor = DOS_HIGH_WHITE, - align_t align = LEFT); + align_t align = LEFT, mogltk::font * = mogltk::SystemFont); virtual void text3d(int x, int y, const String &, ColorP textcolor = DOS_BLACK, ColorP shade1 = DOS_HIGH_WHITE, ColorP shade2 = DOS_GRAY, align_t align = LEFT, - bool bevel = false); + bool bevel = false, mogltk::font * = mogltk::SystemFont); virtual void button(int x1, int y1, int x2, int y2, const String &, bool bevel = false, ColorP front = DOS_WHITE, diff --git a/include/widgets.h b/include/widgets.h index bf1cab1..ae29cee 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.11 2005-06-20 22:43:35 pixel Exp $ */ +/* $Id: widgets.h,v 1.12 2005-12-01 13:48:12 pixel Exp $ */ #ifndef __WIDGETS_H__ #define __WIDGETS_H__ @@ -25,6 +25,7 @@ #include #include #include +#include namespace mogltk { enum event_t { @@ -77,6 +78,9 @@ namespace mogltk { virtual void SetEnabled(bool); void MoveOnTop(); static void check_timed_events(); + void center(bool cx = true, bool cy = true); + void set_viewport(); + void delete_me(); protected: widget(widget * father, int x, int y, int sx, int sy, int type, String name, shape *); virtual void draw(); @@ -179,11 +183,12 @@ namespace mogltk { */ class Label : public widget { public: - Label(shape *, widget * father, int x, int y, int w, int h, const String & caption, const ColorP & color = BLACK); + Label(shape *, widget * father, int x, int y, int w, int h, const String & caption, const ColorP & color = BLACK, mogltk::font * = mogltk::SystemFont); protected: virtual void draw(); private: ColorP color; + mogltk::font * label_font; }; /*! @@ -212,10 +217,12 @@ namespace mogltk { The MsgBox is a SmartBoxClose which holds a text, as well as a 'Ok' button. */ - class MsgBox : public SmartBoxClose { + class MsgBox : public SmartBox { public: - MsgBox(shape *, widget * father, const String & caption, const String & text); + MsgBox(shape *, widget * father, const String & caption, const String & text, mogltk::font * = mogltk::SystemFont); virtual ~MsgBox(); + private: + mogltk::font * msgbox_font; }; /*! @@ -318,7 +325,45 @@ namespace mogltk { std::vector nodes; int cur_x; int selected; + ContextMenu * subselected; + }; + + class InputText : public widget { + public: + InputText(shape *, widget * father, int x, int y); + virtual ~InputText(); + virtual void draw(); + const String & GetText() const; + void SetText(const String &); + private: + class inputtext_keyevent : public mogltk::engine::keyevent { + public: + inputtext_keyevent(InputText *); + virtual void down(SDL_keysym k); + virtual void up(SDL_keysym k); + private: + InputText * father; + } * it_keyevent; + String text; }; + + /*! + The InputDialog is a kind of MsgBox which holds an InputText as well as a 'Ok' button. + It also contains an action so that the text can be readed from where the dialog + is created. + */ + class InputDialog : public SmartBox { + public: + InputDialog(action *, shape *, widget * father, const String & caption, const String & text, mogltk::font * = mogltk::SystemFont); + virtual ~InputDialog(); + String GetText(); + void do_action(); + private: + InputText * it; + action * a; + mogltk::font * InputDialog_font; + }; + }; }; -- cgit v1.2.3