1XtCreateWidget(3) XT FUNCTIONS XtCreateWidget(3)
2
3
4
6 XtCreateWidget, XtVaCreateWidget, XtCreateManagedWidget, XtVaCreate‐
7 ManagedWidget, XtDestroyWidget - create and destroy widgets
8
10 #include <X11/Intrinsic.h>
11
12 Widget XtCreateWidget(const char *name, WidgetClass widget_class, Wid‐
13 get parent, ArgList args, Cardinal num_args);
14
15 Widget XtVaCreateWidget(const char *name, WidgetClass widget_class,
16 Widget parent, ...);
17
18 Widget XtCreateManagedWidget(const char *name, WidgetClass wid‐
19 get_class, Widget parent, ArgList args, Cardinal num_args);
20
21 Widget XtVaCreateManagedWidget(const char *name, WidgetClass wid‐
22 get_class, Widget parent, ...);
23
24 void XtDestroyWidget(Widget w);
25
27 args Specifies the argument list to override the resource
28 defaults.
29
30 name Specifies the resource name for the created widget, which is
31 used for retrieving resources and, for that reason, should
32 not be the same as any other widget that is a child of same
33 parent.
34
35 num_args Specifies the number of arguments in the argument list.
36
37 parent Specifies the parent widget.
38
39 w Specifies the widget.
40
41 widget_class
42 Specifies the widget class pointer for the created widget.
43
44 ... Specifies the variable argument list to override the resource
45 defaults.
46
48 The XtCreateWidget function performs much of the boilerplate operations
49 of widget creation:
50
51 · Checks to see if the class_initialize procedure has been called
52 for this class and for all superclasses and, if not, calls those
53 necessary in a superclass-to-subclass order.
54
55 · Allocates memory for the widget instance.
56
57 · If the parent is a subclass of constraintWidgetClass, it allocates
58 memory for the parent's constraints and stores the address of this
59 memory into the constraints field.
60
61 · Initializes the core nonresource data fields (for example, parent
62 and visible).
63
64 · Initializes the resource fields (for example, background_pixel) by
65 using the resource lists specified for this class and all super‐
66 classes.
67
68 · If the parent is a subclass of constraintWidgetClass, it initial‐
69 izes the resource fields of the constraints record by using the
70 constraint resource list specified for the parent's class and all
71 superclasses up to constraintWidgetClass.
72
73 · Calls the initialize procedures for the widget by starting at the
74 Core initialize procedure on down to the widget's initialize pro‐
75 cedure.
76
77 · If the parent is a subclass of compositeWidgetClass, it puts the
78 widget into its parent's children list by calling its parent's
79 insert_child procedure. For further information, see Section 3.5.
80
81 · If the parent is a subclass of constraintWidgetClass, it calls the
82 constraint initialize procedures, starting at constraintWidget‐
83 Class on down to the parent's constraint initialize procedure.
84
85 Note that you can determine the number of arguments in an argument list
86 by using the XtNumber macro. For further information, see Section
87 11.1.
88
89 The XtCreateManagedWidget function is a convenience routine that calls
90 XtCreateWidget and XtManageChild.
91
92 The XtDestroyWidget function provides the only method of destroying a
93 widget, including widgets that need to destroy themselves. It can be
94 called at any time, including from an application callback routine of
95 the widget being destroyed. This requires a two-phase destroy process
96 in order to avoid dangling references to destroyed widgets.
97
98 In phase one, XtDestroyWidget performs the following:
99
100 · If the being_destroyed field of the widget is True, it returns
101 immediately.
102
103 · Recursively descends the widget tree and sets the being_destroyed
104 field to True for the widget and all children.
105
106 · Adds the widget to a list of widgets (the destroy list) that
107 should be destroyed when it is safe to do so.
108
109 Entries on the destroy list satisfy the invariant that if w2 occurs
110 after w1 on the destroy list then w2 is not a descendent of w1. (A
111 descendant refers to both normal and pop-up children.)
112
113 Phase two occurs when all procedures that should execute as a result of
114 the current event have been called (including all procedures registered
115 with the event and translation managers), that is, when the current
116 invocation of XtDispatchEvent is about to return or immediately if not
117 in XtDispatchEvent.
118
119 In phase two, XtDestroyWidget performs the following on each entry in
120 the destroy list:
121
122 · Calls the destroy callback procedures registered on the widget
123 (and all descendants) in post-order (it calls children callbacks
124 before parent callbacks).
125
126 · If the widget's parent is a subclass of compositeWidgetClass and
127 if the parent is not being destroyed, it calls XtUnmanageChild on
128 the widget and then calls the widget's parent's delete_child pro‐
129 cedure (see Section 3.4).
130
131 · If the widget's parent is a subclass of constraintWidgetClass, it
132 calls the constraint destroy procedure for the parent, then the
133 parent's superclass, until finally it calls the constraint destroy
134 procedure for constraintWidgetClass.
135
136 · Calls the destroy methods for the widget (and all descendants) in
137 post-order. For each such widget, it calls the destroy procedure
138 declared in the widget class, then the destroy procedure declared
139 in its superclass, until finally it calls the destroy procedure
140 declared in the Core class record.
141
142 · Calls XDestroyWindow if the widget is realized (that is, has an X
143 window). The server recursively destroys all descendant windows.
144
145 · Recursively descends the tree and deallocates all pop-up widgets,
146 constraint records, callback lists and, if the widget is a sub‐
147 class of compositeWidgetClass, children.
148
150 XtAppCreateShell(3), XtCreatePopupShell(3)
151 X Toolkit Intrinsics - C Language Interface
152 Xlib - C Language X Interface
153
154
155
156X Version 11 libXt 1.2.0 XtCreateWidget(3)