DSVColumnView.st
changeset 1416 505ef8832a06
parent 1408 1cda0a4fb566
child 1448 b389b8c76479
equal deleted inserted replaced
1415:3727e58ab63b 1416:505ef8832a06
    25 		buttonLightColor buttonShadowColor buttonHalfLightColor
    25 		buttonLightColor buttonShadowColor buttonHalfLightColor
    26 		buttonHalfShadowColor checkToggleExtent checkToggleForm
    26 		buttonHalfShadowColor checkToggleExtent checkToggleForm
    27 		checkToggleActiveImage checkTogglePassiveImage checkToggleLevel
    27 		checkToggleActiveImage checkTogglePassiveImage checkToggleLevel
    28 		comboButtonExtent comboButtonForm comboButtonLevel clickPosition
    28 		comboButtonExtent comboButtonForm comboButtonLevel clickPosition
    29 		dragAccessPoint dragIsActive dropTarget dropSource columnAdaptor
    29 		dragAccessPoint dragIsActive dropTarget dropSource columnAdaptor
    30 		dataSetView'
    30 		dataSetView tabAtEndAction tabAtStartAction'
    31 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    31 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
    32 		DefaultHilightForegroundColor DefaultHilightBackgroundColor
    32 		DefaultHilightForegroundColor DefaultHilightBackgroundColor
    33 		RowSelector ButtonLightColor ButtonShadowColor
    33 		RowSelector ButtonLightColor ButtonShadowColor
    34 		CheckToggleActiveImage CheckTogglePassiveImage
    34 		CheckToggleActiveImage CheckTogglePassiveImage
    35 		ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle
    35 		ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle
   687      block returns the row which is put to the list
   687      block returns the row which is put to the list
   688     "
   688     "
   689     rowIfAbsentBlock := aOneArgAction
   689     rowIfAbsentBlock := aOneArgAction
   690 
   690 
   691 
   691 
       
   692 !
       
   693 
       
   694 tabAtEndAction:aNoneArgAction
       
   695     "set the action, called without any argument at end of the list entering
       
   696      tab next.
       
   697      The default is to give the focus to the view after self in the focusSequence
       
   698     "
       
   699     tabAtEndAction := aNoneArgAction
       
   700 
       
   701 
       
   702 !
       
   703 
       
   704 tabAtStartAction:aNoneArgAction
       
   705     "set the action, called without any argument at start of the list entering
       
   706      tab previous.
       
   707      The default is to give the focus to the view before self in the focusSequence
       
   708     "
       
   709     tabAtStartAction := aNoneArgAction
       
   710 
       
   711 
   692 ! !
   712 ! !
   693 
   713 
   694 !DSVColumnView methodsFor:'accessing behavior'!
   714 !DSVColumnView methodsFor:'accessing behavior'!
   695 
   715 
   696 beDependentOfRows
   716 beDependentOfRows
  2120     "
  2140     "
  2121     <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown
  2141     <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown
  2122                           #BeginOfText #EndOfText #ScrollUp #ScrollDown
  2142                           #BeginOfText #EndOfText #ScrollUp #ScrollDown
  2123                           #CursorUp #CursorDown #CursorRight #CursorLeft)>
  2143                           #CursorUp #CursorDown #CursorRight #CursorLeft)>
  2124 
  2144 
  2125     |sensor n max idx selRowNr key column|
  2145     |sensor n max idx selRowNr key column isTab listSize noSel|
  2126 
  2146 
  2127     (sensor := self sensor) isNil ifTrue:[
  2147     (sensor := self sensor) isNil ifTrue:[
  2128         ^ self
  2148         ^ self
       
  2149     ].
       
  2150     (listSize := list size) == 0 ifTrue:[
       
  2151         ^ super keyPress:aKey x:x y:y
  2129     ].
  2152     ].
  2130 
  2153 
  2131     (aKey == #PreviousPage) ifTrue:[^ self pageUp].
  2154     (aKey == #PreviousPage) ifTrue:[^ self pageUp].
  2132     (aKey == #NextPage)     ifTrue:[^ self pageDown].
  2155     (aKey == #NextPage)     ifTrue:[^ self pageDown].
  2133     (aKey == #HalfPageUp)   ifTrue:[^ self halfPageUp].
  2156     (aKey == #HalfPageUp)   ifTrue:[^ self halfPageUp].
  2136     (aKey == #EndOfText)    ifTrue:[^ self scrollToBottom].
  2159     (aKey == #EndOfText)    ifTrue:[^ self scrollToBottom].
  2137     (aKey isCharacter)      ifTrue:[^ self characterPress:aKey x:x y:y ].
  2160     (aKey isCharacter)      ifTrue:[^ self characterPress:aKey x:x y:y ].
  2138 
  2161 
  2139     (aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[
  2162     (aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[
  2140         n := (1 + (sensor compressKeyPressEventsWithKey:aKey)) * self verticalScrollStep.
  2163         n := (1 + (sensor compressKeyPressEventsWithKey:aKey)) * self verticalScrollStep.
  2141 
  2164         aKey == #ScrollUp ifTrue:[self scrollUp:n] ifFalse:[self scrollDown:n].
  2142         aKey == #ScrollUp ifTrue:[self scrollUp:n]
  2165       ^ self
  2143                          ifFalse:[self scrollDown:n].
  2166     ].
  2144         ^ self
  2167 
  2145     ].
  2168     aKey == #Return ifTrue:[
  2146 
  2169         self numberOfSelections == 1 ifTrue:[self doubleClicked].
  2147     self numberOfSelections == 1 ifFalse:[
  2170       ^ self
  2148         super keyPress:aKey x:x y:y.
  2171     ].
  2149         ^ self
  2172 
  2150     ].
       
  2151     selRowNr := self firstIndexSelected.
  2173     selRowNr := self firstIndexSelected.
  2152 
  2174     n        := 1 + (sensor compressKeyPressEventsWithKey:aKey).
  2153     aKey == #Return ifTrue:[
       
  2154         ^ self doubleClicked
       
  2155     ].
       
  2156 
       
  2157     (aKey == #CursorUp or:[aKey == #CursorDown]) ifTrue:[
  2175     (aKey == #CursorUp or:[aKey == #CursorDown]) ifTrue:[
  2158         max := self size.
  2176         selRowNr == 0 ifTrue:[
  2159 
  2177             n := aKey == #CursorUp ifTrue:[listSize] ifFalse:[1]
  2160         (n := (1 + (sensor compressKeyPressEventsWithKey:aKey)) \\ max) ~~ 0 ifTrue:[
  2178         ] ifFalse:[
       
  2179             n := (n \\ listSize) max:1.
       
  2180 
  2161             aKey == #CursorUp ifTrue:[
  2181             aKey == #CursorUp ifTrue:[
  2162                 (n := selRowNr - n) <= 0  ifTrue:[n := max + n]
  2182                 (n := selRowNr - n) <= 0       ifTrue:[n := listSize + n]
  2163             ] ifFalse:[
  2183             ] ifFalse:[
  2164                 (n := selRowNr + n) > max ifTrue:[n := n - max]
  2184                 (n := selRowNr + n) > listSize ifTrue:[n := n - listSize]
       
  2185             ]
       
  2186         ].
       
  2187         ^ self selectColIndex:selectedColIndex rowIndex:n
       
  2188     ].
       
  2189     (isTab := aKey includesString:'Tab') ifTrue:[
       
  2190         key := (sensor shiftDown or:[aKey includesString:'Left']) ifTrue:[#CursorLeft]
       
  2191                                                                  ifFalse:[#CursorRight]
       
  2192     ] ifFalse:[
       
  2193         (aKey == #focusPrevious or:[aKey == #focusNext]) ifTrue:[
       
  2194             isTab := true.
       
  2195             key   := aKey == #focusPrevious ifTrue:[#CursorLeft] ifFalse:[#CursorRight]
       
  2196         ] ifFalse:[
       
  2197             (aKey == #CursorRight or:[aKey == #CursorLeft]) ifFalse:[
       
  2198                 ^ super keyPress:aKey x:x y:y
  2165             ].
  2199             ].
  2166             self selectColIndex:selectedColIndex rowIndex:n
  2200             key := aKey
  2167         ].
  2201         ]
  2168         ^ self
  2202     ].
  2169     ].
       
  2170 
       
  2171     aKey == #focusPrevious ifTrue:[
       
  2172         key := #CursorLeft
       
  2173     ].
       
  2174 
       
  2175     aKey == #Tab ifTrue:[
       
  2176         key := sensor shiftDown ifTrue:[#CursorLeft] ifFalse:[#CursorRight]
       
  2177     ] ifFalse:[
       
  2178         (aKey == #CursorRight or:[aKey == #CursorLeft]) ifFalse:[
       
  2179             ^ super keyPress:aKey x:x y:y
       
  2180         ].
       
  2181         key := aKey
       
  2182     ].
       
  2183 
       
  2184     selectedColIndex == 0 ifTrue:[  "/ line is selected
       
  2185         ^ self
       
  2186     ].
       
  2187 
       
  2188     n   := 1 + (sensor compressKeyPressEventsWithKey:key).
       
  2189     idx := selectedColIndex.
       
  2190     max := self numberOfColumns.
  2203     max := self numberOfColumns.
       
  2204     selRowNr == 0 ifTrue:[selRowNr := 1].
       
  2205 
       
  2206     (idx := selectedColIndex) == 0 ifTrue:[
       
  2207         idx := key == #CursorRight ifTrue:[0] ifFalse:[max + 1]
       
  2208     ].
  2191 
  2209 
  2192     key == #CursorLeft ifTrue:[
  2210     key == #CursorLeft ifTrue:[
  2193         [n ~~ 0] whileTrue:[
  2211         [n ~~ 0] whileTrue:[
  2194             (idx := idx - 1) == 0 ifTrue:[
  2212             (idx := idx - 1) == 0 ifTrue:[
  2195                 (aKey == #Tab and:[selRowNr > 1]) ifTrue:[
  2213                 (isTab and:[(selRowNr := selRowNr - 1) == 0]) ifTrue:[
  2196                     selRowNr := selRowNr - 1
  2214                     tabAtStartAction notNil ifTrue:[
       
  2215                         tabAtStartAction value
       
  2216                     ] ifFalse:[
       
  2217                         self windowGroup focusPreviousFrom:self
       
  2218                     ].
       
  2219                     ^ self
  2197                 ].
  2220                 ].
  2198                 idx := max
  2221                 idx := max
  2199             ].
  2222             ].
  2200 
       
  2201             column := self columnAt:idx.
  2223             column := self columnAt:idx.
       
  2224 
  2202             (column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[
  2225             (column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[
  2203                 n := n - 1
  2226                 n := n - 1
  2204             ]
  2227             ]
  2205         ]
  2228         ]
  2206     ] ifFalse:[
  2229     ] ifFalse:[
  2207         [n ~~ 0] whileTrue:[
  2230         [n ~~ 0] whileTrue:[
  2208             (idx := idx + 1) > max ifTrue:[
  2231             (idx := idx + 1) > max ifTrue:[
  2209                 (aKey == #Tab and:[selRowNr < self size]) ifTrue:[
  2232                 (isTab and:[(selRowNr := selRowNr + 1) > listSize]) ifTrue:[
  2210                     selRowNr := selRowNr + 1
  2233                     tabAtEndAction notNil ifTrue:[
       
  2234                         tabAtEndAction value
       
  2235                     ] ifFalse:[
       
  2236                         self windowGroup focusNextFrom:self
       
  2237                     ].
       
  2238                     ^ self
  2211                 ].
  2239                 ].
  2212                 idx := 1
  2240                 idx := 1
  2213             ].
  2241             ].
  2214 
       
  2215             column := self columnAt:idx.
  2242             column := self columnAt:idx.
       
  2243 
  2216             (column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[
  2244             (column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[
  2217                 n := n - 1
  2245                 n := n - 1
  2218             ]
  2246             ]
  2219         ]
  2247         ]
  2220     ].
  2248     ].
  2221     self selectColIndex:idx rowIndex:selRowNr.
  2249     self selectColIndex:idx rowIndex:selRowNr.
       
  2250 
  2222 
  2251 
  2223 
  2252 
  2224 !
  2253 !
  2225 
  2254 
  2226 originChanged:delta
  2255 originChanged:delta
  3337 ! !
  3366 ! !
  3338 
  3367 
  3339 !DSVColumnView class methodsFor:'documentation'!
  3368 !DSVColumnView class methodsFor:'documentation'!
  3340 
  3369 
  3341 version
  3370 version
  3342     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.76 1999-06-11 17:22:15 cg Exp $'
  3371     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.77 1999-06-19 10:23:36 cg Exp $'
  3343 ! !
  3372 ! !