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

« back to all changes in this revision

Viewing changes to demos/programs/Outline/outline.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
/*
 
2
 * Copyright 1994, Integrated Computer Solutions, Inc.
 
3
 *
 
4
 * All Rights Reserved.
 
5
 *
 
6
 * Author: Rick Umali
 
7
 *
 
8
 * outline.c
 
9
 *
 
10
 * Almost a direct copy of the tree.c demo code
 
11
 *
 
12
 */
 
13
 
 
14
/**************************************************************
 
15
 *              INCLUDE FILES
 
16
 **************************************************************/
 
17
#include <stdio.h>
 
18
#include <stdlib.h>
 
19
 
 
20
#include <X11/Intrinsic.h>
 
21
 
 
22
#include <Xm/Tree.h>
 
23
#include <Xm/Outline.h>
 
24
#include <Xm/Hierarchy.h>
 
25
#include <Xm/IconButton.h>
 
26
 
 
27
#include <Xm/Xm.h>
 
28
#include <Xm/BulletinB.h>
 
29
#include <Xm/MessageB.h>
 
30
#include <Xm/RowColumn.h>
 
31
#include <Xm/PushB.h>
 
32
#include <Xm/Separator.h>
 
33
#include <Xm/ToggleB.h>
 
34
#include <Xm/Label.h>
 
35
#include <Xm/PanedW.h>
 
36
#include <Xm/ScrolledW.h>
 
37
#include <Xm/Text.h>
 
38
 
 
39
/**************************************************************
 
40
 *              STATIC FUNCTION DECLARATIONS
 
41
 **************************************************************/
 
42
static Widget CreateNode(Widget, Widget, char *, XmHierarchyNodeState);
 
43
static void BuildHierarchy(Widget, WidgetClass);
 
44
static void WriteUpHype(Widget);
 
45
static void MakeControlPanel(Widget);
 
46
static void ShowCB(Widget, XtPointer, XtPointer);
 
47
static void ExplainCB(Widget, XtPointer, XtPointer);
 
48
static void CallbackTogCB(Widget, XtPointer, XtPointer);
 
49
static void QuitCB(Widget, XtPointer, XtPointer);
 
50
void InitializePanel(Widget);
 
51
 
 
52
/**************************************************************
 
53
 *              GLOBALS
 
54
 **************************************************************/
 
55
static Widget G_outline = NULL;
 
56
static int done = 0;
 
57
 
 
58
/**************************************************************
 
59
 *              SHOW CODE
 
60
 **************************************************************/
 
61
#define CODE "void\n\
 
62
BuildHierarchy(Widget parent)\n\
 
63
{\n\
 
64
    Widget outline, hierarchy, w1, w2, w3;\n\
 
65
\n\
 
66
    outline = XtCreateManagedWidget(\"outline_widget\", xmOutlineWidgetClass,\n\
 
67
              parent, NULL, (Cardinal) 0);\n\
 
68
\n\
 
69
    w1 = CreateNode(outline, NULL, \"Widgets\", XmOpen);\n\
 
70
\n\
 
71
    w2 = CreateNode(outline, w1, \"Writing Widgets\", XmOpen);\n\
 
72
    {\n\
 
73
        (void) CreateNode(outline, w2, \"Widget Data Structures\", XmAlwaysOpen);\n\
 
74
        (void) CreateNode(outline, w2, \"Structure Naming Conventions\", XmAlwaysOpen);\n\
 
75
        w3 = CreateNode(outline, w2, \"Writing Header Files\", XmOpen);\n\
 
76
    }\n\
 
77
\n\
 
78
    (void) CreateNode(outline, w3, \"Writing Private Header Files\", XmAlwaysOpen);\n\
 
79
    (void) CreateNode(outline, w3, \"Writing Public Header Files\", XmAlwaysOpen);\n\
 
80
    (void) CreateNode(outline, w3, \"Internal Header Files\", XmAlwaysOpen);\n\
 
81
\n\
 
82
    w3 = CreateNode(outline, w2, \"The Base Widget Classes\", XmOpen);\n\
 
83
    (void) CreateNode(outline, w3, \"The Core Class Structure\", XmAlwaysOpen);\n\
 
84
    (void) CreateNode(outline, w3, \"The Core Instance Structure\", XmAlwaysOpen);\n\
 
85
    (void) CreateNode(outline, w3, \"The Composite Class Structure\", XmAlwaysOpen);\n\
 
86
    (void) CreateNode(outline, w3, \"The Composite Instance Structure\", XmAlwaysOpen);\n\
 
87
    (void) CreateNode(outline, w3, \"The Constraint Class Structure\", XmAlwaysOpen);\n\
 
88
    (void) CreateNode(outline, w3, \"The Constraint Instance Structure\", XmAlwaysOpen);\n\
 
89
}\n\
 
90
\n\
 
91
Widget\n\
 
92
CreateNode(Widget w_parent, Widget parent_node, char * name, \n\
 
93
           XmHierarchyNodeState state)\n\
 
94
{\n\
 
95
    Arg args[10];\n\
 
96
    Cardinal num_args;\n\
 
97
    Widget w;\n\
 
98
    XmString xmstring;\n\
 
99
\n\
 
100
    xmstring = XmStringCreateSimple(name);\n\
 
101
    \n\
 
102
    num_args = 0;\n\
 
103
    XtSetArg(args[num_args], XmNlabelString, xmstring); num_args++;\n\
 
104
    XtSetArg(args[num_args], XmNnodeState, state); num_args++;\n\
 
105
    XtSetArg(args[num_args], XmNparentNode, parent_node); num_args++;\n\
 
106
    \n\
 
107
    w = XtCreateManagedWidget(name, xmPushButtonWidgetClass,\n\
 
108
                              w_parent, args, num_args);\n\
 
109
\n\
 
110
    XmStringFree(xmstring);\n\
 
111
    return(w);\n\
 
112
}"
 
113
 
 
114
/**************************************************************
 
115
 *              RESOURCE FALLBACKS
 
116
 **************************************************************/
 
117
static String fallbacks[] = {
 
118
    "*fontList: -*-helvetica-medium-r-*-*-*-140-*-*-*-*-*-*",
 
119
    "*hypelabel*fontList: -*-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*",
 
120
    "*show_code*fontList: -*-courier-*-r-normal-*-*-*-*-*-*-*-*-*",
 
121
    "*show_pb.labelString: Show Layout Code...",
 
122
    "*explain_pb.labelString: Other Resources...", 
 
123
    "*rc_1*XmSeparator*orientation: XmVERTICAL",
 
124
    "*ladder_tog.labelString: Connect Style:",
 
125
    "*callback_tog.labelString: Node State Callback:",
 
126
    "*autoclose_tog.labelString: Auto Close",
 
127
    "*connect_tog.labelString: Connect Nodes",
 
128
    "*quit_pb.labelString: Quit",
 
129
    NULL,
 
130
};
 
131
 
 
132
/*
 
133
 * Function Name: InitializePanel
 
134
 * Description:   Checks the resources at start up and sets their
 
135
 *                labels and toggles appropriately
 
136
 * Arguments:     pane - area containing the buttons and toggles
 
137
 * Returns:       Nothing
 
138
 *
 
139
 */
 
140
void
 
141
InitializePanel(Widget pane)
 
142
{
 
143
    Arg args[10];
 
144
    Cardinal argcnt;
 
145
    Boolean auto_close;
 
146
    Boolean connect;
 
147
    XmString xmstring;
 
148
    XtCallbackStatus status;
 
149
    Widget lab_temp, tog_temp;
 
150
    
 
151
    argcnt = 0;
 
152
    XtSetArg(args[argcnt], XmNautoClose, &auto_close); argcnt++;
 
153
    XtSetArg(args[argcnt], XmNconnectNodes, &connect); argcnt++;
 
154
    XtGetValues(G_outline, args, argcnt);
 
155
 
 
156
    /*
 
157
     * Initialize Node State Callback Toggle and Label
 
158
     */
 
159
    lab_temp = XtNameToWidget(pane, "*callback_lab");
 
160
    if (lab_temp == NULL) {
 
161
        fprintf(stderr, "InitializePane: cannot find callback_lab\n");
 
162
        exit(1);
 
163
    }
 
164
    tog_temp = XtNameToWidget(pane, "*callback_tog");
 
165
    if (tog_temp == NULL) {
 
166
        fprintf(stderr, "InitializePane: cannot find callback_tog\n");
 
167
        exit(1);
 
168
    }
 
169
 
 
170
    status = XtHasCallbacks(G_outline, XmNnodeStateCallback);
 
171
    switch(status) {
 
172
    case XtCallbackHasSome:
 
173
        XmToggleButtonSetState(tog_temp, True, False);
 
174
        xmstring = XmStringCreateSimple("Added");
 
175
        break;
 
176
    case XtCallbackNoList:
 
177
    case XtCallbackHasNone:
 
178
    default:
 
179
        XmToggleButtonSetState(tog_temp, False, False);
 
180
        xmstring = XmStringCreateSimple("Not Added");
 
181
        break;
 
182
    }
 
183
    argcnt = 0;
 
184
    XtSetArg(args[argcnt], XmNlabelString, xmstring); argcnt++;
 
185
    XtSetValues(lab_temp, args, argcnt);
 
186
    XmStringFree(xmstring);
 
187
 
 
188
    /*
 
189
     * Initialize Auto Close Toggle
 
190
     */
 
191
    tog_temp = XtNameToWidget(pane, "*autoclose_tog");
 
192
    if (tog_temp == NULL) {
 
193
        fprintf(stderr, "InitializePane: cannot find autoclose_tog\n");
 
194
        exit(1);
 
195
    }
 
196
        XmToggleButtonSetState(tog_temp, auto_close, False);
 
197
 
 
198
    tog_temp = XtNameToWidget(pane, "*connect_tog");
 
199
    if (tog_temp == NULL) {
 
200
        fprintf(stderr, "InitializePane: cannot find connecct_tog\n");
 
201
        exit(1);
 
202
    }
 
203
        XmToggleButtonSetState(tog_temp, connect, False);
 
204
}
 
205
 
 
206
/*
 
207
 * Function Name: main
 
208
 * Description:   
 
209
 * Arguments:     the usual suspects
 
210
 * Returns:       nothing
 
211
 *
 
212
 */
 
213
int
 
214
main(int argc, char **argv)
 
215
{
 
216
    Widget top, pane;
 
217
    Arg args[10];
 
218
    Cardinal num_args;
 
219
    XtAppContext app_con;
 
220
 
 
221
    num_args = 0;
 
222
    XtSetArg(args[num_args], XmNtitle, "Outline Demo"); num_args++;
 
223
    XtSetArg(args[num_args], XmNallowShellResize, True); num_args++;
 
224
    top = XtAppInitialize(&app_con, "Treedemo", 
 
225
                          NULL, 0, &argc, argv,
 
226
                          fallbacks, args, num_args);
 
227
        
 
228
    { 
 
229
    Widget sw;
 
230
    num_args = 0;
 
231
    pane = XtCreateManagedWidget("pane", xmPanedWindowWidgetClass, 
 
232
                                 top, args, num_args);    
 
233
    WriteUpHype(pane);
 
234
 
 
235
    num_args = 0;
 
236
    XtSetArg(args[num_args], XmNscrollingPolicy, XmAUTOMATIC); num_args++;
 
237
    XtSetArg(args[num_args], XmNheight, 500); num_args++;
 
238
    sw = XtCreateManagedWidget("pane", xmScrolledWindowWidgetClass, 
 
239
                                 pane, args, num_args);    
 
240
    
 
241
    BuildHierarchy(sw, xmOutlineWidgetClass);
 
242
    MakeControlPanel(pane);
 
243
 
 
244
    InitializePanel(pane);
 
245
 
 
246
    }
 
247
 
 
248
    XtRealizeWidget(top);
 
249
 
 
250
        /*      Process events, unwrapping correctly.  */
 
251
        while (!done)
 
252
        {
 
253
                XEvent event;
 
254
                XtAppNextEvent(app_con, &event);
 
255
                XtDispatchEvent(&event);
 
256
        }
 
257
        XtDestroyWidget(top);
 
258
        XtDestroyApplicationContext(app_con);
 
259
        exit(0);
 
260
}
 
261
 
 
262
/**************************************************************
 
263
 *              STATIC FUNCTIONS
 
264
 **************************************************************/
 
265
/*
 
266
 * Function Name: BuildHierarchy
 
267
 * Description:   
 
268
 * Arguments:     
 
269
 * Returns:       Nothing
 
270
 *
 
271
 */
 
272
static void
 
273
BuildHierarchy(Widget parent, WidgetClass class)
 
274
{
 
275
    Widget outline, hierarchy, w1, w2, w3;
 
276
 
 
277
    G_outline = outline = XtCreateManagedWidget("outline_widget", class, 
 
278
                                          parent, NULL, (Cardinal) 0);
 
279
 
 
280
    w1 = CreateNode(outline, NULL, "Widgets", XmOpen);
 
281
 
 
282
    w2 = CreateNode(outline, w1, "Writing Widgets", XmOpen);
 
283
    {
 
284
        (void) CreateNode(outline, w2, "Widget Data Structures", XmAlwaysOpen);
 
285
        (void) CreateNode(outline, w2, "Structure Naming Conventions", XmAlwaysOpen);
 
286
        w3 = CreateNode(outline, w2, "Writing Header Files", XmOpen);
 
287
    }
 
288
 
 
289
    (void) CreateNode(outline, w3, "Writing Private Header Files", XmAlwaysOpen);
 
290
    (void) CreateNode(outline, w3, "Writing Public Header Files", XmAlwaysOpen);
 
291
    (void) CreateNode(outline, w3, "Internal Header Files", XmAlwaysOpen);
 
292
 
 
293
    w3 = CreateNode(outline, w2, "The Base Widget Classes", XmOpen);
 
294
    (void) CreateNode(outline, w3, "The Core Class Structure", XmAlwaysOpen);
 
295
    (void) CreateNode(outline, w3, "The Core Instance Structure", XmAlwaysOpen);
 
296
    (void) CreateNode(outline, w3, "The Composite Class Structure", XmAlwaysOpen);
 
297
    (void) CreateNode(outline, w3, "The Composite Instance Structure", XmAlwaysOpen);
 
298
    (void) CreateNode(outline, w3, "The Constraint Class Structure", XmAlwaysOpen);
 
299
    (void) CreateNode(outline, w3, "The Constraint Instance Structure", XmAlwaysOpen);
 
300
}
 
301
 
 
302
static void NewChildCB(Widget w, XtPointer client, XtPointer call)
 
303
{
 
304
        static int count = 0;
 
305
        char buffer[30];
 
306
        sprintf (buffer, "New Child %d", count++);
 
307
        CreateNode((Widget)client, w, buffer, XmAlwaysOpen);
 
308
}
 
309
 
 
310
/*
 
311
 * Function Name: CreateNode
 
312
 * Description:   
 
313
 * Arguments:     
 
314
 * Returns:       Widget
 
315
 *
 
316
 */
 
317
static Widget
 
318
CreateNode(Widget w_parent, Widget parent_node, char * name, 
 
319
           XmHierarchyNodeState state)
 
320
{
 
321
    Arg args[10];
 
322
    Cardinal num_args;
 
323
    Widget w;
 
324
    XmString xmstring;
 
325
 
 
326
    xmstring = XmStringCreateSimple(name);
 
327
    
 
328
    num_args = 0;
 
329
    XtSetArg(args[num_args], XmNlabelString, xmstring); num_args++;
 
330
    XtSetArg(args[num_args], XmNnodeState, state); num_args++;
 
331
    XtSetArg(args[num_args], XmNparentNode, parent_node); num_args++;
 
332
    
 
333
    w = XtCreateManagedWidget(name, xmPushButtonWidgetClass,
 
334
                              w_parent, args, num_args);
 
335
 
 
336
    XtAddCallback(w,XmNactivateCallback,NewChildCB,w_parent);
 
337
 
 
338
    XmStringFree(xmstring);
 
339
    return(w);
 
340
}
 
341
 
 
342
/*
 
343
 * Function Name: WriteUpHype
 
344
 * Description:   Prints up the "Hype" message in a label
 
345
 * Arguments:     the usual suspects
 
346
 * Returns:       nothing
 
347
 */
 
348
static
 
349
void WriteUpHype(Widget parent)
 
350
{
 
351
    Arg args[5];
 
352
    Cardinal argcnt;
 
353
    Widget w;
 
354
    XmString xmstring;
 
355
    
 
356
    xmstring = XmStringCreateLtoR(
 
357
"The OpenMotif Outline Widget displays hierarchical data in an outline layout with a Motif\n\
 
358
look and feel. The Outline widget displayed below has several Motif PushButtons (the\n\
 
359
Outline can accept any type of widget); press one to add a new child.\n\
 
360
\n\
 
361
The Outline Widget uses \"constraints\" to arrange the children with the right layout.\n\
 
362
To see the code to generate the tree below, press \"Show Layout Code...\".\n\
 
363
\n\
 
364
The toggles below set different resources on the Outline widget itself.\n\
 
365
\n\
 
366
Press \"Other Resources...\" for more information on the various resources.",
 
367
                                  XmSTRING_DEFAULT_CHARSET);
 
368
     
 
369
    argcnt = 0;
 
370
    XtSetArg(args[argcnt], XmNmarginHeight, 10); argcnt++;
 
371
    XtSetArg(args[argcnt], XmNmarginWidth, 10); argcnt++;
 
372
    XtSetArg(args[argcnt], XmNalignment, XmALIGNMENT_BEGINNING); argcnt++;
 
373
    XtSetArg(args[argcnt], XmNlabelString, xmstring); argcnt++;
 
374
    w = XtCreateManagedWidget("hypelabel", xmLabelWidgetClass,
 
375
                              parent, args, argcnt);
 
376
    
 
377
    XmStringFree(xmstring);
 
378
                                  
 
379
}
 
380
 
 
381
/*
 
382
 * Function Name: ShowCB
 
383
 * Description:   
 
384
 * Arguments:     This is an XtCallback
 
385
 * Returns:       Nothing
 
386
 */
 
387
static void ShowCB(Widget w, XtPointer client, XtPointer call)
 
388
{
 
389
    static Widget info = NULL;
 
390
 
 
391
    if (info == NULL) {
 
392
        Arg args[5];
 
393
        Cardinal argcnt;
 
394
        Widget temp;
 
395
        XmString ok_xmstring;
 
396
 
 
397
        ok_xmstring = XmStringCreateSimple("OK");
 
398
 
 
399
        argcnt = 0;
 
400
        XtSetArg(args[argcnt], XmNtitle, "Show Code..."); argcnt++;
 
401
        /* XtSetArg(args[argcnt], XmNmessageString, xmstring); argcnt++; */
 
402
        XtSetArg(args[argcnt], XmNokLabelString, ok_xmstring); argcnt++;
 
403
        XtSetArg(args[argcnt], XmNallowShellResize, True); argcnt++;
 
404
        info = XmCreateTemplateDialog(G_outline, "show_code", args, argcnt);
 
405
 
 
406
        argcnt = 0;
 
407
        XtSetArg(args[argcnt], XmNcolumns, 60); argcnt++;
 
408
        XtSetArg(args[argcnt], XmNrows, 20); argcnt++;
 
409
        XtSetArg(args[argcnt], XmNvalue, CODE); argcnt++;
 
410
        XtSetArg(args[argcnt], XmNeditable, False); argcnt++;
 
411
        XtSetArg(args[argcnt], XmNeditMode, XmMULTI_LINE_EDIT); argcnt++;
 
412
        temp = XmCreateScrolledText(info, "show_text", args, argcnt);
 
413
        XtManageChild(temp);
 
414
 
 
415
        XmStringFree(ok_xmstring);
 
416
    }
 
417
 
 
418
    XtManageChild(info);
 
419
}
 
420
 
 
421
/*
 
422
 * Function Name: ExplainCB
 
423
 * Description:   
 
424
 * Arguments:     This is an XtCallback
 
425
 * Returns:       Nothing
 
426
 */
 
427
static void ExplainCB(Widget w, XtPointer client, XtPointer call)
 
428
{
 
429
    static Widget info = NULL;
 
430
 
 
431
    if (info == NULL) {
 
432
        Arg args[5];
 
433
        Cardinal argcnt;
 
434
        Widget temp;
 
435
        XmString xmstring;
 
436
 
 
437
        xmstring = XmStringCreateLtoR(
 
438
"The OpenMotif Tree and Outline widget actually derive behavior from the\n\
 
439
Hierarchy Widget. The Hierarchy widget provides resources that specify\n\
 
440
the relationships between children.\n\
 
441
\n\
 
442
XmNautoClose specifies whether the Tree or Outline automatically closes\n\
 
443
any nodes if a parent node is closed. To see the behavior, press the Auto\n\
 
444
Close toggle, then close and reopen the Core.\n\
 
445
\n\
 
446
XmNnodeState is a constraint resource on a child of the Tree or Outline.\n\
 
447
It determines whether a node is Open, Closed, Hidden, or Always Visible.\n\
 
448
Use \"Show Layout Code...\" to see how this demo used this resource.\n\
 
449
\n\
 
450
XmNparentNode specifies this node's parent. This resource determines the\n\
 
451
node's logical parent (the widget instance tree says the node is a child of\n\
 
452
the Tree or Outline, but the parentNode will specify where on the layout\n\
 
453
the node will appear. Use \"Show Layout Code...\" to see how this demo used\n\
 
454
this resource.\n\
 
455
\n\
 
456
XmNnodeStateCallback provides a way to receive feedback when any node is\n\
 
457
opened or closed. To use this callback, press the Node State Callback toggle.",
 
458
                                      XmSTRING_DEFAULT_CHARSET);
 
459
 
 
460
        argcnt = 0;
 
461
        XtSetArg(args[argcnt], XmNtitle, "Explanation"); argcnt++;
 
462
        XtSetArg(args[argcnt], XmNmessageString, xmstring); argcnt++;
 
463
        info = XmCreateInformationDialog(G_outline, "explain", args, argcnt);
 
464
 
 
465
        temp = XmMessageBoxGetChild(info, XmDIALOG_CANCEL_BUTTON);
 
466
        XtUnmanageChild(temp);
 
467
        temp = XmMessageBoxGetChild(info, XmDIALOG_HELP_BUTTON);
 
468
        XtUnmanageChild(temp);
 
469
        XmStringFree(xmstring);
 
470
    }
 
471
 
 
472
    XtManageChild(info);
 
473
}
 
474
 
 
475
/*
 
476
 * Function Name: NodeStateCB
 
477
 * Description:   
 
478
 * Arguments:     This is an XtCallback
 
479
 * Returns:       Nothing
 
480
 */
 
481
void NodeStateCB(Widget w, XtPointer client, XtPointer call)
 
482
{
 
483
    Arg args[5];
 
484
    Cardinal argcnt;
 
485
    Widget info, temp;
 
486
    XmHierarchyNodeStateData *node_data = (XmHierarchyNodeStateData *) call;
 
487
    XmString xmstring;
 
488
    char *name;
 
489
    char buf[100];
 
490
 
 
491
    argcnt = 0;
 
492
    XtSetArg(args[argcnt], XmNlabelString, &xmstring); argcnt++;
 
493
    XtGetValues(node_data->widget, args, argcnt);
 
494
 
 
495
    XmStringGetLtoR(xmstring, XmFONTLIST_DEFAULT_TAG, &name);
 
496
 
 
497
    if (node_data->state == XmOpen)
 
498
        sprintf(buf, "%s has switched to the XmOpen state.", name);
 
499
    else if (node_data->state == XmClosed)
 
500
        sprintf(buf, "%s has switched to the XmClosed state.", name);
 
501
    else if (node_data->state == XmAlwaysOpen)
 
502
        sprintf(buf, "%s has switched to the XmAlwaysOpen state.", name);
 
503
    else if (node_data->state == XmHidden)
 
504
        sprintf(buf, "%s has switched to the XmHidden state.", name);
 
505
    else
 
506
        sprintf(buf, "%s has switched node state.", name);
 
507
 
 
508
    xmstring = XmStringCreateSimple(buf);
 
509
    
 
510
    argcnt = 0;
 
511
    XtSetArg(args[argcnt], XmNtitle, "Node State Changed"); argcnt++;
 
512
    XtSetArg(args[argcnt], XmNmessageString, xmstring); argcnt++;
 
513
    info = XmCreateInformationDialog(w, "nodechange", args, argcnt);
 
514
    
 
515
    temp = XmMessageBoxGetChild(info, XmDIALOG_CANCEL_BUTTON);
 
516
    XtUnmanageChild(temp);
 
517
    temp = XmMessageBoxGetChild(info, XmDIALOG_HELP_BUTTON);
 
518
    XtUnmanageChild(temp);
 
519
 
 
520
    XmStringFree(xmstring);
 
521
    XtFree(name);
 
522
 
 
523
    XtManageChild(info);
 
524
}
 
525
 
 
526
/*
 
527
 * Function Name: CallbackTogCB
 
528
 * Description:   
 
529
 * Arguments:     This is an XtCallback
 
530
 * Returns:       Nothing
 
531
 */
 
532
static void CallbackTogCB(Widget w, XtPointer client, XtPointer call)
 
533
{
 
534
    Arg args[5];
 
535
    Cardinal argcnt;
 
536
    Widget lab = (Widget) client;
 
537
    XmString xmstring;
 
538
 
 
539
    if (XmToggleButtonGetState(w)) {
 
540
        XtAddCallback(G_outline, XmNnodeStateCallback, NodeStateCB, NULL);
 
541
        xmstring = XmStringCreateSimple("Added");
 
542
    } else {
 
543
        XtRemoveAllCallbacks(G_outline, XmNnodeStateCallback);
 
544
        xmstring = XmStringCreateSimple("Not Added");
 
545
    }
 
546
 
 
547
    argcnt = 0;
 
548
    XtSetArg(args[argcnt], XmNlabelString, xmstring); argcnt++;
 
549
    XtSetValues(lab, args, argcnt);
 
550
    XmStringFree(xmstring);
 
551
}
 
552
 
 
553
/*
 
554
 * Function Name: AutoCloseTogCB
 
555
 * Description:   
 
556
 * Arguments:     This is an XtCallback
 
557
 * Returns:       Nothing
 
558
 */
 
559
static void AutoCloseTogCB(Widget w, XtPointer client, XtPointer call)
 
560
{
 
561
  XtVaSetValues(G_outline, XmNautoClose, XmToggleButtonGetState(w), NULL);
 
562
}
 
563
 
 
564
static void ConnectTogCB(Widget w, XtPointer client, XtPointer call)
 
565
{
 
566
  XtVaSetValues(G_outline, XmNconnectNodes, XmToggleButtonGetState(w), NULL);
 
567
}
 
568
 
 
569
 
 
570
/*
 
571
 * Function Name: QuitCB
 
572
 * Description:   Exits the program
 
573
 * Arguments:     This is an XtCallback
 
574
 * Returns:       Nothing
 
575
 */
 
576
static void
 
577
QuitCB(Widget w, XtPointer client, XtPointer call)
 
578
{
 
579
        done = 1;
 
580
}
 
581
 
 
582
/*
 
583
 * Function Name: MakeControlPanel
 
584
 * Description:   Prints up the "Hype" message in a label
 
585
 * Arguments:     the usual suspects
 
586
 * Returns:       nothing
 
587
 */
 
588
static
 
589
void MakeControlPanel(Widget parent)
 
590
{
 
591
    Arg args[5];
 
592
    Cardinal argcnt;
 
593
    Widget big_rc, rc_1, rc_2, show_pb, explain_pb, ladder_tog, ladder_lab, 
 
594
    callback_tog, callback_lab, quit_pb, autoclose_tog, sep, connect_tog;
 
595
 
 
596
    /* Big Vertical Row Column for the control panel */
 
597
    argcnt = 0;
 
598
    XtSetArg(args[argcnt], XmNorientation, XmVERTICAL); argcnt++;
 
599
    XtSetArg(args[argcnt], XmNpacking, XmPACK_TIGHT); argcnt++;
 
600
    big_rc = XtCreateManagedWidget("big_rc", xmRowColumnWidgetClass,
 
601
                                   parent, args, argcnt);
 
602
 
 
603
    /* First Row */
 
604
    argcnt = 0;
 
605
    XtSetArg(args[argcnt], XmNorientation, XmHORIZONTAL); argcnt++;
 
606
    XtSetArg(args[argcnt], XmNpacking, XmPACK_TIGHT); argcnt++;
 
607
    rc_1 = XtCreateManagedWidget("rc_1", xmRowColumnWidgetClass,
 
608
                                 big_rc, args, argcnt);
 
609
 
 
610
    argcnt = 0;
 
611
    callback_tog = XtCreateManagedWidget("callback_tog", 
 
612
                                         xmToggleButtonWidgetClass,
 
613
                                         rc_1, args, argcnt);
 
614
    argcnt = 0;
 
615
    callback_lab = XtCreateManagedWidget("callback_lab", xmLabelWidgetClass,
 
616
                                         rc_1, args, argcnt);
 
617
    XtAddCallback(callback_tog, XmNvalueChangedCallback, 
 
618
                  CallbackTogCB, (XtPointer) callback_lab);
 
619
 
 
620
    argcnt = 0;
 
621
    sep = XtCreateManagedWidget("sep_two", xmSeparatorWidgetClass,
 
622
                                rc_1, args, argcnt);
 
623
 
 
624
    argcnt = 0;
 
625
    autoclose_tog = XtCreateManagedWidget("autoclose_tog", 
 
626
                                          xmToggleButtonWidgetClass,
 
627
                                          rc_1, args, argcnt);
 
628
    XtAddCallback(autoclose_tog, XmNvalueChangedCallback, 
 
629
                  AutoCloseTogCB, NULL);
 
630
 
 
631
    argcnt = 0;
 
632
    sep = XtCreateManagedWidget("sep_two", xmSeparatorWidgetClass,
 
633
                                rc_1, args, argcnt);
 
634
 
 
635
    argcnt = 0;
 
636
    connect_tog = XtCreateManagedWidget("connect_tog", 
 
637
                                          xmToggleButtonWidgetClass,
 
638
                                          rc_1, args, argcnt);
 
639
    XtAddCallback(connect_tog, XmNvalueChangedCallback, 
 
640
                  ConnectTogCB, NULL);
 
641
 
 
642
 
 
643
    /* Third Row */
 
644
    argcnt = 0;
 
645
    XtSetArg(args[argcnt], XmNorientation, XmHORIZONTAL); argcnt++;
 
646
    XtSetArg(args[argcnt], XmNpacking, XmPACK_TIGHT); argcnt++;
 
647
    rc_2 = XtCreateManagedWidget("rc_2", xmRowColumnWidgetClass,
 
648
                                 big_rc, args, argcnt);
 
649
 
 
650
    argcnt = 0;
 
651
    show_pb = XtCreateManagedWidget("show_pb", xmPushButtonWidgetClass,
 
652
                                    rc_2, args, argcnt);
 
653
    XtAddCallback(show_pb, XmNactivateCallback, ShowCB, NULL);
 
654
 
 
655
    argcnt = 0;
 
656
    explain_pb = XtCreateManagedWidget("explain_pb", xmPushButtonWidgetClass,
 
657
                                       rc_2, args, argcnt);
 
658
    XtAddCallback(explain_pb, XmNactivateCallback, ExplainCB, NULL);
 
659
 
 
660
    argcnt = 0;
 
661
    quit_pb = XtCreateManagedWidget("quit_pb", xmPushButtonWidgetClass,
 
662
                                    rc_2, args, argcnt);
 
663
 
 
664
    XtAddCallback(quit_pb, XmNactivateCallback, QuitCB, NULL);
 
665
}