12.07.2015 Views

Athena Widget Set - C Language Interface - X Consortium ... - X.Org

Athena Widget Set - C Language Interface - X Consortium ... - X.Org

Athena Widget Set - C Language Interface - X Consortium ... - X.Org

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

},{ /* template fields *//* empty */ 0}};Creating New <strong>Widget</strong>s(Subclassing)<strong>Widget</strong>Class template<strong>Widget</strong>Class = (<strong>Widget</strong>Class)&templateClassRec;The resource list for the "Window<strong>Widget</strong>" might look like the following:static XtResource resources[] = {#define offset(field) XtOffsetOf(Window<strong>Widget</strong>Rec, 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 passesthe event pointer as call_data. The action procedure is declared as:/* ARGSUSED */static void InputAction(w, event, params, num_params)<strong>Widget</strong> 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 KeyPressand ButtonPress :static char translations[] =" : input(\|) \\n\\: input(\|) \\";133

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!