author | Claus Gittinger <cg@exept.de> |
Fri, 15 Jun 2018 10:54:35 +0200 | |
changeset 5816 | 7876c07931a7 |
parent 3577 | cbc8df5a71c8 |
child 5956 | 3bc79ed6a335 |
permissions | -rw-r--r-- |
12 | 1 |
" |
2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
34 | 3 |
All Rights Reserved |
12 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
3577
cbc8df5a71c8
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
1298
diff
changeset
|
12 |
"{ Package: 'stx:libwidg2' }" |
12 | 13 |
|
56 | 14 |
View subclass:#LabelledEnterField |
153 | 15 |
instanceVariableNames:'labelField textField' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Interactors' |
|
12 | 19 |
! |
20 |
||
298 | 21 |
!LabelledEnterField class methodsFor:'documentation'! |
34 | 22 |
|
100 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
34 | 37 |
documentation |
38 |
" |
|
56 | 39 |
An EnterField with a name. Its protocol mimics that of an |
40 |
inputfield for the most common cases. However, for access to |
|
41 |
some specific things, you have to get the components |
|
42 |
(labelField and inputField) |
|
43 |
and send those message directly. |
|
156 | 44 |
|
45 |
[author:] |
|
46 |
Claus Gittinger |
|
56 | 47 |
" |
48 |
! |
|
49 |
||
50 |
examples |
|
51 |
" |
|
159 | 52 |
[exBegin] |
56 | 53 |
|top panel f1 f2 f3 f4 model data| |
54 |
||
55 |
data := #('John' 'F' 'Smith' '1234567'). |
|
56 |
model := Plug new. |
|
57 |
model respondTo:#firstName with:[data at:1]. |
|
58 |
model respondTo:#firstName: with:[:arg | data at:1 put:arg]. |
|
59 |
model respondTo:#middleInitial with:[data at:2]. |
|
60 |
model respondTo:#middleInitial: with:[:arg | data at:2 put:arg]. |
|
61 |
model respondTo:#lastName with:[data at:3]. |
|
62 |
model respondTo:#lastName: with:[:arg | data at:3 put:arg]. |
|
63 |
model respondTo:#telNo with:[data at:4]. |
|
64 |
model respondTo:#telNo: with:[:arg | data at:4 put:arg]. |
|
34 | 65 |
|
56 | 66 |
top := StandardSystemView new. |
67 |
top extent:300@300. |
|
68 |
||
69 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
70 |
panel verticalLayout:#topSpace. |
|
71 |
||
72 |
f1 := LabelledEnterField new. |
|
73 |
f1 label:'Firstname:'. |
|
1298 | 74 |
f1 aspect:#firstName; change:#firstName:; model:model. |
56 | 75 |
panel add:f1. |
76 |
||
77 |
f2 := LabelledEnterField new. |
|
78 |
f2 label:'Middle Initial:'. |
|
1298 | 79 |
f2 aspect:#middleInitial; change:#middleInitial:; model:model. |
56 | 80 |
panel add:f2. |
81 |
||
82 |
f3 := LabelledEnterField new. |
|
83 |
f3 label:'Lastname:'. |
|
1298 | 84 |
f3 aspect:#lastName; change:#lastName:; model:model. |
56 | 85 |
panel add:f3. |
86 |
||
87 |
f4 := LabelledEnterField new. |
|
88 |
f4 label:'Telephone:'. |
|
1298 | 89 |
f4 aspect:#telNo; change:#telNo:; model:model. |
56 | 90 |
panel add:f4. |
91 |
||
92 |
top open |
|
159 | 93 |
[exEnd] |
34 | 94 |
" |
100 | 95 |
! ! |
96 |
||
97 |
!LabelledEnterField methodsFor:'accessing'! |
|
98 |
||
99 |
inputField |
|
100 |
"return the input field component" |
|
101 |
||
102 |
^ textField |
|
34 | 103 |
! |
104 |
||
100 | 105 |
labelView |
106 |
"return the label component" |
|
107 |
||
108 |
^ labelField |
|
109 |
! ! |
|
110 |
||
111 |
!LabelledEnterField methodsFor:'accessing-behavior'! |
|
112 |
||
107 | 113 |
acceptOnLeave:aBoolean |
114 |
"set/clear the acceptOnLeave flag in my inputField. The default is false." |
|
115 |
||
116 |
textField acceptOnLeave: aBoolean. |
|
117 |
! |
|
118 |
||
298 | 119 |
enabled |
120 |
"return true if enabled - forwarded to the inputField" |
|
121 |
||
122 |
^ textField enabled |
|
1298 | 123 |
! |
124 |
||
125 |
enabled:aBoolean |
|
126 |
"enable/disable - forwarded to the inputField" |
|
127 |
||
128 |
textField enabled:aBoolean |
|
129 |
||
130 |
"Created: / 30.3.1999 / 15:20:44 / stefan" |
|
100 | 131 |
! ! |
132 |
||
133 |
!LabelledEnterField methodsFor:'accessing-look'! |
|
134 |
||
135 |
contents |
|
136 |
^ textField contents |
|
137 |
! |
|
138 |
||
139 |
contents:aString |
|
140 |
textField contents:aString |
|
34 | 141 |
! |
142 |
||
100 | 143 |
editValue |
144 |
^ textField editValue |
|
145 |
! |
|
146 |
||
147 |
editValue:something |
|
148 |
textField editValue:something |
|
149 |
! |
|
150 |
||
151 |
label:aString |
|
152 |
labelField label:aString |
|
153 |
! ! |
|
154 |
||
155 |
!LabelledEnterField methodsFor:'accessing-mvc'! |
|
34 | 156 |
|
100 | 157 |
addModelInterfaceTo:aDictionary |
158 |
labelField addModelInterfaceTo:aDictionary. |
|
159 |
textField addModelInterfaceTo:aDictionary |
|
160 |
! |
|
161 |
||
162 |
aspectMessage:aspectSymbol |
|
163 |
textField aspectMessage:aspectSymbol. |
|
164 |
labelField aspectMessage:aspectSymbol |
|
165 |
! |
|
166 |
||
167 |
changeMessage:aSymbol |
|
168 |
textField changeMessage:aSymbol |
|
169 |
! |
|
170 |
||
171 |
labelMessage:aSymbol |
|
172 |
labelField labelMessage:aSymbol |
|
173 |
! |
|
174 |
||
175 |
model:aModel |
|
176 |
textField model:aModel. |
|
177 |
labelField model:aModel |
|
34 | 178 |
! ! |
179 |
||
12 | 180 |
!LabelledEnterField methodsFor:'initialization'! |
181 |
||
182 |
initialize |
|
183 |
"setup; create the label and an enterfield" |
|
184 |
||
185 |
super initialize. |
|
186 |
||
56 | 187 |
labelField := Label label:'l' in:self. |
188 |
textField := EditField in:self. |
|
189 |
||
190 |
labelField resize. |
|
12 | 191 |
labelField level:0. |
56 | 192 |
labelField origin:(margin @ (margin + textField margin)). |
46 | 193 |
|
12 | 194 |
textField origin:[(labelField origin x + labelField width) @ level] |
34 | 195 |
extent:[(self width |
196 |
- margin - margin |
|
197 |
- labelField width) @ (textField heightIncludingBorder)]. |
|
12 | 198 |
|
46 | 199 |
" |
200 |
forward keyboard input to the enterField |
|
201 |
" |
|
53 | 202 |
self delegate:(KeyboardForwarder from:self toView:textField) |
46 | 203 |
|
204 |
" |
|
205 |
LabelledEnterField new realize |
|
206 |
" |
|
12 | 207 |
! ! |
208 |
||
56 | 209 |
!LabelledEnterField methodsFor:'queries'! |
210 |
||
62 | 211 |
preferredExtent |
153 | 212 |
"return the preferredExtent from the components sizes." |
213 |
||
56 | 214 |
|p lx ly ix iy| |
215 |
||
3577
cbc8df5a71c8
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
1298
diff
changeset
|
216 |
"/ If I have an explicit preferredExtent.. |
cbc8df5a71c8
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
1298
diff
changeset
|
217 |
explicitExtent notNil ifTrue:[ |
cbc8df5a71c8
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
1298
diff
changeset
|
218 |
^ explicitExtent |
cbc8df5a71c8
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
1298
diff
changeset
|
219 |
]. |
223 | 220 |
|
3577
cbc8df5a71c8
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
1298
diff
changeset
|
221 |
"/ If I have a cached preferredExtent value.. |
193
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
222 |
preferredExtent notNil ifTrue:[ |
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
223 |
^ preferredExtent |
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
224 |
]. |
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
225 |
|
62 | 226 |
p := labelField preferredExtent. |
56 | 227 |
lx := p x. ly := p y. |
62 | 228 |
p := textField preferredExtent. |
56 | 229 |
ix := p x. iy := p y. |
230 |
^ (lx + ix) @ (ly max:iy) |
|
153 | 231 |
|
223 | 232 |
"Modified: 19.7.1996 / 20:44:46 / cg" |
56 | 233 |
! ! |
234 |
||
298 | 235 |
!LabelledEnterField class methodsFor:'documentation'! |
24 | 236 |
|
100 | 237 |
version |
3577
cbc8df5a71c8
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
1298
diff
changeset
|
238 |
^ '$Header: /cvs/stx/stx/libwidg2/LabelledEnterField.st,v 1.23 2008-10-26 20:13:28 stefan Exp $' |
56 | 239 |
! ! |