Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ class_initi(3x) — HP-UX 9.10

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XtInitializeWidgetClass(1)

Core(3)

class_part_initialize(4)

initialize(4)

 

NAME

class_initialize − Object class method for one-time class initialization. 

Synopsis

typedef void (*XtProc)(void);

Description

The class_initialize() method is registered on the class_initialize() field of the Object, RectObj, or Core class structures, and is called exactly once by the Intrinsics before any instances of the class are created.  The class_initialize() method takes no arguments and returns no value.  It performs initialization that should be done once for this class and all its subclasses, such as registering type converters and interning atoms and quarks.  Compare this with the class_part_initialize() method which is called once for its class and also for every subclass, and is responsible for initializing fields in the class part structure.  The class_initialize() method is chained in superclass-to-subclass order, and cannot be inherited.  If a class does not need to do any one-time initialization, it should specify NULL in its class_initialize() field.  See the "Background" section below for more information on when this method is called. 

Usage

The class_initialize() method performs initialization for the class.  It is the initialize() method that performs initialization for the instance structure of a widget. 

Example

The following procedure is the class_initialize() method of the Xaw Form widget.  Note that it registers two resource converters, and interns quarks (in global variables) for use by the String-to-EdgeType converter. 

static void ClassInitialize()
{
    static XtConvertArgRec parentCvtArgs[] = {
        {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent),
             sizeof(Widget)}
    };
    XawInitializeWidgetSet();
    XtQChainLeft   = XrmPermStringToQuark("chainleft");
    XtQChainRight  = XrmPermStringToQuark("chainright");
    XtQChainTop    = XrmPermStringToQuark("chaintop");
    XtQChainBottom = XrmPermStringToQuark("chainbottom");
    XtQRubber      = XrmPermStringToQuark("rubber");
     XtAddConverter( XtRString, XtREdgeType, _CvtStringToEdgeType, NULL, 0 );
    XtSetTypeConverter (XtRString, XtRWidget, XmuNewCvtStringToWidget,
                        parentCvtArgs, XtNumber(parentCvtArgs), XtCacheNone,
                        NULL);
}

Background

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 nonzero value.  After the one-time initialization, a class structure is constant.  This initialization process can also be performed explicitly, without creating a widget, by calling XtInitializeWidgetClass(). 

See Also

XtInitializeWidgetClass(1),
Core(3),
class_part_initialize(4), initialize(4). 

Copyright O’Reilly & Assoc.  —  X Toolkit Intrinsics Reference Manual © O’Reilly & Associates

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026