-
-
Notifications
You must be signed in to change notification settings - Fork 346
/
SystemWindow.class.st
2020 lines (1650 loc) · 57.3 KB
/
SystemWindow.class.st
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
"
SystemWindow is the Morphic equivalent of StandardSystemView -- a labelled container for rectangular views, with iconic facilities for close, collapse/expand, and resizing.
The attribute onlyActiveOnTop, if set to true (and any call to activate will set this), determines that only the top member of a collection of such windows on the screen shall be active. To be not active means that a mouse click in any region will only result in bringing the window to the top and then making it active.
"
Class {
#name : 'SystemWindow',
#superclass : 'ModelMorph',
#instVars : [
'labelString',
'stripes',
'label',
'closeBox',
'collapseBox',
'paneMorphs',
'collapsedFrame',
'fullFrame',
'isCollapsed',
'menuBox',
'mustNotClose',
'labelWidgetAllowance',
'updatablePanes',
'labelArea',
'expandBox',
'embeddable',
'isResizeable',
'taskbarTask'
],
#classVars : [
'CloseBoxImage',
'CollapseBoxImage',
'FullscreenMargin',
'TopWindow'
],
#category : 'Morphic-Widgets-Windows-Widgets',
#package : 'Morphic-Widgets-Windows',
#tag : 'Widgets'
}
{ #category : 'accessing' }
SystemWindow class >> borderWidth [
"Making changes to this for some reason requires repositioning of CornerGripMorphs.
Edit BorderedMorph#addCornerGrip and play with offsets to get them right if you increase
border width. For instance, going from 4 to 6 here and you should updated offsets to
(-23@-23 corner: 0@0) for the right placement of corner grips."
^ self theme windowBorderWidthFor: self
]
{ #category : 'keymapping' }
SystemWindow class >> buildShortcutsOn: aBuilder [
<keymap>
(aBuilder shortcut: #close)
category: #WindowShortcuts
default: PharoShortcuts current closeWindowShortcut
do: [ :target | SystemWindow closeTopWindow ]
description: 'Close this window'
]
{ #category : 'keymapping' }
SystemWindow class >> buildWindowBottomEdgeShortcutsOn: aBuilder [
<keymap>
(aBuilder shortcut: #windowBottomEdgeUp)
category: #WindowShortcuts
default: PharoShortcuts current windowBottomEdgeUpShortcut
do: [ :target |
| movement |
movement := 0@(target bounds height / 2) negated.
target bounds: ((target bounds topLeft) corner: (target bounds bottomRight + movement))]
description: 'Move bottom edge of the window up by half of the window extent'.
(aBuilder shortcut: #windowBottomEdgeDown)
category: #WindowShortcuts
default: PharoShortcuts current windowBottomEdgeDownShortcut
do: [ :target |
| movement |
movement := 0@(target bounds height / 2).
target bounds: ((target bounds topLeft) corner: (target bounds bottomRight + movement))]
description: 'Move bottXX edge of the window up by half of the window extent'
]
{ #category : 'keymapping' }
SystemWindow class >> buildWindowLeftEdgeShortcutsOn: aBuilder [
<keymap>
(aBuilder shortcut: #windowLeftEdgeLeft)
category: #WindowShortcuts
default: PharoShortcuts current windowLeftEdgeLeftShortcut
do: [ :target |
| movement |
movement := (target bounds width / 2) negated @0.
target bounds: ((target bounds topLeft + movement) corner: (target bounds bottomRight ))]
description: 'Move left edge of the window left by half of the window extent'.
(aBuilder shortcut: #windowLeftEdgeRight)
category: #WindowShortcuts
default: PharoShortcuts current windowLeftEdgeRightShortcut
do: [ :target |
| movement |
movement := (target bounds width / 2)@0.
target bounds: ((target bounds topLeft + movement) corner: (target bounds bottomRight))]
description: 'Move left edge of the window right by half of the window extent'
]
{ #category : 'keymapping' }
SystemWindow class >> buildWindowMovingShortcutsOn: aBuilder [
<keymap>
(aBuilder shortcut: #windowMoveLeft)
category: #WindowShortcuts
default: PharoShortcuts current windowMoveLeftShortcut
do: [ :target |
| movement |
movement := ((target bounds width / 2) negated)@0.
target bounds: ((target bounds topLeft + (movement)) corner: (target bounds bottomRight + (movement)))]
description: 'Move window left by half of its extent'.
(aBuilder shortcut: #windowMoveRight)
category: #WindowShortcuts
default: PharoShortcuts current windowMoveRightShortcut
do: [ :target |
| movement |
movement := ((target bounds width /2))@0.
target bounds: ((target bounds topLeft + (movement)) corner: (target bounds bottomRight + (movement)))]
description: 'Move window right by half of its extent'.
(aBuilder shortcut: #windowMoveUp)
category: #WindowShortcuts
default: PharoShortcuts current windowMoveUpShortcut
do: [ :target |
| movement |
movement := 0@((target bounds height / 2) negated).
target bounds: ((target bounds topLeft + (movement)) corner: (target bounds bottomRight + (movement)))]
description: 'Move window up by half of its extent'.
(aBuilder shortcut: #windowMoveDown)
category: #WindowShortcuts
default: PharoShortcuts current windowMoveDownShortcut
do: [ :target |
| movement |
movement := 0@(target bounds height / 2).
target bounds: ((target bounds topLeft + (movement)) corner: (target bounds bottomRight + (movement)))]
description: 'Move window down by half of its extent'
]
{ #category : 'keymapping' }
SystemWindow class >> buildWindowRightEdgeShortcutsOn: aBuilder [
<keymap>
(aBuilder shortcut: #windowRightEdgeLeft)
category: #WindowShortcuts
default: PharoShortcuts current windowRightEdgeLeftShortcut
do: [ :target |
| movement |
movement := (target bounds width / 2) negated @0.
target bounds: ((target bounds topLeft) corner: (target bounds bottomRight + movement))]
description: 'Center the window with a default extent'.
(aBuilder shortcut: #windowRightEdgeRight)
category: #WindowShortcuts
default: PharoShortcuts current windowRightEdgeRightShortcut
do: [ :target |
| movement |
movement := (target bounds width / 2)@0.
target bounds: ((target bounds topLeft) corner: (target bounds bottomRight + movement))]
description: 'Center the window with a default extent'
]
{ #category : 'keymapping' }
SystemWindow class >> buildWindowTilingShortcutsOn: aBuilder [
<keymap>
(aBuilder shortcut: #windowTopLeft)
category: #WindowShortcuts
default: PharoShortcuts current windowTopLeftShortcut
do: [ :target | target tileTopLeft]
description: 'Move the window to the top left corner of the display'.
(aBuilder shortcut: #windowLeft)
category: #WindowShortcuts
default: PharoShortcuts current windowLeftShortcut
do: [ :target | target tileLeft ]
description: 'Move the window to the left half of the display'.
(aBuilder shortcut: #windowBottomLeft)
category: #WindowShortcuts
default: PharoShortcuts current windowBottomLeftShortcut
do: [ :target | target tileBottomLeft ]
description: 'Move the window to the bottom left corner of the display'.
(aBuilder shortcut: #windowTop)
category: #WindowShortcuts
default: PharoShortcuts current windowTopShortcut
do: [ :target | target tileTop ]
description: 'Move the window to the top half of the display'.
(aBuilder shortcut: #windowTopRight)
category: #WindowShortcuts
default: PharoShortcuts current windowTopRightShortcut
do: [ :target | target tileTopRight ]
description: 'Move the window to the top right corner of the display'.
(aBuilder shortcut: #windowRight)
category: #WindowShortcuts
default: PharoShortcuts current windowRightShortcut
do: [ :target | target tileRight ]
description: 'Move the window to the right half of the display'.
(aBuilder shortcut: #windowRightBottom)
category: #WindowShortcuts
default: PharoShortcuts current windowRightBottomShortcut
do: [ :target | target tileBottomRight ]
description: 'Move the window to the right bottom corner of the display'.
(aBuilder shortcut: #windowBottom)
category: #WindowShortcuts
default: PharoShortcuts current windowBottomShortcut
do: [ :target | target tileBottom ]
description: 'Move the window to the bottom half of the display'.
(aBuilder shortcut: #windowMaximize)
category: #WindowShortcuts
default: PharoShortcuts current windowMaximizeShortcut
do: [ :target | target tileFull ]
description: 'Maximize the window'.
(aBuilder shortcut: #windowMinimize)
category: #WindowShortcuts
default: PharoShortcuts current windowMinimizeShortcut
do: [ :target | target minimize]
description: 'Miminimze the window'.
(aBuilder shortcut: #windowCenter)
category: #WindowShortcuts
default: PharoShortcuts current windowCenterShortcut
do: [ :target | target tileCenter]
description: 'Center the window with a default extent'
]
{ #category : 'keymapping' }
SystemWindow class >> buildWindowTopEdgeShortcutsOn: aBuilder [
<keymap>
(aBuilder shortcut: #windowTopEdgeUp)
category: #WindowShortcuts
default: PharoShortcuts current windowTopEdgeUpShortcut
do: [ :target |
| movement |
movement := 0@(target bounds height / 2) negated.
target bounds: ((target bounds topLeft + movement) corner: (target bounds bottomRight))]
description: 'Move top edge of the window up by half of the window extent'.
(aBuilder shortcut: #windowTopEdgeDown)
category: #WindowShortcuts
default: PharoShortcuts current windowTopEdgeDownShortcut
do: [ :target |
| movement |
movement := 0@(target bounds height / 2).
target bounds: ((target bounds topLeft + movement) corner: (target bounds bottomRight))]
description: 'Move top edge of the window down by half of the window extent'
]
{ #category : 'accessing' }
SystemWindow class >> closeBoxImage [
"Supplied here because we don't necessarily have ComicBold"
^ CloseBoxImage ifNil: [CloseBoxImage := (Form
extent: 10@10
depth: 32
fromArray: #( 0 0 0 0 0 0 0 0 0 0 0 3326099520 3330310272 0 0 0 0 0 0 0 0 4144038145 3326099520 3330310272 0 0 0 4144038145 3326099520 0 0 0 4227924225 3326099520 3330310272 0 4144038145 3326099520 3330310272 0 0 0 0 4144038145 3326099520 4144038145 3326099520 3330310272 3336494814 0 0 0 0 0 4227924225 3326099520 3330310272 3336494814 0 0 0 0 0 4144038145 3326099520 4144038145 3326099520 3330310272 3336494814 0 0 0 4144038145 3326099520 3330310272 3336494814 4144038145 3326099520 3330310272 0 0 4144038145 3326099520 3330310272 3336494814 0 0 4144038145 3326099520 0 0 0 3330310272 3336494814 0 0 0 0 0 0)
offset: 0@0)]
]
{ #category : 'top window' }
SystemWindow class >> closeTopWindow [
"Try to close the top window. It may of course decline"
TopWindow ifNotNil: [ :window |
TopWindow := nil.
window delete.
]
]
{ #category : 'accessing' }
SystemWindow class >> collapseBoxImage [
"Supplied here because we don't necessarily have ComicBold"
^ CollapseBoxImage ifNil: [ CollapseBoxImage := (Form
extent: 10@10
depth: 32
fromArray: #( 0 0 4127260929 4127260929 4127260929 4127260929 4127260929 0 0 0 0 3875602689 3212869760 3212869760 3212869760 3212869760 3212869760 4227924225 0 0 4127260929 3212869760 3212869760 0 0 0 0 3212869760 4127260929 0 4127260929 3212869760 0 0 0 0 0 0 4127260929 3212869760 4127260929 3212869760 0 0 0 0 0 0 4127260929 3212869760 4127260929 3212869760 0 0 0 0 0 0 4127260929 3212869760 4128708375 3212869760 0 0 0 0 0 0 4127260929 3212869760 0 4127260929 3212869760 0 0 0 0 4127260929 3208659008 3212869760 0 3208659008 4127260929 4127260929 4127260929 4127260929 4127260929 3208659008 3212869760 0 0 0 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 0 0)
offset: 0@0)]
]
{ #category : 'accessing' }
SystemWindow class >> expandBoxImage [
^ (Form
extent: 10@10
depth: 32
fromArray: #( 3875602689 3875602689 3875602689 3875602689 3875602689 3875602689 0 0 0 0 3875602689 0 0 0 0 4127260929 3877181721 3877181721 3875602689 0 3875602689 0 0 0 0 3875602689 3212869760 0 3875602689 3212869760 3875602689 0 0 0 0 3875602689 3212869760 0 3875602689 3212869760 3875602689 0 0 0 0 3875602689 3212869760 0 3875602689 3212869760 3875602689 4127260929 3875602689 3875602689 3875602689 3875602689 3212869760 0 3875602689 3212869760 0 3877181721 3212869760 3212869760 3212869760 3212869760 3212869760 0 3875602689 3212869760 0 3877181721 0 0 0 0 0 0 3875602689 3212869760 0 3875602689 3875602689 3875602689 3875602689 3875602689 3875602689 3875602689 3875602689 3212869760 0 0 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760)
offset: 0@0)
]
{ #category : 'settings' }
SystemWindow class >> fullscreenMargin [
^ FullscreenMargin ifNil: [FullscreenMargin := 0]
]
{ #category : 'settings' }
SystemWindow class >> fullscreenMargin: anInteger [
FullscreenMargin := anInteger
]
{ #category : 'private-menu building' }
SystemWindow class >> icons [
^ Smalltalk ui icons
]
{ #category : 'class initialization' }
SystemWindow class >> initialize [
CollapseBoxImage := nil.
CloseBoxImage := nil
]
{ #category : 'instance creation' }
SystemWindow class >> labelled: labelString [
^self new setLabel: labelString
]
{ #category : 'accessing' }
SystemWindow class >> menuBoxImage [
^ (Form
extent: 10@10
depth: 32
fromArray: #( 4227858432 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4227858432 0 4127195136 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 4127195136 3212869760 4127195136 3212869760 0 0 0 0 0 0 4127195136 3212869760 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 3212869760 4127195136 3212869760 0 0 0 0 0 0 4127195136 3212869760 4127195136 3212869760 0 0 0 0 0 0 4127195136 3212869760 4227858432 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 3212869760 4127195136 3212869760 0 0 0 0 0 0 4127195136 3212869760 4227858432 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4127195136 4227858432 3212869760 0 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760 3212869760)
offset: 0@0)
]
{ #category : 'top window' }
SystemWindow class >> noteTopWindowIn: aWorld [
"Clear the current top window and activate the topmost visible window"
TopWindow := nil.
aWorld ifNil: [^ self].
aWorld submorphsDo: [:m |
(m isSystemWindow and: [m isCollapsed not]) ifTrue: [
^m activate]]
]
{ #category : 'top window' }
SystemWindow class >> sendTopWindowToBack [
"Send the top window of the world to the back. Relies on #submorphs array being ordered top to bottom. "
self currentWorld submorphs
detect: [ :morph | morph isSystemWindow ]
ifFound: [ :morph | morph sendToBack ]
]
{ #category : 'menu items - tiling' }
SystemWindow class >> tilingMenuItemsOn: aBuilder [
<windowMenu>
(aBuilder item: #tileLeft)
action: [ :target | target tileLeft ];
label: 'Left';
parent: #Tile;
icon: (self iconNamed: #blank);
order: 1;
help: 'Move the window to the left half of the display'.
(aBuilder item: #tileRight)
action: [ :target | target tileRight ];
label: 'Right';
parent: #Tile;
help: 'Move the window to the right half of the display'.
(aBuilder item: #tileTop)
action: [ :target | target tileTop ];
label: 'Top';
parent: #Tile;
help: 'Move the window to the top half of the display'.
(aBuilder item: #tileBottom)
action: [ :target | target tileBottom ];
label: 'Bottom';
parent: #Tile;
help: 'Move the window to the bottom half of the display'.
(aBuilder item: #tileTopLeft)
action: [ :target | target tileTopLeft ];
label: 'Top left';
parent: #Tile;
help: 'Move the window to the top left corner of the display'.
(aBuilder item: #tileTopRight)
action: [ :target | target tileTopRight ];
label: 'Top right';
parent: #Tile;
help: 'Move the window to the top right corner of the display'.
(aBuilder item: #tileBottomLeft)
action: [ :target | target tileBottomLeft ];
label: 'Bottom left';
parent: #Tile;
help: 'Move the window to the bottom left corner of the display'.
(aBuilder item: #tileBottomRight)
action: [ :target | target tileBottomRight ];
label: 'Bottom right';
parent: #Tile;
help: 'Move the window to the right bottom corner of the display'.
(aBuilder item: #tileFull)
action: [ :target | target tileFull ];
label: 'Full';
parent: #Tile;
help: 'Maximize the window'.
(aBuilder item: #tileCenter)
action: [ :target | target tileCenter ];
label: 'Center';
parent: #Tile;
help: 'Center the window with a default extent'
]
{ #category : 'menu items - tiling' }
SystemWindow class >> tilingMenuOn: aBuilder [
<windowMenu>
(aBuilder item: #Tile)
order: 10.5
]
{ #category : 'top window' }
SystemWindow class >> topWindow [
^ TopWindow
]
{ #category : 'top window' }
SystemWindow class >> wakeUpTopWindowUponStartup [
TopWindow ifNotNil:
[TopWindow isCollapsed ifFalse:
[TopWindow model ifNotNil:
[TopWindow model modelWakeUpIn: TopWindow]]]
]
{ #category : 'menu items' }
SystemWindow class >> windowMenuOn: aBuilder [
"To inject your custom items in a specific place, note that each item increases in order by 1. For example, if you wanted your item to be the second item, you could give it an #order: 1.5"
<windowMenu>
| closableLabel draggableLabel maximizeLabel |
(aBuilder item: #Close)
order: 1.0;
action: [ aBuilder model closeBoxHit ];
iconName: #windowClose;
enabledBlock: [ aBuilder model allowedToClose ];
withSeparatorAfter.
(aBuilder item: #About)
action: [ aBuilder model showAbout ];
iconName: #smallHelp;
withSeparatorAfter.
(aBuilder item: #'Change title')
action: [ aBuilder model relabel ].
(aBuilder item: #'Copy title')
action: [ aBuilder model copyTitle ];
withSeparatorAfter.
(aBuilder item: #'Send to back')
action: [ aBuilder model sendToBack ].
(aBuilder item: #'Make next-to-topmost')
action: [ aBuilder model makeSecondTopmost ];
withSeparatorAfter.
(aBuilder item: #'Create window group')
action: [ aBuilder model createWindowGroup ].
(aBuilder item: #'Open as external window')
action: [ aBuilder model openAsExternalWindow ];
withSeparatorAfter.
closableLabel := aBuilder model mustNotClose
ifFalse: [ #'Make unclosable' ]
ifTrue: [ #'Make closable' ].
(aBuilder item: closableLabel)
action: [
(closableLabel = #'Make unclosable')
ifTrue: [ aBuilder model makeUnclosable ]
ifFalse:[ aBuilder model makeClosable] ].
draggableLabel := aBuilder model isSticky
ifTrue: [ #'Make draggable' ]
ifFalse: [ #'Make undraggable' ].
(aBuilder item: draggableLabel)
action: [ aBuilder model toggleStickiness ];
withSeparatorAfter.
maximizeLabel := aBuilder model isMaximized
ifTrue: [ #Restore ]
ifFalse: [ #Maximize ].
(aBuilder item: maximizeLabel)
action: [ aBuilder model expandBoxHit ];
iconName: #windowMaximizeForm
]
{ #category : 'top window' }
SystemWindow class >> windowsIn: aWorld satisfying: windowBlock [
| windows |
windows := OrderedCollection new.
aWorld ifNil: [^windows]. "opening MVC in Morphic - WOW!"
aWorld submorphs do:
[:m | | s |
((m isSystemWindow) and: [windowBlock value: m])
ifTrue: [windows addLast: m]
ifFalse: [((m isKindOf: TransformationMorph) and: [m submorphs size = 1])
ifTrue: [s := m firstSubmorph.
((s isSystemWindow) and: [windowBlock value: s])
ifTrue: [windows addLast: s]]]].
^ windows
]
{ #category : 'activation' }
SystemWindow >> activate [
"Activate the owner too."
self activatedModalChild ifTrue: [ ^self ].
self addPaneSplittersIfNeeded.
super activate.
self isEmbedded ifFalse: [
self basicActivate
].
self navigateFocus.
self positionModalOwner
]
{ #category : 'top window' }
SystemWindow >> activateAndForceLabelToShow [
self activate.
bounds top < 0 ifTrue:
[self position: (self position x @ 0)]
]
{ #category : 'activation' }
SystemWindow >> activatedModalChild [
self modalChild ifNotNil: [ :modalChild |
modalChild owner ifNotNil: [
modalChild activate.
modalChild modalChild ifNil: [ modalChild indicateModalChild ].
^true.
]
].
^false
]
{ #category : 'initialization' }
SystemWindow >> addCloseBox [
"If I have a labelArea, add a close box to it"
| frame |
labelArea
ifNil: [^ self].
closeBox := self createCloseBox.
frame := LayoutFrame identity leftOffset: 2.
closeBox layoutFrame: frame.
labelArea addMorphBack: closeBox
]
{ #category : 'menu actions' }
SystemWindow >> addCustomMenuItems: aCustomMenu hand: aHandMorph [
super addCustomMenuItems: aCustomMenu hand: aHandMorph.
"template..."
aCustomMenu addLine.
aCustomMenu add: 'Edit label...' selector: #relabel
]
{ #category : 'initialization' }
SystemWindow >> addLabelArea [
labelArea :=self theme newWindowHeaderFor: self.
self addMorph: labelArea
]
{ #category : 'panes' }
SystemWindow >> addMorph: aMorph frame: rectangle [
^ self addMorph: aMorph fullFrame: rectangle
]
{ #category : 'activation' }
SystemWindow >> addPaneSplittersIfNeeded [
(isCollapsed not
and: [ self paneMorphs isNotEmpty and: [self splitters isEmpty]])
ifTrue: [self addPaneSplitters]
]
{ #category : 'top window' }
SystemWindow >> adjustBorderUponActivationWhenLabeless [
"Adjust the border upon, um, activation when, um, labelless"
| aWidth |
(aWidth := self valueOfProperty: #borderWidthWhenActive) ifNotNil:
[self acquireBorderWidth: aWidth]
]
{ #category : 'top window' }
SystemWindow >> adjustBorderUponDeactivationWhenLabeless [
"Adjust the border upon deactivation when, labelless"
| aWidth |
(aWidth := self valueOfProperty: #borderWidthWhenInactive) ifNotNil:
[self acquireBorderWidth: aWidth]
]
{ #category : 'stepping' }
SystemWindow >> amendSteppingStatus [
"Circumstances having changed, find out whether stepping is wanted and assure that the new policy is carried out"
self wantsSteps
ifTrue:
[self arrangeToStartStepping]
ifFalse:
[self stopStepping]
]
{ #category : 'announcement' }
SystemWindow >> announce: anAnnouncement [
"announcer is lazy initialized. If announcer is not set, this means that there is no listener, no need to propagate the announcement therefore"
self doAnnounce: anAnnouncement
]
{ #category : 'announcement' }
SystemWindow >> announceActivated [
self announce: (
WindowActivated new
window: self;
yourself
)
]
{ #category : 'announcement' }
SystemWindow >> announceDeActivated [
self announce: (
WindowDeActivated new
window: self;
yourself
)
]
{ #category : 'announcement' }
SystemWindow >> announceOpened [
super announceOpened.
self currentWorld announcer
announce: (WindowOpened new
window: self;
yourself)
]
{ #category : 'initialization' }
SystemWindow >> applyModelExtent [
self extent: model initialExtent
]
{ #category : 'activation' }
SystemWindow >> basicActivate [
"Bring me to the front and make me able to respond to mouse and keyboard."
| outerMorph |
outerMorph := self topRendererOrSelf.
outerMorph owner ifNil: [^ self "avoid spurious activate when drop in trash"].
self isTopWindow ifTrue: [^self].
self beTopWindow.
outerMorph owner firstSubmorph == outerMorph
ifFalse: ["Bring me (with any flex) to the top if not already"
outerMorph owner addMorphFront: outerMorph
].
self submorphsDo: [:m | m unlock].
labelArea ifNotNil: [
labelArea submorphsDo: [:m | m unlock].
self setStripeColorsFrom: self paneColorToUse
].
self isCollapsed ifFalse: [
model modelWakeUpIn: self.
self positionSubmorphs.
labelArea ifNil: [ self adjustBorderUponActivationWhenLabeless ]
].
self privateFullBounds: nil; changed "ensure fullBounds computed for active drop shadow"
]
{ #category : 'controls' }
SystemWindow >> beResizeable [
isResizeable := true.
"If isResizable is overriden to always return false, then it would break the invariant"
self isResizeable ifTrue: [ self addGripsIfWanted ]
]
{ #category : 'activation' }
SystemWindow >> beTopWindow [
| oldTopWindow |
oldTopWindow := TopWindow.
TopWindow := self.
oldTopWindow ifNotNil: [ oldTopWindow privateBePassive ].
self announceActivated
]
{ #category : 'controls' }
SystemWindow >> beUnresizeable [
isResizeable := false.
"If isResizable is overriden to always return true, then it would break the invariant"
self isResizeable ifFalse: [ self removeGrips ]
]
{ #category : 'initialization' }
SystemWindow >> boxExtent [
"answer the extent to use in all the buttons.
The label height is used to be proportional to the standard window label font"
label ifNil: [^(14 @ 14) * self displayScaleFactor].
^ (((14 @ 14) * self displayScaleFactor) max: label height @ label height)
]
{ #category : 'controls' }
SystemWindow >> buildWindowMenu [
^ self menu
]
{ #category : 'testing' }
SystemWindow >> canBeMaximized [
"Answer whether we are not we can be maximised."
^ self isResizeable and: [ self isNotMaximized ]
]
{ #category : 'menu actions' }
SystemWindow >> changeColor [
"Change the color of the receiver -- triggered, e.g. from a menu. This variant allows the recolor triggered from the window's halo recolor handle to have the same result as choosing change-window-color from the window-title menu"
self setWindowColor
]
{ #category : 'open/close' }
SystemWindow >> close [
^ self delete
]
{ #category : 'keymapping' }
SystemWindow >> closeWindowAction [
"closed by a shortcut action.
subclasses may overwrite this to do a different action (for example, cancel edits)"
self close
]
{ #category : 'resize/collapse' }
SystemWindow >> collapse [
self isCollapsed ifFalse:[self collapseOrExpand]
]
{ #category : 'resize/collapse' }
SystemWindow >> collapseOrExpand [
"Collapse or expand the window, depending on existing state.
Use the taskbar if present, otherwise do as normal."
| cf |
self isTaskbarPresent ifTrue: [ ^ self minimizeOrRestore ].
isCollapsed
ifTrue: [ "Expand -- restore panes to morphics structure"
isCollapsed := false.
self activate. "Bring to frint first"
collapsedFrame := self getBoundsWithFlex.
collapseBox ifNotNil: [
collapseBox setBalloonText: 'Collapse this window' ].
self setBoundsWithFlex: fullFrame.
paneMorphs reverseDo: [ :m |
self addMorph: m unlock.
m startSteppingSubmorphs ].
self
addPaneSplitters;
addGripsIfWanted ]
ifFalse: [ "Collapse -- remove panes from morphics structure"
isCollapsed := true.
fullFrame := self getBoundsWithFlex.
"First save latest fullFrame"
paneMorphs do: [ :m |
m
delete;
releaseCachedState ].
self removePaneSplitters.
self removeGrips.
cf := self getCollapsedFrame.
collapsedFrame ifNil: [ collapsedFrame := cf ].
self setBoundsWithFlex: cf.
collapseBox ifNotNil: [
collapseBox setBalloonText: 'expand this window' ].
expandBox ifNotNil: [
expandBox setBalloonText: 'expand to full screen' ] ].
self layoutChanged.
"This gets invoked only if the taskbar is not present, if it is, then minimizeOrRestore is invoked (cf beginning of this method)"
self announce: (WindowCollapsed new
window: self;
yourself)
]
{ #category : 'resize/collapse' }
SystemWindow >> collapsedFrame [
^ collapsedFrame
]
{ #category : 'drawing' }
SystemWindow >> colorForInsets [
^self paneColor colorForInsets
]
{ #category : 'label' }
SystemWindow >> copyTitle [
Clipboard clipboardText: self label.
self inform: 'Window title copied.'
]
{ #category : 'initialization' }
SystemWindow >> createBox [
"create a button with default to be used in the label area"
"Transcript show: self paneColor asString;
cr."
| box |
box := IconicButtonMorph new.
box color: Color transparent;
target: self;
useSquareCorners;
borderWidth: 0.
^ box
]
{ #category : 'menu actions' }
SystemWindow >> createWindowGroup [
| group pos ext |
pos := self position.
ext := self extent.
group := GroupWindowMorph new.
group addWindow: self.
(group openInWindowLabeled: 'Group: ' translated , self label)
extent: ext;
position: pos;
model: group
]
{ #category : 'initialization' }
SystemWindow >> defaultBorderColor [
"answer the default border color/fill style for the receiver"
^ #raised
]
{ #category : 'initialization' }
SystemWindow >> defaultColor [
"answer the default color/fill style for the receiver"
^ self theme backgroundColor
]
{ #category : 'controls' }
SystemWindow >> defaultIsResizeable [
^ true
]
{ #category : 'open/close' }
SystemWindow >> delete [
"Should activate window before asking model if okToChange
since likely that a confirmation dialog will be requested.
Don't if not owned by the world though."
"in case we add some panes and reopen!"
self isCloseable
ifFalse: [ ^ self ].
self deleteDiscardingChanges
]
{ #category : 'menu actions' }
SystemWindow >> deleteCloseBox [
closeBox ifNotNil:
[closeBox delete.
closeBox := nil]
]
{ #category : 'open/close' }
SystemWindow >> deleteDiscardingChanges [
| thisWorld announcement |
self removePaneSplitters. "in case we add some panes and reopen!"
thisWorld := self world.
self isFlexed
ifTrue: [ owner delete ]
ifFalse: [ super delete ].
model
ifNotNil: [ model
windowIsClosing;
releaseActionMap ].
model := nil.
SystemWindow noteTopWindowIn: thisWorld.
announcement := WindowClosed new
window: self;
yourself.
self announce: announcement.
self currentWorld announcer announce: announcement
]
{ #category : 'menu building' }
SystemWindow >> discoveredMenuPragmaKeyword [
^ #windowMenu
]
{ #category : 'events' }
SystemWindow >> doFastFrameDrag: grabPoint [
"Do fast frame dragging from the given point"
(FastDraggingFrameMorph forDragging: self clickedAt: grabPoint) openInWorld
]
{ #category : 'resize/collapse' }
SystemWindow >> doFastWindowReframe: aSideOrCornerName [
"Do fast frame resizing from the given corner or side"
(FastDraggingFrameMorph forResizing: self fromLocation: aSideOrCornerName) openInWorld
]
{ #category : 'accessing' }
SystemWindow >> embeddable [
^ embeddable ifNil: [embeddable := false]
]
{ #category : 'accessing' }
SystemWindow >> embeddable: aBoolean [
embeddable := aBoolean
]
{ #category : 'accessing' }
SystemWindow >> embeddedWindowOrNil [
"answer nil for common morphs, yourself from system windows and first submorph for transformation morphs"
^ self
]
{ #category : 'panes' }
SystemWindow >> existingPaneColor [
"Answer the existing pane color for the window, obtaining it from the first paneMorph if any, and fall back on using the second stripe color if necessary."
| aColor |
aColor := self valueOfProperty: #paneColor.
aColor ifNil: [self setProperty: #paneColor toValue: (aColor := self paneColor)].
^aColor
]
{ #category : 'resize/collapse' }
SystemWindow >> expand [
self isCollapsed ifTrue:[self collapseOrExpand]
]
{ #category : 'resize/collapse' }
SystemWindow >> extent: aPoint [
"Set the receiver's extent to value provided. Respect my minimumExtent."
| newExtent w oldExtent|
newExtent := self isCollapsed
ifTrue: [aPoint max: (self labelWidgetAllowance @ 0)]
ifFalse: [aPoint max: self minimumExtent].
newExtent = self extent ifTrue: [^ self].
oldExtent := self extent.
isCollapsed
ifTrue: [super extent: newExtent x @ self labelHeight]
ifFalse: [super extent: newExtent].
isCollapsed