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 |
|
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.
|
|
43 |
"
|
|
44 |
!
|
|
45 |
|
|
46 |
examples
|
|
47 |
"
|
|
48 |
|top panel f1 f2 f3 f4 model data|
|
|
49 |
|
|
50 |
data := #('John' 'F' 'Smith' '1234567').
|
|
51 |
model := Plug new.
|
|
52 |
model respondTo:#firstName with:[data at:1].
|
|
53 |
model respondTo:#firstName: with:[:arg | data at:1 put:arg].
|
|
54 |
model respondTo:#middleInitial with:[data at:2].
|
|
55 |
model respondTo:#middleInitial: with:[:arg | data at:2 put:arg].
|
|
56 |
model respondTo:#lastName with:[data at:3].
|
|
57 |
model respondTo:#lastName: with:[:arg | data at:3 put:arg].
|
|
58 |
model respondTo:#telNo with:[data at:4].
|
|
59 |
model respondTo:#telNo: with:[:arg | data at:4 put:arg].
|
34
|
60 |
|
56
|
61 |
top := StandardSystemView new.
|
|
62 |
top extent:300@300.
|
|
63 |
|
|
64 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
65 |
panel verticalLayout:#topSpace.
|
|
66 |
|
|
67 |
f1 := LabelledEnterField new.
|
|
68 |
f1 label:'Firstname:'.
|
|
69 |
f1 model:model; aspect:#firstName; change:#firstName:.
|
|
70 |
panel add:f1.
|
|
71 |
|
|
72 |
f2 := LabelledEnterField new.
|
|
73 |
f2 label:'Middle Initial:'.
|
|
74 |
f2 model:model; aspect:#middleInitial; change:#middleInitial:.
|
|
75 |
panel add:f2.
|
|
76 |
|
|
77 |
f3 := LabelledEnterField new.
|
|
78 |
f3 label:'Lastname:'.
|
|
79 |
f3 model:model; aspect:#lastName; change:#lastName:.
|
|
80 |
panel add:f3.
|
|
81 |
|
|
82 |
f4 := LabelledEnterField new.
|
|
83 |
f4 label:'Telephone:'.
|
|
84 |
f4 model:model; aspect:#telNo; change:#telNo:.
|
|
85 |
panel add:f4.
|
|
86 |
|
|
87 |
top open
|
34
|
88 |
"
|
100
|
89 |
! !
|
|
90 |
|
|
91 |
!LabelledEnterField methodsFor:'accessing'!
|
|
92 |
|
|
93 |
inputField
|
|
94 |
"return the input field component"
|
|
95 |
|
|
96 |
^ textField
|
34
|
97 |
!
|
|
98 |
|
100
|
99 |
labelView
|
|
100 |
"return the label component"
|
|
101 |
|
|
102 |
^ labelField
|
|
103 |
! !
|
|
104 |
|
|
105 |
!LabelledEnterField methodsFor:'accessing-behavior'!
|
|
106 |
|
|
107 |
disable
|
|
108 |
textField disable
|
|
109 |
!
|
|
110 |
|
|
111 |
enable
|
|
112 |
textField enable
|
|
113 |
! !
|
|
114 |
|
|
115 |
!LabelledEnterField methodsFor:'accessing-look'!
|
|
116 |
|
|
117 |
contents
|
|
118 |
^ textField contents
|
|
119 |
!
|
|
120 |
|
|
121 |
contents:aString
|
|
122 |
textField contents:aString
|
34
|
123 |
!
|
|
124 |
|
100
|
125 |
editValue
|
|
126 |
^ textField editValue
|
|
127 |
!
|
|
128 |
|
|
129 |
editValue:something
|
|
130 |
textField editValue:something
|
|
131 |
!
|
|
132 |
|
|
133 |
label:aString
|
|
134 |
labelField label:aString
|
|
135 |
! !
|
|
136 |
|
|
137 |
!LabelledEnterField methodsFor:'accessing-mvc'!
|
34
|
138 |
|
100
|
139 |
addModelInterfaceTo:aDictionary
|
|
140 |
labelField addModelInterfaceTo:aDictionary.
|
|
141 |
textField addModelInterfaceTo:aDictionary
|
|
142 |
!
|
|
143 |
|
|
144 |
aspectMessage:aspectSymbol
|
|
145 |
textField aspectMessage:aspectSymbol.
|
|
146 |
labelField aspectMessage:aspectSymbol
|
|
147 |
!
|
|
148 |
|
|
149 |
changeMessage:aSymbol
|
|
150 |
textField changeMessage:aSymbol
|
|
151 |
!
|
|
152 |
|
|
153 |
labelMessage:aSymbol
|
|
154 |
labelField labelMessage:aSymbol
|
|
155 |
!
|
|
156 |
|
|
157 |
model:aModel
|
|
158 |
textField model:aModel.
|
|
159 |
labelField model:aModel
|
34
|
160 |
! !
|
|
161 |
|
12
|
162 |
!LabelledEnterField methodsFor:'initialization'!
|
|
163 |
|
|
164 |
initialize
|
|
165 |
"setup; create the label and an enterfield"
|
|
166 |
|
|
167 |
super initialize.
|
|
168 |
|
56
|
169 |
labelField := Label label:'l' in:self.
|
|
170 |
textField := EditField in:self.
|
|
171 |
|
|
172 |
labelField resize.
|
12
|
173 |
labelField level:0.
|
56
|
174 |
labelField origin:(margin @ (margin + textField margin)).
|
46
|
175 |
|
12
|
176 |
textField origin:[(labelField origin x + labelField width) @ level]
|
34
|
177 |
extent:[(self width
|
|
178 |
- margin - margin
|
|
179 |
- labelField width) @ (textField heightIncludingBorder)].
|
12
|
180 |
|
46
|
181 |
"
|
|
182 |
forward keyboard input to the enterField
|
|
183 |
"
|
53
|
184 |
self delegate:(KeyboardForwarder from:self toView:textField)
|
46
|
185 |
|
|
186 |
"
|
|
187 |
LabelledEnterField new realize
|
|
188 |
"
|
12
|
189 |
! !
|
|
190 |
|
56
|
191 |
!LabelledEnterField methodsFor:'queries'!
|
|
192 |
|
62
|
193 |
preferredExtent
|
56
|
194 |
|p lx ly ix iy|
|
|
195 |
|
62
|
196 |
p := labelField preferredExtent.
|
56
|
197 |
lx := p x. ly := p y.
|
62
|
198 |
p := textField preferredExtent.
|
56
|
199 |
ix := p x. iy := p y.
|
|
200 |
^ (lx + ix) @ (ly max:iy)
|
|
201 |
! !
|
|
202 |
|
100
|
203 |
!LabelledEnterField class methodsFor:'documentation'!
|
24
|
204 |
|
100
|
205 |
version
|
|
206 |
^ '$Header: /cvs/stx/stx/libwidg2/LabelledEnterField.st,v 1.12 1995-11-23 18:18:39 cg Exp $'
|
56
|
207 |
! !
|