Constraint destroy() Constraint destroy()Name
Constraint destroy - Constraint class method for freeing resources
associated with a child's constraint record.
Synopsis
typedef void (*XtWidgetProc)(Widget);
Widget w;
Inputs
w Specifies the widget being destroyed.
Description
The Constraint destroy() method is registered on the destroy field of
the Constraint class part structure (which is not the same as the
destroy field of the Object or Core class part structure). It is
called by XtDestroyWidget() when the child of a constraint widget is
destroyed, and should deallocate any memory or resources associated
with the part of the constraint record of w that is owned by the class.
It should not deallocate the constraint record itself.
This method is similar to the Object destroy() method. The Constraint
destroy() methods of a widget class and its superclasses are called in
subclass-to-superclass order, starting at the class of the parent of w,
and ending at the Constraint class. Therefore, the Constraint
destroy() method should deallocate only memory and resources associated
with the part of the constraint record specific to its class, and not
the memory or resources allocated by any of its superclasses.
The Constraint destroy() method is chained, and so cannot be inherited.
If a constraint widget does not need to deallocate any memory or
resources associated with its constraint part structure, the destroy
field in its Constraint class part record can be NULL.
See destroy(4) for more information about what should be freed and what
should not. See XtDestroyWidget(1) for details on the widget and
object destruction process.
Example
The following procedure is the Constraint destroy() method of the Xaw
Tree widget. Note that it uses a macro (defined below) to cast the
specified widget's constraint field appropriately, and calls XtParent()
on the specified widget to obtain the Tree widget itself.
This procedure is a somewhat unusual example, because it does not
directly call XtFree(), XtReleaseGC(), or similar functions on fields
of the constraint record. The constraint records of the Tree class are
linked in a tree structure, and this procedure is used to remove a node
from that tree. This might have been more appropriate in the
delete_child() method instead.
static void ConstraintDestroy (w)
Widget w;
{
TreeConstraints tc = TREE_CONSTRAINT(w);
TreeWidget tw = (TreeWidget) XtParent(w);
int i;
/*
* Remove the widget from its parent's sub-nodes list and
* make all this widget's sub-nodes sub-nodes of the parent.
*/
if (tw->tree.tree_root == w) {
if (tc->tree.n_children > 0)
tw->tree.tree_root = tc->tree.children[0];
else
tw->tree.tree_root = NULL;
}
delete_node (tc->tree.parent, (Widget) w);
for (i = 0; i< tc->tree.n_children; i++)
insert_node (tc->tree.parent, tc->tree.children[i]);
layout_tree ((TreeWidget) (w->core.parent), FALSE);
}
The useful TREE_CONSTRAINTS macro is defined as follows:
#define TREE_CONSTRAINT(w) ((TreeConstraints)((w)->core.constraints))
See AlsoXtDestroyWidget(1),
Constraint(3), Core(3).
Xt - Intrinsics Methods Constraint destroy()