~ubuntu-branches/ubuntu/quantal/openmotif/quantal

« back to all changes in this revision

Viewing changes to demos/programs/ButtonBox/bboxdemo.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bauer
  • Date: 2010-06-23 12:12:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100623121231-u89gxdp51sg9wjj2
Tags: 2.3.0-1
* New Maintainer (Closes: #379258) 
* Acknowledge NMU changes
* New upstream release (Closes: #494375)
* Get rid of security patches as they are already part of new upstream
  release (00-xpmvuln.openmotif.patch, 342092-CVE-2005-3964.patch)
* Bump Standards to 3.8.4
* Added {misc:Depends} to make the package lintian cleaner
* Fix weak-library-dev-dependency by adding ${binary:Version}) for the
  -dev Package of openmotif
* Let package depend on autotools-dev to use newer autotools-helper-files
* Work around an autoconf-bug (Gentoo-Bug #1475)
* Added Client-side anti-aliased fonts support via XFT
* Added UTF-8 and UTF8_STRING atom support
* Ability to show text and pixmaps in Label, LabelGadget and all
  derived widgets
* Support of PNG/JPEG image formats in the same way as XPM is supported
* Increase FILE_OFFSET_BITS to 64 to show files >2GB in file-selector
  Idea taken from Magne Oestlyngen (Closes: #288537)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <string.h>
 
4
#include <ctype.h>
 
5
 
 
6
#include <Xm/Xm.h>
 
7
#include <Xm/MessageB.h>
 
8
#include <Xm/PushB.h>
 
9
#include <Xm/ToggleB.h>
 
10
#include <Xm/Label.h>
 
11
#include <Xm/Frame.h>
 
12
#include <Xm/Form.h>
 
13
#include <Xm/TextF.h>
 
14
#include <Xm/RowColumn.h>
 
15
#include <Xm/MenuShell.h>
 
16
#include <Xm/ButtonBox.h>
 
17
 
 
18
Widget bbox;
 
19
 
 
20
void Exit(Widget w, XtPointer client, XtPointer call);
 
21
void Equal(Widget w, XtPointer client, XtPointer call);
 
22
void Fill(Widget w, XtPointer client, XtPointer call);
 
23
void Width(Widget w, XtPointer client, XtPointer call);
 
24
void OnlyNum(Widget w, XtPointer client, XtPointer call);
 
25
void Orient(Widget w, XtPointer client, XtPointer call);
 
26
void Explain(Widget w, XtPointer client, XtPointer call);
 
27
 
 
28
/*
 
29
 *
 
30
 * These are fallbacks that are designed to ensure the
 
31
 * program works properly in case the resource file is
 
32
 * not picked up.
 
33
 *
 
34
 */
 
35
 
 
36
static String fallbacks[] = {
 
37
    /*
 
38
     * General fallback resources.
 
39
     */ 
 
40
 
 
41
    "*background: grey", 
 
42
    "*bbox*background: white",
 
43
    "*bform.height: 575",
 
44
    "*bbox.width: 450",
 
45
    "*bbox.height: 65",
 
46
    "*fontList: -*-helvetica-medium-r-*-*-*-140-*-*-*-*-*-*",
 
47
    "*infolabel*fontList: -*-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*",
 
48
    "*infolabel.marginWidth: 10",
 
49
    "*infolabel.marginHeight: 10",
 
50
    "*boxSizeLabel.labelString: XmNequalSize",
 
51
    "*fillOptionLabel.labelString: XmNfillOption",
 
52
    "*widLabel.labelString: XmNmarginWidth",
 
53
    "*htLabel.labelString: XmNmarginHeight",
 
54
    "*orientLabel.labelString: XmNorientation",
 
55
    "*toggle1.labelString: True",
 
56
    "*toggle2.labelString: False",
 
57
    "*toggle3.labelString: XmHORIZONTAL",
 
58
    "*toggle4.labelString: XmVERTICAL",
 
59
    "*resform*XmPushButton.labelString: Explain...",
 
60
    "*resform*pulldownMenu.nonePB.labelString: XmFillNone",
 
61
    "*resform*pulldownMenu.minorPB.labelString: XmFillMinor",
 
62
    "*resform*pulldownMenu.majorPB.labelString: XmFillMajor",
 
63
    "*resform*pulldownMenu.allPB.labelString: XmFillAll",
 
64
    "*quitPB.labelString: Quit",
 
65
    NULL,
 
66
};
 
67
 
 
68
void Exit(Widget w, XtPointer client, XtPointer call)
 
69
{
 
70
    exit(0);
 
71
}
 
72
 
 
73
/*
 
74
 *
 
75
 * This function forces the buttons to be of equal size.
 
76
 *
 
77
 */
 
78
 
 
79
void Equal(Widget w, XtPointer client, XtPointer call)
 
80
{
 
81
    Arg args[5];
 
82
    Cardinal argcnt;
 
83
    Boolean equal;
 
84
 
 
85
    if ((int)client == 1) 
 
86
        equal = True;
 
87
    else
 
88
        equal = False;
 
89
 
 
90
    argcnt = 0;
 
91
    XtSetArg(args[argcnt], XmNequalSize, equal); argcnt++;
 
92
    XtSetValues(bbox, args, argcnt);
 
93
 
 
94
}
 
95
 
 
96
/*
 
97
 *
 
98
 * This function forces the margins along the sides (width)
 
99
 * or along the top and bottom (height) to be of a particular
 
100
 * size.
 
101
 *
 
102
 */
 
103
 
 
104
void Width(Widget w, XtPointer client, XtPointer call)
 
105
{
 
106
    Arg args[5];
 
107
    Cardinal argcnt;
 
108
    char *val;
 
109
    int margin = 0;
 
110
 
 
111
    val = XmTextFieldGetString(w);
 
112
    margin = atoi(val);
 
113
 
 
114
    argcnt = 0;
 
115
    if ((int)client == 1)
 
116
    {
 
117
        XtSetArg(args[argcnt], XmNmarginHeight, (short) margin); argcnt++;
 
118
    }
 
119
    else
 
120
    {
 
121
        XtSetArg(args[argcnt], XmNmarginWidth, (short) margin); argcnt++;
 
122
    }
 
123
    XtSetValues(bbox, args, argcnt);
 
124
 
 
125
    XtFree(val);
 
126
}
 
127
 
 
128
/*
 
129
 *
 
130
 * Depending on the resource, the buttons either fill the box
 
131
 * along the minor axis (minor), the major axis (major), neither (none)
 
132
 * or completely fill the box (all).
 
133
 *
 
134
 */
 
135
 
 
136
void Fill(Widget w, XtPointer client, XtPointer call)
 
137
{
 
138
    Arg args[5];
 
139
    Cardinal argcnt;
 
140
    int val = (int)client;
 
141
 
 
142
    argcnt = 0;
 
143
    switch (val) {
 
144
    case 1:
 
145
           XtSetArg(args[argcnt], XmNfillOption, XmFillNone); argcnt++;
 
146
           XtSetValues(bbox, args, argcnt);
 
147
           break;
 
148
    case 2:
 
149
           XtSetArg(args[argcnt], XmNfillOption, XmFillMinor); argcnt++;
 
150
           XtSetValues(bbox, args, argcnt);
 
151
           break;
 
152
    case 3:
 
153
           XtSetArg(args[argcnt], XmNfillOption, XmFillMajor); argcnt++;
 
154
           XtSetValues(bbox, args, argcnt);
 
155
           break;
 
156
    case 4:
 
157
           XtSetArg(args[argcnt], XmNfillOption, XmFillAll); argcnt++;
 
158
           XtSetValues(bbox, args, argcnt);
 
159
           break;
 
160
    }
 
161
}
 
162
 
 
163
/*
 
164
 * Validation of input.
 
165
 *
 
166
 * A common routine to ensure that the only values entered
 
167
 * in the text box are all numeric.
 
168
 *
 
169
 */
 
170
 
 
171
void OnlyNum(Widget w, XtPointer client, XtPointer call)
 
172
{
 
173
    XmTextVerifyCallbackStruct *verify_struct =
 
174
        (XmTextVerifyCallbackStruct *) call;
 
175
 
 
176
    if (verify_struct->text->ptr)
 
177
        if (!isdigit(*verify_struct->text->ptr))
 
178
            verify_struct->doit = False;
 
179
}
 
180
 
 
181
/*
 
182
 *
 
183
 * Specifies the orientation of the buttons in the box.
 
184
 *
 
185
 */
 
186
 
 
187
void Orient(Widget w, XtPointer client, XtPointer call)
 
188
{
 
189
    Arg args[5];
 
190
    Cardinal argcnt;
 
191
    unsigned char orient;
 
192
 
 
193
    if ((int)client == 1)
 
194
        orient = XmVERTICAL;
 
195
    else
 
196
        orient = XmHORIZONTAL;
 
197
 
 
198
    argcnt = 0;
 
199
    XtSetArg(args[argcnt], XmNorientation, orient); argcnt++;
 
200
    XtSetValues(bbox, args, argcnt);
 
201
 
 
202
 
 
203
}
 
204
 
 
205
/*
 
206
 *
 
207
 * Stuff needed for the demo program to output info
 
208
 *
 
209
 */
 
210
 
 
211
void Explain(Widget w, XtPointer client, XtPointer call)
 
212
{
 
213
    Arg args[5];
 
214
    Cardinal argcnt;
 
215
    XmString xmstring = NULL;
 
216
    static Widget info = NULL;
 
217
    int explain = (int) client;
 
218
 
 
219
    if (info == NULL) {
 
220
        Widget temp;
 
221
 
 
222
        argcnt = 0;
 
223
        XtSetArg(args[argcnt], XmNtitle, "Explanation"); argcnt++;
 
224
        info = XmCreateInformationDialog(w, "explain", args, argcnt);
 
225
 
 
226
        temp = XmMessageBoxGetChild(info, XmDIALOG_CANCEL_BUTTON);
 
227
        XtUnmanageChild(temp);
 
228
        temp = XmMessageBoxGetChild(info, XmDIALOG_HELP_BUTTON);
 
229
        XtUnmanageChild(temp);
 
230
    }
 
231
 
 
232
    switch (explain) {
 
233
    case 1:
 
234
        xmstring = XmStringCreateLtoR(
 
235
"The equalSize resource specifies whether children of the Button\n\
 
236
Box have equal heights and widths. The height and width chosen for\n\
 
237
all the children is the height and width of the largest child.",
 
238
                                      XmSTRING_DEFAULT_CHARSET);
 
239
        break;
 
240
    case 2:
 
241
        xmstring = XmStringCreateLtoR(
 
242
"The fillOption resource sets four kinds of fill options: FillNone,\n\
 
243
FillMajor, FillMinor, and FillAll. Fill specifies how to use any extra\n\
 
244
space left over once all children have been sized. This resource usually\n\
 
245
expands children in a reasonable manner.\n\
 
246
\n\
 
247
FillMajor expands children in the direction of the orientation resource.\n\
 
248
FillMinor expands children in the opposite direction of the orientation \
 
249
resource.\n\
 
250
FillAll expands children in both major and minor directions.\n\
 
251
FillNone doesn't expand children.",
 
252
                                      XmSTRING_DEFAULT_CHARSET);
 
253
        break;
 
254
    case 3:
 
255
        xmstring = XmStringCreateLtoR(
 
256
"marginWidth is the number of spacing pixels to the left and to the right\n\
 
257
of the children in the Button Box.",
 
258
                                      XmSTRING_DEFAULT_CHARSET);
 
259
        break;
 
260
    case 4:
 
261
        xmstring = XmStringCreateLtoR(
 
262
"marginHeight is the number of spacing pixels on top and on bottom of the \n\
 
263
children in the Button Box.",
 
264
                                      XmSTRING_DEFAULT_CHARSET);
 
265
        break;
 
266
    case 5:
 
267
        xmstring = XmStringCreateLtoR(
 
268
"orientation specifies whether the children of the Button Box are placed\n\
 
269
in a row or a column. HORIZONTAL places children in a row (major dimension\n\
 
270
is width, minor dimension is height). VERTICAL places children in a column\n\
 
271
(major dimension is height, minor dimension is width).",
 
272
                                      XmSTRING_DEFAULT_CHARSET);
 
273
        break;
 
274
    default:
 
275
        printf("explaining NOTHING\n");
 
276
        break;
 
277
    }
 
278
 
 
279
    argcnt = 0;
 
280
    XtSetArg(args[argcnt], XmNmessageString, xmstring); argcnt++;
 
281
    XtSetValues(info, args, argcnt);
 
282
 
 
283
    XmStringFree(xmstring);
 
284
 
 
285
    XtManageChild(info);
 
286
}
 
287
int
 
288
main(int argc, char **argv)
 
289
{
 
290
    Arg args[5];
 
291
    Cardinal argcnt;
 
292
    Widget top, bboxframe, infoframe, infolabel, resframe, resform, 
 
293
           bboxSizeRC, boxSizeLabel, togl_btn1, togl_btn2, pushButton, radioRC, 
 
294
           fillOptionRC, fillOptionLabel, fillOptionMenu, nonePB, minorPB, 
 
295
           majorPB, allPB, menuShell, pulldownMenu, pushButton1,widRC, 
 
296
           widLabel, widText, htRC, htLabel, htText, pushButton2, orientRC, 
 
297
           orientLabel, pushButton3, pushButton4, quitPB, bbox_PB1, bbox_PB2, 
 
298
           bbox_PB3, bbox_PB4, togl_btn3, togl_btn4, orientRadio, bform;
 
299
 
 
300
    XtAppContext app;
 
301
 
 
302
    XmString xmstring;
 
303
    
 
304
    XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); 
 
305
 
 
306
    argcnt = 0;
 
307
    XtSetArg(args[argcnt], XmNtitle, "Button Box Demo"); argcnt++;
 
308
    XtSetArg(args[argcnt], XmNallowShellResize, True); argcnt++;
 
309
    top = XtOpenApplication(
 
310
            &app, 
 
311
            "Buttonbox", 
 
312
            NULL, 
 
313
            0, 
 
314
            &argc, 
 
315
            argv, 
 
316
            fallbacks, 
 
317
            sessionShellWidgetClass,
 
318
            args, 
 
319
            argcnt);
 
320
 
 
321
    bform = XtVaCreateManagedWidget("bform", xmFormWidgetClass, top, 
 
322
                          XmNresizePolicy, XmRESIZE_GROW, NULL);
 
323
 
 
324
    bboxframe = XtVaCreateManagedWidget("bboxframe", xmFrameWidgetClass,bform,
 
325
                               XmNtopAttachment, XmATTACH_FORM,
 
326
                               XmNbottomAttachment, XmATTACH_FORM,
 
327
                               XmNtopOffset, 10,
 
328
                               XmNbottomOffset, 10,
 
329
                               XmNx, 10, XmNy, 10,
 
330
                               NULL);
 
331
 
 
332
        {
 
333
        Widget dbbox = XmCreateFormDialog(top,"frame",NULL,0);
 
334
 
 
335
/*
 
336
 *
 
337
 *  Take Note:
 
338
 * 
 
339
 *  Creation of the widget being demoed.
 
340
 *
 
341
 */
 
342
 
 
343
    bbox = XtVaCreateManagedWidget("bbox",
 
344
                               xmButtonBoxWidgetClass, dbbox,
 
345
                               XmNx, 2, XmNy, 2,
 
346
                               NULL);
 
347
 
 
348
        XtVaSetValues(bbox,
 
349
                XmNleftAttachment, XmATTACH_FORM,
 
350
                XmNrightAttachment, XmATTACH_FORM,
 
351
                XmNtopAttachment, XmATTACH_FORM,
 
352
                XmNbottomAttachment, XmATTACH_FORM,
 
353
                NULL);
 
354
        XtManageChild(dbbox);
 
355
        }
 
356
 
 
357
/*
 
358
 *
 
359
 * The following widgets created are buttons to fill the box.
 
360
 * This is to assist in the demonstration of the buttonBox's
 
361
 * utility.
 
362
 *
 
363
 */
 
364
 
 
365
    bbox_PB1 = XmVaCreateManagedPushButton(bbox, "FirstButton",
 
366
                NULL);
 
367
 
 
368
    bbox_PB2 = XmVaCreateManagedPushButton(bbox, "SecondButton",
 
369
                NULL);
 
370
 
 
371
    bbox_PB3 = XmVaCreateManagedPushButton(bbox, "ThirdButton",
 
372
                NULL);
 
373
 
 
374
    bbox_PB4 = XtCreateManagedWidget("LastButton",
 
375
                xmPushButtonWidgetClass,
 
376
                bbox,
 
377
                NULL,
 
378
                0);
 
379
 
 
380
    xmstring = XmStringCreateLtoR(
 
381
"The OpenMotif Button Box widget can arrange buttons into single rows and columns\n\
 
382
much more easily than the Motif Row Column or Motif Form!\n\
 
383
(And two ButtonBoxes paired together do a great job of lining items up.)\n\
 
384
\n\
 
385
The four buttons in the other window are inside an OpenMotif Button Box. Try \
 
386
resizing\n\
 
387
this window! Try modifying the Button Box's resources using the area below.\n\
 
388
\n\
 
389
Press the \"Explain...\" button to find out more about a particular resource.",
 
390
                                  XmSTRING_DEFAULT_CHARSET);
 
391
 
 
392
    infoframe = XtVaCreateManagedWidget("infoframe", xmFrameWidgetClass, bform,
 
393
                               XmNbottomAttachment, XmATTACH_NONE,
 
394
                               XmNrightAttachment, XmATTACH_POSITION,
 
395
                               XmNrightPosition, 95,
 
396
                               XmNtopOffset, 0,
 
397
                               XmNbottomOffset, 0,
 
398
                               XmNleftOffset, 10,
 
399
                               XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
 
400
                               XmNtopWidget, bboxframe,
 
401
                               XmNleftAttachment, XmATTACH_WIDGET,
 
402
                               XmNleftWidget, bboxframe,
 
403
                               NULL);
 
404
 
 
405
    resframe = XtVaCreateManagedWidget("resframe", xmFrameWidgetClass, bform,
 
406
                               XmNbottomAttachment, XmATTACH_NONE,
 
407
                               XmNrightAttachment, XmATTACH_POSITION,
 
408
                               XmNrightPosition, 95,
 
409
                               XmNtopOffset, 9,
 
410
                               XmNbottomOffset, 0,
 
411
                               XmNleftOffset, 0,
 
412
                               XmNtopAttachment, XmATTACH_WIDGET,
 
413
                               XmNtopWidget, infoframe,
 
414
                               XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
 
415
                               XmNleftWidget, infoframe,
 
416
                               NULL);
 
417
 
 
418
    quitPB = XmVaCreatePushButton(bform, "quitPB",
 
419
                               XmNtopAttachment,     XmATTACH_NONE,
 
420
                               XmNleftAttachment,   XmATTACH_WIDGET,
 
421
                               XmNleftWidget,       bboxframe,
 
422
                               XmNbottomAttachment, XmATTACH_FORM,
 
423
                               XmNtopOffset,         0,
 
424
                               XmNbottomOffset,     10,
 
425
                               XmNleftOffset,      300,
 
426
                               XmNwidth, 100,
 
427
                               NULL);
 
428
    XtManageChild(quitPB);
 
429
 
 
430
    infolabel = XtVaCreateManagedWidget("infolabel", xmLabelWidgetClass,
 
431
                               infoframe,
 
432
                               XmNx, 2, XmNy, 2,
 
433
                               XmNalignment, XmALIGNMENT_BEGINNING,
 
434
                               XmNlabelString, xmstring,
 
435
                               NULL);
 
436
 
 
437
 
 
438
    resform = XtVaCreateManagedWidget("resform", xmFormWidgetClass, resframe,
 
439
                               XmNresizePolicy, XmRESIZE_GROW, NULL);
 
440
 
 
441
    bboxSizeRC = XtVaCreateManagedWidget("bboxSizeRC", xmRowColumnWidgetClass,
 
442
                               resform,
 
443
                               XmNorientation, XmHORIZONTAL,
 
444
                               XmNpacking, XmPACK_TIGHT,
 
445
                               XmNtopAttachment, XmATTACH_FORM,
 
446
                               XmNleftAttachment, XmATTACH_FORM,
 
447
                               XmNrightAttachment, XmATTACH_NONE,
 
448
                               XmNtopOffset, 10,
 
449
                               XmNleftOffset, 10,
 
450
                               XmNrowColumnType, XmWORK_AREA,
 
451
                               NULL);
 
452
 
 
453
    fillOptionRC = XtVaCreateManagedWidget("fillOptionRC", 
 
454
                               xmRowColumnWidgetClass, resform,
 
455
                               XmNorientation, XmHORIZONTAL,
 
456
                               XmNpacking, XmPACK_TIGHT,
 
457
                               XmNbottomAttachment, XmATTACH_NONE,
 
458
                               XmNleftAttachment, XmATTACH_FORM,
 
459
                               XmNtopOffset, 10,
 
460
                               XmNbottomOffset, 0,
 
461
                               XmNleftOffset, 10,
 
462
                               XmNrowColumnType, XmWORK_AREA,
 
463
                               XmNtopAttachment, XmATTACH_WIDGET,
 
464
                               XmNtopWidget, bboxSizeRC,
 
465
                               NULL);
 
466
 
 
467
    widRC = XtVaCreateManagedWidget("widRC", xmRowColumnWidgetClass, resform,
 
468
                               XmNorientation, XmHORIZONTAL,
 
469
                               XmNtopAttachment, XmATTACH_WIDGET,
 
470
                               XmNtopWidget, fillOptionRC,
 
471
                               XmNpacking, XmPACK_TIGHT,
 
472
                               XmNbottomAttachment, XmATTACH_NONE,
 
473
                               XmNleftAttachment, XmATTACH_FORM,
 
474
                               XmNtopOffset, 10,
 
475
                               XmNbottomOffset, 0,
 
476
                               XmNleftOffset, 10,
 
477
                               XmNrowColumnType, XmWORK_AREA,
 
478
                               NULL);
 
479
 
 
480
    htRC = XtVaCreateManagedWidget("htRC", xmRowColumnWidgetClass, resform,
 
481
                               XmNorientation, XmHORIZONTAL,
 
482
                               XmNtopAttachment, XmATTACH_WIDGET,
 
483
                               XmNtopWidget, widRC,
 
484
                               XmNpacking, XmPACK_TIGHT,
 
485
                               XmNbottomAttachment, XmATTACH_NONE,
 
486
                               XmNleftAttachment, XmATTACH_FORM,
 
487
                               XmNtopOffset, 10,
 
488
                               XmNbottomOffset, 0,
 
489
                               XmNleftOffset, 10,
 
490
                               XmNrowColumnType, XmWORK_AREA,
 
491
                               NULL);
 
492
 
 
493
    orientRC = XtVaCreateManagedWidget("orientRC", xmRowColumnWidgetClass, 
 
494
                               resform,
 
495
                               XmNtopAttachment, XmATTACH_WIDGET,
 
496
                               XmNtopWidget, htRC,
 
497
                               XmNorientation, XmHORIZONTAL,
 
498
                               XmNpacking, XmPACK_TIGHT,
 
499
                               XmNbottomAttachment, XmATTACH_NONE,
 
500
                               XmNleftAttachment, XmATTACH_FORM,
 
501
                               XmNtopOffset, 10,
 
502
                               XmNbottomOffset, 0,
 
503
                               XmNleftOffset, 10,
 
504
                               XmNrowColumnType, XmWORK_AREA,
 
505
                               NULL);
 
506
 
 
507
    boxSizeLabel = XtVaCreateManagedWidget("boxSizeLabel", xmLabelWidgetClass,
 
508
                               bboxSizeRC,
 
509
                               XmNx, 3, XmNy, 3,
 
510
                               NULL);
 
511
 
 
512
    argcnt = 0;
 
513
    XtSetArg(args[argcnt], XmNx, 82); argcnt++;
 
514
    XtSetArg(args[argcnt], XmNy, 3); argcnt++;
 
515
    XtSetArg(args[argcnt], XmNorientation, XmHORIZONTAL); argcnt++;
 
516
    radioRC = XmCreateRadioBox(bboxSizeRC,"radioRC", args, argcnt);
 
517
 
 
518
    togl_btn1 = XtVaCreateManagedWidget("toggle1", xmToggleButtonWidgetClass,
 
519
                               radioRC, NULL);
 
520
 
 
521
    togl_btn2 = XtVaCreateManagedWidget("toggle2", xmToggleButtonWidgetClass,
 
522
                               radioRC, NULL);
 
523
 
 
524
    XtManageChild(radioRC);
 
525
 
 
526
    pushButton = XtVaCreateManagedWidget("pushButton",
 
527
                               xmPushButtonWidgetClass, bboxSizeRC,
 
528
                               XmNx, 265, XmNy, 3,
 
529
                               NULL);
 
530
 
 
531
    fillOptionLabel = XtVaCreateManagedWidget("fillOptionLabel", 
 
532
                               xmLabelWidgetClass, fillOptionRC,
 
533
                               XmNx, 3, XmNy, 3,
 
534
                               NULL);
 
535
 
 
536
    argcnt = 0;
 
537
    XtSetArg(args[argcnt], XmNx, 100); argcnt++;
 
538
    XtSetArg(args[argcnt], XmNy, 3); argcnt++;
 
539
    fillOptionMenu = XmCreateOptionMenu(fillOptionRC, "fillOptionMenu", 
 
540
                               args, argcnt);
 
541
    XtManageChild(fillOptionMenu);
 
542
 
 
543
    argcnt = 0;
 
544
    XtSetArg(args[argcnt], XmNwidth, 1); argcnt++;
 
545
    XtSetArg(args[argcnt], XmNheight, 1); argcnt++;
 
546
    menuShell = XtCreatePopupShell("menuShell", xmMenuShellWidgetClass,
 
547
                fillOptionRC, args, argcnt);
 
548
 
 
549
    argcnt = 0;
 
550
    XtSetArg(args[argcnt], XmNrowColumnType, XmMENU_PULLDOWN); argcnt++;
 
551
    XtSetArg(args[argcnt], XmNx, 0); argcnt++;
 
552
    XtSetArg(args[argcnt], XmNy, 0); argcnt++;
 
553
    XtSetArg(args[argcnt], XmNwidth, 54); argcnt++;
 
554
    XtSetArg(args[argcnt], XmNheight, 88); argcnt++;
 
555
    pulldownMenu = XtCreateWidget("pulldownMenu", xmRowColumnWidgetClass,
 
556
                menuShell, args, argcnt);
 
557
 
 
558
    nonePB = XtVaCreateManagedWidget("nonePB", xmPushButtonWidgetClass, 
 
559
                pulldownMenu, NULL);
 
560
 
 
561
    minorPB = XtVaCreateManagedWidget("minorPB", xmPushButtonWidgetClass,
 
562
                pulldownMenu, NULL);
 
563
 
 
564
    majorPB = XtVaCreateManagedWidget("majorPB", xmPushButtonWidgetClass,
 
565
                pulldownMenu, NULL);
 
566
 
 
567
    allPB = XtVaCreateManagedWidget("allPB", xmPushButtonWidgetClass,
 
568
                pulldownMenu, NULL);
 
569
 
 
570
    argcnt = 0;
 
571
    XtSetArg(args[argcnt], XmNsubMenuId, pulldownMenu); argcnt++;
 
572
    XtSetValues(fillOptionMenu, args, argcnt);
 
573
 
 
574
    pushButton1 = XtVaCreateManagedWidget("pushButton1",
 
575
                               xmPushButtonWidgetClass, fillOptionRC,
 
576
                               XmNx, 262, XmNy, 3,
 
577
                               NULL);
 
578
 
 
579
    widLabel = XtVaCreateManagedWidget("widLabel", xmLabelWidgetClass, widRC,
 
580
                               XmNx, 3, XmNy, 3,
 
581
                               NULL);
 
582
 
 
583
    widText = XtVaCreateManagedWidget("widText", xmTextFieldWidgetClass,
 
584
                widRC, XmNx, 76, XmNy, 3, NULL);
 
585
 
 
586
    pushButton2 = XtVaCreateManagedWidget("pushButton2",
 
587
                               xmPushButtonWidgetClass, widRC,
 
588
                               XmNx, 217, XmNy, 3,
 
589
                               NULL);
 
590
 
 
591
    htLabel = XtVaCreateManagedWidget("htLabel", xmLabelWidgetClass, htRC,
 
592
                               XmNx, 3, XmNy, 3,
 
593
                               NULL);
 
594
 
 
595
    htText = XtVaCreateManagedWidget("htText", xmTextFieldWidgetClass,
 
596
                htRC, XmNx, 76, XmNy, 3, NULL);
 
597
 
 
598
    pushButton3 = XtVaCreateManagedWidget("pushButton3",
 
599
                               xmPushButtonWidgetClass, htRC,
 
600
                               XmNx, 217, XmNy, 3,
 
601
                               NULL);
 
602
 
 
603
    orientLabel = XtVaCreateManagedWidget("orientLabel", xmLabelWidgetClass,
 
604
                               orientRC,
 
605
                               XmNx, 3, XmNy, 3,
 
606
                               NULL);
 
607
 
 
608
    argcnt = 0;
 
609
    XtSetArg(args[argcnt], XmNx, 82); argcnt++;
 
610
    XtSetArg(args[argcnt], XmNy, 3); argcnt++;
 
611
    XtSetArg(args[argcnt], XmNorientation, XmHORIZONTAL); argcnt++;
 
612
    orientRadio = XmCreateRadioBox(orientRC,"orientRadio", args, argcnt);
 
613
 
 
614
    togl_btn3 = XtVaCreateManagedWidget("toggle3", xmToggleButtonWidgetClass,
 
615
                               orientRadio, NULL);
 
616
 
 
617
    togl_btn4 = XtVaCreateManagedWidget("toggle4", xmToggleButtonWidgetClass,
 
618
                               orientRadio, NULL);
 
619
 
 
620
        {
 
621
        unsigned char orientation;
 
622
        XtVaGetValues(bbox, XmNorientation, &orientation, NULL);
 
623
        if (XmHORIZONTAL == orientation)
 
624
                XmToggleButtonSetState(togl_btn3, True, False);
 
625
        else
 
626
                XmToggleButtonSetState(togl_btn4, True, False);
 
627
        }
 
628
 
 
629
    XtManageChild(orientRadio);
 
630
 
 
631
    pushButton4 = XtVaCreateManagedWidget("pushButton4",
 
632
                               xmPushButtonWidgetClass, orientRC,
 
633
                               XmNx, 82, XmNy, 3,
 
634
                               NULL);
 
635
                           
 
636
    XtAddCallback(quitPB, XmNactivateCallback, Exit, (XtPointer)0);
 
637
 
 
638
    XtAddCallback(pushButton, XmNactivateCallback, Explain, (XtPointer)1);
 
639
 
 
640
    XtAddCallback(pushButton1, XmNactivateCallback, Explain, (XtPointer)2);
 
641
 
 
642
    XtAddCallback(pushButton2, XmNactivateCallback, Explain, (XtPointer)3);
 
643
 
 
644
    XtAddCallback(pushButton3, XmNactivateCallback, Explain, (XtPointer)4);
 
645
 
 
646
    XtAddCallback(pushButton4, XmNactivateCallback, Explain, (XtPointer)5);
 
647
 
 
648
    XtAddCallback(togl_btn1, XmNvalueChangedCallback, Equal, (XtPointer)1);
 
649
 
 
650
    XtAddCallback(togl_btn2, XmNvalueChangedCallback, Equal, (XtPointer)0);
 
651
 
 
652
    XtAddCallback(nonePB, XmNactivateCallback, Fill, (XtPointer)1);
 
653
 
 
654
    XtAddCallback(minorPB, XmNactivateCallback, Fill, (XtPointer)2);
 
655
 
 
656
    XtAddCallback(majorPB, XmNactivateCallback, Fill, (XtPointer)3);
 
657
 
 
658
    XtAddCallback(allPB, XmNactivateCallback, Fill, (XtPointer)4);
 
659
 
 
660
    XtAddCallback(htText, XmNactivateCallback, Width, (XtPointer)1);
 
661
    XtAddCallback(htText, XmNmodifyVerifyCallback, OnlyNum, (XtPointer)0);
 
662
 
 
663
    XtAddCallback(widText, XmNactivateCallback, Width, (XtPointer)0);
 
664
    XtAddCallback(widText, XmNmodifyVerifyCallback, OnlyNum, (XtPointer)0);
 
665
 
 
666
    XtAddCallback(togl_btn4, XmNvalueChangedCallback, Orient, (XtPointer)1);
 
667
 
 
668
    XtAddCallback(togl_btn3, XmNvalueChangedCallback, Orient, (XtPointer)0);
 
669
 
 
670
    XtRealizeWidget(top);
 
671
 
 
672
    XtAppMainLoop(app);
 
673
    
 
674
    /* appease compiler warning god */
 
675
    return (0); 
 
676
}