#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xint/EditObject.h>
#include <Xint/ObjectEditor.h>
#include <Xint/Text.h>
#include <Xint/RoundedRect.h>
#include <Xint/Rectangle.h>
#include <Xint/Oval.h>
#include <Xint/Line.h>
#include <Xint/Polyline.h>
#include <Xint/Polygon.h>
#include <Xint/FreeHand.h>
#include <Xint/Chart.h>
/* Define list of pixmaps used when creating the ObjectEditor widget */
static char *pixmap_names[] = {
"50_percent_1", "50_percent_2", "Vertical1", "Horizontal1",
"Slant_Left1", "Slant_Right1", "Weave2", "Weave4",
"Diaper", "Diamond2", "Trellis1", "Cross_Hatch",
"Tread2", "Herring_Bone2","Zigzag2", "Check2",
NULL };
main(argc, argv)
int argc;
char *argv[];
{
XtAppContext app_context;
Widget top_level;
Widget form, frame, edit, object_editor;
ObjectClass object_class_list[12];
Pixmap pixmap_list[20];
int n;
top_level = XtAppInitialize(&app_context, "object_editor",
(XrmOptionDescList)NULL, 0,
&argc, argv, NULL, NULL, 0);
XtVaSetValues(top_level, XmNallowShellResize, True, NULL);
/* Create a Form containter */
form = XtVaCreateManagedWidget("form", xmFormWidgetClass,
top_level, NULL);
/* list the Object classes that we want to create interactively */
n = 0;
object_class_list[n] = xintRectangleObjectClass; n++;
object_class_list[n] = xintRoundedRectObjectClass; n++;
object_class_list[n] = xintOvalObjectClass; n++;
object_class_list[n] = xintLineObjectClass; n++;
object_class_list[n] = xintPolylineObjectClass; n++;
object_class_list[n] = xintPolygonObjectClass; n++;
object_class_list[n] = xintTextObjectClass; n++;
object_class_list[n] = xintFreeHandObjectClass; n++;
object_class_list[n] = xintChartObjectClass; n++;
object_class_list[n] = NULL; n++;
/* Build a list of bitmap patterns */
n = 0;
while (pixmap_names[n]) {
pixmap_list[n] =
XintObjectEditorGetDefinedPixmap(form, pixmap_names[n]);
n++;
}
pixmap_list[n] = XmUNSPECIFIED_PIXMAP;
/* Create an ObjectEditor widget */
object_editor = XtVaCreateManagedWidget("object_editor",
xintObjectEditorWidgetClass,
form,
XmNorientation, XintVERTICAL,
XmNnumColumns, 1,
XmNobjectOrientation, XmHORIZONTAL,
XmNobjectNumColumns, 3,
XmNpixmapNumColumns, 4,
XmNpixmapList, pixmap_list,
XmNshowAttributeLabels, False,
XmNobjectClassList, object_class_list,
/* Form constraint resources */
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
/* Create an Frame widget */
frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass,
form,
XmNshadowType, XmSHADOW_IN,
/* Form constraint resources */
XmNrightAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, object_editor,
NULL);
/* Create an EditObject widget */
edit = XtVaCreateManagedWidget("edit_object",
xintEditObjectWidgetClass, frame,
XmNwidth, 600,
XmNheight, 600,
XmNobjectEditMode, XintEDIT_ADJUST,
NULL);
/* Connect the object editor to the edit object widget */
XintObjectEditorAddEditObjectToList(object_editor, edit);
/* Loop */
XtRealizeWidget(top_level);
XtAppMainLoop(app_context);
}
The output from this example is shown below:

Figure 18: ObjectEditor example output.
| Functionality | Function or Resource |
|---|---|
| Inserting an object interactively | XintEditObjectInsert. |
| Cut/Copy/paste | XintEditObjectCut, XintEditObjectCopy and XintEditObjectPaste. |
| Group/Ungroup | XintEditObjectGroup and XintEditObjectUngroup |
| Back/Front | XintEditObjectBack and XintEditObjectFront. |
| Lower/Raise | XintEditObjectLower and XintEditObjectRaise. |
| Set colors | See resources XmNcolor, XmNfillColor and XmNstippleColor. |
| Set line style | See resource XmNlineThickness and XmNlineStyle. |
| Set dash style | See resource XmNdashList. |
| Set fill style | See resource XmNfillStyle. |
| Set pixmap pattern | See resource XmNfillPixmap. |