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