DSVColumnView.st
changeset 859 e63eb6f321e1
parent 833 c4e3e579f8bd
child 861 a227a3ca27e7
equal deleted inserted replaced
858:0bfbe5be0541 859:e63eb6f321e1
   344     sz := colDesc size.
   344     sz := colDesc size.
   345 
   345 
   346     (sz == 0 or:[selectedColIndex ~~ 0]) ifTrue:[       "/ cell selected
   346     (sz == 0 or:[selectedColIndex ~~ 0]) ifTrue:[       "/ cell selected
   347         self deselect                                   "/ remove selection
   347         self deselect                                   "/ remove selection
   348     ].
   348     ].
       
   349     catchChangeEvents := true.
   349 
   350 
   350     sz ~~ 0 ifTrue:[
   351     sz ~~ 0 ifTrue:[
   351         id := 0.
   352         id := 0.
   352 
   353 
   353         columnDescriptors := colDesc collect:[:aCol|
   354         columnDescriptors := colDesc collect:[:aCol|
   357     ] ifFalse:[
   358     ] ifFalse:[
   358         columnDescriptors := #()
   359         columnDescriptors := #()
   359     ].
   360     ].
   360     canFit := (columnDescriptors findFirst:[:aCol|aCol canResize]) ~~ 0.
   361     canFit := (columnDescriptors findFirst:[:aCol|aCol canResize]) ~~ 0.
   361     preferredExtent := nil.
   362     preferredExtent := nil.
   362     self preferredExtentChanged.
       
   363 
   363 
   364     shown ifTrue:[
   364     shown ifTrue:[
   365         self fitColumns ifFalse:[
   365         self fitColumns ifFalse:[
   366             self invalidate.
   366             self invalidate.
   367             self contentsChanged.
   367             self contentsChanged.
   368         ]
   368         ] ifTrue:[
   369     ].
   369             self preferredExtentChanged.
       
   370         ]
       
   371     ].
       
   372     catchChangeEvents := false.
   370     self changed:#sizeOfColumns.
   373     self changed:#sizeOfColumns.
   371 
   374 
   372 
   375 
   373 !
   376 !
   374 
   377 
   853     ^ self removeIndex:self size
   856     ^ self removeIndex:self size
   854 ! !
   857 ! !
   855 
   858 
   856 !DSVColumnView methodsFor:'change & update'!
   859 !DSVColumnView methodsFor:'change & update'!
   857 
   860 
       
   861 changed:aParameter with:anArgument
       
   862     "notify all dependents that the receiver has changed somehow.
       
   863      Each dependent gets a  '#update:with:from:'-message, with aParameter
       
   864      and anArgument as arguments."
       
   865 
       
   866     catchChangeEvents ifTrue:[
       
   867         (    aParameter == #sizeOfColumns
       
   868          or:[aParameter == #columnsLayout]
       
   869         ) ifTrue:[
       
   870             ^ self
       
   871         ]
       
   872     ].
       
   873     super changed:aParameter with:anArgument
       
   874 
       
   875 !
       
   876 
   858 update:something with:aParameter from:changedObject
   877 update:something with:aParameter from:changedObject
   859     "one of my rows/cells changed its value
   878     "one of my rows/cells changed its value
   860     "
   879     "
   861     |row|
   880     |row|
   862 
   881 
  1113 !
  1132 !
  1114 
  1133 
  1115 redrawX:x y:y width:w height:h
  1134 redrawX:x y:y width:w height:h
  1116     "redraw part of myself immediately, given logical coordinates 
  1135     "redraw part of myself immediately, given logical coordinates 
  1117     "
  1136     "
  1118     |c0 prevClipArea
  1137     |c0 savClip
  1119      start "{ Class:SmallInteger }"
  1138      start "{ Class:SmallInteger }"
  1120      stop  "{ Class:SmallInteger }"
  1139      stop  "{ Class:SmallInteger }"
  1121      x0    "{ Class:SmallInteger }"
  1140      x0    "{ Class:SmallInteger }"
  1122      x1    "{ Class:SmallInteger }"
  1141      x1    "{ Class:SmallInteger }"
  1123      maxX  "{ Class:SmallInteger }"
  1142      maxX  "{ Class:SmallInteger }"
  1127      times "{ Class:SmallInteger }"
  1146      times "{ Class:SmallInteger }"
  1128      yMax  "{ Class:SmallInteger }"
  1147      yMax  "{ Class:SmallInteger }"
  1129     |
  1148     |
  1130 
  1149 
  1131     shown ifFalse:[^ self].
  1150     shown ifFalse:[^ self].
       
  1151 
  1132     self paint:bgColor.
  1152     self paint:bgColor.
  1133     self fillRectangleX:x y:y width:w height:h.
  1153     self fillRectangleX:x y:y width:w height:h.
  1134 
  1154 
  1135     columnDescriptors size ~~ 0 ifTrue:[                
  1155     columnDescriptors size ~~ 0 ifTrue:[                
       
  1156         savClip := clipRect.
       
  1157         self clippingRectangle:(Rectangle left:x top:y width:w height:h).
       
  1158 
  1136         yTop  := margin - viewOrigin y.                   
  1159         yTop  := margin - viewOrigin y.                   
  1137         c0    := y - yTop max:0.
  1160         c0    := y - yTop max:0.
  1138         start := (c0 // rowHeight) + 1.
  1161         start := (c0 // rowHeight) + 1.
  1139         stop  := (c0 + h - 1 // rowHeight + 1) min:(list size).
  1162         stop  := (c0 + h - 1 // rowHeight + 1) min:(list size).
  1140 
  1163 
  1141         (times := stop - start + 1) > 0 ifTrue:[
  1164         (times := stop - start + 1) > 0 ifTrue:[
  1142             prevClipArea := clipRect.
       
  1143             clipRect     := nil.
       
  1144 
       
  1145             maxX := (x + w) min:(width - margin).
  1165             maxX := (x + w) min:(width - margin).
  1146             x0   := margin - viewOrigin x.
  1166             x0   := margin - viewOrigin x.
  1147             yTop := yTop + ((start - 1) * rowHeight).
  1167             yTop := yTop + ((start - 1) * rowHeight).
  1148             yBot := yTop + (times * rowHeight).
  1168             yBot := yTop + (times * rowHeight).
  1149             yMax := height - margin - margin.
  1169             yMax := height - margin - margin.
  1151 
  1171 
  1152             columnDescriptors do:[:aCol|
  1172             columnDescriptors do:[:aCol|
  1153                 x1 := x0 + aCol width.
  1173                 x1 := x0 + aCol width.
  1154 
  1174 
  1155                 (x1 > x and:[x0 < maxX]) ifTrue:[
  1175                 (x1 > x and:[x0 < maxX]) ifTrue:[
  1156                     c0 := (x1 min:maxX) - minX.
       
  1157                     device setClipX:minX y:margin width:c0 height:yMax in:drawableId gc:gcId.
       
  1158                     aCol drawFrom:start times:times x0:x0 yTop:yTop yBot:yBot with:fgColor and:bgColor.
  1176                     aCol drawFrom:start times:times x0:x0 yTop:yTop yBot:yBot with:fgColor and:bgColor.
  1159                 ].
  1177                 ].
  1160                 x0 := x1
  1178                 x0 := x1
  1161             ].
  1179             ]
  1162             clipRect := nil.
  1180         ].
  1163             prevClipArea isNil ifTrue:[device noClipIn:drawableId  gc:gcId]
  1181         self clippingRectangle:savClip.
  1164                               ifFalse:[self clippingRectangle:prevClipArea].
  1182     ].
  1165         ]
       
  1166     ]
       
  1167 
       
  1168     "Modified: / 17.2.1998 / 18:04:15 / stefan"
       
  1169 ! !
  1183 ! !
  1170 
  1184 
  1171 !DSVColumnView methodsFor:'enumerating columns'!
  1185 !DSVColumnView methodsFor:'enumerating columns'!
  1172 
  1186 
  1173 columnsDo:aOneArgBlock
  1187 columnsDo:aOneArgBlock
  1760 !
  1774 !
  1761 
  1775 
  1762 fitColumns
  1776 fitColumns
  1763     "fit columns to view
  1777     "fit columns to view
  1764     "
  1778     "
  1765     |lastColumn dX sz expand resizables deltaWidth|
  1779     |raiseNotify lastColumn dX sz expand resizables deltaWidth|
  1766 
  1780 
  1767     self canFit ifFalse:[^ false ].
  1781     self canFit ifFalse:[^ false ].
  1768 
  1782 
  1769     resizables        := 0.
  1783     resizables  := 0.
  1770     deltaWidth        := 0.
  1784     deltaWidth  := 0.
  1771 
  1785 
  1772     (catchChangeEvents := preferredExtent isNil) ifTrue:[
  1786     preferredExtent isNil ifTrue:[
       
  1787         raiseNotify := catchChangeEvents.
       
  1788         catchChangeEvents := true.
  1773         self preferredExtent.
  1789         self preferredExtent.
       
  1790         catchChangeEvents := raiseNotify.
       
  1791         raiseNotify := raiseNotify not.
       
  1792     ] ifFalse:[
       
  1793         raiseNotify := false
  1774     ].
  1794     ].
  1775 
  1795 
  1776     self columnsDo:[:aCol|
  1796     self columnsDo:[:aCol|
  1777         aCol canResize ifTrue:[
  1797         aCol canResize ifTrue:[
  1778             resizables := resizables + 1.
  1798             resizables := resizables + 1.
  1788             deltaWidth := width - sz + margin + margin
  1808             deltaWidth := width - sz + margin + margin
  1789         ]
  1809         ]
  1790     ].
  1810     ].
  1791 
  1811 
  1792     deltaWidth == 0 ifTrue:[
  1812     deltaWidth == 0 ifTrue:[
  1793         catchChangeEvents ifTrue:[
  1813         raiseNotify ifTrue:[ self changed:#columnsLayout ].
  1794             catchChangeEvents := false.
       
  1795             self changed:#columnsLayout.
       
  1796         ].
       
  1797         ^ false
  1814         ^ false
  1798     ].
  1815     ].
  1799 
  1816 
  1800     expand ifTrue:[
  1817     expand ifTrue:[
  1801         (dX := deltaWidth // resizables) ~~ 0 ifTrue:[
  1818         (dX := deltaWidth // resizables) ~~ 0 ifTrue:[
  1802             self columnsDo:[:aCol|aCol canResize ifTrue:[aCol growWidth:dX]]
  1819             self columnsDo:[:aCol|aCol canResize ifTrue:[aCol growWidth:dX]]
  1803         ].
  1820         ].
  1804         lastColumn growWidth:(deltaWidth - (dX * resizables)).
  1821         lastColumn growWidth:(deltaWidth - (dX * resizables)).
  1805     ].
  1822     ].
  1806 
  1823 
  1807     catchChangeEvents := false.
       
  1808     self preferredExtentChanged.
  1824     self preferredExtentChanged.
  1809 
  1825 
  1810     shown ifTrue:[
  1826     shown ifTrue:[
  1811         self invalidate.
  1827         self invalidate.
  1812 
  1828 
  1973     rowHeight := (rowHeight + separatorSize + verticalSpacing + verticalSpacing + 1) // 2 * 2.
  1989     rowHeight := (rowHeight + separatorSize + verticalSpacing + verticalSpacing + 1) // 2 * 2.
  1974     preferredExtent := (x + margin + margin) @ (self size * rowHeight).
  1990     preferredExtent := (x + margin + margin) @ (self size * rowHeight).
  1975 
  1991 
  1976     x := (rowHeight - separatorSize - font height) // 2 + font ascent.
  1992     x := (rowHeight - separatorSize - font height) // 2 + font ascent.
  1977     self columnsDo:[:aCol|aCol textInsetChanged:x].
  1993     self columnsDo:[:aCol|aCol textInsetChanged:x].
  1978 
  1994     self changed:#columnsLayout.
  1979     catchChangeEvents ifFalse:[
       
  1980         self changed:#columnsLayout
       
  1981     ].
       
  1982 
       
  1983   ^ preferredExtent
  1995   ^ preferredExtent
  1984 
  1996 
  1985 
  1997 
  1986 !
  1998 !
  1987 
  1999 
  2568 ! !
  2580 ! !
  2569 
  2581 
  2570 !DSVColumnView class methodsFor:'documentation'!
  2582 !DSVColumnView class methodsFor:'documentation'!
  2571 
  2583 
  2572 version
  2584 version
  2573     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.32 1998-04-01 14:08:19 ca Exp $'
  2585     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.33 1998-04-14 13:36:18 ca Exp $'
  2574 ! !
  2586 ! !