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