SelectionInListModelView.st
changeset 4571 bf04b7618d7c
parent 4570 4da74a5c2f14
child 4574 4ccc6b5caf8c
equal deleted inserted replaced
4570:4da74a5c2f14 4571:bf04b7618d7c
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libwidg2' }"
    12 "{ Package: 'stx:libwidg2' }"
    13 
    13 
    14 ListModelView subclass:#SelectionInListModelView
    14 ListModelView subclass:#SelectionInListModelView
    15 	instanceVariableNames:'selection multipleSelectOk selectOnButtonMenu actionBlock
    15 	instanceVariableNames:'selection multipleSelectOk actionBlock doubleClickActionBlock
    16 		doubleClickActionBlock selectConditionBlock buttonMotionAction
    16 		selectConditionBlock buttonMotionAction buttonReleaseAction
    17 		buttonReleaseAction highlightMode useIndex ignoreReselect
    17 		highlightMode useIndex ignoreReselect toggleSelect hilightFgColor
    18 		toggleSelect hilightFgColor hilightBgColor hilightFgColorNoFocus
    18 		hilightBgColor hilightFgColorNoFocus hilightBgColorNoFocus
    19 		hilightBgColorNoFocus hilightLevel hilightFrameColor hilightStyle
    19 		hilightLevel hilightFrameColor hilightStyle dropSource editorView
    20 		dropSource editorView openEditorAction closeEditorAction
    20 		openEditorAction closeEditorAction highlightEnterItem enterItem
    21 		highlightEnterItem enterItem cursorItem lineMask keyActionStyle
    21 		cursorItem lineMask keyActionStyle returnKeyActionStyle strikeOut
    22 		returnKeyActionStyle strikeOut modelChangedDuringButtonPress
    22 		modelChangedDuringButtonPress selectOnButtonPress
    23 		selectOnButtonPress selectOnMenuButton minimumEditorHeight
    23 		selectOnMenuButton minimumEditorHeight extraSpaceAtBottomForDrop'
    24 		extraSpaceAtBottomForDrop'
       
    25 	classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor
    24 	classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor
    26 		DefaultHilightForegroundColor DefaultHilightLevel
    25 		DefaultHilightForegroundColor DefaultHilightLevel
    27 		DefaultHilightFrameColor'
    26 		DefaultHilightFrameColor'
    28 	poolDictionaries:''
    27 	poolDictionaries:''
    29 	category:'Views-Lists'
    28 	category:'Views-Lists'
    76     but derives from the ListModelView and thus the list is kept
    75     but derives from the ListModelView and thus the list is kept
    77     in the list.
    76     in the list.
    78 
    77 
    79     [Instance variables:]
    78     [Instance variables:]
    80 
    79 
    81 	selection               <misc>       the current selection. nil, a number or collection of numbers
    80         selection               <misc>       the current selection. nil, a number or collection of numbers
    82 	multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
    81         multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
    83 	selectOnButtonMenu      <Boolean>    enable/disable selection will change on menu pressed
    82         selectMenuButton        <Boolean>    enable/disable selection will change on menu pressed
    84 
    83 
    85 	buttonReleaseAction     <Action>     called if the mouse button is released
    84         buttonReleaseAction     <Action>     called if the mouse button is released
    86 	buttonMotionAction      <Action>     called during mouse motion with one argument the point
    85         buttonMotionAction      <Action>     called during mouse motion with one argument the point
    87 					     under the mouse.
    86                                              under the mouse.
    88 
    87 
    89 	actionBlock             <Block>      action evaluated on single click (0/1/2 arguments)
    88         actionBlock             <Block>      action evaluated on single click (0/1/2 arguments)
    90 	doubleClickActionBlock  <Block>      action evaluated on double click (0/1/2 arguments)
    89         doubleClickActionBlock  <Block>      action evaluated on double click (0/1/2 arguments)
    91 	selectConditionBlock    <Block>      action evaluated before selection changed (0/1/2 arguments)
    90         selectConditionBlock    <Block>      action evaluated before selection changed (0/1/2 arguments)
    92 
    91 
    93 	keyActionStyle          <Symbol>     controls how to respond to keyboard selects
    92         keyActionStyle          <Symbol>     controls how to respond to keyboard selects
    94 	returnKeyActionStyle    <Symbol>     controls how to respond to return key
    93         returnKeyActionStyle    <Symbol>     controls how to respond to return key
    95 
    94 
    96 	useIndex                <Boolean>    representation of the model selection
    95         useIndex                <Boolean>    representation of the model selection
    97 
    96 
    98 	ignoreReselect          <Boolean>    if set, a click on an already selected entry is ignored
    97         ignoreReselect          <Boolean>    if set, a click on an already selected entry is ignored
    99 	toggleSelect            <Boolean>    a click on an entry unselects it and vice versa
    98         toggleSelect            <Boolean>    a click on an entry unselects it and vice versa
   100 
    99 
   101 	highlightMode           <Symbol>     how to draw the selection
   100         highlightMode           <Symbol>     how to draw the selection
   102 	hilightFgColor          <Color>      foregroundColor of highlighted items
   101         hilightFgColor          <Color>      foregroundColor of highlighted items
   103 	hilightBgColor          <Color>      backgroundColor of highlighted items
   102         hilightBgColor          <Color>      backgroundColor of highlighted items
   104 	hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
   103         hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
   105 	hilightFrameColor       <Color>      rectangle around highlighted items
   104         hilightFrameColor       <Color>      rectangle around highlighted items
   106 	hilightStyle            <Boolean>    actions on widget are enabled/disabled
   105         hilightStyle            <Boolean>    actions on widget are enabled/disabled
   107 	strikeOut               <Boolean>    turn on/off strikeOut mode
   106         strikeOut               <Boolean>    turn on/off strikeOut mode
   108 
   107 
   109 	dropTarget              <DropTarget> keeps information about the drop operation
   108         dropTarget              <DropTarget> keeps information about the drop operation
   110 	dropSource              <DropSource> keeps information about the drag operation
   109         dropSource              <DropSource> keeps information about the drag operation
   111 
   110 
   112 	editorView              <View>       editor on current selected item
   111         editorView              <View>       editor on current selected item
   113 	openEditorAction        <Action>     action to get an editor on the current selection from user
   112         openEditorAction        <Action>     action to get an editor on the current selection from user
   114 	closeEditorAction       <Action>     action invoked before the editor is closed.
   113         closeEditorAction       <Action>     action invoked before the editor is closed.
   115 
   114 
   116 	enterItem               <Item/nil>   item over which the mouse pointer is located
   115         enterItem               <Item/nil>   item over which the mouse pointer is located
   117 					     or nil
   116                                              or nil
   118 	highlightEnterItem      <Boolean>    enable or disable highlight of enterItem
   117         highlightEnterItem      <Boolean>    enable or disable highlight of enterItem
   119 
   118 
   120     [author:]
   119     [author:]
   121 	Claus Atzkern
   120         Claus Atzkern
   122 
   121 
   123     [see also:]
   122     [see also:]
   124 
   123 
   125 	ListModelView
   124         ListModelView
   126 	HierarchicalListView
   125         HierarchicalListView
   127 "
   126 "
   128 !
   127 !
   129 
   128 
   130 examples
   129 examples
   131 "
   130 "
   512 	self selection:nil
   511 	self selection:nil
   513     ].
   512     ].
   514     multipleSelectOk := false.
   513     multipleSelectOk := false.
   515 !
   514 !
   516 
   515 
   517 selectOnButtomMenu
       
   518     <resource: #obsolete>
       
   519     self obsoleteMethodWarning:'use selectOnButtonMenu'.
       
   520     ^ self selectOnButtonMenu
       
   521 !
       
   522 
       
   523 selectOnButtomMenu:aBoolean
       
   524     <resource: #obsolete>
       
   525     self obsoleteMethodWarning:'use selectOnButtonMenu:'.
       
   526     ^ self selectOnButtonMenu:aBoolean
       
   527 !
       
   528 
       
   529 selectOnButtonMenu
   516 selectOnButtonMenu
   530     <resource: #obsolete>
   517     <resource: #obsolete>
   531     "define the button-menu-press behavior; if true the line under the mouse
       
   532      will be selected before the menu is opened. Otherwise the menu is opened
       
   533      on the current selection."
       
   534 
       
   535     self obsoleteMethodWarning:'use selectOnMenuButton'.
   518     self obsoleteMethodWarning:'use selectOnMenuButton'.
   536     ^ self selectOnMenuButton
   519     ^ self selectOnMenuButton
   537 !
   520 !
   538 
   521 
   539 selectOnButtonMenu:aBoolean
   522 selectOnButtonMenu:aBoolean
   540     <resource: #obsolete>
   523     <resource: #obsolete>
   541     "define the button-menu-press behavior; if true the line under the mouse
       
   542      will be selected before the menu is opened. Otherwise the menu is opened
       
   543      on the current selection."
       
   544 
       
   545     self obsoleteMethodWarning:'use selectOnMenuButton:'.
   524     self obsoleteMethodWarning:'use selectOnMenuButton:'.
   546     self selectOnMenuButton:aBoolean.
   525     self selectOnMenuButton:aBoolean.
   547 !
   526 !
   548 
   527 
   549 selectOnButtonPress
   528 selectOnButtonPress
  1335 !
  1314 !
  1336 
  1315 
  1337 buttonMultiPress:button x:x y:y
  1316 buttonMultiPress:button x:x y:y
  1338     "button was pressed multiple - handle a doubleClick action"
  1317     "button was pressed multiple - handle a doubleClick action"
  1339 
  1318 
  1340     |lnNr item|
  1319     |lnNr|
  1341 
  1320 
  1342     buttonMotionAction := buttonReleaseAction := nil.
  1321     buttonMotionAction := buttonReleaseAction := nil.
  1343 
  1322 
  1344     enabled ifFalse:[^ self].
  1323     enabled ifFalse:[^ self].
  1345 
  1324 
  1346     (button == 1) ifTrue:[
  1325     (button == 1) ifTrue:[
  1347         (     (lnNr := self yVisibleToLineNr:y)   notNil
  1326         (     (lnNr := self yVisibleToLineNr:y)   notNil
  1348          and:[(item := self at:lnNr ifAbsent:nil) notNil]
  1327          and:[(self at:lnNr ifAbsent:nil) notNil]
  1349         ) ifTrue:[
  1328         ) ifTrue:[
  1350             self selectedIndex == lnNr ifFalse:[
  1329             self selectedIndex == lnNr ifFalse:[
  1351                 self breakPoint:#ca
  1330                 self breakPoint:#ca
  1352             ].
  1331             ].
  1353             self doubleClicked.
  1332             self doubleClicked.
  1920         ]
  1899         ]
  1921     ].
  1900     ].
  1922 !
  1901 !
  1923 
  1902 
  1924 pointerEntersItem:anItemOrNil
  1903 pointerEntersItem:anItemOrNil
  1925     "the pointer moves over an item or nil
  1904     "the pointer moves over an item or nil"
  1926     "
       
  1927     |newItem|
       
  1928 
  1905 
  1929     (shown and:[self size ~~ 0]) ifFalse:[
  1906     (shown and:[self size ~~ 0]) ifFalse:[
  1930 	enterItem := nil.
  1907         enterItem := nil.
  1931 	^ self.
  1908         ^ self.
  1932     ].
  1909     ].
  1933 
       
  1934     highlightEnterItem ifTrue:[ newItem := anItemOrNil ]
       
  1935 		      ifFalse:[ newItem := nil ].
       
  1936 
  1910 
  1937     anItemOrNil == enterItem ifTrue:[ ^ self ].
  1911     anItemOrNil == enterItem ifTrue:[ ^ self ].
  1938 
  1912 
  1939     enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
  1913     enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
  1940     enterItem := anItemOrNil.
  1914     enterItem := anItemOrNil.
  2695 ! !
  2669 ! !
  2696 
  2670 
  2697 !SelectionInListModelView class methodsFor:'documentation'!
  2671 !SelectionInListModelView class methodsFor:'documentation'!
  2698 
  2672 
  2699 version
  2673 version
  2700     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.167 2014-04-13 20:25:30 stefan Exp $'
  2674     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.168 2014-04-13 21:00:15 stefan Exp $'
  2701 !
  2675 !
  2702 
  2676 
  2703 version_CVS
  2677 version_CVS
  2704     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.167 2014-04-13 20:25:30 stefan Exp $'
  2678     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.168 2014-04-13 21:00:15 stefan Exp $'
  2705 ! !
  2679 ! !
  2706 
  2680