-
Notifications
You must be signed in to change notification settings - Fork 2
/
axArea.c
1009 lines (860 loc) · 31 KB
/
axArea.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.
\*************************************************************************/
/* axArea.c */
/************************DESCRIPTION***********************************
Routines for main window widgets
**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Xm/AtomMgr.h>
#include <Xm/CascadeBG.h>
#include <Xm/Form.h>
#include <Xm/LabelG.h>
#include <Xm/PanedW.h>
#include <Xm/Protocols.h>
#include <Xm/PushB.h>
#include <Xm/PushBG.h>
#include <Xm/Scale.h>
#include <Xm/SeparatoG.h>
#include <Xm/Text.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#include "cadef.h"
#include "alarm.h"
#include "ALH.bit"
#include "alh.h"
#include "line.h"
#include "axArea.h"
#include "sllLib.h"
#include "ax.h"
Pixmap ALH_pixmap;
static char *silenceString[] = {"Off","On"};
static const char *executionStateString[] = {"Active","Passive"};
static char *disabledForcePVCountString[] = {" ","Disabled forcePVs:"};
/* global variables */
extern int _global_flag;
extern int _passive_flag;
extern int toBeConnectedCount;
extern int DEBUG;
extern SLIST *areaList;
extern struct setup psetup;
extern Display *display;
extern char *alhAlarmSeverityString[];
extern int _main_window_flag;
extern int (*default_display_filter)(GCLINK *);
extern const char *executionModeString[];
ALINK *alhArea;
/* forward definitions */
static ALINK *setupArea( ALINK *areaOld);
static void scale_callback(Widget widget,ALINK *area,XmScaleCallbackStruct *cbs);
/******************************************************
buildPulldownMenu - Generic menu creation
******************************************************/
Widget buildPulldownMenu( Widget parent, char *menu_title, char menu_mnemonic,
int tearOff, MenuItem *items, XtPointer user_data)
{
Widget PullDown, cascade, widget;
int i;
XmString str;
WidgetClass *xmclass[] = { &xmPushButtonGadgetClass, &xmSeparatorGadgetClass, &xmToggleButtonGadgetClass };
/* Pulldown menus are built from cascade buttons, so this function
* also includes pullright menus. Create the menu, the cascade button
* that owns the menu, and then the submenu items.
*/
PullDown = XmCreatePulldownMenu(parent, "_pulldown", NULL, 0);
str = XmStringCreateSimple(menu_title);
cascade = XtVaCreateManagedWidget(menu_title,
xmCascadeButtonGadgetClass, parent,
XmNsubMenuId, PullDown,
XmNlabelString, str,
XmNmnemonic, menu_mnemonic,
(XtPointer)NULL);
XmStringFree(str);
# if 0 /* DO NOT Use TEAROFF FEATURE. TORNOFF MENUS CANNOT BE CLOSED */
#if XmVersion && XmVersion >= 1002
if (tearOff){
/* Enable pulldown menu tearoff functionality */
XtVaSetValues(PullDown, XmNtearOffModel, XmTEAR_OFF_ENABLED, NULL);
}
#endif
#endif
/* Now add the menu items */
for (i = 0; items[i].label != NULL; i++) {
/* If subitems exist, create the pull-right menu by calling this
* function recursively. Since the function returns a cascade
* button, the widget returned is used..
*/
if (items[i].subitems)
widget = buildPulldownMenu(PullDown,
items[i].label, items[i].mnemonic, FALSE, items[i].subitems, user_data);
else {
widget = XtVaCreateManagedWidget(items[i].label,
*xmclass[items[i].class], PullDown,
XmNuserData, user_data,
NULL);
/* Make spacing of toggle button items the same as pushButtons */
if (xmclass[items[i].class] == &xmToggleButtonWidgetClass ||
xmclass[items[i].class] == &xmToggleButtonGadgetClass)
XtVaSetValues(widget, XmNmarginHeight, 1, NULL);
/* Set initial state of of toggle button items */
if (xmclass[items[i].class] == &xmToggleButtonWidgetClass ||
xmclass[items[i].class] == &xmToggleButtonGadgetClass)
XmToggleButtonSetState(widget,(Boolean)items[i].initial_state,FALSE);
}
/* Whether the item is a real item or a cascade button with a
* menu, it can still have a mnemonic. */
if (items[i].mnemonic)
XtVaSetValues(widget, XmNmnemonic, items[i].mnemonic, NULL);
/* any item can have an accelerator, except cascade menus. But,
* we don't worry about that; we know better in our declarations. */
if (items[i].accelerator) {
str = XmStringCreateSimple(items[i].accel_text);
XtVaSetValues(widget,
XmNaccelerator, items[i].accelerator,
XmNacceleratorText, str,
NULL);
XmStringFree(str);
}
/* again, anyone can have a callback -- however, this is an
* activate-callback. This may not be appropriate for all items.
*/
if (items[i].callback)
XtAddCallback(widget,
(xmclass[items[i].class] == &xmToggleButtonWidgetClass ||
xmclass[items[i].class] == &xmToggleButtonGadgetClass)?
XmNvalueChangedCallback : /* ToggleButton class */
XmNactivateCallback, /* PushButton class */
items[i].callback, items[i].callback_data);
}
return cascade;
}
/***************************************************
setupConfig - Setup area with new config.file
****************************************************/
void setupConfig(char *filename,int program,ALINK *areaOld)
{
ALINK *area;
struct mainGroup *pmainGroup = NULL;
XmString str;
SNODE *proot;
static int firstTime = TRUE;
short beepSevrOld;
int holdToBeConnectedCount;
/* initialize channel access */
if (program == ALH) {
if (firstTime) {
firstTime = FALSE;
alCaInit();
}
}
/* create main group */
pmainGroup = alAllocMainGroup();
if (!pmainGroup ) {
if (areaOld)
createDialog(areaOld->form_main,XmDIALOG_ERROR,
"mainGroup allocation error: ",filename);
return;
}
/* reinitialize beep severity */
beepSevrOld = psetup.beepSevr;
psetup.beepSevr = 1;
/* Read the config file or create a minimal config file */
if (filename[0] != '\0'){
if ( program == ALH) {
toBeConnectedCount =0;
alLogOpModMessage(0,0, "Setup Config File : %s",filename);
alGetConfig(pmainGroup,filename,CA_CONNECT_YES);
/* now lets give the connection layer a little time
* to establish communications */
holdToBeConnectedCount = toBeConnectedCount;
while (TRUE) {
alCaPend(1.0);
if (toBeConnectedCount == holdToBeConnectedCount) break;
holdToBeConnectedCount = toBeConnectedCount;
}
alSetNotConnected(pmainGroup);
alPutGblAckT(pmainGroup);
}
else {
/* Log new configfile filename */
alLogOpModMessage(0,0, "Setup Config File : %s",filename);
alGetConfig(pmainGroup,filename,CA_CONNECT_NO);
}
if (sllFirst(pmainGroup)) strcpy(psetup.configFile,filename);
} else{
if (program == ACT) alCreateConfig(pmainGroup);
else {
if (areaOld) {
psetup.beepSevr = beepSevrOld;
areaOld->managed = TRUE;
errMsg ("ALH Error: Invalid config file: %s\n",filename);
return;
}
}
}
if ( sllFirst(pmainGroup)) {
proot = sllFirst(pmainGroup);
/* initialize unused area */
area = setupArea(areaOld);
/* initialize subWindow create/modify line routines */
setLineRoutine(area,area->treeWindow,program);
setLineRoutine(area,area->groupWindow,program);
pmainGroup->area = area;
area->programId = program;
area->pmainGroup = pmainGroup;
area->changed = FALSE;
/* activate runtime window for ALH */
if (program == ALH){
area->blinkString = alAlarmGroupName((GLINK *)proot);
alHighestSystemSeverity((GLINK *)proot);
if (_main_window_flag) showMainWindow(area);
else createRuntimeWindow(area);
}
/* create/display main window for ACT */
if (program == ACT ) showMainWindow(area);
createConfigDisplay(area,EXPANDCOLLAPSE1);
if (program == ALH ) alhArea = area;
area->managed = TRUE;
/* update filename string on main window */
if (area->label_filename){
str = XmStringCreateSimple(psetup.configFile);
XtVaSetValues(area->label_filename,
XmNlabelString, str,
NULL);
XmStringFree(str);
}
/* update dialog windows */
axUpdateDialogs(area);
/* unmap dialog */
/*
createDialog(0,0," "," ");
*/
} else {
free(pmainGroup);
if (areaOld) {
psetup.beepSevr = beepSevrOld;
areaOld->managed = TRUE;
errMsg ("ALH Error: Invalid config file: %s\n",filename);
} else {
errMsg ("ALH Error: Invalid config file: %s\n",filename);
exit_quit(NULL, NULL, NULL);
}
}
return;
}
/******************************************************
markActiveWidget - Mark active widget border
******************************************************/
void markActiveWidget(ALINK *area,Widget newWidget)
{
/* NOTE: this routine not implemented yet. Border looks YUK!
if (area->selectionWidget == newWidget ) return;
if (area->selectionWidget) {
XtVaSetValues(area->selectionWidget,
XmNborderWidth, 0,
NULL);
}
if (newWidget) {
XtVaSetValues(newWidget,
XmNborderWidth, 1,
NULL);
}
area->selectionWidget = newWidget;
*/
}
/******************************************************
setupArea - Initialize an area
******************************************************/
static ALINK *setupArea(ALINK *areaOld)
{
ALINK *area;
SNODE *proot;
if (!areaOld){
/* create work area linked list */
if (!areaList){
areaList = (SLIST *)calloc(1,sizeof(SLIST));
sllInit(areaList);
}
/* find an unused existing work area */
area = (ALINK *)sllFirst(areaList);
while (area){
if (area->managed == FALSE || area->pmainGroup == NULL) break;
area = (ALINK *)sllNext(area);
}
} else area = areaOld;
/* reinitialize an unused existing work area */
if (area){
area->managed = FALSE;
/* unmark selected widgets */
markSelectedWidget(area->treeWindow,NULL);
markSelectedWidget(area->groupWindow,NULL);
markActiveWidget(area,0);
/* Delete the current config */
if (area->pmainGroup){
/* cancel channel access */
alCaCancel(area->pmainGroup);
proot = sllFirst(area->pmainGroup);
if (proot) alDeleteGroup((GLINK *)proot);
alHeartbeatPVRemove(area->pmainGroup);
free(area->pmainGroup);
area->pmainGroup = NULL;
}
/* or create a new work area */
} else {
area=(ALINK *)calloc(1,sizeof(ALINK));
sllAdd(areaList,(SNODE *)area);
/* Set alarm filter to default value */
area->viewFilter = default_display_filter;
area->blinkString = NULL;
area->runtimeToplevel = NULL;
area->treeWindow = createSubWindow(area);
area->groupWindow = createSubWindow(area);
}
/* Reset count of disabled forcePVs */
area->disabledForcePVCount = 0;
/* Reset data for Current alarm window */
resetCurrentAlarmWindow(area);
/* Make NULL the selected group for Area */
area->selectionLink = NULL;
/* initialize the subWindows */
initializeSubWindow(area->treeWindow);
initializeSubWindow(area->groupWindow);
return area;
}
/******************************************************
createMainWindowWidgets - Create area Main Window widgets
******************************************************/
void createMainWindowWidgets(ALINK *area)
{
char actTitle[] = "Alarm Configuration Tool";
char alhTitle[] = "Alarm Handler";
char execMode[50] = "Execution Status: ";
XmString str;
char *app_name;
char *title_str;
size_t len = 0;
Widget label_executionMode;
if (area->toplevel) return;
/* create toplevel shell */
app_name = (char*) calloc(1,strlen(programName)+6);
strcpy(app_name, programName);
strcat(app_name, "-main");
area->toplevel = XtAppCreateShell(app_name, programName,
applicationShellWidgetClass, display, NULL, 0);
free(app_name);
if (area->blinkString) len = strlen(area->blinkString);
if (area->programId == ACT){
title_str = (char*) calloc(1,strlen(actTitle)+len+3);
strcpy(title_str, actTitle);
} else {
title_str = (char*) calloc(1,strlen(alhTitle)+len+3);
strcpy(title_str, alhTitle);
}
if (area->blinkString){
strcat(title_str, ": ");
strcat(title_str, area->blinkString);
}
XtVaSetValues(area->toplevel,
XmNtitle, title_str,
XmNiconName, area->blinkString,
NULL);
free(title_str);
/* Create form_main for toplevel */
area->form_main = XtVaCreateManagedWidget("form_main",
xmFormWidgetClass, area->toplevel,
XmNuserData, (XtPointer)area,
NULL);
pixelData(area->form_main);
if (!ALH_pixmap) axMakePixmap(area->form_main);
#ifndef WIN32
XtVaSetValues(area->toplevel, XmNiconPixmap, ALH_pixmap, NULL);
#endif
/* Modify the window manager menu "close" callback */
{
Atom WM_DELETE_WINDOW;
XtVaSetValues(area->toplevel,
XmNdeleteResponse, XmDO_NOTHING,
NULL);
WM_DELETE_WINDOW = XmInternAtom(XtDisplay(area->form_main),
"WM_DELETE_WINDOW", False);
if (_main_window_flag)
XmAddWMProtocolCallback(area->toplevel,WM_DELETE_WINDOW,
(XtCallbackProc) exit_quit, (XtPointer) area);
else
XmAddWMProtocolCallback(area->toplevel,WM_DELETE_WINDOW,
(XtCallbackProc) unmapArea_callback, (XtPointer) area->form_main);
}
/* Create MenuBar */
if (area->programId == ACT){
area->menubar = actCreateMenu(area->form_main, (XtPointer)area);
} else {
area->menubar = alhCreateMenu(area->form_main, (XtPointer)area);
}
/* Create message Area Form */
area->messageArea = XtVaCreateWidget("message_area",
xmFormWidgetClass, area->form_main,
XmNallowOverlap, FALSE,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
/* Create scale in the MessageArea to change display split */
area->scale = XtVaCreateManagedWidget("scale",
xmScaleWidgetClass, area->messageArea,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNorientation, XmHORIZONTAL,
XmNuserData, (XtPointer)area,
(XtPointer)NULL);
/* Add scale valueChanged Callback */
XtAddCallback(area->scale, XmNvalueChangedCallback, (XtCallbackProc)scale_callback, area);
/* Add scale drag Callback */
XtAddCallback(area->scale, XmNdragCallback, (XtCallbackProc)scale_callback, area);
/* Create execution mode indicator label for the messageArea */
strcat(execMode,executionModeString[_global_flag]);
strcat(execMode," ");
strcat(execMode,executionStateString[_passive_flag]);
label_executionMode = XtVaCreateManagedWidget(
execMode,
xmLabelGadgetClass, area->messageArea,
XmNmarginHeight, 3,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->scale,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 1,
(XtPointer)NULL);
/* Create group alarm decoder label for the messageArea */
area->label_mask = XtVaCreateManagedWidget(
"Mask <CDATL>: <Cancel,Disable,noAck,noackT,noLog> H=noAck 1hr timer",
xmLabelGadgetClass, area->messageArea,
XmNmarginHeight, 3,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, label_executionMode,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 1,
NULL);
/* Create group alarm decoder label for the messageArea */
area->label_groupAlarm = XtVaCreateManagedWidget(
"Group Alarm Counts: (ERROR,INVALID,MAJOR,MINOR,NOALARM)",
xmLabelGadgetClass, area->messageArea,
XmNmarginHeight, 3,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->label_mask,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 1,
NULL);
/* Create filenameTitle label for the messageArea */
area->label_channelAlarm = XtVaCreateManagedWidget(
"Channel Alarm Data: <Status,Severity>,<Unack Severity>",
xmLabelGadgetClass, area->messageArea,
XmNmarginHeight, 3,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->label_groupAlarm,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 1,
NULL);
/* Create filenameTitle label for the messageArea */
area->label_filenameTitle = XtVaCreateManagedWidget("Filename: ",
xmLabelGadgetClass, area->messageArea,
XmNmarginHeight, 3,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->label_channelAlarm,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 1,
NULL);
/* Create filename label for the messageArea */
str = XmStringCreateSimple(psetup.configFile);
area->label_filename = XtVaCreateManagedWidget("label_filename",
xmLabelGadgetClass, area->messageArea,
XmNlabelString, str,
XmNshadowThickness, 2,
XmNalignment, XmALIGNMENT_BEGINNING,
/*
xmTextWidgetClass, area->messageArea,
XmNeditable, FALSE,
XmNmarginHeight, 0,
XmNresizeWidth, FALSE,
XmNvalue, psetup.configFile,
XmNcursorPositionVisible, FALSE,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 50,
*/
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->label_channelAlarm,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, area->label_filenameTitle,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XmStringFree(str);
/* Create a Silence Selected Minutes Toggle Button in the messageArea */
area->silenceMinutes = 30;
area->silenceSelectedMinutes = XtVaCreateManagedWidget("Silence 30 minutes",
xmToggleButtonGadgetClass, area->messageArea,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->scale,
XmNrightAttachment, XmATTACH_FORM,
XmNuserData, (XtPointer)area,
NULL);
/* Create a Silence Current Toggle Button in the messageArea */
area->silenceCurrent = XtVaCreateManagedWidget("Silence current",
xmToggleButtonGadgetClass, area->messageArea,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->silenceSelectedMinutes,
XmNrightAttachment, XmATTACH_FORM,
XmNuserData, (XtPointer)area,
NULL);
/* Create SilenceForever string for the messageArea */
str = XmStringCreateSimple(silenceString[psetup.silenceForever]);
area->silenceForever = XtVaCreateManagedWidget("silenceForever",
xmLabelGadgetClass, area->messageArea,
XmNlabelString, str,
XmNshadowThickness, 2,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->silenceCurrent,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XmStringFree(str);
/* Create SilenceForeverLabel string for the messageArea */
str = XmStringCreateSimple("Silence Forever: ");
area->silenceForeverLabel = XtVaCreateManagedWidget("silenceForeverLabel",
xmLabelGadgetClass, area->messageArea,
XmNshadowThickness, 2,
XmNlabelString, str,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->silenceCurrent,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, area->silenceForever,
NULL);
XmStringFree(str);
/* Create BeepSeverity string for the messageArea */
str = XmStringCreateSimple(alhAlarmSeverityString[psetup.beepSevr]);
area->beepSeverity = XtVaCreateManagedWidget("beepSeverity",
xmLabelGadgetClass, area->messageArea,
XmNlabelString, str,
XmNshadowThickness, 2,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->silenceForever,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XmStringFree(str);
/* Create BeepSeverityLabel string for the messageArea */
str = XmStringCreateSimple("ALH Beep Severity:");
area->beepSeverityLabel = XtVaCreateManagedWidget("beepSeverityLabel",
xmLabelGadgetClass, area->messageArea,
XmNshadowThickness, 2,
XmNlabelString, str,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->silenceForever,
XmNrightAttachment, XmATTACH_WIDGET,
XmNrightWidget, area->beepSeverity,
NULL);
XmStringFree(str);
XtAddCallback(area->silenceSelectedMinutes, XmNvalueChangedCallback,
(XtCallbackProc)silenceSelectedMinutes_callback,area);
XtAddCallback(area->silenceCurrent, XmNvalueChangedCallback,
(XtCallbackProc)silenceCurrent_callback,area);
/* Create Disabled ForcePV Count string for the messageArea */
str = XmStringCreateSimple(disabledForcePVCountString[0]);
area->disabledForcePVCountLabel = XtVaCreateManagedWidget("disabledForcePVCountLabel",
xmLabelGadgetClass, area->messageArea,
XmNshadowThickness, 2,
XmNlabelString, str,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->beepSeverity,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XmStringFree(str);
/* manage the message area */
XtManageChild(area->messageArea);
/* Create a Form for the treeWindow */
area->treeWindowForm = XtVaCreateManagedWidget("treeForm",
xmFormWidgetClass, area->form_main,
XmNborderWidth, 1,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->menubar,
XmNbottomAttachment, XmATTACH_WIDGET,
XmNbottomWidget, area->messageArea,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 50,
NULL);
XtAddEventHandler(area->form_main, StructureNotifyMask,
FALSE, (XtEventHandler)exposeResizeCallback, (XtPointer *)area->treeWindow);
createSubWindowWidgets(area->treeWindow,area->treeWindowForm);
/* Create a Form for the groupWindow */
area->groupWindowForm = XtVaCreateManagedWidget("groupForm",
xmFormWidgetClass, area->form_main,
XmNborderWidth, 1,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, area->menubar,
XmNbottomAttachment, XmATTACH_WIDGET,
XmNbottomWidget, area->messageArea,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 50,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XtAddEventHandler(area->form_main, StructureNotifyMask,
FALSE, (XtEventHandler)exposeResizeCallback, (XtPointer *)area->groupWindow);
createSubWindowWidgets(area->groupWindow,area->groupWindowForm);
}
/******************************************************
createMainWindow_callback
******************************************************/
void showMainWindow(ALINK *area)
{
if (area->toplevel == 0){
area->mapped = FALSE;
createMainWindowWidgets(area);
XtRealizeWidget(area->toplevel);
}
if (area->mapped == FALSE){
XMapWindow(XtDisplay(area->toplevel),XtWindow(area->toplevel));
area->mapped = TRUE;
redraw(area->treeWindow,0);
/* mark first line as treeWindow selection */
defaultTreeSelection(area);
}
else {
XRaiseWindow(XtDisplay(area->toplevel), XtWindow(area->toplevel));
redraw(area->treeWindow,0);
}
}
/***************************************************
isTreeWindow - Returns TRUE if area is a treeWindow
****************************************************/
int isTreeWindow(ALINK *area,void * subWindow)
{
if (area->treeWindow == subWindow ) return(TRUE);
else return(FALSE);
}
/******************************************************
unmapArea_callback
******************************************************/
void unmapArea_callback(Widget main,Widget w,XmAnyCallbackStruct *cbs)
{
ALINK *area;
XtVaGetValues(w, XmNuserData, &area, NULL);
XUnmapWindow(XtDisplay(main),XtWindow(main));
area->mapped = FALSE;
}
/******************************************************
scale_callback - Scale moved callback
******************************************************/
static void scale_callback(Widget widget,ALINK *area,XmScaleCallbackStruct *cbs)
{
int value;
value = Mmin(95,Mmax(5,cbs->value));
XtVaSetValues(area->groupWindowForm,
XmNleftPosition, value,
NULL);
XtVaSetValues(area->treeWindowForm,
XmNrightPosition, value,
NULL);
}
/***************************************************
markSelectionArea - Set area selection values
****************************************************/
void markSelectionArea(ALINK *area,struct anyLine *line)
{
/* Save selection data */
if (!line){
area->selectionLink = 0;
area->selectionType = 0;
area->selectionWindow = 0;
} else {
area->selectionLink = line->link;
area->selectionType = line->linkType;
area->selectionWindow = (void *)line->pwindow;
}
return;
}
/***************************************************
axMakePixmap
****************************************************/
void axMakePixmap(Widget w)
{
Pixel fg,bg;
int depth;
/*
* create icon pixmap
*/
if (!ALH_pixmap){
/*
* get colors and depth
*/
XtVaGetValues(w,
XmNforeground, &fg,
XmNbackground, &bg,
XmNdepth, &depth,
NULL);
ALH_pixmap = XCreatePixmapFromBitmapData(XtDisplay(w),
RootWindowOfScreen(XtScreen(w)),
(char *)AH_bits,AH_width,AH_height,fg,bg,depth);
}
return;
}
/***************************************************
changeBeepSeverityText
****************************************************/
void changeBeepSeverityText(ALINK *area)
{
XmString str;
if (area->beepSeverity) {
str = XmStringCreateSimple(alhAlarmSeverityString[psetup.beepSevr]);
XtVaSetValues(area->beepSeverity,
XmNlabelString, str,
NULL);
XmStringFree(str);
}
}
/***************************************************
changeSilenceForeverText
****************************************************/
void changeSilenceForeverText(ALINK *area)
{
XmString str;
if (area->silenceForever) {
str = XmStringCreateSimple(silenceString[psetup.silenceForever]);
XtVaSetValues(area->silenceForever,
XmNlabelString, str,
NULL);
XmStringFree(str);
}
}
/***************************************************
updateDisabledForcePVCount
****************************************************/
void updateDisabledForcePVCount(ALINK *area,int value)
{
area->disabledForcePVCount += value;
}
/***************************************************
changeDisabledForcePVText
****************************************************/
void changeDisabledForcePVText(ALINK *area)
{
XmString str;
char buff[24];
if (area->disabledForcePVCountLabel) {
if (area->disabledForcePVCount) {
sprintf(buff,"%-.18s %4.4d",
disabledForcePVCountString[1],area->disabledForcePVCount);
} else sprintf(buff,"%-.18s",disabledForcePVCountString[0]);
str = XmStringCreateSimple(buff);
XtVaSetValues(area->disabledForcePVCountLabel,
XmNlabelString, str,
NULL);
XmStringFree(str);
}
}
/******************************************************
axUpdateDialogs
******************************************************/
void axUpdateDialogs(ALINK *area)
{
/* update beepSeverity string on main window */
changeBeepSeverityText(area);
/* update silenceForever string on main window */
changeSilenceForeverText(area);
/* update disabledForcePVCount string on main window */
changeDisabledForcePVText(area);
/* update property sheet window if it is displayed */
propUpdateDialog(area);
/* update force mask window if it is displayed */
forceMaskUpdateDialog(area);
/* update forcePV window if it is displayed */
forcePVUpdateDialog(area);
/* update force mask window if it is displayed */
maskUpdateDialog(area);
/* update set beep severity window if it is displayed */
beepSevrUpdateDialog(area);
/* update noAck for one hour window if it is displayed */
noAckUpdateDialog(area);
}
/***************************************************
getSelectionLinkArea
****************************************************/
void *getSelectionLinkArea(ALINK *area)
{
return area->selectionLink;
}
/***************************************************
getSelectionLinkTypeArea
****************************************************/
int getSelectionLinkTypeArea(ALINK *area)
{
return area->selectionType;
}
/******************************************************
CreateActionButtons
******************************************************/
Widget createActionButtons(Widget parent,ActionAreaItem *actions,
int num_buttons)
{
Widget mask_sheet, widget;
int i;
mask_sheet = XtVaCreateWidget("mask_sheet", xmFormWidgetClass, parent,
XmNfractionBase, TIGHTNESS*num_buttons - 1,
XmNleftOffset, 10,
XmNrightOffset, 10,
NULL);
for (i = 0; i < num_buttons; i++) {
widget = XtVaCreateManagedWidget(actions[i].label,
xmPushButtonWidgetClass, mask_sheet,
XmNmarginHeight, 0,
XmNleftAttachment, i? XmATTACH_POSITION : XmATTACH_FORM,
XmNleftPosition, TIGHTNESS*i,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNrightAttachment,
i != num_buttons-1? XmATTACH_POSITION : XmATTACH_FORM,
XmNrightPosition, TIGHTNESS*i + (TIGHTNESS-1),
XmNshowAsDefault, i == 2,
XmNdefaultButtonShadowThickness, 1,
(XtPointer)NULL);
if (actions[i].callback)
XtAddCallback(widget, XmNactivateCallback,
actions[i].callback, actions[i].data);
if (i == 2) {
/* Set the mask_sheet's default button to the third widget
* created (or, make the index a parameter to the function
* or have it be part of the data structure). Also, set the
* pane window constraint for max and min heights so this
* particular pane in the PanedWindow is not resizable.
*/
Dimension height, h;
XtVaGetValues(mask_sheet, XmNmarginHeight, &h, NULL);
XtVaGetValues(widget, XmNheight, &height, NULL);
height += 2 * h;
XtVaSetValues(mask_sheet,
XmNdefaultButton, widget,
XmNpaneMaximum, height,