DSVColumnView.st
changeset 1947 1e11b36633b2
parent 1946 0738b9f8c19f
child 1948 9ed8131d94bb
equal deleted inserted replaced
1946:0738b9f8c19f 1947:1e11b36633b2
  1899 !
  1899 !
  1900 
  1900 
  1901 buttonPress:button x:x y:y
  1901 buttonPress:button x:x y:y
  1902     "a button was pressed - handle selection here
  1902     "a button was pressed - handle selection here
  1903     "
  1903     "
  1904     |rowNr colNr menu sz first|
  1904     |rowNr colNr menu sz first sensor|
  1905 
  1905 
  1906     self isEnabled ifFalse:[^ self].
  1906     self isEnabled ifFalse:[^ self].
       
  1907 
       
  1908     sensor := self sensor.
  1907 
  1909 
  1908     clickPosition   := nil.
  1910     clickPosition   := nil.
  1909     dragAccessPoint := nil.
  1911     dragAccessPoint := nil.
  1910     dragIsActive    := false.
  1912     dragIsActive    := false.
  1911 
  1913 
  1917         (     (button == 1 or:[button == #select])
  1919         (     (button == 1 or:[button == #select])
  1918          and:[(rowNr := self yVisibleToRowNr:y) notNil
  1920          and:[(rowNr := self yVisibleToRowNr:y) notNil
  1919          and:[(colNr := self xVisibleToColNr:x) notNil]]
  1921          and:[(colNr := self xVisibleToColNr:x) notNil]]
  1920         ) ifTrue:[
  1922         ) ifTrue:[
  1921             multipleSelectOk ifTrue:[
  1923             multipleSelectOk ifTrue:[
  1922                 self sensor ctrlDown ifTrue:[
  1924                 sensor ctrlDown ifTrue:[
  1923                     selectedColIndex ~~ 0 ifTrue:[
  1925                     selectedColIndex ~~ 0 ifTrue:[
  1924                         colNr := 0
  1926                         colNr := 0
  1925                     ] ifFalse:[
  1927                     ] ifFalse:[
  1926                         (sz := self numberOfSelections == 0) ifFalse:[
  1928                         (sz := self numberOfSelections == 0) ifFalse:[
  1927                             (self isInSelection:rowNr) ifTrue:[
  1929                             (self isInSelection:rowNr) ifTrue:[
  1928                                 sz == 1 ifTrue:[
  1930                                 sz == 1 ifTrue:[
  1929                                     self selectColIndex:0 rowIndex:nil.
  1931                                     self selectColIndex:0 rowIndex:nil.
  1930                                     ^ self sensor flushMotionEventsFor:self.
  1932                                     sensor flushMotionEventsFor:self.
       
  1933                                     ^ self    
  1931                                 ].
  1934                                 ].
  1932                                 selectedRowIndex remove:rowNr.
  1935                                 selectedRowIndex remove:rowNr.
  1933                             ] ifFalse:[
  1936                             ] ifFalse:[
  1934                                 selectedRowIndex add:rowNr
  1937                                 selectedRowIndex add:rowNr
  1935                             ].
  1938                             ].
  1936                             self invalidateRowAt:rowNr.
  1939                             self invalidateRowAt:rowNr.
  1937                             self selectionChanged.
  1940                             self selectionChanged.
  1938                           ^ self sensor flushMotionEventsFor:self.
  1941                             sensor flushMotionEventsFor:self.
       
  1942                             ^ self
  1939                         ]
  1943                         ]
  1940                     ]
  1944                     ]
  1941                 ] ifFalse:[
  1945                 ] ifFalse:[
  1942                     (     selectedColIndex == 0
  1946                     (     selectedColIndex == 0
  1943                      and:[(first := self firstIndexSelected) ~~ 0
  1947                      and:[(first := self firstIndexSelected) ~~ 0
  1944                      and:[self sensor shiftDown]]
  1948                      and:[sensor shiftDown]]
  1945                     ) ifTrue:[|step list|
  1949                     ) ifTrue:[|step list|
  1946                         list := OrderedCollection new.
  1950                         list := OrderedCollection new.
  1947                         step := first < rowNr ifTrue:[1] ifFalse:[-1].
  1951                         step := first < rowNr ifTrue:[1] ifFalse:[-1].
  1948                         first to:rowNr by:step do:[:i|list add:i].
  1952                         first to:rowNr by:step do:[:i|list add:i].
  1949                         self selectedRowIndex:list.
  1953                         self selectedRowIndex:list.
  1959             ].
  1963             ].
  1960             ^ self
  1964             ^ self
  1961         ]
  1965         ]
  1962     ].
  1966     ].
  1963     super buttonPress:button x:x y:y
  1967     super buttonPress:button x:x y:y
  1964 
       
  1965 
       
  1966 
       
  1967 !
  1968 !
  1968 
  1969 
  1969 buttonRelease:button x:x y:y
  1970 buttonRelease:button x:x y:y
  1970 
  1971 
  1971     self stopAutoScroll.
  1972     self stopAutoScroll.
  2083 keyPress:aKey x:x y:y
  2084 keyPress:aKey x:x y:y
  2084     "a key was pressed - handle page-keys here
  2085     "a key was pressed - handle page-keys here
  2085     "
  2086     "
  2086     <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown
  2087     <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown
  2087                           #BeginOfText #EndOfText #ScrollUp #ScrollDown
  2088                           #BeginOfText #EndOfText #ScrollUp #ScrollDown
  2088                           #CursorUp #CursorDown #CursorRight #CursorLeft)>
  2089                           #CursorUp #CursorDown #CursorRight #CursorLeft #SelectAll)>
  2089 
  2090 
  2090     |sensor maxColNr selRowNr selColNr key column isTab listSize hasSelectables|
  2091     |sensor maxColNr selRowNr selColNr key column isTab listSize hasSelectables|
  2091 
  2092 
  2092     self isEnabled ifFalse:[^ self].
  2093     self isEnabled ifFalse:[^ self].
  2093 
  2094 
  2097     (listSize := list size) == 0 ifTrue:[
  2098     (listSize := list size) == 0 ifTrue:[
  2098         ^ super keyPress:aKey x:x y:y
  2099         ^ super keyPress:aKey x:x y:y
  2099     ].
  2100     ].
  2100     aKey isCharacter ifTrue:[
  2101     aKey isCharacter ifTrue:[
  2101         ^ self characterPress:aKey x:x y:y
  2102         ^ self characterPress:aKey x:x y:y
       
  2103     ].
       
  2104 
       
  2105     (aKey == #SelectAll) ifTrue:[
       
  2106         multipleSelectOk ifTrue:[
       
  2107             self selectAllRows. 
       
  2108         ].
       
  2109         ^ self
  2102     ].
  2110     ].
  2103 
  2111 
  2104     aKey == #PreviousPage ifTrue:[^ self pageUp].
  2112     aKey == #PreviousPage ifTrue:[^ self pageUp].
  2105     aKey == #NextPage     ifTrue:[^ self pageDown].
  2113     aKey == #NextPage     ifTrue:[^ self pageDown].
  2106     aKey == #HalfPageUp   ifTrue:[^ self halfPageUp].
  2114     aKey == #HalfPageUp   ifTrue:[^ self halfPageUp].
  2215 
  2223 
  2216         (column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[
  2224         (column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[
  2217             ^ self selectColIndex:selColNr rowIndex:selRowNr
  2225             ^ self selectColIndex:selColNr rowIndex:selRowNr
  2218         ]
  2226         ]
  2219     ].
  2227     ].
  2220 
       
  2221 
       
  2222 
       
  2223 !
  2228 !
  2224 
  2229 
  2225 originChanged:delta
  2230 originChanged:delta
  2226     "this one is sent, after the origin of my contents has changed -
  2231     "this one is sent, after the origin of my contents has changed -
  2227      tell dependents (i.e. scrollers) about this
  2232      tell dependents (i.e. scrollers) about this
  3129         ^ selectedRowIndex ~~ 0 ifTrue:[1] ifFalse:[0]
  3134         ^ selectedRowIndex ~~ 0 ifTrue:[1] ifFalse:[0]
  3130     ].
  3135     ].
  3131     ^ selectedRowIndex size
  3136     ^ selectedRowIndex size
  3132 !
  3137 !
  3133 
  3138 
       
  3139 selectAllRows
       
  3140     1 to:list size do:[:eachRowNr |
       
  3141         selectedRowIndex add:eachRowNr.    
       
  3142         self invalidateRowAt:eachRowNr.
       
  3143     ].
       
  3144     self selectionChanged.
       
  3145 !
       
  3146 
  3134 selectColIndex:aColNr rowIndex:aRowNr
  3147 selectColIndex:aColNr rowIndex:aRowNr
  3135     "change selection with notification
  3148     "change selection with notification
  3136     "
  3149     "
  3137     |oC oR|
  3150     |oC oR|
  3138 
  3151 
  3446 ! !
  3459 ! !
  3447 
  3460 
  3448 !DSVColumnView class methodsFor:'documentation'!
  3461 !DSVColumnView class methodsFor:'documentation'!
  3449 
  3462 
  3450 version
  3463 version
  3451     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.119 2001-03-08 13:51:25 cg Exp $'
  3464     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.120 2001-03-08 14:44:42 cg Exp $'
  3452 ! !
  3465 ! !