forked from rochus-keller/OberonSystem3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gadgets.Mod
1846 lines (1704 loc) · 81.5 KB
/
Gadgets.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 Gadgets; (** portable *) (* , jm 18.1.95*)
(**The Gadgets module forms the basis of the Gadgets system. It defines the most important types, provide default message handlers and often used utility procedures. In addition, a few gadget specific messages are defined.
*)
(*
jm 9.2.93 - Attributes for abstract objects
- object name belongs intrinsically to objects
- support for non gadget frames removed
jm 10.2.93 - support for empty object names
- fixed attributes for abstract objects
jm 11.2.93 - Display.ControlMsg
- moved mask messages to Display3
jm 15.3.93 - Better creation of default clip masks
jm 16.3.93 - ReadRef bug
jm 17.3.93 - Add context to executor dlink when executing a command
jm 23.2.93 - Fixed semantics of Oberon.Par.obj & Oberon.Par.frame
jm 24.2.93 - Warning thrown out
jm 24.2.93 - Gadgets.Execute hack
jm 2.3.93 - Notes removed
jm 3.3.93 - ExecuteAttr corrected
jm 10.3.93 - fix version message
jm 11.3.93 - Call error correction
7.4.93 - Introduced editing platform code
8.4.93 - removed edit platform code
23.7.93 - fixed copy object
17.09.93 15:09:48 - Find message
06.01.94 - improved handling of UpdateMsg slightly
29.3.94 - Broadcast removed
- Fixed UpArrow macro
5.4.94 - fixed unnaming of objects in public libraries
19.4.94 - added aliasing support to Insert, removed aliasing from Attributes.Scanner
19.4.94 - Improved lookup macro
20.4.94 - added visible constant
27.5.94 - improved track highlight in track frame
29.6.94 - Added alias support to Change*
14.7.94 - added some more debug tests for invalid masks, most are deactivated now, search for debug
18.7.94 - changed object naming
3.11.94 - unchanged change of 18.7.94
7.11.94 - unchanged change of 18.7.94
8.11.94 - changed rules in IsLocked
29.11.94
- removed optimization flags from Gadgets
- removed nomove, noresize, nodelete, noselect flags from Gadgets
- renamed lockchildren to locked
30.11.94
- added lockedsize (same as noresize before)
- renamed locked to lockedcontents
6.12.94 - added GetSelection
14.12.94 - CopyObject implemented
15.12.94 - removed col from Gadgets.Frame
16.12.94 - removed selection bug
21.12.94 - When no attribute exists on Objects.AttrMsg "get", nothing is returned. Previously
an empty string was returned.
3.8.95 - load aliases from the Registry
6.12.95 - added ClipMask to Gadgets.ViewDesc (thanks ps) (changes the symbol file)
15.12.95 - CreateObject now uses Modules.resMsg
8.5.96 - fixed bug in Recursive
20.5.96 - CreateObject now understands aliases (ps - 20.5.96)
6.6.96 - changed Execute (light weight)
19.6.96 - fixed bug in new Execute
10.7.96 - added deep parameter to GetPublicObject (* ejz - 10.7.96 *)
4.8.96 - changed printer mask scaling to Printer.Frame
14.08.96 pjm - fix in UpArrowMacro for selected objects
18.2.97 - added ModifySize and Consume
*)
IMPORT
Objects, Display, Display3, Effects, Oberon, Texts, Input, Files, Modules,
Printer, Printer3, Attributes, Links, Viewers, Strings;
CONST
(** Priority message id's. *)
top* = 0; (** Move gadget to the front. *)
bottom* = 1; (** Move gadget to the back. *)
visible* = 2; (** Move gadget to the front if not completely visible. *)
(** Gadget Frame states. *)
selected* = 0; (** Selected or not. *)
lockedsize* = 2; (** Gadget prefers a fixed W, H. *)
transparent* = 4; (** Transparent or not. *)
lockedcontents* = 10; (** All direct descendants are locked. *)
left = 2; middle = 1; right = 0;
TYPE
(** Message broadcast in the display space to indicate that "obj" has changed. Normally used for updating model gadgets, although obj can be a list of gadget frames belonging to the same container. In this case all of the frames are to be displayed. This message is used by the Inspector to indicate that an attribute value has changed. *)
UpdateMsg* = RECORD (Display.FrameMsg)
obj*: Objects.Object;
END;
(** Message broadcast in the display space to indicate that the destination frame F wants to change its overlapping priority. *)
PriorityMsg* = RECORD (Display.FrameMsg)
id*: INTEGER; (** Top, bottom, visible. *)
passon*: BOOLEAN; (** Indication if a whole tree of containers should be changed in priority. *)
END;
CmdMsg* = RECORD (Objects.ObjMsg)
cmd*: ARRAY 128 OF CHAR; (* Information to be passed, command to be executed; result returned. *)
res*: INTEGER; (* result code *)
END;
(** Base type of the Model gadgets *)
Object* = POINTER TO ObjDesc;
ObjDesc* = RECORD (Objects.ObjDesc)
attr*: Attributes.Attr; (** Attribute list. Private variable. *)
link*: Links.Link; (** Link list. Private variable. *)
END;
(** Base type of the visual gadgets *)
Frame* = POINTER TO FrameDesc;
FrameDesc* = RECORD (Display.FrameDesc)
attr*: Attributes.Attr; (** Attribute list. Private variable. *)
link*: Links.Link; (** Link list. Private variable. *)
state*: SET;
mask*: Display3.Mask; (** Cached display mask. Can be NIL to indicate no/invalid mask. *)
obj*: Objects.Object; (** Model object, if any. *)
END;
(** Base type of the camera-view gadgets. *)
View* = POINTER TO ViewDesc;
ViewDesc* = RECORD (FrameDesc)
absX*, absY*: INTEGER; (** Absolute screen position at last message forward to descendants. *)
border*: INTEGER; (** Border width for clipping. *)
(** Install own clipping to display/printer mask here if view has an irregular outline. Otherwise set to NIL. *)
ClipMask*: PROCEDURE (v: View; M: Display3.Mask; ondisplay: BOOLEAN);
END;
(** Calculate a mask for gadget G positioned at X, Y in the context dlink. *)
MakeMaskHandler* = PROCEDURE (G: Frame; X, Y: INTEGER; dlink: Objects.Object; VAR M: Display3.Mask);
RecursiveMsg = RECORD (Display.FrameMsg) END;
Stack = RECORD
Mdlink, Fdlink: Objects.Object;
absX, absY: INTEGER;
END;
CONST
nameLen = 32; valueLen = 64;
TYPE
Alias = POINTER TO AliasDesc;
AliasDesc = RECORD
name: ARRAY nameLen OF CHAR;
value: ARRAY valueLen OF CHAR;
next: Alias;
END;
VAR
framehandle*: Objects.Handler; (** Default message handler for visual gadgets. *)
objecthandle*: Objects.Handler; (** Default message handler for Model gadgets. *)
MakeMask*: MakeMaskHandler; (** Calculates the current display mask of a visual gadget. *)
MakePrinterMask*: MakeMaskHandler; (** Calculates the current printer mask of a visual gadget. *)
(** The following fields are used for parameter transfer during command execution. *)
context*: Objects.Object; (** Context/parent of a gadget executing the command *)
executorObj*: Objects.Object; (** Gadget executing the command. Same as Oberon.Par.obj. *)
senderObj*: Objects.Object; (** Initiator of a drag and drop operation i.e. the gadget being dropped. *)
receiverObj*: Objects.Object; (** Receiver of a dropped gadget. Often same as executorObj. *)
aliases: Alias;
par: Oberon.ParList;
emptyText: Texts.Text;
W, WW, mW: Texts.Writer;
recurse, uparrowdone, verbose: BOOLEAN;
pMask: Display3.Mask; tmpX, tmpY: INTEGER;
(* Misc *)
PROCEDURE Log;
BEGIN Texts.Append(Oberon.Log, W.buf); END Log;
PROCEDURE Push(VAR S: Stack; F: View; VAR M: Display.FrameMsg);
BEGIN
(* save old variables *)
S.Fdlink := F.dlink; S.Mdlink := M.dlink; S.absX := F.absX; S.absY := F.absY;
F.dlink := M.dlink; M.dlink := F
END Push;
PROCEDURE Pop(VAR S: Stack; F: View; VAR M: Display.FrameMsg);
BEGIN
M.dlink := S.Mdlink; F.dlink := S.Fdlink; F.absX := S.absX; F.absY := S.absY
END Pop;
(* general purpose *)
(** Is the context/parent of the frame F locked ? *)
PROCEDURE IsLocked*(F: Frame; dlink: Objects.Object): BOOLEAN;
VAR A: Objects.AttrMsg;
BEGIN
IF dlink # NIL THEN
IF dlink IS Frame THEN RETURN lockedcontents IN dlink(Frame).state
ELSIF dlink.handle # NIL THEN (* not a frame *)
A.id := Objects.get; A.name := "Locked"; A.res := -1; dlink.handle(dlink, A);
RETURN (A.res >= 0) & (A.class = Objects.Bool) & A.b
ELSE RETURN FALSE
END
ELSE RETURN FALSE
END
END IsLocked;
(** Is the mouse located inside the work area of a gadget (i.e. excluding the control areas)? *)
PROCEDURE InActiveArea*(F: Frame; VAR M: Oberon.InputMsg): BOOLEAN;
VAR x, y, w, h: INTEGER;
BEGIN
x := M.x + F.X; y := M.y + F.Y; w := F.W; h := F.H;
IF Effects.Inside(M.X, M.Y, x, y, w, h) & ~(selected IN F.state) THEN
IF IsLocked(F, M.dlink) THEN RETURN TRUE
ELSIF Effects.InBorder(M.X, M.Y, x, y, w, h) THEN RETURN FALSE
ELSE RETURN TRUE
END
ELSE RETURN FALSE
END
END InActiveArea;
(** Returns the name of of obj. Sends an Objects.AttrMsg behind the scenes. *)
PROCEDURE GetObjName*(obj: Objects.Object; VAR name: ARRAY OF CHAR);
VAR A: Objects.AttrMsg;
BEGIN
name[0] := 0X;
A.id := Objects.get; A.name := "Name"; A.res := -1; A.s[0] := 0X;
obj.handle(obj, A);
IF (A.res >= 0) & (A.class = Objects.String) THEN name := A.s END
END GetObjName;
(** Name object obj. Sends an Objects.AttrMsg behind the scenes. *)
PROCEDURE NameObj*(obj: Objects.Object; IN name: ARRAY OF CHAR);
VAR A: Objects.AttrMsg;
BEGIN
A.id := Objects.set; A.name := "Name"; Objects.Stamp(A); A.class := Objects.String; A.res := -1; A.s := name;
obj.handle(obj, A);
END NameObj;
(** Search for the object "O" in the public library "L.Lib" wherename is specified as "L.O". *)
PROCEDURE FindPublicObj*(IN name: ARRAY OF CHAR): Objects.Object; (* Lib.obj format, assumes .Lib extension *)
VAR obj: Objects.Object; libname, objname: ARRAY 64 OF CHAR; i, j, k, ref: INTEGER; lib: Objects.Library;
BEGIN
obj := NIL; i := 0; j := 0;
WHILE (name[i] # ".") & (name[i] # 0X) DO libname[j] := name[i]; INC(j); INC(i); END;
IF name[i] = 0X THEN RETURN NIL END;
libname[j] := 0X; k := j; INC(i); j := 0;
WHILE (name[i] # " ") & (name[i] # 0X) DO objname[j] := name[i]; INC(j); INC(i); END;
objname[j] := 0X;
libname[k] := "."; libname[k+1] := "L"; libname[k+2] := "i"; libname[k+3] := "b"; libname[k+4] := 0X;
lib := Objects.ThisLibrary(libname);
IF lib # NIL THEN
Objects.GetRef(lib.dict, objname, ref);
IF ref # MIN(INTEGER) THEN lib.GetObj(lib, ref, obj); END
END;
RETURN obj;
END FindPublicObj;
(** Search for object named name in context. *)
PROCEDURE FindObj*(context: Objects.Object; IN name: ARRAY OF CHAR): Objects.Object;
VAR obj: Objects.Object; M: Objects.FindMsg;
BEGIN
obj := NIL;
IF context # NIL THEN (* search by find message *)
M.obj := NIL; M.name := name; context.handle(context, M);
obj := M.obj
END;
RETURN obj
END FindObj;
(** Sets new W and H to (offscreen) frame F. *)
PROCEDURE ModifySize* (F: Display.Frame; W, H: INTEGER);
VAR M: Display.ModifyMsg;
BEGIN
IF (F # NIL) & ((F.W # W) OR (F.H # H)) THEN
M.id := Display.extend; M.mode := Display.state; M.F := F;
M.X := F.X; M.Y := F.Y + F.H - H; M.W := W; M.H := H;
M.dW := W - F.W; M.dH := H - F.H; M.dX := 0; M.dY := -M.dH;
M.dlink := NIL; M.x := 0; M.y := 0; M.res := -1; Objects.Stamp(M);
F.handle(F, M)
END
END ModifySize;
(** Inserts the frame f into container F at (u, v). (u, v) is relative to upper left corner of F. *)
PROCEDURE Consume* (F, f: Frame; u, v: INTEGER);
VAR C: Display.ConsumeMsg;
BEGIN
IF (F # NIL) & (f # NIL) THEN
f.slink := NIL;
C.id := Display.drop; C.F := F;
C.res := -1; C.dlink := NIL; C.x := 0; C.v := 0;
C.u := u; C.v := v; C.obj := f;
F.handle(F, C)
END
END Consume;
(** Returns a deep or shallow copy of object obj, depending on parameter deep *)
PROCEDURE Clone*(obj: Objects.Object; deep: BOOLEAN): Objects.Object;
VAR C: Objects.CopyMsg;
BEGIN
C.obj := NIL;
IF obj # NIL THEN
IF deep THEN C.id := Objects.deep ELSE C.id := Objects.shallow END;
Objects.Stamp(C); C.dlink := NIL; obj.handle(obj, C)
END;
RETURN C.obj
END Clone;
(* --- Recursion checking --- *)
PROCEDURE *RecursiveHandler(obj: Objects.Object; VAR M: Objects.ObjMsg);
BEGIN IF ~(M IS Display3.UpdateMaskMsg) THEN recurse := TRUE END;
END RecursiveHandler;
(** Check if a message loop would be created should newchild be inserted in the container parent. Sends a dummy message behind the scenes. *)
PROCEDURE Recursive*(parent, newchild: Objects.Object): BOOLEAN;
VAR old: Objects.Handler; M: RecursiveMsg;
BEGIN
old := parent.handle; M.dlink := NIL; M.F := NIL; M.x := 0; M.y := 0; M.res:= -1;
parent.handle := RecursiveHandler; recurse := FALSE;
newchild.handle(newchild, M);
parent.handle := old;
RETURN recurse;
END Recursive;
(** Broadcasts an Gadgets.UpdateMsg should obj be a model gadget, or a Display.DisplayMsg if obj is a Display.Frame. *)
PROCEDURE Update*(obj: Objects.Object);
VAR M: UpdateMsg; D: Display.DisplayMsg;
BEGIN
IF obj IS Display.Frame THEN
D.device := Display.screen; D.id := Display.full; D.F := obj(Display.Frame); Display.Broadcast(D)
ELSE
M.obj := obj; M.F := NIL; Display.Broadcast(M)
END;
END Update;
(** Make a copy of a pointer to an object. A shallow copy returns a reference to obj. A deep copy results in M being forwarded to obj. *)
PROCEDURE CopyPtr*(VAR M: Objects.CopyMsg; obj: Objects.Object): Objects.Object;
BEGIN
IF obj = NIL THEN RETURN NIL
ELSE
IF M.id = Objects.deep THEN
M.obj := NIL; obj.handle(obj, M); RETURN M.obj
ELSE (* shallow *)
RETURN obj
END;
END;
END CopyPtr;
(** Copy the record fields belonging to the base gadget type. Copies handle, X, Y, W, H, state, attr and obj.*)
PROCEDURE CopyFrame*(VAR M: Objects.CopyMsg; F, F0: Frame);
BEGIN
(* F0.slink := NIL; F0.lib := NIL; F0.ref := -1; F0.next := NIL; F0.dsc := NIL; *)
F0.handle := F.handle; F0.X := F.X; F0.Y := F.Y; F0.W := F.W; F0.H := F.H;
F0.state := F.state;
Attributes.CopyAttributes(F.attr, F0.attr);
Links.CopyLinks(M, F.link, F0.link);
F0.obj := CopyPtr(M, F.obj);
END CopyFrame;
(** Copy the record fields belonging to the base Model gadget type. Copies handle and attr. *)
PROCEDURE CopyObject*(VAR M: Objects.CopyMsg; obj, obj0: Object);
BEGIN
obj0.handle := obj.handle;
Attributes.CopyAttributes(obj.attr, obj0.attr);
Links.CopyLinks(M, obj.link, obj0.link)
END CopyObject;
PROCEDURE *EmptyHandler(obj: Objects.Object; VAR M: Objects.ObjMsg);
END EmptyHandler;
(** Default handling of Display.ModifyMsg for visual gadgets. F.mask is invalidated when the frame changes its location or size. Sends behind the scenes to F an Display.OverlapMsg message to invalidate F.mask. Finally, a Display.DisplayMsg is broadcast to update F on the display.*)
PROCEDURE Adjust*(F: Display.Frame; VAR M: Display.ModifyMsg);
VAR D: Display.DisplayMsg; O: Display3.OverlapMsg;
BEGIN
IF (F.X # M.X) OR (F.Y # M.Y) OR (F.W # M.W) OR (F.H # M.H) THEN (* first adjust *)
F.X := M.X; F.Y := M.Y; F.W := M.W; F.H := M.H;
IF F IS Frame THEN O.F := F; O.M := NIL; O.x := 0; O.y := 0; O.res := -1; O.dlink := NIL; F.handle(F, O);
END
END;
IF (M.mode = Display.display) & (F.H > 0) & (F.W >0) THEN
D.x := M.x; D.y := M.y; D.F := F; D.device := Display.screen; D.id := Display.full;
D.dlink := M.dlink; D.res := -1; Objects.Stamp(D);
F.handle(F, D)
END
END Adjust;
(** Returns the frame that is located at X, Y on the display. U, v return the relative coordinates of X, Y inside F. Behind the scenes a Display.LocateMsg is broadcast. *)
PROCEDURE ThisFrame*(X, Y: INTEGER; VAR F: Display.Frame; VAR u, v: INTEGER);
VAR M: Display.LocateMsg;
BEGIN M.X := X; M.Y := Y; M.F := NIL; M.loc := NIL; Display.Broadcast(M); F := M.loc; u := M.u; v := M.v;
END ThisFrame;
(** Implements standard resize handling for frames. Rubber-bands the gadget size and broadcasts a Display.ModifyMsg. *)
PROCEDURE SizeFrame*(F: Display.Frame; VAR M: Oberon.InputMsg);
VAR x, y, w, h, X, Y: INTEGER; keys: SET; A: Display.ModifyMsg;
BEGIN
x := M.x + F.X; y := M.y + F.Y; w := F.W; h := F.H;
Input.Mouse(keys, X, Y);
Effects.SizeRect(NIL, keys, X, Y, x, y, w, h, NIL);
IF keys # {0, 1, 2} THEN
A.id := Display.extend; A.mode := Display.display; A.X := x - M.x; A.Y := y - M.y; A.W := w; A.H := h;
A.F := F; A.dX := A.X - F.X; A.dY := A.Y - F.Y; A.dW := A.W - F.W; A.dH := A.H - F.H;
Display.Broadcast(A);
M.res := 0
ELSE M.res := 1
END
END SizeFrame;
(** Implements standard move behaviour for frames. Tracks the gadget outline, broadcasts a ConsumeMsg on a copy-over or consume interclick, or broadcast a Display.ModifyMsg for a simple move operation. *)
PROCEDURE MoveFrame*(F: Display.Frame; VAR M: Oberon.InputMsg);
VAR x, y, w, h, X, Y, u0, v0: INTEGER; keys: SET; A: Display.ModifyMsg; f: Display.Frame;
C: Display.ConsumeMsg; old: Objects.Handler; CM: Objects.CopyMsg;
BEGIN
x := M.x + F.X; y := M.y + F.Y; w := F.W; h := F.H;
Input.Mouse(keys, X, Y);
Effects.MoveRect(NIL, keys, X, Y, x, y, w, h);
old := F.handle; F.handle := EmptyHandler;
ThisFrame(X, Y, f, u0, v0);
F.handle := old;
IF keys = {middle, right} THEN (* copy frame *)
IF f # NIL THEN
CM.id := Objects.shallow; Objects.Stamp(CM); F.handle(F, CM); CM.obj.slink := NIL; (* copy the object *)
C.id := Display.drop; C.obj := CM.obj; C.F := f; C.u := u0 + (x - X); C.v := v0 + (y - Y);
Display.Broadcast(C);
END;
M.res := 2; (* copied *)
ELSIF keys = {middle, left} THEN (* consume frame *)
IF f # NIL THEN
(* do a consume *)
C.id := Display.drop; C.obj := F; F.slink := NIL; C.F := f; C.u := u0 + (x - X); C.v := v0 + (y - Y);
Display.Broadcast(C)
END;
M.res := 0 (* moved *)
ELSIF (keys = {middle}) OR (keys = {left}) THEN (* move frame, left key is a special hack, see docframes *)
A.id := Display.move; A.mode := Display.display;
A.X := x - M.x; A.Y := y - M.y;
A.W := w; A.H := h;
A.F := F; A.dX := A.X - F.X; A.dY := A.Y - F.Y; A.dW := A.W - F.W; A.dH := A.H - F.H;
Display.Broadcast(A);
M.res := 0 (* moved *)
ELSE M.res := 1 (* cancel *)
END;
(* Kernel.GC *)
END MoveFrame;
(** Integrate obj at the caret position. A Display.ConsumeMsg is broadcast behind the scenes. *)
PROCEDURE Integrate*(obj: Objects.Object);
VAR C: Display.ConsumeMsg;
BEGIN
IF obj # NIL THEN
C.id := Display.integrate; C.obj := obj; C.F := NIL; Display.Broadcast(C);
END;
END Integrate;
PROCEDURE Atom(lib: Objects.Library; IN name: ARRAY OF CHAR): INTEGER;
VAR ref: INTEGER;
BEGIN
Objects.GetKey(lib.dict, name, ref);
RETURN ref;
END Atom;
(** Write an object POINTER to a file. Lib is the library of the object that contains the pointer.*)
PROCEDURE WriteRef*(VAR r: Files.Rider; lib: Objects.Library; obj: Objects.Object);
BEGIN
IF obj = NIL THEN
Files.WriteInt(r, -1);
ELSE
IF obj.lib # NIL THEN
IF obj.lib # lib THEN
IF obj.lib.name = "" THEN (* private library *)
Files.WriteInt(r, -1);
Texts.WriteString(W, "Warning: Object belonging to private library referenced in ");
IF lib.name = "" THEN Texts.WriteString(W, "(private)")
ELSE Texts.WriteString(W, lib.name)
END;
Texts.WriteLn(W); Log;
ELSE
Files.WriteInt(r, obj.ref);
Files.WriteInt(r, Atom(lib, obj.lib.name));
END;
ELSE
Files.WriteInt(r, obj.ref);
Files.WriteInt(r, Atom(lib, "")); (* belongs to this library *)
END;
IF obj.lib.name # lib.name THEN
IF verbose THEN
Texts.WriteString(W, "Note: ");
IF lib.name = "" THEN Texts.WriteString(W, "(private)")
ELSE Texts.WriteString(W, lib.name)
END;
Texts.WriteString(W, " imports ");
Texts.WriteString(W, obj.lib.name); Texts.WriteLn(W); Log
END
END
ELSE
Files.WriteInt(r, -1);
IF verbose THEN
Texts.WriteString(W, "Warning: Object without library referenced in ");
IF lib.name = "" THEN Texts.WriteString(W, "(private)")
ELSE Texts.WriteString(W, lib.name)
END;
Texts.WriteLn(W); Log
END
END
END
END WriteRef;
(** Read an object POINTER from a file. Lib is the library of the object that contains the pointer. Obj might be of type Objects.Dummy if a loading failure occured. *)
PROCEDURE ReadRef*(VAR r: Files.Rider; lib: Objects.Library; VAR obj: Objects.Object);
VAR i, l: INTEGER; F: Objects.Library; name: ARRAY 32 OF CHAR;
BEGIN
Files.ReadInt(r, i);
IF i = -1 THEN
obj := NIL;
ELSE
Files.ReadInt(r, l);
Objects.GetName(lib.dict, l, name);
IF name[0] = 0X THEN F := lib; name := lib.name; ELSE F := Objects.ThisLibrary(name); END;
IF F # NIL THEN
F.GetObj(F, i, obj);
IF (name # lib.name) & (obj # NIL) THEN
IF verbose THEN
Texts.WriteString(W, "Note: ");
IF lib.name = "" THEN Texts.WriteString(W, "(private)")
ELSE Texts.WriteString(W, lib.name)
END;
Texts.WriteString(W, " imports ");
Texts.WriteString(W, obj.lib.name); Texts.WriteLn(W); Log
END
END;
IF obj = NIL THEN
Texts.WriteString(W, "Warning: "); Texts.WriteString(W, "Object imported from ");
Texts.WriteString(W, name); Texts.WriteString(W, " does not exist (NIL pointer)");
Texts.WriteLn(W); Log;
END;
ELSE
Texts.WriteString(W, "Warning: "); Texts.WriteString(W, name); Texts.WriteString(W, " not found");
Texts.WriteLn(W); Log;
obj := NIL;
END;
END;
END ReadRef;
PROCEDURE MakeMaskFor(G: Frame);
VAR MM: Display3.UpdateMaskMsg; O: Display3.OverlapMsg; M: Display3.Mask;
BEGIN
MM.F := G; Display.Broadcast(MM);
IF G.mask = NIL THEN
(* good debug test
IF ~(dlink IS View) & (dlink IS Frame) THEN HALT(99) END;
*)
(* constructing a dummy mask *)
NEW(M); Display3.Open(M);
Display3.Add(M, 0, -G.H+1, G.W, G.H); M.x := 0; M.y := 0;
O.F := G; O.M := M; O.dlink := NIL; O.res := -1; O.x := 0; O.y := 0; G.handle(G, O);
IF G.mask = NIL THEN G.mask := M END; (* frame is still misbehaving *)
END
END MakeMaskFor;
PROCEDURE *MakeMask0(G: Frame; X, Y: INTEGER; dlink: Objects.Object; VAR M: Display3.Mask);
VAR ox, oy, x, y, w, h, b, b2: INTEGER; R: Display3.Mask; v: Objects.Object;
BEGIN
IF G.mask = NIL THEN (* mask has been invalidated *)
MakeMaskFor(G)
END;
M := G.mask; M.x := X; M.y := Y + G.H - 1;
(* clear the clipping port *)
M.X := X; M.Y := Y; M.W := G.W; M.H := G.H;
(* go through the view stack and modify the mask *)
IF dlink # NIL THEN
v := dlink;
WHILE v # NIL DO
IF v IS View THEN
WITH v: View DO
IF v.mask = NIL THEN (* very bad *)
MakeMaskFor(v)
END;
ox := v.mask.x; oy := v.mask.y;
v.mask.x := v.absX; v.mask.y := v.absY + v.H - 1; (* place mask at absolute position *)
IF Display3.Rectangular(v.mask, x, y, w, h) THEN
Display3.AdjustMask(M, x, y, w, h);
ELSIF Display3.Visible(v.mask, X, Y, G.W, G.H) THEN (* frame completely visible *)
Display3.AdjustMask(M, X, Y, G.W, G.H);
ELSE (* waste memory because of overlapping *)
Display3.IntersectMasks(M, v.mask, R);
R.X := M.X; R.Y := M.Y; R.W := M.W; R.H := M.H; (* set new port to old port *)
M := R;
END;
IF v.ClipMask # NIL THEN v.ClipMask(v, M, TRUE)
ELSE
b := v.border; b2 := b * 2;
Display3.AdjustMask(M, v.absX+b, v.absY+b, v.W-b2, v.H-b2)
END;
v.mask.x := ox; v.mask.y := oy
END
(*
ELSIF (v IS Frame) & (31 IN v(Frame).state) THEN (* from definition these should be position absolutely *)
WITH v: Display.Frame DO
Display3.AdjustMask(M, v.X, v.Y, v.W, v.H)
END
*)
ELSIF (v IS Viewers.Viewer) THEN
ELSIF ~(v IS Frame) & (v IS Display.Frame) THEN (* from definition these should be position absolutely *)
WITH v: Display.Frame DO
Display3.AdjustMask(M, v.X, v.Y, v.W, v.H)
END
END;
v := v.dlink;
END;
END;
END MakeMask0;
PROCEDURE P(x : INTEGER) : INTEGER;
BEGIN RETURN SHORT(x * Display.Unit DIV Printer.Unit) END P;
PROCEDURE *EnumMakePrinterMask(X,Y,W,H: INTEGER);
VAR R, T, L, B: INTEGER;
BEGIN
L := P(X-tmpX) + tmpX; B := P(Y - tmpY) + tmpY;
R := P(X-tmpX + W) + tmpX; T := P(Y - tmpY +H) + tmpY;
Display3.Add(pMask, L, B, R-L, T-B);
END EnumMakePrinterMask;
PROCEDURE MakePMask0(G: Frame; X, Y: INTEGER; VAR M: Display3.Mask);
VAR MM: Display3.UpdateMaskMsg;
BEGIN
IF G.mask = NIL THEN (* mask has been invalidated *)
MM.F := G; Display.Broadcast(MM);
IF G.mask = NIL THEN
(* constructing a dummy mask *)
NEW(M); Display3.Open(M);
Display3.Add(M, 0, -G.H+1, G.W, G.H); M.x := X; M.y := Y + G.H - 1;
IF verbose THEN
Texts.WriteString(W, "Warning Gadgets.MakeMask: creating a default mask"); Texts.WriteLn(W); Log
END
ELSE M := G.mask; M.x := X; M.y := Y + G.H - 1
END;
ELSE
M := G.mask; M.x := X; M.y := Y + G.H - 1
END;
(* clear the clipping port *)
M.X := X; M.Y := Y; M.W := G.W; M.H := G.H;
END MakePMask0;
PROCEDURE ScaleMask(px, py: INTEGER; in: Display3.Mask; VAR out: Display3.Mask);
BEGIN
NEW(pMask); Display3.Open(pMask);
tmpX := px; tmpY := py;
Display3.EnumRect(in, in.X, in.Y, in.W, in.H, EnumMakePrinterMask);
pMask.X := Printer.FrameX; pMask.Y := Printer.FrameY; pMask.W := Printer.FrameW; pMask.H := Printer.FrameH;
out := pMask;
END ScaleMask;
PROCEDURE *MakePrinterMask0(G: Frame; X, Y: INTEGER; dlink: Objects.Object; VAR M: Display3.Mask);
VAR ox, oy, x, y, w, h, b, b2: INTEGER; R, R0: Display3.Mask; v: Objects.Object;
BEGIN
(* make the basic mask *)
MakePMask0(G, X, Y, M);
(* scale it *)
ScaleMask(X, Y, M, M);
(* add views clipping *)
IF dlink # NIL THEN
v := dlink;
WHILE v # NIL DO
IF (v IS View) & (v(View).mask # NIL) THEN
WITH v: View DO
ox := v.mask.x; oy := v.mask.y;
v.mask.x := v.absX; v.mask.y := v.absY + v.H - 1; (* place mask at absolute position *)
ScaleMask(v.absX, v.absY, v.mask, R);
IF Display3.Rectangular(R, x, y, w, h) THEN
Display3.AdjustMask(M, x, y, w, h);
ELSIF Display3.Visible(R, X, Y, P(G.W), P(G.H)) THEN (* frame completely visible *)
Display3.AdjustMask(M, X, Y, P(G.W), P(G.H));
ELSE (* waste memory because of overlapping *)
Display3.IntersectMasks(M, R, R0);
R0.X := M.X; R0.Y := M.Y; R0.W := M.W; R0.H := M.H; (* set new port to old port *)
M := R0;
END;
IF v.ClipMask # NIL THEN v.ClipMask(v, M, FALSE)
ELSE
b := v.border; b2 := b * 2;
Display3.AdjustMask(M, v.absX+P(b), v.absY+P(b), P(v.W-b2), P(v.H-b2))
END;
v.mask.x := ox; v.mask.y := oy
END
END;
v := v.dlink;
END
END
END MakePrinterMask0;
(** Execute a string as an Oberon command. The parameters executor, dlink, sender, receiver are copied to the global variables executorObj, context, senderObj, receiverObj respectively. Dlink must be the parent of executor. If a '%' is leading the command, no Oberon.Par is set up. *)
PROCEDURE Execute*(cmd: ARRAY OF CHAR; executor, dlink, sender, receiver: Objects.Object);
VAR T: Texts.Text; S: Attributes.Scanner; ch: CHAR; res, cx, cy, cw, chl, i, j: INTEGER;
oldcontext, obj: Objects.Object; str: BOOLEAN;
BEGIN
IF cmd[0] = 0X THEN RETURN END;
ch := 0X; T := NIL;
Display.GetClip(cx, cy, cw, chl); Display.ResetClip;
executorObj := executor; context := dlink; senderObj := sender; receiverObj := receiver;
NEW(par); par.obj := executor;
(* calculate outermost frame in the menuviewer*)
IF context = NIL THEN context := executor END; (* may be the outside most frame *)
obj := context;
LOOP
IF (obj = NIL) OR (obj.dlink = NIL) OR (obj.dlink IS Viewers.Viewer) THEN EXIT END;
obj := obj.dlink
END;
IF (obj # NIL) & (obj IS Display.Frame) THEN par.frame := obj(Display.Frame)
ELSE par.frame := Oberon.Par.frame (* hack, otherwise Oberon.Call traps *)
END;
(* modified ps - 6.6.96 *)
IF cmd[0] = "%" THEN
par.text := emptyText; par.pos := 0;
i := 1;
WHILE cmd[i] > " " DO cmd[i-1] := cmd[i]; INC(i) END;
cmd[i-1] := 0X
ELSIF cmd[0] = "$" THEN
NEW(par.text); Texts.Open(par.text, "");
i := 1;
WHILE cmd[i] > " " DO
Texts.Write(W, cmd[i]); cmd[i-1] := cmd[i]; INC(i)
END;
cmd[i-1] := 0X; par.pos := i-1;
WHILE cmd[i] # 0X DO
Texts.Write(W, cmd[i]); INC(i)
END;
Texts.Append(par.text, W.buf)
ELSE
IF ("A" <= CAP(cmd[0])) & (CAP(cmd[0]) <= "Z") THEN (* direct command *)
i := 0;
WHILE (cmd[i] # 0X) & (cmd[i] > " ") DO INC(i) END;
j := i;
WHILE (cmd[j] # 0X) & (cmd[j] <= " ") DO INC(j) END;
IF cmd[j] # 0X THEN
Attributes.StrToTxt(cmd, T); Attributes.OpenScanner(S, T, 0); Attributes.Scan(S);
Attributes.Read(S.R, ch)
END
ELSE (* command has to be retrieved by macro handler *)
Attributes.StrToTxt(cmd, T);
Attributes.OpenScanner(S, T, 0); Attributes.Scan(S);
i := 0; j:= 0;
WHILE S.s[i] # 0X DO cmd[i] := S.s[i]; INC(i) END;
Attributes.Read(S.R, ch);
WHILE ~S.R.eot & (ch <= " ") DO Attributes.Read(S.R, ch) END;
IF S.R.eot THEN cmd[i] := 0X; j := i END
END;
(* set up parameter block *)
IF cmd[j] # 0X THEN
str := FALSE;
WHILE ~S.R.eot & (str OR (ch # "~")) DO
IF (ch = 22X) THEN S.R.substitute := ~S.R.substitute; str := ~str END;
Texts.Write(W, ch); Attributes.Read(S.R, ch);
END;
par.pos := T.len; par.text := T;
Texts.Append(T, W.buf)
ELSE
par.text := emptyText;
par.pos := 0
END;
cmd[i] := 0X
END;
IF executor # NIL THEN oldcontext := executor.dlink; executor.dlink := context END;
Oberon.Call(cmd, par, FALSE, res);
IF res # 0 THEN
Texts.WriteString(W, "Call error: "); Texts.WriteString(W, Modules.resMsg);
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END;
IF par # NIL THEN par.obj := NIL END;
IF executor # NIL THEN executor.dlink := oldcontext END;
Display.SetClip(cx, cy, cw, chl);
executorObj := NIL; context := NIL; senderObj := NIL; receiverObj := NIL; par := NIL
END Execute;
(* Macros *)
PROCEDURE ReadName(VAR T: Attributes.Reader; VAR name: ARRAY OF CHAR);
VAR ch: CHAR; i: INTEGER; old: BOOLEAN;
PROCEDURE Ok(ch: CHAR): BOOLEAN;
BEGIN
RETURN (ch = ".") OR ((ch >= "0") & (ch <= "9")) OR ((CAP(ch) >= "A") & (CAP(ch) <= "Z"));
END Ok;
BEGIN
i := 0; old := T.substitute; T.substitute := FALSE;
LOOP Attributes.Read(T, ch);
IF T.eot THEN EXIT; END;
IF ~Ok(ch) THEN EXIT END;
name[i] := ch; INC(i);
END;
name[i] := 0X;
T.substitute := old;
END ReadName;
(* special code for the & macro. && for next higher context etc. *)
PROCEDURE Lookup0(VAR T: Attributes.Reader; VAR name: ARRAY OF CHAR; VAR context: Objects.Object);
VAR ch: CHAR; i: INTEGER; old: BOOLEAN;
PROCEDURE Ok(ch: CHAR): BOOLEAN;
BEGIN
RETURN (ch = ".") OR ((ch >= "0") & (ch <= "9")) OR ((CAP(ch) >= "A") & (CAP(ch) <= "Z"));
END Ok;
BEGIN
i := 0; old := T.substitute; T.substitute := FALSE;
Attributes.Read(T, ch);
WHILE ~T.eot & (ch = "&") DO
IF (context # NIL) & (context.dlink # NIL) THEN context := context.dlink END;
Attributes.Read(T, ch)
END;
LOOP
IF T.eot THEN EXIT; END;
IF ~Ok(ch) THEN EXIT END;
name[i] := ch; INC(i);
Attributes.Read(T, ch);
END;
name[i] := 0X;
T.substitute := old;
END Lookup0;
PROCEDURE ObjAttr(name: ARRAY OF CHAR; context: Objects.Object; VAR W: Texts.Writer);
VAR i, j: INTEGER; attr: ARRAY 32 OF CHAR; obj: Objects.Object;
BEGIN
IF name # "" THEN
i := 0; WHILE name[i] # 0X DO INC(i); END;
WHILE (i > 0) & (name[i] # ".") DO DEC(i); END;
IF name[i] = "." THEN
name[i] := 0X; INC(i); j := 0;
WHILE name[i] # 0X DO attr[j] := name[i]; INC(i); INC(j); END;
attr[j] := 0X;
obj := FindObj(context, name);
IF obj # NIL THEN Attributes.WriteAttr(obj, attr, W);
ELSE Texts.WriteLn(WW); Texts.WriteString(WW, "Object not found: "); Texts.WriteString(WW, name);
Texts.WriteLn(WW); Texts.Append(Oberon.Log, WW.buf)
END
ELSE Texts.WriteLn(WW); Texts.WriteString(WW, "Syntax error: "); Texts.WriteString(WW, name);
Texts.WriteLn(WW); Texts.Append(Oberon.Log, WW.buf)
END
END
END ObjAttr;
PROCEDURE *StandardMacros(ch: CHAR; VAR T: Attributes.Reader; VAR res: Texts.Text; VAR beg: LONGINT);
VAR name: ARRAY 64 OF CHAR; f, context0: Objects.Object;
BEGIN
IF ch # 0X THEN
NEW(res); Texts.Open(res, ""); beg := 0;
IF ch = "&" THEN
context0 := context;
Lookup0(T, name, context0); ObjAttr(name, context0, mW); Texts.Append(res, mW.buf)
ELSIF ch = "#" THEN
ReadName(T, name);
Attributes.WriteAttr(executorObj, name, mW); Texts.Append(res, mW.buf);
ELSIF ch = "!" THEN (* more than one sender *)
IF senderObj # NIL THEN
ReadName(T, name);
f := senderObj;
WHILE f # NIL DO
Attributes.WriteAttr(f, name, mW); Texts.Write(mW, " ");
f := f.slink
END;
Texts.Write(mW, " "); Texts.Append(res, mW.buf);
END
ELSIF ch = "'" THEN
Texts.Write(mW, 22X); Texts.Append(res, mW.buf);
ELSIF ch = "?" THEN (* only one recipient *)
ReadName(T, name);
Attributes.WriteAttr(receiverObj, name, mW);
Texts.Append(res, mW.buf);
END
END
END StandardMacros;
PROCEDURE *UpArrowMacro(ch: CHAR; VAR T: Attributes.Reader; VAR res: Texts.Text; VAR beg: LONGINT);
VAR text, text0: Texts.Text; bg, end, ttime: LONGINT; obj: Objects.Object; S: Display.SelectMsg;
i: INTEGER; name: ARRAY 32 OF CHAR; R: Attributes.Reader; ch0: CHAR; old: Objects.Library;
string: BOOLEAN;
BEGIN
IF ch = 0X THEN (* Reset *)
uparrowdone := FALSE;
ELSIF (ch = "^") THEN (* getselection *)
IF ~uparrowdone THEN uparrowdone := TRUE;
Attributes.Read(T, ch);
IF (CAP(ch) >= "A") & (CAP(ch) <= "Z") THEN (* skip word *)
i := 0;
LOOP name[i] := ch; INC(i);
Attributes.Read(T, ch);
IF T.eot THEN EXIT; END;
IF (ch # ".") & ((ch <= " ") OR ((CAP(ch) < "A") OR (CAP(ch) > "Z"))) THEN EXIT END;
END;
name[i] := 0X;
END;
Oberon.GetSelection(text, bg, end, ttime);
S.id := Display.get; S.F := NIL; S.sel := NIL; S.obj := NIL; S.time := 0; Display.Broadcast(S);
IF (S.time > ttime) & (S.obj # NIL) & (name # "") THEN
NEW(text); Texts.Open(text, ""); beg := 0;
IF S.time > 0 THEN
obj := S.obj;
WHILE obj # NIL DO
IF obj IS Frame THEN Attributes.WriteAttr(obj, name, W); Texts.Write(W, " ");
END;
obj := obj.slink;
END;
Texts.Append(text, W.buf); res := text;
ELSE res := NIL
END;
ELSE
IF ttime > 0 THEN
(* res := text; beg := bg; *)
Attributes.OpenReader(R, text, bg); uparrowdone := TRUE; beg := bg;
NEW(text0); Texts.Open(text0, ""); string := FALSE;
Attributes.Read(R, ch0);
WHILE ~R.eot & (beg < end) DO
IF ch0 = 22X THEN R.substitute := ~R.substitute; string := ~string END;
old := W.lib; W.lib := R.lib; Texts.Write(W, ch0); W.lib := old;
IF beg + 1 = end THEN (* reached the end, ch0 is the last character read *)
IF (ch0 # " ") & (ch0 # 0DX) & (ch0 # 9X) THEN
Attributes.Read(R, ch0)
ELSE ch0 := " " (* ended on a termination char *)
END
ELSE
Attributes.Read(R, ch0)
END;
INC(beg);
END;
WHILE ~R.eot & (string OR ((ch0 # " ") & (ch0 # 0DX) & (ch0 # 9X))) DO
IF ch0 = 22X THEN R.substitute := ~R.substitute; string := ~string END;
old := W.lib; W.lib := R.lib; Texts.Write(W, ch0); W.lib := old;
Attributes.Read(R, ch0); INC(beg);
END;
Texts.Write(W, " "); Texts.Append(text0, W.buf); beg := 0; end := text0.len; res := text0
ELSE res := NIL;
END;
END;
ELSE
res := NIL; beg := 0;
END;
END;
END UpArrowMacro;
(** Forwards a message from a camera-view to its contents, inserting the camera-view in the message thread. X, Y is the absolute screen coordinates of the bottom-left corner of the camera-view. This is important for calculating the correct display mask for the contents of the view. *)
PROCEDURE Send*(from: View; X, Y: INTEGER; to: Display.Frame; VAR M: Display.FrameMsg);
VAR S: Stack;
BEGIN
Push(S, from, M); from.absX := X; from.absY := Y; to.handle(to, M); Pop(S, from, M);
END Send;
(* ---------- leaf handler ---------- *)
PROCEDURE HandleFrameAttributes(F: Frame; VAR M: Objects.AttrMsg);
VAR b: Attributes.BoolAttr; c: Attributes.CharAttr; i: Attributes.IntAttr; r: Attributes.RealAttr; s: Attributes.StringAttr; a, f: Attributes.Attr;
BEGIN
IF M.id = Objects.get THEN
a := F.attr;
WHILE (a # NIL) & (a.name # M.name) DO a := a.next END;
IF a # NIL THEN
IF a IS Attributes.BoolAttr THEN M.class := Objects.Bool; M.b := a(Attributes.BoolAttr).b;
ELSIF a IS Attributes.CharAttr THEN M.class := Objects.Char; M.c := a(Attributes.CharAttr).c;
ELSIF a IS Attributes.IntAttr THEN M.class := Objects.Int; M.i := a(Attributes.IntAttr).i;
ELSIF a IS Attributes.RealAttr THEN M.class := Objects.LongReal; M.y := a(Attributes.RealAttr).r;
ELSIF a IS Attributes.StringAttr THEN M.class := Objects.String; M.s := a(Attributes.StringAttr).s;
ELSE HALT(42)
END;
M.res := 0;
ELSIF M.name = "Gen" THEN HALT(99)
ELSIF (M.name = "Name") & (F.lib # NIL) & (F.lib.name # "") THEN
M.s[0] := 0X;
Objects.GetName(F.lib.dict, F.ref, M.s); M.class := Objects.String; M.res := 0
ELSIF M.name = "Transparent" THEN (* hidden attributes: special hack/rs wish *)
M.b := transparent IN F.state; M.class := Objects.Bool; M.res := 0
(* should return nothing
ELSE M.class := Objects.String; M.s[0] := 0X; M.res := 0 (* must be. some gadgets advertize Cmd *)
*)
END;
ELSIF M.id = Objects.set THEN
IF M.name = "Gen" THEN HALT(99)
ELSIF (M.name = "Name") (*& (M.s # "")*) THEN