Greg Ercolano schrieb:
> 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;
But most of the modern compilers use RTTI as default (and even the older
ones can activate it) and so it works, when regarding classes, derived
from FLTK.
When there is a class My_Fl_Group, derived from Fl_Group, it is easy to
get the information:
if (My_Fl_Group* pG= dynamic_cast< My_Fl_Group* >(parent()))
{
// use your Group pG->do_something();
}
This also works, when widget is inside of some structures:
Fl_Group* pP= this->parent();
while (pP)
{
if (My_Fl_Group* pG= dynamic_cast< My_Fl_Group* >(pP))
{
// use your Group pG->do_something();
// Terminate loop:
pP= 0;
}
else pP= pP->parent();
}
This will crawl up the parents, until the special group was found.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk