-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathSpOpenOnStringExample.class.st
123 lines (105 loc) · 2.63 KB
/
SpOpenOnStringExample.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
"
I am the component of DynamycSpecExample used for String.
self example
I show also how to dynamically redrawn a widget.
"
Class {
#name : 'SpOpenOnStringExample',
#superclass : 'SpPresenter',
#instVars : [
'label',
'check',
'input',
'button',
'textToReset'
],
#category : 'Spec2-Examples-Wrapper',
#package : 'Spec2-Examples',
#tag : 'Wrapper'
}
{ #category : 'examples' }
SpOpenOnStringExample class >> example [
<sampleInstance>
^ (self new: 'Hello world')
extent: 300 @ 200;
open;
yourself
]
{ #category : 'instantiation' }
SpOpenOnStringExample class >> new: aString [
^ self new initialize: aString
]
{ #category : 'accessing' }
SpOpenOnStringExample >> button [
^ button
]
{ #category : 'accessing' }
SpOpenOnStringExample >> check [
^ check
]
{ #category : 'initialization' }
SpOpenOnStringExample >> connectPresenters [
button action: [ input text: textToReset ].
input whenTextChangedDo: [ :text | label label: text ].
check
whenActivatedDo: [ self needRebuild: false.
self buildWithSpecLayout: self class defaultLayout ];
whenDeactivatedDo: [ self needRebuild: false.
self buildWithSpecLayout: self class bottomLayout ]
]
{ #category : 'layout' }
SpOpenOnStringExample >> defaultLayout [
^ SpBoxLayout newTopToBottom
add: (SpBoxLayout newLeftToRight
add: label;
add: check withConstraints: [ :constraints | constraints width: 100 ];
yourself)
withConstraints: [ :constraints | constraints height: 25 ];
add: (SpBoxLayout newLeftToRight
add: input;
add: button;
yourself)
withConstraints: [ :constraints | constraints height: 25 ];
yourself
]
{ #category : 'initialization' }
SpOpenOnStringExample >> initialize: aString [
label label: aString.
input text: aString.
textToReset := aString
]
{ #category : 'initialization' }
SpOpenOnStringExample >> initializePresenters [
label := self instantiate: SpLabelPresenter.
check := self instantiate: SpCheckBoxPresenter.
input := self instantiate: SpTextInputFieldPresenter.
button := self instantiate: SpButtonPresenter.
button
label: 'reset';
action: [ input text: textToReset ].
check
label: 'Label on top';
state: false
]
{ #category : 'accessing' }
SpOpenOnStringExample >> input [
^ input
]
{ #category : 'accessing' }
SpOpenOnStringExample >> label [
^ label
]
{ #category : 'initialization' }
SpOpenOnStringExample >> openOnString [
| ui temp object |
object whenChangedDo: [ :o | ui label label: o asString ].
temp := object value.
]
{ #category : 'accessing' }
SpOpenOnStringExample >> textToReset [
^ textToReset
]
{ #category : 'accessing' }
SpOpenOnStringExample >> windowTitle [
^ 'OpenOnStringExample'
]