SelectionInTreeView.st
changeset 3176 4785f8b58e64
parent 2689 c382886ddb08
child 3220 02154432a13e
equal deleted inserted replaced
3175:d82c95049597 3176:4785f8b58e64
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
       
    13 
       
    14 "{ Package: 'stx:libwidg2' }"
    12 "{ Package: 'stx:libwidg2' }"
    15 
    13 
    16 SelectionInListView subclass:#SelectionInTreeView
    14 SelectionInListView subclass:#SelectionInTreeView
    17 	instanceVariableNames:'validateDoubleClickBlock selectionHolder rootHolder imageWidth
    15 	instanceVariableNames:'validateDoubleClickBlock selectionHolder rootHolder imageWidth
    18 		showLines showLinesForRoot listOfNodes imageInset textInset
    16 		showLines showLinesForRoot listOfNodes imageInset textInset
   787     img notNil ifTrue:[
   785     img notNil ifTrue:[
   788         ext := img extent // 2.
   786         ext := img extent // 2.
   789         dX  := ext x.
   787         dX  := ext x.
   790 
   788 
   791         (x + dX > 0 and:[(x := x - dX) < (width - margin)]) ifTrue:[
   789         (x + dX > 0 and:[(x := x - dX) < (width - margin)]) ifTrue:[
   792             (self isInSelection:aLineNr) ifTrue:[ self paint:hilightFgColor on:hilightBgColor ]
   790             self paintOnIsSelected:(self isInSelection:aLineNr).
   793                                         ifFalse:[ self paint:fgColor on:bgColor ].
       
   794 
   791 
   795             y := (self yOfVisibleLine:visLn) + (fontHeight // 2) - 1.
   792             y := (self yOfVisibleLine:visLn) + (fontHeight // 2) - 1.
   796             self displayForm:img x:x y:(y - ext y)
   793             self displayForm:img x:x y:(y - ext y)
   797         ].
   794         ].
   798     ].
   795     ].
   799 
       
   800 
       
   801 
       
   802 !
   796 !
   803 
   797 
   804 redrawVisibleLine:visLineNr
   798 redrawVisibleLine:visLineNr
   805     self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
   799     self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
   806 !
   800 !
   955     ].
   949     ].
   956     self redrawX:0
   950     self redrawX:0
   957                y:(self yOfVisibleLine:visLineNr)
   951                y:(self yOfVisibleLine:visLineNr)
   958            width:width
   952            width:width
   959           height:fontHeight
   953           height:fontHeight
       
   954 !
       
   955 
       
   956 paintOnIsSelected:isSelected
       
   957     isSelected ifTrue:[
       
   958         self hasFocus ifTrue:[
       
   959             self paint:hilightFgColor on:hilightBgColor
       
   960         ] ifFalse:[
       
   961             self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus
       
   962         ]
       
   963     ] ifFalse:[
       
   964         self paint:fgColor on:bgColor.
       
   965     ].
   960 !
   966 !
   961 
   967 
   962 redrawElement:anIndex
   968 redrawElement:anIndex
   963 
   969 
   964     |vln x0 xT y|
   970     |vln x0 xT y|
   998     highlightMode == #label ifTrue:[
  1004     highlightMode == #label ifTrue:[
   999         x0 := x + 4.
  1005         x0 := x + 4.
  1000 
  1006 
  1001         isSel ifTrue:[
  1007         isSel ifTrue:[
  1002             w  := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8.
  1008             w  := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8.
  1003             self paint:hilightBgColor.
  1009 
       
  1010             self hasFocus ifTrue:[
       
  1011                 self paint:hilightBgColor.
       
  1012             ] ifFalse:[
       
  1013                 self paint:hilightBgColorNoFocus.
       
  1014             ].                
  1004             self fillRectangleX:x y:yTop width:w height:fontHeight.
  1015             self fillRectangleX:x y:yTop width:w height:fontHeight.
  1005 
  1016 
  1006             (value notNil and:[(editorWidget isNil or:[editorIndex ~~ anIndex])]) ifTrue:[
  1017             (value notNil and:[(editorWidget isNil or:[editorIndex ~~ anIndex])]) ifTrue:[
  1007                 wV := SelectionInset + SelectionInset + (value widthOn:self).
  1018                 wV := SelectionInset + SelectionInset + (value widthOn:self).
  1008                 self fillRectangleX:xV y:yTop width:wV height:fontHeight.
  1019                 self fillRectangleX:xV y:yTop width:wV height:fontHeight.
  1011     ] ifFalse:[
  1022     ] ifFalse:[
  1012         x0 := x
  1023         x0 := x
  1013     ].
  1024     ].
  1014 
  1025 
  1015     label notNil ifTrue:[
  1026     label notNil ifTrue:[
  1016         isSel ifTrue:[self paint:hilightFgColor on:hilightBgColor]
  1027         self paintOnIsSelected:isSel.
  1017              ifFalse:[self paint:fgColor on:bgColor].
       
  1018 
       
  1019         self displayOpaqueString:label x:x0 y:y0.
  1028         self displayOpaqueString:label x:x0 y:y0.
  1020 
  1029 
  1021         value notNil ifTrue:[
  1030         value notNil ifTrue:[
  1022             isSel ifFalse:[
  1031             isSel ifFalse:[
  1023                 self paint:editValueFgColor on:bgColor
  1032                 self paint:editValueFgColor on:bgColor
  1030     (isSel and:[highlightMode == #label]) ifTrue:[
  1039     (isSel and:[highlightMode == #label]) ifTrue:[
  1031         self redrawSelFrameAtX:x y:yTop toX:(x + w).
  1040         self redrawSelFrameAtX:x y:yTop toX:(x + w).
  1032 
  1041 
  1033         wV ~~ 0 ifTrue:[
  1042         wV ~~ 0 ifTrue:[
  1034             self redrawSelFrameAtX:xV y:yTop toX:(xV + wV)
  1043             self redrawSelFrameAtX:xV y:yTop toX:(xV + wV)
  1035         ]
  1044         ].
  1036     ].
  1045     ].
  1037 
       
  1038 
       
  1039 !
  1046 !
  1040 
  1047 
  1041 redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop
  1048 redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop
  1042     "redraw from line to line without clearing the background
  1049     "redraw from line to line without clearing the background
  1043     "
  1050     "
  1138     |
  1145     |
  1139 
  1146 
  1140     hilightFrameColor notNil ifTrue:[
  1147     hilightFrameColor notNil ifTrue:[
  1141         hilightLevel == 0 ifTrue:[
  1148         hilightLevel == 0 ifTrue:[
  1142             self paint:hilightFrameColor.
  1149             self paint:hilightFrameColor.
       
  1150 
  1143             highlightMode == #line ifTrue:[
  1151             highlightMode == #line ifTrue:[
  1144                 self displayLineFromX:x0 y:y0 toX:x1 y:y0.
  1152                 self displayLineFromX:x0 y:y0 toX:x1 y:y0.
  1145                 y := y0 + fontHeight - 1.
  1153                 y := y0 + fontHeight - 1.
  1146                 ^self displayLineFromX:x0 y:y toX:x1 y:y.
  1154                 self displayLineFromX:x0 y:y toX:x1 y:y.
  1147             ] ifFalse:[
  1155             ] ifFalse:[
  1148                 ^self displayRectangleX:x0 y:y0 width:x1 - x0 height:fontHeight
  1156                 self displayRectangleX:x0 y:y0 width:x1 - x0 height:fontHeight.
  1149             ]
  1157             ].
  1150         ]
  1158             ^ self
       
  1159         ].
  1151     ] ifFalse:[
  1160     ] ifFalse:[
  1152         hilightStyle == #motif ifTrue:[
  1161         hilightStyle == #motif ifTrue:[
  1153             self paint:bgColor.
  1162             self paint:bgColor.
  1154             y := y0 + 1.
  1163             y := y0 + 1.
  1155             highlightMode == #line ifTrue:[
  1164             highlightMode == #line ifTrue:[
  2486 ! !
  2495 ! !
  2487 
  2496 
  2488 !SelectionInTreeView class methodsFor:'documentation'!
  2497 !SelectionInTreeView class methodsFor:'documentation'!
  2489 
  2498 
  2490 version
  2499 version
  2491     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.106 2004-03-26 11:35:58 ca Exp $'
  2500     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.107 2007-02-28 15:50:46 ca Exp $'
  2492 ! !
  2501 ! !