support List for columns
authorca
Tue, 14 Apr 1998 15:36:18 +0200
changeset 859 e63eb6f321e1
parent 858 0bfbe5be0541
child 860 64d52b8e3dbd
support List for columns
DSVColumnView.st
DSVLabelView.st
--- a/DSVColumnView.st	Tue Apr 14 13:33:56 1998 +0200
+++ b/DSVColumnView.st	Tue Apr 14 15:36:18 1998 +0200
@@ -346,6 +346,7 @@
     (sz == 0 or:[selectedColIndex ~~ 0]) ifTrue:[       "/ cell selected
         self deselect                                   "/ remove selection
     ].
+    catchChangeEvents := true.
 
     sz ~~ 0 ifTrue:[
         id := 0.
@@ -359,14 +360,16 @@
     ].
     canFit := (columnDescriptors findFirst:[:aCol|aCol canResize]) ~~ 0.
     preferredExtent := nil.
-    self preferredExtentChanged.
 
     shown ifTrue:[
         self fitColumns ifFalse:[
             self invalidate.
             self contentsChanged.
+        ] ifTrue:[
+            self preferredExtentChanged.
         ]
     ].
+    catchChangeEvents := false.
     self changed:#sizeOfColumns.
 
 
@@ -855,6 +858,22 @@
 
 !DSVColumnView methodsFor:'change & update'!
 
+changed:aParameter with:anArgument
+    "notify all dependents that the receiver has changed somehow.
+     Each dependent gets a  '#update:with:from:'-message, with aParameter
+     and anArgument as arguments."
+
+    catchChangeEvents ifTrue:[
+        (    aParameter == #sizeOfColumns
+         or:[aParameter == #columnsLayout]
+        ) ifTrue:[
+            ^ self
+        ]
+    ].
+    super changed:aParameter with:anArgument
+
+!
+
 update:something with:aParameter from:changedObject
     "one of my rows/cells changed its value
     "
@@ -1115,7 +1134,7 @@
 redrawX:x y:y width:w height:h
     "redraw part of myself immediately, given logical coordinates 
     "
-    |c0 prevClipArea
+    |c0 savClip
      start "{ Class:SmallInteger }"
      stop  "{ Class:SmallInteger }"
      x0    "{ Class:SmallInteger }"
@@ -1129,19 +1148,20 @@
     |
 
     shown ifFalse:[^ self].
+
     self paint:bgColor.
     self fillRectangleX:x y:y width:w height:h.
 
     columnDescriptors size ~~ 0 ifTrue:[                
+        savClip := clipRect.
+        self clippingRectangle:(Rectangle left:x top:y width:w height:h).
+
         yTop  := margin - viewOrigin y.                   
         c0    := y - yTop max:0.
         start := (c0 // rowHeight) + 1.
         stop  := (c0 + h - 1 // rowHeight + 1) min:(list size).
 
         (times := stop - start + 1) > 0 ifTrue:[
-            prevClipArea := clipRect.
-            clipRect     := nil.
-
             maxX := (x + w) min:(width - margin).
             x0   := margin - viewOrigin x.
             yTop := yTop + ((start - 1) * rowHeight).
@@ -1153,19 +1173,13 @@
                 x1 := x0 + aCol width.
 
                 (x1 > x and:[x0 < maxX]) ifTrue:[
-                    c0 := (x1 min:maxX) - minX.
-                    device setClipX:minX y:margin width:c0 height:yMax in:drawableId gc:gcId.
                     aCol drawFrom:start times:times x0:x0 yTop:yTop yBot:yBot with:fgColor and:bgColor.
                 ].
                 x0 := x1
-            ].
-            clipRect := nil.
-            prevClipArea isNil ifTrue:[device noClipIn:drawableId  gc:gcId]
-                              ifFalse:[self clippingRectangle:prevClipArea].
-        ]
-    ]
-
-    "Modified: / 17.2.1998 / 18:04:15 / stefan"
+            ]
+        ].
+        self clippingRectangle:savClip.
+    ].
 ! !
 
 !DSVColumnView methodsFor:'enumerating columns'!
@@ -1762,15 +1776,21 @@
 fitColumns
     "fit columns to view
     "
-    |lastColumn dX sz expand resizables deltaWidth|
+    |raiseNotify lastColumn dX sz expand resizables deltaWidth|
 
     self canFit ifFalse:[^ false ].
 
-    resizables        := 0.
-    deltaWidth        := 0.
-
-    (catchChangeEvents := preferredExtent isNil) ifTrue:[
+    resizables  := 0.
+    deltaWidth  := 0.
+
+    preferredExtent isNil ifTrue:[
+        raiseNotify := catchChangeEvents.
+        catchChangeEvents := true.
         self preferredExtent.
+        catchChangeEvents := raiseNotify.
+        raiseNotify := raiseNotify not.
+    ] ifFalse:[
+        raiseNotify := false
     ].
 
     self columnsDo:[:aCol|
@@ -1790,10 +1810,7 @@
     ].
 
     deltaWidth == 0 ifTrue:[
-        catchChangeEvents ifTrue:[
-            catchChangeEvents := false.
-            self changed:#columnsLayout.
-        ].
+        raiseNotify ifTrue:[ self changed:#columnsLayout ].
         ^ false
     ].
 
@@ -1804,7 +1821,6 @@
         lastColumn growWidth:(deltaWidth - (dX * resizables)).
     ].
 
-    catchChangeEvents := false.
     self preferredExtentChanged.
 
     shown ifTrue:[
@@ -1975,11 +1991,7 @@
 
     x := (rowHeight - separatorSize - font height) // 2 + font ascent.
     self columnsDo:[:aCol|aCol textInsetChanged:x].
-
-    catchChangeEvents ifFalse:[
-        self changed:#columnsLayout
-    ].
-
+    self changed:#columnsLayout.
   ^ preferredExtent
 
 
@@ -2570,5 +2582,5 @@
 !DSVColumnView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.32 1998-04-01 14:08:19 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.33 1998-04-14 13:36:18 ca Exp $'
 ! !
--- a/DSVLabelView.st	Tue Apr 14 13:33:56 1998 +0200
+++ b/DSVLabelView.st	Tue Apr 14 15:36:18 1998 +0200
@@ -147,7 +147,11 @@
     self paint:bgColor.
     self fillRectangleX:x y:y width:w height:h.
 
+    items isEmpty ifTrue:[
+        ^ self
+    ].
     savClip := clipRect.
+
     self clippingRectangle:(Rectangle left:x top:y width:w height:h).
 
     items do:[:anItem|
@@ -174,9 +178,7 @@
             ]
         ]
     ].
-
-    savClip isNil ifTrue:[device noClipIn:drawableId gc:gcId]
-                 ifFalse:[self clippingRectangle:savClip].
+    self clippingRectangle:savClip.
 
 
 
@@ -298,7 +300,7 @@
     height  := 0.
 
     columnView numberOfColumns == 0 ifTrue:[
-        ^ self
+        ^ self redraw
     ].
     lastCol := columnView lastColumn.
     prevCol := nil.
@@ -650,5 +652,5 @@
 !DSVLabelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.12 1998-03-30 12:05:22 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.13 1998-04-14 13:36:02 ca Exp $'
 ! !