HVScrollableView.st
changeset 0 e6a541c1c0eb
child 3 9d7eefb5e69f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HVScrollableView.st	Fri Jul 16 11:44:44 1993 +0200
@@ -0,0 +1,161 @@
+"
+ COPYRIGHT (c) 1991-93 by Claus Gittinger
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
+ScrollableView subclass:#HVScrollableView
+       instanceVariableNames:'hScrollBar'
+       classVariableNames:''
+       poolDictionaries:''
+       category:'Views-Basic'
+!
+
+HVScrollableView comment:'
+
+COPYRIGHT (c) 1991-93 by Claus Gittinger
+              All Rights Reserved
+
+a view containing both horizontal and vertical scrollbars
+and some other (slave-)view
+
+%W% %E%
+written jan 91 by claus
+'!
+
+!HVScrollableView methodsFor:'initialization'!
+
+initializeFor:aViewClass
+    |negativeOffset halfMargin|
+
+    super initializeFor:aViewClass.
+
+    negativeOffset := borderWidth negated.
+    halfMargin := innerMargin // 2.
+
+    "create the horizontal scrollbar and change vertical scrollbars size"
+
+    hScrollBar := HorizontalScrollBar in:self.
+
+    self is3D ifTrue:[
+        scrollBar extent:[scrollBar width
+                          @
+                          (height - hScrollBar height - innerMargin)
+                         ]
+    ] ifFalse:[
+        aViewClass isNil ifTrue:[
+            scrollBar extent:[scrollBar width
+                              @
+                              (height - hScrollBar height
+                                      - (1 * hScrollBar borderWidth))
+                             ]
+        ] ifFalse:[
+            scrollBar extent:[scrollBar width
+                              @
+                              (height - hScrollBar height
+                                      - hScrollBar borderWidth
+                                      - scrolledView borderWidth)
+                             ]
+        ]
+    ].
+
+    hScrollBar thumbOrigin:0 thumbHeight:100.
+    hScrollBar scrollAction:[:position | 
+                                scrolledView scrollHorizontalToPercent:position].
+    hScrollBar scrollLeftAction:[scrolledView scrollLeft].
+    hScrollBar scrollRightAction:[scrolledView scrollRight].
+    self is3D ifTrue:[
+        hScrollBar origin:[(scrollBar origin x + scrollBar width + innerMargin)
+                           @
+                           (height - hScrollBar height - halfMargin)
+                          ]
+                   extent:[(width - scrollBar width - (innerMargin * 2))
+                           @
+                           hScrollBar height
+                          ]
+    ] ifFalse:[
+        hScrollBar origin:[(scrollBar origin x + scrollBar width + scrollBar borderWidth)
+                           @
+                           (height - hScrollBar height - (hScrollBar borderWidth "* 2"))
+                          ]
+                   extent:[(width - scrollBar width) @ hScrollBar height
+                          ]
+    ].
+
+    "redefine subviews size"
+    self is3D ifTrue:[
+        helpView extent:[(width - scrollBar width - (innerMargin * 2))
+                         @
+                         (height - hScrollBar height - (innerMargin * 2))
+                        ]
+    ] ifFalse:[
+        scrolledView notNil ifTrue:[
+            scrolledView
+                extent:[(width
+                         - scrollBar width
+                         - scrollBar borderWidth
+                         - scrolledView borderWidth) 
+                        @ 
+                        (height
+                         - hScrollBar height
+                         - hScrollBar borderWidth
+                         - scrolledView borderWidth)
+                       ]
+        ].
+    ].
+
+    scrolledView notNil ifTrue:[
+        scrolledView
+            originChangeAction:[:aView | scrollBar setThumbOriginFor:aView.
+                                         hScrollBar setThumbOriginFor:aView].
+        scrolledView
+            contentsChangeAction:[:aView | scrollBar setThumbFor:aView.
+                                           hScrollBar setThumbFor:aView]
+    ]
+!
+
+realize
+    super realize.
+    hScrollBar setThumbFor:scrolledView
+! !
+
+!HVScrollableView methodsFor:'accessing'!
+
+scrolledView:aView
+    super scrolledView:aView.
+
+    "redefine subviews size"
+    self is3D ifFalse:[
+        scrolledView
+            extent:[(width
+                     - scrollBar width
+                     - scrollBar borderWidth
+                     "- scrolledView borderWidth") 
+                    @ 
+                    (height
+                     - hScrollBar height
+                     - hScrollBar borderWidth
+                     "- scrolledView borderWidth")
+                   ]
+    ].
+
+    scrolledView
+        originChangeAction:[:aView | scrollBar setThumbOriginFor:aView.
+                                     hScrollBar setThumbOriginFor:aView].
+    scrolledView
+        contentsChangeAction:[:aView | scrollBar setThumbFor:aView.
+                                       hScrollBar setThumbFor:aView]
+! !
+
+!HVScrollableView methodsFor:'event processing'!
+
+sizeChanged:how
+    super sizeChanged:how.
+    hScrollBar setThumbFor:scrolledView
+! !