0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
59
|
3 |
All Rights Reserved
|
0
|
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 |
|
105
|
13 |
'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:10:40 am'!
|
99
|
14 |
|
0
|
15 |
VariableVerticalPanel subclass:#VariableHorizontalPanel
|
59
|
16 |
instanceVariableNames:''
|
95
|
17 |
classVariableNames:'DefaultCursor'
|
59
|
18 |
poolDictionaries:''
|
|
19 |
category:'Views-Layout'
|
0
|
20 |
!
|
|
21 |
|
|
22 |
VariableHorizontalPanel comment:'
|
5
|
23 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
59
|
24 |
All Rights Reserved
|
0
|
25 |
|
105
|
26 |
$Header: /cvs/stx/stx/libwidg/VariableHorizontalPanel.st,v 1.13 1995-03-18 05:16:26 claus Exp $
|
38
|
27 |
'!
|
|
28 |
|
|
29 |
!VariableHorizontalPanel class methodsFor:'documentation'!
|
|
30 |
|
|
31 |
copyright
|
|
32 |
"
|
|
33 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
59
|
34 |
All Rights Reserved
|
38
|
35 |
|
|
36 |
This software is furnished under a license and may be used
|
|
37 |
only in accordance with the terms of that license and with the
|
|
38 |
inclusion of the above copyright notice. This software may not
|
|
39 |
be provided or otherwise made available to, or used by, any
|
|
40 |
other person. No title to or ownership of the software is
|
|
41 |
hereby transferred.
|
|
42 |
"
|
|
43 |
!
|
|
44 |
|
|
45 |
version
|
|
46 |
"
|
105
|
47 |
$Header: /cvs/stx/stx/libwidg/VariableHorizontalPanel.st,v 1.13 1995-03-18 05:16:26 claus Exp $
|
38
|
48 |
"
|
|
49 |
!
|
|
50 |
|
|
51 |
documentation
|
|
52 |
"
|
|
53 |
a View to separate its subviews horizontally by a movable bar
|
|
54 |
to adjust the size-ratios.
|
|
55 |
The bar-handle is either an exposed knob (knobStyle == #motif)
|
|
56 |
or the forms defined in Scroller (knobStyle ~~ #motif)
|
|
57 |
or nothing.
|
|
58 |
|
|
59 |
The subvies dimensions MUST be given as relative sizes;
|
|
60 |
typically creation is done as:
|
0
|
61 |
|
59
|
62 |
p := VariableHorizontalPanel in:superView.
|
|
63 |
v1 := <someViewClass> origin:0.0 @ 0.0
|
|
64 |
corner:0.5 @ 1.0
|
|
65 |
in:p.
|
|
66 |
v2 := <someViewClass> origin:0.5 @ 0.0
|
|
67 |
corner:0.8 @ 1.0
|
|
68 |
in:p.
|
|
69 |
v3 := <someViewClass> origin:0.8 @ 0.0
|
|
70 |
corner:1.0 @ 1.0
|
|
71 |
in:p.
|
38
|
72 |
|
63
|
73 |
"
|
|
74 |
!
|
|
75 |
|
|
76 |
examples
|
|
77 |
"
|
38
|
78 |
example:
|
59
|
79 |
|top p v1 v2 v3|
|
38
|
80 |
|
59
|
81 |
top := StandardSystemView new.
|
|
82 |
top extent:300@200.
|
0
|
83 |
|
59
|
84 |
p := VariableHorizontalPanel
|
|
85 |
origin:0.0 @ 0.0
|
|
86 |
corner:1.0 @ 1.0
|
|
87 |
in:top.
|
|
88 |
v1 := SelectionInListView
|
|
89 |
origin:0.0 @ 0.0
|
|
90 |
corner:0.5 @ 1.0
|
|
91 |
in:p.
|
|
92 |
v2 := EditTextView
|
|
93 |
origin:0.5 @ 0.0
|
|
94 |
corner:0.8 @ 1.0
|
|
95 |
in:p.
|
|
96 |
v3 := ScrollableView
|
|
97 |
for:TextView
|
|
98 |
in:p.
|
|
99 |
v3 origin:0.8 @ 0.0
|
|
100 |
corner:1.0 @ 1.0.
|
|
101 |
top open
|
38
|
102 |
"
|
|
103 |
! !
|
0
|
104 |
|
99
|
105 |
!VariableHorizontalPanel methodsFor:'private'!
|
|
106 |
|
0
|
107 |
handleOriginsFrom:start to:stop do:aBlock
|
|
108 |
"evaluate the argument block for some handle-origins"
|
|
109 |
|
63
|
110 |
|y hh vDelta|
|
0
|
111 |
|
|
112 |
subViews notNil ifTrue:[
|
59
|
113 |
shadowForm notNil ifTrue:[
|
|
114 |
hh := shadowForm height
|
|
115 |
] ifFalse:[
|
63
|
116 |
hh := barWidth
|
|
117 |
].
|
|
118 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
|
|
119 |
vDelta := barWidth // 2.
|
|
120 |
] ifFalse:[
|
|
121 |
vDelta := 0
|
59
|
122 |
].
|
|
123 |
(handlePosition == #left) ifTrue:[
|
63
|
124 |
y := vDelta
|
59
|
125 |
] ifFalse:[
|
|
126 |
(handlePosition == #right) ifTrue:[
|
63
|
127 |
y := height - hh - margin - vDelta
|
59
|
128 |
] ifFalse:[
|
63
|
129 |
y := height - barWidth // 2
|
59
|
130 |
]
|
|
131 |
].
|
|
132 |
(start + 1) to:stop do:[:index |
|
|
133 |
|x view|
|
0
|
134 |
|
59
|
135 |
view := subViews at:index.
|
|
136 |
x := view origin x - barHeight + 1.
|
|
137 |
aBlock value:(x @ y)
|
|
138 |
]
|
0
|
139 |
]
|
|
140 |
!
|
|
141 |
|
105
|
142 |
resizeSubviewsFrom:start to:stop
|
|
143 |
"readjust size of some subviews"
|
|
144 |
|
|
145 |
|step nSubviews|
|
|
146 |
|
|
147 |
subViews notNil ifTrue:[
|
|
148 |
(start <= stop) ifTrue:[
|
|
149 |
step := 1
|
|
150 |
] ifFalse:[
|
|
151 |
step := -1
|
|
152 |
].
|
|
153 |
nSubviews := subViews size.
|
|
154 |
start to:stop by:step do:[:index |
|
|
155 |
|bw view o1 o2 relCorner relOrg newCorner newOrg newExt|
|
|
156 |
|
|
157 |
view := subViews at:index.
|
|
158 |
bw := view borderWidth.
|
|
159 |
|
|
160 |
index == 1 ifTrue:[
|
|
161 |
o1 := 0.
|
|
162 |
] ifFalse:[
|
|
163 |
o1 := barHeight // 2 - bw
|
|
164 |
].
|
|
165 |
index == nSubviews ifTrue:[
|
|
166 |
o2 := 0.
|
|
167 |
] ifFalse:[
|
|
168 |
o2 := barHeight // 2 - bw
|
|
169 |
].
|
|
170 |
|
|
171 |
relCorner := view relativeCorner.
|
|
172 |
relCorner isNil ifTrue:[
|
|
173 |
self error:'subview must have relative corner'
|
|
174 |
].
|
|
175 |
newCorner := view cornerFromRelativeCorner.
|
|
176 |
newCorner notNil ifTrue:[
|
|
177 |
newCorner x:(newCorner x - o2)
|
|
178 |
].
|
|
179 |
|
|
180 |
"
|
|
181 |
relOrg := view relativeOrigin.
|
|
182 |
relOrg isNil ifTrue:[
|
|
183 |
self error:'subview must have relative origin'
|
|
184 |
].
|
|
185 |
newOrg := view originFromRelativeOrigin.
|
|
186 |
newOrg notNil ifTrue:[
|
|
187 |
(index ~~ 1) ifTrue:[
|
|
188 |
newOrg x:(newOrg x + o1)
|
|
189 |
].
|
|
190 |
].
|
|
191 |
view pixelOrigin:newOrg corner:newCorner
|
|
192 |
"
|
|
193 |
newOrg := view computeOrigin.
|
|
194 |
newOrg notNil ifTrue:[
|
|
195 |
(index ~~ 1) ifTrue:[
|
|
196 |
newOrg x:(newOrg x + o1)
|
|
197 |
].
|
|
198 |
].
|
|
199 |
newExt := view computeExtent.
|
|
200 |
newExt notNil ifTrue:[
|
|
201 |
newExt x:(newExt x - o2 - o1)
|
|
202 |
].
|
|
203 |
|
|
204 |
view pixelOrigin:newOrg extent:newExt.
|
|
205 |
]
|
|
206 |
]
|
|
207 |
!
|
|
208 |
|
0
|
209 |
setupSubviewSizes
|
|
210 |
"setup subviews sizes (in case of non-relative sizes)"
|
|
211 |
|
|
212 |
|x w |
|
|
213 |
|
|
214 |
self anyNonRelativeSubviews ifTrue:[
|
59
|
215 |
"there is at least one subview without
|
|
216 |
relative origin/extent - setup all subviews
|
|
217 |
to spread evenly ..."
|
0
|
218 |
|
59
|
219 |
x := 0.0.
|
|
220 |
w := 1.0 / (subViews size).
|
0
|
221 |
|
59
|
222 |
1 to:(subViews size) do:[:index |
|
|
223 |
|view|
|
0
|
224 |
|
59
|
225 |
view := subViews at:index.
|
|
226 |
index == subViews size ifTrue:[
|
|
227 |
view origin:(x @ 0.0) corner:(1.0 @ 1.0)
|
|
228 |
] ifFalse:[
|
|
229 |
view origin:(x @ 0.0) corner:((x + w) @ 1.0)
|
|
230 |
].
|
|
231 |
x := x + w
|
|
232 |
]
|
0
|
233 |
]
|
105
|
234 |
!
|
|
235 |
|
|
236 |
setupSubviewOrigins
|
|
237 |
"setup subviews origins (SV 16.1.95)"
|
|
238 |
|
|
239 |
|x e|
|
|
240 |
|
|
241 |
x := 0.0.
|
|
242 |
|
|
243 |
1 to:(subViews size) do:[:index |
|
|
244 |
|view|
|
|
245 |
|
|
246 |
view := subViews at:index.
|
|
247 |
e := view relativeExtent.
|
|
248 |
e notNil ifTrue:[
|
|
249 |
view relativeExtent:nil.
|
|
250 |
e := e x.
|
|
251 |
index == subViews size ifTrue:[
|
|
252 |
view origin:(x @ 0.0) corner:(1.0 @ 1.0)
|
|
253 |
] ifFalse:[
|
|
254 |
view origin:(x @ 0.0) corner:((x+e) @ 1.0)
|
|
255 |
].
|
|
256 |
x := x + e.
|
|
257 |
] ifFalse: [
|
|
258 |
view origin:(x @ 0.0).
|
|
259 |
x := view relativeCorner x.
|
|
260 |
].
|
|
261 |
]
|
|
262 |
|
0
|
263 |
! !
|
|
264 |
|
99
|
265 |
!VariableHorizontalPanel methodsFor:'initializing'!
|
0
|
266 |
|
99
|
267 |
initCursor
|
|
268 |
"set the cursor - a horizontal double arrow"
|
0
|
269 |
|
99
|
270 |
DefaultCursor notNil ifTrue:[
|
|
271 |
cursor := DefaultCursor
|
|
272 |
] ifFalse:[
|
|
273 |
cursor := Cursor sourceForm:(Form fromFile:'VHPanel.xbm')
|
|
274 |
maskForm:(Form fromFile:'VHPanel_m.xbm')
|
|
275 |
hotX:8
|
|
276 |
hotY:8.
|
|
277 |
"
|
|
278 |
if bitmaps are not available, use a standard cursor
|
|
279 |
"
|
|
280 |
cursor isNil ifTrue:[
|
|
281 |
"which one looks better ?"
|
|
282 |
cursor := Cursor leftRightArrow
|
|
283 |
"cursor := Cursor leftLimitArrow"
|
59
|
284 |
].
|
99
|
285 |
DefaultCursor := cursor
|
0
|
286 |
]
|
|
287 |
!
|
|
288 |
|
99
|
289 |
defaultControllerClass
|
|
290 |
^ VariableHorizontalPanelController
|
0
|
291 |
! !
|
|
292 |
|
|
293 |
!VariableHorizontalPanel methodsFor:'drawing'!
|
|
294 |
|
|
295 |
drawHandleAtX:hx y:hy
|
|
296 |
|w x m|
|
|
297 |
|
59
|
298 |
shadowForm notNil ifTrue:[
|
63
|
299 |
w := shadowForm width
|
0
|
300 |
] ifFalse:[
|
59
|
301 |
w := barHeight - 4
|
0
|
302 |
].
|
|
303 |
|
|
304 |
self paint:viewBackground.
|
|
305 |
self fillRectangleX:hx y:margin
|
59
|
306 |
width:barHeight
|
|
307 |
height:(height - margin - margin).
|
0
|
308 |
|
59
|
309 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
|
|
310 |
m := (barHeight - w) // 2.
|
|
311 |
shadowForm isNil ifTrue:[
|
|
312 |
x := hx + (barHeight // 2).
|
|
313 |
separatingLine ifTrue:[
|
|
314 |
self paint:shadowColor.
|
|
315 |
self displayLineFromX:x y:margin toX:x y:(height - margin).
|
|
316 |
x := x + 1.
|
|
317 |
self paint:lightColor.
|
|
318 |
self displayLineFromX:x y:margin toX:x y:(height - margin).
|
|
319 |
].
|
|
320 |
self paint:viewBackground.
|
|
321 |
self fillRectangleX:hx y:(hy - barWidth)
|
|
322 |
width:w
|
|
323 |
height:(barWidth + barWidth).
|
0
|
324 |
|
59
|
325 |
x := hx.
|
|
326 |
handleStyle == #st80 ifTrue:[
|
|
327 |
x := x - 1.
|
|
328 |
].
|
|
329 |
self drawEdgesForX:(x + m)
|
|
330 |
y:(hy - barWidth)
|
|
331 |
width:w
|
|
332 |
height:(barWidth + barWidth)
|
60
|
333 |
level:2.
|
|
334 |
|
|
335 |
handleStyle == #iris ifTrue:[
|
63
|
336 |
self paint:handleColor.
|
60
|
337 |
self fillDeviceRectangleX:(x + m + 2)
|
|
338 |
y:(hy - barWidth + 2)
|
|
339 |
width:w - 4
|
|
340 |
height:(barWidth + barWidth - 4)
|
|
341 |
]
|
59
|
342 |
] ifFalse:[
|
|
343 |
x := hx.
|
|
344 |
self drawHandleFormAtX:(x + m) y:hy
|
|
345 |
].
|
|
346 |
handleStyle == #st80 ifTrue:[
|
|
347 |
x := hx - 1.
|
|
348 |
self paint:lightColor.
|
|
349 |
self displayLineFromX:x y:margin toX:x y:(height - margin).
|
|
350 |
self displayLineFromX:hx y:0 toX:(hx + barHeight - 1) y:0.
|
|
351 |
x := hx + barHeight - 2.
|
|
352 |
self paint:shadowColor.
|
|
353 |
self displayLineFromX:x y:margin toX:x y:(height - margin).
|
|
354 |
"uncomment the -1 if you dont like the notch at the bottom end"
|
|
355 |
" VVV"
|
|
356 |
self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeight - 1) y:height-1.
|
|
357 |
].
|
0
|
358 |
] ifFalse:[
|
63
|
359 |
x := hx + barHeight - 1.
|
59
|
360 |
self paint:handleColor.
|
|
361 |
separatingLine ifTrue:[
|
63
|
362 |
self displayLineFromX:hx+1 y:0 toX:hx+1 y:height.
|
59
|
363 |
self displayLineFromX:x y:0 toX:x y:height.
|
|
364 |
].
|
63
|
365 |
self fillRectangleX:hx y:hy width:barHeight height:barWidth
|
0
|
366 |
]
|
105
|
367 |
!
|
|
368 |
|
|
369 |
invertHandleBarAtX:hx y:hy
|
|
370 |
self noClipByChildren.
|
|
371 |
self xoring:[
|
|
372 |
|x|
|
|
373 |
|
|
374 |
trackLine ifTrue:[
|
|
375 |
x := hx + (barHeight // 2).
|
|
376 |
self displayLineFromX:x y:0 toX:x y:height.
|
|
377 |
] ifFalse:[
|
|
378 |
self fillRectangleX:hx y:0 width:barHeight height:height
|
|
379 |
]
|
|
380 |
].
|
|
381 |
self clipByChildren.
|
|
382 |
|
|
383 |
|
99
|
384 |
! !
|
0
|
385 |
|