class_part_initialize()class_part_initialize()Nameclass_part_initialize - Object class method to initialize class part
typedef void (*XtWidgetClassProc)(WidgetClass);
subclass Specifies the pointer to a widget class structure. It is the
class that registered this method or a subclass thereof.
The class_part_initialize() method is registered on the class_part_ini‐
tialize field of the Object, RectObj, or Core class structure, and is
called to dynamically initialize any fields in the class part structure
of its widget class.
During class initialization, the class_part_initialize() method for the
class and for all its superclasses is called in superclass-to-subclass
order on the class record. These procedures do any dynamic initializa‐
tions necessary to their class's part of the record, including resolu‐
tion of any inherited methods defined in the class. For example, if a
widget class C has superclasses Core, Composite, A, and B, then the
class record for C is passed first to Core's class_part_initialize()
method. This resolves any inherited Core methods and compiles the tex‐
tual representations of the resource list and action table that are
defined in the Core class part. Next, the Composite's class_part_ini‐
tialize() is called to initialize the Composite part of C's class
record. Finally, the class_part_initialize() procedures for A, B, and
C (in order) are called. All these methods will be called again if
subclass D of class C is initialized, this time to initialize the vari‐
ous parts of D's class structure.
The class_part_initialize() method is chained in superclass-to-subclass
order and cannot be inherited. Classes that do not define any new
class fields or that need no extra processing for them can set their
class_part_initialize field to be NULL.
See the "Background" section below for more details on when class ini‐
tialization is performed.
The subclass argument to a class_part_initialize() procedure may be the
widget class itself, or any subclass of it. You should cast it to a
pointer to your widget class and use that pointer to access the fields
of the class part structure that your class defines. If you need to
access the superclass, use the superclass field in the Object, RectObj,
or Core class part. This is shown in the example below.
The most common usage of the class_part_initialize() method is to han‐
dle inheritance of class methods and other fields. If you define a
class with a method or other field that can be inherited, you should
define a special value that the writer of the subclass can use to
inherit the field (use the constant _XtInherit cast to the appropriate
type, as shown in the example below) and provide a class_part_initial‐
ize() method which checks the inheritable field for this special value
and overwrites it with the contents of the superclass's field.
The following procedure is the class_part_initialize() method for the
Xaw Form widget class. Note how it determines the immediate superclass
and handles the inheritance of the Form layout() class method.
Note that it does not initialize the Core, Composite, or Constraint
class part fields, nor does it make any assumptions about its Widget‐
Class argument except that it is a subclass of Form. Also note that
when this method is called for the Form widget class itself, the vari‐
able super will be set to the superclass of Form, which cannot cor‐
rectly be cast to FormWidgetClass. This is a bug, but will never cause
problems, because the Form class itself will never have to inherit any
Note that the identifier class is a reserved word in C++, and your code
will be more portable if you avoid using it as an argument name in C
static void ClassPartInitialize(class)
register FormWidgetClass c = (FormWidgetClass)class;
register FormWidgetClass super = (FormWidgetClass)
if (c->form_class.layout == XtInheritLayout)
c->form_class.layout = super->form_class.layout;
The constant XtInheritLayout is defined as follows (in
#define XtInheritLayout ((Boolean (*)())_XtInherit)
All widget classes, whether or not they have class and class part ini‐
tialization procedures, must start with their class_inited field False.
The first time a widget of a class is created, XtCreateWidget() ensures
that the widget class and all superclasses are initialized, in super‐
class-to-subclass order, by checking each class_inited field. If this
field is False, XtCreateWidget() calls the class_initialize() and the
class_part_initialize() methods for the class and all its superclasses.
The Intrinsics then set the class_inited field to a nonzero value.
After the one-time initialization, a class structure is constant. This
initialization can also be performed explicitly, without creating a
widget, by calling XtInitializeWidgetClass().
Xt - Intrinsics Methods class_part_initialize()