scrollWhenUpdating
authorClaus Gittinger <cg@exept.de>
Fri, 01 Sep 2000 17:57:15 +0200
changeset 1827 54e8a0fc8a42
parent 1826 080df5e45c3c
child 1828 ea1f39c639f8
scrollWhenUpdating
ListModelView.st
--- a/ListModelView.st	Fri Sep 01 12:14:51 2000 +0200
+++ b/ListModelView.st	Fri Sep 01 17:57:15 2000 +0200
@@ -16,7 +16,8 @@
 View subclass:#ListModelView
 	instanceVariableNames:'list listHolder textStartLeft viewOrigin enabled fgColor bgColor
 		lineSpacing widthOfContents computeWidthInRange startOfLinesY
-		displayedFrames syncronizeEvents autoScroll autoScrollBlock'
+		displayedFrames syncronizeEvents autoScroll autoScrollBlock
+		scrollWhenUpdating'
 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultShadowColor
 		DefaultLightColor StopRedrawSignal'
 	poolDictionaries:''
@@ -107,6 +108,7 @@
     top  := StandardSystemView new; extent:300@300.
     view := ScrollableView for:ListModelView miniScroller:true
                         origin:0.0@0.0 corner:1.0@1.0 in:top.
+
     view list:list.
     top  openAndWait.
     up := true.
@@ -117,7 +119,7 @@
         up ifTrue:[
             index := 1 + (list size).
             list add:('element: ', index printString).
-            up := index < 10
+            up := index < 20
         ] ifFalse:[
             list removeIndex:1.
             up := list isEmpty.
@@ -200,12 +202,19 @@
     preferredExtent := nil.
     widthOfContents := nil.
 
-    viewOrigin = (0@0) ifFalse:[
-        self originWillChange.
-        negatedOrg := viewOrigin negated.
-        viewOrigin := (0@0).
-        self originChanged:negatedOrg.
+    scrollWhenUpdating == #beginOfText ifTrue:[
+        viewOrigin = (0@0) ifFalse:[
+            self originWillChange.
+            negatedOrg := viewOrigin negated.
+            viewOrigin := (0@0).
+            self originChanged:negatedOrg.
+        ].
+    ] ifFalse:[
+        scrollWhenUpdating == #endOfText ifTrue:[
+            self scrollTo:(0 @ self heightOfContents - self innerHeight) redraw:false
+        ]
     ].
+
     self invalidate.
     self contentsChanged
 
@@ -252,9 +261,8 @@
      This may be useful for fields which get new values assigned from
      the program (i.e. not from the user)
     "
-    "/ NOT YET SUPPORTED
 
-"/    scrollWhenUpdating := aSymbolOrNil
+    scrollWhenUpdating := aSymbolOrNil
 
 
 ! !
@@ -1047,6 +1055,7 @@
     displayedFrames  := WeakIdentityDictionary new.
     syncronizeEvents := false.
     autoScroll       := true.
+    scrollWhenUpdating := #beginOfText.
 !
 
 mapped
@@ -1427,14 +1436,14 @@
 halfPageDown
     "scroll down half a page
     "
-    self scrollDown:(width // 2).
+    self scrollDown:(height // 2).
 
 !
 
 halfPageUp
     "scroll up half a page
     "
-    self scrollUp:(width // 2).
+    self scrollUp:(height // 2).
 
 !
 
@@ -1604,6 +1613,6 @@
 !ListModelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.46 2000-08-22 13:57:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.47 2000-09-01 15:57:15 cg Exp $'
 ! !
 ListModelView initialize!