author | Claus Gittinger <cg@exept.de> |
Fri, 08 Mar 1996 11:53:23 +0100 | |
changeset 496 | f22ac16a5093 |
parent 485 | 50cbbe748ac9 |
child 585 | 8f395aba0173 |
permissions | -rw-r--r-- |
295 | 1 |
" |
2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
||
13 |
SimpleView subclass:#VariablePanel |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
14 |
instanceVariableNames:'barHeight barWidth separatingLine shadowForm lightForm showHandle |
295 | 15 |
handlePosition handleColor handleStyle handleLevel noColor |
16 |
trackLine redrawLocked orientation' |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
17 |
classVariableNames:'DefaultShowHandle DefaultHandleStyle DefaultHandlePosition |
295 | 18 |
DefaultTrackingLine DefaultSeparatingLine DefaultHandleColor |
19 |
DefaultHandleLevel DefaultVCursor DefaultHCursor' |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
20 |
poolDictionaries:'' |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
21 |
category:'Views-Layout' |
295 | 22 |
! |
23 |
||
24 |
!VariablePanel class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
a View to separate its subviews vertically by a movable bar; |
|
43 |
the size-ratios of the subviews can be changed by moving this bar. |
|
44 |
||
45 |
In order to correctly setup this kind of view, the subviews must |
|
46 |
be created with a relative origin & relative corner. |
|
47 |
The panel does not verify the relative subview bounds; |
|
48 |
therefore, it is your responsibility to set those relative sizes to fit |
|
49 |
according the orientation (see bad example below). |
|
50 |
||
51 |
The bar-handle is either an exposed knob (style == #motif) |
|
52 |
or the form defined in Scroller (style ~~ #motif) |
|
53 |
or nothing. |
|
54 |
||
55 |
Typically creation is done as: |
|
56 |
||
496 | 57 |
p := VariablePanel in:superView. |
58 |
p orientation:#vertical. |
|
295 | 59 |
|
496 | 60 |
v1 := <someViewClass> origin:0.0 @ 0.0 |
61 |
corner:1.0 @ 0.5 |
|
62 |
in:p. |
|
63 |
v2 := <someViewClass> origin:0.0 @ 0.5 |
|
64 |
corner:1.0 @ 0.8 |
|
65 |
in:p. |
|
66 |
v3 := <someViewClass> origin:0.0 @ 0.8 |
|
67 |
corner:1.0 @ 1.0 |
|
68 |
in:p. |
|
69 |
||
70 |
The two subclasses VariableHorizontalPanel and VariableVerticalPanel |
|
71 |
preset the orientation. They are a kept for backward compatibility |
|
72 |
(in previous versions, there used to be no common VariablePanel (super-) class). |
|
295 | 73 |
|
74 |
Notice: if it is required to insert a fixed-size view in the panel, |
|
75 |
use an extra view & insets, and place the subview into that extra view. |
|
76 |
||
77 |
see examples. |
|
496 | 78 |
|
79 |
||
80 |
||
81 |
instanceVariables: |
|
82 |
||
83 |
barHeight <Integer> the height of the bar (for verticalPanels) |
|
84 |
barWidth <Integer> the width of the bar (for horizontalPanels) |
|
85 |
||
86 |
separatingLine <Boolean> show a separating line (as in motif style) |
|
87 |
||
88 |
shadowForm <Image/Form> form (shadow part) drawn as handle - if nonNil |
|
89 |
||
90 |
lightForm <Image/Form> form (light part) drawn as handle - if nonNil |
|
91 |
||
92 |
showHandle <Boolean> if false, no handle is drawn |
|
93 |
||
94 |
handlePosition <Symbol> where is the handle - one of #left, #center, #right |
|
95 |
||
96 |
handleColor <Color> inside color of handle - defaults to viewBackground |
|
97 |
||
98 |
handleStyle <Symbol> type of handle; one of #next, #motif or nil |
|
99 |
||
100 |
handleLevel <Integer> 3D level of handle (only valid if no form is given) |
|
101 |
||
102 |
trackLine <Boolean> if true, an inverted line is drawn for tracking; |
|
103 |
otherwise, the whole bar is inverted. |
|
104 |
||
105 |
redrawLocked internal - locks redraws while tracking |
|
106 |
||
107 |
orientation <Symbol> one of #horizontal / #vertical |
|
108 |
||
109 |
||
110 |
styleSheet values: |
|
111 |
variablePanelShowHandle true/false - should a handle be shown (default:true) |
|
112 |
||
113 |
variablePanelHandleStyle #next / #motif / nil (special handles) |
|
114 |
||
115 |
variablePanelHandlePosition #left / #center / #right (default:#right) |
|
116 |
||
117 |
variablePanelHandleLevel 3D level of heandle (default:2) |
|
118 |
||
119 |
variablePanelTrackingLine when moved, track an inverted line (as in motif) |
|
120 |
as opposed to tracking the whole bar (default:false) |
|
121 |
||
122 |
variablePanelSeparatingLine draw a separating line in the bar as in motif (default:false) |
|
123 |
||
124 |
variablePanelHandleColor color of the handle. (default:Black) |
|
125 |
||
126 |
variablePanelHandleEnteredColor color of the handle when the pointer is in the bar (default:nil) |
|
295 | 127 |
" |
128 |
! |
|
129 |
||
130 |
examples |
|
131 |
" |
|
132 |
example (setting the orientation later makes it equally space its views): |
|
133 |
||
134 |
|top p v1 v2 v3| |
|
135 |
||
136 |
top := StandardSystemView new. |
|
137 |
top extent:300@300. |
|
138 |
||
139 |
p := VariablePanel |
|
140 |
origin:0.0 @ 0.0 |
|
141 |
corner:1.0 @ 1.0 |
|
142 |
in:top. |
|
143 |
||
144 |
v1 := View in:p. |
|
145 |
v2 := View in:p. |
|
146 |
v3 := View in:p. |
|
147 |
||
148 |
v1 viewBackground:(Color red). |
|
149 |
v2 viewBackground:(Color green). |
|
150 |
v3 viewBackground:(Color yellow). |
|
151 |
||
152 |
p orientation:#vertical. |
|
153 |
top open. |
|
154 |
||
155 |
||
156 |
example (setting orientation first, req's that subviews have relative bounds): |
|
157 |
||
158 |
|top p v1 v2 v3| |
|
159 |
||
160 |
top := StandardSystemView new. |
|
161 |
top extent:300@300. |
|
162 |
||
163 |
p := VariablePanel |
|
164 |
origin:0.0 @ 0.0 |
|
165 |
corner:1.0 @ 1.0 |
|
166 |
in:top. |
|
167 |
p orientation:#vertical. |
|
168 |
||
169 |
v1 := View origin:0.0@0.0 corner:1.0@(1/2) in:p. |
|
170 |
v2 := View origin:0.0@(1/2) corner:1.0@(2/3) in:p. |
|
171 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
172 |
||
173 |
v1 viewBackground:(Color red). |
|
174 |
v2 viewBackground:(Color green). |
|
175 |
v3 viewBackground:(Color yellow). |
|
176 |
||
177 |
top open |
|
178 |
||
179 |
||
180 |
||
181 |
example (change the handles level): |
|
182 |
||
183 |
|top p v1 v2 v3| |
|
184 |
||
185 |
top := StandardSystemView new. |
|
186 |
top extent:300@300. |
|
187 |
||
188 |
p := VariablePanel |
|
189 |
origin:0.0 @ 0.0 |
|
190 |
corner:1.0 @ 1.0 |
|
191 |
in:top. |
|
192 |
p orientation:#vertical. |
|
193 |
p handleLevel:-1. |
|
194 |
||
195 |
v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p. |
|
196 |
v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p. |
|
197 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
198 |
||
199 |
v1 viewBackground:(Color red). |
|
200 |
v2 viewBackground:(Color green). |
|
201 |
v3 viewBackground:(Color yellow). |
|
202 |
||
203 |
top open |
|
204 |
||
205 |
||
206 |
||
397 | 207 |
example (change the handles style to nil makes it invisible): |
208 |
||
209 |
|top p v1 v2 v3| |
|
210 |
||
211 |
top := StandardSystemView new. |
|
212 |
top extent:300@300. |
|
213 |
||
214 |
p := VariablePanel |
|
215 |
origin:0.0 @ 0.0 |
|
216 |
corner:1.0 @ 1.0 |
|
217 |
in:top. |
|
218 |
p orientation:#vertical. |
|
219 |
p handleStyle:nil. |
|
220 |
||
221 |
v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p. |
|
222 |
v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p. |
|
223 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
224 |
||
225 |
v1 viewBackground:(Color red). |
|
226 |
v2 viewBackground:(Color green). |
|
227 |
v3 viewBackground:(Color yellow). |
|
228 |
||
229 |
top open |
|
230 |
||
231 |
||
232 |
||
295 | 233 |
example (placing scrolled and unscrolled views into a variablePanel): |
234 |
||
235 |
|top p v1 v2 v3| |
|
236 |
||
237 |
top := StandardSystemView new. |
|
238 |
top extent:300@300. |
|
239 |
||
240 |
p := VariablePanel |
|
241 |
origin:0.0 @ 0.0 |
|
242 |
corner:1.0 @ 1.0 |
|
243 |
in:top. |
|
244 |
p orientation:#vertical. |
|
245 |
||
246 |
v1 := ScrollableView for:SelectionInListView in:p. |
|
247 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
248 |
v1 list:(FileDirectory directoryNamed:'/etc') contents. |
|
249 |
v1 action:[:selNr | |
|
250 |
|fullName stream text| |
|
251 |
fullName := '/etc/' , v1 selectionValue. |
|
252 |
stream := fullName asFilename readStream. |
|
253 |
stream notNil ifTrue:[ |
|
254 |
text := stream contents. |
|
255 |
v2 contents:text. |
|
256 |
v3 contents:text |
|
257 |
] |
|
258 |
]. |
|
259 |
||
260 |
v2 := TextView origin:0.0 @ 0.5 corner:1.0 @ 0.8 in:p. |
|
261 |
||
262 |
v3 := ScrollableView for:TextView in:p. |
|
263 |
v3 origin:0.0 @ 0.8 corner:1.0 @ 1.0. |
|
264 |
top open |
|
265 |
||
266 |
||
267 |
example: (dynamically adding/removing views): |
|
268 |
||
269 |
|top p v1 v2 b| |
|
270 |
||
271 |
top := StandardSystemView new. |
|
272 |
top extent:300@300. |
|
273 |
||
274 |
b := Toggle label:'show' in:top. |
|
275 |
b showLamp:false. |
|
276 |
b origin:0.0 @ 0.0 corner:(1.0 @ 40). |
|
277 |
b action:[:state | |
|
278 |
state ifTrue:[ |
|
279 |
b label:'hide'. |
|
280 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
281 |
v2 := ScrollableView for:EditTextView. |
|
282 |
v2 origin:0.0 @ 0.5 corner:1.0 @ 1.0. |
|
283 |
v2 contents:'another text'. |
|
284 |
p addSubView:v2. |
|
300 | 285 |
v2 realize. |
295 | 286 |
] ifFalse:[ |
287 |
b label:'show'. |
|
288 |
v2 destroy. |
|
289 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 1.0 |
|
290 |
] |
|
291 |
]. |
|
292 |
||
293 |
p := VariablePanel |
|
294 |
origin:0.0 @ 0.0 |
|
295 |
corner:1.0 @ 1.0 |
|
296 |
in:top. |
|
297 |
p orientation:#vertical. |
|
298 |
p topInset:50. |
|
299 |
||
300 |
v1 := ScrollableView for:EditTextView in:p. |
|
301 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
302 |
v1 contents:'some text'. |
|
303 |
||
304 |
top open |
|
305 |
||
306 |
||
307 |
example: (dynamically flipping orientation): |
|
308 |
Notice: you have to change the relative bounds of the subviews first. |
|
309 |
||
310 |
|top p v1 v2 b| |
|
311 |
||
312 |
top := StandardSystemView new. |
|
313 |
top extent:300@300. |
|
314 |
||
315 |
b := Toggle label:'flip' in:top. |
|
316 |
b showLamp:false. |
|
317 |
b origin:0.0 @ 0.0 corner:(1.0 @ 40). |
|
318 |
b action:[:state | |
|
319 |
state ifTrue:[ |
|
320 |
v1 origin:0.0 @ 0.0 corner:0.5 @ 1.0. |
|
321 |
v2 origin:0.5 @ 0.0 corner:1.0 @ 1.0. |
|
322 |
p orientation:#horizontal. |
|
323 |
] ifFalse:[ |
|
324 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
325 |
v2 origin:0.0 @ 0.5 corner:1.0 @ 1.0. |
|
326 |
p orientation:#vertical. |
|
327 |
]. |
|
328 |
]. |
|
329 |
||
330 |
p := VariablePanel |
|
331 |
origin:0.0 @ 0.0 |
|
332 |
corner:1.0 @ 1.0 |
|
333 |
in:top. |
|
334 |
p orientation:#vertical. |
|
335 |
p topInset:50. |
|
336 |
||
337 |
v1 := ScrollableView for:EditTextView in:p. |
|
338 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
339 |
v1 contents:'some text'. |
|
340 |
||
341 |
v2 := ScrollableView for:EditTextView in:p. |
|
342 |
v2 origin:0.0 @ 0.5 corner:1.0 @ 1.0. |
|
343 |
v2 contents:'another text'. |
|
344 |
||
345 |
top open |
|
346 |
||
347 |
||
348 |
example (combining fix-size with variable size): |
|
349 |
(need 3 extra frame-views to place the extra labels into) |
|
350 |
||
351 |
|top p v1 l1 v2 l2 v3 l3 f1 f2 f3| |
|
352 |
||
353 |
top := StandardSystemView new. |
|
354 |
top extent:300@300. |
|
355 |
||
356 |
p := VariablePanel |
|
357 |
origin:0.0 @ 0.0 |
|
358 |
corner:1.0 @ 1.0 |
|
359 |
in:top. |
|
360 |
||
361 |
f1 := View in:p. |
|
362 |
f2 := View in:p. |
|
363 |
f3 := View in:p. |
|
364 |
||
365 |
v1 := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:f1. |
|
366 |
v2 := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:f2. |
|
367 |
v3 := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:f3. |
|
368 |
||
369 |
l1 := Label label:'sub1' in:f1. |
|
370 |
l2 := Label label:'sub2' in:f2. |
|
371 |
l3 := Label label:'sub3' in:f3. |
|
372 |
||
373 |
l1 origin:0.0 @ 0.0 corner:1.0 @ 0.0 ; |
|
374 |
bottomInset:(l1 preferredExtent y negated). |
|
375 |
l2 origin:0.0 @ 0.0 corner:1.0 @ 0.0 ; |
|
376 |
bottomInset:(l2 preferredExtent y negated). |
|
377 |
l3 origin:0.0 @ 0.0 corner:1.0 @ 0.0 ; |
|
378 |
bottomInset:(l3 preferredExtent y negated). |
|
379 |
||
380 |
v1 topInset:(l1 preferredExtent y); level:-1. |
|
381 |
v2 topInset:(l2 preferredExtent y); level:-1. |
|
382 |
v3 topInset:(l3 preferredExtent y); level:-1. |
|
383 |
||
384 |
v1 viewBackground:(Color red). |
|
385 |
v2 viewBackground:(Color green). |
|
386 |
v3 viewBackground:(Color yellow). |
|
387 |
||
388 |
p orientation:#vertical. |
|
389 |
top open |
|
390 |
||
391 |
||
392 |
BAD EXAMPLE (wrong relative sizes - repaired on handle move): |
|
393 |
||
394 |
|top p v1 v2 v3| |
|
395 |
||
396 |
top := StandardSystemView new. |
|
397 |
top extent:300@300. |
|
398 |
||
399 |
p := VariablePanel |
|
400 |
origin:0.0 @ 0.0 |
|
401 |
corner:1.0 @ 1.0 |
|
402 |
in:top. |
|
403 |
p orientation:#vertical. |
|
404 |
||
405 |
v1 := View origin:0.0 @ 0.0 corner:1.0 @ (1/4) in:p. |
|
406 |
v2 := View origin:0.0 @ (1/2) corner:1.0 @ (3/4) in:p. |
|
407 |
v3 := View origin:0.0 @ (3/4) corner:1.0 @ 1.0 in:p. |
|
408 |
||
409 |
v1 viewBackground:(Color red). |
|
410 |
v2 viewBackground:(Color green). |
|
411 |
v3 viewBackground:(Color yellow). |
|
412 |
||
413 |
top open |
|
414 |
" |
|
415 |
! ! |
|
416 |
||
417 |
!VariablePanel class methodsFor:'defaults'! |
|
418 |
||
419 |
lightFormOn:aDisplay |
|
420 |
"use same handle as Scroller" |
|
421 |
||
422 |
^ Scroller handleLightFormOn:aDisplay |
|
423 |
! |
|
424 |
||
425 |
shadowFormOn:aDisplay |
|
426 |
"use same handle as Scroller" |
|
427 |
||
428 |
^ Scroller handleShadowFormOn:aDisplay |
|
429 |
! |
|
430 |
||
431 |
updateStyleCache |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
432 |
"extract values from the styleSheet and cache them in class variables" |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
433 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
434 |
<resource: #style (#variablePanelShowHandle #variablePanelHandleStyle |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
435 |
#variablePanelHandlePosition #variablePanelHandleLevel |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
436 |
#variablePanelTrackingLine |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
437 |
#variablePanelSeparatingLine #variablePanelHandleColor)> |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
438 |
|
295 | 439 |
DefaultShowHandle := StyleSheet at:'variablePanelShowHandle' default:true. |
440 |
DefaultHandleStyle := StyleSheet at:'variablePanelHandleStyle'. |
|
441 |
DefaultHandlePosition := StyleSheet at:'variablePanelHandlePosition' default:#right. |
|
442 |
DefaultHandleLevel := StyleSheet at:'variablePanelHandleLevel' default:2. |
|
443 |
DefaultTrackingLine := StyleSheet at:'variablePanelTrackingLine' default:false. |
|
444 |
DefaultSeparatingLine := StyleSheet at:'variablePanelSeparatingLine' default:false. |
|
445 |
DefaultHandleColor := StyleSheet colorAt:'variablePanelHandleColor' default:Black. |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
446 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
447 |
"Modified: 1.3.1996 / 13:51:24 / cg" |
295 | 448 |
! ! |
449 |
||
450 |
!VariablePanel methodsFor:'accessing'! |
|
451 |
||
452 |
addSubView:aView |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
453 |
"a view is added; adjust other subviews sizes" |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
454 |
|
295 | 455 |
super addSubView:aView. |
456 |
realized ifTrue:[ |
|
397 | 457 |
self resizeSubviews. |
295 | 458 |
] |
459 |
||
460 |
"Created: 17.1.1996 / 22:41:00 / cg" |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
461 |
"Modified: 24.2.1996 / 19:05:05 / cg" |
295 | 462 |
! |
463 |
||
464 |
orientation |
|
485 | 465 |
"return my orientation; either #horizontal or #vertical" |
466 |
||
295 | 467 |
^ orientation |
485 | 468 |
|
469 |
"Modified: 6.3.1996 / 18:08:45 / cg" |
|
295 | 470 |
! |
471 |
||
472 |
orientation:aSymbol |
|
485 | 473 |
"change my orientation; aSymbol must be one of #horizontal or #vertical. |
474 |
Changing implies a resize of my subViews." |
|
475 |
||
476 |
aSymbol ~~ orientation ifTrue:[ |
|
477 |
orientation := aSymbol. |
|
478 |
self initCursor. |
|
479 |
self anyNonRelativeSubviews ifTrue:[ |
|
480 |
self setupSubviews |
|
481 |
]. |
|
482 |
shown ifTrue:[ |
|
483 |
self cursor:cursor. |
|
484 |
self sizeChanged:nil. |
|
485 |
self redraw. |
|
486 |
] |
|
295 | 487 |
] |
485 | 488 |
|
489 |
"Modified: 6.3.1996 / 18:09:22 / cg" |
|
295 | 490 |
! |
491 |
||
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
492 |
removeSubView:aView |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
493 |
"a view is removed; adjust other subviews sizes" |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
494 |
|
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
495 |
super removeSubView:aView. |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
496 |
shown ifTrue:[ |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
497 |
(superView isNil or:[superView shown]) ifTrue:[ |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
498 |
self setupSubviews |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
499 |
] |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
500 |
] |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
501 |
! ! |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
502 |
|
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
503 |
!VariablePanel methodsFor:'accessing-look'! |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
504 |
|
295 | 505 |
barHeight |
506 |
"return the height of the separating bar" |
|
507 |
||
508 |
^ barHeight |
|
509 |
! |
|
510 |
||
511 |
barHeight:nPixel |
|
512 |
"set the height of the separating bar" |
|
513 |
||
514 |
barHeight := nPixel. |
|
515 |
||
516 |
"if screen is very low-res, make certain bar is visible and catchable" |
|
517 |
(barHeight < 4) ifTrue:[ |
|
518 |
barHeight := 4 |
|
519 |
]. |
|
520 |
||
521 |
"make it even so spacing is equally spreadable among subviews" |
|
522 |
barHeight odd ifTrue:[ |
|
523 |
barHeight := barHeight + 1 |
|
524 |
] |
|
525 |
! |
|
526 |
||
527 |
handleLevel:aNumber |
|
528 |
"define the 3D level of the handle (only with some styles). |
|
529 |
Normally, this is defined via styleSheet files, but this entry allows |
|
530 |
individual views to be manipulated." |
|
531 |
||
532 |
handleLevel := aNumber |
|
533 |
! |
|
534 |
||
535 |
handlePosition |
|
536 |
"return the position of the handle" |
|
537 |
||
538 |
^ handlePosition |
|
539 |
! |
|
540 |
||
541 |
handlePosition:aSymbol |
|
542 |
"define the position of the handle; the argument aSymbol |
|
543 |
may be one of #left, #right or #center" |
|
544 |
||
545 |
handlePosition := aSymbol |
|
546 |
! |
|
547 |
||
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
548 |
handleStyle:styleSymbol |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
549 |
"define the style of the handle; |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
550 |
styleSymbol may be #motif to draw a little knob or |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
551 |
anything else to draw scrollBars handleForm. |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
552 |
Normally, this is defined via styleSheet files, but this entry allows |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
553 |
individual views to be manipulated." |
295 | 554 |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
555 |
(styleSymbol ~~ handleStyle) ifTrue:[ |
397 | 556 |
handleStyle := styleSymbol. |
557 |
handleStyle == #next ifTrue:[ |
|
558 |
shadowForm := self class shadowFormOn:device. |
|
559 |
lightForm := self class lightFormOn:device. |
|
560 |
] ifFalse:[ |
|
561 |
shadowForm := lightForm := nil |
|
562 |
]. |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
563 |
|
397 | 564 |
shadowForm notNil ifTrue:[ |
565 |
(self is3D and:[handleStyle ~~ #motif]) ifTrue:[ |
|
566 |
self barHeight:(shadowForm height + 2). |
|
567 |
barWidth := shadowForm width |
|
568 |
] |
|
569 |
]. |
|
570 |
shown ifTrue:[ |
|
571 |
self resizeSubviews. |
|
572 |
self redraw |
|
573 |
] |
|
295 | 574 |
] |
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
575 |
|
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
576 |
"Created: 24.2.1996 / 19:04:07 / cg" |
295 | 577 |
! |
578 |
||
579 |
style:styleSymbol |
|
580 |
"define the style of the handle; |
|
581 |
styleSymbol may be #motif to draw a little knob or |
|
582 |
anything else to draw scrollBars handleForm. |
|
583 |
Normally, this is defined via styleSheet files, but this entry allows |
|
584 |
individual views to be manipulated." |
|
585 |
||
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
586 |
self handleStyle:styleSymbol |
295 | 587 |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
588 |
"Modified: 24.2.1996 / 19:04:19 / cg" |
295 | 589 |
! ! |
590 |
||
591 |
!VariablePanel methodsFor:'drawing'! |
|
592 |
||
593 |
drawHandleAtX:hx y:hy |
|
594 |
"draw a single handle at hx/hy" |
|
595 |
||
596 |
|h w x y m| |
|
597 |
||
396
973d4a9fa32c
setting handleStyle to nil disables handleDrawing
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
598 |
handleStyle isNil ifTrue:[^ self]. |
973d4a9fa32c
setting handleStyle to nil disables handleDrawing
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
599 |
|
295 | 600 |
shadowForm notNil ifTrue:[ |
397 | 601 |
h := shadowForm height. |
602 |
w := shadowForm width . |
|
295 | 603 |
] ifFalse:[ |
397 | 604 |
h := w := barHeight - 4. |
295 | 605 |
]. |
606 |
||
607 |
self paint:viewBackground. |
|
608 |
orientation == #vertical ifTrue:[ |
|
397 | 609 |
self fillRectangleX:margin y:hy |
610 |
width:(width - margin - margin) |
|
611 |
height:barHeight. |
|
295 | 612 |
|
397 | 613 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
614 |
m := (barHeight - h) // 2. |
|
295 | 615 |
|
397 | 616 |
shadowForm isNil ifTrue:[ |
617 |
y := hy + (barHeight // 2). |
|
295 | 618 |
|
397 | 619 |
separatingLine ifTrue:[ |
620 |
self paint:shadowColor. |
|
621 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
622 |
y := y + 1. |
|
623 |
self paint:lightColor. |
|
624 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
625 |
]. |
|
626 |
self paint:viewBackground. |
|
627 |
self fillRectangleX:(hx - barWidth) y:hy |
|
628 |
width:(barWidth + barWidth) |
|
629 |
height:h. |
|
295 | 630 |
|
397 | 631 |
handleStyle == #line ifTrue:[ |
632 |
self paint:handleColor. |
|
633 |
self displayLineFromX:hx - barWidth y:y toX:hx + barWidth y:y |
|
634 |
] ifFalse:[ |
|
635 |
y := hy. |
|
636 |
handleStyle == #st80 ifTrue:[ |
|
637 |
y := y - 1 |
|
638 |
]. |
|
639 |
self drawEdgesForX:(hx - barWidth) |
|
640 |
y:(y + m) |
|
641 |
width:(barWidth + barWidth) |
|
642 |
height:h |
|
643 |
level:handleLevel. |
|
295 | 644 |
|
397 | 645 |
handleStyle == #iris ifTrue:[ |
646 |
self paint:handleColor. |
|
647 |
self fillDeviceRectangleX:(hx - barWidth + 2) |
|
648 |
y:(y + m + 2) |
|
649 |
width:(barWidth + barWidth - 4) |
|
650 |
height:h - 4 |
|
651 |
] |
|
652 |
]. |
|
653 |
] ifFalse:[ |
|
654 |
y := hy. |
|
655 |
self drawHandleFormAtX:hx y:(y + m) |
|
656 |
]. |
|
657 |
handleStyle == #st80 ifTrue:[ |
|
658 |
y := hy - 1. |
|
659 |
self paint:lightColor. |
|
660 |
self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y. |
|
661 |
self displayLineFromX:0 y:hy toX:0 y:(hy + barHeight - 1). |
|
662 |
y := hy + barHeight - 2. |
|
663 |
self paint:shadowColor. |
|
664 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
665 |
"uncomment the -1 if you dont like the notch at the right end" |
|
666 |
" VVV" |
|
667 |
self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + barHeight - 1). |
|
668 |
]. |
|
669 |
] ifFalse:[ |
|
670 |
y := hy + barHeight - 1. |
|
671 |
self paint:handleColor. |
|
672 |
separatingLine ifTrue:[ |
|
673 |
self displayLineFromX:0 y:hy+1 toX:width y:hy+1. |
|
674 |
self displayLineFromX:0 y:y toX:width y:y. |
|
675 |
]. |
|
676 |
self fillRectangleX:hx y:hy width:barWidth height:barHeight |
|
677 |
] |
|
295 | 678 |
] ifFalse:[ |
397 | 679 |
self fillRectangleX:hx y:margin |
680 |
width:barHeight |
|
681 |
height:(height - margin - margin). |
|
682 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
|
683 |
m := (barHeight - w) // 2. |
|
684 |
shadowForm isNil ifTrue:[ |
|
685 |
x := hx + (barHeight // 2). |
|
686 |
separatingLine ifTrue:[ |
|
687 |
self paint:shadowColor. |
|
688 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
689 |
x := x + 1. |
|
690 |
self paint:lightColor. |
|
691 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
692 |
]. |
|
693 |
self paint:viewBackground. |
|
694 |
self fillRectangleX:hx y:(hy - barWidth) |
|
695 |
width:w |
|
696 |
height:(barWidth + barWidth). |
|
295 | 697 |
|
397 | 698 |
handleStyle == #line ifTrue:[ |
699 |
self paint:handleColor. |
|
700 |
self displayLineFromX:x y:hy - barWidth toX:x y:hy + barWidth. |
|
701 |
] ifFalse:[ |
|
702 |
x := hx. |
|
703 |
handleStyle == #st80 ifTrue:[ |
|
704 |
x := x - 1. |
|
705 |
]. |
|
706 |
self drawEdgesForX:(x + m) |
|
707 |
y:(hy - barWidth) |
|
708 |
width:w |
|
709 |
height:(barWidth + barWidth) |
|
710 |
level:handleLevel. |
|
711 |
handleStyle == #iris ifTrue:[ |
|
712 |
self paint:handleColor. |
|
713 |
self fillDeviceRectangleX:(x + m + 2) |
|
714 |
y:(hy - barWidth + 2) |
|
715 |
width:w - 4 |
|
716 |
height:(barWidth + barWidth - 4) |
|
717 |
]. |
|
718 |
] |
|
719 |
] ifFalse:[ |
|
720 |
x := hx. |
|
721 |
self drawHandleFormAtX:(x + m) y:hy |
|
722 |
]. |
|
723 |
handleStyle == #st80 ifTrue:[ |
|
724 |
x := hx - 1. |
|
725 |
self paint:lightColor. |
|
726 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
727 |
self displayLineFromX:hx y:0 toX:(hx + barHeight - 1) y:0. |
|
728 |
x := hx + barHeight - 2. |
|
729 |
self paint:shadowColor. |
|
730 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
731 |
"uncomment the -1 if you dont like the notch at the bottom end" |
|
732 |
" VVV" |
|
733 |
self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeight - 1) y:height-1. |
|
734 |
]. |
|
735 |
] ifFalse:[ |
|
736 |
x := hx + barHeight - 1. |
|
737 |
self paint:handleColor. |
|
738 |
separatingLine ifTrue:[ |
|
739 |
self displayLineFromX:hx+1 y:0 toX:hx+1 y:height. |
|
740 |
self displayLineFromX:x y:0 toX:x y:height. |
|
741 |
]. |
|
742 |
self fillRectangleX:hx y:hy width:barHeight height:barWidth |
|
743 |
] |
|
295 | 744 |
]. |
745 |
||
396
973d4a9fa32c
setting handleStyle to nil disables handleDrawing
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
746 |
"Modified: 24.2.1996 / 19:05:52 / cg" |
295 | 747 |
! |
748 |
||
749 |
drawHandleFormAtX:hx y:hy |
|
750 |
"draw a handles bitmap at hx/hy" |
|
751 |
||
752 |
self paint:shadowColor. |
|
753 |
self displayForm:shadowForm x:hx y:hy. |
|
754 |
self paint:lightColor. |
|
755 |
self displayForm:lightForm x:hx y:hy. |
|
756 |
self paint:viewBackground |
|
757 |
! |
|
758 |
||
759 |
invertHandleBarAtX:hx y:hy |
|
760 |
self noClipByChildren. |
|
761 |
self xoring:[ |
|
762 |
|y x| |
|
763 |
||
764 |
orientation == #vertical ifTrue:[ |
|
765 |
trackLine ifTrue:[ |
|
766 |
y := hy + (barHeight // 2). |
|
767 |
self displayLineFromX:0 y:y toX:width y:y. |
|
768 |
] ifFalse:[ |
|
769 |
self fillRectangleX:0 y:hy width:width height:barHeight |
|
770 |
] |
|
771 |
] ifFalse:[ |
|
772 |
trackLine ifTrue:[ |
|
773 |
x := hx + (barHeight // 2). |
|
774 |
self displayLineFromX:x y:0 toX:x y:height. |
|
775 |
] ifFalse:[ |
|
776 |
self fillRectangleX:hx y:0 width:barHeight height:height |
|
777 |
] |
|
778 |
] |
|
779 |
]. |
|
780 |
self clipByChildren. |
|
781 |
! |
|
782 |
||
783 |
lockRedraw |
|
784 |
redrawLocked := true |
|
785 |
! |
|
786 |
||
787 |
redraw |
|
788 |
"redraw all of the handles" |
|
789 |
||
790 |
redrawLocked ~~ true ifTrue:[ |
|
791 |
self redrawHandlesFrom:1 to:(subViews size) |
|
792 |
] |
|
793 |
! |
|
794 |
||
795 |
redrawHandlesFrom:start to:stop |
|
796 |
"redraw some handles" |
|
797 |
||
798 |
subViews notNil ifTrue:[ |
|
799 |
showHandle ifTrue:[ |
|
800 |
self handleOriginsFrom:start to:stop do:[:hPoint | |
|
801 |
self drawHandleAtX:(hPoint x) y:(hPoint y) |
|
802 |
]. |
|
803 |
] |
|
804 |
] |
|
805 |
! |
|
806 |
||
807 |
unlockRedraw |
|
808 |
redrawLocked := false |
|
809 |
! ! |
|
810 |
||
811 |
!VariablePanel methodsFor:'event handling'! |
|
812 |
||
813 |
sizeChanged:how |
|
814 |
"my size has changed; resize my subviews" |
|
815 |
||
816 |
shown ifTrue:[ |
|
817 |
(how == #smaller) ifTrue:[ |
|
818 |
self resizeSubviews |
|
819 |
] ifFalse:[ |
|
820 |
"/ |
|
821 |
"/ do it in reverse order, to avoid some redraws |
|
822 |
"/ |
|
823 |
self resizeSubviewsFrom:(subViews size) to:1 |
|
824 |
] |
|
825 |
]. |
|
826 |
self changed:#sizeOfView with:how. |
|
827 |
! ! |
|
828 |
||
829 |
!VariablePanel methodsFor:'initializing'! |
|
830 |
||
831 |
defaultControllerClass |
|
832 |
^ VariablePanelController |
|
833 |
! |
|
834 |
||
835 |
fixSize |
|
836 |
extentChanged ifTrue:[ |
|
837 |
super fixSize. |
|
838 |
self resizeSubviews |
|
839 |
] ifFalse:[ |
|
840 |
super fixSize |
|
841 |
] |
|
842 |
! |
|
843 |
||
844 |
initCursor |
|
845 |
"set the cursor - a double arrow" |
|
846 |
||
847 |
orientation == #vertical ifTrue:[ |
|
848 |
DefaultVCursor notNil ifTrue:[ |
|
849 |
cursor := DefaultVCursor |
|
850 |
] ifFalse:[ |
|
851 |
cursor := Cursor sourceForm:(Form fromFile:'VVPanel.xbm') |
|
852 |
maskForm:(Form fromFile:'VVPanel_m.xbm') |
|
853 |
hotX:8 |
|
854 |
hotY:8. |
|
855 |
" |
|
856 |
if bitmaps are not available, use a standard cursor |
|
857 |
" |
|
858 |
cursor isNil ifTrue:[ |
|
859 |
"which one looks better ?" |
|
860 |
cursor := Cursor upDownArrow |
|
861 |
"cursor := Cursor upLimitArrow" |
|
862 |
]. |
|
863 |
DefaultVCursor := cursor |
|
864 |
] |
|
865 |
] ifFalse:[ |
|
866 |
DefaultHCursor notNil ifTrue:[ |
|
867 |
cursor := DefaultHCursor |
|
868 |
] ifFalse:[ |
|
869 |
cursor := Cursor sourceForm:(Form fromFile:'VHPanel.xbm') |
|
870 |
maskForm:(Form fromFile:'VHPanel_m.xbm') |
|
871 |
hotX:8 |
|
872 |
hotY:8. |
|
873 |
" |
|
874 |
if bitmaps are not available, use a standard cursor |
|
875 |
" |
|
876 |
cursor isNil ifTrue:[ |
|
877 |
"which one looks better ?" |
|
878 |
cursor := Cursor leftRightArrow |
|
879 |
"cursor := Cursor leftLimitArrow" |
|
880 |
]. |
|
881 |
DefaultHCursor := cursor |
|
882 |
] |
|
883 |
] |
|
884 |
! |
|
885 |
||
886 |
initStyle |
|
496 | 887 |
|mm h bH| |
295 | 888 |
|
889 |
super initStyle. |
|
890 |
||
891 |
handleColor := DefaultHandleColor on:device. |
|
892 |
||
893 |
DefaultHandleStyle isNil ifTrue:[ |
|
496 | 894 |
handleStyle := styleSheet name |
295 | 895 |
] ifFalse:[ |
496 | 896 |
handleStyle := DefaultHandleStyle |
295 | 897 |
]. |
898 |
||
496 | 899 |
handleLevel := DefaultHandleLevel. |
900 |
showHandle := DefaultShowHandle. |
|
295 | 901 |
handlePosition := DefaultHandlePosition. |
902 |
trackLine := DefaultTrackingLine. |
|
903 |
separatingLine := DefaultSeparatingLine. |
|
904 |
||
496 | 905 |
handleStyle == #next ifTrue:[ |
906 |
shadowForm := self class shadowFormOn:device. |
|
907 |
lightForm := self class lightFormOn:device. |
|
908 |
||
909 |
bH := shadowForm height + 2. |
|
910 |
barWidth := shadowForm width. |
|
295 | 911 |
] ifFalse:[ |
496 | 912 |
shadowForm := lightForm := nil. |
913 |
||
914 |
mm := device verticalPixelPerMillimeter. |
|
915 |
self is3D ifTrue:[ |
|
916 |
h := 3 |
|
917 |
] ifFalse:[ |
|
918 |
h := 2 |
|
919 |
]. |
|
920 |
bH := (h * mm) rounded. |
|
921 |
barWidth := (2 * mm) rounded. "motif style width" |
|
295 | 922 |
]. |
496 | 923 |
self barHeight:bH. |
924 |
||
295 | 925 |
handleStyle == #mswindows ifTrue:[ |
496 | 926 |
barWidth := (ArrowButton new direction:#up) width + 1 |
295 | 927 |
]. |
496 | 928 |
|
929 |
"Modified: 8.3.1996 / 11:51:59 / cg" |
|
295 | 930 |
! |
931 |
||
932 |
initialize |
|
496 | 933 |
orientation isNil ifTrue:[orientation := #vertical]. |
295 | 934 |
super initialize. |
496 | 935 |
|
936 |
"Modified: 7.3.1996 / 14:08:25 / cg" |
|
295 | 937 |
! ! |
938 |
||
939 |
!VariablePanel methodsFor:'private'! |
|
940 |
||
941 |
anyNonRelativeSubviews |
|
942 |
"return true, if any of my subviews has no relative origin/extent" |
|
943 |
||
944 |
1 to:(subViews size) do:[:index | |
|
945 |
|view| |
|
946 |
||
947 |
view := subViews at:index. |
|
948 |
view relativeCorner isNil ifTrue:[^ true]. |
|
949 |
view relativeOrigin isNil ifTrue:[^ true] |
|
950 |
]. |
|
951 |
^ false |
|
952 |
! |
|
953 |
||
954 |
handleOriginsDo:aBlock |
|
955 |
"evaluate the argument block for every handle-origin" |
|
956 |
||
957 |
self handleOriginsFrom:1 to:(subViews size) do:aBlock |
|
958 |
! |
|
959 |
||
960 |
handleOriginsFrom:start to:stop do:aBlock |
|
961 |
"evaluate the argument block for some handle-origins" |
|
962 |
||
963 |
|x y hw hh hDelta vDelta |
|
964 |
first "{ Class: SmallInteger }" |
|
965 |
last "{ Class: SmallInteger }"| |
|
966 |
||
967 |
subViews notNil ifTrue:[ |
|
968 |
shadowForm notNil ifTrue:[ |
|
969 |
hw := shadowForm width. |
|
970 |
hh := shadowForm height. |
|
971 |
] ifFalse:[ |
|
972 |
hw := hh := barWidth |
|
973 |
]. |
|
974 |
||
975 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
|
976 |
hDelta := barWidth // 2. |
|
977 |
vDelta := barWidth // 2. |
|
978 |
] ifFalse:[ |
|
979 |
hDelta := vDelta := 0 |
|
980 |
]. |
|
981 |
||
982 |
(handlePosition == #left) ifTrue:[ |
|
983 |
x := hDelta. |
|
984 |
y := vDelta |
|
985 |
] ifFalse:[ |
|
986 |
(handlePosition == #right) ifTrue:[ |
|
987 |
x := width - hw - margin - hDelta. |
|
988 |
y := height - hh - margin - vDelta. |
|
989 |
] ifFalse:[ |
|
990 |
x := width - barWidth // 2. |
|
991 |
y := height - barWidth // 2 |
|
992 |
] |
|
993 |
]. |
|
994 |
first := start + 1. |
|
995 |
last := stop. |
|
996 |
first to:last do:[:index | |
|
997 |
|view| |
|
998 |
||
999 |
view := subViews at:index. |
|
1000 |
orientation == #vertical ifTrue:[ |
|
1001 |
y := view top "origin y" - barHeight + 1. |
|
1002 |
] ifFalse:[ |
|
1003 |
x := view left "origin x" - barHeight + 1. |
|
1004 |
]. |
|
1005 |
aBlock value:(x @ y) |
|
1006 |
] |
|
1007 |
] |
|
1008 |
! |
|
1009 |
||
1010 |
resizeSubviews |
|
1011 |
"readjust size of some subviews" |
|
1012 |
||
1013 |
self resizeSubviewsFrom:1 to:(subViews size) |
|
1014 |
! |
|
1015 |
||
1016 |
resizeSubviewsFrom:start to:stop |
|
1017 |
"readjust size of some subviews" |
|
1018 |
||
1019 |
|step nSubviews| |
|
1020 |
||
1021 |
subViews notNil ifTrue:[ |
|
1022 |
(start <= stop) ifTrue:[ |
|
1023 |
step := 1 |
|
1024 |
] ifFalse:[ |
|
1025 |
step := -1 |
|
1026 |
]. |
|
1027 |
nSubviews := subViews size. |
|
1028 |
start to:stop by:step do:[:index | |
|
1029 |
|bw view o1 o2 relOrg relCorner newOrg newCorner newExt| |
|
1030 |
||
1031 |
view := subViews at:index. |
|
1032 |
bw := view borderWidth. |
|
1033 |
||
1034 |
index == 1 ifTrue:[ |
|
1035 |
o1 := 0. |
|
1036 |
] ifFalse:[ |
|
1037 |
o1 := barHeight // 2 - bw |
|
1038 |
]. |
|
1039 |
index == nSubviews ifTrue:[ |
|
1040 |
o2 := 0. |
|
1041 |
] ifFalse:[ |
|
1042 |
o2 := barHeight // 2 - bw |
|
1043 |
]. |
|
1044 |
||
1045 |
" |
|
1046 |
relCorner := view relativeCorner. |
|
1047 |
relCorner isNil ifTrue:[ |
|
1048 |
self error:'subview must have relative corner' |
|
1049 |
]. |
|
1050 |
newCorner := view cornerFromRelativeCorner. |
|
1051 |
newCorner notNil ifTrue:[ |
|
1052 |
newCorner y:(newCorner y - o2) |
|
1053 |
]. |
|
1054 |
||
1055 |
relOrg := view relativeOrigin. |
|
1056 |
relOrg isNil ifTrue:[ |
|
1057 |
self error:'subview must have relative origin' |
|
1058 |
]. |
|
1059 |
newOrg := view originFromRelativeOrigin. |
|
1060 |
newOrg notNil ifTrue:[ |
|
1061 |
(index ~~ 1) ifTrue:[ |
|
1062 |
newOrg y:(newOrg y + o1) |
|
1063 |
]. |
|
1064 |
]. |
|
1065 |
view pixelOrigin:newOrg corner:newCorner |
|
1066 |
" |
|
1067 |
newOrg := view computeOrigin. |
|
1068 |
newOrg notNil ifTrue:[ |
|
1069 |
(index ~~ 1) ifTrue:[ |
|
1070 |
orientation == #vertical ifTrue:[ |
|
1071 |
newOrg y:(newOrg y + o1) |
|
1072 |
] ifFalse:[ |
|
1073 |
newOrg x:(newOrg x + o1) |
|
1074 |
] |
|
1075 |
]. |
|
1076 |
]. |
|
1077 |
newExt := view computeExtent. |
|
1078 |
newExt notNil ifTrue:[ |
|
1079 |
orientation == #vertical ifTrue:[ |
|
1080 |
newExt y:(newExt y - o2 - o1) |
|
1081 |
] ifFalse:[ |
|
1082 |
newExt x:(newExt x - o2 - o1) |
|
1083 |
] |
|
1084 |
]. |
|
1085 |
view pixelOrigin:newOrg extent:newExt. |
|
1086 |
] |
|
1087 |
] |
|
1088 |
! |
|
1089 |
||
1090 |
setupSubviews |
|
1091 |
"setup subviews sizes (in case of non-relative sizes)" |
|
1092 |
||
1093 |
|pos delta| |
|
1094 |
||
300 | 1095 |
"/ setup all subviews to spread evenly ... |
295 | 1096 |
|
300 | 1097 |
pos := 0.0. |
1098 |
delta := 1.0 / (subViews size). |
|
295 | 1099 |
|
300 | 1100 |
1 to:(subViews size) do:[:index | |
1101 |
|view| |
|
295 | 1102 |
|
300 | 1103 |
view := subViews at:index. |
1104 |
orientation == #vertical ifTrue:[ |
|
1105 |
index == subViews size ifTrue:[ |
|
1106 |
view origin:(0.0 @ pos) corner:(1.0 @ 1.0) |
|
295 | 1107 |
] ifFalse:[ |
300 | 1108 |
view origin:(0.0 @ pos) corner:(1.0 @ (pos + delta)) |
295 | 1109 |
]. |
300 | 1110 |
] ifFalse:[ |
1111 |
index == subViews size ifTrue:[ |
|
1112 |
view origin:(pos @ 0.0) corner:(1.0 @ 1.0) |
|
1113 |
] ifFalse:[ |
|
1114 |
view origin:(pos @ 0.0) corner:((pos + delta) @ 1.0) |
|
1115 |
]. |
|
1116 |
]. |
|
1117 |
pos := pos + delta |
|
295 | 1118 |
] |
1119 |
! ! |
|
1120 |
||
299
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1121 |
!VariablePanel methodsFor:'private tableView protocol'! |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1122 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1123 |
setupSubviewOrigins |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1124 |
"setup subviews origins (SV 16.1.95)" |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1125 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1126 |
|x y e eX eY n "{ Class: SmallInteger }"| |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1127 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1128 |
x := y := 0.0. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1129 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1130 |
n := subViews size. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1131 |
1 to:n do:[:index | |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1132 |
|view| |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1133 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1134 |
view := subViews at:index. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1135 |
e := view relativeExtent. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1136 |
e notNil ifTrue:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1137 |
view relativeExtent:nil. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1138 |
eX := e x. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1139 |
eY := e y. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1140 |
index == n ifTrue:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1141 |
view origin:(x @ y) corner:(1.0 @ 1.0) |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1142 |
] ifFalse:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1143 |
orientation == #vertical ifTrue:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1144 |
view origin:(x @ y) corner:(1.0 @ (y+eY)) |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1145 |
] ifFalse:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1146 |
view origin:(x @ y) corner:((x+eX) @ 1.0) |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1147 |
]. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1148 |
]. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1149 |
orientation == #vertical ifTrue:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1150 |
y := y + eY. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1151 |
] ifFalse:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1152 |
x := x + eX. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1153 |
] |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1154 |
] ifFalse: [ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1155 |
view origin:(x @ y). |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1156 |
orientation == #vertical ifTrue:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1157 |
y := view relativeCorner y. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1158 |
] ifFalse:[ |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1159 |
x := view relativeCorner x. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1160 |
] |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1161 |
]. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1162 |
] |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1163 |
! ! |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1164 |
|
295 | 1165 |
!VariablePanel class methodsFor:'documentation'! |
1166 |
||
1167 |
version |
|
496 | 1168 |
^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.9 1996-03-08 10:53:01 cg Exp $' |
295 | 1169 |
! ! |