VariableVerticalPanel.st
changeset 59 450ce95a72a4
parent 38 4b9b70b2cc87
child 60 f3c738c24ce6
equal deleted inserted replaced
58:28815246bbc1 59:450ce95a72a4
     1 "
     1 "
     2  COPYRIGHT (c) 1991 by Claus Gittinger
     2  COPYRIGHT (c) 1991 by Claus Gittinger
     3               All Rights Reserved
     3 	      All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     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
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 View subclass:#VariableVerticalPanel
    13 View subclass:#VariableVerticalPanel
    14          instanceVariableNames:'movedHandle prev start
    14 	 instanceVariableNames:'movedHandle prev start
    15                                 barHeight barWidth separatingLine
    15 				barHeight barWidth separatingLine
    16                                 shadowForm lightForm
    16 				shadowForm lightForm
    17                                 showHandle handlePosition 
    17 				showHandle handlePosition 
    18                                 handleColor noColor
    18 				handleColor handleStyle noColor
    19                                 trackLine'
    19 				trackLine'
    20          classVariableNames:''
    20 	 classVariableNames:'DefaultShowHandle DefaultHandleStyle DefaultHandlePosition
    21          poolDictionaries:''
    21 			     DefaultTrackingLine DefaultSeparatingLine DefaultHandleColor'
    22          category:'Views-Layout'
    22 	 poolDictionaries:''
       
    23 	 category:'Views-Layout'
    23 !
    24 !
    24 
    25 
    25 VariableVerticalPanel comment:'
    26 VariableVerticalPanel comment:'
    26 COPYRIGHT (c) 1991 by Claus Gittinger
    27 COPYRIGHT (c) 1991 by Claus Gittinger
    27               All Rights Reserved
    28 	      All Rights Reserved
    28 
    29 
    29 $Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.7 1994-08-07 13:23:37 claus Exp $
    30 $Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.8 1994-10-10 03:03:22 claus Exp $
    30 '!
    31 '!
    31 
    32 
    32 !VariableVerticalPanel class methodsFor:'documentation'!
    33 !VariableVerticalPanel class methodsFor:'documentation'!
    33 
    34 
    34 copyright
    35 copyright
    35 "
    36 "
    36  COPYRIGHT (c) 1991 by Claus Gittinger
    37  COPYRIGHT (c) 1991 by Claus Gittinger
    37               All Rights Reserved
    38 	      All Rights Reserved
    38 
    39 
    39  This software is furnished under a license and may be used
    40  This software is furnished under a license and may be used
    40  only in accordance with the terms of that license and with the
    41  only in accordance with the terms of that license and with the
    41  inclusion of the above copyright notice.   This software may not
    42  inclusion of the above copyright notice.   This software may not
    42  be provided or otherwise made available to, or used by, any
    43  be provided or otherwise made available to, or used by, any
    45 "
    46 "
    46 !
    47 !
    47 
    48 
    48 version
    49 version
    49 "
    50 "
    50 $Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.7 1994-08-07 13:23:37 claus Exp $
    51 $Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.8 1994-10-10 03:03:22 claus Exp $
    51 "
    52 "
    52 !
    53 !
    53 
    54 
    54 documentation
    55 documentation
    55 "
    56 "
    61     or nothing.
    62     or nothing.
    62 
    63 
    63     The subvies dimensions MUST be given as relative sizes;
    64     The subvies dimensions MUST be given as relative sizes;
    64     typically creation is done as:
    65     typically creation is done as:
    65 
    66 
    66         p := VariableVerticalPanel in:superView.
    67 	p := VariableVerticalPanel in:superView.
    67         v1 := <someViewClass> origin:0.0 @ 0.0
    68 	v1 := <someViewClass> origin:0.0 @ 0.0
    68                               corner:1.0 @ 0.5
    69 			      corner:1.0 @ 0.5
    69                                   in:p.
    70 				  in:p.
    70         v2 := <someViewClass> origin:0.0 @ 0.5 
    71 	v2 := <someViewClass> origin:0.0 @ 0.5 
    71                               corner:1.0 @ 0.8 
    72 			      corner:1.0 @ 0.8 
    72                                   in:p.
    73 				  in:p.
    73         v3 := <someViewClass> origin:0.0 @ 0.8 
    74 	v3 := <someViewClass> origin:0.0 @ 0.8 
    74                               corner:1.0 @ 1.0
    75 			      corner:1.0 @ 1.0
    75                                   in:p.
    76 				  in:p.
    76 
    77 
    77    example:
    78    example:
    78         |top p v1 v2 v3|
    79 	|top p v1 v2 v3|
    79 
    80 
    80         top := StandardSystemView new.
    81 	top := StandardSystemView new.
    81         top extent:300@300.
    82 	top extent:300@300.
    82 
    83 
    83         p := VariableVerticalPanel 
    84 	p := VariableVerticalPanel 
    84                  origin:0.0 @ 0.0
    85 		 origin:0.0 @ 0.0
    85                  corner:1.0 @ 1.0
    86 		 corner:1.0 @ 1.0
    86                  in:top.
    87 		 in:top.
    87         v1 := ScrollableView for:SelectionInListView in:p.
    88 	v1 := ScrollableView for:SelectionInListView in:p.
    88         v1 origin:0.0 @ 0.0
    89 	v1 origin:0.0 @ 0.0
    89            corner:1.0 @ 0.5.
    90 	   corner:1.0 @ 0.5.
    90         v1 list:(FileDirectory directoryNamed:'/etc') contents.
    91 	v1 list:(FileDirectory directoryNamed:'/etc') contents.
    91         v1 action:[:selNr |
    92 	v1 action:[:selNr |
    92                 |fullName stream text|
    93 		|fullName stream text|
    93                 fullName := '/etc/' , v1 selectionValue.
    94 		fullName := '/etc/' , v1 selectionValue.
    94                 stream := fullName asFilename readStream.
    95 		stream := fullName asFilename readStream.
    95                 stream notNil ifTrue:[
    96 		stream notNil ifTrue:[
    96                     text := stream contents.
    97 		    text := stream contents.
    97                     v2 contents:text.
    98 		    v2 contents:text.
    98                     v3 contents:text
    99 		    v3 contents:text
    99                 ]
   100 		]
   100         ].
   101 	].
   101 
   102 
   102         v2 := TextView 
   103 	v2 := TextView 
   103                  origin:0.0 @ 0.5 
   104 		 origin:0.0 @ 0.5 
   104                  corner:1.0 @ 0.8 
   105 		 corner:1.0 @ 0.8 
   105                  in:p.
   106 		 in:p.
   106         v3 := ScrollableView 
   107 	v3 := ScrollableView 
   107                  for:EditTextView 
   108 		 for:EditTextView 
   108                  in:p.
   109 		 in:p.
   109         v3 origin:0.0 @ 0.8 
   110 	v3 origin:0.0 @ 0.8 
   110            corner:1.0 @ 1.0.
   111 	   corner:1.0 @ 1.0.
   111         top open
   112 	top open
   112 "
   113 "
   113 ! !
   114 ! !
   114 
   115 
   115 !VariableVerticalPanel class methodsFor:'defaults'!
   116 !VariableVerticalPanel class methodsFor:'defaults'!
   116 
   117 
   122 
   123 
   123 lightFormOn:aDisplay
   124 lightFormOn:aDisplay
   124     "use same handle as Scroller"
   125     "use same handle as Scroller"
   125 
   126 
   126     ^ Scroller handleLightFormOn:aDisplay
   127     ^ Scroller handleLightFormOn:aDisplay
       
   128 !
       
   129 
       
   130 updateStyleCache
       
   131     DefaultShowHandle := StyleSheet at:'variablePanelShowHandle' default:true.
       
   132     DefaultHandleStyle := StyleSheet at:'variablePanelHandleStyle'.
       
   133     DefaultHandlePosition := StyleSheet at:'variablePanelHandlePosition' default:#right.
       
   134     DefaultTrackingLine := StyleSheet at:'variablePanelTrackingLine' default:false.
       
   135     DefaultSeparatingLine := StyleSheet at:'variablePanelSeparatingLine' default:false.
       
   136     DefaultHandleColor := StyleSheet at:'variablePanelHandleColor' default:Black.
   127 ! !
   137 ! !
   128 
   138 
   129 !VariableVerticalPanel methodsFor:'initializing'!
   139 !VariableVerticalPanel methodsFor:'initializing'!
   130 
   140 
   131 initialize
   141 initialize
   132     super initialize.
   142     super initialize.
   133     noColor := Color noColor.
   143     noColor := Color noColor.
   134     handleColor := Black.
       
   135 !
   144 !
   136 
   145 
   137 initStyle
   146 initStyle
       
   147     |mm|
       
   148 
   138     super initStyle.
   149     super initStyle.
   139 
   150 
   140     showHandle := style ~~ #mswindows.
   151     handleColor := DefaultHandleColor on:device.
   141 
   152 
   142     (style == #next) ifTrue:[
   153     showHandle := DefaultShowHandle.
   143         shadowForm := self class shadowFormOn:device.
   154 
   144         lightForm := self class lightFormOn:device.
   155     DefaultHandleStyle isNil ifTrue:[
   145         self barHeight:(shadowForm height + 2).
   156 	handleStyle := style
   146         barWidth := shadowForm width.
   157     ] ifFalse:[
   147         handlePosition := #center.
   158 	handleStyle := DefaultHandleStyle
   148     ] ifFalse:[
   159     ].
   149         shadowForm := lightForm := nil.
   160     handleStyle == #next ifTrue:[
   150         handlePosition := #right
   161 	shadowForm := self class shadowFormOn:device.
   151     ].
   162 	lightForm := self class lightFormOn:device.
   152 
   163 
   153     style == #motif ifTrue:[
   164 	self barHeight:(shadowForm height + 2).
   154         trackLine := true.
   165 	barWidth := shadowForm width.
   155         separatingLine := "true" false. "its so ugly"
   166     ] ifFalse:[
   156     ] ifFalse:[
   167 	shadowForm := lightForm := nil.
   157         trackLine := false.
   168     ].
   158         separatingLine := false
   169 
   159     ].
   170     handlePosition := DefaultHandlePosition.
   160 
   171     trackLine := DefaultTrackingLine.
       
   172     separatingLine := DefaultSeparatingLine.
       
   173 
       
   174     mm := device verticalPixelPerMillimeter.
   161     self is3D ifTrue:[
   175     self is3D ifTrue:[
   162         self barHeight:(3 * ViewSpacing)
   176 	self barHeight:(3 * mm) rounded
   163     ] ifFalse:[
   177     ] ifFalse:[
   164         self barHeight:(2 * ViewSpacing)
   178 	self barHeight:(2 * mm) rounded
   165     ].
   179     ].
   166     barWidth := 2 * ViewSpacing. "motif style width"
   180     barWidth := (2 * mm) rounded. "motif style width"
   167 !
   181 !
   168 
   182 
   169 initCursor
   183 initCursor
   170     "set the cursor - a double arrow"
   184     "set the cursor - a double arrow"
   171 
   185 
   172     cursor := Cursor sourceForm:(Form fromFile:'VVPanel.xbm')
   186     cursor := Cursor sourceForm:(Form fromFile:'VVPanel.xbm')
   173                      maskForm:(Form fromFile:'VVPanel_m.xbm')
   187 		     maskForm:(Form fromFile:'VVPanel_m.xbm')
   174                      hotX:8
   188 		     hotX:8
   175                      hotY:8.
   189 		     hotY:8.
   176     "
   190     "
   177      if bitmaps are not available, use a standard cursor
   191      if bitmaps are not available, use a standard cursor
   178     "
   192     "
   179     cursor isNil ifTrue:[
   193     cursor isNil ifTrue:[
   180         "which one looks better ?"
   194 	"which one looks better ?"
   181         cursor := Cursor upDownArrow
   195 	cursor := Cursor upDownArrow
   182         "cursor := Cursor upLimitArrow"
   196 	"cursor := Cursor upLimitArrow"
   183     ]
   197     ]
   184 !
   198 !
   185 
   199 
   186 initEvents
   200 initEvents
   187     self enableButtonEvents.
   201     self enableButtonEvents.
   188     self enableButtonMotionEvents
   202     self enableButtonMotionEvents
   189 !
   203 !
   190 
   204 
   191 fixSize 
   205 fixSize 
   192     extentChanged ifTrue:[
   206     extentChanged ifTrue:[
   193         super fixSize.
   207 	super fixSize.
   194         self resizeSubviewsFrom:1 to:(subViews size)
   208 	self resizeSubviewsFrom:1 to:(subViews size)
   195     ] ifFalse:[
   209     ] ifFalse:[
   196         super fixSize
   210 	super fixSize
   197     ]
   211     ]
   198 ! !
   212 ! !
   199 
   213 
   200 !VariableVerticalPanel methodsFor:'accessing'!
   214 !VariableVerticalPanel methodsFor:'accessing'!
   201 
   215 
   204 
   218 
   205 "obsolete" self halt.
   219 "obsolete" self halt.
   206 
   220 
   207     super add:aView.
   221     super add:aView.
   208     shown ifTrue:[
   222     shown ifTrue:[
   209         (superView isNil or:[superView shown]) ifTrue:[
   223 	(superView isNil or:[superView shown]) ifTrue:[
   210             self setupSubviewSizes
   224 	    self setupSubviewSizes
   211         ]
   225 	]
   212     ]
   226     ]
   213 !
   227 !
   214 
   228 
   215 removeSubView:aView
   229 removeSubView:aView
   216     "a view is removed; adjust other subviews sizes"
   230     "a view is removed; adjust other subviews sizes"
   217 
   231 
   218     super removeSubView:aView.
   232     super removeSubView:aView.
   219     shown ifTrue:[
   233     shown ifTrue:[
   220         (superView isNil or:[superView shown]) ifTrue:[
   234 	(superView isNil or:[superView shown]) ifTrue:[
   221             self setupSubviewSizes
   235 	    self setupSubviewSizes
   222         ]
   236 	]
   223     ]
   237     ]
   224 !
   238 !
   225 
   239 
   226 barHeight:nPixel
   240 barHeight:nPixel
   227     "set the height of the separating bar"
   241     "set the height of the separating bar"
   228 
   242 
   229     barHeight := nPixel.
   243     barHeight := nPixel.
   230 
   244 
   231     "if screen is very low-res, make certain bar is visible and catchable"
   245     "if screen is very low-res, make certain bar is visible and catchable"
   232     (barHeight < 4) ifTrue:[
   246     (barHeight < 4) ifTrue:[
   233         barHeight := 4
   247 	barHeight := 4
   234     ].
   248     ].
   235 
   249 
   236     "make it even so spacing is equally spreadable among subviews"
   250     "make it even so spacing is equally spreadable among subviews"
   237     barHeight odd ifTrue:[
   251     barHeight odd ifTrue:[
   238         barHeight := barHeight + 1
   252 	barHeight := barHeight + 1
   239     ]
   253     ]
   240 !
   254 !
   241 
   255 
   242 handlePosition:aSymbol
   256 handlePosition:aSymbol
   243     "define the position of the handle; the argument aSymbol
   257     "define the position of the handle; the argument aSymbol
   255 style:styleSymbol
   269 style:styleSymbol
   256     "define the style of the handle;
   270     "define the style of the handle;
   257      styleSymbol may be #motif to draw a little knob or
   271      styleSymbol may be #motif to draw a little knob or
   258      enything else to draw scrollBars handleForm"
   272      enything else to draw scrollBars handleForm"
   259 
   273 
   260     (styleSymbol ~~ style) ifTrue:[
   274     (styleSymbol ~~ handleStyle) ifTrue:[
   261         style := styleSymbol.
   275 	handleStyle := styleSymbol.
   262         style == #next ifTrue:[
   276 	handleStyle == #next ifTrue:[
   263             shadowForm := self class shadowFormOn:device.
   277 	    shadowForm := self class shadowFormOn:device.
   264             lightForm := self class lightFormOn:device.
   278 	    lightForm := self class lightFormOn:device.
   265         ] ifFalse:[
   279 	] ifFalse:[
   266             shadowForm := lightForm := nil
   280 	    shadowForm := lightForm := nil
   267         ].
   281 	].
   268 
   282 
   269         shadowForm notNil ifTrue:[
   283 	shadowForm notNil ifTrue:[
   270             (self is3D and:[style ~~ #motif]) ifTrue:[
   284 	    (self is3D and:[handleStyle ~~ #motif]) ifTrue:[
   271                 self barHeight:(shadowForm height + 2).
   285 		self barHeight:(shadowForm height + 2).
   272                 barWidth := shadowForm width
   286 		barWidth := shadowForm width
   273             ]
   287 	    ]
   274         ].
   288 	].
   275         shown ifTrue:[
   289 	shown ifTrue:[
   276             self resizeSubviewsFrom:1 to:(subViews size).
   290 	    self resizeSubviewsFrom:1 to:(subViews size).
   277             self redraw
   291 	    self redraw
   278         ]
   292 	]
   279     ]
   293     ]
   280 ! !
   294 ! !
   281 
   295 
   282 !VariableVerticalPanel methodsFor:'drawing'!
   296 !VariableVerticalPanel methodsFor:'drawing'!
   283 
   297 
   284 drawHandleFormAtX:hx y:hy
   298 drawHandleFormAtX:hx y:hy
   285     "kludge for now"
   299     self paint:shadowColor.
   286     (viewBackground colorId notNil
   300     self displayForm:shadowForm x:hx y:hy.
   287      and:[shadowColor colorId notNil
   301     self paint:lightColor.
   288           and:[lightColor colorId notNil]]) ifTrue:[
   302     self displayForm:lightForm x:hx y:hy.
   289         self foreground:viewBackground background:noColor function:#xor.
   303     self paint viewBackground
   290         self displayOpaqueForm:shadowForm x:hx y:hy.
       
   291         self foreground:shadowColor function:#or.
       
   292         self displayOpaqueForm:shadowForm x:hx y:hy.
       
   293         self foreground:viewBackground function:#xor.
       
   294         self displayOpaqueForm:lightForm x:hx y:hy.
       
   295         self foreground:lightColor function:#or.
       
   296         self displayOpaqueForm:lightForm x:hx y:hy.
       
   297 
       
   298         self foreground:viewBackground.
       
   299         paint := nil. "kludge to force paint to be really set"
       
   300         self paint:viewBackground.
       
   301         self function:#copy
       
   302     ]
       
   303 !
   304 !
   304 
   305 
   305 drawHandleAtX:hx y:hy
   306 drawHandleAtX:hx y:hy
   306     |h y m|
   307     |h y m|
   307 
   308 
   308     (self is3D and:[shadowForm notNil]) ifTrue:[
   309     shadowForm notNil ifTrue:[
   309         h := shadowForm height
   310 	h := shadowForm height
   310     ] ifFalse:[
   311     ] ifFalse:[
   311         h := barHeight - 4
   312 	h := barHeight - 4
   312     ].
   313     ].
   313 
   314 
   314     self paint:viewBackground.
   315     self paint:viewBackground.
   315     self fillRectangleX:margin y:hy 
   316     self fillRectangleX:margin y:hy 
   316                   width:(width - margin - margin) 
   317 		  width:(width - margin - margin) 
   317                   height:barHeight.
   318 		  height:barHeight.
   318 
   319 
   319     self is3D ifTrue:[
   320     (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
   320         m := (barHeight - h) // 2.
   321 	m := (barHeight - h) // 2.
   321         shadowForm isNil ifTrue:[
   322 	shadowForm isNil ifTrue:[
   322             y := hy + (barHeight // 2).
   323 	    y := hy + (barHeight // 2).
   323             separatingLine ifTrue:[
   324 	    separatingLine ifTrue:[
   324                 self paint:shadowColor.
   325 		self paint:shadowColor.
   325                 self displayLineFromX:margin y:y toX:(width - margin) y:y.
   326 		self displayLineFromX:margin y:y toX:(width - margin) y:y.
   326                 y := y + 1.
   327 		y := y + 1.
   327                 self paint:lightColor.
   328 		self paint:lightColor.
   328                 self displayLineFromX:margin y:y toX:(width - margin) y:y.
   329 		self displayLineFromX:margin y:y toX:(width - margin) y:y.
   329             ].
   330 	    ].
   330             self paint:viewBackground.
   331 	    self paint:viewBackground.
   331             self fillRectangleX:(hx - barWidth) y:hy 
   332 	    self fillRectangleX:(hx - barWidth) y:hy 
   332                          width:(barWidth + barWidth) 
   333 			 width:(barWidth + barWidth) 
   333                          height:h.
   334 			 height:h.
   334 
   335 
   335             "/ y := hy.   "old"
   336 	    y := hy.   
   336             y := hy - 1.  "2.10.3"
   337 	    handleStyle == #st80 ifTrue:[
   337             self drawEdgesForX:(hx - barWidth)
   338 		y := y - 1
   338                              y:(y + m)
   339 	    ].
   339                          width:(barWidth + barWidth)
   340 	    self drawEdgesForX:(hx - barWidth)
   340                         height:h level:2
   341 			     y:(y + m)
   341         ] ifFalse:[
   342 			 width:(barWidth + barWidth)
   342             "/ y := hy.   "old"
   343 			height:h 
   343             y := hy - 1.  "2.10.3"
   344 			 level:2
   344             self drawHandleFormAtX:hx y:(y + m)
   345 	] ifFalse:[
   345         ].
   346 	    y := hy.
   346         style == #st80 ifTrue:[
   347 	    self drawHandleFormAtX:hx y:(y + m)
   347             y := hy - 1.
   348 	].
   348             self paint:lightColor.
   349 	handleStyle == #st80 ifTrue:[
   349             self displayLineFromX:margin y:y toX:(width - margin) y:y.
   350 	    y := hy - 1.
   350             y := hy + barHeight - 2.
   351 	    self paint:lightColor.
   351             self paint:shadowColor.
   352 	    self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y.
   352             self displayLineFromX:margin y:y toX:(width - margin) y:y.
   353 	    self displayLineFromX:0 y:hy toX:0 y:(hy + barHeight - 1).
   353         ].
   354 	    y := hy + barHeight - 2.
   354     ] ifFalse:[
   355 	    self paint:shadowColor.
   355         y := hy + barHeight - 1.
   356 	    self displayLineFromX:margin y:y toX:(width - margin) y:y.
   356         self paint:handleColor.
   357 		"uncomment the -1 if you dont like the notch at the right end"
   357         separatingLine ifTrue:[
   358 		"                            VVV"
   358             self displayLineFromX:0 y:hy+1 toX:width y:hy+1.
   359 	    self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + barHeight - 1).
   359             self displayLineFromX:0 y:y toX:width y:y.
   360 	].
   360         ].
   361     ] ifFalse:[
   361         self fillRectangleX:hx y:hy width:barHeight height:barHeight
   362 	y := hy + barHeight - 1.
       
   363 	self paint:handleColor.
       
   364 	separatingLine ifTrue:[
       
   365 	    self displayLineFromX:0 y:hy+1 toX:width y:hy+1.
       
   366 	    self displayLineFromX:0 y:y toX:width y:y.
       
   367 	].
       
   368 	self fillRectangleX:hx y:hy width:barHeight height:barHeight
   362     ]
   369     ]
   363 !
   370 !
   364 
   371 
   365 redrawHandlesFrom:start to:stop
   372 redrawHandlesFrom:start to:stop
   366     "redraw some handles"
   373     "redraw some handles"
   367 
   374 
   368     subViews notNil ifTrue:[
   375     subViews notNil ifTrue:[
   369         showHandle ifTrue:[
   376 	showHandle ifTrue:[
   370             self handleOriginsFrom:start to:stop do:[:hPoint |
   377 	    self handleOriginsFrom:start to:stop do:[:hPoint |
   371                 self drawHandleAtX:(hPoint x) y:(hPoint y)
   378 		self drawHandleAtX:(hPoint x) y:(hPoint y)
   372             ].
   379 	    ].
   373             movedHandle notNil ifTrue:[
   380 	    movedHandle notNil ifTrue:[
   374                 self noClipByChildren.
   381 		self noClipByChildren.
   375                 self xoring:[
   382 		self xoring:[
   376                     trackLine ifTrue:[
   383 		    trackLine ifTrue:[
   377                         self displayLineFromX:0 y:prev+(barHeight // 2)
   384 			self displayLineFromX:0 y:prev+(barHeight // 2)
   378                                           toX:width y:prev+(barHeight // 2).
   385 					  toX:width y:prev+(barHeight // 2).
   379                     ] ifFalse:[
   386 		    ] ifFalse:[
   380                         self fillRectangleX:0 y:prev width:width height:barHeight
   387 			self fillRectangleX:0 y:prev width:width height:barHeight
   381                     ]
   388 		    ]
   382                 ].
   389 		].
   383                 self clipByChildren
   390 		self clipByChildren
   384             ]
   391 	    ]
   385         ]
   392 	]
   386     ]
   393     ]
   387 !
   394 !
   388 
   395 
   389 redraw
   396 redraw
   390     "redraw the handles"
   397     "redraw the handles"
   396 
   403 
   397 sizeChanged:how
   404 sizeChanged:how
   398     "tell subviews if I change size"
   405     "tell subviews if I change size"
   399 
   406 
   400     shown ifTrue:[
   407     shown ifTrue:[
   401         (how == #smaller) ifTrue:[
   408 	(how == #smaller) ifTrue:[
   402             self resizeSubviewsFrom:1 to:(subViews size)
   409 	    self resizeSubviewsFrom:1 to:(subViews size)
   403         ] ifFalse:[
   410 	] ifFalse:[
   404             self resizeSubviewsFrom:(subViews size) to:1
   411 	    self resizeSubviewsFrom:(subViews size) to:1
   405         ]
   412 	]
   406     ]
   413     ]
   407 !
   414 !
   408 
   415 
   409 buttonPress:button x:bx y:by
   416 buttonPress:button x:bx y:by
   410     "button was pressed - if it hits a handle, start move"
   417     "button was pressed - if it hits a handle, start move"
   411 
   418 
   412     |handle|
   419     |handle|
   413 
   420 
   414     ((button == 1) or:[button == #select]) ifTrue:[
   421     ((button == 1) or:[button == #select]) ifTrue:[
   415         handle := 1.
   422 	handle := 1.
   416         self handleOriginsDo:[:hPoint |
   423 	self handleOriginsDo:[:hPoint |
   417             |hy|
   424 	    |hy|
   418 
   425 
   419             hy := hPoint y.
   426 	    hy := hPoint y.
   420             (by between:hy and:(hy + barHeight)) ifTrue:[
   427 	    (by between:hy and:(hy + barHeight)) ifTrue:[
   421                 movedHandle := handle.
   428 		movedHandle := handle.
   422                 prev := hy.
   429 		prev := hy.
   423                 start := by - hy.
   430 		start := by - hy.
   424                 self noClipByChildren.
   431 		self noClipByChildren.
   425                 self xoring:[
   432 		self xoring:[
   426                     trackLine ifTrue:[
   433 		    trackLine ifTrue:[
   427                         self displayLineFromX:0 y:hy+(barHeight // 2) 
   434 			self displayLineFromX:0 y:hy+(barHeight // 2) 
   428                                           toX:width y:hy+(barHeight // 2).
   435 					  toX:width y:hy+(barHeight // 2).
   429                     ] ifFalse:[
   436 		    ] ifFalse:[
   430                         self fillRectangleX:0 y:hy width:width height:barHeight
   437 			self fillRectangleX:0 y:hy width:width height:barHeight
   431                     ]
   438 		    ]
   432                 ].
   439 		].
   433                 self clipByChildren.
   440 		self clipByChildren.
   434                 ^ self
   441 		^ self
   435             ].
   442 	    ].
   436             handle := handle + 1
   443 	    handle := handle + 1
   437         ].
   444 	].
   438         movedHandle := nil
   445 	movedHandle := nil
   439     ] ifFalse:[
   446     ] ifFalse:[
   440         super buttonPress:button x:bx y:by
   447 	super buttonPress:button x:bx y:by
   441     ]
   448     ]
   442 !
   449 !
   443 
   450 
   444 buttonMotion:button x:bx y:by
   451 buttonMotion:button x:bx y:by
   445     "mouse-button was moved while pressed;
   452     "mouse-button was moved while pressed;
   457 
   464 
   458     ypos := by - start.
   465     ypos := by - start.
   459     limitTop := barHeight // 2.
   466     limitTop := barHeight // 2.
   460     limitBot := self height - barHeight.
   467     limitBot := self height - barHeight.
   461     movedHandle > 1 ifTrue:[
   468     movedHandle > 1 ifTrue:[
   462         limitTop := (subViews at:movedHandle) origin y + (barHeight // 2)
   469 	limitTop := (subViews at:movedHandle) origin y + (barHeight // 2)
   463     ].
   470     ].
   464     movedHandle < (subViews size - 1) ifTrue:[
   471     movedHandle < (subViews size - 1) ifTrue:[
   465         limitBot := (subViews at:(movedHandle + 2)) origin y - barHeight
   472 	limitBot := (subViews at:(movedHandle + 2)) origin y - barHeight
   466     ].
   473     ].
   467     limitBot := limitBot - barHeight.
   474     limitBot := limitBot - barHeight.
   468     (ypos < limitTop) ifTrue:[ "check against view limits"
   475     (ypos < limitTop) ifTrue:[ "check against view limits"
   469         ypos := limitTop
   476 	ypos := limitTop
   470     ] ifFalse:[
   477     ] ifFalse:[
   471         (ypos > limitBot) ifTrue:[
   478 	(ypos > limitBot) ifTrue:[
   472             ypos := limitBot
   479 	    ypos := limitBot
   473         ]
   480 	]
   474     ].
   481     ].
   475 
   482 
   476     self noClipByChildren.
   483     self noClipByChildren.
   477     self xoring:[
   484     self xoring:[
   478         trackLine ifTrue:[
   485 	trackLine ifTrue:[
   479             self displayLineFromX:0 y:prev+(barHeight // 2) 
   486 	    self displayLineFromX:0 y:prev+(barHeight // 2) 
   480                               toX:width y:prev+(barHeight // 2).
   487 			      toX:width y:prev+(barHeight // 2).
   481             self displayLineFromX:0 y:ypos+(barHeight // 2) 
   488 	    self displayLineFromX:0 y:ypos+(barHeight // 2) 
   482                               toX:width y:ypos+(barHeight // 2).
   489 			      toX:width y:ypos+(barHeight // 2).
   483         ] ifFalse:[
   490 	] ifFalse:[
   484             self fillRectangleX:0 y:prev width:width height:barHeight.
   491 	    self fillRectangleX:0 y:prev width:width height:barHeight.
   485             self fillRectangleX:0 y:ypos width:width height:barHeight
   492 	    self fillRectangleX:0 y:ypos width:width height:barHeight
   486         ]
   493 	]
   487     ].
   494     ].
   488     self clipByChildren.
   495     self clipByChildren.
   489     prev := ypos
   496     prev := ypos
   490 !
   497 !
   491 
   498 
   493     "end bar-move"
   500     "end bar-move"
   494 
   501 
   495     |aboveView belowView aboveIndex belowIndex newY|
   502     |aboveView belowView aboveIndex belowIndex newY|
   496 
   503 
   497     ((button == 1) or:[button == #select]) ifTrue:[
   504     ((button == 1) or:[button == #select]) ifTrue:[
   498         movedHandle isNil ifTrue:[^ self].
   505 	movedHandle isNil ifTrue:[^ self].
   499 
   506 
   500         "undo the last xor"
   507 	"undo the last xor"
   501 
   508 
   502         self noClipByChildren.
   509 	self noClipByChildren.
   503         self xoring:[
   510 	self xoring:[
   504             trackLine ifTrue:[
   511 	    trackLine ifTrue:[
   505                 self displayLineFromX:0 y:prev+(barHeight // 2) 
   512 		self displayLineFromX:0 y:prev+(barHeight // 2) 
   506                                   toX:width y:prev+(barHeight // 2).
   513 				  toX:width y:prev+(barHeight // 2).
   507             ] ifFalse:[
   514 	    ] ifFalse:[
   508                 self fillRectangleX:0 y:prev width:width height:barHeight
   515 		self fillRectangleX:0 y:prev width:width height:barHeight
   509             ].
   516 	    ].
   510         ].
   517 	].
   511         self clipByChildren.
   518 	self clipByChildren.
   512 
   519 
   513         "compute the new relative heights"
   520 	"compute the new relative heights"
   514 
   521 
   515         aboveIndex := movedHandle.
   522 	aboveIndex := movedHandle.
   516         belowIndex := movedHandle + 1.
   523 	belowIndex := movedHandle + 1.
   517         aboveView := subViews at:aboveIndex.
   524 	aboveView := subViews at:aboveIndex.
   518         belowView := subViews at:belowIndex.
   525 	belowView := subViews at:belowIndex.
   519 
   526 
   520         newY := (prev + start / height) asFloat.
   527 	newY := (prev + start / height) asFloat.
   521         aboveView relativeCorner:aboveView relativeCorner x @ newY.
   528 	aboveView relativeCorner:aboveView relativeCorner x @ newY.
   522         belowView relativeOrigin:belowView relativeOrigin x @ newY.
   529 	belowView relativeOrigin:belowView relativeOrigin x @ newY.
   523         self resizeSubviewsFrom:aboveIndex to:belowIndex.
   530 	self resizeSubviewsFrom:aboveIndex to:belowIndex.
   524 
   531 
   525         movedHandle := nil.
   532 	movedHandle := nil.
   526 
   533 
   527         self redrawHandlesFrom:aboveIndex to:belowIndex
   534 	self redrawHandlesFrom:aboveIndex to:belowIndex
   528     ] ifFalse:[
   535     ] ifFalse:[
   529         super buttonRelease:button x:x y:y
   536 	super buttonRelease:button x:x y:y
   530     ]
   537     ]
   531 ! !
   538 ! !
   532 
   539 
   533 !VariableVerticalPanel methodsFor:'private'!
   540 !VariableVerticalPanel methodsFor:'private'!
   534 
   541 
   535 anyNonRelativeSubviews
   542 anyNonRelativeSubviews
   536     "return true, if any of my subviews has no relative origin/extent"
   543     "return true, if any of my subviews has no relative origin/extent"
   537 
   544 
   538     1 to:(subViews size) do:[:index |
   545     1 to:(subViews size) do:[:index |
   539         |view|
   546 	|view|
   540 
   547 
   541         view := subViews at:index.
   548 	view := subViews at:index.
   542         view relativeExtent isNil ifTrue:[^ true].
   549 	view relativeExtent isNil ifTrue:[^ true].
   543         view relativeOrigin isNil ifTrue:[^ true]
   550 	view relativeOrigin isNil ifTrue:[^ true]
   544     ].
   551     ].
   545     ^ false
   552     ^ false
   546 !
   553 !
   547 
   554 
   548 setupSubviewSizes
   555 setupSubviewSizes
   549     "setup subviews sizes (in case of non-relative sizes)"
   556     "setup subviews sizes (in case of non-relative sizes)"
   550 
   557 
   551     |y h|
   558     |y h|
   552 
   559 
   553     self anyNonRelativeSubviews ifTrue:[
   560     self anyNonRelativeSubviews ifTrue:[
   554         "there is at least one subview without
   561 	"there is at least one subview without
   555          relative origin/extent - setup all subviews
   562 	 relative origin/extent - setup all subviews
   556          to spread evenly ..."
   563 	 to spread evenly ..."
   557 
   564 
   558         y := 0.0.
   565 	y := 0.0.
   559         h := 1.0 / (subViews size).
   566 	h := 1.0 / (subViews size).
   560 
   567 
   561         1 to:(subViews size) do:[:index |
   568 	1 to:(subViews size) do:[:index |
   562             |view|
   569 	    |view|
   563 
   570 
   564             view := subViews at:index.
   571 	    view := subViews at:index.
   565             index == subViews size ifTrue:[
   572 	    index == subViews size ifTrue:[
   566                 view origin:(0.0 @ y) corner:(1.0 @ 1.0)
   573 		view origin:(0.0 @ y) corner:(1.0 @ 1.0)
   567             ] ifFalse:[
   574 	    ] ifFalse:[
   568                 view origin:(0.0 @ y) corner:(1.0 @ (y + h))
   575 		view origin:(0.0 @ y) corner:(1.0 @ (y + h))
   569             ].
   576 	    ].
   570             y := y + h
   577 	    y := y + h
   571         ]
   578 	]
   572     ]
   579     ]
   573 !
   580 !
   574 
   581 
   575 resizeSubviewsFrom:start to:stop
   582 resizeSubviewsFrom:start to:stop
   576     "readjust size of some subviews"
   583     "readjust size of some subviews"
   577 
   584 
   578     |step nSubviews|
   585     |step nSubviews|
   579 
   586 
   580     subViews notNil ifTrue:[
   587     subViews notNil ifTrue:[
   581         (start <= stop) ifTrue:[
   588 	(start <= stop) ifTrue:[
   582             step := 1
   589 	    step := 1
   583         ] ifFalse:[
   590 	] ifFalse:[
   584             step := -1
   591 	    step := -1
   585         ].
   592 	].
   586         nSubviews := subViews size.
   593 	nSubviews := subViews size.
   587         start to:stop by:step do:[:index |
   594 	start to:stop by:step do:[:index |
   588             |bw view o1 o2 relOrg relCorner newOrg newCorner|
   595 	    |bw view o1 o2 relOrg relCorner newOrg newCorner|
   589 
   596 
   590             view := subViews at:index.
   597 	    view := subViews at:index.
   591             bw := view borderWidth.
   598 	    bw := view borderWidth.
   592 
   599 
   593             index == 1 ifTrue:[
   600 	    index == 1 ifTrue:[
   594                 o1 := 0.
   601 		o1 := 0.
   595             ] ifFalse:[
   602 	    ] ifFalse:[
   596                 o1 := barHeight // 2 - bw
   603 		o1 := barHeight // 2 - bw
   597             ].
   604 	    ].
   598             index ==  nSubviews ifTrue:[
   605 	    index ==  nSubviews ifTrue:[
   599                 o2 := 0.
   606 		o2 := 0.
   600             ] ifFalse:[
   607 	    ] ifFalse:[
   601                 o2 := barHeight // 2 - bw
   608 		o2 := barHeight // 2 - bw
   602             ].
   609 	    ].
   603 
   610 
   604             relCorner := view relativeCorner.
   611 	    relCorner := view relativeCorner.
   605             relCorner isNil ifTrue:[
   612 	    relCorner isNil ifTrue:[
   606                 self error:'subview must have relative corner'
   613 		self error:'subview must have relative corner'
   607             ].
   614 	    ].
   608             newCorner := view cornerFromRelativeCorner.
   615 	    newCorner := view cornerFromRelativeCorner.
   609             newCorner notNil ifTrue:[
   616 	    newCorner notNil ifTrue:[
   610                 newCorner y:(newCorner y - o2)
   617 		newCorner y:(newCorner y - o2)
   611             ].
   618 	    ].
   612 
   619 
   613             relOrg := view relativeOrigin.
   620 	    relOrg := view relativeOrigin.
   614             relOrg isNil ifTrue:[
   621 	    relOrg isNil ifTrue:[
   615                 self error:'subview must have relative origin'
   622 		self error:'subview must have relative origin'
   616             ].
   623 	    ].
   617             newOrg := view originFromRelativeOrigin.
   624 	    newOrg := view originFromRelativeOrigin.
   618             newOrg notNil ifTrue:[
   625 	    newOrg notNil ifTrue:[
   619                 (index ~~ 1) ifTrue:[  
   626 		(index ~~ 1) ifTrue:[  
   620                     newOrg y:(newOrg y + o1)
   627 		    newOrg y:(newOrg y + o1)
   621                 ].
   628 		].
   622             ].
   629 	    ].
   623             view pixelOrigin:newOrg corner:newCorner
   630 	    view pixelOrigin:newOrg corner:newCorner
   624         ]
   631 	]
   625     ]
   632     ]
   626 !
   633 !
   627 
   634 
   628 handleOriginsFrom:start to:stop do:aBlock
   635 handleOriginsFrom:start to:stop do:aBlock
   629     "evaluate the argument block for some handle-origins"
   636     "evaluate the argument block for some handle-origins"
   630 
   637 
   631     |x hw|
   638     |x hw|
   632 
   639 
   633     subViews notNil ifTrue:[
   640     subViews notNil ifTrue:[
   634         shadowForm notNil ifTrue:[
   641 	shadowForm notNil ifTrue:[
   635             hw := shadowForm width
   642 	    hw := shadowForm width
   636         ] ifFalse:[
   643 	] ifFalse:[
   637             hw := barHeight
   644 	    hw := barHeight
   638         ].
   645 	].
   639         (handlePosition == #left) ifTrue:[
   646 	(handlePosition == #left) ifTrue:[
   640             x := hw * 2
   647 	    x := hw * 2
   641         ] ifFalse:[
   648 	] ifFalse:[
   642             (handlePosition == #right) ifTrue:[
   649 	    (handlePosition == #right) ifTrue:[
   643                 x := width - (1 "2" * hw) - margin
   650 		x := width - (1 "2" * hw) - margin
   644             ] ifFalse:[
   651 	    ] ifFalse:[
   645                 x := width // 2
   652 		x := width // 2
   646             ]
   653 	    ]
   647         ].
   654 	].
   648         (start + 1) to:stop do:[:index |
   655 	(start + 1) to:stop do:[:index |
   649             |view y|
   656 	    |view y|
   650 
   657 
   651             view := subViews at:index.
   658 	    view := subViews at:index.
   652             y := view origin y - barHeight + 1.
   659 	    y := view origin y - barHeight + 1.
   653             aBlock value:(x @ y)
   660 	    aBlock value:(x @ y)
   654         ]
   661 	]
   655     ]
   662     ]
   656 !
   663 !
   657 
   664 
   658 handleOriginsDo:aBlock
   665 handleOriginsDo:aBlock
   659     "evaluate the argument block for every handle-origin"
   666     "evaluate the argument block for every handle-origin"