-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlewindows.c
2502 lines (2206 loc) · 89.5 KB
/
handlewindows.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
/* window-handling routines
*
* Copyright 1996-2008 pinc Software. All Rights Reserved.
* Licensed under the terms of the GNU General Public License, version 3.
*/
#include "types.h"
#include "funcs.h"
#ifdef __amigaos4__
#include <gadgets/texteditor.h>
#endif
extern void CreateGClassesGadgets(struct winData *wd, long wid, long hei);
extern void CreateScriptsGadgets(struct winData *wd, long wid, long hei);
extern void CreateNotesGadgets(struct winData *wd, long wid, long hei);
extern ULONG weightvalues[];
extern UWORD kPredefinedFrames[];
extern STRPTR wdt_cmdstr;
void PUBLIC
RxMapLock(REG(a0, struct LockNode *ln), REG(a1, struct MinNode *node), REG(d0, UBYTE flags))
{
if (!rxpage)
CloseAppWindow(ln->ln_Data[0], TRUE);
}
static void
GT_SetString(struct Gadget *gad, STRPTR *string)
{
STRPTR t;
if (GT_GetGadgetAttrs(gad, win, NULL, GTST_String, &t, TAG_END)) {
FreeString(*string);
*string = AllocString(t);
}
}
void ASM
CloseBorderWindow(REG(a0, struct Window *win), REG(d0, BOOL clean))
{
struct winData *wd = (struct winData *)win->UserData;
if (clean) {
FreePooled(pool, wd->wd_ExtData[0], sizeof(struct wdtBorder));
FreePooled(pool, wd->wd_ExtData[1], sizeof(struct wdtBorder));
FreePooled(pool, wd->wd_ExtData[2], sizeof(struct wdtBorder));
FreePooled(pool, wd->wd_ExtData[3], sizeof(struct wdtBorder));
}
}
#define wbwd(x) ((struct wdtBorder *)wd->wd_ExtData[x])
static void
updateBorderGadgets(struct wdtBorder *wb)
{
char tt[20];
if (!wb)
return;
GT_SetGadgetAttrs(GadgetAddress(win,2),win,NULL,GTCB_Checked,wb->wb_Adopt,TAG_END);
sprintf(tt,"%s pt",ita(wb->wb_Point/65536.0,-3,FALSE));
GT_SetGadgetAttrs(GadgetAddress(win,4),win,NULL,GTST_String,tt,TAG_END);
DrawColorField(win->RPort,GadgetAddress(win,3),wb->wb_Color,TRUE);
}
void ASM
HandleBorderIDCMP(REG(a0, struct TagItem *tag))
{
struct wdtBorder *wb;
struct Node *ln;
char *t,tt[20];
long i,j,id;
wb = (struct wdtBorder *)wd->wd_ExtData[(long)wd->wd_Data];
switch (imsg.Class) {
case IDCMP_GADGETDOWN:
switch ((gad = (struct Gadget *)imsg.IAddress)->GadgetID) {
case 3:
i = PopUpList(win, gad, &colors,
POPA_CallBack, &colorHook,
POPA_MaxPen, ~0L,
POPA_ItemHeight,fontheight + 4,
POPA_Width, GetListWidth(&colors) + boxwidth + 5,
TAG_END);
if (i != ~0L)
{
for(j = 0,ln = (struct Node *)colors.mlh_Head;j < i;j++,ln = ln->ln_Succ);
wb->wb_Color = ((struct colorPen *)ln)->cp_ID;
wb->wb_Adopt = TRUE;
DrawColorField(win->RPort,gad,wb->wb_Color,TRUE);
GT_SetGadgetAttrs(GadgetAddress(win, 2), win, NULL, GTCB_Checked, TRUE, TAG_END);
}
break;
case 5:
case 6:
wd->wd_ExtData[4] = (APTR)((long)gad->GadgetID);
wd->wd_ExtData[5] = NULL;
break;
}
break;
case IDCMP_GADGETUP:
switch (id = (gad = (struct Gadget *)imsg.IAddress)->GadgetID) {
case 1: // Border-Cycle
wd->wd_Data = (APTR)((long)imsg.Code);
wb = (struct wdtBorder *)wd->wd_ExtData[imsg.Code];
updateBorderGadgets(wb);
/* GT_SetGadgetAttrs(GadgetAddress(win,2),win,NULL,GTCB_Checked,wb->wb_Adopt,TAG_END);
sprintf(tt,"%s pt",ita(wb->wb_Point/65536.0,-3,FALSE));
GT_SetGadgetAttrs(GadgetAddress(win,4),win,NULL,GTST_String,tt,TAG_END);
DrawColorField(win->RPort,GadgetAddress(win,3),wb->wb_Color,TRUE);*/
break;
case 2: // Übernehmen?
wb->wb_Adopt = (BOOL)imsg.Code;
break;
case 4: // Stärke
wb->wb_Adopt = TRUE;
GT_GetGadgetAttrs(gad, win, NULL, GTST_String, &t, TAG_END);
if (t)
wb->wb_Point = (long)(ConvertNumber(t,CNT_POINT)*65536.0);
GT_SetGadgetAttrs(GadgetAddress(win,2),win,NULL,GTCB_Checked,TRUE,TAG_END);
break;
case 5: // -
case 6: // +
if (!wd->wd_ExtData[5])
goto border_tooshortforintuiticks;
break;
case 10: // FramesGadget
if (imsg.Code != 0xffff) {
bool addOnly;
long point;
if (IsDoubleClick(imsg.Code))
goto border_doubleclick;
addOnly = GetCheckBoxFlag(GadgetAddress(win, 11), win, TRUE) && imsg.Code != 0;
// if "add only" is set, the first default frame (the empty frame)
// will still remove all frames for convenience
for (i = 0; i < 4; i++) {
wb = (struct wdtBorder *)wd->wd_ExtData[i];
point = ((kPredefinedFrames[imsg.Code] & (0x3 << i*2)) >> i*2) << 16;
if (!addOnly || point)
{
wb->wb_Point = point;
wb->wb_Adopt = TRUE;
wb->wb_Color = kPredefinedFrames[imsg.Code] & (0x100 << i) ? FindColorPen(255,255,255) : FindColorPen(0,0,0);
}
else
wb->wb_Adopt = FALSE;
}
updateBorderGadgets((struct wdtBorder *)wd->wd_ExtData[(long)wd->wd_Data]);
}
break;
}
case IDCMP_VANILLAKEY:
if (imsg.Class == IDCMP_GADGETUP)
id = gad->GadgetID;
else
{
id = imsg.Code;
gad = NULL;
}
if (id == wd->wd_ShortCuts[1] || id == wd->wd_ShortCuts[4]) // "Ok" und "Zuweisen"
{
long border = 0;
border_doubleclick: /********************************************************/
GT_GetGadgetAttrs(GadgetAddress(win,wd->wd_ShortCuts[0]),win,NULL,GTCB_Checked,&border,TAG_END);
SetBorder(rxpage, border,wbwd(0)->wb_Adopt ? wbwd(0)->wb_Color : ~0L,wbwd(0)->wb_Point >> 11, wbwd(1)->wb_Adopt ? wbwd(1)->wb_Color : ~0L,wbwd(1)->wb_Point >> 11,wbwd(2)->wb_Adopt ? wbwd(2)->wb_Color : ~0L,wbwd(2)->wb_Point >> 11,wbwd(3)->wb_Adopt ? wbwd(3)->wb_Color : ~0L,wbwd(3)->wb_Point >> 11);
if (id == wd->wd_ShortCuts[1]) // Fenster schließen bei "Ok", nicht bei Doppelklick oder "Zuweisen"
CloseAppWindow(win,TRUE);
}
else if (id == wd->wd_ShortCuts[2] || id == ESCAPE_KEY) // Abbrechen
CloseAppWindow(win,TRUE);
else if (!gad && id == wd->wd_ShortCuts[0]) // Block umrahmen
{
long border = 0;
GT_GetGadgetAttrs(gad = GadgetAddress(win, wd->wd_ShortCuts[0]), win, NULL, GTCB_Checked, &border, TAG_END);
GT_SetGadgetAttrs(gad, win, NULL, GTCB_Checked, !border, TAG_END);
}
else if (id == wd->wd_ShortCuts[3]) // Rahmen von aktueller Zelle übernehmen
{
if (rxpage && rxpage->pg_Gad.DispPos > PGS_NONE)
{
struct tableField *tf = rxpage->pg_Gad.tf;
for(i = 0;i < 4;i++)
{
wb = (struct wdtBorder *)wd->wd_ExtData[i];
wb->wb_Adopt = TRUE;
if (tf)
{
wb->wb_Point = tf->tf_Border[i] << 11;
wb->wb_Color = tf->tf_BorderColor[i];
}
else
{
wb->wb_Point = 0;
wb->wb_Color = 0;
}
}
updateBorderGadgets((struct wdtBorder *)wd->wd_ExtData[(long)wd->wd_Data]);
}
}
break;
case IDCMP_INTUITICKS:
if (wd->wd_ExtData[4])
{
if ((gad = GadgetAddress(win,(long)wd->wd_ExtData[4])) && gad->Flags & GFLG_SELECTED)
{
border_tooshortforintuiticks: /********************************************************/
if (!wb->wb_Adopt)
{
wb->wb_Adopt = TRUE;
GT_SetGadgetAttrs(GadgetAddress(win,2),win,NULL,GTCB_Checked,TRUE,TAG_END);
}
wb->wb_Point += gad->GadgetID == 5 ? -65536 : 65536;
if (wb->wb_Point < 0)
wb->wb_Point = 0;
if (wb->wb_Point > (7 << 16))
wb->wb_Point = 7 << 16;
sprintf(tt,"%s pt",ita(wb->wb_Point/65536.0,-3,FALSE));
wd->wd_ExtData[5] = (APTR)TRUE;
GT_SetGadgetAttrs(GadgetAddress(win,4),win,NULL,GTST_String,tt,TAG_END);
}
else
wd->wd_ExtData[4] = NULL;
}
break;
case IDCMP_CLOSEWINDOW:
CloseAppWindow(win,TRUE);
break;
}
}
void ASM
CloseFormelWindow(REG(a0, struct Window *win), REG(d0, BOOL clean))
{
struct winData *wd = (struct winData *)win->UserData;
if (clean)
FreeStringList(wd->wd_ExtData[2]);
}
void ASM
HandleFormelIDCMP(REG(a0, struct TagItem *tag))
{
struct Function *f;
struct Node *ln;
long i;
switch(imsg.Class)
{
case IDCMP_CLOSEWINDOW:
CloseAppWindow(win,TRUE);
break;
case IDCMP_GADGETUP:
switch(((struct Gadget *)imsg.IAddress)->GadgetID)
{
case 1:
fewftype = imsg.Code;
GT_SetGadgetAttrs(wd->wd_ExtData[1],win,NULL,GTLV_Labels,~0L,TAG_END);
MakeFewFuncs();
GT_SetGadgetAttrs(wd->wd_ExtData[1],win,NULL,GTLV_Labels,&fewfuncs,TAG_END);
GT_SetGadgetAttrs(GadgetAddress(win,3),win,NULL,GTTX_Text,NULL,TAG_END);
break;
case 2:
for(ln = (struct Node *)fewfuncs.mlh_Head,i = 0;i < imsg.Code;i++,ln = ln->ln_Succ);
((struct Gadget *)wd->wd_ExtData[1])->UserData = ln;
if ((f = (struct Function *)MyFindName(&funcs, ln->ln_Name)) != 0)
GT_SetGadgetAttrs(GadgetAddress(win,3),win,NULL,GTTX_Text,f->f_Help,TAG_END);
break;
case 4:
if ((gad = wd->wd_ExtData[1])->UserData)
insertFormel(rxpage,((struct Node *)gad->UserData)->ln_Name);
CloseAppWindow(win,TRUE);
break;
case 5:
CloseAppWindow(win,TRUE);
break;
}
break;
}
}
void ASM
HandlePageSetupIDCMP(REG(a0, struct TagItem *tag))
{
struct Mappe *mp = (struct Mappe *)wd->wd_Data;
switch(imsg.Class)
{
case IDCMP_GADGETUP:
switch((gad = imsg.IAddress)->GadgetID)
{
case 1:
if (imsg.Code < pageSizes)
{
char t[16];
strcpy(t,ita(pageWidth[imsg.Code]/10240.0,2,FALSE));
strcat(t," cm");
GT_SetGadgetAttrs(GadgetAddress(win,2),win,NULL,GTST_String,t,TAG_END);
strcpy(t,ita(pageHeight[imsg.Code]/10240.0,2,FALSE));
strcat(t," cm");
GT_SetGadgetAttrs(GadgetAddress(win,3),win,NULL,GTST_String,t,TAG_END);
}
break;
case 2:
case 5:
case 6:
case 7:
ActivateGadget(GadgetAddress(win,gad->GadgetID+1),win,NULL);
break;
case 9: // Ok
{
STRPTR t;
LONG storage,width,height;
GT_GetGadgetAttrs(GadgetAddress(win,2),win,NULL,GTST_String,&t,TAG_END);
width = (ULONG)(ConvertNumber(t,CNT_MM)*1024.0);
GT_GetGadgetAttrs(GadgetAddress(win,3),win,NULL,GTST_String,&t,TAG_END);
height = (ULONG)(ConvertNumber(t,CNT_MM)*1024.0);
if (height < 1024 || width < 1024)
{
ErrorRequest(GetString(&gLocaleInfo, MSG_INVALID_PAPER_SIZE_ERR));
break;
}
mp->mp_mmWidth = width;
mp->mp_mmHeight = height;
mp->mp_Flags &= ~(MPF_PAGEMARKED | MPF_PAGEONLY);
GT_GetGadgetAttrs(GadgetAddress(win,4),win,NULL,GTCY_Active,&storage,TAG_END);
if (storage == 1)
mp->mp_Flags |= MPF_PAGEMARKED;
if (storage == 2)
mp->mp_Flags |= MPF_PAGEONLY;
GT_GetGadgetAttrs(GadgetAddress(win,5),win,NULL,GTST_String,&t,TAG_END);
mp->mp_BorderLeft = (ULONG)(ConvertNumber(t,CNT_MM)*1024.0);
GT_GetGadgetAttrs(GadgetAddress(win,6),win,NULL,GTST_String,&t,TAG_END);
mp->mp_BorderRight = (ULONG)(ConvertNumber(t,CNT_MM)*1024.0);
GT_GetGadgetAttrs(GadgetAddress(win,7),win,NULL,GTST_String,&t,TAG_END);
mp->mp_BorderTop = (ULONG)(ConvertNumber(t,CNT_MM)*1024.0);
GT_GetGadgetAttrs(GadgetAddress(win,8),win,NULL,GTST_String,&t,TAG_END);
mp->mp_BorderBottom = (ULONG)(ConvertNumber(t,CNT_MM)*1024.0);
CloseAppWindow(win,TRUE);
if (mp->mp_Window)
DrawTable(mp->mp_Window);
break;
}
case 10: // Abbrechen
CloseAppWindow(win,TRUE);
break;
}
break;
case IDCMP_CLOSEWINDOW:
CloseAppWindow(win,TRUE);
break;
}
}
void ASM
HandleDocInfoIDCMP(REG(a0, struct TagItem *tag))
{
struct Mappe *mp = wd->wd_Data;
long id;
switch (imsg.Class)
{
case IDCMP_GADGETUP:
if ((id = (gad = imsg.IAddress)->GadgetID) < 4)
{
ActivateGadget(GadgetAddress(win,id+1),win,NULL);
break;
}
case IDCMP_VANILLAKEY:
if (imsg.Class == IDCMP_VANILLAKEY)
{
gad = NULL;
id = imsg.Code;
}
if (id == wd->wd_ShortCuts[0]) // Ok
{
STRPTR note = NULL;
GT_SetString(GadgetAddress(win,1),&mp->mp_Author);
GT_SetString(GadgetAddress(win,2),&mp->mp_Version);
GT_SetString(GadgetAddress(win,3),&mp->mp_CatchWords);
#ifdef __amigaos4__
note = (STRPTR)DoGadgetMethod (wd->wd_ExtData[1],win,NULL,GM_TEXTEDITOR_ExportText,NULL);
#else
GetAttr(EGA_Text, wd->wd_ExtData[1], (IPTR *)¬e);
#endif
if (note != NULL)
{
FreeString(mp->mp_Note);
mp->mp_Note = AllocString(note);
}
}
else if (id == wd->wd_ShortCuts[2]) // Autor
ActivateGadget(GadgetAddress(win, 1), win, NULL);
else if (id == wd->wd_ShortCuts[3]) // Version
ActivateGadget(GadgetAddress(win, 2), win, NULL);
else if (id == wd->wd_ShortCuts[4]) // Stichworte
ActivateGadget(GadgetAddress(win, 3), win, NULL);
else if (id == wd->wd_ShortCuts[5]) // Bemerkung
ActivateGadget(wd->wd_ExtData[1], win, NULL);
if (id != wd->wd_ShortCuts[1] && id != wd->wd_ShortCuts[0]) // nicht "Ok" oder "Abbrechen"
break;
case IDCMP_CLOSEWINDOW: /********** muß hinter IDCMP_VANILLAKEY stehen bleiben **********/
CloseAppWindow(win,TRUE);
break;
}
}
void ASM
CloseDocumentWindow(REG(a0, struct Window *win), REG(d0, BOOL clean))
{
struct winData *wd = (struct winData *)win->UserData;
struct Node *ln;
int i;
for(i = 8;i < 12;i++)
{
if ((gad = GadgetAddress(win,i)) && gad->UserData)
FreePooled(pool,gad->UserData,32);
}
if (clean)
{
while((ln = MyRemHead(wd->wd_ExtData[3])) != 0)
FreePooled(pool,ln,sizeof(struct Node));
FreePooled(pool,wd->wd_ExtData[3],sizeof(struct List));
}
}
STRPTR
TestPasswords(struct Window *win, LONG id)
{
struct Gadget *ga,*gb;
STRPTR a,b;
if ((ga = GadgetAddress(win,id)) && (a = ga->UserData) && (gb = GadgetAddress(win,id+1)) && (b = gb->UserData))
{
if (strcmp(a,b))
{
DisplayBeep(NULL);
ErrorRequest(GetString(&gLocaleInfo, MSG_PASSWORDS_DONT_MATCH_ERR));
GT_SetGadgetAttrs(ga,win,NULL,GTST_String,NULL,TAG_END);
GT_SetGadgetAttrs(gb,win,NULL,GTST_String,NULL,TAG_END);
*a = 0; *b = 0;
ActivateGadget(ga,win,NULL);
return NULL;
}
}
else
ErrorRequest("Interner Fehler %ld",42); /* MERKER: was ist denn das??? */
return a;
}
void
UpdateEventGadgets(struct Mappe *mp, UBYTE event)
{
char t[16];
if (event == (UBYTE)~0L)
return;
GT_SetGadgetAttrs(wd->wd_ExtData[4],win,NULL,GTLV_Labels,~0L,TAG_END);
GT_SetGadgetAttrs(wd->wd_ExtData[4],win,NULL,GTLV_Labels,wd->wd_ExtData[3],GTLV_Selected,event,TAG_END);
GT_SetGadgetAttrs(GadgetAddress(win,13),win,NULL,GA_Disabled,FALSE,GTST_String,mp->mp_Events[event].ev_Command,TAG_END);
GT_SetGadgetAttrs(GadgetAddress(win,14),win,NULL,GA_Disabled,FALSE,TAG_END);
if (event == EVT_TIME)
sprintf(t,"%ld s",mp->mp_Events[EVT_TIME].ev_Intervall);
else
t[0] = 0;
GT_SetGadgetAttrs(GadgetAddress(win,16),win,NULL,GA_Disabled,event != EVT_TIME,GTST_String,t,TAG_END);
}
void ASM
HandleDocumentIDCMP(REG(a0, struct TagItem *tag))
{
struct Mappe *mp = (struct Mappe *)wd->wd_Data;
struct Node *ln;
long i,evt = (long)((struct Gadget *)wd->wd_ExtData[4])->UserData;
switch (imsg.Class)
{
case IDCMP_GADGETDOWN:
switch (((struct Gadget *)imsg.IAddress)->GadgetID)
{
case 15:
if (evt != ~0L)
{
long mode, j;
GT_GetGadgetAttrs(GadgetAddress(win,14),win,NULL,GTCY_Active,&mode,TAG_END);
gad = GadgetAddress(win,13);
i = PopUpList(win, imsg.IAddress, mode ? &intcmds : &mp->mp_AppCmds,
mode ? TAG_IGNORE : POPA_ItemHeight,itemheight,
mode ? TAG_IGNORE : POPA_CallBack,&linkHook,
mode ? TAG_IGNORE : POPA_MaxItems,5,
POPA_Left, TRUE,
POPA_Width, ((struct Gadget *)imsg.IAddress)->LeftEdge-(gad ? gad->LeftEdge+6 : 100),
TAG_END);
if (i != ~0L)
{
for(j = 0,ln = (struct Node *)(mode ? intcmds.mlh_Head : mp->mp_AppCmds.mlh_Head);j < i;j++,ln = ln->ln_Succ);
if (!mode)
ln = ((struct Link *)ln)->l_Link;
mp->mp_Events[evt].ev_Flags |= EVF_ACTIVE;
mp->mp_Events[evt].ev_Command = AllocString(ln->ln_Name);
if ((ln = FindListNumber(wd->wd_ExtData[3],evt)) != 0)
ln->ln_Type = TRUE;
UpdateEventGadgets(mp,evt);
}
}
break;
}
break;
case IDCMP_GADGETUP:
switch ((gad = imsg.IAddress)->GadgetID)
{
/********** Schutz ***********/
case 8:
case 10:
ActivateGadget(GadgetAddress(win,gad->GadgetID+1),win,NULL);
break;
case 9:
case 11:
TestPasswords(win,gad->GadgetID-1);
break;
/********** Ereignisse ***********/
case 12: // Liste
((struct Gadget *)wd->wd_ExtData[4])->UserData = (APTR)((long)imsg.Code);
if (imsg.Code == evt)
{
GT_SetGadgetAttrs(wd->wd_ExtData[4],win,NULL,GTLV_Labels,~0L,TAG_END);
if ((ln = FindListNumber(wd->wd_ExtData[3],evt = imsg.Code)) != 0)
ln->ln_Type = (!ln->ln_Type) & 1;
if (ln->ln_Type && mp->mp_Events[evt].ev_Command)
mp->mp_Events[evt].ev_Flags |= EVF_ACTIVE;
else
mp->mp_Events[evt].ev_Flags &= ~EVF_ACTIVE;
}
UpdateEventGadgets(mp,imsg.Code);
break;
case 13: // Command
{
STRPTR t;
GT_GetGadgetAttrs(gad,win,NULL,GTST_String,&t,TAG_END);
if (!(ln = FindListNumber(wd->wd_ExtData[3],evt)))
break;
if ((mp->mp_Events[evt].ev_Command = AllocString(t)) != 0)
{
ln->ln_Type = TRUE;
mp->mp_Events[evt].ev_Flags |= EVF_ACTIVE;
}
else
{
ln->ln_Type = FALSE;
mp->mp_Events[evt].ev_Flags &= ~EVF_ACTIVE;
}
UpdateEventGadgets(mp,evt);
break;
case 16: // Intervalle
if (evt == EVT_TIME)
{
GT_GetGadgetAttrs(gad,win,NULL,GTST_String,&t,TAG_END);
if ((i = ConvertTime(t) < 1) != 0)
i = 1;
mp->mp_Events[evt].ev_Intervall = i;
}
break;
}
/********** Ok ***********/
case 17:
{
STRPTR t;
if ((t = TestPasswords(win, 8)) != 0)
{
FreeString(mp->mp_Password);
mp->mp_Password = AllocString(t);
}
else
break;
if ((t = TestPasswords(win, 10)) != 0)
{
FreeString(mp->mp_CellPassword);
mp->mp_CellPassword = AllocString(t);
}
else
break;
mp->mp_Flags &= ~(MPF_NOTES | MPF_SCRIPTS | MPF_READONLY | MPF_SHOWHIDDEN | MPF_SAVEWINPOS);
mp->mp_Flags |= GetCheckBoxFlag(GadgetAddress(win,1),win,MPF_SCRIPTS) |
GetCheckBoxFlag(GadgetAddress(win,2),win,MPF_NOTES) |
GetCheckBoxFlag(GadgetAddress(win,3),win,MPF_READONLY) |
GetCheckBoxFlag(GadgetAddress(win,4),win,MPF_SHOWHIDDEN) |
GetCheckBoxFlag(GadgetAddress(win,5),win,MPF_SAVEWINPOS);
CloseAppWindow(win,TRUE);
UpdateInteractive(mp,FALSE);
if (mp->mp_Window)
DrawTable(mp->mp_Window);
break;
}
}
break;
case IDCMP_CLOSEWINDOW:
CloseAppWindow(win, TRUE);
break;
}
}
void ASM
HandlePageIDCMP(REG(a0, struct TagItem *tag))
{
struct Page *page = wd->wd_Data;
struct tableField *tf;
struct Node *ln;
STRPTR t;
long j, i = 0;
#ifdef __amigaos4__
bool ok_pressed = FALSE; //Notwendig, bis das mit den Dokumentenschutz geklärt ist. Welcher zusammenhang besteht mit übernahme der Änderungen!
#endif
switch (imsg.Class)
{
case IDCMP_GADGETDOWN:
switch((gad = imsg.IAddress)->GadgetID)
{
case 3:
case 4:
i = PopUpList(win, gad, &colors, POPA_CallBack, &colorHook, POPA_MaxPen, ~0L,
POPA_ItemHeight, fontheight + 4, POPA_Width, GetListWidth(&colors) + boxwidth + 5,
TAG_END);
if (i != ~0L)
{
for(j = 0,ln = (struct Node *)colors.mlh_Head;j < i;j++,ln = ln->ln_Succ);
wd->wd_ExtData[gad->GadgetID-3] = (APTR)(i = ((struct colorPen *)ln)->cp_ID);
DrawColorField(win->RPort,gad,i,TRUE);
}
break;
}
break;
case IDCMP_GADGETUP:
switch ((gad = imsg.IAddress)->GadgetID)
{
case 5: // Ok (apply page changes)
#ifdef __amigaos4__
ok_pressed = TRUE;
#endif
GT_GetGadgetAttrs(GadgetAddress(win, 1), win, NULL, GTST_String, &t, TAG_END);
if (!page->pg_Node.ln_Name || strcmp(page->pg_Node.ln_Name,t))
{
FreeString(page->pg_Node.ln_Name);
page->pg_Node.ln_Name = AllocString(t);
if (page->pg_Window && ((struct winData *)page->pg_Window->UserData)->wd_Data == page)
GT_SetGadgetAttrs(GadgetAddress(page->pg_Window,GID_PAGE),page->pg_Window,NULL,GTTX_Text,page->pg_Node.ln_Name,TAG_END);
}
if ((ULONG)wd->wd_ExtData[0] != page->pg_APen || (ULONG)wd->wd_ExtData[1] != page->pg_BPen)
{
struct tableField *stf;
struct UndoNode *un;
char s[100];
/* Create UndoNode and string */
i = 42;
strcpy(s, GetString(&gLocaleInfo, MSG_PAGE_COLOR));
if ((ln = (APTR)GetColorPen((ULONG)wd->wd_ExtData[0])) != 0)
strcat(s, ln->ln_Name);
else
strcat(s,"-");
strcat(s,"/");
if ((ln = (APTR)GetColorPen((ULONG)wd->wd_ExtData[1])) != 0)
strcat(s,ln->ln_Name);
else
strcat(s,"-");
if ((un = CreateUndo(page, UNDO_PRIVATE, s)) != 0)
{
un->un_Type = UNT_CELLS_CHANGED;
un->un_Mode = UNM_PAGECOLORS;
un->un_TablePos.tp_Col = page->pg_APen; /* undo: apen */
un->un_TablePos.tp_Row = page->pg_BPen; /* bpen */
un->un_TablePos.tp_Width = (ULONG)wd->wd_ExtData[0]; /* redo: apen */
un->un_TablePos.tp_Height = (ULONG)wd->wd_ExtData[1]; /* bpen */
}
/* Actually perform the changes - set every color that matches
* the old colors to the newly chosen ones.
*/
foreach (&page->pg_Table, tf)
{
if (un && (stf = CopyCell(page, tf)))
MyAddTail(&un->un_UndoList, stf);
if (tf->tf_APen == page->pg_APen)
tf->tf_APen = (ULONG)wd->wd_ExtData[0];
if (tf->tf_ReservedPen == page->pg_APen)
tf->tf_ReservedPen = (ULONG)wd->wd_ExtData[0];
if (tf->tf_BPen == page->pg_BPen)
tf->tf_BPen = (ULONG)wd->wd_ExtData[1];
if (un && (stf = CopyCell(page, tf)))
MyAddTail(&un->un_RedoList, stf);
}
page->pg_APen = (ULONG)wd->wd_ExtData[0];
page->pg_BPen = (ULONG)wd->wd_ExtData[1];
/* Set the page protection flags */
GT_GetGadgetAttrs(GadgetAddress(win, 2), win, NULL, GTCY_Active, &i, TAG_END);
page->pg_Flags &= ~PGF_SECURITY;
if (i == 1)
page->pg_Flags |= PGF_IMMUTABLE;
}
case 6:
CloseAppWindow(win, TRUE);
#ifdef __amigaos4__
if(ok_pressed)
#else
if (i)
#endif
DrawTable(page->pg_Window);
break;
}
break;
case IDCMP_CLOSEWINDOW:
CloseAppWindow(win, TRUE);
break;
}
}
void
updateCellSizeGads(long w, long h)
{
if (w != ~0L)
{
GT_SetGadgetAttrs(GadgetAddress(win,1),win,NULL,GTCY_Active,w,TAG_END);
GT_SetGadgetAttrs(gad = GadgetAddress(win,2),win,NULL,GA_Disabled,w == 3 || w == 0,TAG_END);
if (w > 0 && w < 3)
ActivateGadget(gad,win,NULL);
}
if (h != ~0L)
{
GT_SetGadgetAttrs(GadgetAddress(win,3),win,NULL,GTCY_Active,h,TAG_END);
GT_SetGadgetAttrs(gad = GadgetAddress(win,4),win,NULL,GA_Disabled,h == 3 || h == 0,TAG_END);
if (h > 0 && h < 3)
ActivateGadget(gad,win,NULL);
}
}
void
SetCellSizeGadget(struct Window *win,long gad,long mm)
{
char t[32];
if (mm != -1L)
{
strcpy(t,ita(mm/1024.0,2,FALSE));
strcat(t," mm");
GT_SetGadgetAttrs(GadgetAddress(win,gad),win,NULL,GTST_String,t,TAG_END);
}
}
void ASM
handleCellSizeIDCMP(REG(a0, struct TagItem *tag))
{
long i,id;
switch (imsg.Class)
{
case IDCMP_VANILLAKEY:
id = imsg.Code;
case IDCMP_GADGETUP:
if (imsg.Class == IDCMP_GADGETUP)
id = (gad = imsg.IAddress)->GadgetID;
switch(id)
{
case 1:
updateCellSizeGads(imsg.Code,~0L);
break;
case 3:
updateCellSizeGads(~0L,imsg.Code);
break;
case 2:
if (imsg.Qualifier & IEQUALIFIER_SHIFT)
break;
GT_GetGadgetAttrs(gad = GadgetAddress(win,4),win,NULL,GA_Disabled,&i,TAG_END);
if (gad && !i)
ActivateGadget(gad,win,NULL);
break;
case ' ':
ActivateGadget(GadgetAddress(win,2),win,NULL);
break;
default:
if (tolower(id) == wd->wd_ShortCuts[0] || tolower(id) == wd->wd_ShortCuts[1])
{
GT_GetGadgetAttrs(gad = GadgetAddress(win,tolower(id) == wd->wd_ShortCuts[0] ? 1 : 3),win,NULL,GTCY_Active,&i,TAG_END);
if (isupper(id)) // Cycle-Gadget zurück
{
i--;
if (i < 0) i = 3;
}
else // Cycle-Gadget weiter
{
i++;
if (i > 3) i = 0;
}
GT_SetGadgetAttrs(gad,win,NULL,GTCY_Active,i,TAG_END);
updateCellSizeGads(gad->GadgetID == 1 ? i : ~0L,gad->GadgetID == 3 ? i : ~0L);
}
else if (id == wd->wd_ShortCuts[5]) // Größe von aktueller Zelle übernehmen
{
if (rxpage && rxpage->pg_Gad.DispPos > PGS_NONE)
{
long mm = -1L;
if (rxpage->pg_Gad.cp.cp_Col > rxpage->pg_Cols)
mm = rxpage->pg_mmStdWidth;
else if (rxpage->pg_tfWidth)
mm = (rxpage->pg_tfWidth+rxpage->pg_Gad.cp.cp_Col-1)->ts_mm;
SetCellSizeGadget(win,2,mm);
if (rxpage->pg_Gad.cp.cp_Row > rxpage->pg_Rows)
mm = rxpage->pg_mmStdHeight;
else if (rxpage->pg_tfHeight)
mm = (rxpage->pg_tfHeight+rxpage->pg_Gad.cp.cp_Row-1)->ts_mm;
else
mm = -1L;
SetCellSizeGadget(win,4,mm);
updateCellSizeGads(1,1);
}
else
DisplayBeep(NULL);
}
else if (id == wd->wd_ShortCuts[2] || id == wd->wd_ShortCuts[3]) // Ok & Zuweisen
{
STRPTR width = NULL,height = NULL;
long j;
GT_GetGadgetAttrs(GadgetAddress(win,1),win,NULL,GTCY_Active,&i,TAG_END);
if (i) // neue Breite
{
GT_GetGadgetAttrs(GadgetAddress(win,2),win,NULL,GTST_String,&width,TAG_END);
width = AllocString(width);
}
GT_GetGadgetAttrs(GadgetAddress(win,3),win,NULL,GTCY_Active,&j,TAG_END);
if (j) // neue Höhe
{
GT_GetGadgetAttrs(GadgetAddress(win,4),win,NULL,GTST_String,&height,TAG_END);
height = AllocString(height);
}
if (id == wd->wd_ShortCuts[2])
CloseAppWindow(win,TRUE);
ChangeCellSize(rxpage,width,height,(i == 2 ? CCS_MINWIDTH : (i == 3 ? CCS_OPTWIDTH : 0)) | (id == 2 ? CCS_MINHEIGHT : (id == 3 ? CCS_OPTHEIGHT : 0)),NULL);
FreeString(width); FreeString(height);
}
else if (id == wd->wd_ShortCuts[4] || id == ESCAPE_KEY) // Abbrechen
CloseAppWindow(win,TRUE);
break;
}
break;
case IDCMP_CLOSEWINDOW:
CloseAppWindow(win,TRUE);
break;
}
}
void ASM
closeNotesWin(REG(a0, struct Window *win), REG(d0, BOOL clean))
{
struct winData *wd = (struct winData *)win->UserData;
struct wdtNote *wn;
if (clean)
{
while((wn = (struct wdtNote *)MyRemHead((struct List *)wd->wd_ExtData[0])) != 0)
{
FreeString(wn->wn_Node.ln_Name);
FreeString(wn->wn_Note);
FreePooled(pool,wn,sizeof(struct wdtNote));
}
}
}
void ASM
handleNotesIDCMP(REG(a0, struct TagItem *tag))
{
struct tableField *tf = NULL;
char t[256];
long id,i;
switch(imsg.Class)
{
case IDCMP_GADGETDOWN:
if ((gad = imsg.IAddress)->GadgetID == 2)
{
i = PopUpList(win,gad,wd->wd_ExtData[0],POPA_Width,win->Width-16-boxwidth,TAG_END);
if (i != ~0L)
{
struct wdtNote *wn;
STRPTR s,t;
long len;
wn = (struct wdtNote *)FindListNumber(wd->wd_ExtData[0],i);
#ifdef __amigaos4__
s = (STRPTR)DoGadgetMethod ((gad = wd->wd_ExtData[1]),win,NULL,GM_TEXTEDITOR_ExportText,TAG_END);
#else
GetAttr(EGA_Text, (Object*)(gad = wd->wd_ExtData[1]), (IPTR *)&s);
#endif
if (s && wn->wn_Note && (t = AllocPooled(pool,len = strlen(s)+strlen(wn->wn_Note)+1)))
{
strcpy(t,s);
strcat(t,wn->wn_Note);
#ifdef __amigaos4__
SetGadgetAttrs(gad, win, NULL, GA_TEXTEDITOR_Contents, t, TAG_END);
#else
SetGadgetAttrs(gad,win,NULL,EGA_Text,t,TAG_END);
#endif
FreePooled(pool,t,len);
}
else
#ifdef __amigaos4__
SetGadgetAttrs(gad, win, NULL, GA_TEXTEDITOR_Contents, wn->wn_Note, TAG_END);
#else
SetGadgetAttrs(gad,win,NULL,EGA_Text,wn->wn_Note,TAG_END);
#endif
ActivateGadget(gad,win,NULL);
}
break;
}
break;
case IDCMP_GADGETUP:
id = ((struct Gadget *)imsg.IAddress)->GadgetID;
case IDCMP_VANILLAKEY:
if (imsg.Class == IDCMP_VANILLAKEY)
id = imsg.Code;
if (wd->wd_ShortCuts[0] == id)
ActivateGadget(wd->wd_ExtData[1],win,NULL);
else if (wd->wd_ShortCuts[1] == id || wd->wd_ShortCuts[2] == id)
{
STRPTR note = NULL;
id = wd->wd_ShortCuts[1] == id ? 1 : 2;
#ifdef __amigaos4__
note = (STRPTR)DoGadgetMethod (wd->wd_ExtData[1],win,NULL,GM_TEXTEDITOR_ExportText,NULL);