-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeWin.c
865 lines (679 loc) · 21.2 KB
/
SeWin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
/*
* This file is part of the Seyon, Copyright (c) 1992-1993 by Muhammad M.
* Saggaf. All rights reserved.
*
* See the file COPYING (1-COPYING) or the manual page seyon(1) for a full
* statement of rights and permissions for this program.
*/
/* -*- Mode: C -*-
* SeWin.c --- Windows/widgets routines
* Author : Muhammad M. Saggaf
* Created On : sometime in 1992
* Last Modified By: system admin
* Last Modified On: Sat Jun 5 16:57:06 1993
* Update Count : 9
* Status : Mostly OK, needs some cleaning up
*/
#include "MultiList.h"
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/List.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Toggle.h>
#include <X11/Xmu/CharSet.h>
#include <setjmp.h>
#include "SeDecl.h"
#include "seyon.h"
extern Widget topLevel;
extern Widget statusMessage;
extern Pixmap progIcon;
void SePopupMsg(), EditSaveFile(), StopMainLoop();
Boolean DoMainLoop;
/*
* does nothing
*/
void DoNothing() { return; }
/*
* distroys a popup
*/
void DestroyShell(widget) Widget widget;
{
Widget shell = GetShell(widget);
XtPopdown(shell);
XtDestroyWidget(shell);
}
void DestroyShellCallBack(widget, child) Widget widget;
XtPointer child;
{ DestroyShell((Widget)child); }
void DestroyParentPopup(widget, child) Widget widget;
XtPointer child;
{ DestroyShellCallBack(widget, child); }
void DismissPopup(widget, upFlag) Widget widget;
XtPointer upFlag;
{
*((Boolean *)upFlag) = False;
DestroyShell(widget);
}
void ResetFlag(widget, flag) Widget widget;
XtPointer flag;
{ *((Boolean *)flag) = False; }
void SetSensitiveOn(widget, callData) Widget widget;
XtPointer callData;
{ XtVaSetValues((Widget)callData, XtNsensitive, True, NULL); }
/*
* creates a button
*/
Widget SeAddButton(name, parent, call_back) String name;
Widget parent;
void (*call_back)();
{
Widget widget;
widget = XtCreateManagedWidget(name, commandWidgetClass, parent, NULL, 0);
XtAddCallback(widget, XtNcallback, call_back, (XtPointer)parent);
return widget;
}
/*
* similar to the above, but also passes client data to the call back
* WCD = with client data
*/
Widget SeAddButtonWCD(name, parent, callBack, clientData) String name;
Widget parent;
void (*callBack)();
XtPointer clientData;
{ return AddButton(name, parent, callBack, clientData); }
Widget AddButton(name, parent, callBack, clientData) String name;
Widget parent;
void (*callBack)();
XtPointer clientData;
{
Widget widget;
widget = XtCreateManagedWidget(name, commandWidgetClass, parent, NULL, 0);
if (callBack)
XtAddCallback(widget, XtNcallback, callBack, clientData);
return widget;
}
Widget SeAddButtonWithClientData(name, parent, call_back,
client_data) String name;
Widget parent;
void (*call_back)();
XtPointer client_data;
{ return SeAddButtonWCD(name, parent, call_back, client_data); }
/*
* creates a label
*/
Widget SeAddLabel(name, parent) String name;
Widget parent;
{ return XtCreateManagedWidget(name, labelWidgetClass, parent, NULL, 0); }
/*
* sets a widget's label
*/
void SeSetLabel(widget, label) Widget widget;
String label;
{ XtVaSetValues(widget, XtNlabel, label, NULL); }
/*
* creates a toggle
*/
Widget SeAddToggleWCD(name, parent, call_back, clientData) String name;
Widget parent;
void (*call_back)();
XtPointer clientData;
{
Widget widget;
widget = XtCreateManagedWidget(name, toggleWidgetClass, parent, NULL, 0);
if (call_back) {
if (clientData == NULL)
clientData = (XtPointer)parent;
XtAddCallback(widget, XtNcallback, call_back, clientData);
}
return widget;
}
Widget SeAddToggle(name, parent, call_back) String name;
Widget parent;
void (*call_back)();
{ return SeAddToggleWCD(name, parent, call_back, NULL); }
/*
* sets or unsets a toggle
*/
void SeSetUnsetToggle(widget, state) Widget widget;
Boolean state;
{ XtVaSetValues(widget, XtNstate, state, NULL); }
/*
* gets a toggle's state
*/
Boolean SeGetToggleState(widget) Widget widget;
{
Boolean state;
XtVaGetValues(widget, XtNstate, &state, NULL);
return state;
}
Widget SePopupRadio(popup_name, parent, name, active, call_back,
clientData) String popup_name;
Widget parent;
String name[];
int active;
void (*call_back)();
XtPointer clientData;
{
Widget popup, mBox, uBox, lBox, toggle, widget;
long i = 0;
popup = AddSimplePopup(popup_name, parent);
mBox = SeAddPaned("mBox", popup);
uBox = SeAddBox("Radio", mBox);
lBox = SeAddBox("lBox", mBox);
toggle = XtVaCreateManagedWidget(name[i], toggleWidgetClass, uBox,
XtNradioData, (XtPointer)(i + 1), NULL);
SeSetUnsetToggle(toggle, (active == i + 1));
XtAddCallback(toggle, XtNcallback, call_back, clientData);
for (i++; name[i]; i++) {
widget =
XtVaCreateManagedWidget(name[i], toggleWidgetClass, uBox, XtNradioGroup,
toggle, XtNradioData, (XtPointer)(i + 1), NULL);
SeSetUnsetToggle(widget, (active == i + 1));
XtAddCallback(widget, XtNcallback, call_back, clientData);
}
SeAddButtonWCD("dismiss", lBox, DestroyParentPopup, (XtPointer)mBox);
PopupCentered(popup, parent);
return toggle;
}
/*
* AddBox: creates a box.
*/
Widget AddBox(name, parent) String name;
Widget parent;
{ return XtCreateManagedWidget(name, boxWidgetClass, parent, NULL, 0); }
Widget SeAddBox(name, parent) String name;
Widget parent;
{ return AddBox(name, parent); }
/*
* AddDialog: creates a dialog widget.
*/
Widget AddDialog(name, parent) String name;
Widget parent;
{ return XtCreateManagedWidget(name, dialogWidgetClass, parent, NULL, 0); }
Widget SeAddDialog(name, parent) String name;
Widget parent;
{ return AddDialog(name, parent); }
/*
* sets a dialog's label
*/
void SeSetDialogValue(dialog, value) Widget dialog;
String value;
{
Arg args;
XtSetArg(args, XtNvalue, value);
XtSetValues(dialog, &args, 1);
}
Widget PopupDialogGetValue(name, parent, callBack, clientData,
defVal) String name;
Widget parent;
void (*callBack)();
XtPointer clientData;
String defVal;
{
Widget popup, dialog;
popup = AddSimplePopup(name, parent);
dialog = AddDialog("dialog", popup);
XtVaSetValues(dialog, XtNvalue, (defVal ? defVal : ""), NULL);
if (clientData == NULL)
clientData = (XtPointer)dialog;
XawDialogAddButton(dialog, "ok", callBack, clientData);
XawDialogAddButton(dialog, "cancel", DestroyShell, (XtPointer)dialog);
return dialog;
}
char getValueDefValue[REG_BUF];
void (*getValueExecProc)();
void GetValueDispatchProc(valueWidget) Widget valueWidget;
{
Widget dialog = XtParent(valueWidget);
strncpy(getValueDefValue, XawDialogGetValueString(dialog), REG_BUF);
DestroyShell(dialog);
(*getValueExecProc)(XtParent(GetShell(valueWidget)), getValueDefValue);
}
void GetValueByPopupOKAction(widget) Widget widget;
{ GetValueDispatchProc(widget); }
void GetValueByPopup(widget, name, callback) Widget widget;
String name;
XtCallbackProc callback;
{
Widget popup, dialog;
getValueExecProc = (void (*)())callback;
popup =
GetShell((dialog = PopupDialogGetValue(name, widget, GetValueDispatchProc,
NULL, getValueDefValue)));
PopupCentered(popup, widget);
}
Widget SePopupDialogGetStringE(popup_name, parent, ok_callback, ok_client_data,
def_val, UL) String popup_name;
Widget parent;
void (*ok_callback)();
XtPointer ok_client_data;
String def_val;
Boolean UL;
{
Widget dialog;
dialog = PopupDialogGetValue(popup_name, parent, ok_callback, ok_client_data,
def_val);
PopupCentered(GetShell(dialog), parent);
return dialog;
}
Widget SePopupDialogGetString(popup_name, parent, ok_callback,
ok_client_data) String popup_name;
Widget parent;
void (*ok_callback)();
XtPointer ok_client_data;
{
return SePopupDialogGetStringE(popup_name, parent, ok_callback,
ok_client_data, NULL, False);
}
/*
* creates a from
*/
Widget SeAddForm(name, parent) String name;
Widget parent;
{ return XtCreateManagedWidget(name, formWidgetClass, parent, NULL, 0); }
Widget AddPaned(name, parent) String name;
Widget parent;
{ return XtCreateManagedWidget(name, panedWidgetClass, parent, NULL, 0); }
Widget SeAddPaned(name, parent) String name;
Widget parent;
{ return AddPaned(name, parent); }
/*
* sets a viewport's dimensions
*/
void SeSetViewportDimensions(viewport, child, max_height) Widget viewport,
child;
Dimension max_height;
{
SeSetWidgetWidth(viewport, SeWidgetWidth(child) + 14);
if (SeWidgetHeight(child) > max_height)
SeSetWidgetHeight(viewport, max_height);
}
/*
* sets a viwport's dimensions according to a child list
*/
void SeSetViewportDimFromList(viewport, list, rows) Widget viewport, list;
Cardinal rows;
{
XFontStruct *font;
Dimension height, internalHeight, rowSpacing, borderWidth;
XtVaGetValues(list, XtNfont, &font, XtNinternalHeight, &internalHeight,
XtNrowSpacing, &rowSpacing, XtNborderWidth, &borderWidth, NULL);
height = font->ascent + font->descent;
height = height * rows + rowSpacing * (rows - 1) +
2 * (internalHeight + borderWidth);
SeSetViewportDimensions(viewport, list, height);
}
/*
* sets a viwport's dimensions according to a child multi-list
*/
void SeSetViewportDimFromMultiList(viewport, list, rows) Widget viewport, list;
Cardinal rows;
{
Dimension rowHeight, borderWidth;
XtVaGetValues(list, XtNrowHeight, &rowHeight, XtNborderWidth, &borderWidth,
NULL);
SeSetViewportDimensions(viewport, list, rowHeight * rows + 2 * borderWidth);
}
Widget GetShell(widget) Widget widget;
{
while ((widget != NULL) && !XtIsShell(widget))
widget = XtParent(widget);
return widget;
}
int IconifyShell(widget) Widget widget;
{
widget = GetShell(widget);
return (int)XIconifyWindow(XtDisplay(widget), XtWindow(widget),
XScreenNumberOfScreen(XtScreen(widget)));
}
/*
* Creates a popup with a bit more control on geometry.
* WG = With Geometry
*/
void CenterShell(widget, geomParent) Widget widget, geomParent;
{
Dimension width, height, borderWidth;
Position x, y, maxPos;
XtVaGetValues(geomParent, XtNwidth, &width, XtNheight, &height, NULL);
XtTranslateCoords(geomParent, (Position)width / 2, (Position)height / 2, &x,
&y);
widget = GetShell(widget);
if (!XtIsRealized(widget))
XtRealizeWidget(widget);
XtVaGetValues(widget, XtNwidth, &width, XtNheight, &height, XtNborderWidth,
&borderWidth, NULL);
width += 2 * borderWidth;
height += 2 * borderWidth;
x -= (Position)width / 2;
if (x < 0)
x = 0;
if (x > (maxPos = (Position)(XtScreen(widget)->width - width)))
x = maxPos;
y -= (Position)height / 2;
if (y < 0)
y = 0;
if (y > (maxPos = (Position)(XtScreen(widget)->height - height)))
y = maxPos;
XtVaSetValues(widget, XtNx, x, XtNy, y, NULL);
}
void CenterShellOnRoot(widget) Widget widget;
{
Dimension width, height, borderWidth;
Position x, y;
widget = GetShell(widget);
if (!XtIsRealized(widget))
XtRealizeWidget(widget);
XtVaGetValues(widget, XtNwidth, &width, XtNheight, &height, XtNborderWidth,
&borderWidth, NULL);
width += 2 * borderWidth;
height += 2 * borderWidth;
x = (Position)(XtScreen(widget)->width - width) / 2;
y = (Position)(XtScreen(widget)->height - height) / 2;
XtVaSetValues(widget, XtNx, x, XtNy, y, NULL);
}
void PositionShell(widget, parent, posStyle) Widget widget;
Widget parent;
int posStyle;
{
Dimension width, height /*, borderWidth*/;
Position x, y;
widget = GetShell(widget);
if (!XtIsRealized(widget))
XtRealizeWidget(widget);
switch (posStyle) {
case SHELLPOS_HWFH:
XtVaGetValues(parent, XtNwidth, &width, XtNheight, &height, NULL);
XtTranslateCoords(parent, (Position)width / 2, (Position)height, &x, &y);
XtVaSetValues(widget, XtNx, x, XtNy, y, NULL);
break;
}
}
Widget SeAddPopupWG(name, parent, x_widget, y_widget, x_offset, y_offset,
topLev, setGeom) String name;
Widget parent, x_widget, y_widget;
Position x_offset, y_offset;
Boolean topLev;
Boolean setGeom;
{
Widget popup;
Position x, y, dummy;
if (x_widget == NULL)
x_widget = parent;
if (y_widget == NULL)
y_widget = x_widget;
if (topLev)
popup = XtVaCreatePopupShell(name, topLevelShellWidgetClass, parent,
XtNiconPixmap, progIcon, NULL);
else
popup = XtVaCreatePopupShell(name, transientShellWidgetClass, parent,
XtNtransientFor, GetShell(parent),
XtNiconPixmap, progIcon, NULL);
if (setGeom) {
XtTranslateCoords(x_widget, x_offset, (Position)0, &x, &dummy);
XtTranslateCoords(y_widget, (Position)0, y_offset, &dummy, &y);
XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
}
return popup;
}
Widget AddSimplePopup(name, parent) String name;
Widget parent;
{
return XtVaCreatePopupShell(name, transientShellWidgetClass, parent,
XtNtransientFor, GetShell(parent), XtNiconPixmap,
progIcon, NULL);
}
Widget SeAddPopup(name, parent) String name;
Widget parent;
{
return SeAddPopupWG(name, parent, NULL, NULL, SeWidgetWidth(parent) / 2,
SeWidgetHeight(parent), False, True);
}
Widget SeAddPopupOffset(name, parent, geomParent) String name;
Widget parent;
Widget geomParent;
{
return SeAddPopupWG(name, parent, geomParent, geomParent, 10, 10, False,
True);
}
Widget SeAddPopupUL(name, parent) String name;
Widget parent;
{ return SeAddPopupOffset(name, parent, XtParent(parent)); }
Widget SeAddPopupSh(name, parent) String name;
Widget parent;
{ return SeAddPopupOffset(name, parent, GetShell(parent)); }
/*
* pops up a message
*/
void SePopupMsg(parent, msg) Widget parent;
String msg;
{
Widget popup, dialog;
Arg args;
popup = SeAddPopup("message", parent);
XtSetArg(args, XtNlabel, msg);
dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, popup, &args, 1);
XawDialogAddButton(dialog, "dismiss", DestroyShell, (XtPointer)dialog);
XtPopup(popup, XtGrabExclusive);
}
void SePopupMsgf(parent, fmt, a, b, c) Widget parent;
String fmt, a, b, c;
{ SePopupMsg(parent, FmtString(fmt, a, b, c)); }
Widget SePopupNotice(parent, title, call_back, msg) Widget parent;
String title;
void (*call_back)();
String msg;
{
Widget popup, dialog;
popup = SeAddPopupUL("notice", parent);
XtVaSetValues(popup, XtNtitle, title, NULL);
dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass, popup, XtNlabel,
msg, NULL);
XawDialogAddButton(dialog, "dismiss", call_back, (XtPointer)dialog);
XtPopup(popup, XtGrabExclusive);
return popup;
}
void SePopupNoticeF(parent, title, call_back, fmt, a, b, c) Widget parent;
String title;
void (*call_back)();
String fmt, a, b, c;
{ SePopupNotice(parent, title, call_back, FmtString(fmt, a, b, c)); }
/*
* almost similar to the above
*/
void SeTransMsg(name, parent) String name;
Widget parent;
{
Widget popup, dialog;
popup = SeAddPopup(name, parent);
dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, popup, NULL, 0);
XawDialogAddButton(dialog, "dismiss", DestroyShell, (XtPointer)dialog);
XtPopupSpringLoaded(popup);
}
/*
* pops up a message to the effect that a feature is not implemented
*/
void NotImplemented(w) Widget w;
{ SeTransMsg("notImplemented", w); }
void SeSetValue(widget, name, value) Widget widget;
String name;
XtArgVal value;
{
Arg args;
XtSetArg(args, name, value);
XtSetValues(widget, &args, 1);
}
/*
* returns a widget's height
*/
Dimension SeWidgetHeight(widget) Widget widget;
{
Dimension height;
Arg args;
XtSetArg(args, XtNheight, &height);
XtGetValues(widget, &args, 1);
return height;
}
/*
* sets a widget's height
*/
void SeSetWidgetHeight(widget, height) Widget widget;
Dimension height;
{
Arg args;
XtSetArg(args, XtNheight, height);
XtSetValues(widget, &args, 1);
}
/*
* returns a widget's width
*/
Dimension SeWidgetWidth(widget) Widget widget;
{
Dimension width;
Arg args;
XtSetArg(args, XtNwidth, &width);
XtGetValues(widget, &args, 1);
return width;
}
/*
* sets a widget's width
*/
void SeSetWidgetWidth(widget, width) Widget widget;
Dimension width;
{
Arg args;
XtSetArg(args, XtNwidth, width);
XtSetValues(widget, &args, 1);
}
/*
* sets the status message
*/
void SetStatusMessage(msg) String msg;
{
SeSetLabel(statusMessage, msg);
/* XFlush(XtDisplay(statusMessage));*/
}
/*
* similar to the above, but accepts a formmat string
*/
void SetStatusMessagef(fmt, a, b, c) String fmt, a, b, c;
{ SetStatusMessage(FmtString(fmt, a, b, c)); }
/*---------------------------------------------------------------------------+
| Beep - rings the terminal bell.
+---------------------------------------------------------------------------*/
void FancyBell(widget) Widget widget;
{
Display *display = XtDisplay(widget);
XKeyboardControl keyboardControl;
XKeyboardState keyboardState;
static int pitch[3] = {200, 400, 500}, duration[3] = {50, 100, 100};
int i;
XGetKeyboardControl(display, &keyboardState);
for (i = 0; i < 3; i++) {
keyboardControl.bell_pitch = pitch[i];
keyboardControl.bell_duration = duration[i];
XChangeKeyboardControl(display, KBBellPitch | KBBellDuration,
&keyboardControl);
XBell(display, 100);
XFlush(display);
usleep(100000L);
}
keyboardControl.bell_pitch = keyboardState.bell_pitch;
keyboardControl.bell_duration = keyboardState.bell_duration;
XChangeKeyboardControl(display, KBBellPitch | KBBellDuration,
&keyboardControl);
}
/*---------------------------------------------------------------------------+
| DoDisplayFile - prepares a pop up file view.
+---------------------------------------------------------------------------*/
Widget DoDisplayFile(parent, fileName) Widget parent;
XtPointer fileName;
{
Widget popup, form;
popup = AddSimplePopup("display", parent);
form = SeAddForm("form", popup);
XtVaCreateManagedWidget(
"text", asciiTextWidgetClass, form, XtNtype, XawAsciiFile, XtNstring,
(String)fileName, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL);
AddButton("dismiss", form, DestroyShell, NULL);
return popup;
}
/*---------------------------------------------------------------------------+
| DisplayFile - pops up a file for viewing.
+---------------------------------------------------------------------------*/
void DisplayFile(parent, fileName) Widget parent;
XtPointer fileName;
{
Widget popup;
popup = DoDisplayFile(parent, fileName);
CenterShell(popup, parent);
XtPopup(popup, XtGrabNone);
}
/*---------------------------------------------------------------------------+
| DialogDisplayFile - prompts for a file name then pops up the file for
| viewing.
+---------------------------------------------------------------------------*/
void DialogDisplayFile(widget) Widget widget;
{ GetValueByPopup(widget, "dialogDisplayFile", DisplayFile); }
/*---------------------------------------------------------------------------+
| EditFile - pops up a file for editing.
+---------------------------------------------------------------------------*/
void EditFile(parent, fileName) Widget parent;
XtPointer fileName;
{
Widget popup, form, text;
popup = AddSimplePopup("edit", parent);
form = SeAddForm("form", popup);
text = XtVaCreateManagedWidget(
"text", asciiTextWidgetClass, form, XtNtype, XawAsciiFile, XtNstring,
(String)fileName, XtNeditType, XawtextEdit, XtNdisplayCaret, True, NULL);
AddButton("save", form, EditSaveFile, (XtPointer)text);
AddButton("dismiss", form, DestroyShell, NULL);
CenterShell(popup, parent);
XtPopup(popup, XtGrabNone);
}
/*---------------------------------------------------------------------------+
| DialogEditFile - prompts for a file name then pops up the file for editing.
+---------------------------------------------------------------------------*/
void DialogEditFile(widget) Widget widget;
{ GetValueByPopup(widget, "dialogEditFile", EditFile); }
/*---------------------------------------------------------------------------+
| EditSaveFile - saves the file being edited.
+---------------------------------------------------------------------------*/
void EditSaveFile(widget, text) Widget widget;
XtPointer text;
{
Widget textSource;
XtVaGetValues((Widget)text, XtNtextSource, &textSource, NULL);
if (XawAsciiSave(textSource) != True)
SePopupMsg(widget, "File Save Failed");
}
void SeAppMainLoop(appContext) XtAppContext appContext;
{
DoMainLoop = True;
while (DoMainLoop)
XtAppProcessEvent(appContext, XtIMAll);
}
void StopMainLoop() { DoMainLoop = False; }
#ifdef notdef
int SeAppMSleep(appContext, msec) XtAppContext appContext;
unsigned long msec;
{
Widget widget = statusMessage;
static Boolean inSleep = False;
if (inSleep)
return -1;
XtAppAddTimeOut(appContext, msec, (XtTimerCallbackProc)StopMainLoop, NULL);
/* XtAddGrab(widget, True, False);*/
inSleep = True;
SeAppMainLoop(appContext);
/* XtRemoveGrab(widget);*/
inSleep = False;
return 0;
}
#endif