
Widget XtCreateWidget (String, WidgetClass, ArgList, Cardinal);
Widget XtVaCreateWidget (String, WidgetClass,...);
Additionally, a creation convenience function is provided by each object class. For example, you can create a Grid widget using the Xt creation function as follows:
Widget grid_widget;
grid_widget = XtVaCreateWidget ("grid", xintGridWidgetClass, parent,
XmNwidth, 500, XmNheight, 500, NULL);
or, using the creation function provided by the Grid widget class:
n = 0;
XtSetArg (arg[n], XmNwidth, 500); n++;
XtSetArg (arg[n], XmNheight, 500; n++;
grid_widget = XintCreateGrid (parent, "grid", arg, n);
The parent widget can be any valid Motif composite widget.
Changing widget attributes can be accomplished with the Xt functions:
void XtSetValues (Widget, ArgList, Cardinal);
void XtVaSetValues (Widget,...);
For example, the following code sample changes the vertical major grid line style of a Grid widget:
XtVaSetValues (grid_widget, XmNverticalMajorGridLineStyle,
XintGRID_LINE_DASHED, NULL);
Functions XtSetValues and XtVaSetValues, when applied to a pointer resource, return the pointer to the internal widget or object data. You should not modify this data directly. This is a common error that often occurs when trying to modify a resource. The following example, which applies a horizontal translation to a rectangle object, illustrates the problem.
Object rect_object;
XintRectangle *rectangle, new_rectangle;
...
XtVaGetValues((Widget) rect_object, XmNrectangle, &rectangle, NULL);
/* DON'T modify structure rectangle directly; copy data first...*/
new_rectangle = *rectangle;
/* apply translation */
new_rectangle.x1 += tx;
new_rectangle.x2 += tx;
XtVaSetValues((Widget) rect_object, XmNrectangle, &new_rectangle, NULL);
...
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/Separator.h>
#include <Xm/PushB.h>
#include <Xint/Axis.h>
#include <Xint/Grid.h>
/* declare subroutines */
static void BuildUI();
/* declare callbacks */
static void ExitProc();
/* declare global variables */
Widget toplevel_widget;
main(argc, argv)
int argc;
char *argv[];
{
XtAppContext app_context;
toplevel_widget = XtAppInitialize (&app_context, "Example", NULL, 0,
&argc, argv, NULL, NULL, 0);
BuildUI ();
XtRealizeWidget(toplevel_widget);
XtAppMainLoop(app_context);
}
/***
*** BuildUI
***/
static void BuildUI()
{
Widget form, grid, separator, exit_pb;
float hstart = 0;
float hend = 700;
float vstart = 0;
float vend = 280;
float major = 100;
float minor = 50;
float start, end;
Widget axis1, axis2;
XmString cstring;
/* create the form widget */
form = XtVaCreateManagedWidget("form", xmFormWidgetClass,
toplevel_widget, NULL);
/* create a Grid widget */
grid = XtVaCreateManagedWidget("grid", xintGridWidgetClass, form,
XmNtitleString, "Survey Boundaries",
XmNverticalAnnotationFormat, "%.0f",
XmNverticalLabel, "Y Cell Number",
XmNverticalLabelPlacement,
XintPLACEMENT_LEFT,
XmNverticalAnnotationPlacement,
XintPLACEMENT_LEFT,
XmNverticalMinorGridLineStyle,
XintGRID_LINE_DASHED,
XmNverticalMajorThickness, 1,
XmNverticalStart, &vstart,
XmNverticalEnd, &vend,
XmNverticalMajorIncrement, &major,
XmNverticalMinorIncrement, &minor,
XmNhorizontalMinorGridLineStyle,
XintGRID_LINE_DASHED,
XmNhorizontalMajorThickness, 1,
XmNhorizontalLabel, "X Cell Number",
XmNhorizontalLabelPlacement,
XintPLACEMENT_BOTTOM,
XmNhorizontalAnnotationPlacement,
XintPLACEMENT_BOTTOM,
XmNhorizontalStart, &hstart,
XmNhorizontalEnd, &hend,
XmNhorizontalMajorIncrement, &major,
XmNhorizontalMinorIncrement, &minor,
XmNhorizontalMajorGridLineStyle,
XintGRID_LINE_SOLID,
XmNautoMarginAdjust, XintADJUST_ALL,
XmNwidth, 650,
XmNheight, 600,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
/* create axes */
start = 0;
end = 32000;
major = 8000;
minor = 4000;
axis1 = XtVaCreateManagedWidget("axis1", xintAxisWidgetClass, grid,
XmNorientation, XintVERTICAL,
XmNannotationFormat, "%.0f",
XmNaxisLineThickness, 1,
XmNaxisOffset, 0,
XmNstart, &start,
XmNend, &end,
XmNmajorIncrement, &major,
XmNminorIncrement, &minor,
XmNlabel, "Y (feet)", NULL);
axis2 = XtVaCreateManagedWidget("axis2", xintAxisWidgetClass, grid,
XmNorientation, XintHORIZONTAL,
XmNannotationFormat, "%.0f",
XmNaxisLineThickness, 1,
XmNstart, &start,
XmNend, &end,
XmNmajorIncrement, &major,
XmNminorIncrement, &minor,
XmNaxisOffset, 0,
XmNlabel, "X (feet)", NULL);
/* create separator */
...
}
The output from this example is shown below:

/* create a Scroll widget */
int_scroll = XtVaCreateManagedWidget("int_scroll", xintScrollWidgetClass,
toplevel_widget,
XmNwidth, 500,
XmNheight, 500,
XmNscrollBarExtend, False, NULL);
/* create the segy widget */
traces_per_inch = 7.0;
segy_widget= XtVaCreateManagedWidget ("segy_widget",
xintSegyWidgetClass,
int_scroll,
XmNplotTitle,
"Segy Example with Scroll widget",
XmNplotType, XintPOSITIVE_COLOR_FILL +
XintNEGATIVE_COLOR_FILL +
XintWIGGLE,
XmNcolorScale, XintCOLOR_SCALE_LEFT,
XmNcolormapFile, "seg.cmp",
XmCColorScaleSize, 400,
XmNtracesPerInch, &traces_per_inch,
XmNsegyFilename, "segy1.dat",
XmNautoMarginAdjust, XintADJUST_ALL,
NULL);
The output produced by this example is shown below:

The hardcopy mechanism supports a powerful composition mechanism which enables the application to output multiple widgets into one plot file. For example, one can automatically output a composite of several INT widgets, based on the screen layout, in one function call. It is also possible to compose the hardcopy output manually by explicitly specifying the position of each widget for the plot.
All the functions related to hardcopy output are defined in the CompBase widget class. See the CompBase reference section in this chapter for a complete description of those functions.