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