G5G have developed a special widget to solve these problems. This widget provides a proper link between the widget and the graphics window. It manages the backing store and all expose events, and, according to the resources, this widget is capable of managing the movement of the graphics window, by means of the scrollbars.
Like all Motif widgets, the GPHIGS widget has certain resources. It is easy to attribute certain specific parameters to a workstation by means of these resources :
Widgets are created by the XtCreateManageWidget or XtCreateWidget functions, and the class xmGPhigsWidgetClass must be specified.
Example:
#include <Xm/Xm.h>
#include <phigure.h>
#include "GPhigsW.h"
void open_phigure_CB(w,client_data,call_data)
Widget w;
XtPointer client_data,call_data;
{
topen_ws (1,PDEF_ERR_FILE,8887);
predraw_all_structs(1,PFLAG_ALWAYS);
}
/*------------------------------------------*/
main(argc,argv)
int argc; char **argv;
{
Widget toplevel, phigure ;
int n, ac = 0;
Arg args[5] ;
toplevel = XtInitialize (" ", "config_file", NULL, 0, &ac, NULL);
topen_phigure(PDEF_ERR_FILE);
phigure = XmCreateGPhigsW(toplevel,"PHIGURE",args,0);
XtManageChild(phigure);
XtAddCallback(phigure,XmNcreateDACallback,open_phigure_CB,NULL);
XtRealizeWidget (toplevel);
XtMainLoop();
}
This short program is used to create a GPHIGS widget, making it possile to open a workstation with PHIGURE.
GPHIGS widgets have the following resources :
XmNwsid Workstation identifier .
XmNwidthWs Width of the graphics window.
XmNheightWs Height of the graphics window.
XmNlocdev N° of the Locator entry device (1 by default).
XmNpickdev N° of the Pick entry device (1 by default).
XmNnumButton N° of the mouse button to use (1 - 3, 1 by default).
XmNpressButton Pick or locator device activation by press or release
XmNdepthPick PHIGS pick search depth.
XmNresizeWs Window resize behavior.
XmNdeviceWs Workstation type (8887 by default, i.e. X11).
XmNphigureWs Use widget with PhigureTM.
XmNwidgetDA Obtain workstation identifier.
Specific callbacks associated with the widget:
XmNlocatorCallback
Callback reverting to the structure XmGPhigsLocatorStruct.
XmNpickCallback
Callback reverting to the structure XmGPhigsPickStruct.
XmNcreateDACallback
This callback, which is only called once , informs the user that the GPHIGS widget is mapped (is on the screen), and that it is now possible to plot the graphics. As the Xwindow client-server operating mode is asynchronous, it is not possible to know in advance when an event will happen, in particular when a window is mapped. As PHIGURE (or PHIGS) plotting can only be carried out when a window is on the screen, this callback solves the problem.
It makes it possible to launch an application with a graphic displayed in a window as soon as it is on the screen. Without this callback it would be necessary to wait until a window was mapped (on the screen) then press a button to start plotting the the graphic. It is simply necessary to include build CSS and a PHIGS redraw in this callback to solve the problem.
XmNexposeDACallback
This callback is used to redefine widget default behavior on expose- type events in the graphic zone.
XmNresizeDACallback
This callback is used to redefine widget default behavior on resize- type events in the graphic zone.