Constraint initialize() Constraint initialize()Name
Constraint initialize - Constraint class method to initialize a child
object or widget's constraint record.
Synopsis
typedef void (*XtInitProc)(Widget, Widget, ArgList, Cardinal *);
Widget request;
Widget init;
ArgList args;
Cardinal *num_args;
Inputs
request Specifies the newly created child widget or object instance
with its constraint record resource values set as requested
by the argument list, the resource database, and the con‐
straint defaults.
init Specifies the same widget or object with its constraint
record fields as modified by any superclass Constraint ini‐
tialize() methods.
args Specifies the argument list that was passed to XtCreateWid‐
get().
num_args Specifies the number of entries in the argument list.
Description
The Constraint initialize() method is registered on the initialize
field of the Constraint class part structure, and is called by XtCre‐
ateWidget() when a child of the constraint widget is created. The Con‐
straint initialize() method performs the same sort of initializations
on the constraint record of a widget that the normal (Object, RectObj,
or Core) initialize() method performs on the widget instance structure.
The request and init arguments specify the child widget that is being
created. The constraints field of the request widget points to a copy
of the constraint record as it was after all of the constraint
resources were initialized from the argument list, the resource data‐
base, or the resource list defaults. The constraints field of the init
widget points to the actual constraints record of the widget, and has
been further initialized by the Constraint initialize() method of any
Constraint superclasses of the parent widget. All modifications should
be made to the init constraints record; the request argument exists so
that the widget class can determine which field of the constraints
record have been modified by superclass Constraint initialize() meth‐
ods.
The Constraint initialize() method is chained in superclass-to-subclass
order, and cannot be inherited. If nothing in the constraint structure
needs initialization, the Constraint class part initialize field should
be NULL.
The args and num_args arguments were added to this method in Release 4.
See initialize(4) for an explanation of the things that an initialize
procedure should do. See XtCreateWidget(1) for full details of the
widget creation process.
Example
The following procedure is the Constraint initialize() method, slightly
modified, of the Athena Form widget class. Note how it obtains the
constraint record and the parent form widget from the supplied child
widget. Note also that it provides "dynamic defaults" for two of its
constraint resources: if dx or dy is equal to some default value (i.e.,
if it was not explicitly specified), then it will be replaced by the
value of the XtNdefaultSpacing resource from the Form widget itself.
Note that this procedure (and most other initialize() procedures in
existence) has named its init argument new. "new" is a reserved word
in C++, and your programs will be more portable if you avoid using it
in your C code.
/* ARGSUSED */
static void ConstraintInitialize(request, new, args, num_args)
Widget request, new;
ArgList args;
Cardinal *num_args;
{
FormConstraints form = (FormConstraints)new->core.constraints;
FormWidget fw = (FormWidget)new->core.parent;
form->form.virtual_width = (int) new->core.width;
form->form.virtual_height = (int) new->core.height;
if (form->form.dx == default_value)
form->form.dx = fw->form.default_spacing;
if (form->form.dy == default_value)
form->form.dy = fw->form.default_spacing;
form->form.deferred_resize = False;
}
See AlsoXtCreateWidget(1),
Constraint(3), Core(3),
Constraint destroy(4), initialize(4), Constraint set_values(4).
Xt - Intrinsics Methods Constraint initialize()