1.0 Introduction
This section explains how to use the HOOPS/Motif Widget to build an application
for UNIX using the MOTIF toolkit for the GUI. This involves two main steps:
-
Creating and Anchoring the HOOPS/MOTIF Widget
-
Connecting the Widget Events to the HOOPS/MVO Objects
2.0
Creating and Anchoring the HOOPS/Motif Widget within the MOTIF framework
The following function is taken from the HOOPS
Motif Viewer (no longer supported). It shows how to create an instance of
the widget and anchor it within the MOTIF widget framework.
void UI_create_hoops_widget (Viewer_Data *vd) {
char dbl_buf_flg[32]; /* flag
for HOOPS driver
* option "double buffering"
*/
int double_buf_boolean;
/* variable setting for double
* buffer flag
* actually stored in the widget
*/
HC_Show_Environment ("HV_DB_FLAG", double_buf_flag);
if (streq (double_buf_flag, "TRUE"))
double_buf_boolean = true;
else
double_buf_boolean = false;
/* Create a HOOPS driver instance */
UC_Instance_Driver ("?picture");
/*
* Add an instance of the HOOPS widget to the
* Motif hierarchy
*/
vd->hoops_widget XtVaCreateWidget ("hoops_widget",
htWidgetClass, /*
our class*/
vd->work_area, /*
parent widget */
HTNhoopsDriver, "?picture",
HTNallowDefaultPicture, FALSE,
HTNuseColormap, FALSE,
HTNinterruptUpdateFilter, event_checker,
HTNdoubleBuffering, double_buf_boolean,
XmNbottomAttachment, XmATTACH_FORM,
XmNwidth, 500,
XmNheight, 400,
XmNleftAttachment, XmATTACH_FORM,
XmNuserData, vd,
NULL);
XtAddCallback(vd->hoops_widget, HTNexposeCallback,
(XtCallbackProc) CB_Update, vd);
XtAddCallback(vd->hoops_widget, HTNresizeCallback, (XtCallbackProc)CB_Update,
vd);
XtAddCallback(vd->hoops_widget, HTNginitCallback, (XtCallbackProc)CB_Init_HOOPS,
vd);
XtAddCallback(vd->hoops_widget,HTNbtnMotionCallback,
(XtCallbackProc)eh_rotate, vd);
XtAddCallback (vd->hoops_widget, HTNbtnDownCallback,
(XtCallbackProc) eh_rotate, vd);
XtAddCallback (vd->hoops_widget, HTNbtnUpCallback,(XtCallbackProc)eh_rotate,
vd);
#if 0
/* These are other callbacks that can
be used - maybe for changing a cursor, etc.
*/
XtAddCallback (vd->hoops_widget,
HTNenterCallback,
(XtCallbackProc)tester, "enter");
XtAddCallback (vd->hoops_widget, HTNleaveCallback,
(XtCallbackProc) tester, "leave");
#endif
XtManageChild(vd->hoops_widget);
/*
* Initialize local static variables used by interrupt
update routines.
*/
hoops_window = XtWindow (vd->hoops_widget);
display = XtDisplay (vd->hoops_widget);
return;
}
3.0
Connecting HOOPS/MOTIF Widget to HOOPS/MVO Objects
The mouse and keyboard events the HOOPS/MOTIF widget receives must be encapsulated
in a HEventInfo object and passed to the widget's associated View object.
On creation of the HOOPS/MOTIF widget, the pointer to the associated View object
should be stored in the XmNuserData field either directly or in the datastructure
whose pointer is stored there. Then one XtCallbackProc should be registered
for all mouse and button events that create a HEventInfo object (which should
be packed with the information in the XEvent datastructure passed to the
callback) which in turn should call the appropriate event handling method to
pass it the HEventInfo object.