Specifications
Athena Widget Set libXaw 1.0.7
#define XtCTemplateResource "TemplateResource"
/* declare specific TemplateWidget class and instance datatypes */
typedef struct _TemplateClassRec* TemplateWidgetClass;
typedef struct _TemplateRec* TemplateWidget;
/* declare the class constant */
extern WidgetClass templateWidgetClass;
#endif /* _Template_h */
Youwill notice that most of this file is documentation. The crucial parts are the last 8 lines where
macros for anyprivate resource names and classes are defined and where the widget class
datatypes and class record pointer are declared.
Forthe ‘‘WindowWidget’’, we want 2 drawing colors, a callback list for user input and an
exposeCallback callback list, and we will declare three convenience procedures, so we need to
add
/* Resources:
...
callback Callback Callback NULL
drawingColor1 Color Pixel XtDefaultForeground
drawingColor2 Color Pixel XtDefaultForeground
exposeCallback Callback Callback NULL
font Font XFontStruct* XtDefaultFont
...
*/
#define XtNdrawingColor1 "drawingColor1"
#define XtNdrawingColor2 "drawingColor2"
#define XtNexposeCallback "exposeCallback"
extern Pixel WindowColor1( /* Widget */ );
extern Pixel WindowColor2( /* Widget */ );
extern Font WindowFont( /* Widget */ );
Note that we have chosen to call the input callback list by the generic name, callback,rather than
aspecific name. If widgets that define a single user-input action all choose the same resource
name then there is greater possibility for an application to switch between widgets of different
types.
7.2. Private Header File
The private header file contains the complete declaration of the class and instance structures for
the widget and anyadditional private data that will be required by anticipated subclasses of the
widget. Information in the private header file is normally hidden from the application and is
designed to be accessed only through other public procedures; e.g. XtSetValues.
The contents of the Template private header file, <X11/Xaw/TemplateP.h>, are:
/* XConsortium: TemplateP.h,v 1.2 88/10/25 17:31:47 swick Exp $ */
/* Copyright (c) X Consortium 1987, 1988
*/
#ifndef _TemplateP_h
#define _TemplateP_h
134