forked from pharo-project/pharo
/
SpMorphicLayoutAdapter.class.st
119 lines (91 loc) · 2.66 KB
/
SpMorphicLayoutAdapter.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
"
I'm a base adapter for layouts.
"
Class {
#name : #SpMorphicLayoutAdapter,
#superclass : #SpAbstractMorphicAdapter,
#category : #'Spec2-Adapters-Morphic-Layout'
}
{ #category : #'as yet unclassified' }
SpMorphicLayoutAdapter >> adapter [
^ nil
]
{ #category : #factory }
SpMorphicLayoutAdapter >> add: aPresenter constraints: constraints [
self widgetDo: [ :aPanel |
self
basicAdd: aPresenter
constraints: constraints
to: aPanel ]
]
{ #category : #adding }
SpMorphicLayoutAdapter >> addConstraits: constraints toChild: childMorph [
self subclassResponsibility
]
{ #category : #initialization }
SpMorphicLayoutAdapter >> addKeyBindingsTo: aMorph [
"This is called before the layout actually exists.
Skipping it."
]
{ #category : #initialization }
SpMorphicLayoutAdapter >> applyStyle: aMorph [
"layouts do not have style to apply"
]
{ #category : #factory }
SpMorphicLayoutAdapter >> applyStyle: aPresenter to: aMorph [
self flag: #TODO. "This is a HACK, to apply styles just when I'm using new layouts
(otherwise, it interferes on how the old layout is displayed).
Of course, this needs to be applied where it belongs, but for now we need to keep
it this way :("
aPresenter adapter ifNil: [ ^ self ].
aPresenter adapter applyStyle: aMorph
]
{ #category : #private }
SpMorphicLayoutAdapter >> basicAdd: aPresenter constraints: constraints to: aPanel [
self subclassResponsibility
]
{ #category : #private }
SpMorphicLayoutAdapter >> buildMorph: aPresenter constraints: constraints [
| childMorph |
childMorph := aPresenter buildWithSpec: constraints spec.
self applyStyle: aPresenter to: childMorph.
childMorph := self addConstraits: constraints toChild: childMorph.
^ childMorph
]
{ #category : #factory }
SpMorphicLayoutAdapter >> buildWidget [
^ nil
]
{ #category : #factory }
SpMorphicLayoutAdapter >> buildWithSpec [
^ self widget
]
{ #category : #factory }
SpMorphicLayoutAdapter >> buildWithSpec: aString [
^ self buildWithSpec
]
{ #category : #'as yet unclassified' }
SpMorphicLayoutAdapter >> layout: aLayout [
"Basic apply visibility to the widget.
This call is here because layouts and widgets work differently"
self applyVisibility
]
{ #category : #factory }
SpMorphicLayoutAdapter >> newPanel [
^ Morph new
changeTableLayout;
hResizing: #spaceFill;
vResizing: #spaceFill;
color: Color transparent;
borderColor: Color transparent;
clipSubmorphs: true;
beSticky "stop being grabbed";
borderWidth: 0;
extent: 0@0;
yourself
]
{ #category : #protocol }
SpMorphicLayoutAdapter >> takeKeyboardFocus [
self presenter presentersInFocusOrder
ifNotEmpty: [ :presenters | presenters first takeKeyboardFocus ]
]