delete_child()delete_child()Namedelete_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 wid‐
get, 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 superclass
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 super‐
class. 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 procedures
commonly "envelop" their superclass's method by providing a procedure
that does class-specific processing and explicitly invokes the super‐
class method. This technique allows a kind of non-automatic inheri‐
tance, 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 meth‐
ods, then your methods are responsible for adding and removing the
child widget 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 automati‐
cally 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 super‐
class pointer will not always be the class whose method should be
invoked.
See AlsoComposite(3),
insert_child(4).
Xt - Intrinsics Methods delete_child()