On 01/16/12 14:28, ORL wrote: > I need to get the parent of a Fl_Box type to determine what the handle method > does. > To be more accurate, I need to check if the parent class is light_xyPad > (which is a class I've written, quite close to Fl_Group, but with some > private variables).
AFAIK, FLTK doesn't use RTTI; quoting the docs for Fl_Widget::type(): http://www.fltk.org/doc-1.3/classFl__Widget.html#ac3050e16d7ed8dccbbf3468ea8c64ab8 "FLTK does not use RTTI (Run Time Typing Information), to enhance portability. But this may change in the near future if RTTI becomes standard everywhere. "If you don't have RTTI you can use the clumsy FLTK mechanism, by having type() use a unique value. These unique values must be greater than the symbol FL_RESERVED_TYPE (which is 100) and less than FL_WINDOW (unless you make a subclass of Fl_Window). Look through the header files for FL_RESERVED_TYPE to find an unused number. If you make a subclass of Fl_Window you must use FL_WINDOW + n (where n must be in the range 1 to 7)." I myself don't like to mess around with type(), since sometimes FLTK itself uses it internally. Is there any unique data that light_xyPad class saves in Fl_Widget? Like setting callback(), user_data() or label()? If so, you can test for that, eg: if ( box->parent()->callback() == what_you_want ) if ( box->parent()->user_data() == what_you_want ) if ( box->parent()->label() && strcmp(box->parent()->label(), what_you_want)==0 ) > (because I didn't figure out how to use type() function, always empty), type() is an integer IIRC that each widget can use for its own purposes, but doesn't have to use, and if unused it's probably 0. Its contents is not unique unless your derived class changes it to something above FL_RESERVED_TYPE (as defined above), but watch out that you don't affect the underlying FLTK widget's behavior if you use it. Since your class derives from Fl_Group (and thereby, Fl_Widget), Fl_Widget is pretty small, so there are only a few things you can 'customize'. Certainly callback() and user_data() and label() are safe things to change, provided you set them to things you're sure will be unique for your purposes. _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk