delete_child() delete_child()
Name
delete_child - Composite class method called when a child is destroyed.
Synopsis
typedef void (*XtWidgetProc)(Widget);
Widget w;
Inputs
w Specifies the child that is to be removed from its parent's children array.
Description
The delete_child() method is registered on the delete_child field of the Composite class part structure. It is called by XtDestroyWidget()
to remove a child from its parent's children array.
Note that the argument to the delete_child() method is the child widget, not the composite widget that defines the method. This method
must remove the specified child from its parent's children array, and free up any other memory that the class uses to keep track of the
child.
The delete_child() method is not chained. If a class does not define a delete_child() method, it should inherit the method from its super-
class by specifying XtInheritDeleteChild in the delete_child field of its Composite class part structure. This field should not be set to
NULL.
Usage
Most widgets simply inherit the delete_child() method from their superclass. Some widget classes, though, create companion widgets for
each of their children (the Xaw Paned widget creates the Grip widgets that separate the panes, for example) or maintain information about
each child that must be freed up when the child is destroyed. These classes must provide their own delete_child() procedures. These pro-
cedures commonly "envelop" their superclass's method by providing a procedure that does class-specific processing and explicitly invokes
the superclass method. This technique allows a kind of non-automatic inheritance, and is shown in the example below.
Note that the Composite insert_child() and delete_child() methods exploit internal common data structures, so you should inherit or envelop
both or neither. If you do not inherit or envelop these methods, then your methods are responsible for adding and removing the child wid-
get from the children array.
Example
The following procedure is the delete_child() method of the Xaw Paned widget class. Note how it destroys the Grip widget that was automat-
ically created as a sibling of the child, and then explicitly invokes its superclass's delete_child() method to remove the child from the
Composite children array. See insert_child(4) for the corresponding insert_child() procedure.
static void DeleteChild(w)
Widget w;
{
/* remove the subwidget info and destroy the grip */
if ( IsPane(w) && HasGrip(w) ) XtDestroyWidget(PaneInfo(w)->grip);
/* delete the child widget in the composite children list with the */
/* superclass delete_child routine. */
(*SuperClass->composite_class.delete_child) (w);
} /* DeleteChild */
In this example, SuperClass is a symbolic name for the superclass of the Paned widget class. Note that this method does not determine the
superclass as follows:
XtSuperclass(XtParent(w))
The parent of w may be a subclass of Paned, and therefore its superclass pointer will not always be the class whose method should be
invoked.
See Also
Composite(3),
insert_child(4).
Xt - Intrinsics Methods delete_child()