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