prepared for table
authorca
Fri, 20 Feb 2004 12:30:59 +0100
changeset 2644 78ca3bd5eef1
parent 2643 8db56678dc19
child 2645 b3d3e7c3ee40
prepared for table
HierarchicalListView.st
ListModelView.st
SelectionInListModelView.st
--- a/HierarchicalListView.st	Thu Feb 19 14:54:50 2004 +0100
+++ b/HierarchicalListView.st	Fri Feb 20 12:30:59 2004 +0100
@@ -374,7 +374,10 @@
     "true, than automatically scroll horizontal upto the text label
      of the current selected line.
     "
-    ^ autoScrollHorizontal ? false
+    autoScrollHorizontal == true ifTrue:[
+        ^ renderer autoScrollHorizontal
+    ].
+    ^ false
 !
 
 autoScrollHorizontal:aBoolean
@@ -808,16 +811,18 @@
     ^ super listChangedRemove:aStart toIndex:aStop
 !
 
-update:what with:aPara from:chgObj
+updateFromList:what with:aPara
     "get the status of <showRoot> from the list
     "
-    chgObj == self list ifTrue:[
-        showRoot ~~ chgObj showRoot ifTrue:[
-            showRoot := chgObj showRoot.
-            self invalidate.
-        ]
+    |newState|
+
+    newState := self list showRoot.
+
+    showRoot ~~ newState ifTrue:[
+        showRoot := newState.
+        self invalidate.
     ].
-    super update:what with:aPara from:chgObj
+    super updateFromList:what with:aPara.
 ! !
 
 !HierarchicalListView methodsFor:'drawing basics'!
@@ -1406,6 +1411,9 @@
      width        "{ Class: SmallInteger }"
      widthOfLabel "{ Class: SmallInteger }"
     |
+    width := renderer widthOfWidestLineBetween:firstLine and:lastLine.
+    width notNil ifTrue:[^ width].
+
     width := 20.
 
     alignTextRight ifTrue:[
@@ -1530,6 +1538,8 @@
 
     vwOrgX := viewOrigin x.
 
+    renderer autoScrollHorizontal ifFalse:[^ vwOrgX ].
+
     alignTextRight ifTrue:[ ^ vwOrgX ].
     aLnrNr == 1    ifTrue:[ ^ 0 ].
 
@@ -1586,7 +1596,7 @@
 
     newX := viewOrigin x.
 
-    (autoScrollHorizontal or:[newX ~~ 0]) ifTrue:[
+    (self autoScrollHorizontal or:[newX ~~ 0]) ifTrue:[
         newX := self computeViewOriginXat:aLnrNr
     ].
     self scrollTo:(newX @ newY).
@@ -1595,5 +1605,5 @@
 !HierarchicalListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.88 2004-01-28 06:09:01 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.89 2004-02-20 11:30:59 ca Exp $'
 ! !
--- a/ListModelView.st	Thu Feb 19 14:54:50 2004 +0100
+++ b/ListModelView.st	Fri Feb 20 12:30:59 2004 +0100
@@ -223,16 +223,25 @@
     self contentsChanged
 !
 
-newDefaultList
-    "creates and returns a new default list class, on default a List
-    "
-    ^ List new
-!
-
 renderer
     "returns the used renderer
     "
     ^ renderer
+!
+
+renderer:aRenderer
+    "change the used renderer
+    "
+    aRenderer isNil ifTrue:[^ self].
+
+    renderer == aRenderer ifTrue:[^ self].
+    renderer notNil ifTrue:[renderer release].
+
+    renderer := aRenderer.
+    renderer isBehavior ifTrue:[
+        renderer := renderer basicNew initialize.
+    ].
+    renderer forView:self.
 ! !
 
 !ListModelView methodsFor:'accessing-behavior'!
@@ -682,18 +691,25 @@
     "catch and handle any notification raised from the list model
      or list holder
     "
-    |a1 a2|
-
     chgObj ~~ self list ifTrue:[
         chgObj == self listHolder ifTrue:[
             self list:(chgObj value).
         ] ifFalse:[
             super update:what with:aPara from:chgObj
         ].
-        ^ self
+        ^ self.
+    ].
+
+    renderer withinUpdateFromListDo:[
+        self updateFromList:what with:aPara.
     ].
-    "the list has changed
+!
+
+updateFromList:what with:aPara
+    "called if the list changed
     "
+    |arg1 arg2|
+
     aPara isCollection ifFalse:[
         what == #at:     ifTrue:[self lineChangedAt:aPara        with:nil.   ^ self].
         what == #insert: ifTrue:[self listChangedInsert:aPara  nItems:1.     ^ self].
@@ -701,20 +717,20 @@
       ^ self.
     ].
 
-    a1 := aPara at:1.
-    a2 := aPara at:2.
+    arg1 := aPara at:1.
+    arg2 := aPara at:2.
 
-    (a1 == 1 and:[a2 == self size]) ifTrue:[
-        self list:chgObj.                               "/ reload list
+    (arg1 == 1 and:[arg2 == self size]) ifTrue:[
+        self list:(self list).  "/ reload list
       ^ self
     ].
 
-    what == #at:               ifTrue:[self lineChangedAt:a1        with:a2. ^ self].
-    what == #insertCollection: ifTrue:[self listChangedInsert:a1  nItems:a2. ^ self].
-    what == #removeFrom:       ifTrue:[self listChangedRemove:a1 toIndex:a2. ^ self].
+    what == #at:               ifTrue:[self lineChangedAt:arg1        with:arg2. ^ self].
+    what == #insertCollection: ifTrue:[self listChangedInsert:arg1  nItems:arg2. ^ self].
+    what == #removeFrom:       ifTrue:[self listChangedRemove:arg1 toIndex:arg2. ^ self].
 
     what == #replace: ifTrue:[
-        a1 to:a2 do:[:i|self lineChangedAt:i with:nil].
+        arg1 to:arg2 do:[:i|self lineChangedAt:i with:nil].
       ^ self
     ].
 ! !
@@ -755,14 +771,13 @@
     |maxX w|
 
     maxX := renderer maxItemWidthOrNil.
+    w := aWidth.
 
-    maxX isNil ifTrue:[
-        w := aWidth
-    ] ifFalse:[ |clip|
+    maxX notNil ifTrue:[ |clip|
         maxX := maxX - viewOrigin x.
-        maxX > xLft ifFalse:[^ self].
+        maxX > xLft ifFalse:[^ self.].
 
-        w := maxX - xLft.
+        w := maxX - xLft min:aWidth.
 
         (clip := self clipRect copy) notNil ifTrue:[
             clip width:w
@@ -823,7 +838,7 @@
 redrawX:x y:y width:w height:h
     "redraw part of myself immediately, given logical coordinates 
     "
-    |start stop yAbs|
+    |start stop yAbs yStart|
 
     shown ifFalse:[^ self].
 
@@ -840,38 +855,50 @@
             ^ self
         ].
     ].
-
-    self paint:bgColor.
-    self fillRectangleX:x y:y width:w height:h.
-
     widthOfContents isNil ifTrue:[
         self preferredExtent
     ].
+    yStart := y.
+    start  := self yVisibleToLineNr:y.
 
-    start := self yVisibleToLineNr:y.
-    start isNil ifTrue:[ ^ self ].
+    start notNil ifTrue:[
+        yAbs := y + h.
+        stop := self yVisibleToLineNr:yAbs.
 
-    yAbs := y + h.
-    stop := self yVisibleToLineNr:yAbs.
+        stop isNil ifTrue:[
+            stop := self size.
+        ] ifFalse:[ |y0|
+            y0 := self startOfLinesY at:stop ifAbsent:nil.
+            y0 isNil ifTrue:[^ self].   "/ oops, lines differ (will be changed)
 
-    stop isNil ifTrue:[
-        stop := self size.
-    ] ifFalse:[ |y0|
-        y0 := self startOfLinesY at:stop ifAbsent:nil.
-        y0 isNil ifTrue:[^ self].
+            yAbs == y0 ifTrue:[
+                stop := (stop - 1) max:start
+            ].
+        ].
 
-        yAbs == y0 ifTrue:[
-            stop := (stop - 1) max:start
+        start > stop ifTrue:[
+            start := stop := nil.
+        ] ifFalse:[
+            (renderer validateDrawableItemsFrom:start to:stop) ifFalse:[
+                self invalidate.
+                ^ self.
+            ].
+            yStart := self yVisibleOfLine:start.
         ].
     ].
-
-    start > stop ifTrue:[^ self ].      "/oops, should not happen
+    self paint:bgColor.
+    self fillRectangleX:x y:y width:w height:h.
 
     StopRedrawSignal handle:[:ex|
         "/ an item changed its dimension during drawing, draw is aborted
         self invalidate
     ] do:[
-        self drawFrom:start to:stop x:x y:(self yVisibleOfLine:start) w:w.
+
+
+        start notNil ifTrue:[
+            self drawFrom:start to:stop x:x y:yStart w:w.
+        ].
+        renderer postRedrawX:x y:yStart w:w from:start to:stop.
     ].
 ! !
 
@@ -1230,12 +1257,21 @@
     ].
 !
 
+newDefaultList
+    "creates and returns a new default list class, on default a List
+    "
+    ^ List new
+!
+
 widthOfWidestLineBetween:firstLine and:lastLine
     "return the width in pixels of the widest line in a range
     "
     |item
      width    "{ Class: SmallInteger }"
     |
+    width := renderer widthOfWidestLineBetween:firstLine and:lastLine.
+    width notNil ifTrue:[^ width].
+
     width := textStartLeft.
 
     firstLine to:lastLine do:[:anIndex|
@@ -1328,6 +1364,10 @@
 
 !ListModelView methodsFor:'scroller interface'!
 
+getWidthOfContents
+    ^ widthOfContents
+!
+
 heightOfContents
     "return the height of the contents in pixels
     "
@@ -1379,6 +1419,10 @@
 
 !
 
+setWidthOfContents: aWidth
+    widthOfContents := aWidth.
+!
+
 verticalScrollStep
     "return the amount to scroll when stepping up/down.
     "
@@ -1637,6 +1681,14 @@
     ].
 ! !
 
+!ListModelView methodsFor:'selection'!
+
+hasSelection
+    "on default false is returned
+    "
+    ^ false
+! !
+
 !ListModelView::Renderer class methodsFor:'documentation'!
 
 documentation
@@ -1665,6 +1717,12 @@
     "called before the list changed, clear cashes ect.
      here nothing is done
     "
+!
+
+withinUpdateFromListDo:aBlock
+    "handle an update from the list
+    "
+    aBlock value
 ! !
 
 !ListModelView::Renderer methodsFor:'displaying'!
@@ -1693,12 +1751,27 @@
         ].
         label displayOn:view x:x0 y:y0
     ].
+!
+
+postRedrawX:damageX y:yStartOrYDamage w:damageWidth from:startOrNil to:stopOrNil
+    "called after redraw of the items in range from start to stop is done;
+     if no items are damaged, start and stop is set to nil.
+    "
+!
+
+validateDrawableItemsFrom:start to:stop
+    "called before drawing items from start to stop; if the method returns false
+     nothing will be drawn and a invalidate is pushed on the event queue.
+     On default true is returned.
+    "
+    ^ true
 ! !
 
 !ListModelView::Renderer methodsFor:'instance creation'!
 
 forView:aView
     view := aView.
+    view shown ifTrue:[ self mapped ].
 !
 
 mapped
@@ -1711,6 +1784,15 @@
     "
 ! !
 
+!ListModelView::Renderer methodsFor:'queries-behavior'!
+
+autoScrollHorizontal
+    "returns true if automatic scrolling horizontal
+     is allowed (the default is true).
+    "
+    ^ true
+! !
+
 !ListModelView::Renderer methodsFor:'queries-dimensions'!
 
 heightFor:anItem
@@ -1730,12 +1812,19 @@
     "returns the width of an item on the view
     "
     ^ anItem widthOn:view
+!
+
+widthOfWidestLineBetween:firstLine and:lastLine
+    "returns the width of the longest line in pixels in a range; if the rendere
+     cannot compute the width, nil is returned (the default).
+    "
+    ^ nil
 ! !
 
 !ListModelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.90 2004-02-19 13:54:50 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.91 2004-02-20 11:30:19 ca Exp $'
 ! !
 
 ListModelView initialize!
--- a/SelectionInListModelView.st	Thu Feb 19 14:54:50 2004 +0100
+++ b/SelectionInListModelView.st	Fri Feb 20 12:30:59 2004 +0100
@@ -389,6 +389,18 @@
     ].
 !
 
+hilightBackgroundColor
+    "returns the color used for the hilighted background
+    "
+    ^ hilightBgColor
+!
+
+hilightForegroundColor
+    "returns the color used for the hilighted foreground
+    "
+    ^ hilightFgColor
+!
+
 strikeout
     "turn on/off strikeOut mode
     "
@@ -2312,5 +2324,5 @@
 !SelectionInListModelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.94 2004-02-19 13:54:39 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.95 2004-02-20 11:30:27 ca Exp $'
 ! !