hi Thomas,
I feel it is more like time for protecting widgetbehavior type itself, instead of exposing its objects. I expect the type definition is going to change, after people start complaining about flext objects being visible on-parent...
Besides, the long-term goal should be for externs to include only m_pd.h -- g_canvas.h is declared unstable.
So my short-term proposal is to have an access call, declared
EXTERN t_widgetbehavior *class_getwidget(t_class *c);
The longer-term proposal is to have a set of access calls, one for every callback, like
EXTERN void class_setpropertiesfn(t_class *c, t_propertiesfn f);
These routines would first check for an 'iscloned' flag introduced into t_widgetbehavior (along with a 'visedonparent' flag). If the 'iscloned' flag for a class c is zero, the routine will clone the widgetbehavior, and set the flag.
This way, an extern would just have to define a callback, and call class_set<whatever>fn() in class' setup routine, without bothering about other callbacks at all.
Krzysztof
Thomas Grill wrote: ...
- after the recent communication about cloning widget behavior i found the
easiest and equally portable solution to expose the text_widgetbehavior structure in g_canvas.h so that one can copy the respective functions to an object's own widgetbehavior structure, e.g. (from the attribute editor in flext)
//cloned functions widgetbehavior.w_getrectfn = text_widgetbehavior.w_getrectfn; widgetbehavior.w_displacefn = text_widgetbehavior.w_displacefn; widgetbehavior.w_selectfn = text_widgetbehavior.w_selectfn; widgetbehavior.w_activatefn = text_widgetbehavior.w_activatefn; widgetbehavior.w_deletefn = text_widgetbehavior.w_deletefn; widgetbehavior.w_clickfn = text_widgetbehavior.w_clickfn; // special functions widgetbehavior.w_propertiesfn = cb_GfxProperties; widgetbehavior.w_savefn = cb_GfxSave; widgetbehavior.w_visfn = cb_GfxVis; class_setwidget(c, &widgetbehavior);