Specifications
Athena Widget Set libXaw 1.0.7
The resource list for the ‘‘WindowWidget’’might look likethe following:
static XtResource resources[] = {
#define offset(field) XtOffsetOf(WindowWidgetRec, window.field)
/* {name, class, type, size, offset, default_type, default_addr}, */
{XtNdrawingColor1, XtCColor,XtRPixel, sizeof(Pixel),
offset(color_1), XtRString, XtDefaultForeground },
{XtNdrawingColor2, XtCColor,XtRPixel, sizeof(Pixel),
offset(color_2), XtRString, XtDefaultForeground },
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct*),
offset(font), XtRString, XtDefaultFont },
{XtNexposeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
offset(expose_callback), XtRCallback, NULL },
{XtNcallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
offset(input_callback), XtRCallback, NULL },
#undef offset
};
The user input callback will be implemented by an action procedure which passes the event
pointer as call_data. The action procedure is declared as:
/* ARGSUSED */
static void InputAction(w,event, params, num_params)
Widget w;
XEvent *event;
String *params; /* unused */
Cardinal *num_params; /* unused */
{
XtCallCallbacks(w,XtNcallback, (XtPointer)event);
}
static XtActionsRec actions[] =
{
/* {name, procedure}, */
{"input", InputAction},
};
and the default input binding will be to execute the input callbacks on KeyPress and Button-
Press:
static char translations[] =
"<Ke y>: input( )\n\
<BtnDown>: input()\
";
In the class record declaration and initialization, the only field that is different from the Template
is the expose procedure:
/* ARGSUSED */
static void Redisplay(w,event, region)
Widget w;
XEvent *event; /* unused */
Region region;
{
XtCallCallbacks(w,XtNexposeCallback, (XtPointer)region);
}
WindowClassRec windowClassRec = {
...
137