SelectionInListModelView.st
changeset 1557 e3feb8bc17b0
parent 1554 c45cac3c4d31
child 1561 edac7f38341b
equal deleted inserted replaced
1556:79229e472bbe 1557:e3feb8bc17b0
   263     "
   263     "
   264     selection isNil ifTrue:[
   264     selection isNil ifTrue:[
   265         multipleSelectOk ifTrue:[^ #()].
   265         multipleSelectOk ifTrue:[^ #()].
   266         ^ useIndex ifTrue:[0] ifFalse:[nil]
   266         ^ useIndex ifTrue:[0] ifFalse:[nil]
   267     ].
   267     ].
   268     useIndex ifTrue:[^ selection].
   268     useIndex ifTrue:[^ selection copy].
   269 
   269 
   270     multipleSelectOk ifFalse:[
   270     multipleSelectOk ifFalse:[
   271         ^ list at:selection ifAbsent:nil
   271         ^ list at:selection ifAbsent:nil
   272     ].
   272     ].
   273     ^ selection collect:[:nr| list at:nr ifAbsent:nil ]
   273     ^ selection collect:[:nr| list at:nr ifAbsent:nil ]
   275 
   275 
   276 getSelectionFromModel
   276 getSelectionFromModel
   277     "get selection from model; returns a selection or nil
   277     "get selection from model; returns a selection or nil
   278     "
   278     "
   279     |value nsel|
   279     |value nsel|
   280 
       
   281     model isNil ifTrue:[
       
   282         ^ nil
       
   283     ].
       
   284     self syncFlushEvent:#setSelection:.
       
   285 
   280 
   286     ((value := model value) isNil or:[value == 0]) ifTrue:[
   281     ((value := model value) isNil or:[value == 0]) ifTrue:[
   287         ^ nil
   282         ^ nil
   288     ].
   283     ].
   289 
   284 
   499 !SelectionInListModelView methodsFor:'drawing'!
   494 !SelectionInListModelView methodsFor:'drawing'!
   500 
   495 
   501 drawFrom:start to:stop x:x y:y w:w
   496 drawFrom:start to:stop x:x y:y w:w
   502     "draw the lines between start to stop without clearing the background
   497     "draw the lines between start to stop without clearing the background
   503     "
   498     "
   504     self selectionDo:[:lnNr|
   499     highlightMode notNil ifTrue:[
   505         (lnNr between:start and:stop) ifTrue:[
   500         self selectionDo:[:lnNr|
   506             self drawSelectionFrameAt:lnNr x:x w:w
   501             (lnNr between:start and:stop) ifTrue:[
       
   502                 self drawSelectionFrameAt:lnNr x:x w:w
       
   503             ]
   507         ]
   504         ]
   508     ].
   505     ].
   509     self drawElementsFrom:start to:stop x:x y:y w:w.
   506     self drawElementsFrom:start to:stop x:x y:y w:w.
   510 
   507 
   511 
   508 
   515     "draw the label at position x/y without clearing the background
   512     "draw the label at position x/y without clearing the background
   516     "
   513     "
   517     |item|
   514     |item|
   518 
   515 
   519     item := list at:anIndex ifAbsent:nil.
   516     item := list at:anIndex ifAbsent:nil.
   520     item isNil ifTrue:[^ self].
   517 
   521 
   518     item notNil ifTrue:[
   522     (self isInSelection:anIndex) ifTrue:[
   519         (highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
   523         self paint:hilightFgColor on:hilightBgColor
   520             self paint:hilightFgColor on:hilightBgColor
   524     ] ifFalse:[
   521         ] ifFalse:[
   525         self paint:fgColor on:bgColor.
   522             self paint:fgColor on:bgColor.
   526     ].
   523         ].
   527     self displayElement:item x:x y:y h:h.
   524         self displayElement:item x:x y:y h:h.
       
   525     ]
   528 
   526 
   529 
   527 
   530 !
   528 !
   531 
   529 
   532 drawSelectionFrameAt:lnNr x:x w:w
   530 drawSelectionFrameAt:lnNr x:x w:w
   609 !
   607 !
   610 
   608 
   611 redrawSelectionAt:aLineNr
   609 redrawSelectionAt:aLineNr
   612     "called to redraw a line caused by a change of the selection
   610     "called to redraw a line caused by a change of the selection
   613     "
   611     "
   614     self redrawLineAt:aLineNr.
   612     highlightMode notNil ifTrue:[
       
   613         self redrawLineAt:aLineNr
       
   614     ].
       
   615 
   615 ! !
   616 ! !
   616 
   617 
   617 !SelectionInListModelView methodsFor:'event handling'!
   618 !SelectionInListModelView methodsFor:'event handling'!
   618 
   619 
   619 buttonMotion:buttonMask x:x y:y
   620 buttonMotion:buttonMask x:x y:y
   914     super initStyle.
   915     super initStyle.
   915 
   916 
   916     hilightFrameColor := nil.
   917     hilightFrameColor := nil.
   917     hilightLevel      := 0.
   918     hilightLevel      := 0.
   918     hilightStyle      := DefaultHilightStyle.
   919     hilightStyle      := DefaultHilightStyle.
   919     highlightMode     := #line.
   920     highlightMode     := #label.
   920     textStartLeft     := 4.
   921     textStartLeft     := 4.
   921 
   922 
   922     device hasGrayscales ifTrue:[
   923     device hasGrayscales ifTrue:[
   923         "
   924         "
   924          must get rid of these hard codings
   925          must get rid of these hard codings
  1292 ! !
  1293 ! !
  1293 
  1294 
  1294 !SelectionInListModelView class methodsFor:'documentation'!
  1295 !SelectionInListModelView class methodsFor:'documentation'!
  1295 
  1296 
  1296 version
  1297 version
  1297     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.18 1999-09-22 10:08:16 cg Exp $'
  1298     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.19 1999-09-23 08:18:38 cg Exp $'
  1298 ! !
  1299 ! !
  1299 SelectionInListModelView initialize!
  1300 SelectionInListModelView initialize!