diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-12-05 15:12:20 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-12-05 15:12:20 +0000 |
commit | 00b324bfc162030b575e03795dcfcaac56bd0b4d (patch) | |
tree | fbaada243839b0b67351856e2d02a2e8184bf65f /Panel.h | |
parent | 2a73405cd060b543d56987650327b18078a137d7 (diff) |
Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers.
Diffstat (limited to 'Panel.h')
-rw-r--r-- | Panel.h | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -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); |