author | Claus Gittinger <cg@exept.de> |
Thu, 07 Nov 1996 20:40:19 +0100 | |
changeset 876 | 9766a5eda233 |
parent 874 | f79d88b92c1b |
child 900 | 0541b96dd173 |
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 |
871 | 16 |
trackLine redrawLocked orientation handleLabels knobHeight' |
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 |
||
871 | 24 |
!VariablePanel class methodsFor:'documentation'! |
295 | 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 |
|
585 | 79 |
[instance Variables:] |
496 | 80 |
|
81 |
barHeight <Integer> the height of the bar (for verticalPanels) |
|
82 |
barWidth <Integer> the width of the bar (for horizontalPanels) |
|
83 |
||
84 |
separatingLine <Boolean> show a separating line (as in motif style) |
|
85 |
||
86 |
shadowForm <Image/Form> form (shadow part) drawn as handle - if nonNil |
|
87 |
||
88 |
lightForm <Image/Form> form (light part) drawn as handle - if nonNil |
|
89 |
||
90 |
showHandle <Boolean> if false, no handle is drawn |
|
91 |
||
92 |
handlePosition <Symbol> where is the handle - one of #left, #center, #right |
|
93 |
||
94 |
handleColor <Color> inside color of handle - defaults to viewBackground |
|
95 |
||
96 |
handleStyle <Symbol> type of handle; one of #next, #motif or nil |
|
97 |
||
98 |
handleLevel <Integer> 3D level of handle (only valid if no form is given) |
|
99 |
||
100 |
trackLine <Boolean> if true, an inverted line is drawn for tracking; |
|
101 |
otherwise, the whole bar is inverted. |
|
102 |
||
103 |
redrawLocked internal - locks redraws while tracking |
|
104 |
||
105 |
orientation <Symbol> one of #horizontal / #vertical |
|
106 |
||
107 |
||
585 | 108 |
[styleSheet values:] |
496 | 109 |
variablePanelShowHandle true/false - should a handle be shown (default:true) |
110 |
||
111 |
variablePanelHandleStyle #next / #motif / nil (special handles) |
|
112 |
||
113 |
variablePanelHandlePosition #left / #center / #right (default:#right) |
|
114 |
||
115 |
variablePanelHandleLevel 3D level of heandle (default:2) |
|
116 |
||
117 |
variablePanelTrackingLine when moved, track an inverted line (as in motif) |
|
118 |
as opposed to tracking the whole bar (default:false) |
|
119 |
||
120 |
variablePanelSeparatingLine draw a separating line in the bar as in motif (default:false) |
|
121 |
||
122 |
variablePanelHandleColor color of the handle. (default:Black) |
|
123 |
||
124 |
variablePanelHandleEnteredColor color of the handle when the pointer is in the bar (default:nil) |
|
585 | 125 |
|
126 |
[see also:] |
|
127 |
PanelView |
|
128 |
||
129 |
[author:] |
|
130 |
Claus Gittinger |
|
295 | 131 |
" |
132 |
! |
|
133 |
||
134 |
examples |
|
135 |
" |
|
874 | 136 |
example (notice that the subviews MUST have relative bounds): |
593 | 137 |
[exBegin] |
138 |
|top p v1 v2 v3| |
|
295 | 139 |
|
593 | 140 |
top := StandardSystemView new. |
141 |
top extent:300@300. |
|
295 | 142 |
|
593 | 143 |
p := VariablePanel |
144 |
origin:0.0 @ 0.0 |
|
145 |
corner:1.0 @ 1.0 |
|
146 |
in:top. |
|
147 |
p orientation:#vertical. |
|
295 | 148 |
|
593 | 149 |
v1 := View origin:0.0@0.0 corner:1.0@(1/2) in:p. |
150 |
v2 := View origin:0.0@(1/2) corner:1.0@(2/3) in:p. |
|
151 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
295 | 152 |
|
593 | 153 |
v1 viewBackground:(Color red). |
154 |
v2 viewBackground:(Color green). |
|
155 |
v3 viewBackground:(Color yellow). |
|
295 | 156 |
|
593 | 157 |
top open |
158 |
[exEnd] |
|
295 | 159 |
|
160 |
||
161 |
||
876 | 162 |
change the handles level: |
593 | 163 |
[exBegin] |
164 |
|top p v1 v2 v3| |
|
295 | 165 |
|
593 | 166 |
top := StandardSystemView new. |
167 |
top extent:300@300. |
|
295 | 168 |
|
593 | 169 |
p := VariablePanel |
170 |
origin:0.0 @ 0.0 |
|
171 |
corner:1.0 @ 1.0 |
|
172 |
in:top. |
|
173 |
p orientation:#vertical. |
|
174 |
p handleLevel:-1. |
|
295 | 175 |
|
593 | 176 |
v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p. |
177 |
v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p. |
|
178 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
295 | 179 |
|
593 | 180 |
v1 viewBackground:(Color red). |
181 |
v2 viewBackground:(Color green). |
|
182 |
v3 viewBackground:(Color yellow). |
|
295 | 183 |
|
593 | 184 |
top open |
185 |
[exEnd] |
|
295 | 186 |
|
187 |
||
188 |
||
876 | 189 |
change the handles style to nil makes it invisible: |
593 | 190 |
[exBegin] |
191 |
|top p v1 v2 v3| |
|
397 | 192 |
|
593 | 193 |
top := StandardSystemView new. |
194 |
top extent:300@300. |
|
397 | 195 |
|
593 | 196 |
p := VariablePanel |
197 |
origin:0.0 @ 0.0 |
|
198 |
corner:1.0 @ 1.0 |
|
199 |
in:top. |
|
200 |
p orientation:#vertical. |
|
201 |
p handleStyle:nil. |
|
397 | 202 |
|
593 | 203 |
v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p. |
204 |
v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p. |
|
205 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
397 | 206 |
|
593 | 207 |
v1 viewBackground:(Color red). |
208 |
v2 viewBackground:(Color green). |
|
209 |
v3 viewBackground:(Color yellow). |
|
397 | 210 |
|
593 | 211 |
top open |
212 |
[exEnd] |
|
397 | 213 |
|
214 |
||
215 |
||
876 | 216 |
define your own handle (-bitmap): |
217 |
[exBegin] |
|
218 |
|top p v1 v2 v3| |
|
219 |
||
220 |
top := StandardSystemView new. |
|
221 |
top extent:300@300. |
|
222 |
||
223 |
p := VariablePanel |
|
224 |
origin:0.0 @ 0.0 |
|
225 |
corner:1.0 @ 1.0 |
|
226 |
in:top. |
|
227 |
p orientation:#vertical. |
|
228 |
p handleImage:(Image fromFile:'bitmaps/ScrollLt.8.xbm'). |
|
229 |
||
230 |
v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p. |
|
231 |
v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p. |
|
232 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
233 |
||
234 |
v1 viewBackground:(Color red). |
|
235 |
v2 viewBackground:(Color green). |
|
236 |
v3 viewBackground:(Color yellow). |
|
237 |
||
238 |
top open |
|
239 |
[exEnd] |
|
240 |
||
241 |
||
242 |
||
243 |
another handle-bitmap: |
|
244 |
[exBegin] |
|
245 |
|top p v1 v2 v3| |
|
246 |
||
247 |
top := StandardSystemView new. |
|
248 |
top extent:300@300. |
|
249 |
||
250 |
p := VariablePanel |
|
251 |
origin:0.0 @ 0.0 |
|
252 |
corner:1.0 @ 1.0 |
|
253 |
in:top. |
|
254 |
p orientation:#vertical. |
|
255 |
p handleImage:(Form width:9 |
|
256 |
height:11 |
|
257 |
fromArray:#( |
|
258 |
2r00000000 2r00000000 |
|
259 |
2r00001000 2r00000000 |
|
260 |
2r00011100 2r00000000 |
|
261 |
2r00111110 2r00000000 |
|
262 |
2r01111111 2r00000000 |
|
263 |
2r00000000 2r00000000 |
|
264 |
2r01111111 2r00000000 |
|
265 |
2r00111110 2r00000000 |
|
266 |
2r00011100 2r00000000 |
|
267 |
2r00001000 2r00000000 |
|
268 |
2r00000000 2r00000000 |
|
269 |
) |
|
270 |
). |
|
271 |
||
272 |
v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p. |
|
273 |
v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p. |
|
274 |
v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p. |
|
275 |
||
276 |
v1 viewBackground:(Color red). |
|
277 |
v2 viewBackground:(Color green). |
|
278 |
v3 viewBackground:(Color yellow). |
|
279 |
||
280 |
top open |
|
281 |
[exEnd] |
|
282 |
||
283 |
placing scrolled and unscrolled views into a variablePanel: |
|
593 | 284 |
[exBegin] |
285 |
|top p v1 v2 v3| |
|
295 | 286 |
|
593 | 287 |
top := StandardSystemView new. |
288 |
top extent:300@300. |
|
295 | 289 |
|
593 | 290 |
p := VariablePanel |
291 |
origin:0.0 @ 0.0 |
|
292 |
corner:1.0 @ 1.0 |
|
293 |
in:top. |
|
294 |
p orientation:#vertical. |
|
295 | 295 |
|
593 | 296 |
v1 := ScrollableView for:SelectionInListView in:p. |
297 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
298 |
v1 list:(FileDirectory directoryNamed:'/etc') contents. |
|
299 |
v1 action:[:selNr | |
|
300 |
|fullName stream text| |
|
301 |
fullName := '/etc/' , v1 selectionValue. |
|
302 |
stream := fullName asFilename readStream. |
|
303 |
stream notNil ifTrue:[ |
|
304 |
text := stream contents. |
|
305 |
v2 contents:text. |
|
306 |
v3 contents:text |
|
307 |
] |
|
308 |
]. |
|
295 | 309 |
|
593 | 310 |
v2 := TextView origin:0.0 @ 0.5 corner:1.0 @ 0.8 in:p. |
295 | 311 |
|
593 | 312 |
v3 := ScrollableView for:TextView in:p. |
313 |
v3 origin:0.0 @ 0.8 corner:1.0 @ 1.0. |
|
314 |
top open |
|
315 |
[exEnd] |
|
295 | 316 |
|
317 |
||
876 | 318 |
dynamically adding/removing views: |
593 | 319 |
[exBegin] |
320 |
|top p v1 v2 b| |
|
295 | 321 |
|
593 | 322 |
top := StandardSystemView new. |
323 |
top extent:300@300. |
|
295 | 324 |
|
593 | 325 |
b := Toggle label:'show' in:top. |
326 |
b showLamp:false. |
|
327 |
b origin:0.0 @ 0.0 corner:(1.0 @ 40). |
|
328 |
b action:[:state | |
|
329 |
state ifTrue:[ |
|
330 |
b label:'hide'. |
|
331 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
332 |
v2 := ScrollableView for:EditTextView. |
|
333 |
v2 origin:0.0 @ 0.5 corner:1.0 @ 1.0. |
|
334 |
v2 contents:'another text'. |
|
335 |
p addSubView:v2. |
|
336 |
v2 realize. |
|
337 |
] ifFalse:[ |
|
338 |
b label:'show'. |
|
339 |
v2 destroy. |
|
340 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 1.0 |
|
341 |
] |
|
342 |
]. |
|
295 | 343 |
|
593 | 344 |
p := VariablePanel |
345 |
origin:0.0 @ 0.0 |
|
346 |
corner:1.0 @ 1.0 |
|
347 |
in:top. |
|
348 |
p orientation:#vertical. |
|
349 |
p topInset:50. |
|
295 | 350 |
|
593 | 351 |
v1 := ScrollableView for:EditTextView in:p. |
352 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
353 |
v1 contents:'some text'. |
|
295 | 354 |
|
593 | 355 |
top open |
356 |
[exEnd] |
|
295 | 357 |
|
358 |
||
876 | 359 |
dynamically flipping orientation: |
295 | 360 |
Notice: you have to change the relative bounds of the subviews first. |
593 | 361 |
[exBegin] |
362 |
|top p v1 v2 b| |
|
295 | 363 |
|
593 | 364 |
top := StandardSystemView new. |
365 |
top extent:300@300. |
|
295 | 366 |
|
593 | 367 |
b := Toggle label:'flip' in:top. |
368 |
b showLamp:false. |
|
369 |
b origin:0.0 @ 0.0 corner:(1.0 @ 40). |
|
370 |
b action:[:state | |
|
371 |
state ifTrue:[ |
|
372 |
v1 origin:0.0 @ 0.0 corner:0.5 @ 1.0. |
|
373 |
v2 origin:0.5 @ 0.0 corner:1.0 @ 1.0. |
|
374 |
p orientation:#horizontal. |
|
375 |
] ifFalse:[ |
|
376 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
377 |
v2 origin:0.0 @ 0.5 corner:1.0 @ 1.0. |
|
378 |
p orientation:#vertical. |
|
379 |
]. |
|
380 |
]. |
|
295 | 381 |
|
593 | 382 |
p := VariablePanel |
383 |
origin:0.0 @ 0.0 |
|
384 |
corner:1.0 @ 1.0 |
|
385 |
in:top. |
|
386 |
p orientation:#vertical. |
|
387 |
p topInset:50. |
|
295 | 388 |
|
593 | 389 |
v1 := ScrollableView for:EditTextView in:p. |
390 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
|
391 |
v1 contents:'some text'. |
|
295 | 392 |
|
593 | 393 |
v2 := ScrollableView for:EditTextView in:p. |
394 |
v2 origin:0.0 @ 0.5 corner:1.0 @ 1.0. |
|
395 |
v2 contents:'another text'. |
|
295 | 396 |
|
593 | 397 |
top open |
398 |
[exEnd] |
|
295 | 399 |
|
400 |
||
876 | 401 |
combining fix-size with variable size: |
295 | 402 |
(need 3 extra frame-views to place the extra labels into) |
593 | 403 |
[exBegin] |
404 |
|top p v1 l1 v2 l2 v3 l3 f1 f2 f3| |
|
295 | 405 |
|
593 | 406 |
top := StandardSystemView new. |
407 |
top extent:300@300. |
|
295 | 408 |
|
593 | 409 |
p := VariablePanel |
410 |
origin:0.0 @ 0.0 |
|
411 |
corner:1.0 @ 1.0 |
|
412 |
in:top. |
|
295 | 413 |
|
874 | 414 |
p orientation:#vertical. |
415 |
||
416 |
f1 := View origin:0.0@0.0 corner:1.0@0.3 in:p. |
|
417 |
f2 := View origin:0.0@0.3 corner:1.0@0.6 in:p. |
|
418 |
f3 := View origin:0.0@0.6 corner:1.0@1.0 in:p. |
|
295 | 419 |
|
593 | 420 |
v1 := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:f1. |
421 |
v2 := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:f2. |
|
422 |
v3 := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:f3. |
|
295 | 423 |
|
593 | 424 |
l1 := Label label:'sub1' in:f1. |
425 |
l2 := Label label:'sub2' in:f2. |
|
426 |
l3 := Label label:'sub3' in:f3. |
|
295 | 427 |
|
593 | 428 |
l1 origin:0.0 @ 0.0 corner:1.0 @ 0.0 ; |
429 |
bottomInset:(l1 preferredExtent y negated). |
|
430 |
l2 origin:0.0 @ 0.0 corner:1.0 @ 0.0 ; |
|
431 |
bottomInset:(l2 preferredExtent y negated). |
|
432 |
l3 origin:0.0 @ 0.0 corner:1.0 @ 0.0 ; |
|
433 |
bottomInset:(l3 preferredExtent y negated). |
|
295 | 434 |
|
593 | 435 |
v1 topInset:(l1 preferredExtent y); level:-1. |
436 |
v2 topInset:(l2 preferredExtent y); level:-1. |
|
437 |
v3 topInset:(l3 preferredExtent y); level:-1. |
|
295 | 438 |
|
593 | 439 |
v1 viewBackground:(Color red). |
440 |
v2 viewBackground:(Color green). |
|
441 |
v3 viewBackground:(Color yellow). |
|
295 | 442 |
|
874 | 443 |
top open |
444 |
[exEnd] |
|
445 |
||
446 |
VerticalPansels allow a label to be associated with the |
|
447 |
handles; this looks much like the above, but is slightly |
|
448 |
more compact. Notice, no label can be placed above the first |
|
449 |
view - it has no handle. |
|
450 |
[exBegin] |
|
451 |
|top p v1 v2 v3| |
|
452 |
||
453 |
top := StandardSystemView new. |
|
454 |
top extent:300@300. |
|
455 |
||
456 |
p := VariablePanel |
|
457 |
origin:0.0 @ 0.0 |
|
458 |
corner:1.0 @ 1.0 |
|
459 |
in:top. |
|
460 |
||
593 | 461 |
p orientation:#vertical. |
874 | 462 |
p handleLabels:#('ignored' 'sub2' 'sub3'). |
463 |
||
464 |
v1 := View origin:0.0@0.0 corner:1.0@0.3 in:p. |
|
465 |
v2 := View origin:0.0@0.3 corner:1.0@0.6 in:p. |
|
466 |
v3 := View origin:0.0@0.6 corner:1.0@1.0 in:p. |
|
467 |
||
468 |
v1 viewBackground:(Color red). |
|
469 |
v2 viewBackground:(Color green). |
|
470 |
v3 viewBackground:(Color yellow). |
|
471 |
||
593 | 472 |
top open |
473 |
[exEnd] |
|
295 | 474 |
|
874 | 475 |
handle labels can be more than strings .... |
476 |
(however, they should have about the same height, since |
|
477 |
the largest defines heights of all bars; |
|
478 |
retry the example below with a larger bitmap image ...) |
|
479 |
[exBegin] |
|
480 |
|top e p v1 v2 v3| |
|
481 |
||
482 |
top := StandardSystemView new. |
|
483 |
top extent:300@300. |
|
484 |
||
485 |
p := VariablePanel |
|
486 |
origin:0.0 @ 0.0 |
|
487 |
corner:1.0 @ 1.0 |
|
488 |
in:top. |
|
489 |
||
490 |
p orientation:#vertical. |
|
491 |
e := Array with:#bold |
|
492 |
with:#color->Color red. |
|
493 |
||
494 |
p handleLabels:(Array with:nil |
|
495 |
with:('bold and red' asText emphasizeAllWith:e) |
|
496 |
with:(Image fromFile:'ScrollRt.xbm')). |
|
497 |
||
498 |
v1 := View origin:0.0@0.0 corner:1.0@0.3 in:p. |
|
499 |
v2 := View origin:0.0@0.3 corner:1.0@0.6 in:p. |
|
500 |
v3 := View origin:0.0@0.6 corner:1.0@1.0 in:p. |
|
501 |
||
502 |
v1 viewBackground:(Color red). |
|
503 |
v2 viewBackground:(Color green). |
|
504 |
v3 viewBackground:(Color yellow). |
|
505 |
||
506 |
top open |
|
507 |
[exEnd] |
|
508 |
||
509 |
||
295 | 510 |
|
511 |
BAD EXAMPLE (wrong relative sizes - repaired on handle move): |
|
593 | 512 |
[exBegin] |
513 |
|top p v1 v2 v3| |
|
295 | 514 |
|
593 | 515 |
top := StandardSystemView new. |
516 |
top extent:300@300. |
|
295 | 517 |
|
593 | 518 |
p := VariablePanel |
519 |
origin:0.0 @ 0.0 |
|
520 |
corner:1.0 @ 1.0 |
|
521 |
in:top. |
|
522 |
p orientation:#vertical. |
|
295 | 523 |
|
593 | 524 |
v1 := View origin:0.0 @ 0.0 corner:1.0 @ (1/4) in:p. |
525 |
v2 := View origin:0.0 @ (1/2) corner:1.0 @ (3/4) in:p. |
|
526 |
v3 := View origin:0.0 @ (3/4) corner:1.0 @ 1.0 in:p. |
|
295 | 527 |
|
593 | 528 |
v1 viewBackground:(Color red). |
529 |
v2 viewBackground:(Color green). |
|
530 |
v3 viewBackground:(Color yellow). |
|
295 | 531 |
|
593 | 532 |
top open |
533 |
[exEnd] |
|
295 | 534 |
" |
535 |
! ! |
|
536 |
||
871 | 537 |
!VariablePanel class methodsFor:'defaults'! |
295 | 538 |
|
539 |
lightFormOn:aDisplay |
|
540 |
"use same handle as Scroller" |
|
541 |
||
542 |
^ Scroller handleLightFormOn:aDisplay |
|
543 |
! |
|
544 |
||
545 |
shadowFormOn:aDisplay |
|
546 |
"use same handle as Scroller" |
|
547 |
||
548 |
^ Scroller handleShadowFormOn:aDisplay |
|
549 |
! |
|
550 |
||
551 |
updateStyleCache |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
552 |
"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
|
553 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
554 |
<resource: #style (#variablePanelShowHandle #variablePanelHandleStyle |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
555 |
#variablePanelHandlePosition #variablePanelHandleLevel |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
556 |
#variablePanelTrackingLine |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
557 |
#variablePanelSeparatingLine #variablePanelHandleColor)> |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
558 |
|
295 | 559 |
DefaultShowHandle := StyleSheet at:'variablePanelShowHandle' default:true. |
560 |
DefaultHandleStyle := StyleSheet at:'variablePanelHandleStyle'. |
|
561 |
DefaultHandlePosition := StyleSheet at:'variablePanelHandlePosition' default:#right. |
|
562 |
DefaultHandleLevel := StyleSheet at:'variablePanelHandleLevel' default:2. |
|
563 |
DefaultTrackingLine := StyleSheet at:'variablePanelTrackingLine' default:false. |
|
564 |
DefaultSeparatingLine := StyleSheet at:'variablePanelSeparatingLine' default:false. |
|
565 |
DefaultHandleColor := StyleSheet colorAt:'variablePanelHandleColor' default:Black. |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
566 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
567 |
"Modified: 1.3.1996 / 13:51:24 / cg" |
295 | 568 |
! ! |
569 |
||
570 |
!VariablePanel methodsFor:'accessing'! |
|
571 |
||
572 |
addSubView:aView |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
573 |
"a view is added; adjust other subviews sizes" |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
574 |
|
295 | 575 |
super addSubView:aView. |
576 |
realized ifTrue:[ |
|
397 | 577 |
self resizeSubviews. |
295 | 578 |
] |
579 |
||
580 |
"Created: 17.1.1996 / 22:41:00 / cg" |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
581 |
"Modified: 24.2.1996 / 19:05:05 / cg" |
295 | 582 |
! |
583 |
||
584 |
orientation |
|
485 | 585 |
"return my orientation; either #horizontal or #vertical" |
586 |
||
295 | 587 |
^ orientation |
485 | 588 |
|
589 |
"Modified: 6.3.1996 / 18:08:45 / cg" |
|
295 | 590 |
! |
591 |
||
592 |
orientation:aSymbol |
|
485 | 593 |
"change my orientation; aSymbol must be one of #horizontal or #vertical. |
594 |
Changing implies a resize of my subViews." |
|
595 |
||
596 |
aSymbol ~~ orientation ifTrue:[ |
|
597 |
orientation := aSymbol. |
|
598 |
self initCursor. |
|
599 |
self anyNonRelativeSubviews ifTrue:[ |
|
600 |
self setupSubviews |
|
601 |
]. |
|
602 |
shown ifTrue:[ |
|
603 |
self cursor:cursor. |
|
604 |
self sizeChanged:nil. |
|
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
605 |
self invalidate. |
485 | 606 |
] |
295 | 607 |
] |
485 | 608 |
|
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
609 |
"Modified: 29.5.1996 / 16:22:35 / cg" |
295 | 610 |
! |
611 |
||
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
612 |
removeSubView:aView |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
613 |
"a view is removed; adjust other subviews sizes" |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
614 |
|
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
615 |
super removeSubView:aView. |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
616 |
shown ifTrue:[ |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
617 |
(superView isNil or:[superView shown]) ifTrue:[ |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
618 |
self setupSubviews |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
619 |
] |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
620 |
] |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
621 |
! ! |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
622 |
|
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
623 |
!VariablePanel methodsFor:'accessing-look'! |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
624 |
|
295 | 625 |
barHeight |
626 |
"return the height of the separating bar" |
|
627 |
||
628 |
^ barHeight |
|
629 |
! |
|
630 |
||
631 |
barHeight:nPixel |
|
632 |
"set the height of the separating bar" |
|
633 |
||
634 |
barHeight := nPixel. |
|
635 |
||
636 |
"if screen is very low-res, make certain bar is visible and catchable" |
|
637 |
(barHeight < 4) ifTrue:[ |
|
876 | 638 |
barHeight := 4 |
295 | 639 |
]. |
640 |
||
876 | 641 |
"make it even, so spacing is equally spreadable among subviews" |
295 | 642 |
barHeight odd ifTrue:[ |
876 | 643 |
barHeight := barHeight + 1 |
295 | 644 |
] |
876 | 645 |
|
646 |
"Modified: 7.11.1996 / 20:07:11 / cg" |
|
647 |
! |
|
648 |
||
649 |
handleImage:aBitmapOrImage |
|
650 |
"define the handles image" |
|
651 |
||
652 |
shadowForm := aBitmapOrImage. |
|
653 |
lightForm := nil. |
|
654 |
self computeBarHeight. |
|
655 |
||
656 |
"Created: 7.11.1996 / 20:21:10 / cg" |
|
657 |
"Modified: 7.11.1996 / 20:27:22 / cg" |
|
295 | 658 |
! |
659 |
||
871 | 660 |
handleLabels:aCollectionOfLabels |
661 |
orientation == #horizontal ifTrue:[ |
|
662 |
self error:'not allowed for horizontal panels' |
|
663 |
]. |
|
664 |
||
665 |
handleLabels := aCollectionOfLabels. |
|
666 |
self computeBarHeight. |
|
667 |
self resizeSubviews. |
|
668 |
||
669 |
! |
|
670 |
||
295 | 671 |
handleLevel:aNumber |
672 |
"define the 3D level of the handle (only with some styles). |
|
673 |
Normally, this is defined via styleSheet files, but this entry allows |
|
674 |
individual views to be manipulated." |
|
675 |
||
676 |
handleLevel := aNumber |
|
677 |
! |
|
678 |
||
679 |
handlePosition |
|
680 |
"return the position of the handle" |
|
681 |
||
682 |
^ handlePosition |
|
683 |
! |
|
684 |
||
685 |
handlePosition:aSymbol |
|
686 |
"define the position of the handle; the argument aSymbol |
|
687 |
may be one of #left, #right or #center" |
|
688 |
||
689 |
handlePosition := aSymbol |
|
690 |
! |
|
691 |
||
876 | 692 |
handleShadowImage:shadowImage lightImage:lightImage |
693 |
"define the handles image; both shadow and light parts" |
|
694 |
||
695 |
shadowForm := shadowImage. |
|
696 |
lightForm := lightImage. |
|
697 |
self computeBarHeight. |
|
698 |
||
699 |
"Created: 7.11.1996 / 20:21:51 / cg" |
|
700 |
"Modified: 7.11.1996 / 20:27:26 / cg" |
|
701 |
! |
|
702 |
||
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
703 |
handleStyle:styleSymbol |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
704 |
"define the style of the handle; |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
705 |
styleSymbol may be #motif to draw a little knob or |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
706 |
anything else to draw scrollBars handleForm. |
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
707 |
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
|
708 |
individual views to be manipulated." |
295 | 709 |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
710 |
(styleSymbol ~~ handleStyle) ifTrue:[ |
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
711 |
handleStyle := styleSymbol. |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
712 |
handleStyle == #next ifTrue:[ |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
713 |
shadowForm := self class shadowFormOn:device. |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
714 |
lightForm := self class lightFormOn:device. |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
715 |
] ifFalse:[ |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
716 |
shadowForm := lightForm := nil |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
717 |
]. |
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
718 |
|
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
719 |
shadowForm notNil ifTrue:[ |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
720 |
(self is3D and:[handleStyle ~~ #motif]) ifTrue:[ |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
721 |
self barHeight:(shadowForm height + 2). |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
722 |
barWidth := shadowForm width |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
723 |
] |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
724 |
]. |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
725 |
shown ifTrue:[ |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
726 |
self resizeSubviews. |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
727 |
self invalidate |
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
728 |
] |
295 | 729 |
] |
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
730 |
|
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
731 |
"Created: 24.2.1996 / 19:04:07 / cg" |
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
732 |
"Modified: 29.5.1996 / 16:22:24 / cg" |
295 | 733 |
! |
734 |
||
735 |
style:styleSymbol |
|
736 |
"define the style of the handle; |
|
737 |
styleSymbol may be #motif to draw a little knob or |
|
738 |
anything else to draw scrollBars handleForm. |
|
739 |
Normally, this is defined via styleSheet files, but this entry allows |
|
740 |
individual views to be manipulated." |
|
741 |
||
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
742 |
self handleStyle:styleSymbol |
295 | 743 |
|
395
db172e0f3d56
renamed #style: to #handleStyle:
Claus Gittinger <cg@exept.de>
parents:
300
diff
changeset
|
744 |
"Modified: 24.2.1996 / 19:04:19 / cg" |
295 | 745 |
! ! |
746 |
||
747 |
!VariablePanel methodsFor:'drawing'! |
|
748 |
||
871 | 749 |
drawHandle:hIndex atX:hx y:hy |
295 | 750 |
"draw a single handle at hx/hy" |
751 |
||
876 | 752 |
|h w x y m lbl maxKnob| |
295 | 753 |
|
396
973d4a9fa32c
setting handleStyle to nil disables handleDrawing
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
754 |
handleStyle isNil ifTrue:[^ self]. |
973d4a9fa32c
setting handleStyle to nil disables handleDrawing
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
755 |
|
871 | 756 |
|
295 | 757 |
shadowForm notNil ifTrue:[ |
871 | 758 |
h := shadowForm height. |
759 |
w := shadowForm width . |
|
876 | 760 |
maxKnob := h min:barHeight. |
295 | 761 |
] ifFalse:[ |
876 | 762 |
maxKnob := knobHeight min: barHeight. |
763 |
maxKnob := maxKnob max:4. |
|
764 |
w := h := maxKnob - 4. |
|
295 | 765 |
]. |
766 |
||
767 |
self paint:viewBackground. |
|
768 |
orientation == #vertical ifTrue:[ |
|
871 | 769 |
self fillRectangleX:margin y:hy |
770 |
width:(width - margin - margin) |
|
771 |
height:barHeight. |
|
772 |
||
773 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
|
876 | 774 |
m := (maxKnob - h) // 2. |
871 | 775 |
|
776 |
shadowForm isNil ifTrue:[ |
|
876 | 777 |
|
778 |
y := hy + (barHeight // 2). "/ center of the bar |
|
295 | 779 |
|
871 | 780 |
separatingLine ifTrue:[ |
781 |
self paint:shadowColor. |
|
782 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
783 |
y := y + 1. |
|
784 |
self paint:lightColor. |
|
785 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
786 |
]. |
|
787 |
self paint:viewBackground. |
|
788 |
self fillRectangleX:(hx - barWidth) y:hy |
|
789 |
width:(barWidth + barWidth) |
|
790 |
height:h. |
|
295 | 791 |
|
871 | 792 |
handleStyle == #line ifTrue:[ |
793 |
self paint:handleColor. |
|
794 |
self displayLineFromX:hx - barWidth y:y toX:hx + barWidth y:y |
|
795 |
] ifFalse:[ |
|
796 |
y := hy. |
|
797 |
handleStyle == #st80 ifTrue:[ |
|
798 |
y := y - 1 |
|
799 |
]. |
|
876 | 800 |
|
871 | 801 |
self drawEdgesForX:(hx - barWidth) |
802 |
y:(y + m) |
|
803 |
width:(barWidth + barWidth) |
|
804 |
height:h |
|
805 |
level:handleLevel. |
|
295 | 806 |
|
871 | 807 |
handleStyle == #iris ifTrue:[ |
808 |
self paint:handleColor. |
|
809 |
self fillDeviceRectangleX:(hx - barWidth + 2) |
|
810 |
y:(y + m + 2) |
|
811 |
width:(barWidth + barWidth - 4) |
|
812 |
height:h - 4 |
|
813 |
] |
|
814 |
]. |
|
815 |
] ifFalse:[ |
|
816 |
y := hy. |
|
817 |
self drawHandleFormAtX:hx y:(y + m) |
|
818 |
]. |
|
876 | 819 |
|
871 | 820 |
handleStyle == #st80 ifTrue:[ |
821 |
y := hy - 1. |
|
822 |
self paint:lightColor. |
|
823 |
self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y. |
|
824 |
self displayLineFromX:0 y:hy toX:0 y:(hy + knobHeight - 1). |
|
825 |
y := hy + knobHeight - 2. |
|
826 |
self paint:shadowColor. |
|
827 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
828 |
"uncomment the -1 if you dont like the notch at the right end" |
|
829 |
" VVV" |
|
830 |
self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + knobHeight - 1). |
|
831 |
]. |
|
832 |
] ifFalse:[ |
|
833 |
y := hy + barHeight - 1. |
|
834 |
self paint:handleColor. |
|
835 |
separatingLine ifTrue:[ |
|
836 |
self displayLineFromX:0 y:hy+1 toX:width y:hy+1. |
|
837 |
self displayLineFromX:0 y:y toX:width y:y. |
|
838 |
]. |
|
839 |
self fillRectangleX:hx y:hy width:barWidth height:barHeight |
|
840 |
]. |
|
295 | 841 |
|
871 | 842 |
lbl := self handleLabelAt:hIndex. |
843 |
lbl notNil ifTrue:[ |
|
844 |
hIndex ~~ 1 ifTrue:[ |
|
845 |
self paint:Color black. |
|
874 | 846 |
lbl isImageOrForm ifTrue:[ |
847 |
lbl displayOn:self x:margin y:hy |
|
848 |
] ifFalse:[ |
|
849 |
lbl displayOn:self x:margin y:hy + font ascent + 1 |
|
850 |
] |
|
871 | 851 |
] |
852 |
]. |
|
853 |
||
295 | 854 |
] ifFalse:[ |
871 | 855 |
self fillRectangleX:hx y:margin |
856 |
width:barHeight |
|
857 |
height:(height - margin - margin). |
|
876 | 858 |
|
871 | 859 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
860 |
m := (barHeight - w) // 2. |
|
861 |
shadowForm isNil ifTrue:[ |
|
862 |
x := hx + (barHeight // 2). |
|
863 |
separatingLine ifTrue:[ |
|
864 |
self paint:shadowColor. |
|
865 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
866 |
x := x + 1. |
|
867 |
self paint:lightColor. |
|
868 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
869 |
]. |
|
870 |
self paint:viewBackground. |
|
871 |
self fillRectangleX:hx y:(hy - barWidth) |
|
872 |
width:w |
|
873 |
height:(barWidth + barWidth). |
|
295 | 874 |
|
871 | 875 |
handleStyle == #line ifTrue:[ |
876 |
self paint:handleColor. |
|
877 |
self displayLineFromX:x y:hy - barWidth toX:x y:hy + barWidth. |
|
878 |
] ifFalse:[ |
|
879 |
x := hx. |
|
880 |
handleStyle == #st80 ifTrue:[ |
|
881 |
x := x - 1. |
|
882 |
]. |
|
883 |
self drawEdgesForX:(x + m) |
|
884 |
y:(hy - barWidth) |
|
885 |
width:w |
|
886 |
height:(barWidth + barWidth) |
|
887 |
level:handleLevel. |
|
888 |
handleStyle == #iris ifTrue:[ |
|
889 |
self paint:handleColor. |
|
890 |
self fillDeviceRectangleX:(x + m + 2) |
|
891 |
y:(hy - barWidth + 2) |
|
892 |
width:w - 4 |
|
893 |
height:(barWidth + barWidth - 4) |
|
894 |
]. |
|
895 |
] |
|
896 |
] ifFalse:[ |
|
897 |
x := hx. |
|
898 |
self drawHandleFormAtX:(x + m) y:hy |
|
899 |
]. |
|
900 |
handleStyle == #st80 ifTrue:[ |
|
901 |
x := hx - 1. |
|
902 |
self paint:lightColor. |
|
903 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
904 |
self displayLineFromX:hx y:0 toX:(hx + barHeight - 1) y:0. |
|
905 |
x := hx + barHeight - 2. |
|
906 |
self paint:shadowColor. |
|
907 |
self displayLineFromX:x y:margin toX:x y:(height - margin). |
|
908 |
"uncomment the -1 if you dont like the notch at the bottom end" |
|
909 |
" VVV" |
|
910 |
self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeight - 1) y:height-1. |
|
911 |
]. |
|
912 |
] ifFalse:[ |
|
913 |
x := hx + barHeight - 1. |
|
914 |
self paint:handleColor. |
|
915 |
separatingLine ifTrue:[ |
|
916 |
self displayLineFromX:hx+1 y:0 toX:hx+1 y:height. |
|
917 |
self displayLineFromX:x y:0 toX:x y:height. |
|
918 |
]. |
|
919 |
self fillRectangleX:hx y:hy width:barHeight height:barWidth |
|
920 |
] |
|
295 | 921 |
]. |
922 |
||
876 | 923 |
"Modified: 7.11.1996 / 20:26:31 / cg" |
295 | 924 |
! |
925 |
||
926 |
drawHandleFormAtX:hx y:hy |
|
927 |
"draw a handles bitmap at hx/hy" |
|
928 |
||
876 | 929 |
shadowForm notNil ifTrue:[ |
930 |
self paint:shadowColor. |
|
931 |
self displayForm:shadowForm x:hx y:hy. |
|
932 |
]. |
|
933 |
lightForm notNil ifTrue:[ |
|
934 |
self paint:lightColor. |
|
935 |
self displayForm:lightForm x:hx y:hy. |
|
936 |
]. |
|
295 | 937 |
self paint:viewBackground |
876 | 938 |
|
939 |
"Modified: 7.11.1996 / 20:25:33 / cg" |
|
295 | 940 |
! |
941 |
||
942 |
invertHandleBarAtX:hx y:hy |
|
943 |
self noClipByChildren. |
|
944 |
self xoring:[ |
|
945 |
|y x| |
|
946 |
||
947 |
orientation == #vertical ifTrue:[ |
|
948 |
trackLine ifTrue:[ |
|
949 |
y := hy + (barHeight // 2). |
|
950 |
self displayLineFromX:0 y:y toX:width y:y. |
|
951 |
] ifFalse:[ |
|
952 |
self fillRectangleX:0 y:hy width:width height:barHeight |
|
953 |
] |
|
954 |
] ifFalse:[ |
|
955 |
trackLine ifTrue:[ |
|
956 |
x := hx + (barHeight // 2). |
|
957 |
self displayLineFromX:x y:0 toX:x y:height. |
|
958 |
] ifFalse:[ |
|
959 |
self fillRectangleX:hx y:0 width:barHeight height:height |
|
960 |
] |
|
961 |
] |
|
962 |
]. |
|
963 |
self clipByChildren. |
|
964 |
! |
|
965 |
||
966 |
lockRedraw |
|
967 |
redrawLocked := true |
|
968 |
! |
|
969 |
||
970 |
redraw |
|
971 |
"redraw all of the handles" |
|
972 |
||
973 |
redrawLocked ~~ true ifTrue:[ |
|
974 |
self redrawHandlesFrom:1 to:(subViews size) |
|
975 |
] |
|
976 |
! |
|
977 |
||
978 |
redrawHandlesFrom:start to:stop |
|
979 |
"redraw some handles" |
|
980 |
||
981 |
subViews notNil ifTrue:[ |
|
871 | 982 |
showHandle ifTrue:[ |
983 |
self handleOriginsWithIndexFrom:start to:stop do:[:hPoint :hIndex | |
|
984 |
self drawHandle:hIndex atX:(hPoint x) y:(hPoint y) |
|
985 |
]. |
|
986 |
] |
|
295 | 987 |
] |
988 |
! |
|
989 |
||
990 |
unlockRedraw |
|
991 |
redrawLocked := false |
|
992 |
! ! |
|
993 |
||
994 |
!VariablePanel methodsFor:'event handling'! |
|
995 |
||
996 |
sizeChanged:how |
|
997 |
"my size has changed; resize my subviews" |
|
998 |
||
999 |
shown ifTrue:[ |
|
1000 |
(how == #smaller) ifTrue:[ |
|
1001 |
self resizeSubviews |
|
1002 |
] ifFalse:[ |
|
1003 |
"/ |
|
1004 |
"/ do it in reverse order, to avoid some redraws |
|
1005 |
"/ |
|
1006 |
self resizeSubviewsFrom:(subViews size) to:1 |
|
1007 |
] |
|
1008 |
]. |
|
1009 |
self changed:#sizeOfView with:how. |
|
1010 |
! ! |
|
1011 |
||
1012 |
!VariablePanel methodsFor:'initializing'! |
|
1013 |
||
871 | 1014 |
computeBarHeight |
1015 |
|bH h| |
|
1016 |
||
876 | 1017 |
shadowForm notNil ifTrue:[ |
871 | 1018 |
bH := shadowForm height + 2. |
1019 |
] ifFalse:[ |
|
1020 |
self is3D ifTrue:[ |
|
1021 |
h := 3 |
|
1022 |
] ifFalse:[ |
|
1023 |
h := 2 |
|
1024 |
]. |
|
1025 |
bH := (h * device verticalPixelPerMillimeter) rounded. |
|
1026 |
]. |
|
876 | 1027 |
self barHeight:bH. |
871 | 1028 |
knobHeight := bH. |
1029 |
||
1030 |
handleLabels notNil ifTrue:[ |
|
1031 |
font := font on:device. |
|
1032 |
bH := handleLabels inject:bH into:[:maxSoFar :thisLabel | |
|
874 | 1033 |
thisLabel isNil ifTrue:[ |
1034 |
maxSoFar |
|
1035 |
] ifFalse:[ |
|
1036 |
maxSoFar max:(thisLabel heightOn:self) |
|
1037 |
] |
|
1038 |
]. |
|
871 | 1039 |
bH := bH + font descent - 1 |
1040 |
]. |
|
1041 |
||
1042 |
self barHeight:bH. |
|
1043 |
||
876 | 1044 |
"Modified: 7.11.1996 / 20:27:13 / cg" |
871 | 1045 |
! |
1046 |
||
295 | 1047 |
defaultControllerClass |
1048 |
^ VariablePanelController |
|
1049 |
! |
|
1050 |
||
1051 |
fixSize |
|
1052 |
extentChanged ifTrue:[ |
|
1053 |
super fixSize. |
|
1054 |
self resizeSubviews |
|
1055 |
] ifFalse:[ |
|
1056 |
super fixSize |
|
1057 |
] |
|
1058 |
! |
|
1059 |
||
1060 |
initCursor |
|
1061 |
"set the cursor - a double arrow" |
|
1062 |
||
1063 |
orientation == #vertical ifTrue:[ |
|
1064 |
DefaultVCursor notNil ifTrue:[ |
|
1065 |
cursor := DefaultVCursor |
|
1066 |
] ifFalse:[ |
|
1067 |
cursor := Cursor sourceForm:(Form fromFile:'VVPanel.xbm') |
|
1068 |
maskForm:(Form fromFile:'VVPanel_m.xbm') |
|
1069 |
hotX:8 |
|
1070 |
hotY:8. |
|
1071 |
" |
|
1072 |
if bitmaps are not available, use a standard cursor |
|
1073 |
" |
|
1074 |
cursor isNil ifTrue:[ |
|
1075 |
"which one looks better ?" |
|
1076 |
cursor := Cursor upDownArrow |
|
1077 |
"cursor := Cursor upLimitArrow" |
|
1078 |
]. |
|
1079 |
DefaultVCursor := cursor |
|
1080 |
] |
|
1081 |
] ifFalse:[ |
|
1082 |
DefaultHCursor notNil ifTrue:[ |
|
1083 |
cursor := DefaultHCursor |
|
1084 |
] ifFalse:[ |
|
1085 |
cursor := Cursor sourceForm:(Form fromFile:'VHPanel.xbm') |
|
1086 |
maskForm:(Form fromFile:'VHPanel_m.xbm') |
|
1087 |
hotX:8 |
|
1088 |
hotY:8. |
|
1089 |
" |
|
1090 |
if bitmaps are not available, use a standard cursor |
|
1091 |
" |
|
1092 |
cursor isNil ifTrue:[ |
|
1093 |
"which one looks better ?" |
|
1094 |
cursor := Cursor leftRightArrow |
|
1095 |
"cursor := Cursor leftLimitArrow" |
|
1096 |
]. |
|
1097 |
DefaultHCursor := cursor |
|
1098 |
] |
|
1099 |
] |
|
1100 |
! |
|
1101 |
||
1102 |
initStyle |
|
871 | 1103 |
|mm| |
295 | 1104 |
|
1105 |
super initStyle. |
|
1106 |
||
1107 |
handleColor := DefaultHandleColor on:device. |
|
1108 |
||
1109 |
DefaultHandleStyle isNil ifTrue:[ |
|
496 | 1110 |
handleStyle := styleSheet name |
295 | 1111 |
] ifFalse:[ |
496 | 1112 |
handleStyle := DefaultHandleStyle |
295 | 1113 |
]. |
1114 |
||
496 | 1115 |
handleLevel := DefaultHandleLevel. |
1116 |
showHandle := DefaultShowHandle. |
|
295 | 1117 |
handlePosition := DefaultHandlePosition. |
1118 |
trackLine := DefaultTrackingLine. |
|
1119 |
separatingLine := DefaultSeparatingLine. |
|
1120 |
||
496 | 1121 |
handleStyle == #next ifTrue:[ |
1122 |
shadowForm := self class shadowFormOn:device. |
|
1123 |
lightForm := self class lightFormOn:device. |
|
1124 |
||
1125 |
barWidth := shadowForm width. |
|
295 | 1126 |
] ifFalse:[ |
496 | 1127 |
shadowForm := lightForm := nil. |
1128 |
||
1129 |
mm := device verticalPixelPerMillimeter. |
|
1130 |
barWidth := (2 * mm) rounded. "motif style width" |
|
295 | 1131 |
]. |
871 | 1132 |
self computeBarHeight. |
496 | 1133 |
|
295 | 1134 |
handleStyle == #mswindows ifTrue:[ |
496 | 1135 |
barWidth := (ArrowButton new direction:#up) width + 1 |
295 | 1136 |
]. |
496 | 1137 |
|
1138 |
"Modified: 8.3.1996 / 11:51:59 / cg" |
|
295 | 1139 |
! |
1140 |
||
1141 |
initialize |
|
496 | 1142 |
orientation isNil ifTrue:[orientation := #vertical]. |
295 | 1143 |
super initialize. |
496 | 1144 |
|
1145 |
"Modified: 7.3.1996 / 14:08:25 / cg" |
|
295 | 1146 |
! ! |
1147 |
||
1148 |
!VariablePanel methodsFor:'private'! |
|
1149 |
||
1150 |
anyNonRelativeSubviews |
|
1151 |
"return true, if any of my subviews has no relative origin/extent" |
|
1152 |
||
1153 |
1 to:(subViews size) do:[:index | |
|
1154 |
|view| |
|
1155 |
||
1156 |
view := subViews at:index. |
|
1157 |
view relativeCorner isNil ifTrue:[^ true]. |
|
1158 |
view relativeOrigin isNil ifTrue:[^ true] |
|
1159 |
]. |
|
1160 |
^ false |
|
1161 |
! |
|
1162 |
||
871 | 1163 |
handleLabelAt:hIndex |
1164 |
handleLabels notNil ifTrue:[ |
|
1165 |
^ handleLabels at:hIndex ifAbsent:nil |
|
1166 |
]. |
|
1167 |
^ nil |
|
1168 |
! |
|
1169 |
||
1170 |
handleOriginsWithIndexDo:aBlock |
|
295 | 1171 |
"evaluate the argument block for every handle-origin" |
1172 |
||
871 | 1173 |
self handleOriginsWithIndexFrom:1 to:(subViews size) do:aBlock |
295 | 1174 |
! |
1175 |
||
871 | 1176 |
handleOriginsWithIndexFrom:start to:stop do:aBlock |
295 | 1177 |
"evaluate the argument block for some handle-origins" |
1178 |
||
1179 |
|x y hw hh hDelta vDelta |
|
1180 |
first "{ Class: SmallInteger }" |
|
1181 |
last "{ Class: SmallInteger }"| |
|
1182 |
||
1183 |
subViews notNil ifTrue:[ |
|
871 | 1184 |
shadowForm notNil ifTrue:[ |
1185 |
hw := shadowForm width. |
|
1186 |
hh := shadowForm height. |
|
1187 |
] ifFalse:[ |
|
1188 |
hw := hh := barWidth |
|
1189 |
]. |
|
295 | 1190 |
|
871 | 1191 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
1192 |
hDelta := barWidth // 2. |
|
1193 |
vDelta := barWidth // 2. |
|
1194 |
] ifFalse:[ |
|
1195 |
hDelta := vDelta := 0 |
|
1196 |
]. |
|
295 | 1197 |
|
871 | 1198 |
(handlePosition == #left) ifTrue:[ |
1199 |
x := hDelta. |
|
1200 |
y := vDelta |
|
1201 |
] ifFalse:[ |
|
1202 |
(handlePosition == #right) ifTrue:[ |
|
1203 |
x := width - hw - margin - hDelta. |
|
1204 |
y := height - hh - margin - vDelta. |
|
1205 |
] ifFalse:[ |
|
1206 |
x := width - barWidth // 2. |
|
1207 |
y := height - barWidth // 2 |
|
1208 |
] |
|
1209 |
]. |
|
1210 |
first := start + 1. |
|
1211 |
last := stop. |
|
1212 |
first to:last do:[:index | |
|
1213 |
|view| |
|
295 | 1214 |
|
871 | 1215 |
view := subViews at:index. |
1216 |
orientation == #vertical ifTrue:[ |
|
1217 |
y := view top "origin y" - barHeight + 1. |
|
1218 |
] ifFalse:[ |
|
1219 |
x := view left "origin x" - barHeight + 1. |
|
1220 |
]. |
|
1221 |
aBlock value:(x @ y) value:index |
|
1222 |
] |
|
295 | 1223 |
] |
1224 |
! |
|
1225 |
||
1226 |
resizeSubviews |
|
1227 |
"readjust size of some subviews" |
|
1228 |
||
1229 |
self resizeSubviewsFrom:1 to:(subViews size) |
|
1230 |
! |
|
1231 |
||
1232 |
resizeSubviewsFrom:start to:stop |
|
1233 |
"readjust size of some subviews" |
|
1234 |
||
1235 |
|step nSubviews| |
|
1236 |
||
1237 |
subViews notNil ifTrue:[ |
|
871 | 1238 |
(start <= stop) ifTrue:[ |
1239 |
step := 1 |
|
1240 |
] ifFalse:[ |
|
1241 |
step := -1 |
|
1242 |
]. |
|
1243 |
nSubviews := subViews size. |
|
1244 |
start to:stop by:step do:[:index | |
|
1245 |
|bw view o1 o2 relOrg relCorner newOrg newCorner newExt| |
|
295 | 1246 |
|
871 | 1247 |
view := subViews at:index. |
1248 |
bw := view borderWidth. |
|
295 | 1249 |
|
871 | 1250 |
index == 1 ifTrue:[ |
1251 |
o1 := 0. |
|
1252 |
] ifFalse:[ |
|
1253 |
o1 := barHeight // 2 - bw |
|
1254 |
]. |
|
1255 |
index == nSubviews ifTrue:[ |
|
1256 |
o2 := 0. |
|
1257 |
] ifFalse:[ |
|
1258 |
o2 := barHeight // 2 - bw |
|
1259 |
]. |
|
295 | 1260 |
|
1261 |
" |
|
871 | 1262 |
relCorner := view relativeCorner. |
1263 |
relCorner isNil ifTrue:[ |
|
1264 |
self error:'subview must have relative corner' |
|
1265 |
]. |
|
1266 |
newCorner := view cornerFromRelativeCorner. |
|
1267 |
newCorner notNil ifTrue:[ |
|
1268 |
newCorner y:(newCorner y - o2) |
|
1269 |
]. |
|
295 | 1270 |
|
871 | 1271 |
relOrg := view relativeOrigin. |
1272 |
relOrg isNil ifTrue:[ |
|
1273 |
self error:'subview must have relative origin' |
|
1274 |
]. |
|
1275 |
newOrg := view originFromRelativeOrigin. |
|
1276 |
newOrg notNil ifTrue:[ |
|
1277 |
(index ~~ 1) ifTrue:[ |
|
1278 |
newOrg y:(newOrg y + o1) |
|
1279 |
]. |
|
1280 |
]. |
|
1281 |
view pixelOrigin:newOrg corner:newCorner |
|
295 | 1282 |
" |
871 | 1283 |
newOrg := view computeOrigin. |
1284 |
newOrg notNil ifTrue:[ |
|
1285 |
(index ~~ 1) ifTrue:[ |
|
1286 |
orientation == #vertical ifTrue:[ |
|
1287 |
newOrg y:(newOrg y + o1) |
|
1288 |
] ifFalse:[ |
|
1289 |
newOrg x:(newOrg x + o1) |
|
1290 |
] |
|
1291 |
]. |
|
1292 |
]. |
|
1293 |
newExt := view computeExtent. |
|
1294 |
newExt notNil ifTrue:[ |
|
1295 |
orientation == #vertical ifTrue:[ |
|
1296 |
newExt y:(newExt y - o2 - o1) |
|
1297 |
] ifFalse:[ |
|
1298 |
newExt x:(newExt x - o2 - o1) |
|
1299 |
] |
|
1300 |
]. |
|
1301 |
view pixelOrigin:newOrg extent:newExt. |
|
1302 |
] |
|
295 | 1303 |
] |
873 | 1304 |
|
1305 |
"Modified: 7.11.1996 / 17:10:26 / cg" |
|
295 | 1306 |
! |
1307 |
||
1308 |
setupSubviews |
|
1309 |
"setup subviews sizes (in case of non-relative sizes)" |
|
1310 |
||
1311 |
|pos delta| |
|
1312 |
||
300 | 1313 |
"/ setup all subviews to spread evenly ... |
295 | 1314 |
|
300 | 1315 |
pos := 0.0. |
1316 |
delta := 1.0 / (subViews size). |
|
295 | 1317 |
|
300 | 1318 |
1 to:(subViews size) do:[:index | |
1319 |
|view| |
|
295 | 1320 |
|
300 | 1321 |
view := subViews at:index. |
1322 |
orientation == #vertical ifTrue:[ |
|
1323 |
index == subViews size ifTrue:[ |
|
1324 |
view origin:(0.0 @ pos) corner:(1.0 @ 1.0) |
|
295 | 1325 |
] ifFalse:[ |
300 | 1326 |
view origin:(0.0 @ pos) corner:(1.0 @ (pos + delta)) |
295 | 1327 |
]. |
300 | 1328 |
] ifFalse:[ |
1329 |
index == subViews size ifTrue:[ |
|
1330 |
view origin:(pos @ 0.0) corner:(1.0 @ 1.0) |
|
1331 |
] ifFalse:[ |
|
1332 |
view origin:(pos @ 0.0) corner:((pos + delta) @ 1.0) |
|
1333 |
]. |
|
1334 |
]. |
|
1335 |
pos := pos + delta |
|
295 | 1336 |
] |
1337 |
! ! |
|
1338 |
||
299
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1339 |
!VariablePanel methodsFor:'private tableView protocol'! |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1340 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1341 |
setupSubviewOrigins |
826 | 1342 |
"setup subviews origins |
1343 |
if we only have relative extents |
|
1344 |
(Variable Panels need relative origins and corners!!) (SV 16.1.95)" |
|
299
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1345 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1346 |
|x y e eX eY n "{ Class: SmallInteger }"| |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1347 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1348 |
x := y := 0.0. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1349 |
|
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1350 |
n := subViews size. |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1351 |
1 to:n do:[:index | |
826 | 1352 |
|view| |
299
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1353 |
|
826 | 1354 |
view := subViews at:index. |
1355 |
e := view relativeExtent. |
|
1356 |
e notNil ifTrue:[ |
|
1357 |
view relativeExtent:nil. |
|
1358 |
eX := e x. |
|
1359 |
eY := e y. |
|
1360 |
index == n ifTrue:[ |
|
1361 |
view origin:(x @ y) corner:(1.0 @ 1.0) |
|
1362 |
] ifFalse:[ |
|
1363 |
orientation == #vertical ifTrue:[ |
|
1364 |
view origin:(x @ y) corner:(1.0 @ (y+eY)) |
|
1365 |
] ifFalse:[ |
|
1366 |
view origin:(x @ y) corner:((x+eX) @ 1.0) |
|
1367 |
]. |
|
1368 |
]. |
|
1369 |
orientation == #vertical ifTrue:[ |
|
1370 |
y := y + eY. |
|
1371 |
] ifFalse:[ |
|
1372 |
x := x + eX. |
|
1373 |
] |
|
1374 |
] ifFalse: [ |
|
1375 |
view origin:(x @ y). |
|
1376 |
orientation == #vertical ifTrue:[ |
|
1377 |
y := view relativeCorner y. |
|
1378 |
] ifFalse:[ |
|
1379 |
x := view relativeCorner x. |
|
1380 |
] |
|
1381 |
]. |
|
1382 |
] |
|
1383 |
||
1384 |
"Modified: 21.8.1996 / 10:01:29 / stefan" |
|
299
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1385 |
! ! |
d2f955840ad5
oops - tableViews private interface was lost - reintroduced
ah
parents:
295
diff
changeset
|
1386 |
|
871 | 1387 |
!VariablePanel class methodsFor:'documentation'! |
295 | 1388 |
|
1389 |
version |
|
876 | 1390 |
^ '$Header: /cvs/stx/stx/libwidg/Attic/VarPanel.st,v 1.17 1996-11-07 19:40:19 cg Exp $' |
295 | 1391 |
! ! |