2.5. Obtaining Window Information from a Widget   

The Core widget class definition contains the screen and window ids. The window field may be NULL for a while.

The display pointer, the parent widget, screen pointer, and window of a widget are available to the widget writer by means of macros and to the application writer by means of functions.


Display *XtDisplay(w)
Widget w;
w Specifies the widget. Must be of class Core or any subclass thereof.
XtDisplay returns the display pointer for the specified widget.

Widget XtParent(w)
Widget w;
w Specifies the widget. Must be of class Object or any subclass thereof.
XtParent returns the parent object for the specified widget. The returned object will be of class Object or a subclass.

Screen *XtScreen(w)
Widget w;
w Specifies the widget. Must be of class Core or any subclass thereof.
XtScreen returns the screen pointer for the specified widget.

Window XtWindow(w)
Widget w;
w Specifies the widget. Must be of class Core or any subclass thereof.
XtWindow returns the window of the specified widget.

The display pointer, screen pointer, and window of a widget or of the closest widget ancestor of a nonwidget object are available by means of XtDisplayOfObject, XtScreenOfObject, and XtWindowOfObject.


Display *XtDisplayOfObject(object)
Widget object;
object Specifies the object. Must be of class Object or any subclass thereof.
XtDisplayOfObject is identical in function to XtDisplay if the object is a widget; otherwise XtDisplayOfObject returns the display pointer for the nearest ancestor of object that is of class Widget or a subclass thereof.

Screen *XtScreenOfObject(object)
Widget object;
object Specifies the object. Must be of class Object or any subclass thereof.
XtScreenOfObject is identical in function to XtScreen if the object is a widget; otherwise XtScreenOfObject returns the screen pointer for the nearest ancestor of object that is of class Widget or a subclass thereof.

Window XtWindowOfObject(object)
Widget object;
object Specifies the object. Must be of class Object or any subclass thereof.
XtWindowOfObject is identical in function to XtWindow if the object is a widget; otherwise XtWindowOfObject returns the window for the nearest ancestor of object that is of class Widget or a subclass thereof.

To retrieve the instance name of an object, use XtName.


String XtName(object)
Widget object;
object Specifies the object whose name is desired. Must be of class Object or any subclass thereof.
XtName returns a pointer to the instance name of the specified object. The storage is owned by the Intrinsics and must not be modified. The name is not qualified by the names of any of the object's ancestors.

Several window attributes are locally cached in the widget instance. Thus, they can be set by the resource manager and XtSetValues as well as used by routines that derive structures from these values (for example, depth for deriving pixmaps, background_pixel for deriving GCs, and so on) or in the XtCreateWindow call.

The x, y, width, height, and border_width window attributes are available to geometry managers. These fields are maintained synchronously inside the Intrinsics. When an XConfigureWindow is issued by the Intrinsics on the widget's window (on request of its parent), these values are updated immediately rather than some time later when the server generates a ConfigureNotify event. (In fact, most widgets do not select SubstructureNotify events.) This ensures that all geometry calculations are based on the internally consistent toolkit world rather than on either an inconsistent world updated by asynchronous ConfigureNotify events or a consistent but slow world in which geometry managers ask the server for window sizes whenever they need to lay out their managed children.

2.5.1. Unrealizing Widgets   

To destroy the windows associated with a widget and its non-pop-up descendants, use XtUnrealizeWidget.


void XtUnrealizeWidget(w)
Widget w;
w Specifies the widget. Must be of class Core or any subclass thereof.
If the widget is currently unrealized, XtUnrealizeWidget simply returns. Otherwise it performs the following:

Unmanages the widget if the widget is managed.

Makes a postorder (child-to-parent) traversal of the widget tree rooted at the specified widget and, for each widget that has declared a callback list resource named ``unrealizeCallback'', executes the procedures on the XtNunrealizeCallback list.

Destroys the widget's window and any subwindows by calling XDestroyWindow with the specified widget's window field.

Any events in the queue or which arrive following a call to XtUnrealizeWidget will be dispatched as if the window(s) of the unrealized widget(s) had never existed.