Name
realize — Core method to set window attributes and to create a window.
Synopsis
typedef void (∗XtRealizeProc)(Widget, XtValueMask, XSetWindowAttributes ∗);
Widget w;
XtValueMask value_mask;
XSetWindowAttributes ∗attributes;
Arguments
wSpecifies the widget.
value_mask
Specifies which fields in the attributes structure to use.
attributes
Specifies the window attributes to use in the XCreateWindow call.
Description
The Intrinsics invoke the Core realize method of each widget instance when the application calls XtRealizeWidget on the application’s top-level widget.
The Core realize method must set window attributes for the window and create the widget’s window. value_mask indicates what values in the XSetWindowAttributes structure are used.
XtRealizeWidget fills in a mask and a corresponding XSetWindowAttributes structure. It sets the following fields based on information in the widget’s Core structure:
•background_pixmap (or background_pixel if background_pixmap is NULL) is filled in from the corresponding field.
•colormap is filled in from the corresponding field.
•border_pixmap (or border_pixel if border_pixmap is NULL) is filled in from the corresponding field.
•event_mask is filled in based on which event handlers are registered, which event translations are specified, whether expose is non-NULL, and whether visible_interest is True.
•bit_gravity is set to NorthWestGravity if the expose field is NULL.
All other fields in attributes (and the corresponding bits in value_mask) can be set by the realize method.
Note that because realize is not a chained operation, the widget class’s realize method must update the XSetWindowAttributes structure with all the appropriate fields from non-Core superclasses.
A widget class can inherit its realize method from its superclass during class initialization by specifying XtInheritRealize for the realize field. The realize method defined for Core calls XtCreateWindow with the passed value_mask and attributes and with windowClass and visual set to CopyFromParent. Both CompositeWidgetClass and ConstraintWidgetClass inherit this realize method, and most new widget subclasses can do the same.
The most common noninherited realize methods set bit_gravity in value_mask and attributes to the appropriate value and then create the window. For example, depending on its justification, Label sets bit_gravity to WestGravity, CenterGravity, or EastGravity. Consequently, shrinking it just moves the bits appropriately, and no Expose event is needed for repainting.
If a composite widget’s children should be realized in a particular order (typically to control the stacking order), the widget should call XtRealizeWidget on its children itself in the appropriate order from within its own realize method.
Widgets that have children and that are not a subclass of compositeWidgetClass are responsible for calling XtRealizeWidget on their children, usually from within the realize method.
Structures
/∗ Definitions for valuemask argument. These control which fields in
∗ XSetWindowAttributes structure should be used.
∗/
typedef struct {
Pixmap background_pixmap; /∗ background or None or ParentRelative ∗ /
unsigned long background_pixel;/∗ background pixel ∗/
Pixmap border_pixmap;/∗ border of the window ∗/
unsigned long border_pixel;/∗ border pixel value ∗/
int bit_gravity;/∗ one of bit gravity values ∗/
int win_gravity;/∗ one of the window gravity values ∗/
int backing_store;/∗ NotUseful, WhenMapped, Always ∗/
unsigned long backing_planes;/∗ planes to be preserved if possible ∗/
unsigned long backing_pixel;/∗ value to use in restoring planes ∗/
Bool save_under;/∗ should bits under be saved (popups) ∗/
long event_mask;/∗ set of events that should be saved ∗/
long do_not_propagate_mask;/∗ set of events that should not propagate ∗/
Bool override_redirect;/∗ boolean value for override-redirect ∗/
Colormap colormap;/∗ colormap to be associated with window ∗/
Cursor cursor;/∗ cursor to be displayed (or None) ∗/
} XSetWindowAttributes;
Examples
The following is the realize method of the Athena Paned widget class:
static void
Realize(w, valueMask, attributes)
Widget w;
Mask ∗valueMask;
XSetWindowAttributes ∗attributes;
{
PanedWidget pw = (PanedWidget) w;
Widget ∗ childP;
if ((attributes->cursor = (pw)->paned.cursor) != None)
∗valueMask |= CWCursor;
(∗SuperClass->core_class.realize) (w, valueMask, attributes);
/∗
∗ Before we commit the new locations we need to
∗ realize all the panes and their grips.
∗/
ForAllPanes(pw, childP) {
XtRealizeWidget( ∗childP );
if (HasGrip (∗childP))
XtRealizeWidget( PaneInfo(∗childP)->grip );
}
RefigureLocationsAndCommit(w);
} /∗ Realize ∗/