forked from rochus-keller/OberonSystem3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicGadgets.Mod
1356 lines (1263 loc) · 48.8 KB
/
BasicGadgets.Mod
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
(* OBERON System 3, Release 2.3.
Copyright 1999 ETH Zürich Institute for Computer Systems,
ETH Center, CH-8092 Zürich. e-mail: [email protected].
This module may be used under the conditions of the general Oberon
System 3 license contract. The full text can be downloaded from
"ftp://ftp.inf.ethz.ch/pub/software/Oberon/System3/license.txt;A"
Under the license terms stated it is in particular (a) prohibited to modify
the interface of this module in any way that disagrees with the style
or content of the system and (b) requested to provide all conversions
of the source code to another platform with the name OBERON. *)
MODULE BasicGadgets; (** portable *) (* jm 18.1.95 *)
(** Contains an implementation of the model gadgets Boolean, String, Integer, and Real, and of the visual gadgets Button, Checkbox and Slider. The buttons and checkboxes can also be used as radio-buttons by linking to them an Integer model gadget.
*)
(*
JM 3.2.93 - New radio button look
- SetValues improved
- Gadgets.UpdateMsg goes to abstract gadgets too
JM 8.2.93 - Cancel combination for button clicks improved
jm 9.2.93 - new abstract object rooted in gadgets
- Respond on Viewers.ViewerMsg
jm 11.2.93 - Display.ControlMsg
jm 3.2.93 - popout buttons improved
23.7.93 - simplified copy of abstract objects
19.4.94 - popout attribute is now set by default for buttons
19.4.94 - Added Break
21.4.95 - fixed command execution of checkboxes
27.9.95 - fixed slider update model
13.10.95 - Changed popout behavior of buttons
3.5.96 - YesVal of checkboxes now always returns a value (ps - 3.5.96)
8.5.96 - Add Look-Link to Buttons (ps - 8.5.96)
29.7.96 - fixed NIL-trap in SetValues (ps - 29.7.96)
20.11.96 - add 2 new button attributes (iw)
25.4.97 - fixed bug in ButtonAttr (YesVal)
*)
IMPORT
Objects, Gadgets, Display, Display3, Effects, Oberon, Texts, Files, Printer, Printer3, Fonts, Strings;
CONST
VersionNo = 2; VersionNewButton = 4; VersionAbstract = 4;
VersionNewCheckbox = 3;
MaxLen = 64;
TYPE
(* --- Things --- *)
Boolean* = POINTER TO BooleanDesc;
BooleanDesc* = RECORD (Gadgets.ObjDesc)
val*: BOOLEAN;
END;
String* = POINTER TO StringDesc;
StringDesc* = RECORD (Gadgets.ObjDesc)
val*: ARRAY MaxLen OF CHAR;
END;
Integer* = POINTER TO IntegerDesc;
IntegerDesc* = RECORD (Gadgets.ObjDesc)
val*: LONGINT;
END;
Real* = POINTER TO RealDesc;
RealDesc* = RECORD (Gadgets.ObjDesc)
val*: LONGREAL;
END;
(* --- Gadgets --- *)
Button* = POINTER TO ButtonDesc;
ButtonDesc* = RECORD (Gadgets.FrameDesc)
caption*: ARRAY 32 OF CHAR; (** Caption shown inside the button. *)
val*: BOOLEAN; (** Pushed/popped out. *)
popout*: BOOLEAN; (** Button should pop out immediately after pressed. *)
setval*: INTEGER; (** Button is pressed should the button model have this value. *)
look*: Objects.Object; (** Object dropped inside of button, used as button representation instead of caption. *)
led*: BOOLEAN; (** visibility of a led if Button is pressed *)
ledcol*: INTEGER; (** Color of LED when Button is pressed *)
inM, outM: Display3.Mask;
END;
CheckBox* = POINTER TO CheckBoxDesc;
CheckBoxDesc* = RECORD (Gadgets.FrameDesc)
val*: BOOLEAN; (** State. *)
setval*: INTEGER; (** checkbox is ticked should the checkbox model have this value. *)
END;
Slider* = POINTER TO SliderDesc;
SliderDesc* = RECORD (Gadgets.FrameDesc)
min*, max*, val*: LONGINT; (** Minimum, maximum and current value *)
B, BW: INTEGER;
END;
VAR W: Texts.Writer;
PROCEDURE Log;
BEGIN Texts.Append(Oberon.Log, W.buf) END Log;
PROCEDURE Min(x, y: INTEGER): INTEGER;
BEGIN IF x < y THEN RETURN x; ELSE RETURN y; END;
END Min;
PROCEDURE KillMasks(F: Objects.Object);
VAR O: Display3.OverlapMsg;
BEGIN
O.F := NIL; O.M := NIL; O.x := 0; O.y := 0; O.res := -1; O.dlink := NIL; F.handle(F, O);
END KillMasks;
(* --- Version check --- *)
PROCEDURE WriteVersion(VAR R: Files.Rider);
BEGIN Files.WriteNum(R, VersionNo);
END WriteVersion;
PROCEDURE ReadVersion(VAR R: Files.Rider);
VAR x: LONGINT;
BEGIN Files.ReadNum(R, x);
IF x # VersionNo THEN
Texts.WriteString(W, "Version "); Texts.WriteInt(W, VersionNo, 3);
Texts.WriteString(W, " of BasicGadgets cannot read version "); Texts.WriteInt(W, x, 3); Texts.WriteLn(W); Log;
HALT(42);
END;
END ReadVersion;
(* ---------- abstract objects ---------- *)
PROCEDURE CopyBoolean*(VAR M: Objects.CopyMsg; from, to: Boolean);
BEGIN
Gadgets.CopyObject(M, from, to); to.val := from.val;
END CopyBoolean;
PROCEDURE BooleanHandler*(obj: Objects.Object; VAR M: Objects.ObjMsg);
VAR obj2: Boolean; x: INTEGER; ver: LONGINT;
BEGIN
WITH obj: Boolean DO
IF M IS Objects.AttrMsg THEN
WITH M: Objects.AttrMsg DO
IF M.id = Objects.get THEN
IF M.name = "Gen" THEN M.s := "BasicGadgets.NewBoolean"; M.class := Objects.String; M.res := 0
ELSIF M.name = "Value" THEN M.b := obj.val; M.class := Objects.Bool; M.res := 0
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.set THEN
IF M.name = "Value" THEN
IF M.class = Objects.Bool THEN obj.val := M.b; M.res := 0 END
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.enum THEN
M.Enum("Value"); Gadgets.objecthandle(obj, M)
END
END
ELSIF M IS Objects.FileMsg THEN
WITH M: Objects.FileMsg DO
IF M.id = Objects.store THEN
Files.WriteNum(M.R, VersionAbstract); Files.WriteBool(M.R, obj.val);
Gadgets.objecthandle(obj, M);
(* WriteVersion(M.R); IF obj.val THEN Files.WriteInt(M.R, 1); ELSE Files.WriteInt(M.R, 0); END; *)
ELSIF M.id = Objects.load THEN
Files.ReadNum(M.R, ver);
IF ver = VersionNo THEN (* old *)
Files.ReadInt(M.R, x); obj.val := (x = 1);
ELSIF ver = VersionAbstract THEN
Files.ReadBool(M.R, obj.val); Gadgets.objecthandle(obj, M);
ELSE
Texts.WriteString(W, "Version "); Texts.WriteInt(W, VersionAbstract, 3);
Texts.WriteString(W, " of boolean cannot read version "); Texts.WriteInt(W, ver, 3); Texts.WriteLn(W); Log;
HALT(42);
END
END
END;
ELSIF M IS Objects.CopyMsg THEN
WITH M: Objects.CopyMsg DO
IF M.stamp = obj.stamp THEN M.obj := obj.dlink
ELSE NEW(obj2); obj.stamp := M.stamp; obj.dlink := obj2; CopyBoolean(M, obj, obj2); M.obj := obj2
END
END
ELSE
Gadgets.objecthandle(obj, M)
END
END
END BooleanHandler;
PROCEDURE InitBoolean*(obj: Boolean);
BEGIN obj.handle := BooleanHandler
END InitBoolean;
PROCEDURE NewBoolean*;
VAR obj: Boolean;
BEGIN NEW(obj); InitBoolean(obj); Objects.NewObj := obj;
END NewBoolean;
PROCEDURE CopyString*(VAR M: Objects.CopyMsg; from, to: String);
BEGIN Gadgets.CopyObject(M, from, to); to.val := from.val;
END CopyString;
PROCEDURE StringHandler*(obj: Objects.Object; VAR M: Objects.ObjMsg);
VAR obj2: String; ver: LONGINT;
BEGIN
WITH obj: String DO
IF M IS Objects.AttrMsg THEN
WITH M: Objects.AttrMsg DO
IF M.id = Objects.get THEN
IF M.name = "Gen" THEN M.s := "BasicGadgets.NewString"; M.class := Objects.String; M.res := 0
ELSIF M.name = "Value" THEN M.s := obj.val; M.class := Objects.String; M.res := 0
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.set THEN
IF M.name = "Value" THEN
IF M.class = Objects.String THEN obj.val := M.s; M.res := 0
ELSIF M.class = Objects.Int THEN Strings.IntToStr(M.i, obj.val); M.res := 0
ELSIF M.class = Objects.Real THEN Strings.RealToStr(M.x, obj.val); M.res := 0
ELSIF M.class = Objects.LongReal THEN Strings.RealToStr(M.y, obj.val); M.res := 0
END
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.enum THEN
M.Enum("Value"); Gadgets.objecthandle(obj, M)
END
END
ELSIF M IS Objects.FileMsg THEN
WITH M: Objects.FileMsg DO
IF M.id = Objects.store THEN
Files.WriteNum(M.R, VersionAbstract); Files.WriteString(M.R, obj.val);
Gadgets.objecthandle(obj, M);
ELSIF M.id = Objects.load THEN
Files.ReadNum(M.R, ver);
IF ver = VersionNo THEN (* old *)
Files.ReadString(M.R, obj.val)
ELSIF ver = VersionAbstract THEN
Files.ReadString(M.R, obj.val); Gadgets.objecthandle(obj, M);
ELSE
Texts.WriteString(W, "Version "); Texts.WriteInt(W, VersionAbstract, 3);
Texts.WriteString(W, " of string cannot read version "); Texts.WriteInt(W, ver, 3); Texts.WriteLn(W); Log;
HALT(42);
END
END
END;
ELSIF M IS Objects.CopyMsg THEN
WITH M: Objects.CopyMsg DO
IF M.stamp = obj.stamp THEN M.obj := obj.dlink
ELSE NEW(obj2); obj.stamp := M.stamp; obj.dlink := obj2; CopyString(M, obj, obj2); M.obj := obj2
END
END
ELSE
Gadgets.objecthandle(obj, M)
END
END
END StringHandler;
PROCEDURE InitString*(obj: String);
BEGIN obj.handle := StringHandler; obj.val := ""
END InitString;
PROCEDURE NewString*;
VAR obj: String;
BEGIN NEW(obj); InitString(obj); Objects.NewObj := obj
END NewString;
PROCEDURE CopyInteger*(VAR M: Objects.CopyMsg; from, to: Integer);
BEGIN Gadgets.CopyObject(M, from, to); to.val := from.val;
END CopyInteger;
PROCEDURE IntegerHandler*(obj: Objects.Object; VAR M: Objects.ObjMsg);
VAR obj2: Integer; ver: LONGINT;
BEGIN
WITH obj: Integer DO
IF M IS Objects.AttrMsg THEN
WITH M: Objects.AttrMsg DO
IF M.id = Objects.get THEN
IF M.name = "Gen" THEN M.s := "BasicGadgets.NewInteger"; M.class := Objects.String; M.res := 0
ELSIF M.name = "Value" THEN M.i := obj.val; M.class := Objects.Int; M.res := 0
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.set THEN
IF M.name = "Value" THEN
IF M.class = Objects.Int THEN obj.val := M.i; M.res := 0
ELSIF M.class = Objects.String THEN Strings.StrToInt(M.s, obj.val); M.res := 0
ELSIF M.class = Objects.Real THEN obj.val := ENTIER(M.x); M.res := 0
ELSIF M.class = Objects.LongReal THEN obj.val := ENTIER(M.x); M.res := 0
END
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.enum THEN
M.Enum("Value"); Gadgets.objecthandle(obj, M)
END
END;
ELSIF M IS Objects.FileMsg THEN
WITH M: Objects.FileMsg DO
IF M.id = Objects.store THEN
Files.WriteNum(M.R, VersionAbstract); Files.WriteLInt(M.R, obj.val); Gadgets.objecthandle(obj, M)
ELSIF M.id = Objects.load THEN
Files.ReadNum(M.R, ver);
IF ver = VersionNo THEN (* old *)
Files.ReadLInt(M.R, obj.val);
ELSIF ver = VersionAbstract THEN
Files.ReadLInt(M.R, obj.val); Gadgets.objecthandle(obj, M);
ELSE
Texts.WriteString(W, "Version "); Texts.WriteInt(W, VersionAbstract, 3);
Texts.WriteString(W, " of integer cannot read version "); Texts.WriteInt(W, ver, 3); Texts.WriteLn(W); Log;
HALT(42);
END
END
END;
ELSIF M IS Objects.CopyMsg THEN
WITH M: Objects.CopyMsg DO
IF M.stamp = obj.stamp THEN
M.obj := obj.dlink
ELSE
NEW(obj2); obj.stamp := M.stamp; obj.dlink := obj2; CopyInteger(M, obj, obj2); M.obj := obj2
END;
END;
ELSE
Gadgets.objecthandle(obj, M)
END;
END;
END IntegerHandler;
PROCEDURE InitInteger*(obj: Integer);
BEGIN obj.handle := IntegerHandler; obj.val := 0
END InitInteger;
PROCEDURE NewInteger*;
VAR obj: Integer;
BEGIN
NEW(obj); InitInteger(obj); Objects.NewObj := obj
END NewInteger;
PROCEDURE CopyReal*(VAR M: Objects.CopyMsg; from, to: Real);
BEGIN Gadgets.CopyObject(M, from, to); to.val := from.val;
END CopyReal;
PROCEDURE RealHandler*(obj: Objects.Object; VAR M: Objects.ObjMsg);
VAR obj2: Real; ver: LONGINT;
BEGIN
WITH obj: Real DO
IF M IS Objects.AttrMsg THEN
WITH M: Objects.AttrMsg DO
IF M.id = Objects.get THEN
IF M.name = "Gen" THEN M.s := "BasicGadgets.NewReal"; M.class := Objects.String; M.res := 0
ELSIF M.name = "Value" THEN M.y := obj.val; M.class := Objects.LongReal; M.res := 0
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.set THEN
IF M.name = "Value" THEN
IF M.class = Objects.LongReal THEN obj.val := M.y; M.res := 0
ELSIF M.class = Objects.Real THEN obj.val := M.x; M.res := 0
ELSIF M.class = Objects.Int THEN obj.val := M.i; M.res := 0
ELSIF M.class = Objects.String THEN Strings.StrToReal(M.s, obj.val); M.res := 0
END
ELSE Gadgets.objecthandle(obj, M)
END
ELSIF M.id = Objects.enum THEN
M.Enum("Value"); Gadgets.objecthandle(obj, M)
END
END
ELSIF M IS Objects.FileMsg THEN
WITH M: Objects.FileMsg DO
IF M.id = Objects.store THEN
Files.WriteNum(M.R, VersionAbstract); Files.WriteLReal(M.R, obj.val); Gadgets.objecthandle(obj, M)
ELSIF M.id = Objects.load THEN
Files.ReadNum(M.R, ver);
IF ver = VersionNo THEN (* old *)
Files.ReadLReal(M.R, obj.val);
ELSIF ver = VersionAbstract THEN
Files.ReadLReal(M.R, obj.val); Gadgets.objecthandle(obj, M);
ELSE
Texts.WriteString(W, "Version "); Texts.WriteInt(W, VersionAbstract, 3);
Texts.WriteString(W, " of real cannot read version "); Texts.WriteInt(W, ver, 3); Texts.WriteLn(W); Log;
HALT(42)
END
END
END
ELSIF M IS Objects.CopyMsg THEN
WITH M: Objects.CopyMsg DO
IF M.stamp = obj.stamp THEN
M.obj := obj.dlink
ELSE
NEW(obj2); obj.stamp := M.stamp; obj.dlink := obj2; CopyReal(M, obj, obj2); M.obj := obj2
END
END
ELSE
Gadgets.objecthandle(obj, M)
END
END
END RealHandler;
PROCEDURE InitReal*(obj: Real);
BEGIN obj.handle := RealHandler; obj.val := 0
END InitReal;
PROCEDURE NewReal*;
VAR obj: Real;
BEGIN
NEW(obj); InitReal(obj); Objects.NewObj := obj
END NewReal;
PROCEDURE Field(F: Gadgets.Frame; VAR name: ARRAY OF CHAR);
VAR A: Objects.AttrMsg;
BEGIN
A.id := Objects.get; A.name := "Field"; A.class := Objects.Inval; A.s := "";
F.handle(F, A);
IF (A.res >= 0) & (A.class = Objects.String) & (A.s # "") THEN name := A.s
ELSE name := "Value"
END
END Field;
(* ------ Gadgets ------ *)
PROCEDURE ButtonUpdateModel(F: Button);
VAR A: Objects.AttrMsg;
BEGIN
IF F.obj # NIL THEN
A.id := Objects.get; Field(F, A.name); A.class := Objects.Inval; A.res := -1;
F.obj.handle(F.obj, A);
IF A.res >= 0 THEN
IF A.class = Objects.Bool THEN F.val := A.b
ELSIF A.class = Objects.Int THEN F.val := A.i = F.setval
END
END
END
END ButtonUpdateModel;
PROCEDURE ButtonSetModel(F: Button);
VAR A: Objects.AttrMsg;
BEGIN
IF F.obj # NIL THEN
A.id := Objects.get; Field(F, A.name); A.class := Objects.Inval; A.res := -1;
F.obj.handle(F.obj, A);
IF A.res >= 0 THEN
A.dlink := F.dlink;
IF A.class = Objects.Bool THEN A.b := F.val;
A.id := Objects.set; A.res := -1; F.obj.handle(F.obj, A)
ELSIF A.class = Objects.Int THEN
IF F.val THEN A.i := F.setval; A.id := Objects.set; A.res := -1; F.obj.handle(F.obj, A) END
END
END
END
END ButtonSetModel;
PROCEDURE ButtonSetLook(F: Button; f: Gadgets.Frame): BOOLEAN; (* ps - 8.5.96 *)
VAR CM: Display.ControlMsg; B: Objects.BindMsg;
BEGIN
IF Gadgets.Recursive(F, f) THEN
Texts.WriteString(W,"Not allowed, will cause recursive structures"); Log;
RETURN FALSE
ELSIF (F.lib # NIL) & (f.lib # NIL) & (F.lib # f.lib) & (f.lib.name # "") THEN
Texts.WriteString(W,"Across library movement not allowed"); Log;
RETURN FALSE
ELSE
CM.id := Display.remove; CM.F := f; Display.Broadcast(CM); (* <<< remove *)
IF F.lib # NIL THEN B.lib:= F.lib; f.handle(f, B); END;
F.look := f; KillMasks(F);
RETURN TRUE
END;
END ButtonSetLook;
(** Goes through the list of selected gadgets (must be buttons and checkboxes) and assigns to each of
them a different SetValue attribute numbered from 0. This is useful to create mutual exclusive radio-buttons *)
PROCEDURE SetValues*;
VAR M: Display.SelectMsg; b, c: Objects.Object; val: INTEGER;
BEGIN
M.id := Display.get; M.F := NIL; M.time := 0; M.obj := NIL; Display.Broadcast(M);
IF M.time > 0 THEN
b := M.obj; val := 0;
WHILE b # NIL DO
IF b IS Button THEN
WITH b: Button DO IF (b.obj # NIL) & (b.obj IS Integer) THEN c := b.obj; b.setval := val; INC(val) END
END
ELSIF b IS CheckBox THEN
WITH b: CheckBox DO IF (b.obj # NIL) & (b.obj IS Integer) THEN c := b.obj; b.setval := val; INC(val) END
END
END;
b := b.slink
END;
IF c # NIL THEN Gadgets.Update(c) END (* ps - 29.7.96 *)
END;
END SetValues;
PROCEDURE ForceString(F: Display.Frame; VAR M: Objects.AttrMsg);
BEGIN Gadgets.framehandle(F, M);
IF M.res < 0 THEN M.class := Objects.String; M.s := ""; M.res := 0 END
END ForceString;
PROCEDURE ButtonAttr(F: Button; VAR M: Objects.AttrMsg);
BEGIN
IF M.id = Objects.get THEN
IF M.name = "Gen" THEN M.class := Objects.String; M.s := "BasicGadgets.NewButton"; M.res := 0
ELSIF M.name = "Caption" THEN M.class := Objects.String; M.s := F.caption; M.res := 0
ELSIF M.name = "Value" THEN M.class := Objects.Bool; M.b := F.val; M.res := 0
ELSIF M.name = "Popout" THEN M.class := Objects.Bool; M.b := F.popout; M.res := 0
ELSIF M.name = "SetVal" THEN M.class := Objects.Int; M.i := F.setval; M.res := 0
ELSIF M.name = "LineupHY" THEN M.class := Objects.Int; M.i := F.H DIV 2 - 5; M.res := 0
ELSIF M.name = "YesVal" THEN
IF F.val THEN Gadgets.framehandle(F, M);
IF M.res < 0 THEN M.class := Objects.String; M.s := "" END
ELSE M.class := Objects.String; M.s := ""
END;
M.res := 0
ELSIF M.name = "Field" THEN ForceString(F, M)
ELSIF M.name = "Cmd" THEN ForceString(F, M)
ELSIF M.name = "Led" THEN M.class := Objects.Bool; M.b:= F.led; M.res := 0
ELSIF M.name = "LedColor" THEN M.class:= Objects.Int; M.i := F.ledcol; M.res := 0
ELSIF M.name = "Color" THEN
Gadgets.framehandle(F, M);
IF M.res < 0 THEN
M.class := Objects.Int; M.i := Display3.upC; M.res := 0
END
ELSE Gadgets.framehandle(F, M) END
ELSIF M.id = Objects.set THEN
IF (M.name = "Caption") THEN
IF (M.class = Objects.String) THEN F.caption := M.s; M.res := 0 END
ELSIF (M.name = "Value") THEN
IF (M.class = Objects.Bool) THEN
IF F.popout THEN M.b := FALSE END; (* small hack *)
F.val := M.b; M.res := 0;
IF F.obj # NIL THEN
ButtonSetModel(F); Gadgets.Update(F.obj)
END
END
ELSIF (M.name = "Popout") THEN
IF (M.class = Objects.Bool) THEN F.popout := M.b; M.res := 0;
IF F.val THEN (* pushed in *)
F.val := FALSE;
IF F.obj # NIL THEN
ButtonSetModel(F); Gadgets.Update(F.obj);
END;
END;
END;
ELSIF (M.name = "SetVal") THEN
IF (M.class = Objects.Int) THEN F.setval := SHORT(M.i);
IF F.obj # NIL THEN Gadgets.Update(F.obj) END;
M.res := 0
END
ELSIF (M.name = "Led") THEN
IF (M.class = Objects.Bool) THEN F.led := M.b; M.res:= 0 END
ELSIF (M.name = "LedColor") THEN
IF (M.class = Objects.Int) THEN F.ledcol := SHORT(M.i); M.res:= 0 END
ELSE Gadgets.framehandle(F, M)
END;
ELSIF M.id = Objects.enum THEN
M.Enum("Caption");
M.Enum("Value"); M.Enum("Popout"); M.Enum("Led");
M.Enum("LedColor"); M.Enum("Color"); M.Enum("SetVal");
M.Enum("YesVal"); M.Enum("Field"); M.Enum("Cmd");
Gadgets.framehandle(F, M)
END
END ButtonAttr;
PROCEDURE RestoreButton(R: Display3.Mask; F: Button; x, y, w, h, u, v, w1, h1: INTEGER; dlink: Objects.Object);
VAR D: Display.DisplayMsg; L: Gadgets.Frame; O: Display3.OverlapMsg; A: Objects.AttrMsg; ll, lr, lb, lt, col: INTEGER;
BEGIN
Oberon.RemoveMarks(x, y, w, h);
A.id := Objects.get; A.name := "Color"; A.class := Objects.Inval; A.i := Display3.upC; A.res := -1;
F.handle(F, A); IF A.class = Objects.Int THEN col := SHORT(A.i) ELSE col := Display3.upC END;
IF F.val THEN
Display3.Rect3D(R, Display3.bottomC, Display3.topC, x, y, w, h, 1, Display.replace);
Display3.Rect3D(R, Display3.downC, Display3.upC, x + 1, y + 1, w - 2, h - 2, 1, Display.replace);
Display3.ReplConst(R, col, x + 2, y + 2, w - 4, h - 4, Display.replace); (* inside *)
IF F.caption # "" THEN
Display3.CenterString(R, Display3.textC, x + 3, y + 1, w - 4, h - 4, Fonts.Default, F.caption, Display3.textmode)
ELSIF (F.look # NIL) THEN
L := F.look(Gadgets.Frame);
ll := x + w DIV 2 - L.W DIV 2 + 1; lr := ll + L.W - 1;
lb := y + h DIV 2 - L.H DIV 2 - 1; lt := lb + L.H - 1;
u := x + u; v := y + h - 1 + v;
IF u < ll THEN DEC(w1, ll - u); u := ll END;
IF v < lb THEN DEC(h1, lb - y); v := lb END;
IF u + w1 - 1 > lr THEN w1 := lr + 1 - u END;
IF v + h1 - 1 > lt THEN h1 := lt + 1 - v END;
O.F := L; O.res := -1; O.M := F.inM; O.x := 0; O.y := 0; O.dlink := NIL; L.handle(L, O);
D.device := Display.screen; D.id := Display.area; D.F := L; D.dlink := dlink;
D.x := ll - L.X; D.y := lb - L.Y;
D.u := u - ll; D.v := v - lt; D.w := w1; D.h := h1;
D.res := -1;
L.handle(L, D)
END;
IF F.led THEN
Display3.ReplConst(R, F.ledcol, x + 4, y + h - 7, 10, 3, Display.replace);
Display3.ReplConst(R, Display3.black, x + 4, y + h - 8, 10, 1, Display.replace);
Display3.ReplConst(R, Display3.black, x + 14, y + h - 8, 1, 4, Display.replace)
END
ELSE
Display3.Rect3D(R, Display3.bottomC, Display3.topC, x, y, w, h, 1, Display.replace);
Display3.Rect3D(R, Display3.topC, Display3.bottomC, x + 1, y + 1, w - 2, h - 2, 1, Display.replace);
Display3.ReplConst(R, col, x + 2, y + 2, w - 4, h - 4, Display.replace); (* inside *)
IF F.caption # "" THEN
Display3.CenterString(R, Display3.textC, x + 2, y + 2, w - 4, h - 4, Fonts.Default, F.caption, Display3.textmode)
ELSIF (F.look # NIL) THEN
L := F.look(Gadgets.Frame);
ll := x + w DIV 2 - L.W DIV 2; lr := ll + L.W - 1;
lb := y + h DIV 2 - L.H DIV 2; lt := lb + L.H - 1;
u := x + u; v := y + h - 1 + v;
IF u < ll THEN DEC(w1, ll - u); u := ll END;
IF v < lb THEN DEC(h1, lb - y); v := lb END;
IF u + w1 - 1 > lr THEN w1 := lr + 1 - u END;
IF v + h1 - 1 > lt THEN h1 := lt + 1 - v END;
O.F := L; O.res := -1; O.M := F.outM; O.x := 0; O.y := 0; O.dlink := NIL; L.handle(L, O);
D.device := Display.screen; D.id := Display.area; D.F := L; D.dlink := dlink;
D.x := ll - L.X; D.y := lb - L.Y;
D.u := u - ll; D.v := v - lt; D.w := w1; D.h := h1;
D.res := -1;
L.handle(L, D)
END
END;
IF Gadgets.selected IN F.state THEN Display3.FillPattern(R, Display3.white, Display3.selectpat, x, y, x, y, w, h, Display.paint) END
END RestoreButton;
PROCEDURE PrintButton(F: Button; VAR M: Display.DisplayMsg);
VAR R: Display3.Mask; x, y, w, h: INTEGER; D: Display.DisplayMsg; L: Gadgets.Frame; O: Display3.OverlapMsg;
PROCEDURE P(x: INTEGER): INTEGER;
BEGIN RETURN SHORT(x * Display.Unit DIV Printer.Unit)
END P;
BEGIN
Gadgets.MakePrinterMask(F, M.x, M.y, M.dlink, R);
x := M.x; y := M.y; w := P(F.W); h := P(F.H);
IF F.val THEN
Printer3.Rect3D(R, Display3.bottomC, Display3.topC, x, y, w, h, P(1), Display.replace);
Printer3.Rect3D(R, Display3.downC, Display3.upC, x + P(1), y + P(1), w - P(2), h - P(2), P(1), Display.replace);
Printer3.ReplConst(R, Display3.upC, x + P(2), y + P(2), w - P(4), h - P(4), Display.replace); (* inside *)
IF F.caption # "" THEN
Printer3.CenterString(R, Display3.textC, x + P(3), y + P(1), w - P(4), h - P(4), Fonts.Default, F.caption, Display3.textmode);
ELSIF (F.look # NIL) THEN
L := F.look(Gadgets.Frame);
O.res := -1; O.M := F.inM; O.x := 0; O.y := 0; O.dlink := NIL; L.handle(L, O);
D.device := Display.printer; D.id := Display.full; D.F := NIL; D.dlink := M.dlink;
D.x := x + w DIV 2 - P(L.W DIV 2) + P(1); D.y := y + h DIV 2 - P(L.H DIV 2) - P(1);
D.res := -1;
L.handle(L, D)
END;
IF F.led THEN
Printer3.ReplConst(R, F.ledcol, x + P(4), y + h - P(7), P(10), P(3), Display.replace);
Printer3.ReplConst(R, Display3.black, x + P(4), y + h - P(8), P(10), P(1), Display.replace);
Printer3.ReplConst(R, Display3.black, x + P(14), y + h - P(8), P(1), P(4), Display.replace)
END
ELSE
Printer3.Rect3D(R, Display3.bottomC, Display3.topC, x, y, w, h, P(1), Display.replace);
Printer3.Rect3D(R, Display3.topC, Display3.bottomC, x + P(1), y + P(1), w - P(2), h - P(2), P(1), Display.replace);
Printer3.ReplConst(R, Display3.upC, x + P(2), y + P(2), w - P(4), h - P(4), Display.replace); (* inside *)
IF F.caption # "" THEN
Printer3.CenterString(R, Display3.textC, x + P(2), y + P(2), w - P(4), h - P(4), Fonts.Default, F.caption, Display3.textmode);
ELSIF (F.look # NIL) THEN
L := F.look(Gadgets.Frame);
O.res := -1; O.M := F.outM; O.x := 0; O.y := 0; O.dlink := NIL; L.handle(L, O);
D.device := Display.printer; D.id := Display.full; D.F := NIL; D.dlink := M.dlink;
D.x := x + w DIV 2 - P(L.W DIV 2); D.y := y + h DIV 2 - P(L.H DIV 2);
D.res := -1;
L.handle(L, D);
END;
END
END PrintButton;
PROCEDURE CopyButton*(VAR M: Objects.CopyMsg; from, to: Button);
BEGIN
Gadgets.CopyFrame(M, from, to); to.caption := from.caption; to.val := from.val; to.popout := from.popout;
to.look := Gadgets.CopyPtr(M, from.look); to.setval := from.setval;
to.led := from.led; to.ledcol := from.ledcol
END CopyButton;
PROCEDURE ButtonHandler*(F: Objects.Object; VAR M: Objects.ObjMsg);
VAR F2: Button; x, y, w, h: INTEGER;
keysum: SET; ver: LONGINT; f: Gadgets.Frame; R: Display3.Mask;
BEGIN
WITH F: Button DO
IF M IS Objects.AttrMsg THEN
WITH M: Objects.AttrMsg DO ButtonAttr(F, M) END;
ELSIF M IS Objects.FileMsg THEN
WITH M: Objects.FileMsg DO
IF M.id = Objects.store THEN
IF ~F.led OR (F.ledcol # Display3.red) THEN
Files.WriteNum(M.R, VersionNewButton);
IF F.led THEN Files.WriteInt(M.R, 1); ELSE Files.WriteInt(M.R, 0); END;
Files.WriteInt(M.R, F.ledcol)
ELSE Files.WriteNum(M.R, 3)
END;
Files.WriteString(M.R, F.caption);
IF F.val THEN Files.WriteInt(M.R, 1); ELSE Files.WriteInt(M.R, 0); END;
IF F.popout THEN Files.WriteInt(M.R, 1); ELSE Files.WriteInt(M.R, 0); END;
Files.WriteInt(M.R,F.setval);
Gadgets.WriteRef(M.R, F.lib, F.look);
Gadgets.framehandle(F, M)
ELSIF M.id = Objects.load THEN
Files.ReadNum(M.R, ver);
IF ver = VersionNo THEN
Files.ReadString(M.R, F.caption);
Files.ReadInt(M.R, x); F.val := (x = 1);
Files.ReadInt(M.R, x); F.popout := (x = 1);
Gadgets.framehandle(F, M);
IF (F.obj # NIL) & (F.obj IS Integer) THEN Files.ReadInt(M.R, x); F.setval := SHORT(x) END;
ELSIF ver >= 3 THEN
IF ver = VersionNewButton THEN
Files.ReadInt(M.R, x); F.led := (x = 1);
Files.ReadInt(M.R, F.ledcol)
END;
Files.ReadString(M.R, F.caption);
Files.ReadInt(M.R, x); F.val := (x = 1);
Files.ReadInt(M.R, x); F.popout := (x = 1); IF F.popout THEN F.val := FALSE END;
Files.ReadInt(M.R,F.setval);
Gadgets.ReadRef(M.R, F.lib, F.look);
Gadgets.framehandle(F, M);
ELSE
Texts.WriteString(W, "Version "); Texts.WriteInt(W, VersionNewButton, 3);
Texts.WriteString(W, " of buttons cannot read version "); Texts.WriteInt(W, ver, 3); Texts.WriteLn(W); Log;
HALT(42);
END
END
END
ELSIF M IS Objects.CopyMsg THEN
WITH M: Objects.CopyMsg DO
IF M.stamp = F.stamp THEN
M.obj := F.dlink
ELSE
NEW(F2); F.stamp := M.stamp; F.dlink := F2; CopyButton(M, F, F2); M.obj := F2
END
END
ELSIF M IS Objects.BindMsg THEN
Gadgets.framehandle(F, M);
IF F.look # NIL THEN F.look.handle(F.look, M) END;
ELSIF M IS Objects.LinkMsg THEN (* ps - 8.5.96 *)
WITH M: Objects.LinkMsg DO
IF M.id = Objects.get THEN
IF M.name = "Look" THEN M.obj:= F.look; M.res:= 0
ELSE Gadgets.framehandle(F, M)
END
ELSIF M.id = Objects.set THEN
IF M.name = "Look" THEN
IF M.obj = NIL THEN F.look:= NIL; M.res:= 0
ELSIF M.obj = F.look THEN M.res:= 0
ELSIF M.obj IS Gadgets.Frame THEN
IF ButtonSetLook(F, M.obj(Gadgets.Frame)) THEN M.res:= 0 END
END
ELSE Gadgets.framehandle(F, M)
END
ELSIF M.id = Objects.enum THEN
M.Enum("Look"); Gadgets.framehandle(F, M)
END
END
ELSIF M IS Display.FrameMsg THEN
WITH M: Display.FrameMsg DO
IF M.res >= 0 THEN RETURN END;
x := M.x + F.X; y := M.y + F.Y; w := F.W; h := F.H;
IF M IS Display.DisplayMsg THEN
WITH M: Display.DisplayMsg DO
IF M.device = Display.screen THEN
IF (M.F = NIL) OR ((M.id = Display.full) & (M.F = F)) THEN
Gadgets.MakeMask(F, x, y, M.dlink, R);
RestoreButton(R, F, x, y, w, h, 0, 1 - h, w, h, M.dlink)
ELSIF (M.id = Display.area) & (M.F = F) THEN
Gadgets.MakeMask(F, x, y, M.dlink, R);
Display3.AdjustMask(R, x + M.u, y + h - 1 + M.v, M.w, M.h);
RestoreButton(R, F, x, y, w, h, M.u, M.v, M.w, M.h, M.dlink)
END
ELSIF M.device = Display.printer THEN PrintButton(F, M)
END
END
ELSIF M IS Display.ConsumeMsg THEN
WITH M: Display.ConsumeMsg DO (* ps - 8.5.96 *)
IF (M.id = Display.drop) & (M.F = F) & (F.caption = "") & (M.obj IS Gadgets.Frame) & (F.look = NIL) THEN
IF ButtonSetLook(F, M.obj(Gadgets.Frame)) THEN
M.res:= 0; Gadgets.Update(F);
END
ELSE
Gadgets.framehandle(F, M);
END
END
ELSIF M IS Display3.OverlapMsg THEN
WITH M: Display3.OverlapMsg DO
Gadgets.framehandle(F, M);
IF F.look # NIL THEN
f := F.look(Gadgets.Frame);
IF F.mask = NIL THEN
KillMasks(F.look); F.inM := NIL; F.outM := NIL;
ELSE
Display3.Copy(M.M, F.outM);
Display3.Intersect(F.outM, 2, -h + 3, w - 4, h - 4);
Display3.Intersect(F.outM, w DIV 2 - f.W DIV 2, (-h+1) DIV 2 - f.H DIV 2, f.W, f.H);
F.outM.x := -(w DIV 2 - f.W DIV 2); F.outM.y := -((-h+1) DIV 2 - f.H DIV 2 + f.H) + 1;
Display3.Shift(F.outM);
Display3.Copy(M.M, F.inM);
Display3.Intersect(F.inM, 2, -h + 3, w - 4, h - 4);
Display3.Intersect(F.inM, w DIV 2 - f.W DIV 2 + 1, (-h+1) DIV 2 - f.H DIV 2 - 1, f.W, f.H);
F.inM.x := -(w DIV 2 - f.W DIV 2 + 1); F.inM.y := -((-h+1) DIV 2 - f.H DIV 2 + f.H - 1) + 1;
Display3.Shift(F.inM)
END
END
END
ELSIF M IS Gadgets.UpdateMsg THEN
WITH M: Gadgets.UpdateMsg DO
IF F.obj # NIL THEN F.obj.handle(F.obj, M) END;
IF M.obj = F.obj THEN
IF M.stamp # F.stamp THEN F.stamp := M.stamp;
ButtonUpdateModel(F)
END;
Gadgets.MakeMask(F, x, y, M.dlink, R);
RestoreButton(R, F, x, y, w, h, 0, 1 - h, w, h, M.dlink)
ELSE Gadgets.framehandle(F, M)
END
END
ELSIF M IS Display.ControlMsg THEN (*!!! *)
WITH M: Display.ControlMsg DO
IF F.obj # NIL THEN F.obj.handle(F.obj, M) END;
IF (M.id = Display.restore) & (M.stamp # F.stamp) THEN F.stamp := M.stamp;
ButtonUpdateModel(F)
END
END
ELSIF M IS Oberon.InputMsg THEN
WITH M: Oberon.InputMsg DO
IF (M.id = Oberon.track) & (1 IN M.keys) & Gadgets.InActiveArea(F, M) THEN
F.val := ~F.val;
IF F.obj # NIL THEN
ButtonSetModel(F); Gadgets.Update(F.obj)
ELSE Gadgets.Update(F)
END;
IF F.popout THEN
keysum := M.keys;
REPEAT
IF F.val # Effects.Inside(M.X, M.Y, x, y, w, h) THEN
F.val := ~F.val;
IF F.obj # NIL THEN
ButtonSetModel(F); Gadgets.Update(F.obj);
ELSE Gadgets.Update(F)
END;
END;
Effects.TrackMouse(M.keys, M.X, M.Y, Effects.Arrow);
keysum := keysum + M.keys;
UNTIL M.keys = {}; M.res := 0;
IF F.val THEN
F.val := ~F.val;
IF F.obj # NIL THEN
ButtonSetModel(F); Gadgets.Update(F.obj)
ELSE Gadgets.Update(F);
END;
IF keysum = {1} THEN
Gadgets.ExecuteAttr(F, "Cmd", M.dlink, NIL, NIL);
END
END
ELSE
keysum := M.keys;
REPEAT Effects.TrackMouse(M.keys, M.X, M.Y, Effects.Arrow); keysum := keysum + M.keys;
UNTIL M.keys = {}; M.res := 0;
IF keysum = {1} THEN
Gadgets.ExecuteAttr(F, "Cmd", M.dlink, NIL, NIL);
END;
END;
ELSIF ~(Gadgets.selected IN F.state) THEN
Gadgets.framehandle(F, M);
END;
END;
ELSE
Gadgets.framehandle(F, M);
END;
END;
ELSE
Gadgets.framehandle(F, M);
END;
END;
END ButtonHandler;
PROCEDURE InitButton*(F: Button);
BEGIN
F.handle := ButtonHandler; F.W := 40; F.H := 30;
F.popout := TRUE; F.led:= TRUE; F.ledcol:= Display3.red;
F.caption := "Button"
END InitButton;
PROCEDURE NewButton*;
VAR F: Button;
BEGIN
NEW(F); InitButton(F); Objects.NewObj := F;
END NewButton;
(* ========== Checkboxes ================ *)
PROCEDURE CheckBoxUpdateModel(F: CheckBox);
VAR A: Objects.AttrMsg;
BEGIN
IF F.obj # NIL THEN
A.id := Objects.get; Field(F, A.name); A.class := Objects.Inval; A.res := -1;
F.obj.handle(F.obj, A);
IF A.res >= 0 THEN
IF A.class = Objects.Bool THEN F.val := A.b
ELSIF A.class = Objects.Int THEN F.val := A.i = F.setval
END
END
END
END CheckBoxUpdateModel;
PROCEDURE CheckBoxSetModel(F: CheckBox);
VAR A: Objects.AttrMsg;
BEGIN
IF F.obj # NIL THEN
A.id := Objects.get; Field(F, A.name); A.class := Objects.Inval; A.res := -1;
F.obj.handle(F.obj, A);
IF A.res >= 0 THEN
A.dlink := F.dlink;
IF A.class = Objects.Bool THEN A.b := F.val;
A.id := Objects.set; A.res := -1; F.obj.handle(F.obj, A)
ELSIF A.class = Objects.Int THEN
IF F.val THEN A.i := F.setval; A.id := Objects.set; A.res := -1; F.obj.handle(F.obj, A) END
END
END
END
END CheckBoxSetModel;
PROCEDURE CheckBoxAttr(B: CheckBox; VAR M: Objects.AttrMsg);
BEGIN
IF M.id = Objects.get THEN
IF M.name = "Gen" THEN M.class := Objects.String; M.s := "BasicGadgets.NewCheckBox"; M.res := 0
ELSIF M.name = "Value" THEN M.class := Objects.Bool; M.b := B.val; M.res := 0
ELSIF M.name = "SetVal" THEN M.class := Objects.Int; M.i := B.setval; M.res := 0
ELSIF M.name = "LineupHY" THEN M.class := Objects.Int; M.i := B.H DIV 2 - 5; M.res := 0
ELSIF M.name = "YesVal" THEN (* ps - 3.5.96 *)
IF B.val THEN
Gadgets.framehandle(B, M);
IF M.res < 0 THEN M.class := Objects.String; M.s := "" END
ELSE M.class := Objects.String; M.s := "" END; M.res := 0;
ELSIF M.name = "Field" THEN ForceString(B, M)
ELSIF M.name = "Cmd" THEN ForceString(B, M)
ELSIF M.name = "Color" THEN
Gadgets.framehandle(B, M);
IF M.res < 0 THEN
M.class := Objects.Int; M.i := Display3.textbackC; M.res := 0
END
ELSE Gadgets.framehandle(B, M);
END;
ELSIF M.id = Objects.set THEN
IF M.name = "Value" THEN
IF (M.class = Objects.Bool) THEN B.val := M.b; M.res := 0;
IF B.obj # NIL THEN
CheckBoxSetModel(B); Gadgets.Update(B.obj);
END
END;
ELSIF M.name = "SetVal" THEN
IF (M.class = Objects.Int) THEN B.setval := SHORT(M.i);
IF B.obj # NIL THEN Gadgets.Update(B.obj) END;
M.res := 0;
END
ELSE Gadgets.framehandle(B, M)
END;
ELSIF M.id = Objects.enum THEN
M.Enum("Value"); M.Enum("YesVal"); M.Enum("SetVal"); M.Enum("Field"); M.Enum("Cmd"); M.Enum("Color"); Gadgets.framehandle(B, M);
END;
END CheckBoxAttr;
PROCEDURE RestoreCheckBox(R: Display3.Mask; F: CheckBox; x, y, w, h: INTEGER);
VAR A: Objects.AttrMsg; col: INTEGER;
BEGIN
Oberon.RemoveMarks(x, y, w, h);
A.id := Objects.get; A.name := "Color"; A.class := Objects.Inval; A.i := Display3.textbackC; A.res := -1;
F.handle(F, A); IF A.class = Objects.Int THEN col := SHORT(A.i) ELSE col := Display3.textbackC END;
A.id := Objects.get; Field(F, A.name); A.class := Objects.Inval; A.res := -1;
IF F.obj # NIL THEN F.obj.handle(F.obj, A) END;
IF (A.res >= 0) & (A.class = Objects.Int) THEN (* change look if integers are involved *)
Display3.FilledRect3D(R, Display3.bottomC, Display3.topC, col, x, y, w, h, 1, Display.replace);
IF F.val THEN
Display3.FilledRect3D(R, Display3.topC, Display3.bottomC, Display3.groupC, x + 3, y + 3, w - 6, h - 6, 1, Display.replace);
END
ELSE
Display3.FilledRect3D(R, Display3.bottomC, Display3.topC, col, x, y, w, h, 1, Display.replace);
IF F.val THEN
Display3.ReplConst(R, Display3.white, x + 5, y + 4, 1, 10, Display.replace);
Display3.ReplConst(R, Display3.black, x + 6, y + 4, 1, 10, Display.replace);
Display3.Line(R, Display3.white, Display.solid, x + 5, y + 5, x + 17, y + 17, 1, Display.replace);
Display3.Line(R, Display3.black, Display.solid, x + 5, y + 4, x + 17, y + 16, 1, Display.replace);
END
END;
IF Gadgets.selected IN F.state THEN Display3.FillPattern(R, Display3.white, Display3.selectpat, x, y, x, y, w, h, Display.paint); END;
END RestoreCheckBox;
PROCEDURE PrintCheckBox(F: CheckBox; VAR M: Display.DisplayMsg);
VAR A: Objects.AttrMsg; R: Display3.Mask; x, y, w, h, col: INTEGER;
PROCEDURE P(x: INTEGER): INTEGER;
BEGIN RETURN SHORT(x * Display.Unit DIV Printer.Unit)
END P;
BEGIN
Gadgets.MakePrinterMask(F, M.x, M.y, M.dlink, R);
A.id := Objects.get; A.name := "Color"; A.class := Objects.Inval; A.i := Display3.textbackC; A.res := -1;
F.handle(F, A); IF A.class = Objects.Int THEN col := SHORT(A.i) ELSE col := Display3.textbackC END;
x := M.x; y := M.y; w := P(F.W); h := P(F.H);
IF (F.obj # NIL) & (F.obj IS Integer) THEN
Printer3.FilledRect3D(R, Display3.bottomC, Display3.topC, col, x, y, w, h, P(1), Display.replace);
IF F.val THEN
Printer3.FilledRect3D(R, Display3.topC, Display3.bottomC, Display3.groupC, x + P(3), y + P(3), w - P(6), h - P(6), 1, Display.replace);
END
ELSE
Printer3.FilledRect3D(R, Display3.bottomC, Display3.topC, col, x, y, w, h, P(1), Display.replace);