forked from rochus-keller/OberonSystem3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDesktops.Mod
2000 lines (1837 loc) · 68.3 KB
/
Desktops.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;type=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 Desktops; (** portable *) (** , jm 1.2.95 *)
(**Implementation of the Oberon Desktop, with Viewers for displaying documents in the tiled and overlapping windowing systems of Oberon.
*)
(*
25.3.94 - Added support for Documents.LocateMsg
5.4.94 - fixed the size of the grab area on top of the Viewer to 6 pixels
6.4.94 - changed from jg style modifyMsg's to gadget style messages for Viewers
19.4.94 - left key in DocGadget Menu bar takes it to behind, left + middle to the front
20.4.94 - left key in document prints it to front
22.4.94 - Send restore msg on ShowDoc
27.4.94 - improved to front
2.5.94 - Added copy over for docgadgets\
24.5.94 - Remove dynamic buttons in the menu-bars
30.5.94 - added "loading failed" messages
27.7.94 - improved document placement
12.10.94 - improved opening of non desktop tjings
12.10.94 - fixed button on opening new desktop
19.10.94 - Added Recall.
this module is very much an hack now. Compatibility with classic Oberon and old gadgets
applications makes it difficult to change. The whole flag business should be fixed (difficult when everything
is not a gadget).
8.11.94 - Viewers now respond on Locked attribute. used together with Gadgets.IsLocked
8.11.94 - flag business simplified drastically. 31 flag not used any more.
- removed OpenView plus modified signature of ShowDoc
30.11.94 - renamed Viewer to DocViewer
21.12.94 - added alias support for Document generators
3.1.95 - simplified MakeIcon, renamed from MakeIcons
24.1.95 - fixed cursor in DocViewer menubar
19.4.95 - increased the height where the DocViewer can be grabbed with the left key
15.5.95 - LoadDoc now checks on a NIL dsc
21.6.95 - Removed setting of Views.View border
7.6.96 - fixed parsing of menustring (* ps - 7.6.96 *)
21.9.96 - bugfix in ModifyFrame (* ps - 21.9.96 *)
11.12.96 - changed Grow
12.12.96 - added Copy, changed Init, newMenu
7.1.97 - default width on desktop (set to 250) introduced
*)
IMPORT
Input, Objects, Display, Viewers, Oberon, Gadgets, Attributes, Files, Documents, Texts, Display3, Views,
Printer, Printer3, Effects, Fonts, Pictures, Strings;
CONST
leftBorder = 0; frameColor = 12;
extend = Display.extend; reduce = Display.reduce;
AvoidLostViewer = TRUE;
TYPE
(** Viewer for displaying documents in a desktop. *)
DocGadget* = POINTER TO DocGadgetDesc;
DocGadgetDesc* = RECORD (Gadgets.FrameDesc)
time: LONGINT;
END;
(** Viewers.Viewer for displaying documents in the tiled viewer system. *)
DocViewer* = POINTER TO DocViewerDesc;
DocViewerDesc* = RECORD (Viewers.ViewerDesc)
menuH*: INTEGER; (** Menubar height. *)
time: LONGINT;
END;
Dummy = POINTER TO RECORD (Display.FrameDesc) END;
UpdateNameMsg* = RECORD (Display.FrameMsg)
obj*: Objects.Object
END;
ParentMsg = RECORD (Display.FrameMsg)
parent: Objects.Object
END;
VAR
menuH*: INTEGER; (** Default menubar heigth of DocGadget and DocViewer *)
menuC*: INTEGER; (** Default menubar panel color *)
menuButtonW*: INTEGER; (** Default menu button width *)
namePlateW*: INTEGER; (** Default nameplate width *)
recDocWidth*: INTEGER; (** recommended minimal document width *)
W: Texts.Writer;
recall: Display.Frame;
PROCEDURE ^NewMenu*(menubar: ARRAY OF CHAR): Display.Frame;
(* ===================== Own Viewer code ================ *)
PROCEDURE ^NewDummy(): Dummy;
PROCEDURE ^ViewerDoc(V: DocViewer): Documents.Document;
PROCEDURE DummyHandler(F: Objects.Object; VAR M: Objects.ObjMsg);
BEGIN
IF M IS Objects.CopyMsg THEN
M(Objects.CopyMsg).obj := NewDummy();
END
END DummyHandler;
PROCEDURE NewDummy(): Dummy;
VAR F: Dummy;
BEGIN NEW(F); F.handle := DummyHandler; RETURN F
END NewDummy;
(** Does the DocViewer have a menubar? Only the desktops are DocViewers without menubars. *)
PROCEDURE HasMenu*(V: DocViewer): BOOLEAN;
BEGIN RETURN ~(V.dsc IS Dummy)
END HasMenu;
PROCEDURE CopyDocViewer (V: DocViewer; VAR V1: DocViewer);
VAR Menu, Main: Display.Frame; M: Objects.CopyMsg;
BEGIN
Menu := V.dsc; Main := V.dsc.next;
NEW(V1); V1^ := V^; V1.state := 0;
M.id := Objects.shallow; Objects.Stamp(M);
Menu.handle(Menu, M); V1.dsc := M.obj(Display.Frame);
Main.handle(Main, M); V1.dsc.next := M.obj(Display.Frame)
END CopyDocViewer;
PROCEDURE ModifyFrame(V: DocViewer; F: Display.Frame; id, Y, H: INTEGER);
VAR M: Display.ModifyMsg;
BEGIN
M.F := F; M.id := id; M.dlink := V; V.dlink := NIL;
IF (F.Y + F.H # Y + H) & (F.H # H) THEN (* move main first and then resize *) (* ps - 21.9.96 *)
IF H < F.H THEN (* reduce *)
M.X := F.X; M.Y := F.Y + (F.H - H); M.W := F.W; M.H := H;
M.dX := 0; M.dY := M.Y - F.Y; M.dW := 0; M.dH := M.H - F.H;
M.mode := Display.state; M.res := MIN(INTEGER); M.x := 0; M.y := 0; Objects.Stamp(M);
F.handle(F, M); F.Y := M.Y
ELSE (* extend *)
M.X := F.X; M.Y := Y + H - F.H; M.W := F.W; M.H := F.H;
M.dX := 0; M.dY := M.Y - F.Y; M.dW := 0; M.dH := 0;
M.mode := Display.display; M.res := MIN(INTEGER); M.x := 0; M.y := 0; Objects.Stamp(M);
F.handle(F, M); F.Y := M.Y
END
END;
M.X := F.X; M.Y := Y; M.W := F.W; M.H := H;
M.dX := 0; M.dY := M.Y - F.Y; M.dW := 0; M.dH := M.H - F.H;
M.mode := Display.display; M.res := MIN(INTEGER); M.x := 0; M.y := 0; Objects.Stamp(M);
F.handle(F, M); F.Y := Y; F.H := H
END ModifyFrame;
PROCEDURE Restore (V: DocViewer);
VAR Menu, Main: Display.Frame; M: Display.ControlMsg;
BEGIN
Menu := V.dsc; Main := V.dsc.next;
Oberon.RemoveMarks(V.X, V.Y, V.W, V.H);
Menu.X := V.X; Menu.Y := V.Y + V.H; Menu.W := V.W; Menu.H := 0;
Main.X := V.X; Main.Y := V.Y + V.H - V.menuH; Main.W := V.W; Main.H := 0;
M.F := NIL; M.id := Display.restore; M.res := -1; Objects.Stamp(M); M.dlink := V; V.dlink := NIL;
M.x := 0; M.y := 0;
Menu.handle(Menu, M); Main.handle(Main, M);
IF V.H > V.menuH + 1 THEN
ModifyFrame(V, Menu, extend, V.Y + V.H - V.menuH, V.menuH);
ModifyFrame(V, Main, extend, V.Y, V.H - V.menuH)
ELSE ModifyFrame(V, Menu, extend, V.Y, V.H)
END
END Restore;
PROCEDURE ModifyDocViewer (V: DocViewer; id, Y, H: INTEGER);
VAR Menu, Main: Display.Frame;
BEGIN
Menu := V.dsc; Main := V.dsc.next;
IF id = extend THEN
Oberon.RemoveMarks(V.X, Y, V.W, V.Y - Y);
IF H > V.menuH + 1 THEN
ModifyFrame(V, Menu, extend, Y + H - V.menuH, V.menuH);
ModifyFrame(V, Main, extend, Y , H - V.menuH)
ELSE
ModifyFrame(V, Menu, extend, Y, H);
ModifyFrame(V, Main, extend, Y + H - V.menuH, 0)
END
ELSIF id = reduce THEN
Oberon.RemoveMarks(V.X, Y, V.W, Y - V.Y);
IF H > V.menuH + 1 THEN
ModifyFrame(V, Main, reduce, Y, H - V.menuH);
ModifyFrame(V, Menu, reduce, Y + H - V.menuH, V.menuH)
ELSE
ModifyFrame(V, Main, reduce, Y + H - V.menuH, 0);
ModifyFrame(V, Menu, reduce, Y, H)
END;
END
END ModifyDocViewer;
PROCEDURE Change (V: DocViewer; X, Y: INTEGER; Keys: SET);
VAR Menu, Main: Display.Frame;
V1: Viewers.Viewer; keysum: SET; Y0, dY, H: INTEGER;
BEGIN (*Keys # {}*)
Menu := V.dsc; Main := V.dsc.next;
IF Menu IS Dummy THEN V.dsc.H := 5 END;
Oberon.FadeCursor(Oberon.Mouse);
Display.ReplConst(3, V.X, V.Y + V.H - V.dsc.H, V.W, V.dsc.H, Display.invert);
Y0 := Y;
keysum := Keys;
LOOP
Input.Mouse(Keys, X, Y);
IF Keys = {} THEN EXIT END;
keysum := keysum + Keys;
Oberon.DrawCursor(Oberon.Mouse, Effects.Arrow, X, Y)
END;
Oberon.FadeCursor(Oberon.Mouse);
Display.ReplConst(3, V.X, V.Y + V.H - V.dsc.H, V.W, V.dsc.H, Display.invert);
IF Menu IS Dummy THEN V.dsc.H := 0 END;
IF ~(0 IN keysum) THEN
IF 1 IN keysum THEN V1 := Viewers.This(X, Y);
IF (V1 IS DocViewer) & (Y > V1.Y + V1.H - V1(DocViewer).menuH) THEN
Y := V1.Y + V1.H
END;
Viewers.Close(V); Viewers.Open(V, X, Y); Restore(V)
ELSE
IF Y > Y0 THEN (*extend*) dY := Y - Y0;
V1 := Viewers.Next(V);
IF V1.state > 1 THEN
IF V1 IS DocViewer THEN
IF V1.H < V1(DocViewer).menuH + 2 THEN dY := 0
ELSIF V1.H < V1(DocViewer).menuH + 2 + dY THEN dY := V1.H - V1(DocViewer).menuH - 2
END
ELSIF V1.H < 1 + dY THEN dY := V1.H - 1
END
ELSIF V1.H < dY THEN dY := V1.H
END;
Viewers.Change(V, V.Y + V.H + dY);
Oberon.RemoveMarks(V.X, V.Y, V.W, V.H);
IF V.H > V.menuH + 1 THEN
ModifyFrame(V, Menu, extend, V.Y + V.H - V.menuH, V.menuH);
ModifyFrame(V, Main, extend, V.Y, V.H - V.menuH)
ELSE (*V.H > 1*)
ModifyFrame(V, Menu, extend, V.Y, V.H);
ModifyFrame(V, Main, extend, V.Y + V.H - V.menuH, 0)
END
ELSIF Y < Y0 THEN (*reduce*) dY := Y0 - Y;
IF V.H >= V.menuH + 2 THEN
IF V.H < V.menuH + 2 + dY THEN dY := V.H - V.menuH - 2 END;
Oberon.RemoveMarks(V.X, V.Y, V.W, V.H);
H := V.H - dY;
ModifyFrame(V, Main, reduce, V.Y, H - V.menuH);
ModifyFrame(V, Menu, reduce, V.Y + H - V.menuH, V.menuH);
Viewers.Change(V, V.Y + H)
END
END
END
END;
IF AvoidLostViewer & (V.Y+V.H < 20) THEN
Viewers.Change(V, 20); Restore(V)
END
END Change;
PROCEDURE Suspend (V: DocViewer);
VAR Menu, Main: Display.Frame;
BEGIN
Menu := V.dsc; Main := V.dsc.next;
ModifyFrame(V, Main, reduce, V.Y + V.H - V.menuH, 0);
ModifyFrame(V, Menu, reduce, V.Y + V.H (* ps - 1 *), 0)
END Suspend;
PROCEDURE DocViewerNeutralize(F: DocViewer);
VAR main: Gadgets.Frame; S: Display.SelectMsg;
BEGIN
main := F.dsc.next(Gadgets.Frame);
IF Gadgets.selected IN main.state THEN
S.F := main; S.res := -1; S.x := 0; S.y := 0;
S.id := Display.reset; F.time := 0;
main.handle(main, S);
Gadgets.Update(main)
END
END DocViewerNeutralize;
PROCEDURE DocViewerHandleSelect(F: DocViewer; VAR M: Oberon.InputMsg);
VAR main: Gadgets.Frame; S: Display.SelectMsg; keysum: SET; C: Objects.CopyMsg;
BEGIN
main := F.dsc.next(Gadgets.Frame);
S.F := main; S.res := -1; S.x := 0; S.y := 0;
IF Gadgets.selected IN main.state THEN
S.id := Display.reset; F.time := 0
ELSE
S.id := Display.set; F.time := Oberon.Time()
END;
main.handle(main, S);
Gadgets.Update(main); 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 = {0, 2}) & (S.id = Display.set) THEN (* RL delete selection *)
(* nothing *)
ELSIF (keysum = {0, 1}) & (S.id = Display.set) THEN (* RM copy to focus *)
C.id := Objects.deep; C.obj := NIL; Objects.Stamp(C); main.handle(main, C);
IF C.obj # NIL THEN
Gadgets.Integrate(C.obj)
END
END
END DocViewerHandleSelect;
PROCEDURE DocViewerHandle* (V: Objects.Object; VAR M: Objects.ObjMsg);
VAR Menu, Main: Display.Frame; V1: DocViewer;
BEGIN
WITH V: DocViewer DO
Menu := V.dsc; Main := V.dsc.next; M.dlink := V; V.dlink := NIL;
IF M IS Oberon.InputMsg THEN
WITH M: Oberon.InputMsg DO
IF M.id = Oberon.track THEN
IF (M.Y > V.Y + V.H - 5) & (Menu IS Dummy) & (2 IN M.keys) THEN Change(V, M.X, M.Y, M.keys)
ELSIF M.Y < V.Y + V.H - V.menuH THEN Main.handle(Main, M);
IF (M.res < 0) & (M.keys = {0}) & Effects.InBorder(M.X, M.Y, V.X, V.Y, V.W, V.H - V.menuH) THEN
DocViewerHandleSelect(V, M)
END
ELSIF M.Y < V.Y + V.H - 1 THEN
Menu.handle(Menu, M);
IF (M.res < 0) & (2 IN M.keys) THEN Change(V, M.X, M.Y, M.keys) END
END;
IF M.res < 0 THEN Oberon.DrawCursor(Oberon.Mouse, Effects.Arrow, M.X, M.Y) END
ELSE Menu.handle(Menu, M); Main.handle(Main, M);
END
END
ELSIF M IS Oberon.ControlMsg THEN
WITH M: Oberon.ControlMsg DO
IF M.id = Oberon.mark THEN
IF (M.X >= V.X) & (M.X < V.X + V.W) & (M.Y >= V.Y) & (M.Y < V.Y + V.H) THEN
Oberon.FadeCursor(Oberon.Mouse);
Oberon.DrawCursor(Oberon.Pointer, Oberon.Star, M.X, M.Y);
Oberon.DrawCursor(Oberon.Mouse, Effects.Arrow, M.X, M.Y);
END
ELSE Menu.handle(Menu, M); Main.handle(Main, M)
END;
IF M.id = Oberon.neutralize THEN DocViewerNeutralize(V) END
END
ELSIF M IS Display.SelectMsg THEN
WITH M: Display.SelectMsg DO
IF M.id = Display.get THEN
IF (V.time > M.time) & (Gadgets.selected IN Main(Gadgets.Frame).state) THEN
M.time := V.time; M.sel := V; M.obj := Main
END
END;
Menu.handle(Menu, M); Main.handle(Main, M)
END
ELSIF M IS Display.LocateMsg THEN
WITH M: Display.LocateMsg DO
IF M.F = NIL THEN Menu.handle(Menu, M); Main.handle(Main, M) END
END
ELSIF M IS Display.ModifyMsg THEN
WITH M: Display.ModifyMsg DO
IF M.F = V THEN ModifyDocViewer(V, M.id, M.Y, M.H)
ELSE
IF M.F # Menu THEN Menu.handle(Menu, M) END;
IF M.F # Main THEN Main.handle(Main, M) END
END
END
ELSIF M IS Objects.CopyMsg THEN
WITH M: Objects.CopyMsg DO CopyDocViewer(V(DocViewer), V1); M.obj := V1 END
ELSIF M IS Objects.LinkMsg THEN
WITH M: Objects.LinkMsg DO
IF (M.id = Objects.get) & (M.name = "Model") THEN M.obj := V.dsc.next; M.res := 0 END
END
ELSIF M IS Objects.AttrMsg THEN
WITH M: Objects.AttrMsg DO
IF (M.id = Objects.get) THEN
IF M.name = "Locked" THEN M.res := 0; M.class := Objects.Bool; M.b := TRUE
ELSIF M.name = "Absolute" THEN M.res := 0; M.class := Objects.Bool; M.b := TRUE
END
END
END
ELSIF M IS Display.ControlMsg THEN
WITH M: Display.ControlMsg DO
IF M.id = Display.restore THEN Restore(V)
ELSIF M.id = Display.suspend THEN Suspend(V)
ELSE Menu.handle(Menu, M); Main.handle(Main, M)
END
END
ELSIF M IS Documents.LocateMsg THEN (* added 25.3.94 *)
WITH M: Documents.LocateMsg DO
Main.handle(Main, M);
IF (M.doc = NIL) & Effects.Inside(M.X, M.Y, V.X, V.Y, V.W, V.H) THEN
M.doc := ViewerDoc(V);
END
END
ELSE Menu.handle(Menu, M); Main.handle(Main, M)
END
END
END DocViewerHandle;
(** Create and open a new DocViewer. Analogue to old-fashioned MenuViewers.New. X, Y indicate the opening position. *)
PROCEDURE NewDocViewer*(Menu, Main: Display.Frame; menuH, X, Y: INTEGER): DocViewer;
VAR V: DocViewer;
BEGIN NEW(V);
IF Menu = NIL THEN menuH := 0; Menu := NewDummy() END;
V.handle := DocViewerHandle; V.dsc := Menu; V.dsc.next := Main; V.menuH := menuH;
Viewers.Open(V, X, Y); Restore(V);
RETURN V
END NewDocViewer;
(* ===================== default handler for document frames ================ *)
PROCEDURE^ Init*(F: DocGadget; menu, main: Gadgets.Frame; adjust: BOOLEAN);
(** Returns the menubar of a DocGadget. *)
PROCEDURE Menu*(F: DocGadget): Gadgets.Frame;
BEGIN
IF F.dsc # NIL THEN RETURN F.dsc(Gadgets.Frame)
ELSE RETURN NIL
END
END Menu;
(** Returns the contents of a DocGadget. *)
PROCEDURE Main*(F: DocGadget): Gadgets.Frame;
BEGIN
IF F.dsc.next # NIL THEN RETURN F.dsc.next(Gadgets.Frame)
ELSE RETURN NIL
END
END Main;
PROCEDURE SetMask(F: Gadgets.Frame; M: Display3.Mask);
VAR O: Display3.OverlapMsg;
BEGIN O.M := M; O.x := 0; O.y := 0; O.F := F; O.dlink := NIL; O.res := -1; F.handle(F, O);
END SetMask;
PROCEDURE SetMainMask(F: DocGadget);
VAR main: Gadgets.Frame; R: Display3.Mask;
BEGIN
main := Main(F);
IF main # NIL THEN
IF F.mask = NIL THEN SetMask(main, NIL)
ELSE
Display3.Copy(F.mask, R); R.x := 0; R.y := 0;
Display3.Intersect(R, main.X, main.Y, main.W, main.H);
R.x := -main.X; R.y := -(main.Y + main.H - 1); Display3.Shift(R);
SetMask(main, R)
END
END
END SetMainMask;
PROCEDURE SetMenuMask(F: DocGadget);
VAR menu: Gadgets.Frame; R: Display3.Mask;
BEGIN
menu := Menu(F);
IF menu # NIL THEN
IF F.mask = NIL THEN SetMask(menu, NIL)
ELSE
Display3.Copy(F.mask, R); R.x := 0; R.y := 0;
Display3.Intersect(R, menu.X, menu.Y, menu.W, menu.H);
R.x := -menu.X; R.y := -(menu.Y + menu.H - 1); Display3.Shift(R);
SetMask(menu, R)
END
END
END SetMenuMask;
PROCEDURE ToMain(F: DocGadget; x, y: INTEGER; VAR M: Display.FrameMsg);
VAR main: Gadgets.Frame; Mdlink, Fdlink: Objects.Object; tx, ty: INTEGER;
BEGIN
main := Main(F);
IF main # NIL THEN
tx := M.x; ty := M.y; M.x := x; M.y := y + F.H - 1;
Fdlink := F.dlink; Mdlink := M.dlink;
F.dlink := M.dlink; M.dlink := F; main.handle(main, M);
F.dlink := Fdlink; M.dlink := Mdlink;
M.x := tx; M.y := ty
END
END ToMain;
PROCEDURE ToMenu(F: DocGadget; x, y: INTEGER; VAR M: Display.FrameMsg);
VAR menu: Gadgets.Frame; Mdlink, Fdlink: Objects.Object; tx, ty: INTEGER;
BEGIN
menu := Menu(F);
IF menu # NIL THEN
tx := M.x; ty := M.y; M.x := x; M.y := y + F.H - 1;
Fdlink := F.dlink; Mdlink := M.dlink;
F.dlink := M.dlink; M.dlink := F; menu.handle(menu, M);
F.dlink := Fdlink; M.dlink := Mdlink;
M.x := tx; M.y := ty
END
END ToMenu;
PROCEDURE PositionMain(F: DocGadget; VAR X, Y, W, H: INTEGER);
VAR border: INTEGER; menu: Gadgets.Frame;
BEGIN
menu := Menu(F);
IF menu # NIL THEN border := menu.H ELSE border := 0 END;
X := leftBorder; Y := -F.H + 1; W := F.W - leftBorder; H := F.H - border
END PositionMain;
PROCEDURE AdjustDocGadget(F: DocGadget; VAR M: Display.ModifyMsg);
VAR main, menu: Gadgets.Frame; A: Display.ModifyMsg; border: INTEGER;
BEGIN
menu := Menu(F); main := Main(F);
IF menu # NIL THEN border := menu.H ELSE border := 0 END;
IF main # NIL THEN
(* Adjust main *)
A.id := Display.extend; A.F := main; A.mode := Display.state;
A.X := leftBorder; A.Y := -M.H + 1; A.W := M.W - leftBorder; A.H := M.H - border;
A.dX := A.X - main.X; A.dY := A.Y - main.Y; A.dW := A.W - main.W; A.dH := A.H - main.H;
A.dlink := M.dlink; A.res := -1; Objects.Stamp(A);
ToMain(F, M.x + F.X, M.y + F.Y, A)
END;
IF menu # NIL THEN
(* Adjust menu *)
A.id := Display.extend; A.F := menu; A.mode := Display.state;
A.X := leftBorder; A.Y := -border + 1; A.W := M.W - leftBorder; A.H := border;
A.dX := A.X - menu.X; A.dY := A.Y - menu.Y; A.dW := A.W - menu.W; A.dH := A.H - menu.H;
A.dlink := M.dlink; A.res := -1; Objects.Stamp(A);
ToMenu(F, M.x + F.X, M.y + F.Y, A)
END;
Gadgets.framehandle(F, M)
END AdjustDocGadget;
(* -- docviewer main frame changed; have to adjust docviewer size *)
PROCEDURE AdjustChildDocGadget(F: DocGadget; VAR M: Display.ModifyMsg);
VAR menu: Gadgets.Frame; A: Display.ModifyMsg;
BEGIN
IF M.stamp # F.stamp THEN
F.stamp := M.stamp; menu := Menu(F);
A.id := Display.extend; A.F := F; A.mode := M.mode;
A.W := leftBorder + M.W; A.H := M.H;
IF menu # NIL THEN INC(A.H, menu.H) END;
A.dW := A.W - F.W; A.dH := A.H - F.H;
A.X := F.X + M.dX; A.Y := F.Y + M.dY;
A.dX := A.X - F.X; A.dY := A.Y - F.Y;
Display.Broadcast(A)
END
END AdjustChildDocGadget;
PROCEDURE RestoreDocGadget(F: DocGadget; R: Display3.Mask; x, y, w, h: INTEGER; VAR M: Display.DisplayMsg);
VAR menu, main: Gadgets.Frame; D: Display.DisplayMsg; b: INTEGER;
PROCEDURE ClipAgainst(VAR x, y, w, h: INTEGER; x1, y1, w1, h1: INTEGER);
VAR r, t, r1, t1: INTEGER;
BEGIN
r := x + w - 1; r1 := x1 + w1 - 1; t := y + h - 1; t1 := y1 + h1 - 1;
IF x < x1 THEN x := x1 END;
IF y < y1 THEN y := y1 END;
IF r > r1 THEN r := r1 END;
IF t > t1 THEN t := t1 END;
w := r - x + 1; h := t - y + 1;
END ClipAgainst;
BEGIN
Oberon.RemoveMarks(x, y, w, h);
menu := Menu(F); main := Main(F);
IF menu # NIL THEN b := menu.H ELSE b := 0 END;
IF leftBorder > 0 THEN
Display3.ReplConst(R, frameColor, x, y, leftBorder, h, Display.replace)
END;
IF M.id = Display.area THEN
IF main # NIL THEN
(* display main frame *)
D.device := Display.screen; D.id := Display.area; D.F := main; D.u := M.u - leftBorder;
D.v := M.v + b; D.w := M.w; D.h := M.h;
ClipAgainst(D.u, D.v, D.w, D.h, 0, -main.H +1, main.W, main.H);
D.dlink := M.dlink; D.res := -1; Objects.Stamp(D);
ToMain(F, x, y, D);
ELSE
Display3.FilledRect3D(R, Display3.FG, Display3.FG, Display3.BG, x + leftBorder, y, w-leftBorder, h - b, 1, Display.replace);
Display3.String(R, Display3.FG, x + leftBorder + 5, y + h - b - 20, Fonts.Default, "Document not found", Display.paint);
END;
IF menu # NIL THEN
D.device := Display.screen; D.id := Display.area; D.F := menu; D.u := M.u - leftBorder;
D.v := M.v; D.w := M.w; D.h := M.h;
ClipAgainst(D.u, D.v, D.w, D.h, 0, -menu.H +1, menu.W, menu.H);
D.dlink := M.dlink; D.res := -1; Objects.Stamp(D);
ToMenu(F, x, y, D)
END
ELSE
IF main # NIL THEN
D.device := Display.screen; D.id := Display.full; D.F := main; D.dlink := M.dlink; D.res := -1; Objects.Stamp(D);
ToMain(F, x, y, D)
ELSE
Display3.FilledRect3D(R, Display3.FG, Display3.FG, Display3.BG, x + leftBorder, y, w-leftBorder, h - b, 1, Display.replace);
Display3.String(R, Display3.FG, x + leftBorder + 5, y + h - b - 20, Fonts.Default, "Document not found", Display.paint);
END;
IF menu # NIL THEN
D.device := Display.screen; D.id := Display.full; D.F := menu; D.dlink := M.dlink; D.res := -1; Objects.Stamp(D);
ToMenu(F, x, y, 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 RestoreDocGadget;
PROCEDURE PrintDocGadget(F: DocGadget; VAR M: Display.DisplayMsg);
VAR menu, main: Display.Frame; b, x, y, w, h: INTEGER; PM: Display.DisplayMsg; R: Display3.Mask;
PROCEDURE P(x: INTEGER): INTEGER;
BEGIN RETURN SHORT(x * Display.Unit DIV Printer.Unit)
END P;
BEGIN
IF M.id = Display.full THEN
menu := Menu(F); main := Main(F);
IF menu # NIL THEN b := menu.H ELSE b := 0 END;
IF main # NIL THEN
PM.device := Display.printer; PM.id := Display.full; PM.x := M.x; PM.y := M.y;
PM.res := -1; PM.F := main; PM.dlink := M.dlink;
main.handle(main, PM)
ELSE
Gadgets.MakePrinterMask(F, M.x, M.y, M.dlink, R);
x := M.x; y := M.y; w := P(F.W); h := P(F.H);
Printer3.FilledRect3D(R, Display3.FG, Display3.FG, Display3.BG, x, y, w, h - P(b), 1, Display.replace);
Printer3.String(R, Display3.FG, x + 5, y + h - P(b + 20), Fonts.Default, "Document not found", Display.paint);
END;
IF menu # NIL THEN
PM.device := Display.printer; PM.id := Display.full; PM.x := M.x; PM.y := M.y + P(F.H - b);
PM.res := -1; PM.F := menu; PM.dlink := M.dlink;
menu.handle(menu, PM)
END
END
END PrintDocGadget;
PROCEDURE CopyDocGadget*(VAR M: Objects.CopyMsg; from, to: DocGadget);
VAR menu, main, menu0, main0: Gadgets.Frame; C: Objects.CopyMsg;
BEGIN
Gadgets.CopyFrame(M, from, to);
menu := Menu(from); main := Main(from);
IF main # NIL THEN
C.id := Objects.shallow; Objects.Stamp(C); main.handle(main, C);
main0 := C.obj(Gadgets.Frame)
ELSE main0 := NIL
END;
IF menu # NIL THEN
C.id := Objects.shallow; Objects.Stamp(C); menu.handle(menu, C);
menu0 := C.obj(Gadgets.Frame)
ELSE menu0 := NIL
END;
IF menu0 = NIL THEN to.dsc := main0
ELSE to.dsc := menu0; menu0.next := main0
END;
END CopyDocGadget;
PROCEDURE StoreDocGadget(F: DocGadget; VAR M: Objects.FileMsg);
BEGIN
Files.WriteInt(M.R, 1);
Files.WriteSet(M.R, {});
Gadgets.WriteRef(M.R, F.lib, Main(F));
Gadgets.framehandle(F, M)
END StoreDocGadget;
PROCEDURE LoadDocGadget(F: DocGadget; VAR M: Objects.FileMsg);
VAR x, i, j: INTEGER; tmp: SET; obj: Objects.Object; main: Gadgets.Frame; title: ARRAY 128 OF CHAR;
L: Objects.LinkMsg; A: Objects.AttrMsg;
BEGIN
Files.ReadInt(M.R, x);
IF x # 1 THEN HALT(99) END;
Files.ReadSet(M.R, tmp);
Gadgets.ReadRef(M.R, F.lib, obj);
Gadgets.framehandle(F, M);
IF (obj # NIL) & (obj IS Gadgets.Frame) THEN main := obj(Gadgets.Frame);
ELSE main := NIL
END;
(* Menu *)
L.obj := NIL; L.res := -1;
IF main # NIL THEN
L.id := Objects.get; L.name := "DeskMenu"; main.handle(main, L)
END;
IF (L.obj # NIL) & (L.obj IS Gadgets.Frame) & (L.res >= 0) THEN obj := L.obj
ELSE
title := "Desktops.CloseDoc[Close] ";
IF (main # NIL) THEN
A.id := Objects.get; A.name := "Menu"; A.res := -1; A.s := ""; obj.handle(obj, A);
IF (A.res >= 0) & (A.class = Objects.String) & (A.s # "") THEN
i := 0; WHILE title[i] # 0X DO INC(i) END;
j := 0; WHILE A.s[j] # 0X DO title[i] := A.s[j]; INC(i); INC(j) END;
title[i] := 0X
END
END;
obj := NewMenu(title)
END;
(* F.Y := F.Y + F.H - main.H - menuH; *)
Init(F, obj(Gadgets.Frame), main, FALSE)
END LoadDocGadget;
PROCEDURE DocGadgetAttr(F: DocGadget; VAR M: Objects.AttrMsg);
BEGIN
IF M.id = Objects.get THEN
IF M.name = "Gen" THEN M.s := "Desktops.NewDocGadget"; M.class := Objects.String; M.res := 0
ELSE Gadgets.framehandle(F, M)
END
ELSE Gadgets.framehandle(F, M)
END
END DocGadgetAttr;
PROCEDURE LinkMenu(F: DocGadget; obj: Objects.Object);
VAR new, main, menu: Gadgets.Frame; h: INTEGER;
BEGIN
IF (obj # NIL) & (obj IS Gadgets.Frame) THEN
new := obj(Gadgets.Frame); h := new.H
ELSE new := NIL; h := 0;
END;
main := Main(F); menu := Menu(F);
IF menu = NIL THEN INC(F.H, h)
ELSE F.H := F.H - menu.H + h
END;
Init(F, new, main, FALSE)
END LinkMenu;
PROCEDURE DocGadgetLink(F: DocGadget; VAR M: Objects.LinkMsg);
BEGIN
IF M.id = Objects.get THEN
IF M.name = "Model" THEN M.obj := Main(F); M.res := 0
ELSIF M.name = "Menu" THEN M.obj := Menu(F); M.res := 0
END
ELSIF M.id = Objects.set THEN
IF (M.name = "Menu") THEN LinkMenu(F, M.obj); M.res := 0 END
END
END DocGadgetLink;
PROCEDURE Neutralize(F: DocGadget);
VAR main: Gadgets.Frame; S: Display.SelectMsg;
BEGIN
main := Main(F);
IF (main # NIL) & (Gadgets.selected IN main.state) THEN
S.F := main; S.res := -1; S.x := 0; S.y := 0;
S.id := Display.reset; F.time := 0;
ToMain(F, 0, 0, S);
Gadgets.Update(main)
END
END Neutralize;
PROCEDURE HandleSelect(F: DocGadget; VAR M: Oberon.InputMsg);
VAR main: Gadgets.Frame; S: Display.SelectMsg; keysum: SET; C: Objects.CopyMsg;
BEGIN
main := Main(F);
IF main # NIL THEN
S.F := main; S.res := -1; S.x := 0; S.y := 0;
IF Gadgets.selected IN main.state THEN S.id := Display.reset; F.time := 0; ELSE S.id := Display.set; F.time := Oberon.Time() END;
ToMain(F, M.x + F.X, M.y + F.Y, S);
Gadgets.Update(main); 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 = {0, 2}) & (S.id = Display.set) THEN (* RL delete selection *)
(* nothing *)
ELSIF (keysum = {0, 1}) & (S.id = Display.set) THEN (* RM copy to focus *)
C.id := Objects.deep; C.obj := NIL; Objects.Stamp(C); main.handle(main, C);
IF C.obj # NIL THEN
Gadgets.Integrate(C.obj)
END
END
END
END HandleSelect;
PROCEDURE TrackDocGadget(F: DocGadget; x, y, w, h, border: INTEGER; VAR M: Oberon.InputMsg);
VAR PM: Gadgets.PriorityMsg;
BEGIN
IF M.Y >= y + h - border THEN
IF M.keys = {2} THEN (* to front first *)
PM.id := Gadgets.visible; PM.passon := TRUE; PM.F := F; Display.Broadcast(PM)
END;
ToMenu(F, x, y, M);
IF (M.res < 0) & ~Gadgets.InActiveArea(F, M) THEN Gadgets.framehandle(F, M) END
ELSE
IF M.keys = {2} THEN (* to front first *)
PM.id := Gadgets.visible; PM.passon := TRUE; PM.F := F; Display.Broadcast(PM)
END;
IF ~Gadgets.InActiveArea(F, M) & (M.keys = {1}) THEN
Gadgets.framehandle(F, M)
ELSE
ToMain(F, x, y, M);
IF (M.res < 0) & (M.keys = {0}) THEN HandleSelect(F, M) END;
IF (M.res < 0) & ~Gadgets.InActiveArea(F, M) THEN Gadgets.framehandle(F, M) END
END
END
END TrackDocGadget;
PROCEDURE DocGadgetHandler*(F: Objects.Object; VAR M: Objects.ObjMsg);
VAR x, y, w, h: INTEGER; F0: DocGadget; R: Display3.Mask; obj: Objects.Object; main, menu: Gadgets.Frame;
border: INTEGER; N: Oberon.ControlMsg; tM: Display.DisplayMsg;
BEGIN
WITH F: DocGadget DO
IF M IS Display.FrameMsg THEN
WITH M: Display.FrameMsg DO
IF (M.F = NIL) OR (M.F = F) THEN (* message addressed to this frame *)
x := M.x + F.X; y := M.y + F.Y; w := F.W; h := F.H; (* calculate display coordinates *)
menu := Menu(F); main := Main(F);
IF menu # NIL THEN border := menu.H ELSE border := 0 END;
IF M IS Display.DisplayMsg THEN
WITH M: Display.DisplayMsg DO
IF M.device = Display.screen THEN
IF (M.id = Display.full) OR (M.F = NIL) THEN
Gadgets.MakeMask(F, x, y, M.dlink, R);
RestoreDocGadget(F, R, x, y, w, h, M)
ELSIF M.id = Display.area THEN
Gadgets.MakeMask(F, x, y, M.dlink, R);
Display3.AdjustMask(R, x + M.u, y + h - 1 + M.v, M.w, M.h);
RestoreDocGadget(F, R, x, y, w, h, M)
END
ELSIF M.device = Display.printer THEN PrintDocGadget(F, M)
END
END
ELSIF M IS Oberon.InputMsg THEN
WITH M: Oberon.InputMsg DO
IF (M.id = Oberon.track) & ~(Gadgets.selected IN F.state) THEN TrackDocGadget(F, x, y, w, h, border, M)
ELSIF ~(Gadgets.selected IN F.state) THEN ToMain(F, x, y, M); ToMenu(F, x, y, M)
ELSE Gadgets.framehandle(F, M)
END
END
ELSIF M IS Display.ModifyMsg THEN
IF M.F = F THEN AdjustDocGadget(F, M(Display.ModifyMsg));
ELSE Gadgets.framehandle(F, M)
END
ELSIF M IS Display.LocateMsg THEN
WITH M: Display.LocateMsg DO
IF (M.loc = NIL) & Effects.Inside(M.X, M.Y, x, y, w, h) THEN
IF M.Y >= y + h - border THEN ToMenu(F, x, y, M)
ELSE ToMain(F, x, y, M)
END;
IF M.loc = NIL THEN M.loc := F; M.u := M.X - x; M.v := M.Y - (y + h - 1); M.res := 0 END;
END
END
ELSIF M IS Display.SelectMsg THEN
WITH M: Display.SelectMsg DO
IF M.id = Display.set THEN
Neutralize(F);
N.id := Oberon.neutralize; N.F := NIL; N.res := -1; ToMain(F, x, y, N); ToMenu(F, x, y, N);
ELSIF M.id = Display.reset THEN
ELSIF M.id = Display.get THEN
main := Main(F);
IF (F.time > M.time) & (Gadgets.selected IN main.state) THEN
M.time := F.time; M.sel := F; M.obj := main
END
END;
IF M.F # NIL THEN Gadgets.framehandle(F, M)
ELSE ToMain(F, x, y, M); ToMenu(F, x, y, M)
END
END
ELSIF M IS Display3.UpdateMaskMsg THEN
WITH M: Display3.UpdateMaskMsg DO
IF M.F = F THEN (* have to create own mask *)
NEW(F.mask); Display3.Open(F.mask); Display3.Add(F.mask, 0, -F.H+1, F.W, F.H);
SetMainMask(F); SetMenuMask(F);
M.res := 0;
END
END
ELSIF M IS Display3.OverlapMsg THEN
WITH M: Display3.OverlapMsg DO
IF (M.F = F) OR (M.F = NIL) THEN F.mask := M.M; SetMainMask(F); SetMenuMask(F) END
END
ELSIF M IS Display3.UpdateMaskMsg THEN
WITH M: Display3.UpdateMaskMsg DO
IF F.mask = NIL THEN Gadgets.MakeMask(F, x, y, M.dlink, R) END;
SetMainMask(F); SetMenuMask(F);
END
ELSIF M IS Oberon.ControlMsg THEN
WITH M: Oberon.ControlMsg DO
ToMain(F, x, y, M); ToMenu(F, x, y, M);
IF M.id = Oberon.neutralize THEN Neutralize(F) END
END
ELSIF M IS Documents.LocateMsg THEN (* added 25.3.94 *)
WITH M: Documents.LocateMsg DO
ToMain(F, x, y, M);
obj := Main(F);
IF M.doc # obj THEN
Gadgets.MakeMask(F, x, y, M.dlink, R);
IF Effects.Inside(M.X, M.Y, x, y, w, h) & Display3.Visible(R, M.X, M.Y, 1, 1) & (obj IS Documents.Document) THEN
M.doc := obj(Documents.Document);
END
END
END
ELSIF M IS Gadgets.UpdateMsg THEN
WITH M: Gadgets.UpdateMsg DO
IF M.obj = main THEN
Gadgets.MakeMask(F, x, y, M.dlink, R);
tM.device := Display.screen; tM.id := Display.full; tM.dlink := M.dlink;
RestoreDocGadget(F, R, x, y, w, h, tM);
ELSE ToMain(F, x, y, M); ToMenu(F, x, y, M)
END;
IF Gadgets.lockedsize IN main.state THEN INCL(F.state, Gadgets.lockedsize)
ELSE EXCL(F.state, Gadgets.lockedsize)
END
END
ELSIF M.F # NIL THEN Gadgets.framehandle(F, M)
ELSE ToMain(F, x, y, M); ToMenu(F, x, y, M)
END
ELSE (* not for this frame but perhaps for a child *)
main := Main(F);
IF M IS Display3.UpdateMaskMsg THEN
WITH M: Display3.UpdateMaskMsg DO
IF M.F = main THEN
IF F.mask = NIL THEN Gadgets.MakeMask(F, x, y, M.dlink, R) END;
SetMainMask(F); SetMenuMask(F)
ELSE ToMain(F, M.x + F.X, M.y + F.Y, M)
END
END
ELSIF M IS Display.ConsumeMsg THEN
WITH M: Display.ConsumeMsg DO
IF (M.obj IS DocGadget) THEN (* prevent consumption *)
ELSE ToMain(F, M.x + F.X, M.y + F.Y, M)
END
END
ELSIF M IS Display.ModifyMsg THEN
IF M.F = main THEN AdjustChildDocGadget(F, M(Display.ModifyMsg))
ELSE ToMain(F, M.x + F.X, M.y + F.Y, M); ToMenu(F, M.x + F.X, M.y + F.Y, M)
END
ELSIF M IS Display.DisplayMsg THEN
WITH M: Display.DisplayMsg DO
IF (M.device = Display.screen) & (M.F = main) THEN
Oberon.RemoveMarks(M.x + F.X, M.y + F.Y, F.W, F.H)
END;
ToMain(F, M.x + F.X, M.y + F.Y, M); ToMenu(F, M.x + F.X, M.y + F.Y, M)
END
ELSE ToMain(F, M.x + F.X, M.y + F.Y, M); ToMenu(F, M.x + F.X, M.y + F.Y, M)
END
END
END
(* Object messages *)
ELSIF M IS Objects.AttrMsg THEN DocGadgetAttr(F, M(Objects.AttrMsg))
ELSIF M IS Objects.LinkMsg THEN DocGadgetLink(F, M(Objects.LinkMsg))
ELSIF M IS Objects.FileMsg THEN
WITH M: Objects.FileMsg DO
IF M.id = Objects.store THEN StoreDocGadget(F, M)
ELSIF M.id = Objects.load THEN LoadDocGadget(F, M)
END
END
ELSIF M IS Objects.CopyMsg THEN
WITH M: Objects.CopyMsg DO
IF M.stamp = F.stamp THEN M.obj := F.dlink (* copy msg arrives again *)
ELSE (* first time copy message arrives *)
NEW(F0); F.stamp := M.stamp; F.dlink := F0; CopyDocGadget(M, F, F0); M.obj := F0
END
END
ELSIF M IS Objects.BindMsg THEN
main := Main(F); IF main # NIL THEN main.handle(main, M) END;
Gadgets.framehandle(F, M);
ELSE (* unknown msg, framehandler might know it *)
Gadgets.framehandle(F, M)
END
END
END DocGadgetHandler;
PROCEDURE NewDocGadget*;
VAR F: DocGadget;
BEGIN
NEW(F); F.handle := DocGadgetHandler; F.W := Display.Width DIV 8 * 3; F.H := 200; Objects.NewObj := F;
END NewDocGadget;
(** Initialize a DocGadget with a menu and main frame. The adjust flag is TRUE if the DocGadget should determine its
size according to the combined size of the menu and main frames. This is the default case. *)
PROCEDURE Init*(F: DocGadget; menu, main: Gadgets.Frame; adjust: BOOLEAN);
VAR A: Display.ModifyMsg; oldH: INTEGER;
BEGIN
IF menu = NIL THEN HALT(99) END;
IF adjust THEN
F.W := 0; F.H := 0;
INC(F.H, menu.H);
IF (main # NIL) & (main.H > 0) THEN
INC(F.H, main.H); INC(F.W, main.W)
ELSE
INC(F.W, Display.Width DIV 8 * 3); INC(F.H, 200)
END;
END;
F.dsc := menu; menu.next := main;
A.id := Display.extend; A.mode := Display.state; A.F := menu; A.res := -1; A.x := 0; A.y := 0;
A.dlink := NIL; Objects.Stamp(A);
(* ps - 12.12.96 *)
oldH := menu.H;
A.X := menu.X; A.Y := menu.Y + oldH - 1; A.W := menu.W; A.H := 0;
A.dX := A.X - menu.X; A.dY := A.Y - menu.Y; A.dW := A.W - menu.W; A.dH := A.H - menu.H;
menu.handle(menu, A);
menu.X := leftBorder; menu.Y := 0;
A.res := -1; Objects.Stamp(A);
A.X := leftBorder; A.Y := -oldH + 1; A.W := F.W - leftBorder; A.H := oldH;
A.dX := A.X - menu.X; A.dY := A.Y - menu.Y; A.dW := A.W - menu.W; A.dH := A.H - menu.H;
menu.handle(menu, A);
IF main # NIL THEN
A.id := Display.extend; A.mode := Display.state; A.F := main; A.res := -1; A.x := 0; A.y := 0;
A.dlink := NIL; Objects.Stamp(A);
PositionMain(F, A.X, A.Y, A.W, A.H);
A.dX := A.X - main.X; A.dY := A.Y - main.Y; A.dW := A.W - main.W; A.dH := A.H - main.H;
IF Gadgets.lockedsize IN main.state THEN INCL(F.state, Gadgets.lockedsize) END;
main.handle(main, A);
END;
INCL(F.state, Gadgets.lockedcontents)
END Init;
(* ===================== Menu bar =================================*)
PROCEDURE newMenu(IN name, menubar: ARRAY OF CHAR): Display.Frame;
VAR obj, list: Objects.Object; P, f: Gadgets.Frame; X, p: INTEGER; cmd, title: ARRAY 64 OF CHAR;