SelectionInListView.st
changeset 1640 1ddc9c17b4bf
parent 1638 3168c74c3d48
child 1676 a85936a2064c
equal deleted inserted replaced
1639:ae51010bd1dc 1640:1ddc9c17b4bf
  2069 "/           ^ self buttonPress:button x:x y:y
  2069 "/           ^ self buttonPress:button x:x y:y
  2070 "/        ].
  2070 "/        ].
  2071         enabled ifTrue:[
  2071         enabled ifTrue:[
  2072             listLineNr := self visibleLineToListLine:(self visibleLineOfY:y).
  2072             listLineNr := self visibleLineToListLine:(self visibleLineOfY:y).
  2073             listLineNr notNil ifTrue:[
  2073             listLineNr notNil ifTrue:[
  2074                 (self line:listLineNr hasAttribute:#disabled) ifTrue:[^ self].
  2074                 (self lineIsEnabled:listLineNr) ifFalse:[^ self].
  2075 
  2075 
  2076                 (selectConditionBlock notNil 
  2076                 (selectConditionBlock notNil 
  2077                  and:[(selectConditionBlock value:listLineNr) not]) ifTrue:[^ self].
  2077                  and:[(selectConditionBlock value:listLineNr) not]) ifTrue:[^ self].
  2078             ].
  2078             ].
  2079             oldSelection := selection copy.
  2079             oldSelection := selection copy.
  2096         ]
  2096         ]
  2097     ] ifFalse:[
  2097     ] ifFalse:[
  2098         super buttonPress:button x:x y:y
  2098         super buttonPress:button x:x y:y
  2099     ]
  2099     ]
  2100 
  2100 
  2101     "Created: 14.11.1996 / 15:51:41 / cg"
  2101     "Created: / 14.11.1996 / 15:51:41 / cg"
  2102     "Modified: 17.6.1997 / 18:03:19 / cg"
  2102     "Modified: / 8.8.1998 / 03:24:03 / cg"
  2103 !
  2103 !
  2104 
  2104 
  2105 buttonMotion:buttonMask x:x y:y
  2105 buttonMotion:buttonMask x:x y:y
  2106     "mouse-move while button was pressed - handle selection changes"
  2106     "mouse-move while button was pressed - handle selection changes"
  2107 
  2107 
  2762 !
  2762 !
  2763 
  2763 
  2764 isValidSelection:aNumberOrCollection
  2764 isValidSelection:aNumberOrCollection
  2765     "return true, if aNumber is ok as a selection index"
  2765     "return true, if aNumber is ok as a selection index"
  2766 
  2766 
       
  2767     |sz|
       
  2768 
  2767     aNumberOrCollection isNil ifTrue:[^ false].
  2769     aNumberOrCollection isNil ifTrue:[^ false].
  2768 
  2770 
       
  2771     sz := self size.
  2769     (aNumberOrCollection isCollection) ifTrue:[
  2772     (aNumberOrCollection isCollection) ifTrue:[
  2770 	multipleSelectOk ifFalse:[^ false].
  2773         multipleSelectOk ifFalse:[^ false].
  2771 	aNumberOrCollection do:[:index |
  2774         aNumberOrCollection do:[:index |
  2772 	    (index between:1 and:self size) ifFalse:[^ false].
  2775             (index between:1 and:sz) ifFalse:[^ false].
  2773 	].
  2776             (self lineIsEnabled:index) ifFalse:[^ false].
  2774 	^ true.
  2777         ].
  2775     ] ifFalse:[
  2778     ] ifFalse:[
  2776 	^ (aNumberOrCollection between:1 and:self size).
  2779         (aNumberOrCollection between:1 and:sz) ifFalse:[^ false].
  2777     ].
  2780         (self lineIsEnabled:aNumberOrCollection) ifFalse:[^ false].
  2778 
  2781     ].
       
  2782     ^ true.
       
  2783 
       
  2784     "Modified: / 8.8.1998 / 03:34:27 / cg"
       
  2785 !
       
  2786 
       
  2787 lineIsEnabled:lineNr
       
  2788     ^ (self line:lineNr hasAttribute:#disabled) not
       
  2789 
       
  2790     "Modified: / 8.8.1998 / 03:22:50 / cg"
  2779 !
  2791 !
  2780 
  2792 
  2781 positionToSelectionX:x y:y
  2793 positionToSelectionX:x y:y
  2782     "given a click position, return the selection lineNo"
  2794     "given a click position, return the selection lineNo"
  2783 
  2795 
  2814         (toggleSelect 
  2826         (toggleSelect 
  2815         and:[self isInSelection:listLineNr]) ifTrue:[
  2827         and:[self isInSelection:listLineNr]) ifTrue:[
  2816             oldSelection := selection copy.
  2828             oldSelection := selection copy.
  2817             self removeFromSelection:listLineNr
  2829             self removeFromSelection:listLineNr
  2818         ] ifFalse:[
  2830         ] ifFalse:[
  2819             (self line:listLineNr hasAttribute:#disabled) ifTrue:[^ self].
  2831             (self lineIsEnabled:listLineNr) ifFalse:[^ self].
  2820 
  2832 
  2821             (selectConditionBlock notNil 
  2833             (selectConditionBlock notNil 
  2822              and:[(selectConditionBlock value:listLineNr) not]) ifTrue:[^ self].
  2834              and:[(selectConditionBlock value:listLineNr) not]) ifTrue:[^ self].
  2823 
  2835 
  2824             (toggleSelect and:[multipleSelectOk]) ifTrue:[
  2836             (toggleSelect and:[multipleSelectOk]) ifTrue:[
  2834             self selectionChangedFrom:oldSelection.
  2846             self selectionChangedFrom:oldSelection.
  2835         ].
  2847         ].
  2836         clickLine := listLineNr
  2848         clickLine := listLineNr
  2837     ]
  2849     ]
  2838 
  2850 
  2839     "Created: 14.11.1996 / 16:27:17 / cg"
  2851     "Created: / 14.11.1996 / 16:27:17 / cg"
  2840 
  2852     "Modified: / 8.8.1998 / 03:22:26 / cg"
  2841 !
  2853 !
  2842 
  2854 
  2843 visibleLineNeedsSpecialCare:visLineNr
  2855 visibleLineNeedsSpecialCare:visLineNr
  2844     |listLine|
  2856     |listLine|
  2845 
  2857 
  2990             self paint:fg on:bg.
  3002             self paint:fg on:bg.
  2991             dObj displayOn:self x:0 y:y opaque:true.
  3003             dObj displayOn:self x:0 y:y opaque:true.
  2992             ^ self
  3004             ^ self
  2993         ].
  3005         ].
  2994         listAttributes notNil ifTrue:[
  3006         listAttributes notNil ifTrue:[
  2995             (self line:listLine hasAttribute:#halfIntensity) ifTrue:[
  3007             ((self line:listLine hasAttribute:#halfIntensity) 
       
  3008             or:[ (self lineIsEnabled:listLine) not ]) ifTrue:[
  2996                 fg := halfIntensityFgColor
  3009                 fg := halfIntensityFgColor
  2997             ] ifFalse:[
       
  2998                 (self line:listLine hasAttribute:#disabled) ifTrue:[
       
  2999                     fg := halfIntensityFgColor
       
  3000                 ].
       
  3001             ].
  3010             ].
  3002             (self line:listLine hasAttribute:#bold) ifTrue:[
  3011             (self line:listLine hasAttribute:#bold) ifTrue:[
  3003                 newFont := font asBold.
  3012                 newFont := font asBold.
  3004                 (font bold 
  3013                 (font bold 
  3005                 or:[id := (newFont on:device) fontId.
  3014                 or:[id := (newFont on:device) fontId.
  3034             ]
  3043             ]
  3035         ]
  3044         ]
  3036     ].
  3045     ].
  3037     ^ self drawVisibleLine:visLineNr with:fg and:bg
  3046     ^ self drawVisibleLine:visLineNr with:fg and:bg
  3038 
  3047 
  3039     "Modified: / 21.6.1998 / 03:26:28 / cg"
  3048     "Modified: / 8.8.1998 / 03:42:13 / cg"
  3040 !
  3049 !
  3041 
  3050 
  3042 redrawVisibleLine:visLineNr col:colNr
  3051 redrawVisibleLine:visLineNr col:colNr
  3043     "redraw a single character.
  3052     "redraw a single character.
  3044      Must check, if its in the selection and handle this case."
  3053      Must check, if its in the selection and handle this case."
  3153 
  3162 
  3154 nextAfterSelection
  3163 nextAfterSelection
  3155     "return the index of the next selectable entry after the selection.
  3164     "return the index of the next selectable entry after the selection.
  3156      Wrap at end."
  3165      Wrap at end."
  3157 
  3166 
  3158     |next|
  3167     |next sz|
  3159 
  3168 
  3160     selection isNil ifTrue:[
  3169     selection isNil ifTrue:[
  3161         next := firstLineShown
  3170         next := firstLineShown
  3162     ] ifFalse:[
  3171     ] ifFalse:[
  3163         selection isCollection ifTrue:[
  3172         selection isCollection ifTrue:[
  3168             ]
  3177             ]
  3169         ] ifFalse:[
  3178         ] ifFalse:[
  3170             next := selection + 1
  3179             next := selection + 1
  3171         ].
  3180         ].
  3172     ].
  3181     ].
       
  3182 
  3173     (self isValidSelection:next) ifFalse:[
  3183     (self isValidSelection:next) ifFalse:[
  3174         next > self size ifTrue:[
  3184         sz := self size.
       
  3185         next > sz ifTrue:[
  3175             next := 1.
  3186             next := 1.
  3176         ] ifFalse:[
  3187         ] ifFalse:[
  3177             [next <= self size
  3188             [next <= sz
  3178              and:[(self isValidSelection:next) not]] whileTrue:[
  3189              and:[(self isValidSelection:next) not ]] whileTrue:[
  3179                 next := next + 1
  3190                 next := next + 1
  3180             ].
  3191             ].
  3181         ].
  3192         ].
  3182     ].
  3193     ].
       
  3194 
  3183     (self isValidSelection:next) ifFalse:[
  3195     (self isValidSelection:next) ifFalse:[
  3184         next := nil
  3196         next := nil
  3185     ].
  3197     ].
  3186     ^ next
  3198     ^ next
       
  3199 
       
  3200     "Modified: / 8.8.1998 / 03:36:55 / cg"
  3187 !
  3201 !
  3188 
  3202 
  3189 numberOfSelections
  3203 numberOfSelections
  3190     "return the number of selected entries"
  3204     "return the number of selected entries"
  3191 
  3205 
  3556 ! !
  3570 ! !
  3557 
  3571 
  3558 !SelectionInListView class methodsFor:'documentation'!
  3572 !SelectionInListView class methodsFor:'documentation'!
  3559 
  3573 
  3560 version
  3574 version
  3561     ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.132 1998-08-07 18:00:51 cg Exp $'
  3575     ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.133 1998-08-08 11:33:52 cg Exp $'
  3562 ! !
  3576 ! !