| /*
* This is an example widget using the upward compatibility code of the
* DECtoolkit. The widget is a simple "pushbutton". It is a sub-class
* of the Label widget
*/
#include <decw$include/DECwDwtWidgetProg.h>
static void Notify(), Destroy(), ClassInitialize();
/*
* Index used by the DwtField macro
*/
#define DwtSimplePushIndex (DwtLabelIndex + 1)
/*
* Class part record
*/
typedef struct _SimplePushClass {
DwtOffsetPtr simplepushoffsets;
int reserved;
} SimplePushClassPart;
/*
* Class record
*/
typedef struct _SimplePushClassRec {
CoreClassPart core_class;
CompositeClassPart composite_class;
DwtCommonClassPart dwtcommon_class;
LabelClassPart label_class;
SimplePushClassPart simplepush_class;
} SimplePushClassRec, *SimplePushWidgetClass;
/*
* Instance Part Record
*/
typedef struct {
XtCallbackList callback_list;
int anything;
} SimplePushPart;
/*
* Instance record
*/
typedef struct _SimplePushRec {
CorePart core;
CompositePart composite;
DwtCommonPart dwtcommon;
LabelPart label;
SimplePushPart simplepush;
} SimplePushRec, *SimplePushWidget;
/*
* Resources for the SimplePush widget. NOTE the use of the
* DwtPartResources and DwtPartOffset macros
*/
static DwtPartResource resources[] = {
{"callback", XtCCallback, XtRCallback, sizeof(caddr_t),
DwtPartOffset(SimplePush, callback_list), XtRCallback, (caddr_t) NULL},
{"anything", "Int", XtRInt, sizeof(int),
DwtPartOffset(SimplePush, anything), XtRInt, (caddr_t) NULL},
};
/*
* Translation table for SimplePush; activates on button 1 up
*/
static char defaultTranslations[] = "<Btn1Up>: notify()";
/*
* Action table
*/
static XtActionsRec actionsList[] = { {"notify", Notify} };
/*
* Initialization of Class Record
* NOTE that the size is set to the size of the SimplePush's part
*/
SimplePushClassRec simplepushClassRec = {
{ /* Core Class Part */
/* superclass */ (WidgetClass) &labelwidgetclassrec,
/* class_name */ "SimplePush",
/* widget_size */ sizeof(SimplePushPart),
/* class_initialize */ ClassInitialize,
/* class_part_initialize*/ NULL,
/* class_inited */ FALSE,
/* initialize */ NULL,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ actionsList,
/* num_actions */ XtNumber(actionsList),
/* resources */ (XtResource *) resources,
/* num_resources */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ TRUE,
/* compress_enterleave*/ TRUE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ XtInheritResize,
/* expose */ XtInheritExpose,
/* set_values */ NULL,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersionDontCheck,
/* callback offsets */ NULL,
/* tm_table */ defaultTranslations,
/* query geometry */ NULL,
/* disp accelerators */ NULL,
/* extension */ NULL,
},
{ /* composite class record */
/* childrens geo mgr proc */XtInheritGeometryManager,
/* set changed proc */ XtInheritChangeManaged,
/* add a child */ XtInheritInsertChild,
/* remove a child */ XtInheritDeleteChild,
/* extension */ NULL,
},
{ /* dwt common class record */
/* reserved */ _XtInherit,
/* reserved */ _XtInherit,
/* reserved */ _XtInherit,
/* extension */ NULL,
},
{ /* label class record */
/* */ NULL,
},
{ /* simplepush class record */
/* */ NULL,
/* */ NULL,
}
};
WidgetClass simplepushWidgetClass = (WidgetClass) &simplepushClassRec;
/*
* Class Initialize Routine. NOTE the call to DwtResolvePartOffsets
*/
static void ClassInitialize()
{
DwtResolvePartOffsets(simplepushWidgetClass,
&simplepushClassRec.simplepush_class.simplepushoffsets);
}
/*
* Action routine for the widget
*/
static void Notify(w, event)
SimplePushWidget w;
XEvent *event;
{
int data;
DwtOffsetPtr o;
/*
* Pass back the label
*/
o = ((SimplePushWidgetClass)w->core.widget_class)->simplepush_class.simplepushoffsets;
data = DwtField(w, o, Label, label, char *);
XtCallCallbacks(w, XtNcallback, data);
}
/*
* Class Destroy Routine
*/
static void Destroy(w)
Widget w;
{
XtRemoveAllCallbacks(w, XtNcallback);
}
|