From 893a02e2c234330cd547e2bbbdc779f5c6050bea Mon Sep 17 00:00:00 2001 From: mescalinum Date: Tue, 1 Sep 2009 17:41:16 +0000 Subject: add skeleton for classes with widgetbehavior (GUI classes) svn path=/trunk/externals/tclpd/; revision=12165 --- tcl_class.cxx | 40 +++++++++++++++++++++++++++++++++++++--- tcl_extras.h | 8 ++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/tcl_class.cxx b/tcl_class.cxx index d468d04..8b21139 100644 --- a/tcl_class.cxx +++ b/tcl_class.cxx @@ -10,15 +10,28 @@ map class_table; map object_table; /* set up the class that handles loading of tcl classes */ -t_class* tclpd_class_new(char *name, int flags) { - t_class *c = class_new(gensym(name), (t_newmethod)tclpd_new, +t_class* tclpd_class_new(const char* name, int flags) { + t_class* c = class_new(gensym(name), (t_newmethod)tclpd_new, (t_method)tclpd_free, sizeof(t_tcl), flags, A_GIMME, A_NULL); class_table[string(name)] = c; class_addanything(c, tclpd_anything); return c; } -t_tcl* tclpd_new(t_symbol *classsym, int ac, t_atom *at) { +t_class* tclpd_guiclass_new(const char* name, int flags) { + t_class* c = tclpd_class_new(name, flags); + t_widgetbehavior* wb = (t_widgetbehavior*)getbytes(sizeof(t_widgetbehavior)); + wb->w_getrectfn = tclpd_guiclass_getrect; + wb->w_displacefn = tclpd_guiclass_displace; + wb->w_selectfn = tclpd_guiclass_select; + wb->w_activatefn = NULL; + wb->w_deletefn = tclpd_guiclass_delete; + wb->w_visfn = tclpd_guiclass_vis; + wb->w_clickfn = tclpd_guiclass_click; + class_setwidget(c, wb); +} + +t_tcl* tclpd_new(t_symbol* classsym, int ac, t_atom* at) { const char* name = classsym->s_name; t_class* qlass = class_table[string(name)]; t_tcl* self = (t_tcl*)pd_new(qlass); @@ -108,3 +121,24 @@ t_pd* tclpd_get_object_pd(const char* objectSequentialId) { void poststring2 (const char *s) { post("%s", s); } + +void tclpd_guiclass_getrect(t_gobj* z, t_glist* owner, int* xp1, int* yp1, int* xp2, int* yp2) { +} + +void tclpd_guiclass_displace(t_gobj* z, t_glist* glist, int dx, int dy) { +} + +void tclpd_guiclass_select(t_gobj* z, t_glist* glist, int selected) { +} + +void tclpd_guiclass_activate(t_gobj* z, t_glist* glist, int state) { +} + +void tclpd_guiclass_delete(t_gobj* z, t_glist* glist) { +} + +void tclpd_guiclass_vis(t_gobj* z, t_glist* glist, int vis) { +} + +int tclpd_guiclass_click(t_gobj* z, t_glist* glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { +} diff --git a/tcl_extras.h b/tcl_extras.h index 370145d..cdfc2e5 100644 --- a/tcl_extras.h +++ b/tcl_extras.h @@ -45,6 +45,7 @@ void tclpd_interp_error(int result); /* tcl_class.cxx */ t_class* tclpd_class_new(char* name, int flags); +t_class* tclpd_guiclass_new(const char* name, int flags); t_tcl* tclpd_new(t_symbol* classsym, int ac, t_atom* at); void tclpd_free (t_tcl* self); void tclpd_anything(t_tcl* self, t_symbol* s, int ac, t_atom* at); @@ -54,6 +55,13 @@ t_tcl* tclpd_get_instance(const char* objectSequentialId); t_object* tclpd_get_object(const char* objectSequentialId); t_pd* tclpd_get_object_pd(const char* objectSequentialId); void poststring2(const char* s); +void tclpd_guiclass_getrect(t_gobj* z, t_glist* owner, int* xp1, int* yp1, int* xp2, int* yp2); +void tclpd_guiclass_displace(t_gobj* z, t_glist* glist, int dx, int dy); +void tclpd_guiclass_select(t_gobj* z, t_glist* glist, int selected); +void tclpd_guiclass_activate(t_gobj* z, t_glist* glist, int state); +void tclpd_guiclass_delete(t_gobj* z, t_glist* glist); +void tclpd_guiclass_vis(t_gobj* z, t_glist* glist, int vis); +int tclpd_guiclass_click(t_gobj* z, t_glist* glist, int xpix, int ypix, int shift, int alt, int dbl, int doit); /* tcl_loader.cxx */ extern "C" int tclpd_do_load_lib(t_canvas* canvas, char* objectname); -- cgit v1.2.1