124
|
1 |
View subclass:#ComboBoxView
|
|
2 |
instanceVariableNames:'enterField pullDownButton list'
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Views-Interactors'
|
|
6 |
!
|
|
7 |
|
|
8 |
!ComboBoxView class methodsFor:'documentation'!
|
|
9 |
|
|
10 |
documentation
|
|
11 |
"
|
|
12 |
a first attempt in a comboBox implementation.
|
|
13 |
Not yet finished.
|
|
14 |
"
|
|
15 |
!
|
|
16 |
|
|
17 |
examples
|
|
18 |
"
|
|
19 |
|top b|
|
|
20 |
|
|
21 |
top := StandardSystemView new.
|
|
22 |
top extent:(300 @ 200).
|
|
23 |
|
|
24 |
b := ComboBoxView in:top.
|
|
25 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
|
|
26 |
b bottomInset:(b preferredExtent y negated).
|
|
27 |
|
|
28 |
b list:#('hello' 'world' 'this' 'is' 'st/x').
|
|
29 |
top open.
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
model operation:
|
|
34 |
|
|
35 |
|model top b|
|
|
36 |
|
|
37 |
model := 'foo' asValue.
|
|
38 |
|
|
39 |
top := StandardSystemView new.
|
|
40 |
top extent:(300 @ 200).
|
|
41 |
|
|
42 |
b := ComboBoxView in:top.
|
|
43 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
|
|
44 |
b bottomInset:(b preferredExtent y negated).
|
|
45 |
|
|
46 |
b list:#('hello' 'world' 'this' 'is' 'st/x').
|
|
47 |
b model:model.
|
|
48 |
|
|
49 |
top openModal.
|
|
50 |
model inspect.
|
|
51 |
|
|
52 |
"
|
|
53 |
! !
|
|
54 |
|
|
55 |
!ComboBoxView class methodsFor:'defaults'!
|
|
56 |
|
|
57 |
buttonForm
|
|
58 |
|form|
|
|
59 |
|
|
60 |
form := Form fromFile:'ComboDn_win.xbm'.
|
|
61 |
^ form on:Display
|
|
62 |
! !
|
|
63 |
|
|
64 |
!ComboBoxView methodsFor:'accessing-contents'!
|
|
65 |
|
|
66 |
list:aList
|
|
67 |
list := aList
|
|
68 |
|
|
69 |
"Created: 9.2.1996 / 00:51:25 / cg"
|
|
70 |
"Modified: 9.2.1996 / 00:51:56 / cg"
|
|
71 |
! !
|
|
72 |
|
|
73 |
!ComboBoxView methodsFor:'accessing-mvc'!
|
|
74 |
|
|
75 |
action:aBlock
|
|
76 |
enterField action:aBlock
|
|
77 |
|
|
78 |
"Created: 9.2.1996 / 01:44:20 / cg"
|
|
79 |
!
|
|
80 |
|
|
81 |
model
|
|
82 |
^ enterField model
|
|
83 |
|
|
84 |
"Created: 9.2.1996 / 00:50:18 / cg"
|
|
85 |
!
|
|
86 |
|
|
87 |
model:aModel
|
|
88 |
enterField model:aModel.
|
|
89 |
|
|
90 |
"Created: 9.2.1996 / 00:50:12 / cg"
|
|
91 |
! !
|
|
92 |
|
|
93 |
!ComboBoxView methodsFor:'initialization'!
|
|
94 |
|
|
95 |
initialize
|
|
96 |
|ext|
|
|
97 |
|
|
98 |
super initialize.
|
|
99 |
|
|
100 |
"/ borderWidth := 0.
|
|
101 |
|
|
102 |
enterField := EditField in:self.
|
|
103 |
enterField origin:0.0@0.0 corner:1.0@1.0.
|
|
104 |
|
|
105 |
enterField model:('' asValue).
|
|
106 |
|
|
107 |
pullDownButton := Toggle in:self.
|
|
108 |
pullDownButton label:(self class buttonForm).
|
125
|
109 |
pullDownButton showLamp:false.
|
124
|
110 |
ext := pullDownButton preferredExtent.
|
|
111 |
pullDownButton origin:1.0@0.0 corner:1.0@1.0.
|
|
112 |
pullDownButton leftInset:(ext x negated).
|
|
113 |
|
|
114 |
enterField rightInset:(ext x).
|
|
115 |
|
|
116 |
pullDownButton pressAction:[self pullMenu].
|
|
117 |
pullDownButton releaseAction:[self hideMenu].
|
|
118 |
|
|
119 |
self height:enterField preferredExtent y + ViewSpacing.
|
|
120 |
|
|
121 |
"
|
|
122 |
all of my input goes to the enterfield
|
|
123 |
"
|
|
124 |
self delegate:(KeyboardForwarder toView:enterField).
|
|
125 |
|
|
126 |
"
|
|
127 |
|b|
|
|
128 |
|
|
129 |
b := ComboBoxView new.
|
|
130 |
b list:#('hello' 'world' 'this' 'is' 'st/x').
|
|
131 |
b open
|
|
132 |
"
|
|
133 |
|
|
134 |
"Created: 9.2.1996 / 00:05:24 / cg"
|
|
135 |
"Modified: 9.2.1996 / 01:07:10 / cg"
|
|
136 |
! !
|
|
137 |
|
|
138 |
!ComboBoxView methodsFor:'queries'!
|
|
139 |
|
|
140 |
preferredExtent
|
|
141 |
|pref1 pref2|
|
|
142 |
|
|
143 |
pref1 := enterField preferredExtent.
|
|
144 |
pref2 := pullDownButton preferredExtent.
|
|
145 |
^ (pref1 x + pref2 x) @ (pref1 y max:pref2 y)
|
|
146 |
|
|
147 |
"Created: 9.2.1996 / 01:08:47 / cg"
|
|
148 |
! !
|
|
149 |
|
|
150 |
!ComboBoxView methodsFor:'user interaction'!
|
|
151 |
|
|
152 |
entryChanged:what
|
|
153 |
enterField contents:what.
|
|
154 |
enterField accept.
|
|
155 |
pullDownButton turnOff.
|
|
156 |
|
|
157 |
"Created: 9.2.1996 / 01:06:01 / cg"
|
|
158 |
"Modified: 9.2.1996 / 01:42:38 / cg"
|
|
159 |
!
|
|
160 |
|
|
161 |
pullMenu
|
|
162 |
|m org|
|
|
163 |
|
|
164 |
m := PopUpMenu
|
|
165 |
labels:list
|
|
166 |
selectors:#entryChanged:
|
|
167 |
args:list
|
|
168 |
receiver:self.
|
|
169 |
|
|
170 |
m menuView resize.
|
|
171 |
m menuView width:(self width).
|
|
172 |
m menuView sizeFixed:true.
|
|
173 |
m hideOnRelease:false.
|
|
174 |
|
|
175 |
org := device translatePoint:(0 @ self height)
|
|
176 |
from:(self id)
|
|
177 |
to:(device rootView id).
|
|
178 |
|
|
179 |
m showAt:org.
|
|
180 |
pullDownButton turnOff.
|
|
181 |
|
|
182 |
"Created: 9.2.1996 / 00:36:49 / cg"
|
|
183 |
"Modified: 9.2.1996 / 02:02:54 / cg"
|
|
184 |
! !
|
|
185 |
|
|
186 |
!ComboBoxView class methodsFor:'documentation'!
|
|
187 |
|
|
188 |
version
|
125
|
189 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboBoxView.st,v 1.2 1996-02-09 01:42:03 cg Exp $'
|
124
|
190 |
! !
|