examples
authorClaus Gittinger <cg@exept.de>
Thu, 07 Nov 1996 20:40:19 +0100
changeset 876 9766a5eda233
parent 875 2c5dde603098
child 877 b451fa6920d0
examples
VarPanel.st
VariablePanel.st
--- a/VarPanel.st	Thu Nov 07 17:32:48 1996 +0100
+++ b/VarPanel.st	Thu Nov 07 20:40:19 1996 +0100
@@ -159,7 +159,7 @@
 
 
 
-   example (change the handles level):
+   change the handles level:
                                                                         [exBegin]
         |top p v1 v2 v3|
 
@@ -186,7 +186,7 @@
 
 
 
-   example (change the handles style to nil makes it invisible):
+   change the handles style to nil makes it invisible:
                                                                         [exBegin]
         |top p v1 v2 v3|
 
@@ -213,7 +213,74 @@
 
 
 
-    example (placing scrolled and unscrolled views into a variablePanel):
+   define your own handle (-bitmap):
+                                                                        [exBegin]
+        |top p v1 v2 v3|
+
+        top := StandardSystemView new.
+        top extent:300@300.
+
+        p := VariablePanel 
+                 origin:0.0 @ 0.0
+                 corner:1.0 @ 1.0
+                 in:top.
+        p orientation:#vertical.
+        p handleImage:(Image fromFile:'bitmaps/ScrollLt.8.xbm').
+
+        v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p.
+        v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p.
+        v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p.
+
+        v1 viewBackground:(Color red).
+        v2 viewBackground:(Color green).
+        v3 viewBackground:(Color yellow).
+
+        top open
+                                                                        [exEnd]
+
+
+
+   another handle-bitmap:
+                                                                        [exBegin]
+        |top p v1 v2 v3|
+
+        top := StandardSystemView new.
+        top extent:300@300.
+
+        p := VariablePanel 
+                 origin:0.0 @ 0.0
+                 corner:1.0 @ 1.0
+                 in:top.
+        p orientation:#vertical.
+        p handleImage:(Form width:9
+                            height:11
+                            fromArray:#(
+                                        2r00000000 2r00000000
+                                        2r00001000 2r00000000
+                                        2r00011100 2r00000000
+                                        2r00111110 2r00000000
+                                        2r01111111 2r00000000
+                                        2r00000000 2r00000000
+                                        2r01111111 2r00000000
+                                        2r00111110 2r00000000
+                                        2r00011100 2r00000000
+                                        2r00001000 2r00000000
+                                        2r00000000 2r00000000
+                                       )
+                      ).
+
+        v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p.
+        v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p.
+        v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p.
+
+        v1 viewBackground:(Color red).
+        v2 viewBackground:(Color green).
+        v3 viewBackground:(Color yellow).
+
+        top open
+                                                                        [exEnd]
+
+    placing scrolled and unscrolled views into a variablePanel:
                                                                         [exBegin]
         |top p v1 v2 v3|
 
@@ -248,7 +315,7 @@
                                                                         [exEnd]
 
 
-    example: (dynamically adding/removing views):
+    dynamically adding/removing views:
                                                                         [exBegin]
         |top p v1 v2 b|
 
@@ -289,7 +356,7 @@
                                                                         [exEnd]
 
 
-    example: (dynamically flipping orientation):
+    dynamically flipping orientation:
     Notice: you have to change the relative bounds of the subviews first.
                                                                         [exBegin]
         |top p v1 v2 b|
@@ -331,7 +398,7 @@
                                                                         [exEnd]
 
 
-   example (combining fix-size with variable size):
+   combining fix-size with variable size:
    (need 3 extra frame-views to place the extra labels into)
                                                                         [exBegin]
         |top p v1 l1 v2 l2 v3 l3 f1 f2 f3|
@@ -568,13 +635,26 @@
 
     "if screen is very low-res, make certain bar is visible and catchable"
     (barHeight < 4) ifTrue:[
-	barHeight := 4
+        barHeight := 4
     ].
 
-    "make it even so spacing is equally spreadable among subviews"
+    "make it even, so spacing is equally spreadable among subviews"
     barHeight odd ifTrue:[
-	barHeight := barHeight + 1
+        barHeight := barHeight + 1
     ]
+
+    "Modified: 7.11.1996 / 20:07:11 / cg"
+!
+
+handleImage:aBitmapOrImage
+    "define the handles image"
+
+    shadowForm := aBitmapOrImage.
+    lightForm := nil.
+    self computeBarHeight.
+
+    "Created: 7.11.1996 / 20:21:10 / cg"
+    "Modified: 7.11.1996 / 20:27:22 / cg"
 !
 
 handleLabels:aCollectionOfLabels
@@ -609,6 +689,17 @@
     handlePosition := aSymbol
 !
 
+handleShadowImage:shadowImage lightImage:lightImage
+    "define the handles image; both shadow and light parts"
+
+    shadowForm := shadowImage.
+    lightForm := lightImage.
+    self computeBarHeight.
+
+    "Created: 7.11.1996 / 20:21:51 / cg"
+    "Modified: 7.11.1996 / 20:27:26 / cg"
+!
+
 handleStyle:styleSymbol
     "define the style of the handle;
      styleSymbol may be #motif to draw a little knob or
@@ -658,7 +749,7 @@
 drawHandle:hIndex atX:hx y:hy
     "draw a single handle at hx/hy"
 
-    |h w x y m lbl|
+    |h w x y m lbl maxKnob|
 
     handleStyle isNil ifTrue:[^ self].
 
@@ -666,8 +757,11 @@
     shadowForm notNil ifTrue:[
         h := shadowForm height.
         w := shadowForm width .
+        maxKnob := h min:barHeight.
     ] ifFalse:[
-        h := w := knobHeight - 4.
+        maxKnob := knobHeight min: barHeight.
+        maxKnob := maxKnob max:4.
+        w := h := maxKnob - 4.
     ].
 
     self paint:viewBackground.
@@ -677,10 +771,11 @@
                      height:barHeight.
 
         (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-            m := (knobHeight - h) // 2.
+            m := (maxKnob - h) // 2.
 
             shadowForm isNil ifTrue:[
-                y := hy + (barHeight // 2).
+
+                y := hy + (barHeight // 2).   "/ center of the bar
 
                 separatingLine ifTrue:[
                     self paint:shadowColor.
@@ -702,6 +797,7 @@
                     handleStyle == #st80 ifTrue:[
                         y := y - 1
                     ].
+
                     self drawEdgesForX:(hx - barWidth)
                                      y:(y + m)
                                  width:(barWidth + barWidth)
@@ -720,6 +816,7 @@
                 y := hy.
                 self drawHandleFormAtX:hx y:(y + m)
             ].
+
             handleStyle == #st80 ifTrue:[
                 y := hy - 1.
                 self paint:lightColor.
@@ -758,6 +855,7 @@
         self fillRectangleX:hx y:margin 
                       width:barHeight
                      height:(height - margin - margin).
+
         (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
              m := (barHeight - w) // 2.
              shadowForm isNil ifTrue:[
@@ -822,17 +920,23 @@
         ]
     ].
 
-    "Modified: 7.11.1996 / 17:23:51 / cg"
+    "Modified: 7.11.1996 / 20:26:31 / cg"
 !
 
 drawHandleFormAtX:hx y:hy
     "draw a handles bitmap at hx/hy"
 
-    self paint:shadowColor.
-    self displayForm:shadowForm x:hx y:hy.
-    self paint:lightColor.
-    self displayForm:lightForm x:hx y:hy.
+    shadowForm notNil ifTrue:[
+        self paint:shadowColor.
+        self displayForm:shadowForm x:hx y:hy.
+    ].
+    lightForm notNil ifTrue:[
+        self paint:lightColor.
+        self displayForm:lightForm x:hx y:hy.
+    ].
     self paint:viewBackground
+
+    "Modified: 7.11.1996 / 20:25:33 / cg"
 !
 
 invertHandleBarAtX:hx y:hy
@@ -910,7 +1014,7 @@
 computeBarHeight
     |bH h|
 
-    handleStyle == #next ifTrue:[
+    shadowForm notNil ifTrue:[
         bH := shadowForm height + 2.
     ] ifFalse:[
         self is3D ifTrue:[
@@ -920,6 +1024,7 @@
         ].
         bH := (h * device verticalPixelPerMillimeter) rounded.
     ].
+    self barHeight:bH.
     knobHeight := bH.
 
     handleLabels notNil ifTrue:[
@@ -936,7 +1041,7 @@
 
     self barHeight:bH.
 
-    "Modified: 7.11.1996 / 17:22:32 / cg"
+    "Modified: 7.11.1996 / 20:27:13 / cg"
 !
 
 defaultControllerClass
@@ -1282,5 +1387,5 @@
 !VariablePanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/VarPanel.st,v 1.16 1996-11-07 16:28:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/VarPanel.st,v 1.17 1996-11-07 19:40:19 cg Exp $'
 ! !
--- a/VariablePanel.st	Thu Nov 07 17:32:48 1996 +0100
+++ b/VariablePanel.st	Thu Nov 07 20:40:19 1996 +0100
@@ -159,7 +159,7 @@
 
 
 
-   example (change the handles level):
+   change the handles level:
                                                                         [exBegin]
         |top p v1 v2 v3|
 
@@ -186,7 +186,7 @@
 
 
 
-   example (change the handles style to nil makes it invisible):
+   change the handles style to nil makes it invisible:
                                                                         [exBegin]
         |top p v1 v2 v3|
 
@@ -213,7 +213,74 @@
 
 
 
-    example (placing scrolled and unscrolled views into a variablePanel):
+   define your own handle (-bitmap):
+                                                                        [exBegin]
+        |top p v1 v2 v3|
+
+        top := StandardSystemView new.
+        top extent:300@300.
+
+        p := VariablePanel 
+                 origin:0.0 @ 0.0
+                 corner:1.0 @ 1.0
+                 in:top.
+        p orientation:#vertical.
+        p handleImage:(Image fromFile:'bitmaps/ScrollLt.8.xbm').
+
+        v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p.
+        v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p.
+        v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p.
+
+        v1 viewBackground:(Color red).
+        v2 viewBackground:(Color green).
+        v3 viewBackground:(Color yellow).
+
+        top open
+                                                                        [exEnd]
+
+
+
+   another handle-bitmap:
+                                                                        [exBegin]
+        |top p v1 v2 v3|
+
+        top := StandardSystemView new.
+        top extent:300@300.
+
+        p := VariablePanel 
+                 origin:0.0 @ 0.0
+                 corner:1.0 @ 1.0
+                 in:top.
+        p orientation:#vertical.
+        p handleImage:(Form width:9
+                            height:11
+                            fromArray:#(
+                                        2r00000000 2r00000000
+                                        2r00001000 2r00000000
+                                        2r00011100 2r00000000
+                                        2r00111110 2r00000000
+                                        2r01111111 2r00000000
+                                        2r00000000 2r00000000
+                                        2r01111111 2r00000000
+                                        2r00111110 2r00000000
+                                        2r00011100 2r00000000
+                                        2r00001000 2r00000000
+                                        2r00000000 2r00000000
+                                       )
+                      ).
+
+        v1 := View origin:0.0@0.0 corner:1.0@(1/3) in:p.
+        v2 := View origin:0.0@(1/3) corner:1.0@(2/3) in:p.
+        v3 := View origin:0.0@(2/3) corner:1.0@1.0 in:p.
+
+        v1 viewBackground:(Color red).
+        v2 viewBackground:(Color green).
+        v3 viewBackground:(Color yellow).
+
+        top open
+                                                                        [exEnd]
+
+    placing scrolled and unscrolled views into a variablePanel:
                                                                         [exBegin]
         |top p v1 v2 v3|
 
@@ -248,7 +315,7 @@
                                                                         [exEnd]
 
 
-    example: (dynamically adding/removing views):
+    dynamically adding/removing views:
                                                                         [exBegin]
         |top p v1 v2 b|
 
@@ -289,7 +356,7 @@
                                                                         [exEnd]
 
 
-    example: (dynamically flipping orientation):
+    dynamically flipping orientation:
     Notice: you have to change the relative bounds of the subviews first.
                                                                         [exBegin]
         |top p v1 v2 b|
@@ -331,7 +398,7 @@
                                                                         [exEnd]
 
 
-   example (combining fix-size with variable size):
+   combining fix-size with variable size:
    (need 3 extra frame-views to place the extra labels into)
                                                                         [exBegin]
         |top p v1 l1 v2 l2 v3 l3 f1 f2 f3|
@@ -568,13 +635,26 @@
 
     "if screen is very low-res, make certain bar is visible and catchable"
     (barHeight < 4) ifTrue:[
-	barHeight := 4
+        barHeight := 4
     ].
 
-    "make it even so spacing is equally spreadable among subviews"
+    "make it even, so spacing is equally spreadable among subviews"
     barHeight odd ifTrue:[
-	barHeight := barHeight + 1
+        barHeight := barHeight + 1
     ]
+
+    "Modified: 7.11.1996 / 20:07:11 / cg"
+!
+
+handleImage:aBitmapOrImage
+    "define the handles image"
+
+    shadowForm := aBitmapOrImage.
+    lightForm := nil.
+    self computeBarHeight.
+
+    "Created: 7.11.1996 / 20:21:10 / cg"
+    "Modified: 7.11.1996 / 20:27:22 / cg"
 !
 
 handleLabels:aCollectionOfLabels
@@ -609,6 +689,17 @@
     handlePosition := aSymbol
 !
 
+handleShadowImage:shadowImage lightImage:lightImage
+    "define the handles image; both shadow and light parts"
+
+    shadowForm := shadowImage.
+    lightForm := lightImage.
+    self computeBarHeight.
+
+    "Created: 7.11.1996 / 20:21:51 / cg"
+    "Modified: 7.11.1996 / 20:27:26 / cg"
+!
+
 handleStyle:styleSymbol
     "define the style of the handle;
      styleSymbol may be #motif to draw a little knob or
@@ -658,7 +749,7 @@
 drawHandle:hIndex atX:hx y:hy
     "draw a single handle at hx/hy"
 
-    |h w x y m lbl|
+    |h w x y m lbl maxKnob|
 
     handleStyle isNil ifTrue:[^ self].
 
@@ -666,8 +757,11 @@
     shadowForm notNil ifTrue:[
         h := shadowForm height.
         w := shadowForm width .
+        maxKnob := h min:barHeight.
     ] ifFalse:[
-        h := w := knobHeight - 4.
+        maxKnob := knobHeight min: barHeight.
+        maxKnob := maxKnob max:4.
+        w := h := maxKnob - 4.
     ].
 
     self paint:viewBackground.
@@ -677,10 +771,11 @@
                      height:barHeight.
 
         (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-            m := (knobHeight - h) // 2.
+            m := (maxKnob - h) // 2.
 
             shadowForm isNil ifTrue:[
-                y := hy + (barHeight // 2).
+
+                y := hy + (barHeight // 2).   "/ center of the bar
 
                 separatingLine ifTrue:[
                     self paint:shadowColor.
@@ -702,6 +797,7 @@
                     handleStyle == #st80 ifTrue:[
                         y := y - 1
                     ].
+
                     self drawEdgesForX:(hx - barWidth)
                                      y:(y + m)
                                  width:(barWidth + barWidth)
@@ -720,6 +816,7 @@
                 y := hy.
                 self drawHandleFormAtX:hx y:(y + m)
             ].
+
             handleStyle == #st80 ifTrue:[
                 y := hy - 1.
                 self paint:lightColor.
@@ -758,6 +855,7 @@
         self fillRectangleX:hx y:margin 
                       width:barHeight
                      height:(height - margin - margin).
+
         (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
              m := (barHeight - w) // 2.
              shadowForm isNil ifTrue:[
@@ -822,17 +920,23 @@
         ]
     ].
 
-    "Modified: 7.11.1996 / 17:23:51 / cg"
+    "Modified: 7.11.1996 / 20:26:31 / cg"
 !
 
 drawHandleFormAtX:hx y:hy
     "draw a handles bitmap at hx/hy"
 
-    self paint:shadowColor.
-    self displayForm:shadowForm x:hx y:hy.
-    self paint:lightColor.
-    self displayForm:lightForm x:hx y:hy.
+    shadowForm notNil ifTrue:[
+        self paint:shadowColor.
+        self displayForm:shadowForm x:hx y:hy.
+    ].
+    lightForm notNil ifTrue:[
+        self paint:lightColor.
+        self displayForm:lightForm x:hx y:hy.
+    ].
     self paint:viewBackground
+
+    "Modified: 7.11.1996 / 20:25:33 / cg"
 !
 
 invertHandleBarAtX:hx y:hy
@@ -910,7 +1014,7 @@
 computeBarHeight
     |bH h|
 
-    handleStyle == #next ifTrue:[
+    shadowForm notNil ifTrue:[
         bH := shadowForm height + 2.
     ] ifFalse:[
         self is3D ifTrue:[
@@ -920,6 +1024,7 @@
         ].
         bH := (h * device verticalPixelPerMillimeter) rounded.
     ].
+    self barHeight:bH.
     knobHeight := bH.
 
     handleLabels notNil ifTrue:[
@@ -936,7 +1041,7 @@
 
     self barHeight:bH.
 
-    "Modified: 7.11.1996 / 17:22:32 / cg"
+    "Modified: 7.11.1996 / 20:27:13 / cg"
 !
 
 defaultControllerClass
@@ -1282,5 +1387,5 @@
 !VariablePanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.16 1996-11-07 16:28:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.17 1996-11-07 19:40:19 cg Exp $'
 ! !