author | Stefan Vogel <sv@exept.de> |
Wed, 31 Mar 1999 08:07:57 +0200 | |
changeset 1298 | f5082846bc62 |
parent 298 | 88cb01678b87 |
child 3577 | cbc8df5a71c8 |
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 |
||
298 | 20 |
!LabelledEnterField class methodsFor:'documentation'! |
34 | 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:'. |
|
1298 | 73 |
f1 aspect:#firstName; change:#firstName:; model:model. |
56 | 74 |
panel add:f1. |
75 |
||
76 |
f2 := LabelledEnterField new. |
|
77 |
f2 label:'Middle Initial:'. |
|
1298 | 78 |
f2 aspect:#middleInitial; change:#middleInitial:; model:model. |
56 | 79 |
panel add:f2. |
80 |
||
81 |
f3 := LabelledEnterField new. |
|
82 |
f3 label:'Lastname:'. |
|
1298 | 83 |
f3 aspect:#lastName; change:#lastName:; model:model. |
56 | 84 |
panel add:f3. |
85 |
||
86 |
f4 := LabelledEnterField new. |
|
87 |
f4 label:'Telephone:'. |
|
1298 | 88 |
f4 aspect:#telNo; change:#telNo:; model:model. |
56 | 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 |
||
298 | 118 |
enabled |
119 |
"return true if enabled - forwarded to the inputField" |
|
120 |
||
121 |
^ textField enabled |
|
1298 | 122 |
! |
123 |
||
124 |
enabled:aBoolean |
|
125 |
"enable/disable - forwarded to the inputField" |
|
126 |
||
127 |
textField enabled:aBoolean |
|
128 |
||
129 |
"Created: / 30.3.1999 / 15:20:44 / stefan" |
|
100 | 130 |
! ! |
131 |
||
132 |
!LabelledEnterField methodsFor:'accessing-look'! |
|
133 |
||
134 |
contents |
|
135 |
^ textField contents |
|
136 |
! |
|
137 |
||
138 |
contents:aString |
|
139 |
textField contents:aString |
|
34 | 140 |
! |
141 |
||
100 | 142 |
editValue |
143 |
^ textField editValue |
|
144 |
! |
|
145 |
||
146 |
editValue:something |
|
147 |
textField editValue:something |
|
148 |
! |
|
149 |
||
150 |
label:aString |
|
151 |
labelField label:aString |
|
152 |
! ! |
|
153 |
||
154 |
!LabelledEnterField methodsFor:'accessing-mvc'! |
|
34 | 155 |
|
100 | 156 |
addModelInterfaceTo:aDictionary |
157 |
labelField addModelInterfaceTo:aDictionary. |
|
158 |
textField addModelInterfaceTo:aDictionary |
|
159 |
! |
|
160 |
||
161 |
aspectMessage:aspectSymbol |
|
162 |
textField aspectMessage:aspectSymbol. |
|
163 |
labelField aspectMessage:aspectSymbol |
|
164 |
! |
|
165 |
||
166 |
changeMessage:aSymbol |
|
167 |
textField changeMessage:aSymbol |
|
168 |
! |
|
169 |
||
170 |
labelMessage:aSymbol |
|
171 |
labelField labelMessage:aSymbol |
|
172 |
! |
|
173 |
||
174 |
model:aModel |
|
175 |
textField model:aModel. |
|
176 |
labelField model:aModel |
|
34 | 177 |
! ! |
178 |
||
12 | 179 |
!LabelledEnterField methodsFor:'initialization'! |
180 |
||
181 |
initialize |
|
182 |
"setup; create the label and an enterfield" |
|
183 |
||
184 |
super initialize. |
|
185 |
||
56 | 186 |
labelField := Label label:'l' in:self. |
187 |
textField := EditField in:self. |
|
188 |
||
189 |
labelField resize. |
|
12 | 190 |
labelField level:0. |
56 | 191 |
labelField origin:(margin @ (margin + textField margin)). |
46 | 192 |
|
12 | 193 |
textField origin:[(labelField origin x + labelField width) @ level] |
34 | 194 |
extent:[(self width |
195 |
- margin - margin |
|
196 |
- labelField width) @ (textField heightIncludingBorder)]. |
|
12 | 197 |
|
46 | 198 |
" |
199 |
forward keyboard input to the enterField |
|
200 |
" |
|
53 | 201 |
self delegate:(KeyboardForwarder from:self toView:textField) |
46 | 202 |
|
203 |
" |
|
204 |
LabelledEnterField new realize |
|
205 |
" |
|
12 | 206 |
! ! |
207 |
||
56 | 208 |
!LabelledEnterField methodsFor:'queries'! |
209 |
||
62 | 210 |
preferredExtent |
153 | 211 |
"return the preferredExtent from the components sizes." |
212 |
||
56 | 213 |
|p lx ly ix iy| |
214 |
||
223 | 215 |
"/ If I have an explicit preferredExtent .. |
216 |
||
193
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
217 |
preferredExtent notNil ifTrue:[ |
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
218 |
^ preferredExtent |
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
219 |
]. |
2fc0b374fdc6
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
159
diff
changeset
|
220 |
|
62 | 221 |
p := labelField preferredExtent. |
56 | 222 |
lx := p x. ly := p y. |
62 | 223 |
p := textField preferredExtent. |
56 | 224 |
ix := p x. iy := p y. |
225 |
^ (lx + ix) @ (ly max:iy) |
|
153 | 226 |
|
223 | 227 |
"Modified: 19.7.1996 / 20:44:46 / cg" |
56 | 228 |
! ! |
229 |
||
298 | 230 |
!LabelledEnterField class methodsFor:'documentation'! |
24 | 231 |
|
100 | 232 |
version |
1298 | 233 |
^ '$Header: /cvs/stx/stx/libwidg2/LabelledEnterField.st,v 1.22 1999-03-31 06:07:57 stefan Exp $' |
56 | 234 |
! ! |