Base class for the association type. More...
Inherited by shortcutAssociationType.
|virtual void||destroy (void *data) const =0|
|This function is called when associated data is freed This function must be proveded when creating a data specific subclass. The function must do whatever is necessary to free associated data. Most of the time it will be a cast to the right datatype and a delete. |
|void *||foreach (const Widget *wg, AssociationFunctor &fkt)|
|Finds all data of this association type for a widget This function just calls fltk::foreach(this, wg, fkt). If wg is NULL this function will find all data for any widget. |
|(Note that these are not member functions.) |
|void *||foreach (const AssociationType *, const Widget *, AssociationFunctor &)|
Base class for the association type.
FLTK allows you to attach any kind of user data to a widget. This data is automatically freed when the widget to which it is attached is destroyed. Internally an association table is used to connect the widget pointer with the data pointer that is why all the functions concerned with this feature contain "association" in their name. The advantage of this is that no space is taken on widgets that do not contain the data (or that have the "default value"), and that the destructor code is not linked in if the association is not used.
To be able to associate data and to be able to have a customized way of freeing the data you need to derive from this class and then create an instance of that class. With the pointer to that instance the type of the data is identified.
This function allows traversing all associations of a certain association type, a certain widget, both, or none of the constraints. For each found widget the handle function in the associaionFunctor class is called. If that function returns true the scan is aborted and the data for the current widget is returned A NULL pointer for the AssociationType or the Widget pointer means to call the functor for all AssociationTypes and/or all Widgets.