-
Notifications
You must be signed in to change notification settings - Fork 2
/
awAlh.c
2030 lines (1689 loc) · 61.1 KB
/
awAlh.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
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 Deutches Elektronen-Synchrotron in der Helmholtz-
* Gemelnschaft (DESY).
* Copyright (c) 2002 Berliner Speicherring-Gesellschaft fuer Synchrotron-
* Strahlung mbH (BESSY).
* Copyright (c) 2002 Southeastern Universities Research Association, as
* Operator of Thomas Jefferson National Accelerator Facility.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* This file is distributed subject to a Software License Agreement found
* in the file LICENSE that is included with this distribution.
\*************************************************************************/
/* awAlh.c */
/************************DESCRIPTION***********************************
This file contains routines for alh menu.
**********************************************************************/
/******************************************************************
Public routines defined in awAlh.c
Widget alhCreateMenu(parent, user_data) Create alh pulldown Menu
void alhFileCallback(widget, item, cbs) File menu items callback
void alhActionCallback(widget, item, cbs) Action menu items callback
void alhViewCallback(widget, item, cbs) View menu items callback
void alhSetupCallback(widget, item, cbs) Setup menu items callback
void alhHelpCallback(widget, item, cbs) Help menu items callback
void awRowWidgets(line, area) Create line widgets
void awUpdateRowWidgets(line) Update line widgets
**************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#ifndef CYGWIN32
#ifndef WIN32
#include <unistd.h>
#include <pwd.h>
#endif
#endif
#include <errno.h>
#include <sys/types.h>
#include <Xm/Xm.h>
#include <Xm/ArrowB.h>
#include <Xm/CascadeBG.h>
#include <Xm/DrawingA.h>
#include <Xm/FileSB.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/LabelG.h>
#include <Xm/PushB.h>
#include <Xm/PushBG.h>
#include <Xm/RowColumn.h>
#include <Xm/SelectioB.h>
#include <Xm/SeparatoG.h>
#include <Xm/TextF.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/AtomMgr.h>
#include <Xm/DragDrop.h>
#include <Xm/CutPaste.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
#include <X11/Xmu/Atoms.h>
#include <X11/Xmu/StdSel.h>
#include "alarm.h"
#include "epicsVersion.h"
#include "ax.h"
#include "alh.h"
#include "axArea.h"
#include "axSubW.h"
#include "line.h"
#include "alLib.h"
#include "sllLib.h"
#include "version.h"
#include "alAudio.h"
/* menu definitions */
#define MENU_FILE_OPEN 10101
#define MENU_FILE_OPEN_OK 10102
#define MENU_FILE_CLOSE 10103
#define MENU_FILE_SAVEAS 10106
#define MENU_FILE_QUIT 10109
#define MENU_VIEW_EXPANDCOLLAPSE1 10200
#define MENU_VIEW_EXPANDBRANCH 10201
#define MENU_VIEW_EXPANDALL 10202
#define MENU_VIEW_COLLAPSEBRANCH 10203
#define MENU_VIEW_PROPERTIES 10204
#define MENU_ACTION_ACK 10300
#define MENU_ACTION_GUIDANCE 10301
#define MENU_ACTION_PROCESS 10302
#define MENU_ACTION_FORCEPV 10303
#define MENU_ACTION_FORCE_MASK 10304
#define MENU_ACTION_MODIFY_MASK 10305
#define MENU_ACTION_BEEPSEVR 10306
#define MENU_ACTION_NOACKTIMER 10307
#define MENU_VIEW_CONFIG 10400
#define MENU_VIEW_OPMOD 10401
#define MENU_VIEW_ALARMLOG 10402
#define MENU_VIEW_CURRENT 10403
#define MENU_VIEW_CMLOG 10404
#define MENU_SETUP_BEEP_MINOR 10500
#define MENU_SETUP_BEEP_MAJOR 10501
#define MENU_SETUP_BEEP_INVALID 10502
#define MENU_SETUP_FILTER_NONE 10503
#define MENU_SETUP_FILTER_ACTIVE 10504
#define MENU_SETUP_FILTER_UNACK 10505
#define MENU_SETUP_SILENCE_INTERVAL_5 10506
#define MENU_SETUP_SILENCE_INTERVAL_10 10507
#define MENU_SETUP_SILENCE_INTERVAL_15 10509
#define MENU_SETUP_SILENCE_INTERVAL_30 10510
#define MENU_SETUP_SILENCE_INTERVAL_60 10511
#define MENU_SETUP_SILENCE_FOREVER 10512
#define MENU_SETUP_ALARMLOG 10513
#define MENU_SETUP_OPMOD 10514
#define MENU_SETUP_TESTBEEPSOUND 10515
#define MENU_HELP_HELP 10900
#define MENU_HELP_ABOUT 10906
/* external variables */
extern Display *display;
extern Pixel silenced_bg_pixel;
extern char alhVersionString[100];
extern char *bg_char[];
extern Pixel bg_pixel[];
extern Pixel channel_bg_pixel;
extern Pixel noack_bg_pixel;
extern struct setup psetup;
extern Widget versionPopup;
extern int _message_broadcast_flag; /* messages sending flag. Albert1*/
extern int messBroadcastDeskriptor;
extern char messBroadcastInfoFileName[250];
int messBroadcastLockDelay=60000; /* 1 min */
extern char *reloadMBString;
extern char *rebootString;
extern int max_not_save_time;
extern int amIsender;
extern int DEBUG;
extern int _main_window_flag;
extern int _mask_color_flag;
char FS_filename[128]; /* Filename for FSBox. Albert*/
struct UserInfo {
char *loginid;
char *real_world_name;
char *myhostname;
char *displayName;
};
extern struct UserInfo userID; /* info about current operator */
/* prototypes for static routines */
static void alhFileCallback( Widget widget, XtPointer calldata, XtPointer cbs);
static void alhActionCallback( Widget widget, XtPointer calldata, XtPointer cbs);
static void alhViewCallback( Widget widget, XtPointer calldata, XtPointer cbs);
static void alhViewBrowserCallback( Widget widget, XtPointer item, XtPointer cbs); /* Albert1 */
static void messBroadcast(Widget widget, XtPointer item, XtPointer cbs); /* Albert1 */
static void alhSetupCallback( Widget widget, XtPointer calldata, XtPointer cbs);
static void alhHelpCallback( Widget widget, XtPointer calldata, XtPointer cbs);
static void browserFBSDialogCbOk(); /* Ok-button for FSBox. Albert*/
static void browserFBSDialogCbCancel(); /* Cancel-button for FSBox. Albert*/
static void writeMessBroadcast(Widget dialog, Widget text_w);
static void helpMessBroadcast(Widget,XtPointer,XtPointer);
static void cancelMessBroadcast(Widget w);
static void messBroadcastFileUnlock();
#ifdef CMLOG
static void awCMLOGstartBrowser(void);
#endif
static void drag (
Widget w,
XEvent *e,
String *params,
Cardinal numParams );
static void dummy (
Widget w,
XEvent *e,
String *params,
Cardinal numParams );
static int g_transInit = 1;
static XtTranslations g_parsedTrans;
static char g_dragTrans[] =
"~Ctrl~Shift<Btn2Down>: startDrag()\n\
Ctrl~Shift<Btn2Down>: dummy()\n\
Shift~Ctrl<Btn2Down>: dummy()\n\
Shift Ctrl<Btn2Down>: dummy()\n\
Shift Ctrl<Btn2Up>: dummy()\n\
Shift~Ctrl<Btn2Up>: dummy()";
static XtActionsRec g_dragActions[] = {
{ "startDrag", (XtActionProc) drag },
{ "dummy", (XtActionProc) dummy }
};
static int g_ddFixedFont_created = 0;
static XFontStruct *g_ddFixedFont = NULL;
static int g_ddgc_created = 0;
static GC g_ddgc = NULL;
static void dragFin (
Widget w,
XtPointer clientData,
XtPointer call_data )
{
Widget icon;
icon = NULL;
XtVaGetValues( w, XmNsourcePixmapIcon, &icon, NULL );
if ( icon ) {
XtDestroyWidget( icon );
}
}
static Boolean cvtSel (
Widget w,
Atom *selection,
Atom *target,
Atom *type_return,
XtPointer *value_return,
unsigned long *len_return,
int *format_return )
{
struct anyLine *line;
int l;
char *pasteData;
char **value = (char**) value_return;
XSelectionRequestEvent* req;
Display* d = XtDisplay( w );
if ( *selection != XA_PRIMARY ) {
return FALSE;
}
req = XtGetSelectionRequest( w, *selection, (XtRequestId) NULL );
XtVaGetValues( w, XmNuserData, &line, NULL );
if ( !line ) {
return FALSE;
}
if ( !line->pname ) {
return FALSE;
}
l = strlen( line->pname );
if ( l < 1 ) {
return FALSE;
}
if (*target == XA_TARGETS(d)) {
Atom* targetP;
caddr_t std_targets;
unsigned long std_length;
XmuConvertStandardSelection( w, req->time, selection, target, type_return,
&std_targets, &std_length, format_return );
*value =
(char*) XtMalloc( sizeof(Atom) * ( (unsigned) std_length + 5 ) );
targetP = *( (Atom**) value );
*targetP++ = XA_STRING;
*targetP++ = XA_TEXT(d);
*len_return = std_length + ( targetP - ( *(Atom **) value) );
memcpy( (void*) targetP, (void*) std_targets,
(size_t)( sizeof(Atom) * std_length ) );
XtFree( (char*) std_targets );
*type_return = XA_ATOM;
*format_return = 32;
return True;
}
if ( *target == XA_STRING ||
*target == XA_TEXT(d) ||
*target == XA_COMPOUND_TEXT(d) ) {
if ( *target == XA_COMPOUND_TEXT(d) ) {
*type_return = *target;
}
else {
*type_return = XA_STRING;
}
pasteData = strdup( line->pname );
*value_return = pasteData;
*len_return = l;
*format_return = 8;
return TRUE;
}
if ( XmuConvertStandardSelection( w, req->time, selection, target,
type_return, (XPointer *) value_return, len_return, format_return ) ) {
return True;
}
return False;
}
static Boolean cvt (
Widget w,
Atom *selection,
Atom *target,
Atom *type_return,
XtPointer *value_return,
unsigned long *len_return,
int *format_return )
{
Display *d;
struct anyLine *line;
Atom MOTIF_DROP;
size_t l;
char *dragData;
d = XtDisplay( w );
MOTIF_DROP = XmInternAtom( d, "_MOTIF_DROP", FALSE );
if ( *selection != MOTIF_DROP ) {
return FALSE;
}
if ( *target != XA_STRING ) {
return FALSE;
}
XtVaGetValues( w, XmNclientData, &line, NULL );
if ( !line->pname ) {
return FALSE;
}
l = strlen( line->pname );
if ( l < 1 ) {
return FALSE;
}
dragData = strdup( line->pname );
*type_return = *target;
*value_return = dragData;
*len_return = l+1;
*format_return = 8;
return TRUE;
}
/* 21 Aug 01 16:04:30 Thomas Birke (Thomas.Birke@mail.bessy.de)
*
* Create a small pixmap to be set as the drag-icon and write the
* PV-names into the pixmap
*/
static Widget mkDragIcon (
Widget w,
struct anyLine *line
) {
Arg args[8];
Cardinal n;
Widget sourceIcon;
int textWidth=0, maxWidth, maxHeight, fontHeight;
unsigned long fg, bg;
XGCValues gcValues;
unsigned long gcValueMask;
char tmpStr[131+1], *str;
Display *disp = XtDisplay(w);
int screenNum = DefaultScreen(disp);
Pixmap sourcePixmap = (Pixmap)NULL;
if ( !g_ddFixedFont_created ) {
g_ddFixedFont_created = 1;
g_ddFixedFont = XLoadQueryFont( disp, "fixed" );
}
#define X_SHIFT 8
#define MARGIN 2
bg = BlackPixel(disp,screenNum);
fg = WhitePixel(disp,screenNum);
fontHeight = g_ddFixedFont->ascent + g_ddFixedFont->descent;
strcpy( tmpStr, "[N/A]" );
str = strdup( line->pname );
if ( str ) {
strncpy( tmpStr, str, 131 );
tmpStr[131] = 0;
}
textWidth = XTextWidth( g_ddFixedFont, tmpStr, strlen(tmpStr) );
maxWidth = X_SHIFT + ( textWidth + MARGIN );
maxHeight = fontHeight + 2 * MARGIN;
sourcePixmap = XCreatePixmap(disp,
RootWindow(disp, screenNum),
maxWidth,maxHeight,
DefaultDepth(disp,screenNum) );
if ( !g_ddgc_created ) {
g_ddgc_created = 1;
g_ddgc = XCreateGC( disp, sourcePixmap, 0, NULL );
}
gcValueMask = GCForeground|GCBackground|GCFunction|GCFont;
gcValues.foreground = bg;
gcValues.background = bg;
gcValues.function = GXcopy;
gcValues.font = g_ddFixedFont->fid;
XChangeGC( disp, g_ddgc, gcValueMask, &gcValues );
XFillRectangle( disp, sourcePixmap, g_ddgc, 0, 0, maxWidth,
maxHeight);
XSetForeground( disp, g_ddgc, fg );
XDrawString( disp, sourcePixmap, g_ddgc,
X_SHIFT, g_ddFixedFont->ascent + MARGIN,
tmpStr, strlen(tmpStr) );
n = 0;
XtSetArg(args[n],XmNpixmap,sourcePixmap); n++;
XtSetArg(args[n],XmNwidth,maxWidth); n++;
XtSetArg(args[n],XmNheight,maxHeight); n++;
XtSetArg(args[n],XmNdepth,DefaultDepth(disp,screenNum)); n++;
sourceIcon = XmCreateDragIcon(XtParent(w),"sourceIcon",args,n);
return sourceIcon;
}
static int startDrag (
struct anyLine *line,
Widget w,
XEvent *e )
{
Atom expList[1];
int status, n;
Arg args[10];
Widget dc;
Widget icon;
/* attempt to put pv name into primary select buffer */
if ( w ) {
XtDisownSelection( w, XA_PRIMARY, CurrentTime );
status = XtOwnSelection( w, XA_PRIMARY, CurrentTime,
cvtSel, (XtLoseSelectionProc) 0, (XtSelectionDoneProc) 0 );
}
icon = mkDragIcon( w, line );
if ( !icon ) return 0;
expList[0] = XA_STRING;
n = 0;
XtSetArg( args[n], XmNexportTargets, expList ); n++;
XtSetArg( args[n], XmNnumExportTargets, 1 ); n++;
XtSetArg( args[n], XmNdragOperations, XmDROP_COPY ); n++;
XtSetArg( args[n], XmNconvertProc, cvt ); n++;
XtSetArg( args[n], XmNsourcePixmapIcon, icon ); n++;
XtSetArg( args[n], XmNclientData, (XtPointer) line ); n++;
dc = XmDragStart( w, e, args, n );
XtAddCallback( dc, XmNdragDropFinishCallback, dragFin, (XtPointer) line );
return 1;
}
static void drag (
Widget w,
XEvent *e,
String *params,
Cardinal numParams )
{
struct anyLine *line;
int stat;
XtVaGetValues( w, XmNuserData, &line, NULL );
stat = startDrag( line, w, e );
}
static void dummy (
Widget w,
XEvent *e,
String *params,
Cardinal numParams )
{
}
/******************************************************
alhCreateMenu
******************************************************/
/* Create ALH MenuBar */
Widget alhCreateMenu(Widget parent,XtPointer user_data)
{
static MenuItem file_menu[] = {
{ "Open ...", PushButtonGadgetClass, 'O', "Ctrl<Key>O", "Ctrl+O",
alhFileCallback, (XtPointer)MENU_FILE_OPEN, (MenuItem *)NULL, 0 },
{ "Save As ...",PushButtonGadgetClass, 'v', NULL, NULL,
alhFileCallback, (XtPointer)MENU_FILE_SAVEAS, (MenuItem *)NULL , 0},
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL },
{ "Close", PushButtonGadgetClass, 'C', NULL, NULL,
alhFileCallback, (XtPointer)MENU_FILE_CLOSE, (MenuItem *)NULL, 0 },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL, 0 },
{NULL},
};
static MenuItem action_menu[] = {
{ "Acknowledge Alarm", PushButtonGadgetClass, 'A', "Ctrl<Key>A", "Ctrl+A",
alhActionCallback, (XtPointer)MENU_ACTION_ACK, (MenuItem *)NULL, 0 },
{ "Display Guidance", PushButtonGadgetClass, 'G', "Ctrl<Key>G", "Ctrl+G",
alhActionCallback, (XtPointer)MENU_ACTION_GUIDANCE, (MenuItem *)NULL, 0 },
{ "Start Related Process", PushButtonGadgetClass, 'P', "Ctrl<Key>P", "Ctrl+P",
alhActionCallback, (XtPointer)MENU_ACTION_PROCESS, (MenuItem *)NULL, 0 },
{ "Force Process Variable ...", ToggleButtonGadgetClass, 'V', "Ctrl<Key>V", "Ctrl+V",
alhActionCallback, (XtPointer)MENU_ACTION_FORCEPV, (MenuItem *)NULL, 0 },
{ "Force Mask ...", ToggleButtonGadgetClass, 'M',"Ctrl<Key>M", "Ctrl+M",
alhActionCallback, (XtPointer)MENU_ACTION_FORCE_MASK, (MenuItem *)NULL, 0 },
{ "Modify Mask Settings ...", ToggleButtonGadgetClass, 'S', "Ctrl<Key>S", "Ctrl+S",
alhActionCallback, (XtPointer)MENU_ACTION_MODIFY_MASK, (MenuItem *)NULL, 0 },
{ "Beep Severity ...", ToggleButtonGadgetClass, 'B', "Ctrl<Key>B", "Ctrl+B",
alhActionCallback, (XtPointer)MENU_ACTION_BEEPSEVR, (MenuItem *)NULL, 0 },
{ "NoAck for One Hour ...", ToggleButtonGadgetClass, 'N', "Ctrl<Key>N", "Ctrl+N",
alhActionCallback, (XtPointer)MENU_ACTION_NOACKTIMER, (MenuItem *)NULL, 0 },
{NULL},
};
/* Albert Kagarmanov new */
#ifndef CYGWIN32
#ifndef WIN32
static MenuItem setup_broadcast_mess_menu[] = {
{ "Common Message", PushButtonGadgetClass, 'C', NULL, NULL,
messBroadcast, (XtPointer)0, (MenuItem *)NULL, 0 },
{ "Stop Logging Message", PushButtonGadgetClass, 'S', NULL, NULL,
messBroadcast, (XtPointer)1, (MenuItem *)NULL, 0 },
{ "Reload", PushButtonGadgetClass, 'R', NULL, NULL,
messBroadcast, (XtPointer)2, (MenuItem *)NULL, 0 },
{ "About", PushButtonGadgetClass, 'H', NULL, NULL,
helpMessBroadcast, (XtPointer)0, (MenuItem *)NULL, 0 },
{NULL},
};
#endif
#endif
/* end Albert Kagarmanov new */
/* ******************************************** Albert1 : ************************************ */
static MenuItem action_menuNew[] = {
{ "Acknowledge Alarm", PushButtonGadgetClass, 'A', "Ctrl<Key>A", "Ctrl+A",
alhActionCallback, (XtPointer)MENU_ACTION_ACK, (MenuItem *)NULL, 0 },
{ "Display Guidance", PushButtonGadgetClass, 'G', "Ctrl<Key>G", "Ctrl+G",
alhActionCallback, (XtPointer)MENU_ACTION_GUIDANCE, (MenuItem *)NULL, 0 },
{ "Start Related Process", PushButtonGadgetClass, 'P', "Ctrl<Key>P", "Ctrl+P",
alhActionCallback, (XtPointer)MENU_ACTION_PROCESS, (MenuItem *)NULL, 0 },
{ "Force Process Variable ...", ToggleButtonGadgetClass, 'V', "Ctrl<Key>V", "Ctrl+V",
alhActionCallback, (XtPointer)MENU_ACTION_FORCEPV, (MenuItem *)NULL, 0 },
{ "Force Mask ...", ToggleButtonGadgetClass, 'M',"Ctrl<Key>M", "Ctrl+M",
alhActionCallback, (XtPointer)MENU_ACTION_FORCE_MASK, (MenuItem *)NULL, 0 },
{ "Modify Mask Settings ...", ToggleButtonGadgetClass, 'S', "Ctrl<Key>S", "Ctrl+S",
alhActionCallback, (XtPointer)MENU_ACTION_MODIFY_MASK, (MenuItem *)NULL, 0 },
{ "Beep Severity ...", ToggleButtonGadgetClass, 'B', "Ctrl<Key>B", "Ctrl+B",
alhActionCallback, (XtPointer)MENU_ACTION_BEEPSEVR, (MenuItem *)NULL, 0 },
{ "NoAck for One Hour ...", ToggleButtonGadgetClass, 'N', "Ctrl<Key>N", "Ctrl+N",
alhActionCallback, (XtPointer)MENU_ACTION_NOACKTIMER, (MenuItem *)NULL, 0 },
/* Albert1 For MESSAGE BROADCAST: */
#ifndef CYGWIN32
#ifndef WIN32
{ "Send Message ...", PushButtonGadgetClass, 'B', "Ctrl<Key>B", "Ctrl+B",
0, 0, (MenuItem *)setup_broadcast_mess_menu, 0 },
#endif
#endif
{NULL},
};
/* ******************************************** End Albert1 ********************************** */
static MenuItem view_menu[] = {
{ "Expand One Level", PushButtonGadgetClass, 'L', "None<Key>plus", "+",
alhViewCallback, (XtPointer)MENU_VIEW_EXPANDCOLLAPSE1, (MenuItem *)NULL, 0 },
{ "Expand Branch", PushButtonGadgetClass, 'B', "None<Key>asterisk", "*",
alhViewCallback, (XtPointer)MENU_VIEW_EXPANDBRANCH, (MenuItem *)NULL, 0 },
{ "Expand All", PushButtonGadgetClass, 'A', "Ctrl<Key>asterisk", "Ctrl+*",
alhViewCallback, (XtPointer)MENU_VIEW_EXPANDALL, (MenuItem *)NULL, 0 },
{ "Collapse Branch", PushButtonGadgetClass, 'C', "None<Key>minus", "-",
alhViewCallback, (XtPointer)MENU_VIEW_COLLAPSEBRANCH, (MenuItem *)NULL, 0 },
{ "", SeparatorGadgetClass, '\0', NULL, NULL,
NULL, NULL, (MenuItem *)NULL, 0 },
{ "Current Alarm History Window", ToggleButtonGadgetClass, 'H', NULL, NULL,
alhViewCallback, (XtPointer)MENU_VIEW_CURRENT, (MenuItem *)NULL, 0 },
{ "Configuration File Window", ToggleButtonGadgetClass, 'f', NULL, NULL,
alhViewCallback, (XtPointer)MENU_VIEW_CONFIG, (MenuItem *)NULL, 0 },
#ifdef CMLOG
{ "Start CMLOG Log Browser", PushButtonGadgetClass, 's', NULL, NULL,
alhViewCallback, (XtPointer)MENU_VIEW_CMLOG, (MenuItem *)NULL, 0 },
#endif
{ "Alarm Log File Window", ToggleButtonGadgetClass, 'r', NULL, NULL,
alhViewCallback, (XtPointer)MENU_VIEW_ALARMLOG, (MenuItem *)NULL, 0 },
{ "Browser For Alarm Log", ToggleButtonGadgetClass, 's', NULL, NULL,
alhViewBrowserCallback, (XtPointer)MENU_VIEW_ALARMLOG, (MenuItem *)NULL, 0 },
{ "Operation Log File Window", ToggleButtonGadgetClass, 'O', NULL, NULL,
alhViewCallback, (XtPointer)MENU_VIEW_OPMOD, (MenuItem *)NULL, 0 },
{ "Browser For Operation Log", ToggleButtonGadgetClass, 'e', NULL, NULL,
alhViewBrowserCallback, (XtPointer)MENU_VIEW_OPMOD, (MenuItem *)NULL, 0 },
{ "Group/Channel Properties Window", ToggleButtonGadgetClass, 'W', NULL, NULL,
alhViewCallback, (XtPointer)MENU_VIEW_PROPERTIES, (MenuItem *)NULL, 0 },
{NULL},
};
static MenuItem setup_beep_menu[] = {
{ "Minor", PushButtonGadgetClass, 'M', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_BEEP_MINOR, (MenuItem *)NULL, 0 },
{ "Major", PushButtonGadgetClass, 'A', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_BEEP_MAJOR, (MenuItem *)NULL, 0 },
{ "Invalid", PushButtonGadgetClass, 'V', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_BEEP_INVALID, (MenuItem *)NULL, 0 },
{NULL},
};
static MenuItem setup_silence_interval_menu[] = {
{ "5 minutes", PushButtonGadgetClass, 0, NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_SILENCE_INTERVAL_5, (MenuItem *)NULL, 0 },
{ "10 minutes", PushButtonGadgetClass, 0, NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_SILENCE_INTERVAL_10, (MenuItem *)NULL, 0 },
{ "15 minutes", PushButtonGadgetClass, 0, NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_SILENCE_INTERVAL_15, (MenuItem *)NULL, 0 },
{ "30 minutes", PushButtonGadgetClass, 0, NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_SILENCE_INTERVAL_30, (MenuItem *)NULL, 0 },
{ "1 hour", PushButtonGadgetClass, 0, NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_SILENCE_INTERVAL_60, (MenuItem *)NULL, 0 },
{NULL},
};
static MenuItem setup_filter_menu[] = {
{ "No filter", PushButtonGadgetClass, 'N', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_FILTER_NONE, (MenuItem *)NULL, 0 },
{ "Active Alarms Only", PushButtonGadgetClass, 'A', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_FILTER_ACTIVE, (MenuItem *)NULL, 0 },
{ "Unacknowledged Alarms Only", PushButtonGadgetClass, 'U', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_FILTER_UNACK, (MenuItem *)NULL, 0 },
{NULL},
};
static MenuItem setup_menu[] = {
{ "Display Filter...", PushButtonGadgetClass, 'F', NULL, NULL,
0, 0, (MenuItem *)setup_filter_menu, 0 },
{ "ALH Beep Severity...", PushButtonGadgetClass, 'B', NULL, NULL,
0, 0, (MenuItem *)setup_beep_menu, 0 },
#ifdef AUDIO_BEEP
{ "Audio Setup...", ToggleButtonGadgetClass, 'D', NULL, NULL,
alhAudioSetupCallback, NULL, (MenuItem *)NULL, 0 },
#endif
{ "Select silence interval...",PushButtonGadgetClass, 'S', NULL, NULL,
0, 0, (MenuItem *)setup_silence_interval_menu, 0 },
{ "Silence Forever", ToggleButtonGadgetClass, 'S', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_SILENCE_FOREVER,(MenuItem *)NULL, 0 },
{ "New Alarm Log File Name...", PushButtonGadgetClass, 'L', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_ALARMLOG, (MenuItem *)NULL, 0 },
{ "New Oper. Log File Name...", PushButtonGadgetClass, 'O', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_OPMOD, (MenuItem *)NULL, 0 },
{ "Test Beep Sound", PushButtonGadgetClass, 'B', NULL, NULL,
alhSetupCallback, (XtPointer)MENU_SETUP_TESTBEEPSOUND,(MenuItem *)NULL, 0 },
{NULL},
};
static MenuItem help_menu[] = {
{ "Help", PushButtonGadgetClass, 'H', "Ctrl<Key>H", "Ctrl+H",
alhHelpCallback, (XtPointer)MENU_HELP_HELP, (MenuItem *)NULL, 0 },
{ "About ALH", PushButtonGadgetClass, 'A', NULL, NULL,
alhHelpCallback, (XtPointer)MENU_HELP_ABOUT, (MenuItem *)NULL, 0 },
{NULL},
};
Widget menubar,widget;
/* Set "Silence Forever" toggleButton initial state */
setup_menu[2].initial_state = psetup.silenceForever;
menubar = XmCreateMenuBar(parent, "menubar", NULL, 0);
widget = buildPulldownMenu(menubar, "File", 'F', TRUE, file_menu, user_data);
if(!_message_broadcast_flag) /* Albert1 */
widget = buildPulldownMenu(menubar, "Action", 'A', TRUE, action_menu, user_data);
else
widget = buildPulldownMenu(menubar, "Action", 'A', TRUE, action_menuNew, user_data);
widget = buildPulldownMenu(menubar, "View", 'V', TRUE, view_menu, user_data);
widget = buildPulldownMenu(menubar, "Setup", 'S', TRUE, setup_menu, user_data);
widget = buildPulldownMenu(menubar, "Help", 'H', TRUE, help_menu, user_data);
/* Make sure Help on MenuBar item is right adjusted */
XtVaSetValues(menubar, XmNtopAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(menubar, XmNrightAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(menubar, XmNleftAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(menubar, XmNmenuHelpWidget, widget, NULL);
XtManageChild(menubar);
return(menubar);
}
/******************************************************
alhFileCallback
******************************************************/
static void alhFileCallback(Widget widget,XtPointer calldata,XtPointer cbs)
{
ALINK *area;
int item=(long)calldata;
XtVaGetValues(widget, XmNuserData, &area, NULL);
switch (item){
case MENU_FILE_OPEN:
/* New Name for Config File */
/* Display the config_changed warning dialog */
if (area->changed){
createActionDialog(area->form_main,XmDIALOG_WARNING,
"Config file settings have Changed. Do you wish to continue?",
(XtCallbackProc)alhFileCallback,
(XtPointer)MENU_FILE_OPEN_OK, (XtPointer)area);
break;
}
area->managed = FALSE;
createFileDialog(area->form_main,
(void *)fileSetupCallback, (XtPointer)FILE_CONFIG,
(void *)fileCancelCallback,(XtPointer)area,
(XtPointer)area,
"Alarm Configuration File",CONFIG_PATTERN,psetup.configDir);
break;
case MENU_FILE_OPEN_OK:
area->managed = FALSE;
createFileDialog(area->form_main,
(void *)fileSetupCallback, (XtPointer)FILE_CONFIG,
(void *)fileCancelCallback,(XtPointer)area,
(XtPointer)area,
"Alarm Configuration File",CONFIG_PATTERN,psetup.configDir);
break;
case MENU_FILE_SAVEAS:
/* New Name for Save Config File */
createFileDialog(area->form_main,
(void *)fileSetupCallback, (XtPointer)FILE_SAVEAS,
(void *)XtUnmanageChild,(XtPointer)0,
(XtPointer)area,
"Save Alarm Configuration File",CONFIG_PATTERN,psetup.configDir);
break;
case MENU_FILE_CLOSE:
/* "Close" was selected. */
if (_main_window_flag)
exit_quit(area->toplevel,(XtPointer)area,(XtPointer)area);
else
unmapArea_callback(area->toplevel,area->form_main,(XmAnyCallbackStruct *)cbs);
break;
case MENU_FILE_QUIT:
createActionDialog(area->toplevel,XmDIALOG_WARNING,
"Exit Alarm Handler?",(XtCallbackProc)exit_quit,
(XtPointer)area, (XtPointer)area);
break;
}
}
/******************************************************
alhActionCallback
******************************************************/
static void alhActionCallback(Widget widget,XtPointer calldata,XtPointer cbs)
{
int item=(long)calldata;
ALINK *area;
Widget parent;
GCLINK *link;
struct anyLine *line;
WLINE *wline;
XtVaGetValues(widget, XmNuserData, &area, NULL);
switch (item){
case MENU_ACTION_ACK:
/* Acknowledge Alarm */
link = (GCLINK *)area->selectionLink;
if (link){
line = (struct anyLine *)link->lineTreeW;
if (line && line->pwindow == (void *)area->selectionWindow ){
ack_callback(widget,line,(XmAnyCallbackStruct *)cbs);
}
else {
line = (struct anyLine *)link->lineGroupW;
if (line && line->pwindow == (void *)area->selectionWindow ){
ack_callback(widget,line,(XmAnyCallbackStruct *)cbs);
}
}
} else {
createDialog(area->form_main,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
case MENU_ACTION_GUIDANCE:
/* Display Guidance */
link = (GCLINK *)area->selectionLink;
line = (struct anyLine *)link->lineTreeW;
if (! line || line->pwindow != (void *)area->selectionWindow )
line = (struct anyLine *)link->lineGroupW;
if (line){
wline=(WLINE *)line->wline;
guidanceCallback(wline->guidance,(GCLINK *)link,(XmAnyCallbackStruct *) cbs);
}
else {
createDialog(area->form_main,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
case MENU_ACTION_PROCESS:
/* Start Related Process */
link = (GCLINK *)area->selectionLink;
if (link){
if (alProcessExists(link)){
relatedProcess_callback(widget,link, cbs);
} else {
if (((GCLINK *)link)->pgcData->alias){
createDialog(area->form_main,XmDIALOG_WARNING,"No related process for ",
link->pgcData->alias);
} else {
createDialog(area->form_main,XmDIALOG_WARNING,"No related process for ",
link->pgcData->name);
}
}
} else {
createDialog(area->form_main,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
case MENU_ACTION_FORCEPV:
if (area->selectionLink) {
forcePVShowDialog(area, widget);
} else {
parent = area->form_main;
createDialog(parent,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
case MENU_ACTION_FORCE_MASK:
if (area->selectionLink) {
forceMaskShowDialog(area, widget);
} else {
parent = area->form_main;
createDialog(parent,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
case MENU_ACTION_MODIFY_MASK:
if (area->selectionLink) {
maskShowDialog(area, widget);
} else {
parent = area->form_main;
createDialog(parent,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
case MENU_ACTION_BEEPSEVR:
if (area->selectionLink) {
beepSevrShowDialog(area, widget);
} else {
parent = area->form_main;
createDialog(parent,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
case MENU_ACTION_NOACKTIMER:
if (area->selectionLink) {
noAckShowDialog(area, widget);
} else {
parent = area->form_main;
createDialog(parent,XmDIALOG_WARNING,
"Please select an alarm group or channel first."," ");
}
break;
}
}
/******************************************************
alhViewCallback
******************************************************/
static void alhViewCallback(Widget widget,XtPointer calldata,XtPointer cbs)
{
int item=(long)calldata;
ALINK *area;
void *link;
struct subWindow *treeWindow;
XtVaGetValues(widget, XmNuserData, &area, NULL);
treeWindow = (struct subWindow *)area->treeWindow;
switch (item){
case MENU_VIEW_EXPANDCOLLAPSE1:
/* Expand 1 level */
link = treeWindow->selectionLink;
if (link) displayNewViewTree(area,link,EXPANDCOLLAPSE1);
else createDialog(area->form_main,XmDIALOG_WARNING,"Please select an alarm group first."," ");
break;
case MENU_VIEW_EXPANDBRANCH:
/* Expand Branch */
link = treeWindow->selectionLink;
if (link )displayNewViewTree(area,link,EXPAND);
else createDialog(area->form_main,XmDIALOG_WARNING,"Please select an alarm group first."," ");
break;
case MENU_VIEW_EXPANDALL:
/* Expand all */
displayNewViewTree(area,(GLINK *)sllFirst(area->pmainGroup),EXPAND);
break;