From 00b324bfc162030b575e03795dcfcaac56bd0b4d Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 5 Dec 2012 15:12:20 +0000 Subject: Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers. --- Panel.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'Panel.h') diff --git a/Panel.h b/Panel.h index 3f355837..16f0c2fe 100644 --- a/Panel.h +++ b/Panel.h @@ -26,8 +26,18 @@ typedef enum HandlerResult_ { typedef HandlerResult(*Panel_EventHandler)(Panel*, int); +typedef struct PanelClass_ { + const ObjectClass super; + const Panel_EventHandler eventHandler; +} PanelClass; + +#define As_Panel(this_) ((PanelClass*)((this_)->super.klass)) +#define Panel_eventHandlerFn(this_) As_Panel(this_)->eventHandler +#define Panel_eventHandler(this_, ev_) As_Panel(this_)->eventHandler((Panel*)(this_), ev_) + struct Panel_ { Object super; + PanelClass* class; int x, y, w, h; WINDOW* window; Vector* items; @@ -37,7 +47,6 @@ struct Panel_ { int oldSelected; bool needsRedraw; RichString header; - Panel_EventHandler eventHandler; char* eventHandlerBuffer; }; @@ -49,22 +58,18 @@ struct Panel_ { #define MAX(a,b) ((a)>(b)?(a):(b)) #endif -#ifdef DEBUG -extern char* PANEL_CLASS; -#else -#define PANEL_CLASS NULL -#endif - #define KEY_CTRLN 0016 /* control-n key */ #define KEY_CTRLP 0020 /* control-p key */ #define KEY_CTRLF 0006 /* control-f key */ #define KEY_CTRLB 0002 /* control-b key */ -Panel* Panel_new(int x, int y, int w, int h, char* type, bool owner, Object_Compare compare); +extern PanelClass Panel_class; + +Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type); void Panel_delete(Object* cast); -void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner); +void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner); void Panel_done(Panel* this); @@ -72,8 +77,6 @@ RichString* Panel_getHeader(Panel* this); extern void Panel_setHeader(Panel* this, const char* header); -void Panel_setEventHandler(Panel* this, Panel_EventHandler eh); - void Panel_move(Panel* this, int x, int y); void Panel_resize(Panel* this, int w, int h); -- cgit v1.2.3