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