forked from pharo-project/pharo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpPresenter.class.st
1167 lines (878 loc) · 29.1 KB
/
SpPresenter.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
"
SpPresenter is an abstract class which represent a applicative presenter made to be composed with other SpPresenter
Most often, I am used to display other subclasses of SpPresenter or subclasses of SpAbstractWidgetPresenter.
I collaborate with
- ValueHolder to managed some of my variables.
- SpecFocusOrder when no focusOrder are specified.
- SpecLayout
- WindowPresenter or DialogWindowPresenter to display myself.
A new subclass of SpPresenter must at least define initializeWidgets and defaultSpec on the class side.
I provide the following methods
- aboutText: set the text displayed in the About.
- initializeWindow: to set the title, and other information related to the window.
- extent: set the initial size of the window, alternative possibility is define again initialExtent, it must be called before have displayed the widget.
- focusOrder: set an instance what manage the order of focus of the keyboard navigation.
- bindKeyCombination:toAction: create a shortcut on keyboard what perform the block of the action.
- owner getter of my parent.
- window getter of the window displaying me.
On my class side, I provide methods returning standard height and width for some elements.
todo
- announce:
- applyMenuModel: and neglectMenuModel:
- keyStrokeForNextFocus:, giveFocusToNextFrom: and takeKeyboardFocus
- ensureExtentFor:
- hide
- needRebuild
- on:do:
- update:
- widget
Window
=======
- openWithSpec instantiates a WindowPresenter using the lookup to found the layout to use.
- openDialogWithSpec instanciates a DialogWindowPresenter using the lookup to found the layout to use.
Their variants openWithSpec: and openDialogWithSpec: use the layout parameter.
These methods can be useful to manage the window
- isDisplayed returns true if the window of the widget is displayed
- hasWindow returns true if the widget have a window
- centered to center the window in the world.
- delete to delete the window.
todo
- cancelled
- setModal:
- windowIcon:
Instantiation
===========
* initializeWidgets is called by the initialize method, it should contain initialization of subwidgets and of the focusorder.
The instantiation of a subwidget should use one of that way
- instantiate: take a class in parameter and return the created instance.
- methods named 'new' followed by a widget name are shortcut working with instatiate:
Usually, the subwidgets must be added in the focusOrder using something like 'self focusOrder add: accessor of the subwidget'
Note that instantiateModels: is legacy code in ComposablePresenter and must not be used. It will be deprecated and removed.
* initializePresenter is called by the initialize method after initializeWidgets, it should manage interaction of subwidgets.
Methods named 'when' followed by an event provide hook to perform the action in parameter.
Note
-------
Be careful about code order if you are overriding initialize method.
Normally in Spec initializing instance variables should be done BEFORE calling super initialize (so the opposite of the normal approach), because super initialize calls initalizeWidgets and initializePresenter that normally would make use of those variables.
Layout
======
See SpecLayout
defaultSpec or a method containing the pragma <spec: #default> must be defined in the class side of my subclasses.
It contains informations about how place its elements.
It possible to define more than one method to give the possibility to use another layout, by default the one containing the pragma will be used if it exists, if not defaultSpec will be used.
"
Class {
#name : #SpPresenter,
#superclass : #SpAbstractPresenter,
#instVars : [
'#application',
'#focusOrder',
'#contextKeyBindings',
'#windowIcon => SpObservableSlot',
'#aboutText => SpObservableSlot',
'#askOkToClose => SpObservableSlot',
'#titleHolder => SpObservableSlot',
'#additionalSubpresentersMap',
'#layout => SpObservableSlot',
'#visible => SpObservableSlot',
'#extent => SpObservableSlot'
],
#category : #'Spec2-Core-Base'
}
{ #category : #accessing }
SpPresenter class >> currentApplication [
^ SpApplication defaultApplication
]
{ #category : #specs }
SpPresenter class >> defaultSpec [
^ self subclassResponsibility
]
{ #category : #accessing }
SpPresenter class >> iconNamed: aSymbol [
^ Smalltalk ui icons iconNamed: aSymbol
]
{ #category : #'labelled-presenters' }
SpPresenter class >> iconWidth [
^ 24
]
{ #category : #testing }
SpPresenter class >> isAbstract [
^ self = SpPresenter
]
{ #category : #'labelled-presenters' }
SpPresenter class >> labelWidth [
^ 100
]
{ #category : #'instance creation' }
SpPresenter class >> newApplication: anApplication [
^ self basicNew
application: anApplication;
initialize;
yourself
]
{ #category : #'instance creation' }
SpPresenter class >> newApplication: anApplication model: aModel [
^ self basicNew
application: anApplication;
setModelBeforeInitialization: aModel;
initialize;
yourself
]
{ #category : #'instance creation' }
SpPresenter class >> newApplication: anApplication owner: anOwningPresenter [
^ self basicNew
application: anApplication;
owner: anOwningPresenter;
initialize;
yourself
]
{ #category : #'instance creation' }
SpPresenter class >> newApplication: anApplication owner: anOwningPresenter model: aDomainObject [
^ self basicNew
application: anApplication;
owner: anOwningPresenter;
setModelBeforeInitialization: aDomainObject;
initialize;
yourself
]
{ #category : #'instance creation' }
SpPresenter class >> on: aDomainObject [
^ self
newApplication: self currentApplication
model: aDomainObject
]
{ #category : #'instance creation' }
SpPresenter class >> owner: anOwningPresenter on: aDomainObject [
^ self basicNew
owner: anOwningPresenter;
setModelBeforeInitialization: aDomainObject;
initialize;
yourself
]
{ #category : #specs }
SpPresenter class >> title [
^ 'Untitled window'
]
{ #category : #TOREMOVE }
SpPresenter >> aboutText [
"DO NOT USE
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
This method cannot be deprecated because during a transition phase we keep this mecanism. "
^ aboutText
]
{ #category : #private }
SpPresenter >> addAll: aWindow withSpecLayout: aSpec [
aWindow
addMorph: (self buildWithSpecLayout: aSpec)
frame: (0@0 corner: 1@1).
]
{ #category : #TOREMOVE }
SpPresenter >> addMenuItemsToWindowMenu: aMenu [
"Do nothing"
]
{ #category : #TOREMOVE }
SpPresenter >> additionalSubpresentersMap [
"additionalSubpresentersMap serves for storing of sub-presenters that are not
stored in instance variables"
self flag: #TOREMOVE. "This is now provided by TDynamicPresenter"
^ additionalSubpresentersMap ifNil: [ additionalSubpresentersMap := Dictionary new ]
]
{ #category : #'private-traversing' }
SpPresenter >> allPresenters [
| allPresenters |
allPresenters := OrderedCollection new.
self traversePresentersDo: [ :each |
allPresenters add: each ].
^ allPresenters
]
{ #category : #private }
SpPresenter >> allPresentersInFocusOrder [
| allPresenters |
allPresenters := OrderedCollection new.
self traverseInFocusOrderDo: [ :each |
allPresenters add: each ].
^ allPresenters
]
{ #category : #api }
SpPresenter >> announce: anAnnouncement [
self announcer announce: anAnnouncement
]
{ #category : #'api-events' }
SpPresenter >> announceDisplayed [
"When using a VersatileDialogPresenter the adapter is nil.
We do not know if that is a correct behaviour"
self announcer
announce:
(SpWidgetDisplayed new
presenter: self;
widget: (adapter ifNotNil: [ adapter widget ]);
yourself)
]
{ #category : #accessing }
SpPresenter >> application [
^ self hasOwner
ifTrue: [ self owner application ]
ifFalse: [
application ifNil: [
self flag: #TODO. "This is incorrect, no component who is also a root
(it does not has owner) should not have an application. But in older times
it was not like that and to support such components we assign them to a
default application"
application := SpApplication defaultApplication ] ]
]
{ #category : #accessing }
SpPresenter >> application: anApplication [
application := anApplication
]
{ #category : #TOREMOVE }
SpPresenter >> applyMenuModel: aMenuModel [
aMenuModel menuGroups do: [ :group |
group menuItems do: [ :item |
item shortcut ifNotNil: [ :shortcut |
self
bindKeyCombination: shortcut
toAction: [ item performMenuActionWith: #() ] ].
item subMenu ifNotNil: [ :subMenu | subMenu applyTo: self ] ] ]
]
{ #category : #converting }
SpPresenter >> asPresenter [
"This allows to use presenter instances inside layouts directly"
^ self
]
{ #category : #TOREMOVE }
SpPresenter >> askOkToClose [
"DO NOT USE
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
This method cannot be deprecated because during a transition phase we keep this mecanism. "
^ askOkToClose
]
{ #category : #'private building' }
SpPresenter >> basicBuildAdapterWithSpecLayout: aSpecLayout [
layout == aSpecLayout
ifFalse: [ layout := aSpecLayout ].
^ super basicBuildAdapterWithSpecLayout: aSpecLayout
]
{ #category : #'api-shortcuts' }
SpPresenter >> bindKeyCombination: aShortcut toAction: aBlock [
contextKeyBindings ifNil: [ contextKeyBindings := KMCategory new ].
contextKeyBindings addKeymapEntry: (KMKeymap
shortcut: aShortcut
action: aBlock).
self withAdapterDo: [ :anAdapter |
anAdapter bindKeyCombination: aShortcut toAction: aBlock ]
]
{ #category : #testing }
SpPresenter >> canTakeKeyboardFocus [
^ true
]
{ #category : #'api-window' }
SpPresenter >> cancelled [
self flag: #TODO. "just for dialogs... I wonder if we need it here?"
self withWindowDo: #cancelled
]
{ #category : #'api-window' }
SpPresenter >> centered [
self withWindowDo: #centered
]
{ #category : #TOMOVE }
SpPresenter >> centeredRelativeTo: aModel [
self withWindowDo: [ :w |
w centeredRelativeTo: aModel ]
]
{ #category : #initialization }
SpPresenter >> connectPresenters [
"The method connectPresenters defines the interactions between the dif- ferent widgets. By connecting the behaviors of the different widgets it speci- fies the overall presentation, i.e., how the overall UI responds to interactions by the user. Usually this method consists of specifications of actions to per- form when a certain event is received by a widget. The whole interaction flow of the UI then emerges from the propagation of those events."
]
{ #category : #'api-shortcuts' }
SpPresenter >> contextKeyBindings [
"contextKeyBindings stores a KMCategory with keybindings for this presenter"
self flag: #TODO. "Think is... not all presenters can have keybindings. Why are we
putting this functionality here and not in a trait?"
^ contextKeyBindings
]
{ #category : #'api-shortcuts' }
SpPresenter >> contextKeyBindings: aKMCategory [
contextKeyBindings := aKMCategory
]
{ #category : #private }
SpPresenter >> createInstanceFor: aClassSymbol [
"Retrieve the class corresponding to aClassSymbol using the bindings, then create a new instance of theis class"
| class |
class := self resolveSymbol: aClassSymbol.
^ self instantiate: class.
]
{ #category : #'api-focus' }
SpPresenter >> defaultKeyboardFocus [
"Override this to allow the presenter to re-define the one that will answer the
takeKeyboardFocus call in composed presenters"
^ self
]
{ #category : #specs }
SpPresenter >> defaultSpec [
^ self class perform: self defaultSpecSelector
]
{ #category : #'api-showing' }
SpPresenter >> defaultWindowPresenterClass [
^ SpWindowPresenter
]
{ #category : #accessing }
SpPresenter >> defer: aBlock [
self application defer: aBlock
]
{ #category : #private }
SpPresenter >> delete [
self withWindowDo: #delete
]
{ #category : #accessing }
SpPresenter >> enabled: aBoolean [
self presentersDo: [ :each |
each enabled: aBoolean ]
]
{ #category : #TOMOVE }
SpPresenter >> ensureExtentFor: widget [
self extent
ifNil: [ self initialExtent
ifNotNil: [ :ex |
(widget respondsTo: #extent:)
ifTrue: [ widget extent: ex ] ] ]
ifNotNil: [ :ex |
(widget respondsTo: #extent:)
ifTrue: [ widget extent: ex ] ].
]
{ #category : #TOMOVE }
SpPresenter >> extent [
^ extent
]
{ #category : #TOMOVE }
SpPresenter >> extent: aPoint [
^ extent := aPoint
]
{ #category : #accessing }
SpPresenter >> focusOrder [
^ focusOrder ifNil: [ focusOrder := OrderedCollection new ].
]
{ #category : #accessing }
SpPresenter >> focusOrder: anObject [
^ focusOrder := anObject
]
{ #category : #'GTInspector-Extensions' }
SpPresenter >> gtInspectorPreviewIn: composite [
<gtInspectorPresentationOrder: 30>
self adapter ifNotNil: [ :w | w gtInspectorPreviewIn: composite ]
]
{ #category : #'GTInspector-Extensions' }
SpPresenter >> gtInspectorSubPresentersIn: composite [
<gtInspectorPresentationOrder: 20>
composite tree
title: 'Sub presenters';
rootsExpanded;
display: [ :each | {each} ];
children: [ :each | each presenters ];
when: [ :each | each presenters isNotEmpty ]
]
{ #category : #'api-focus' }
SpPresenter >> hasKeyboardFocus [
self canTakeKeyboardFocus ifFalse: [ ^ false ].
self withAdapterDo: [ :anAdapter | ^ anAdapter hasKeyboardFocus ].
^ false
]
{ #category : #api }
SpPresenter >> hide [
visible := false
]
{ #category : #accessing }
SpPresenter >> iconNamed: aSymbol [
^ self class iconNamed: aSymbol
]
{ #category : #TOREMOVE }
SpPresenter >> initialExtent [
"DO NOT USE
With Spec 2, SpPresenter was refactored to move all window management to WindowPresenter.
From now on, if you want to interact with a window you need to:
- Implement #initializeWindow: method (#initializeDialog: for dialogs) to manage window elements before the presenter is opened
- Use the method #window or #withWindowDo: to interact with windows after it has been opened.
This method cannot be deprecated because during a transition phase we keep this mecanism. "
^ nil
]
{ #category : #initialization }
SpPresenter >> initialize [
super initialize.
visible := true.
self initializePrivateAnnouncer.
self initializePrivateValueHolders.
self initializePrivateHooks.
self initializePrivateAnnouncements
]
{ #category : #initialization }
SpPresenter >> initializePresenter [
"Now, presenters should implement #connectPresenters instead."
self
property: #extent
whenChangedDo: [ :ex |
self withAdapterDo: [ :widget |
(widget respondsTo: #extent:)
ifTrue: [ widget extent: ex ] ] ]
]
{ #category : #initialization }
SpPresenter >> initializePresenters [
"The method initializePresenters instantiates, saves in instance vari- ables, and partially configures the different widgets that will be part of the UI.
In general the initializePresenters method should follow the pattern:
• widget instantiation
• widget configuration specification
• specification of focus order"
"self subclassResponsibility"
]
{ #category : #'initialization - private' }
SpPresenter >> initializePrivateAnnouncements [
self property: #titleHolder whenChangedDo: [ self updateTitle ].
self property: #layout whenChangedDo: [ :newLayout | self replaceLayoutWith: newLayout ]
]
{ #category : #'initialization - private' }
SpPresenter >> initializePrivateAnnouncer [
announcer := Announcer new.
]
{ #category : #'initialization - private' }
SpPresenter >> initializePrivateHooks [
self flag: #todo. "We should remove later #initializeWidgets and #initializePresenter."
self initializeWidgets.
self initializePresenters.
self initializePresenter.
self connectPresenters.
self updatePresenter.
]
{ #category : #'initialization - private' }
SpPresenter >> initializePrivateValueHolders [
askOkToClose := false.
titleHolder := self class title
]
{ #category : #initialization }
SpPresenter >> initializeWidgets [
"Now, presenters should implement #initializePresenters instead."
]
{ #category : #initialization }
SpPresenter >> initializeWindow: aWindowPresenter [
"override this to set window values before opening.
You may want to add a menu, a toolbar or a statusbar"
"IMPORTANT: Please ovirride this method and set yourself the informations you want in your window.
The content of this method is here to help the transition between Spec 1 and 2.
In the next Spec version the content of this method will be removed and it will do nothing by default because the goal is to remove the management of all of those informations from Composable to put them in WindowPresenter."
aWindowPresenter
title: self title;
initialExtent: self initialExtent;
windowIcon: self windowIcon;
askOkToClose: self askOkToClose;
aboutText: self aboutText
]
{ #category : #'instance creation' }
SpPresenter >> instantiate: aPresenterClass [
"Instantiate a SpPresenter subclass and set its instance owner"
^ aPresenterClass owner: self
]
{ #category : #'instance creation' }
SpPresenter >> instantiate: aPresenterClass on: aModel [
"Instantiate a SpPresenter subclass and set its instance owner and model"
^ aPresenterClass owner: self on: aModel
]
{ #category : #'instance creation' }
SpPresenter >> instantiatePresenters: aCollectionOfPairs [
"instantiatePresenters: is legacy code in SpPresenter and must not be used. It will be deprecated and removed."
"Used to instantiate multiple sub widget at once. Take aCollectionOfPairs where each odd element is an inst var name and each even element is a class name, create an instance from the class name and store it into the inst var"
(aCollectionOfPairs anySatisfy: [ :e | e isKindOf: Association ])
ifTrue: [ aCollectionOfPairs
do: [ :a |
| k v |
k := a key.
v := a value.
self instVarNamed: k asString put: (self createInstanceFor: v) ] ]
ifFalse: [ aCollectionOfPairs
pairsDo: [ :k :v | self instVarNamed: k asString put: (self createInstanceFor: v) ] ]
]
{ #category : #testing }
SpPresenter >> isBuilt [
^ self isDisplayed
]
{ #category : #testing }
SpPresenter >> isDisplayed [
"Return true if the widget is currently displayed on screen"
self flag: #TODO. "To move to WindowPresenter exclusive?"
^ self hasWindow
ifTrue: [ self root isDisplayed ]
ifFalse: [ false ]
]
{ #category : #testing }
SpPresenter >> isRoot [
self withWindowDo: [ :w |
^ w presenter = self ].
^ false
]
{ #category : #testing }
SpPresenter >> isVisible [
^ visible value
]
{ #category : #accessing }
SpPresenter >> layout [
^ layout
]
{ #category : #api }
SpPresenter >> layout: aLayout [
layout := aLayout
]
{ #category : #private }
SpPresenter >> layoutPresenters [
layout ifNil: [ ^ self presenters ].
^ layout deepPresenters
select: [ :each | each isSymbol or: [ each isPresenter ] ]
thenCollect: [ :each |
each isPresenter
ifTrue: [ each ]
ifFalse:[ self presenterAt: each ] ]
]
{ #category : #accessing }
SpPresenter >> locale [
^ self application locale
]
{ #category : #localization }
SpPresenter >> localeChanged [
"do nothing here. Override me in subclasses to update strings presented to the users"
]
{ #category : #TOREMOVE }
SpPresenter >> neglectMenuModel: aMenuModel [
aMenuModel menuGroups do: [ :group |
group menuItems do: [ :item |
item shortcut ifNotNil: [ :shortcut | self removeKeyCombination: shortcut ].
item subMenu ifNotNil: [ :subMenu | subMenu neglect: self ] ] ]
]
{ #category : #widgets }
SpPresenter >> newActionBar [
^ self instantiate: SpActionBarPresenter
]
{ #category : #widgets }
SpPresenter >> newButton [
^ self instantiate: SpButtonPresenter
]
{ #category : #widgets }
SpPresenter >> newButtonBar [
^ self instantiate: SpButtonBarPresenter
]
{ #category : #widgets }
SpPresenter >> newCheckBox [
^ self instantiate: SpCheckBoxPresenter
]
{ #category : #widgets }
SpPresenter >> newComponentList [
^ self instantiate: SpComponentListPresenter
]
{ #category : #widgets }
SpPresenter >> newDiff [
^ self instantiate: SpDiffPresenter
]
{ #category : #widgets }
SpPresenter >> newDropList [
^ self instantiate: SpDropListPresenter
]
{ #category : #widgets }
SpPresenter >> newDynamicPresentersListIn: accessorSymbol usingBuilder: aDynamicPresentersListBuilder [
|mutatorSymbol newDynamicPresenter |
mutatorSymbol := (accessorSymbol , ':') asSymbol.
(self perform: accessorSymbol)
ifNotNil: [ :dynamicPresenter | dynamicPresenter owner: nil ].
newDynamicPresenter := aDynamicPresentersListBuilder build.
self perform: mutatorSymbol with: newDynamicPresenter.
newDynamicPresenter owner: self.
self needRebuild: false.
self buildWithSpec
]
{ #category : #widgets }
SpPresenter >> newLabel [
^ self instantiate: SpLabelPresenter
]
{ #category : #widgets }
SpPresenter >> newList [
^ self instantiate: SpListPresenter
]
{ #category : #widgets }
SpPresenter >> newMenu [
^ self instantiate: SpMenuPresenter
]
{ #category : #widgets }
SpPresenter >> newMenuBar [
^ self instantiate: SpMenuBarPresenter
]
{ #category : #widgets }
SpPresenter >> newMenuButton [
^ self instantiate: SpMenuButtonPresenter
]
{ #category : #widgets }
SpPresenter >> newNotebook [
^ self instantiate: SpNotebookPresenter
]
{ #category : #widgets }
SpPresenter >> newNotebookPage [
self flag: #TODO. "NotebookPage needs to be a Presenter?"
^ SpNotebookPage new
]
{ #category : #widgets }
SpPresenter >> newNullPresenter [
^ self instantiate: SpNullPresenter
]
{ #category : #widgets }
SpPresenter >> newNumberInput [
^ self instantiate: SpNumberInputFieldPresenter
]
{ #category : #widgets }
SpPresenter >> newPopover [
^ self instantiate: SpPopoverPresenter
]
{ #category : #widgets }
SpPresenter >> newPresenterSelector [
^ self instantiate: SpPresenterSelectorPresenter
]
{ #category : #widgets }
SpPresenter >> newProgressBar [
^ self instantiate: SpProgressBarPresenter
]
{ #category : #widgets }
SpPresenter >> newRadioButton [
^ self instantiate: SpRadioButtonPresenter
]
{ #category : #widgets }
SpPresenter >> newRichText [
^ self instantiate: SpRichTextPresenter
]
{ #category : #widgets }
SpPresenter >> newSearchInput [
^ self instantiate: SpSearchInputFieldPresenter
]
{ #category : #widgets }
SpPresenter >> newSlider [
^ self instantiate: SpSliderPresenter
]
{ #category : #widgets }
SpPresenter >> newStatusBar [
^ self instantiate: SpStatusBarPresenter
]
{ #category : #widgets }
SpPresenter >> newTable [
^ self instantiate: SpTablePresenter
]
{ #category : #widgets }
SpPresenter >> newText [
^ self instantiate: SpTextPresenter
]
{ #category : #widgets }
SpPresenter >> newTextInput [
^ self instantiate: SpTextInputFieldPresenter
]
{ #category : #widgets }
SpPresenter >> newToggleButton [
^ self instantiate: SpToggleButtonPresenter
]
{ #category : #widgets }
SpPresenter >> newToolbar [
^ self instantiate: SpToolbarPresenter
]
{ #category : #widgets }
SpPresenter >> newToolbarButton [
^ self instantiate: SpToolbarButtonPresenter
]
{ #category : #widgets }
SpPresenter >> newToolbarMenuButton [
^ self instantiate: SpToolbarToggleButtonPresenter
]
{ #category : #widgets }
SpPresenter >> newToolbarToggleButton [
^ self instantiate: SpToolbarToggleButtonPresenter
]
{ #category : #widgets }
SpPresenter >> newTreeTable [
^ self instantiate: SpTreeTablePresenter
]
{ #category : #private }
SpPresenter >> okToChange [
^ self hasWindow
ifTrue: [ self window okToChange ]
ifFalse: [ true ]
]
{ #category : #'api-announcements' }
SpPresenter >> on: anAnnouncement send: aSelector to: aTarget [
self announcer
when: anAnnouncement
send: aSelector
to: aTarget
]
{ #category : #accessing }
SpPresenter >> presenterAt: aName [
"Retrieves a subpresenter of this composed presenter."
^ self readSlotNamed: aName
]
{ #category : #accessing }
SpPresenter >> presenterAt: aName ifAbsent: aBlock [
"Retrieves a subpresenter of this composed presenter."
^ [ self readSlotNamed: aName ]
on: SlotNotFound
do: aBlock
]
{ #category : #'private-traversing' }
SpPresenter >> presenters [
| presenters |
presenters := OrderedCollection new.
self presentersDo: [ :each |
presenters add: each ].
^ presenters
]
{ #category : #'private-traversing' }
SpPresenter >> presentersDo: aBlock [
self class allSlots
reject: [ :each | each name = #owner ]
thenDo: [ :each | | var |
var := self readSlot: each.
(var isKindOf: SpAbstractPresenter) ifTrue: [
aBlock value: var ] ]
]
{ #category : #private }
SpPresenter >> presentersInFocusOrder [
^ focusOrder ifNil: [
self layoutPresenters
select: [ :each | each isVisible and: [ each canTakeKeyboardFocus ] ] ]
]
{ #category : #private }
SpPresenter >> rebuildLayout [
self replaceLayoutWith: self layout
]
{ #category : #'api-shortcuts' }
SpPresenter >> removeKeyCombination: aShortcut [
self contextKeyBindings removeKey: aShortcut ifAbsent: [ ^ self ].
self withAdapterDo: [ :anAdapter |
anAdapter removeKeyCombination: aShortcut ]
]
{ #category : #private }
SpPresenter >> replaceLayoutWith: aLayout [
self withAdapterDo: [ :anAdapter |
anAdapter replaceLayoutWith: aLayout ]