DSVColumnView.st
changeset 1668 085f5ee84f9b
parent 1665 51c444bfe5ae
child 1673 67898506ba03
equal deleted inserted replaced
1667:54c87dace343 1668:085f5ee84f9b
    17 	instanceVariableNames:'labelView listHolder editValue editView multipleSelectOk useIndex
    17 	instanceVariableNames:'labelView listHolder editValue editView multipleSelectOk useIndex
    18 		selectedColIndex selectedRowIndex selectRowOnDefault rowHeight
    18 		selectedColIndex selectedRowIndex selectRowOnDefault rowHeight
    19 		columnDescriptors viewOrigin colorMap rowFontAscent lockRowIndex
    19 		columnDescriptors viewOrigin colorMap rowFontAscent lockRowIndex
    20 		rowIfAbsentBlock columnHolder registererImages list fgColor
    20 		rowIfAbsentBlock columnHolder registererImages list fgColor
    21 		separatorSize catchChangeEvents beDependentOfRows bgColor
    21 		separatorSize catchChangeEvents beDependentOfRows bgColor
    22 		hgLgFgColor hgLgBgColor actionBlock builder
    22 		hgLgFgColor hgLgBgColor actionBlock builder tabIntern
    23 		doubleClickActionBlock verticalSpacing horizontalSpacing
    23 		doubleClickActionBlock verticalSpacing horizontalSpacing
    24 		rowSelectorForm buttonLightColor buttonShadowColor
    24 		rowSelectorForm buttonLightColor buttonShadowColor
    25 		buttonHalfLightColor buttonHalfShadowColor checkToggleExtent
    25 		buttonHalfLightColor buttonHalfShadowColor checkToggleExtent
    26 		checkToggleForm checkToggleActiveImage checkTogglePassiveImage
    26 		checkToggleForm checkToggleActiveImage checkTogglePassiveImage
    27 		checkToggleLevel comboButtonExtent comboButtonForm
    27 		checkToggleLevel comboButtonExtent comboButtonForm
   439             ]
   439             ]
   440         ]
   440         ]
   441     ]
   441     ]
   442 !
   442 !
   443 
   443 
   444 handleTab
       
   445     ^ true
       
   446 !
       
   447 
       
   448 multipleSelectOk
   444 multipleSelectOk
   449     "allow/disallow multiple row selections; the default is false
   445     "allow/disallow multiple row selections; the default is false
   450     "
   446     "
   451     ^ multipleSelectOk
   447     ^ multipleSelectOk
   452 !
   448 !
   468 
   464 
   469 selectRowOnDefault:aBool
   465 selectRowOnDefault:aBool
   470     "in case of selecting a none selectable cell, the row is selected
   466     "in case of selecting a none selectable cell, the row is selected
   471     "
   467     "
   472     selectRowOnDefault := aBool
   468     selectRowOnDefault := aBool
       
   469 !
       
   470 
       
   471 tabIntern
       
   472     "returns true if tabing is supported in the widget
       
   473     "
       
   474     ^ tabIntern
       
   475 !
       
   476 
       
   477 tabIntern:aBool
       
   478     "returns true if tabing is supported in the widget
       
   479     "
       
   480     tabIntern := aBool ? true
   473 !
   481 !
   474 
   482 
   475 useIndex
   483 useIndex
   476     "specify, if the selected components value or its index in the
   484     "specify, if the selected components value or its index in the
   477      list should be sent to the model. The default is its index.
   485      list should be sent to the model. The default is its index.
  1994     "
  2002     "
  1995     <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown
  2003     <resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown
  1996                           #BeginOfText #EndOfText #ScrollUp #ScrollDown
  2004                           #BeginOfText #EndOfText #ScrollUp #ScrollDown
  1997                           #CursorUp #CursorDown #CursorRight #CursorLeft)>
  2005                           #CursorUp #CursorDown #CursorRight #CursorLeft)>
  1998 
  2006 
  1999     |sensor n maxColNr idx selRowNr key column isTab listSize noSel|
  2007     |sensor n maxColNr idx selRowNr key column isTab listSize noSel hasSelectables|
  2000 
  2008 
  2001     (sensor := self sensor) isNil ifTrue:[
  2009     (sensor := self sensor) isNil ifTrue:[
  2002         ^ self
  2010         ^ self
  2003     ].
  2011     ].
  2004     (listSize := list size) == 0 ifTrue:[
  2012     (listSize := list size) == 0 ifTrue:[
  2022     aKey == #Return ifTrue:[
  2030     aKey == #Return ifTrue:[
  2023         self numberOfSelections == 1 ifTrue:[self doubleClicked].
  2031         self numberOfSelections == 1 ifTrue:[self doubleClicked].
  2024       ^ self
  2032       ^ self
  2025     ].
  2033     ].
  2026 
  2034 
       
  2035     hasSelectables := false.
       
  2036 
       
  2037     columnDescriptors do:[:aCol|
       
  2038         (hasSelectables or:[aCol rendererType == #rowSelector]) ifFalse:[
       
  2039             hasSelectables := aCol description canSelect
       
  2040         ]
       
  2041     ].
       
  2042 
       
  2043     hasSelectables ifFalse:[
       
  2044         ^ super keyPress:aKey x:x y:y
       
  2045     ].
       
  2046 
  2027     selRowNr := self firstIndexSelected.
  2047     selRowNr := self firstIndexSelected.
  2028     n        := 1 + (sensor compressKeyPressEventsWithKey:aKey).
  2048     n        := 1 + (sensor compressKeyPressEventsWithKey:aKey).
  2029     (aKey == #CursorUp or:[aKey == #CursorDown]) ifTrue:[
  2049     (aKey == #CursorUp or:[aKey == #CursorDown]) ifTrue:[
  2030         selRowNr == 0 ifTrue:[
  2050         selRowNr == 0 ifTrue:[
  2031             n := aKey == #CursorUp ifTrue:[listSize] ifFalse:[1]
  2051             n := aKey == #CursorUp ifTrue:[listSize] ifFalse:[1]
  2040         ].
  2060         ].
  2041         ^ self selectColIndex:selectedColIndex rowIndex:n
  2061         ^ self selectColIndex:selectedColIndex rowIndex:n
  2042     ].
  2062     ].
  2043 
  2063 
  2044     (aKey == #CursorLeft or:[aKey == #CursorRight]) ifFalse:[
  2064     (aKey == #CursorLeft or:[aKey == #CursorRight]) ifFalse:[
  2045         self handleTab ifFalse:[
  2065         tabIntern ifFalse:[
  2046             ^ super keyPress:aKey x:x y:y
  2066             ^ super keyPress:aKey x:x y:y
  2047         ].
  2067         ].
  2048 
  2068 
  2049         (aKey includesString:'Tab') ifTrue:[
  2069         (aKey includesString:'Tab') ifTrue:[
  2050             key := (sensor shiftDown or:[aKey includesString:'Left']) ifTrue:[#CursorLeft]
  2070             key := (sensor shiftDown or:[aKey includesString:'Left']) ifTrue:[#CursorLeft]
  2059     ] ifTrue:[
  2079     ] ifTrue:[
  2060         isTab := false.
  2080         isTab := false.
  2061         key   := aKey.
  2081         key   := aKey.
  2062     ].
  2082     ].
  2063 
  2083 
  2064     isTab ifTrue:[
       
  2065         selRowNr == 0 ifTrue:[
       
  2066             self tabIn ifFalse:[
       
  2067                 ^ super keyPress:aKey x:x y:y
       
  2068             ].
       
  2069         ]
       
  2070     ].
       
  2071     maxColNr := self numberOfColumns.
  2084     maxColNr := self numberOfColumns.
  2072     idx := selectedColIndex.
  2085     idx := selectedColIndex.
  2073 
  2086 
  2074     key == #CursorLeft ifTrue:[
  2087     key == #CursorLeft ifTrue:[
  2075         selRowNr == 0 ifTrue:[selRowNr := listSize].
  2088         selRowNr == 0 ifTrue:[selRowNr := listSize].
  2143 canTab
  2156 canTab
  2144     super canTab ifTrue:[
  2157     super canTab ifTrue:[
  2145         ^ editView isNil
  2158         ^ editView isNil
  2146     ].
  2159     ].
  2147     ^ false
  2160     ^ false
  2148 !
       
  2149 
       
  2150 tabIn
       
  2151     ^ true
       
  2152 ! !
  2161 ! !
  2153 
  2162 
  2154 !DSVColumnView methodsFor:'gc operations'!
  2163 !DSVColumnView methodsFor:'gc operations'!
  2155 
  2164 
  2156 imageOnDevice:anImage
  2165 imageOnDevice:anImage
  2305     "set default attributes
  2314     "set default attributes
  2306     "
  2315     "
  2307     super initialize.
  2316     super initialize.
  2308     self lineWidth:0.
  2317     self lineWidth:0.
  2309 
  2318 
       
  2319     tabIntern          := true.
  2310     useIndex           := true.
  2320     useIndex           := true.
  2311     viewOrigin         := 0@0.
  2321     viewOrigin         := 0@0.
  2312     font               := font onDevice:device.
  2322     font               := font onDevice:device.
  2313     rowHeight          := font height.
  2323     rowHeight          := font height.
  2314     multipleSelectOk   := false.                        "/ multiselect disabled
  2324     multipleSelectOk   := false.                        "/ multiselect disabled
  2322     catchChangeEvents  := false.
  2332     catchChangeEvents  := false.
  2323     dragIsActive       := false.
  2333     dragIsActive       := false.
  2324     rowFontAscent      := 1.                            "/ dummy initialization
  2334     rowFontAscent      := 1.                            "/ dummy initialization
  2325     separatorSize      := 1.                            "/ separators mode 2D
  2335     separatorSize      := 1.                            "/ separators mode 2D
  2326     selectRowOnDefault := true.
  2336     selectRowOnDefault := true.
  2327 
       
  2328 !
  2337 !
  2329 
  2338 
  2330 mapped
  2339 mapped
  2331     "set selection if exists after mapping
  2340     "set selection if exists after mapping
  2332     "
  2341     "
  3310 ! !
  3319 ! !
  3311 
  3320 
  3312 !DSVColumnView class methodsFor:'documentation'!
  3321 !DSVColumnView class methodsFor:'documentation'!
  3313 
  3322 
  3314 version
  3323 version
  3315     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.98 2000-02-01 13:53:30 ca Exp $'
  3324     ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.99 2000-02-02 09:32:16 ca Exp $'
  3316 ! !
  3325 ! !