Name
class_initialize — Core method for dynamically initializing the class.
Synopsis
typedef void (∗XtProc);
Description
The class_initialize method is responsible for dynamically initializing the class. The most common code in this method is for the registering of type converters and the interning of atoms and quarks. You can also use it for run-time alterations to the class structure, or other actions that cannot be performed at compile time. The class_initialize method is called exactly once by the X Toolkit.
A widget class indicates that it has no class initialization procedure by specifying NULL in the class_initialize field.
A class may need to perform initialization for fields in its part of the class record. These are performed not just for the particular class but for subclasses as well. This is done in the class’s class_part_initialize method, not in class_initialize.
All widget classes, whether they have a class_initialize method or not, 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 superclass-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 non-zero value. After the one-time initialization, a class structure is constant.
The following provides the class initialization procedure for Label.
static void ClassInitialize()
{
XtQEleft = XrmStringToQuark("left");
XtQEcenter = XrmStringToQuark("center");
XtQEright = XrmStringToQuark("right");
XtAddConverter(XtRString, XtRJustify, CvtStringToJustify, NULL, 0);
}