25 |
25 |
26 VariableVerticalPanel comment:' |
26 VariableVerticalPanel comment:' |
27 COPYRIGHT (c) 1991 by Claus Gittinger |
27 COPYRIGHT (c) 1991 by Claus Gittinger |
28 All Rights Reserved |
28 All Rights Reserved |
29 |
29 |
30 $Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.11 1994-11-28 21:05:40 claus Exp $ |
30 $Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.12 1995-02-06 00:54:57 claus Exp $ |
31 '! |
31 '! |
32 |
32 |
33 !VariableVerticalPanel class methodsFor:'documentation'! |
33 !VariableVerticalPanel class methodsFor:'documentation'! |
34 |
34 |
35 copyright |
35 copyright |
89 p := VariableVerticalPanel |
89 p := VariableVerticalPanel |
90 origin:0.0 @ 0.0 |
90 origin:0.0 @ 0.0 |
91 corner:1.0 @ 1.0 |
91 corner:1.0 @ 1.0 |
92 in:top. |
92 in:top. |
93 v1 := ScrollableView for:SelectionInListView in:p. |
93 v1 := ScrollableView for:SelectionInListView in:p. |
94 v1 origin:0.0 @ 0.0 |
94 v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
95 corner:1.0 @ 0.5. |
|
96 v1 list:(FileDirectory directoryNamed:'/etc') contents. |
95 v1 list:(FileDirectory directoryNamed:'/etc') contents. |
97 v1 action:[:selNr | |
96 v1 action:[:selNr | |
98 |fullName stream text| |
97 |fullName stream text| |
99 fullName := '/etc/' , v1 selectionValue. |
98 fullName := '/etc/' , v1 selectionValue. |
100 stream := fullName asFilename readStream. |
99 stream := fullName asFilename readStream. |
275 ! |
272 ! |
276 |
273 |
277 style:styleSymbol |
274 style:styleSymbol |
278 "define the style of the handle; |
275 "define the style of the handle; |
279 styleSymbol may be #motif to draw a little knob or |
276 styleSymbol may be #motif to draw a little knob or |
280 enything else to draw scrollBars handleForm" |
277 anything else to draw scrollBars handleForm" |
281 |
278 |
282 (styleSymbol ~~ handleStyle) ifTrue:[ |
279 (styleSymbol ~~ handleStyle) ifTrue:[ |
283 handleStyle := styleSymbol. |
280 handleStyle := styleSymbol. |
284 handleStyle == #next ifTrue:[ |
281 handleStyle == #next ifTrue:[ |
285 shadowForm := self class shadowFormOn:device. |
282 shadowForm := self class shadowFormOn:device. |
302 ! ! |
299 ! ! |
303 |
300 |
304 !VariableVerticalPanel methodsFor:'drawing'! |
301 !VariableVerticalPanel methodsFor:'drawing'! |
305 |
302 |
306 drawHandleFormAtX:hx y:hy |
303 drawHandleFormAtX:hx y:hy |
|
304 "draw a handles bitmap at hx/hy" |
|
305 |
307 self paint:shadowColor. |
306 self paint:shadowColor. |
308 self displayForm:shadowForm x:hx y:hy. |
307 self displayForm:shadowForm x:hx y:hy. |
309 self paint:lightColor. |
308 self paint:lightColor. |
310 self displayForm:lightForm x:hx y:hy. |
309 self displayForm:lightForm x:hx y:hy. |
311 self paint:viewBackground |
310 self paint:viewBackground |
312 ! |
311 ! |
313 |
312 |
314 drawHandleAtX:hx y:hy |
313 drawHandleAtX:hx y:hy |
|
314 "draw a single handle at hx/hy" |
|
315 |
315 |h y m| |
316 |h y m| |
316 |
317 |
317 shadowForm notNil ifTrue:[ |
318 shadowForm notNil ifTrue:[ |
318 h := shadowForm height |
319 h := shadowForm height |
319 ] ifFalse:[ |
320 ] ifFalse:[ |
320 h := barHeight - 4 |
321 h := barHeight - 4 |
321 ]. |
322 ]. |
322 |
323 |
323 self paint:viewBackground. |
324 "/ self paint:viewBackground. |
324 self fillRectangleX:margin y:hy |
325 "/ self fillRectangleX:margin y:hy |
325 width:(width - margin - margin) |
326 "/ width:(width - margin - margin) |
326 height:barHeight. |
327 "/ height:barHeight. |
327 |
328 |
328 (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
329 (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
329 m := (barHeight - h) // 2. |
330 m := (barHeight - h) // 2. |
330 shadowForm isNil ifTrue:[ |
331 shadowForm isNil ifTrue:[ |
331 y := hy + (barHeight // 2). |
332 y := hy + (barHeight // 2). |
393 self drawHandleAtX:(hPoint x) y:(hPoint y) |
394 self drawHandleAtX:(hPoint x) y:(hPoint y) |
394 ]. |
395 ]. |
395 movedHandle notNil ifTrue:[ |
396 movedHandle notNil ifTrue:[ |
396 self noClipByChildren. |
397 self noClipByChildren. |
397 self xoring:[ |
398 self xoring:[ |
|
399 |y| |
|
400 |
398 trackLine ifTrue:[ |
401 trackLine ifTrue:[ |
399 self displayLineFromX:0 y:prev+(barHeight // 2) |
402 y := prev+(barHeight // 2). |
400 toX:width y:prev+(barHeight // 2). |
403 self displayLineFromX:0 y:y toX:width y:y. |
401 ] ifFalse:[ |
404 ] ifFalse:[ |
402 self fillRectangleX:0 y:prev width:width height:barHeight |
405 self fillRectangleX:0 y:prev width:width height:barHeight |
403 ] |
406 ] |
404 ]. |
407 ]. |
405 self clipByChildren |
408 self clipByChildren |
445 movedHandle := handle. |
448 movedHandle := handle. |
446 prev := hy. |
449 prev := hy. |
447 start := by - hy. |
450 start := by - hy. |
448 self noClipByChildren. |
451 self noClipByChildren. |
449 self xoring:[ |
452 self xoring:[ |
|
453 |y| |
|
454 |
450 trackLine ifTrue:[ |
455 trackLine ifTrue:[ |
451 self displayLineFromX:0 y:hy+(barHeight // 2) |
456 y := hy + (barHeight // 2). |
452 toX:width y:hy+(barHeight // 2). |
457 self displayLineFromX:0 y:y toX:width y:y. |
453 ] ifFalse:[ |
458 ] ifFalse:[ |
454 self fillRectangleX:0 y:hy width:width height:barHeight |
459 self fillRectangleX:0 y:hy width:width height:barHeight |
455 ] |
460 ] |
456 ]. |
461 ]. |
457 self clipByChildren. |
462 self clipByChildren. |
509 ] |
514 ] |
510 ]. |
515 ]. |
511 |
516 |
512 self noClipByChildren. |
517 self noClipByChildren. |
513 self xoring:[ |
518 self xoring:[ |
|
519 |halfHeight y| |
|
520 |
514 trackLine ifTrue:[ |
521 trackLine ifTrue:[ |
515 self displayLineFromX:0 y:prev+(barHeight // 2) |
522 halfHeight := barHeight // 2. |
516 toX:width y:prev+(barHeight // 2). |
523 y := prev + halfHeight. |
517 self displayLineFromX:0 y:ypos+(barHeight // 2) |
524 self displayLineFromX:0 y:y toX:width y:y. |
518 toX:width y:ypos+(barHeight // 2). |
525 y := ypos + halfHeight. |
|
526 self displayLineFromX:0 y:y toX:width y:y. |
519 ] ifFalse:[ |
527 ] ifFalse:[ |
520 self fillRectangleX:0 y:prev width:width height:barHeight. |
528 self fillRectangleX:0 y:prev width:width height:barHeight. |
521 self fillRectangleX:0 y:ypos width:width height:barHeight |
529 self fillRectangleX:0 y:ypos width:width height:barHeight |
522 ] |
530 ] |
523 ]. |
531 ]. |
535 |
543 |
536 "undo the last xor" |
544 "undo the last xor" |
537 |
545 |
538 self noClipByChildren. |
546 self noClipByChildren. |
539 self xoring:[ |
547 self xoring:[ |
|
548 |y| |
|
549 |
540 trackLine ifTrue:[ |
550 trackLine ifTrue:[ |
541 self displayLineFromX:0 y:prev+(barHeight // 2) |
551 y := prev + (barHeight // 2). |
542 toX:width y:prev+(barHeight // 2). |
552 self displayLineFromX:0 y:y toX:width y:y. |
543 ] ifFalse:[ |
553 ] ifFalse:[ |
544 self fillRectangleX:0 y:prev width:width height:barHeight |
554 self fillRectangleX:0 y:prev width:width height:barHeight |
545 ]. |
555 ]. |
546 ]. |
556 ]. |
547 self clipByChildren. |
557 self clipByChildren. |
548 |
558 |
549 "compute the new relative heights" |
559 "compute the new relative heights" |
550 |
560 |
551 aboveIndex := movedHandle. |
561 aboveIndex := movedHandle. |
552 belowIndex := movedHandle + 1. |
562 belowIndex := movedHandle + 1. |
|
563 movedHandle := nil. |
|
564 |
553 aboveView := subViews at:aboveIndex. |
565 aboveView := subViews at:aboveIndex. |
554 belowView := subViews at:belowIndex. |
566 belowView := subViews at:belowIndex. |
555 |
567 |
556 oldY := aboveView relativeCorner y. |
568 oldY := aboveView relativeCorner y. |
557 newY := (prev + start / height) asFloat. |
569 newY := (prev + start / height) asFloat. |
558 aboveView relativeCorner:aboveView relativeCorner x @ newY. |
570 aboveView relativeCorner:aboveView relativeCorner x @ newY. |
559 belowView relativeOrigin:belowView relativeOrigin x @ newY. |
571 belowView relativeOrigin:belowView relativeOrigin x @ newY. |
560 movedHandle := nil. |
572 |
561 |
573 redrawLocked := true. |
562 oldY > newY ifTrue:[ |
574 oldY > newY ifTrue:[ |
563 self resizeSubviewsFrom:aboveIndex to:belowIndex. |
575 self resizeSubviewsFrom:aboveIndex to:belowIndex. |
564 ] ifFalse:[ |
576 ] ifFalse:[ |
565 self resizeSubviewsFrom:belowIndex to:aboveIndex. |
577 self resizeSubviewsFrom:belowIndex to:aboveIndex. |
566 ]. |
578 ]. |
567 |
|
568 redrawLocked := true. |
579 redrawLocked := true. |
569 self redrawHandlesFrom:aboveIndex to:belowIndex. |
580 self redrawHandlesFrom:aboveIndex to:belowIndex. |
570 redrawLocked := false. |
581 redrawLocked := false. |
571 ] ifFalse:[ |
582 ] ifFalse:[ |
572 super buttonRelease:button x:x y:y |
583 super buttonRelease:button x:x y:y |