SelectionInListModelView.st
changeset 3728 8858b3571313
parent 3704 c9b2102bfd1c
child 3740 67a77c2fcb03
equal deleted inserted replaced
3727:03a3787770ed 3728:8858b3571313
     1 "
     1 "
     2  COPYRIGHT (c) 1999 by eXept Software AG
     2  COPYRIGHT (c) 1999 by eXept Software AG
     3               All Rights Reserved
     3 	      All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     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
    40 
    40 
    41     1 to:100 do:[:i| list add:('element: ', i printString) ].
    41     1 to:100 do:[:i| list add:('element: ', i printString) ].
    42 
    42 
    43     top  := StandardSystemView new; extent:300@300.
    43     top  := StandardSystemView new; extent:300@300.
    44     view := ScrollableView for:SelectionInListModelView miniScroller:true
    44     view := ScrollableView for:SelectionInListModelView miniScroller:true
    45                         origin:0.0@0.0 corner:1.0@1.0 in:top.
    45 			origin:0.0@0.0 corner:1.0@1.0 in:top.
    46 
    46 
    47     view minimumEditorHeight:100.
    47     view minimumEditorHeight:100.
    48     view openEditorAction:[:ln :aGC| |f|
    48     view openEditorAction:[:ln :aGC| |f|
    49         f := SimpleView in:aGC.
    49 	f := SimpleView in:aGC.
    50         f viewBackground:(Color red).
    50 	f viewBackground:(Color red).
    51         f
    51 	f
    52     ].
    52     ].
    53     view list:list.
    53     view list:list.
    54     top  open.
    54     top  open.
    55 !
    55 !
    56 
    56 
    57 copyright
    57 copyright
    58 "
    58 "
    59  COPYRIGHT (c) 1999 by eXept Software AG
    59  COPYRIGHT (c) 1999 by eXept Software AG
    60               All Rights Reserved
    60 	      All Rights Reserved
    61 
    61 
    62  This software is furnished under a license and may be used
    62  This software is furnished under a license and may be used
    63  only in accordance with the terms of that license and with the
    63  only in accordance with the terms of that license and with the
    64  inclusion of the above copyright notice.   This software may not
    64  inclusion of the above copyright notice.   This software may not
    65  be provided or otherwise made available to, or used by, any
    65  be provided or otherwise made available to, or used by, any
    75     but derives from the ListModelView and thus the list is kept
    75     but derives from the ListModelView and thus the list is kept
    76     in the list.
    76     in the list.
    77 
    77 
    78     [Instance variables:]
    78     [Instance variables:]
    79 
    79 
    80         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
    81         multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
    81 	multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
    82         selectOnButtonMenu      <Boolean>    enable/disable selection will change on menu pressed
    82 	selectOnButtonMenu      <Boolean>    enable/disable selection will change on menu pressed
    83 
    83 
    84         buttonReleaseAction     <Action>     called if the mouse button is released
    84 	buttonReleaseAction     <Action>     called if the mouse button is released
    85         buttonMotionAction      <Action>     called during mouse motion with one argument the point
    85 	buttonMotionAction      <Action>     called during mouse motion with one argument the point
    86                                              under the mouse.
    86 					     under the mouse.
    87 
    87 
    88         actionBlock             <Block>      action evaluated on single click (0/1/2 arguments)
    88 	actionBlock             <Block>      action evaluated on single click (0/1/2 arguments)
    89         doubleClickActionBlock  <Block>      action evaluated on double click (0/1/2 arguments)
    89 	doubleClickActionBlock  <Block>      action evaluated on double click (0/1/2 arguments)
    90         selectConditionBlock    <Block>      action evaluated before selection changed (0/1/2 arguments)
    90 	selectConditionBlock    <Block>      action evaluated before selection changed (0/1/2 arguments)
    91 
    91 
    92         keyActionStyle          <Symbol>     controls how to respond to keyboard selects
    92 	keyActionStyle          <Symbol>     controls how to respond to keyboard selects
    93         returnKeyActionStyle    <Symbol>     controls how to respond to return key
    93 	returnKeyActionStyle    <Symbol>     controls how to respond to return key
    94 
    94 
    95         useIndex                <Boolean>    representation of the model selection
    95 	useIndex                <Boolean>    representation of the model selection
    96 
    96 
    97         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
    98         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
    99 
    99 
   100         highlightMode           <Symbol>     how to draw the selection
   100 	highlightMode           <Symbol>     how to draw the selection
   101         hilightFgColor          <Color>      foregroundColor of highlighted items       
   101 	hilightFgColor          <Color>      foregroundColor of highlighted items
   102         hilightBgColor          <Color>      backgroundColor of highlighted items
   102 	hilightBgColor          <Color>      backgroundColor of highlighted items
   103         hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
   103 	hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
   104         hilightFrameColor       <Color>      rectangle around highlighted items
   104 	hilightFrameColor       <Color>      rectangle around highlighted items
   105         hilightStyle            <Boolean>    actions on widget are enabled/disabled
   105 	hilightStyle            <Boolean>    actions on widget are enabled/disabled
   106         strikeOut               <Boolean>    turn on/off strikeOut mode
   106 	strikeOut               <Boolean>    turn on/off strikeOut mode
   107 
   107 
   108         dropTarget              <DropTarget> keeps information about the drop operation
   108 	dropTarget              <DropTarget> keeps information about the drop operation
   109         dropSource              <DropSource> keeps information about the drag operation
   109 	dropSource              <DropSource> keeps information about the drag operation
   110 
   110 
   111         editorView              <View>       editor on current selected item
   111 	editorView              <View>       editor on current selected item
   112         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
   113         closeEditorAction       <Action>     action invoked before the editor is closed.
   113 	closeEditorAction       <Action>     action invoked before the editor is closed.
   114 
   114 
   115         enterItem               <Item/nil>   item over which the mouse pointer is located
   115 	enterItem               <Item/nil>   item over which the mouse pointer is located
   116                                              or nil
   116 					     or nil
   117         highlightEnterItem      <Boolean>    enable or disable highlight of enterItem
   117 	highlightEnterItem      <Boolean>    enable or disable highlight of enterItem
   118 
   118 
   119     [author:]
   119     [author:]
   120         Claus Atzkern
   120 	Claus Atzkern
   121 
   121 
   122     [see also:]
   122     [see also:]
   123 
   123 
   124         ListModelView
   124 	ListModelView
   125         HierarchicalListView
   125 	HierarchicalListView
   126 "
   126 "
   127 !
   127 !
   128 
   128 
   129 examples
   129 examples
   130 "
   130 "
   131                                                                         [exBegin]
   131 									[exBegin]
   132     |top list view|
   132     |top list view|
   133 
   133 
   134     list := List new.
   134     list := List new.
   135 
   135 
   136     1 to:100 do:[:i| list add:('element: ', i printString) ].
   136     1 to:100 do:[:i| list add:('element: ', i printString) ].
   137     top  := StandardSystemView new; extent:300@300.
   137     top  := StandardSystemView new; extent:300@300.
   138     view := ScrollableView for:SelectionInListModelView miniScroller:true
   138     view := ScrollableView for:SelectionInListModelView miniScroller:true
   139                         origin:0.0@0.0 corner:1.0@1.0 in:top.
   139 			origin:0.0@0.0 corner:1.0@1.0 in:top.
   140     view list:list.
   140     view list:list.
   141     top  open.
   141     top  open.
   142                                                                         [exEnd]
   142 									[exEnd]
   143 
   143 
   144 
   144 
   145                                                                         [exBegin]
   145 									[exBegin]
   146     |top list view|
   146     |top list view|
   147 
   147 
   148     list := List new.
   148     list := List new.
   149 
   149 
   150     1 to:100 do:[:i| list add:('element: ', i printString) ].
   150     1 to:100 do:[:i| list add:('element: ', i printString) ].
   151     top  := StandardSystemView new; extent:300@300.
   151     top  := StandardSystemView new; extent:300@300.
   152     view := ScrollableView for:SelectionInListModelView miniScroller:true
   152     view := ScrollableView for:SelectionInListModelView miniScroller:true
   153                         origin:0.0@0.0 corner:1.0@1.0 in:top.
   153 			origin:0.0@0.0 corner:1.0@1.0 in:top.
   154     view list:list.
   154     view list:list.
   155 
   155 
   156     view openEditorAction:[:ln :aGC| |field|
   156     view openEditorAction:[:ln :aGC| |field|
   157         field := EditField new.
   157 	field := EditField new.
   158         field level:0.
   158 	field level:0.
   159         field acceptOnLostFocus:true.
   159 	field acceptOnLostFocus:true.
   160         field acceptAction:[:x| list at:ln put:(field contents) ].
   160 	field acceptAction:[:x| list at:ln put:(field contents) ].
   161         field font:(aGC font).
   161 	field font:(aGC font).
   162         field contents:(list at:ln).
   162 	field contents:(list at:ln).
   163         field
   163 	field
   164     ].
   164     ].
   165     top open.
   165     top open.
   166                                                                         [exEnd]
   166 									[exEnd]
   167 
   167 
   168                                                                         [exBegin]
   168 									[exBegin]
   169     |top list view item|
   169     |top list view item|
   170 
   170 
   171     list := HierarchicalList new.
   171     list := HierarchicalList new.
   172     item := HierarchicalItem::Example labeled:'Test'.
   172     item := HierarchicalItem::Example labeled:'Test'.
   173     item expand.
   173     item expand.
   174     list showRoot:false.
   174     list showRoot:false.
   175     list root:item.
   175     list root:item.
   176 
   176 
   177     top  := StandardSystemView new; extent:300@300.
   177     top  := StandardSystemView new; extent:300@300.
   178     view := ScrollableView for:SelectionInListModelView miniScroller:true
   178     view := ScrollableView for:SelectionInListModelView miniScroller:true
   179                         origin:0.0@0.0 corner:1.0@1.0 in:top.
   179 			origin:0.0@0.0 corner:1.0@1.0 in:top.
   180 
   180 
   181     view list:list.
   181     view list:list.
   182     view doubleClickAction:[:i| (list at:i) toggleExpand ].
   182     view doubleClickAction:[:i| (list at:i) toggleExpand ].
   183     top  open.
   183     top  open.
   184                                                                         [exEnd]
   184 									[exEnd]
   185 
   185 
   186 "
   186 "
   187 ! !
   187 ! !
   188 
   188 
   189 !SelectionInListModelView class methodsFor:'defaults'!
   189 !SelectionInListModelView class methodsFor:'defaults'!
   190 
   190 
   191 updateStyleCache
   191 updateStyleCache
   192     "extract values from the styleSheet and cache them in class variables"
   192     "extract values from the styleSheet and cache them in class variables"
   193 
   193 
   194     <resource: #style   (
   194     <resource: #style   (
   195                         #'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
   195 			#'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
   196                         #'selection.hilightFrameColor'      #'selection.hilightLevel'
   196 			#'selection.hilightFrameColor'      #'selection.hilightLevel'
   197                         #'selection.foregroundColor'        #'selection.backgroundColor'
   197 			#'selection.foregroundColor'        #'selection.backgroundColor'
   198                         #'selection.shadowColor'            #'selection.lightColor'
   198 			#'selection.shadowColor'            #'selection.lightColor'
   199                         #'selection.font'                   #'selection.hilightStyle'
   199 			#'selection.font'                   #'selection.hilightStyle'
   200                         #'text.foregroundColor'
   200 			#'text.foregroundColor'
   201                         )>
   201 			)>
   202 
   202 
   203     DefaultHilightForegroundColor  := StyleSheet colorAt:'selection.hilightForegroundColor'.
   203     DefaultHilightForegroundColor  := StyleSheet colorAt:'selection.hilightForegroundColor'.
   204     DefaultHilightBackgroundColor  := StyleSheet colorAt:'selection.hilightBackgroundColor'.
   204     DefaultHilightBackgroundColor  := StyleSheet colorAt:'selection.hilightBackgroundColor'.
   205     DefaultHilightFrameColor       := StyleSheet colorAt:'selection.hilightFrameColor'.
   205     DefaultHilightFrameColor       := StyleSheet colorAt:'selection.hilightFrameColor'.
   206     DefaultHilightLevel            := StyleSheet at:'selection.hilightLevel' default:0.
   206     DefaultHilightLevel            := StyleSheet at:'selection.hilightLevel' default:0.
   209     DefaultBackgroundColor         := StyleSheet colorAt:'selection.backgroundColor'.
   209     DefaultBackgroundColor         := StyleSheet colorAt:'selection.backgroundColor'.
   210     DefaultShadowColor             := StyleSheet colorAt:'selection.shadowColor'.
   210     DefaultShadowColor             := StyleSheet colorAt:'selection.shadowColor'.
   211     DefaultLightColor              := StyleSheet colorAt:'selection.lightColor'.
   211     DefaultLightColor              := StyleSheet colorAt:'selection.lightColor'.
   212 
   212 
   213     DefaultForegroundColor isNil ifTrue:[
   213     DefaultForegroundColor isNil ifTrue:[
   214         DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black
   214 	DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black
   215     ].
   215     ].
   216     "
   216     "
   217      self updateStyleCache
   217      self updateStyleCache
   218     "
   218     "
   219 
   219 
   243 
   243 
   244 action
   244 action
   245     "get the action block to be performed on select
   245     "get the action block to be performed on select
   246 
   246 
   247      The arguments to the block are:
   247      The arguments to the block are:
   248         - no argument
   248 	- no argument
   249         -  1 argument     index or item
   249 	-  1 argument     index or item
   250         -  2 argument     index or item, self
   250 	-  2 argument     index or item, self
   251     "
   251     "
   252     ^ actionBlock
   252     ^ actionBlock
   253 !
   253 !
   254 
   254 
   255 action:aOneArgAction
   255 action:aOneArgAction
   256     "set the action block to be performed on select
   256     "set the action block to be performed on select
   257 
   257 
   258      The arguments to the block are:
   258      The arguments to the block are:
   259         - no argument
   259 	- no argument
   260         -  1 argument     index or item
   260 	-  1 argument     index or item
   261         -  2 argument     index or item, self
   261 	-  2 argument     index or item, self
   262     "
   262     "
   263     actionBlock := aOneArgAction
   263     actionBlock := aOneArgAction
   264 !
   264 !
   265 
   265 
   266 doubleClickAction
   266 doubleClickAction
   267     "get the action block to be performed on doubleclick.
   267     "get the action block to be performed on doubleclick.
   268 
   268 
   269      The arguments to the block are:
   269      The arguments to the block are:
   270         - no argument
   270 	- no argument
   271         -  1 argument     selectedIndex
   271 	-  1 argument     selectedIndex
   272         -  2 argument     selectedIndex, self
   272 	-  2 argument     selectedIndex, self
   273     "
   273     "
   274     ^ doubleClickActionBlock
   274     ^ doubleClickActionBlock
   275 !
   275 !
   276 
   276 
   277 doubleClickAction:aOneArgAction
   277 doubleClickAction:aOneArgAction
   278     "set the action block to be performed on doubleclick.
   278     "set the action block to be performed on doubleclick.
   279 
   279 
   280      The arguments to the block are:
   280      The arguments to the block are:
   281         - no argument
   281 	- no argument
   282         -  1 argument     selectedIndex
   282 	-  1 argument     selectedIndex
   283         -  2 argument     selectedIndex, self
   283 	-  2 argument     selectedIndex, self
   284     "
   284     "
   285     doubleClickActionBlock := aOneArgAction
   285     doubleClickActionBlock := aOneArgAction
   286 !
   286 !
   287 
   287 
   288 keyActionStyle
   288 keyActionStyle
   289     "defines how the view should respond to alpha-keys pressed.
   289     "defines how the view should respond to alpha-keys pressed.
   290      Possible values are:
   290      Possible values are:
   291         #select               -> will select next entry starting with that
   291 	#select               -> will select next entry starting with that
   292                                  character and perform the click-action
   292 				 character and perform the click-action
   293 
   293 
   294         #selectAndDoubleclick -> will select next & perform double-click action
   294 	#selectAndDoubleclick -> will select next & perform double-click action
   295 
   295 
   296         #pass                 -> will pass key to superclass (i.e. no special treatment)
   296 	#pass                 -> will pass key to superclass (i.e. no special treatment)
   297 
   297 
   298         nil                   -> will ignore key
   298 	nil                   -> will ignore key
   299 
   299 
   300      the default (set in #initialize) is #select
   300      the default (set in #initialize) is #select
   301     "
   301     "
   302     ^ keyActionStyle
   302     ^ keyActionStyle
   303 !
   303 !
   304 
   304 
   305 keyActionStyle:aSymbol
   305 keyActionStyle:aSymbol
   306     "defines how the view should respond to alpha-keys pressed.
   306     "defines how the view should respond to alpha-keys pressed.
   307      Possible values are:
   307      Possible values are:
   308         #select               -> will select next entry starting with that
   308 	#select               -> will select next entry starting with that
   309                                  character and perform the click-action
   309 				 character and perform the click-action
   310 
   310 
   311         #selectAndDoubleclick -> will select next & perform double-click action
   311 	#selectAndDoubleclick -> will select next & perform double-click action
   312 
   312 
   313         #pass                 -> will pass key to superclass (i.e. no special treatment)
   313 	#pass                 -> will pass key to superclass (i.e. no special treatment)
   314 
   314 
   315         nil                   -> will ignore key
   315 	nil                   -> will ignore key
   316 
   316 
   317      the default (set in #initialize) is #select
   317      the default (set in #initialize) is #select
   318     "
   318     "
   319     keyActionStyle := aSymbol
   319     keyActionStyle := aSymbol
   320 !
   320 !
   321 
   321 
   322 returnKeyActionStyle
   322 returnKeyActionStyle
   323     "defines how the view should respond to a return key pressed.
   323     "defines how the view should respond to a return key pressed.
   324      Possible values are:
   324      Possible values are:
   325         #doubleClick          -> perform double-click action
   325 	#doubleClick          -> perform double-click action
   326 
   326 
   327         #pass                 -> will pass key to superclass (i.e. no special treatment)
   327 	#pass                 -> will pass key to superclass (i.e. no special treatment)
   328 
   328 
   329         nil                   -> will ignore key
   329 	nil                   -> will ignore key
   330 
   330 
   331      the default (set in #initialize) is #doubleClick 
   331      the default (set in #initialize) is #doubleClick
   332     "
   332     "
   333     ^ returnKeyActionStyle
   333     ^ returnKeyActionStyle
   334 !
   334 !
   335 
   335 
   336 returnKeyActionStyle:aSymbol
   336 returnKeyActionStyle:aSymbol
   337     "defines how the view should respond to a return key pressed.
   337     "defines how the view should respond to a return key pressed.
   338      Possible values are:
   338      Possible values are:
   339         #doubleClick          -> perform double-click action
   339 	#doubleClick          -> perform double-click action
   340 
   340 
   341         #pass                 -> will pass key to superclass (i.e. no special treatment)
   341 	#pass                 -> will pass key to superclass (i.e. no special treatment)
   342 
   342 
   343         nil                   -> will ignore key
   343 	nil                   -> will ignore key
   344 
   344 
   345      the default (set in #initialize) is #doubleClick 
   345      the default (set in #initialize) is #doubleClick
   346     "
   346     "
   347     returnKeyActionStyle := aSymbol
   347     returnKeyActionStyle := aSymbol
   348 !
   348 !
   349 
   349 
   350 selectConditionBlock
   350 selectConditionBlock
   351     "set the conditionBlock; this block is evaluated before a selection
   351     "set the conditionBlock; this block is evaluated before a selection
   352      change is performed; the change will not be done, if the evaluation
   352      change is performed; the change will not be done, if the evaluation
   353      returns false
   353      returns false
   354 
   354 
   355      The arguments to the block are:
   355      The arguments to the block are:
   356         - no argument
   356 	- no argument
   357         -  1 argument     index
   357 	-  1 argument     index
   358         -  2 argument     index, isForAdd
   358 	-  2 argument     index, isForAdd
   359     "
   359     "
   360     ^ selectConditionBlock
   360     ^ selectConditionBlock
   361 !
   361 !
   362 
   362 
   363 selectConditionBlock:aOneArgBlock
   363 selectConditionBlock:aOneArgBlock
   364     "set the conditionBlock; this block is evaluated before a selection
   364     "set the conditionBlock; this block is evaluated before a selection
   365      change is performed; the change will not be done, if the evaluation
   365      change is performed; the change will not be done, if the evaluation
   366      returns false.
   366      returns false.
   367 
   367 
   368      The arguments to the block are:
   368      The arguments to the block are:
   369         - no argument
   369 	- no argument
   370         -  1 argument     index
   370 	-  1 argument     index
   371         -  2 argument     index, isForAdd
   371 	-  2 argument     index, isForAdd
   372     "
   372     "
   373     selectConditionBlock := aOneArgBlock.
   373     selectConditionBlock := aOneArgBlock.
   374 ! !
   374 ! !
   375 
   375 
   376 !SelectionInListModelView methodsFor:'accessing-attributes'!
   376 !SelectionInListModelView methodsFor:'accessing-attributes'!
   383 
   383 
   384 highlightEnterItem:aBool
   384 highlightEnterItem:aBool
   385     "enable or disable to highlight the item over which the mouse pointer is located
   385     "enable or disable to highlight the item over which the mouse pointer is located
   386     "
   386     "
   387     highlightEnterItem ~~ aBool ifTrue:[
   387     highlightEnterItem ~~ aBool ifTrue:[
   388         highlightEnterItem := aBool.
   388 	highlightEnterItem := aBool.
   389         self pointerEntersItem:nil.
   389 	self pointerEntersItem:nil.
   390 
   390 
   391         highlightEnterItem ifTrue:[
   391 	highlightEnterItem ifTrue:[
   392             self enableMotionEvents
   392 	    self enableMotionEvents
   393         ].
   393 	].
   394     ].
   394     ].
   395 !
   395 !
   396 
   396 
   397 highlightMode
   397 highlightMode
   398     "get the mode how to draw a selected line:
   398     "get the mode how to draw a selected line:
   399         #line           draw whole line selected
   399 	#line           draw whole line selected
   400         #label          draw label selected
   400 	#label          draw label selected
   401         #dropMode       set during drop
   401 	#dropMode       set during drop
   402     "
   402     "
   403     ^ highlightMode
   403     ^ highlightMode
   404 !
   404 !
   405 
   405 
   406 highlightMode:aMode
   406 highlightMode:aMode
   407     "set the mode how to draw a selected line:
   407     "set the mode how to draw a selected line:
   408         #line           draw whole line selected
   408 	#line           draw whole line selected
   409         #label          draw label selected
   409 	#label          draw label selected
   410         #dropMode       set during drop
   410 	#dropMode       set during drop
   411     "
   411     "
   412     highlightMode ~~ aMode ifTrue:[
   412     highlightMode ~~ aMode ifTrue:[
   413         highlightMode := aMode.
   413 	highlightMode := aMode.
   414         self invalidateSelection.
   414 	self invalidateSelection.
   415     ].
   415     ].
   416 !
   416 !
   417 
   417 
   418 highlightWithUnderline
   418 highlightWithUnderline
   419     ^ false
   419     ^ false
   439 
   439 
   440 strikeout:aBoolean
   440 strikeout:aBoolean
   441     "turn on/off strikeOut mode
   441     "turn on/off strikeOut mode
   442     "
   442     "
   443     strikeOut ~~ aBoolean ifTrue:[
   443     strikeOut ~~ aBoolean ifTrue:[
   444         strikeOut := aBoolean.
   444 	strikeOut := aBoolean.
   445         self invalidateSelection.
   445 	self invalidateSelection.
   446     ].
   446     ].
   447 ! !
   447 ! !
   448 
   448 
   449 !SelectionInListModelView methodsFor:'accessing-behavior'!
   449 !SelectionInListModelView methodsFor:'accessing-behavior'!
   450 
   450 
   453     "
   453     "
   454     ^ ignoreReselect
   454     ^ ignoreReselect
   455 !
   455 !
   456 
   456 
   457 ignoreReselect:aBoolean
   457 ignoreReselect:aBoolean
   458     "set/clear the ignoreReselect flag - 
   458     "set/clear the ignoreReselect flag -
   459      if set, a click on an already selected entry is ignored.
   459      if set, a click on an already selected entry is ignored.
   460      Otherwise the notification is done, even if no
   460      Otherwise the notification is done, even if no
   461      change in the selection occurs.
   461      change in the selection occurs.
   462      (for example, in browser to update a method).
   462      (for example, in browser to update a method).
   463      Setting ignoreReselect to false makes sense if data is shown
   463      Setting ignoreReselect to false makes sense if data is shown
   490     state := aState ? false.
   490     state := aState ? false.
   491 
   491 
   492     multipleSelectOk == state ifTrue:[ ^ self ].
   492     multipleSelectOk == state ifTrue:[ ^ self ].
   493 
   493 
   494     selection isNil ifTrue:[
   494     selection isNil ifTrue:[
   495         multipleSelectOk := state.
   495 	multipleSelectOk := state.
   496         ^ self.
   496 	^ self.
   497     ].
   497     ].
   498 
   498 
   499     multipleSelectOk ifFalse:[
   499     multipleSelectOk ifFalse:[
   500         selection := Array with:selection.
   500 	selection := Array with:selection.
   501         multipleSelectOk := true.
   501 	multipleSelectOk := true.
   502         ^ self
   502 	^ self
   503     ].
   503     ].
   504 
   504 
   505     selection size == 1 ifTrue:[
   505     selection size == 1 ifTrue:[
   506         selection := selection first.
   506 	selection := selection first.
   507     ] ifFalse:[
   507     ] ifFalse:[
   508         self selection:nil
   508 	self selection:nil
   509     ].
   509     ].
   510     multipleSelectOk := false.
   510     multipleSelectOk := false.
   511 !
   511 !
   512 
   512 
   513 selectOnButtomMenu
   513 selectOnButtomMenu
   547     "
   547     "
   548     ^ selectOnButtonPress ? true
   548     ^ selectOnButtonPress ? true
   549 !
   549 !
   550 
   550 
   551 selectOnButtonPress:aBoolean
   551 selectOnButtonPress:aBoolean
   552     "set/clear the selectOnButtonPress flag - 
   552     "set/clear the selectOnButtonPress flag -
   553      if set (default), the selection changed on button press. This was the
   553      if set (default), the selection changed on button press. This was the
   554      behaviour until now.
   554      behaviour until now.
   555      if cleared, the selection is changed on button release. This new behaviour allows to start
   555      if cleared, the selection is changed on button release. This new behaviour allows to start
   556      a drag without changing the real selection. The selection is changed during the
   556      a drag without changing the real selection. The selection is changed during the
   557      drag and restored after the drop.
   557      drag and restored after the drop.
   563     "define the button-menu-press behavior; if true the line under the mouse
   563     "define the button-menu-press behavior; if true the line under the mouse
   564      will be selected before the menu is opened. Otherwise the menu is opened
   564      will be selected before the menu is opened. Otherwise the menu is opened
   565      on the current selection."
   565      on the current selection."
   566 
   566 
   567     selectOnMenuButton isNil ifTrue:[
   567     selectOnMenuButton isNil ifTrue:[
   568         ^ UserPreferences current selectOnRightClick
   568 	^ UserPreferences current selectOnRightClick
   569     ].
   569     ].
   570     ^ selectOnMenuButton
   570     ^ selectOnMenuButton
   571 !
   571 !
   572 
   572 
   573 selectOnMenuButton:aBoolean
   573 selectOnMenuButton:aBoolean
   622     "
   622     "
   623     |editor action|
   623     |editor action|
   624 
   624 
   625     (editor := editorView) notNil ifTrue:[
   625     (editor := editorView) notNil ifTrue:[
   626 "/        editorView := nil.
   626 "/        editorView := nil.
   627         action := self closeEditorAction.
   627 	action := self closeEditorAction.
   628         action notNil ifTrue:[action value:editor.].
   628 	action notNil ifTrue:[action value:editor.].
   629         editor destroy.
   629 	editor destroy.
   630         editorView := nil.
   630 	editorView := nil.
   631     ].
   631     ].
   632 !
   632 !
   633 
   633 
   634 closeEditorAction
   634 closeEditorAction
   635     "get the block which is evaluated before the editor is closed; the argument
   635     "get the block which is evaluated before the editor is closed; the argument
   684 
   684 
   685     editorView := action valueWithOptionalArgument:lnNr and:self.
   685     editorView := action valueWithOptionalArgument:lnNr and:self.
   686     editorView isNil ifTrue:[^ nil].
   686     editorView isNil ifTrue:[^ nil].
   687 
   687 
   688     editorView superView isNil ifTrue:[
   688     editorView superView isNil ifTrue:[
   689         self addSubView:editorView
   689 	self addSubView:editorView
   690     ].
   690     ].
   691     self computeEditorLayout.
   691     self computeEditorLayout.
   692     editorView realize.
   692     editorView realize.
   693     self windowGroup focusView:editorView.
   693     self windowGroup focusView:editorView.
   694     ^ editorView
   694     ^ editorView
   732 
   732 
   733 lineChangedAt:aLnNr with:arg
   733 lineChangedAt:aLnNr with:arg
   734     super lineChangedAt:aLnNr with:arg.
   734     super lineChangedAt:aLnNr with:arg.
   735 
   735 
   736     (editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[
   736     (editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[
   737         self computeEditorLayout.
   737 	self computeEditorLayout.
   738     ]
   738     ]
   739 !
   739 !
   740 
   740 
   741 listSizeChanged:aLnNr nLines:aDeltaLines
   741 listSizeChanged:aLnNr nLines:aDeltaLines
   742     |changed cnts|
   742     |changed cnts|
   744     super listSizeChanged:aLnNr nLines:aDeltaLines.
   744     super listSizeChanged:aLnNr nLines:aDeltaLines.
   745 
   745 
   746     selection isNil ifTrue:[^ self].
   746     selection isNil ifTrue:[^ self].
   747 
   747 
   748     self size == 0 ifTrue:[
   748     self size == 0 ifTrue:[
   749         selection := nil.
   749 	selection := nil.
   750         ^ self selectionChanged
   750 	^ self selectionChanged
   751     ].
   751     ].
   752 
   752 
   753     multipleSelectOk ifFalse:[
   753     multipleSelectOk ifFalse:[
   754         selection < aLnNr ifTrue:[^ self].
   754 	selection < aLnNr ifTrue:[^ self].
   755 
   755 
   756         selection := selection + aDeltaLines.
   756 	selection := selection + aDeltaLines.
   757 
   757 
   758         (aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
   758 	(aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
   759             selection := nil.
   759 	    selection := nil.
   760             ^ self selectionChanged
   760 	    ^ self selectionChanged
   761         ]
   761 	]
   762     ] ifTrue:[
   762     ] ifTrue:[
   763         changed := false.
   763 	changed := false.
   764 
   764 
   765         aDeltaLines < 0  ifFalse:[
   765 	aDeltaLines < 0  ifFalse:[
   766             selection keysAndValuesDo:[:i :ln|
   766 	    selection keysAndValuesDo:[:i :ln|
   767                 ln >= aLnNr ifTrue:[
   767 		ln >= aLnNr ifTrue:[
   768                     changed := true.
   768 		    changed := true.
   769                     selection at:i put:(ln + aDeltaLines)
   769 		    selection at:i put:(ln + aDeltaLines)
   770                 ]
   770 		]
   771             ]
   771 	    ]
   772         ] ifTrue:[
   772 	] ifTrue:[
   773             cnts := 0.
   773 	    cnts := 0.
   774 
   774 
   775             selection keysAndValuesDo:[:i :ln||new|
   775 	    selection keysAndValuesDo:[:i :ln||new|
   776                 ln >= aLnNr ifTrue:[
   776 		ln >= aLnNr ifTrue:[
   777                     changed := true.
   777 		    changed := true.
   778 
   778 
   779                     (new := ln + aDeltaLines) < aLnNr ifTrue:[
   779 		    (new := ln + aDeltaLines) < aLnNr ifTrue:[
   780                         cnts := cnts + 1.
   780 			cnts := cnts + 1.
   781                         new  := nil
   781 			new  := nil
   782                     ].
   782 		    ].
   783                     selection at:i put:new
   783 		    selection at:i put:new
   784                 ]
   784 		]
   785             ].
   785 	    ].
   786             cnts ~~ 0 ifTrue:[
   786 	    cnts ~~ 0 ifTrue:[
   787                 cnts == selection size ifTrue:[
   787 		cnts == selection size ifTrue:[
   788                     selection := nil
   788 		    selection := nil
   789                 ] ifFalse:[
   789 		] ifFalse:[
   790                     selection := selection select:[:ln| ln notNil]
   790 		    selection := selection select:[:ln| ln notNil]
   791                 ].
   791 		].
   792                 ^ self selectionChanged.
   792 		^ self selectionChanged.
   793             ].
   793 	    ].
   794         ].
   794 	].
   795         changed ifFalse:[^ self].
   795 	changed ifFalse:[^ self].
   796     ].
   796     ].
   797 
   797 
   798     (useIndex and:[model notNil]) ifTrue:[
   798     (useIndex and:[model notNil]) ifTrue:[
   799         model setValue:(self argForChangeMessage)
   799 	model setValue:(self argForChangeMessage)
   800     ].
   800     ].
   801 !
   801 !
   802 
   802 
   803 originChanged:delta
   803 originChanged:delta
   804     "setup the origin of the editing view
   804     "setup the origin of the editing view
   815     |arg|
   815     |arg|
   816 
   816 
   817     self closeEditor.
   817     self closeEditor.
   818 
   818 
   819     (model isNil and:[actionBlock isNil]) ifTrue:[
   819     (model isNil and:[actionBlock isNil]) ifTrue:[
   820         ^ self
   820 	^ self
   821     ].
   821     ].
   822 
   822 
   823     arg := self argForChangeMessage.
   823     arg := self argForChangeMessage.
   824 
   824 
   825     model notNil ifTrue:[
   825     model notNil ifTrue:[
   826         model removeDependent:self.
   826 	model removeDependent:self.
   827         "/ change models value to force a change notification: reselect mode
   827 	"/ change models value to force a change notification: reselect mode
   828         arg = model value ifTrue:[
   828 	arg = model value ifTrue:[
   829             model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
   829 	    model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
   830         ].
   830 	].
   831         self sendChangeMessage:#value: with:arg.
   831 	self sendChangeMessage:#value: with:arg.
   832         model notNil ifTrue:[  "/ argggh could be nilled
   832 	model notNil ifTrue:[  "/ argggh could be nilled
   833             model addDependent:self.
   833 	    model addDependent:self.
   834             self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent
   834 	    self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent
   835         ]
   835 	]
   836     ].
   836     ].
   837 
   837 
   838     actionBlock notNil ifTrue:[
   838     actionBlock notNil ifTrue:[
   839         actionBlock valueWithOptionalArgument:arg and:self
   839 	actionBlock valueWithOptionalArgument:arg and:self
   840     ].
   840     ].
   841 !
   841 !
   842 
   842 
   843 updateFromModel
   843 updateFromModel
   844     "update selection from the model
   844     "update selection from the model
   845     "
   845     "
   846     |value newSelection|
   846     |value newSelection|
   847 
   847 
   848     model isNil ifTrue:[
   848     model isNil ifTrue:[
   849         ^ self
   849 	^ self
   850     ].
   850     ].
   851 
   851 
   852     buttonMotionAction notNil ifTrue:[
   852     buttonMotionAction notNil ifTrue:[
   853         "running in button motion; discard change notification
   853 	"running in button motion; discard change notification
   854         "
   854 	"
   855         ^ self
   855 	^ self
   856     ].
   856     ].
   857 
   857 
   858     value := model value.
   858     value := model value.
   859 
   859 
   860     (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
   860     (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
   861         multipleSelectOk ifFalse:[
   861 	multipleSelectOk ifFalse:[
   862             newSelection := self identityIndexOf:value
   862 	    newSelection := self identityIndexOf:value
   863         ] ifTrue:[
   863 	] ifTrue:[
   864             value size == 0 ifTrue:[
   864 	    value size == 0 ifTrue:[
   865                 newSelection := nil
   865 		newSelection := nil
   866             ] ifFalse:[
   866 	    ] ifFalse:[
   867                 newSelection := OrderedCollection new.
   867 		newSelection := OrderedCollection new.
   868 
   868 
   869                 value do:[:e||index|
   869 		value do:[:e||index|
   870                     index := self identityIndexOf:e.
   870 		    index := self identityIndexOf:e.
   871                     index ~~ 0 ifTrue:[ newSelection add:index ].
   871 		    index ~~ 0 ifTrue:[ newSelection add:index ].
   872                 ].
   872 		].
   873 
   873 
   874                 newSelection isEmpty ifTrue:[
   874 		newSelection isEmpty ifTrue:[
   875                     newSelection := nil
   875 		    newSelection := nil
   876                 ].
   876 		].
   877             ]
   877 	    ]
   878         ].
   878 	].
   879     ] ifTrue:[
   879     ] ifTrue:[
   880         newSelection := value copy
   880 	newSelection := value copy
   881     ].
   881     ].
   882     self setSelection:newSelection.
   882     self setSelection:newSelection.
   883 ! !
   883 ! !
   884 
   884 
   885 !SelectionInListModelView methodsFor:'drag & drop'!
   885 !SelectionInListModelView methodsFor:'drag & drop'!
   901     visibleY := aContext targetPoint y.
   901     visibleY := aContext targetPoint y.
   902     yOrigin  := self yOriginOfContents.
   902     yOrigin  := self yOriginOfContents.
   903     inset    := 15 + margin.
   903     inset    := 15 + margin.
   904 
   904 
   905     visibleY <= inset ifTrue:[
   905     visibleY <= inset ifTrue:[
   906         self yOriginOfContents == 0 ifTrue:[ ^ false ].
   906 	self yOriginOfContents == 0 ifTrue:[ ^ false ].
   907     ] ifFalse:[
   907     ] ifFalse:[
   908         visibleY < (self height - inset) ifTrue:[ ^ false ].
   908 	visibleY < (self height - inset) ifTrue:[ ^ false ].
   909         self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ].
   909 	self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ].
   910     ].
   910     ].
   911 
   911 
   912     aContext contentsWillChange.
   912     aContext contentsWillChange.
   913 
   913 
   914     visibleY <= inset ifTrue:[ self scrollUp:inset ]
   914     visibleY <= inset ifTrue:[ self scrollUp:inset ]
   915                      ifFalse:[ self scrollDown:inset ].
   915 		     ifFalse:[ self scrollDown:inset ].
   916 
   916 
   917     ^ true
   917     ^ true
   918 !
   918 !
   919 
   919 
   920 dropSource
   920 dropSource
   921     "returns the dropSource or nil"
   921     "returns the dropSource or nil"
   922     
   922 
   923     ^ dropSource
   923     ^ dropSource
   924 !
   924 !
   925 
   925 
   926 dropSource:aDropSourceOrNil 
   926 dropSource:aDropSourceOrNil
   927     "set the dropSource or nil"
   927     "set the dropSource or nil"
   928     
   928 
   929     dropSource := aDropSourceOrNil.
   929     dropSource := aDropSourceOrNil.
   930 !
   930 !
   931 
   931 
   932 startDragAt:aPoint
   932 startDragAt:aPoint
   933     "start drag at a point
   933     "start drag at a point
   934     "
   934     "
   935     buttonMotionAction := buttonReleaseAction := nil.
   935     buttonMotionAction := buttonReleaseAction := nil.
   936 
   936 
   937     dropSource notNil ifTrue:[
   937     dropSource notNil ifTrue:[
   938         dropSource startDragSelector notNil ifTrue:[
   938 	dropSource startDragSelector notNil ifTrue:[
   939             ^ dropSource startDragIn:self at:aPoint
   939 	    ^ dropSource startDragIn:self at:aPoint
   940         ] ifFalse:[
   940 	] ifFalse:[
   941             ^ DragAndDropManager new 
   941 	    ^ DragAndDropManager new
   942                 startDragFrom:self dropSource:dropSource offset:#center
   942 		startDragFrom:self dropSource:dropSource offset:#center
   943         ]
   943 	]
   944     ].
   944     ].
   945     ^ nil
   945     ^ nil
   946 ! !
   946 ! !
   947 
   947 
   948 !SelectionInListModelView methodsFor:'drawing'!
   948 !SelectionInListModelView methodsFor:'drawing'!
   956     |
   956     |
   957     x0 := textStartLeft - viewOrigin x.
   957     x0 := textStartLeft - viewOrigin x.
   958     y1 := y.
   958     y1 := y.
   959 
   959 
   960     start to:stop do:[:i|
   960     start to:stop do:[:i|
   961         y0 := y1.
   961 	y0 := y1.
   962         y1 := self yVisibleOfLine:(i + 1).
   962 	y1 := self yVisibleOfLine:(i + 1).
   963         self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
   963 	self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
   964     ].
   964     ].
   965 
   965 
   966 
   966 
   967 !
   967 !
   968 
   968 
   969 drawFrom:start to:stop x:x y:y w:w
   969 drawFrom:start to:stop x:x y:y w:w
   970     "draw the lines between start to stop without clearing the background
   970     "draw the lines between start to stop without clearing the background
   971     "
   971     "
   972     highlightMode notNil ifTrue:[
   972     highlightMode notNil ifTrue:[
   973         self selectionDo:[:lnNr|
   973 	self selectionDo:[:lnNr|
   974             (lnNr between:start and:stop) ifTrue:[
   974 	    (lnNr between:start and:stop) ifTrue:[
   975                 self drawSelectionFrameAt:lnNr x:x w:w
   975 		self drawSelectionFrameAt:lnNr x:x w:w
   976             ]
   976 	    ]
   977         ]
   977 	]
   978     ].
   978     ].
   979     super drawFrom:start to:stop x:x y:y w:w.
   979     super drawFrom:start to:stop x:x y:y w:w.
   980 !
   980 !
   981 
   981 
   982 drawLabelAt:anIndex x:xI y:y h:h
   982 drawLabelAt:anIndex x:xI y:y h:h
   984     "
   984     "
   985     |item y0 x1 x w drawStrikeOut xOut0 xOut1|
   985     |item y0 x1 x w drawStrikeOut xOut0 xOut1|
   986 
   986 
   987     x := xI + 1.
   987     x := xI + 1.
   988     editorView notNil ifTrue:[
   988     editorView notNil ifTrue:[
   989         "/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
   989 	"/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
   990         self selectedIndex == anIndex ifTrue:[^ self].
   990 	self selectedIndex == anIndex ifTrue:[^ self].
   991     ].
   991     ].
   992 
   992 
   993     item := self at:anIndex ifAbsent:nil.
   993     item := self at:anIndex ifAbsent:nil.
   994     item isNil ifTrue:[^ self].
   994     item isNil ifTrue:[^ self].
   995 
   995 
   996     drawStrikeOut := false.
   996     drawStrikeOut := false.
   997 
   997 
   998     (highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
   998     (highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
   999         strikeOut ifTrue:[
   999 	strikeOut ifTrue:[
  1000             drawStrikeOut := true.
  1000 	    drawStrikeOut := true.
  1001             self paint:fgColor on:bgColor
  1001 	    self paint:fgColor on:bgColor
  1002         ] ifFalse:[
  1002 	] ifFalse:[
  1003             (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
  1003 	    (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
  1004                 self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus.
  1004 		self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus.
  1005             ] ifFalse:[
  1005 	    ] ifFalse:[
  1006                 self paint:hilightFgColor on:hilightBgColor
  1006 		self paint:hilightFgColor on:hilightBgColor
  1007             ].
  1007 	    ].
  1008         ]
  1008 	]
  1009     ] ifFalse:[
  1009     ] ifFalse:[
  1010         enterItem == item ifTrue:[
  1010 	enterItem == item ifTrue:[
  1011             self paint:hilightBgColor on:bgColor.
  1011 	    self paint:hilightBgColor on:bgColor.
  1012         ] ifFalse:[
  1012 	] ifFalse:[
  1013             self paint:fgColor on:bgColor.
  1013 	    self paint:fgColor on:bgColor.
  1014         ].
  1014 	].
  1015     ].
  1015     ].
  1016     renderer display:item atX:x y:y lineHeight:h.
  1016     listRenderer display:item atX:x y:y lineHeight:h.
  1017 
  1017 
  1018     drawStrikeOut ifTrue:[
  1018     drawStrikeOut ifTrue:[
  1019         xOut0 := self xVisibleOfItem:item.
  1019 	xOut0 := self xVisibleOfItem:item.
  1020         highlightMode == #label ifTrue:[
  1020 	highlightMode == #label ifTrue:[
  1021             xOut1 := xOut0 + (renderer widthFor:item).
  1021 	    xOut1 := xOut0 + (listRenderer widthFor:item).
  1022         ] ifFalse:[
  1022 	] ifFalse:[
  1023             xOut1 := width - margin.
  1023 	    xOut1 := width - margin.
  1024         ].
  1024 	].
  1025         y0 := y + (h // 2).
  1025 	y0 := y + (h // 2).
  1026         self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
  1026 	self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
  1027         y0 := y0 - 1.
  1027 	y0 := y0 - 1.
  1028         self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
  1028 	self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
  1029     ].
  1029     ].
  1030 
  1030 
  1031     cursorItem == item ifTrue:[
  1031     cursorItem == item ifTrue:[
  1032         "/ textStartLeft
  1032 	"/ textStartLeft
  1033         self maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
  1033 	self maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
  1034         self mask:lineMask.
  1034 	self mask:lineMask.
  1035         w := renderer widthFor:item.
  1035 	w := listRenderer widthFor:item.
  1036         self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4).
  1036 	self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4).
  1037         self mask:nil.
  1037 	self mask:nil.
  1038     ] ifFalse:[
  1038     ] ifFalse:[
  1039         enterItem == item ifTrue:[
  1039 	enterItem == item ifTrue:[
  1040             self highlightWithUnderline ifTrue:[
  1040 	    self highlightWithUnderline ifTrue:[
  1041                 "/ underline the hilite...
  1041 		"/ underline the hilite...
  1042                 y0 := y + h - 2.
  1042 		y0 := y + h - 2.
  1043                 x1 := x + (renderer widthFor:item).
  1043 		x1 := x + (listRenderer widthFor:item).
  1044 
  1044 
  1045                 self displayLineFromX:x y:y0 toX:x1 y:y0.
  1045 		self displayLineFromX:x y:y0 toX:x1 y:y0.
  1046             ]
  1046 	    ]
  1047         ].
  1047 	].
  1048     ].
  1048     ].
  1049 !
  1049 !
  1050 
  1050 
  1051 drawSelectionFrameAt:lnNr x:x w:w
  1051 drawSelectionFrameAt:lnNr x:x w:w
  1052     "draw the background and foreground of the selection frame
  1052     "draw the background and foreground of the selection frame
  1053      at a lineNr.
  1053      at a lineNr.
  1054     "
  1054     "
  1055     |item xMax xLftDmg xRgtDmg x0 x1 y0 y1 hL wL|
  1055     |item xMax xLftDmg xRgtDmg x0 x1 y0 y1 hL wL|
  1056 
  1056 
  1057     (strikeOut or:[highlightMode isNil]) ifTrue:[
  1057     (strikeOut or:[highlightMode isNil]) ifTrue:[
  1058         ^ self
  1058 	^ self
  1059     ].
  1059     ].
  1060     editorView notNil ifTrue:[
  1060     editorView notNil ifTrue:[
  1061         "/ there is an open editor; do not redraw selected
  1061 	"/ there is an open editor; do not redraw selected
  1062         ^ self
  1062 	^ self
  1063     ].
  1063     ].
  1064 
  1064 
  1065     (    highlightMode == #line
  1065     (    highlightMode == #line
  1066      or:[highlightMode == #label
  1066      or:[highlightMode == #label
  1067      or:[highlightMode == #dropMode]]
  1067      or:[highlightMode == #dropMode]]
  1068     ) ifFalse:[
  1068     ) ifFalse:[
  1069         "/ highlightMode not supported
  1069 	"/ highlightMode not supported
  1070         ^ self
  1070 	^ self
  1071     ].
  1071     ].
  1072     (item := self at:lnNr ifAbsent:nil) isNil ifTrue:[
  1072     (item := self at:lnNr ifAbsent:nil) isNil ifTrue:[
  1073         "/ list might change during drawing; item no longer visible
  1073 	"/ list might change during drawing; item no longer visible
  1074         ^ self
  1074 	^ self
  1075     ].
  1075     ].
  1076     xMax := x + w.
  1076     xMax := x + w.
  1077 
  1077 
  1078     "/ CLEAR THE BACKGROUND
  1078     "/ CLEAR THE BACKGROUND
  1079 
  1079 
  1080     y0 := self yVisibleOfLine:lnNr.
  1080     y0 := self yVisibleOfLine:lnNr.
  1081     y1 := self yVisibleOfLine:(lnNr + 1).
  1081     y1 := self yVisibleOfLine:(lnNr + 1).
  1082     hL := y1 - y0.
  1082     hL := y1 - y0.
  1083 
  1083 
  1084     highlightMode == #line ifTrue:[
  1084     highlightMode == #line ifTrue:[
  1085         x0 := x.
  1085 	x0 := x.
  1086         x1 := xMax.
  1086 	x1 := xMax.
  1087     ] ifFalse:[ "/ is #label or #rectangle
  1087     ] ifFalse:[ "/ is #label or #rectangle
  1088         x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
  1088 	x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
  1089         x0 >= xMax ifTrue:[ ^ self ].
  1089 	x0 >= xMax ifTrue:[ ^ self ].
  1090 
  1090 
  1091         x1 := x0 + (renderer widthFor:item) + textStartLeft + 1.
  1091 	x1 := x0 + (listRenderer widthFor:item) + textStartLeft + 1.
  1092         x1 < x ifTrue:[ ^ self ].
  1092 	x1 < x ifTrue:[ ^ self ].
  1093     ].
  1093     ].
  1094     xLftDmg := x0 max:x.
  1094     xLftDmg := x0 max:x.
  1095     xRgtDmg := x1 min:xMax.
  1095     xRgtDmg := x1 min:xMax.
  1096     xRgtDmg > xLftDmg ifFalse:[^ self].
  1096     xRgtDmg > xLftDmg ifFalse:[^ self].
  1097 
  1097 
  1098     (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
  1098     (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
  1099         self paint:hilightBgColorNoFocus.
  1099 	self paint:hilightBgColorNoFocus.
  1100     ] ifFalse:[
  1100     ] ifFalse:[
  1101         self paint:hilightBgColor.
  1101 	self paint:hilightBgColor.
  1102     ].
  1102     ].
  1103     self fillRectangleX:xLftDmg y:y0 width:(xRgtDmg - xLftDmg) height:hL.
  1103     self fillRectangleX:xLftDmg y:y0 width:(xRgtDmg - xLftDmg) height:hL.
  1104     wL := x1 - x0.
  1104     wL := x1 - x0.
  1105 
  1105 
  1106     "/ DRAW THE FRAME
  1106     "/ DRAW THE FRAME
  1107 
  1107 
  1108     hilightFrameColor notNil ifTrue:[
  1108     hilightFrameColor notNil ifTrue:[
  1109         hilightLevel == 0 ifTrue:[
  1109 	hilightLevel == 0 ifTrue:[
  1110             self paint:hilightFrameColor.
  1110 	    self paint:hilightFrameColor.
  1111 
  1111 
  1112             highlightMode == #line ifTrue:[
  1112 	    highlightMode == #line ifTrue:[
  1113                 self displayLineFromX:x0 y:y0 toX:x1 y:y0.
  1113 		self displayLineFromX:x0 y:y0 toX:x1 y:y0.
  1114                 y1 := y0 + hL - 1.
  1114 		y1 := y0 + hL - 1.
  1115                 self displayLineFromX:x0 y:y1 toX:x1 y:y1.
  1115 		self displayLineFromX:x0 y:y1 toX:x1 y:y1.
  1116             ] ifFalse:[
  1116 	    ] ifFalse:[
  1117                 self displayRectangleX:x0 y:y0 width:wL height:hL
  1117 		self displayRectangleX:x0 y:y0 width:wL height:hL
  1118             ].
  1118 	    ].
  1119             ^ self.
  1119 	    ^ self.
  1120         ]
  1120 	]
  1121     ] ifFalse:[
  1121     ] ifFalse:[
  1122         hilightStyle == #motif ifTrue:[
  1122 	hilightStyle == #motif ifTrue:[
  1123             self paint:bgColor.
  1123 	    self paint:bgColor.
  1124             y1 := y0 + 1.
  1124 	    y1 := y0 + 1.
  1125             highlightMode == #line ifTrue:[
  1125 	    highlightMode == #line ifTrue:[
  1126                 self displayLineFromX:x0 y:y1 toX:x1 y:y1.
  1126 		self displayLineFromX:x0 y:y1 toX:x1 y:y1.
  1127                 y1 := y0 + hL - 2.
  1127 		y1 := y0 + hL - 2.
  1128                 self displayLineFromX:x0 y:y1 toX:x1 y:y1.
  1128 		self displayLineFromX:x0 y:y1 toX:x1 y:y1.
  1129             ] ifFalse:[
  1129 	    ] ifFalse:[
  1130                 self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
  1130 		self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
  1131             ]
  1131 	    ]
  1132         ].
  1132 	].
  1133         hilightLevel == 0 ifTrue:[ ^ self ].
  1133 	hilightLevel == 0 ifTrue:[ ^ self ].
  1134     ].
  1134     ].
  1135 
  1135 
  1136     "/ draw edge
  1136     "/ draw edge
  1137     highlightMode == #line ifTrue:[
  1137     highlightMode == #line ifTrue:[
  1138         x0 := margin.
  1138 	x0 := margin.
  1139         wL := width - x0 - x0.
  1139 	wL := width - x0 - x0.
  1140     ].
  1140     ].
  1141     self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel.
  1141     self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel.
  1142 !
  1142 !
  1143 
  1143 
  1144 invalidateSelection
  1144 invalidateSelection
  1145     "invalidate the current selection
  1145     "invalidate the current selection
  1146     "
  1146     "
  1147     shown ifTrue:[
  1147     shown ifTrue:[
  1148         self selectionDo:[:aLnNr|
  1148 	self selectionDo:[:aLnNr|
  1149             self invalidateLineAt:aLnNr
  1149 	    self invalidateLineAt:aLnNr
  1150         ].
  1150 	].
  1151     ].
  1151     ].
  1152 !
  1152 !
  1153 
  1153 
  1154 invalidateSelectionAt:aLineNr
  1154 invalidateSelectionAt:aLineNr
  1155     "redraw a line which changed its selection status.
  1155     "redraw a line which changed its selection status.
  1156      optimized when drawing only the label.
  1156      optimized when drawing only the label.
  1157     "
  1157     "
  1158     |item x|
  1158     |item x|
  1159 
  1159 
  1160     editorView notNil ifTrue:[
  1160     editorView notNil ifTrue:[
  1161         "/ there is an open editor; do not redraw selected
  1161 	"/ there is an open editor; do not redraw selected
  1162         ^ self
  1162 	^ self
  1163     ].
  1163     ].
  1164 
  1164 
  1165     (shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[
  1165     (shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[
  1166         ^ self
  1166 	^ self
  1167     ].
  1167     ].
  1168 
  1168 
  1169     highlightMode == #label ifTrue:[
  1169     highlightMode == #label ifTrue:[
  1170         item := self at:aLineNr ifAbsent:nil.
  1170 	item := self at:aLineNr ifAbsent:nil.
  1171 
  1171 
  1172         item isNil ifTrue:[
  1172 	item isNil ifTrue:[
  1173             ^ self
  1173 	    ^ self
  1174         ].
  1174 	].
  1175         x := (self xVisibleOfItem:item) - (textStartLeft // 2)
  1175 	x := (self xVisibleOfItem:item) - (textStartLeft // 2)
  1176     ] ifFalse:[
  1176     ] ifFalse:[
  1177         x := 0.
  1177 	x := 0.
  1178     ].
  1178     ].
  1179     self invalidateLineAt:aLineNr fromX:x
  1179     self invalidateLineAt:aLineNr fromX:x
  1180 ! !
  1180 ! !
  1181 
  1181 
  1182 !SelectionInListModelView methodsFor:'event handling'!
  1182 !SelectionInListModelView methodsFor:'event handling'!
  1187     |isInSelection prvLine chgSet doAdd|
  1187     |isInSelection prvLine chgSet doAdd|
  1188 
  1188 
  1189     isInSelection := self isInSelection:lineNr.
  1189     isInSelection := self isInSelection:lineNr.
  1190 
  1190 
  1191     multipleSelectOk ifFalse:[
  1191     multipleSelectOk ifFalse:[
  1192         isInSelection ifTrue:[
  1192 	isInSelection ifTrue:[
  1193             self deselect
  1193 	    self deselect
  1194         ]ifFalse:[
  1194 	]ifFalse:[
  1195             (self canSelectIndex:lineNr forAdd:false) ifTrue:[
  1195 	    (self canSelectIndex:lineNr forAdd:false) ifTrue:[
  1196                 self buttonPressOrReleaseAtLine:lineNr x:x y:y.
  1196 		self buttonPressOrReleaseAtLine:lineNr x:x y:y.
  1197             ].
  1197 	    ].
  1198         ].
  1198 	].
  1199         ^ self
  1199 	^ self
  1200     ].
  1200     ].
  1201     isInSelection ifTrue:[
  1201     isInSelection ifTrue:[
  1202         self removeFromSelection:lineNr
  1202 	self removeFromSelection:lineNr
  1203     ] ifFalse:[
  1203     ] ifFalse:[
  1204         self addToSelection:lineNr.
  1204 	self addToSelection:lineNr.
  1205 
  1205 
  1206         (self isInSelection:lineNr) ifFalse:[
  1206 	(self isInSelection:lineNr) ifFalse:[
  1207             "/ cannot add to selection
  1207 	    "/ cannot add to selection
  1208             ^ self
  1208 	    ^ self
  1209         ].
  1209 	].
  1210     ].
  1210     ].
  1211 
  1211 
  1212     prvLine := lineNr.
  1212     prvLine := lineNr.
  1213     chgSet  := IdentitySet new.
  1213     chgSet  := IdentitySet new.
  1214     doAdd   := isInSelection not.
  1214     doAdd   := isInSelection not.
  1215 
  1215 
  1216     buttonMotionAction := [:p| |rowNr mustRestore step f|
  1216     buttonMotionAction := [:p| |rowNr mustRestore step f|
  1217         rowNr := self yVisibleToLineNr:(p y).
  1217 	rowNr := self yVisibleToLineNr:(p y).
  1218 
  1218 
  1219         (rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[
  1219 	(rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[
  1220             rowNr == lineNr ifTrue:[
  1220 	    rowNr == lineNr ifTrue:[
  1221                 mustRestore := true
  1221 		mustRestore := true
  1222             ] ifFalse:[
  1222 	    ] ifFalse:[
  1223                 rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ]
  1223 		rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ]
  1224                               ifFalse:[ mustRestore := (rowNr > prvLine) ].
  1224 			      ifFalse:[ mustRestore := (rowNr > prvLine) ].
  1225             ].
  1225 	    ].
  1226             prvLine > rowNr ifTrue:[ step := -1 ]
  1226 	    prvLine > rowNr ifTrue:[ step := -1 ]
  1227                           ifFalse:[ step :=  1 ].
  1227 			  ifFalse:[ step :=  1 ].
  1228             mustRestore ifTrue:[
  1228 	    mustRestore ifTrue:[
  1229                 [ prvLine ~~ rowNr ] whileTrue:[
  1229 		[ prvLine ~~ rowNr ] whileTrue:[
  1230                     (chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[
  1230 		    (chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[
  1231                         doAdd ifFalse:[ self addToSelection:prvLine ]
  1231 			doAdd ifFalse:[ self addToSelection:prvLine ]
  1232                                ifTrue:[ self removeFromSelection:prvLine ].
  1232 			       ifTrue:[ self removeFromSelection:prvLine ].
  1233                     ].
  1233 		    ].
  1234                     prvLine := prvLine + step.
  1234 		    prvLine := prvLine + step.
  1235                 ].
  1235 		].
  1236             ] ifFalse:[
  1236 	    ] ifFalse:[
  1237                 [ prvLine ~~ rowNr ] whileTrue:[
  1237 		[ prvLine ~~ rowNr ] whileTrue:[
  1238                     prvLine := prvLine + step.
  1238 		    prvLine := prvLine + step.
  1239 
  1239 
  1240                     doAdd ~~ (self isInSelection:rowNr) ifTrue:[
  1240 		    doAdd ~~ (self isInSelection:rowNr) ifTrue:[
  1241                         chgSet add:prvLine.
  1241 			chgSet add:prvLine.
  1242 
  1242 
  1243                         doAdd ifTrue:[ self addToSelection:prvLine ]
  1243 			doAdd ifTrue:[ self addToSelection:prvLine ]
  1244                              ifFalse:[ self removeFromSelection:prvLine ].
  1244 			     ifFalse:[ self removeFromSelection:prvLine ].
  1245                     ]
  1245 		    ]
  1246                 ].
  1246 		].
  1247             ].
  1247 	    ].
  1248         ].
  1248 	].
  1249     ].
  1249     ].
  1250 !
  1250 !
  1251 
  1251 
  1252 buttonMotion:buttonMask x:x y:y
  1252 buttonMotion:buttonMask x:x y:y
  1253     "mouse-move while button was pressed - handle selection changes
  1253     "mouse-move while button was pressed - handle selection changes
  1255     |lnNr item|
  1255     |lnNr item|
  1256 
  1256 
  1257     self stopAutoScroll.
  1257     self stopAutoScroll.
  1258 
  1258 
  1259     (buttonMask ~~ 0 and:[buttonMotionAction notNil]) ifTrue:[
  1259     (buttonMask ~~ 0 and:[buttonMotionAction notNil]) ifTrue:[
  1260         buttonMotionAction value:(x@y).
  1260 	buttonMotionAction value:(x@y).
  1261 
  1261 
  1262         (autoScroll and:[buttonMotionAction notNil]) ifTrue:[
  1262 	(autoScroll and:[buttonMotionAction notNil]) ifTrue:[
  1263             "/ if moved outside of view, start autoscroll
  1263 	    "/ if moved outside of view, start autoscroll
  1264             (y between:0 and:height) ifFalse:[
  1264 	    (y between:0 and:height) ifFalse:[
  1265                 y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ]
  1265 		y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ]
  1266                      ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ].
  1266 		     ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ].
  1267             ].
  1267 	    ].
  1268         ].
  1268 	].
  1269         ^ self
  1269 	^ self
  1270     ].
  1270     ].
  1271 
  1271 
  1272     (enabled and:[highlightEnterItem]) ifTrue:[
  1272     (enabled and:[highlightEnterItem]) ifTrue:[
  1273         self sensor anyButtonPressed ifFalse:[
  1273 	self sensor anyButtonPressed ifFalse:[
  1274             lnNr := self yVisibleToLineNr:y.
  1274 	    lnNr := self yVisibleToLineNr:y.
  1275 
  1275 
  1276             lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ]
  1276 	    lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ]
  1277                        ifFalse:[ item := nil ].
  1277 		       ifFalse:[ item := nil ].
  1278 
  1278 
  1279             self pointerEntersItem:item.
  1279 	    self pointerEntersItem:item.
  1280         ]
  1280 	]
  1281     ].    
  1281     ].
  1282 !
  1282 !
  1283 
  1283 
  1284 buttonMultiPress:button x:x y:y
  1284 buttonMultiPress:button x:x y:y
  1285     "button was pressed multiple - handle a doubleClick action"
  1285     "button was pressed multiple - handle a doubleClick action"
  1286 
  1286 
  1289     buttonMotionAction := buttonReleaseAction := nil.
  1289     buttonMotionAction := buttonReleaseAction := nil.
  1290 
  1290 
  1291     enabled ifFalse:[^ self].
  1291     enabled ifFalse:[^ self].
  1292 
  1292 
  1293     ((button == 1) or:[button == #select]) ifTrue:[
  1293     ((button == 1) or:[button == #select]) ifTrue:[
  1294         doubleClickActionBlock notNil ifTrue:[
  1294 	doubleClickActionBlock notNil ifTrue:[
  1295             (     (lnNr := self yVisibleToLineNr:y)   notNil
  1295 	    (     (lnNr := self yVisibleToLineNr:y)   notNil
  1296              and:[(item := self at:lnNr ifAbsent:nil) notNil]
  1296 	     and:[(item := self at:lnNr ifAbsent:nil) notNil]
  1297             ) ifTrue:[
  1297 	    ) ifTrue:[
  1298                 doubleClickActionBlock valueWithOptionalArgument:lnNr and:self.
  1298 		doubleClickActionBlock valueWithOptionalArgument:lnNr and:self.
  1299             ].
  1299 	    ].
  1300         ].
  1300 	].
  1301         ^ self.
  1301 	^ self.
  1302     ].
  1302     ].
  1303 
  1303 
  1304     super buttonMultiPress:button x:x y:y
  1304     super buttonMultiPress:button x:x y:y
  1305 !
  1305 !
  1306 
  1306 
  1311 
  1311 
  1312     modelChangedDuringButtonPress := buttonMotionAction := buttonReleaseAction := nil.
  1312     modelChangedDuringButtonPress := buttonMotionAction := buttonReleaseAction := nil.
  1313 
  1313 
  1314     self pointerEntersItem:nil.
  1314     self pointerEntersItem:nil.
  1315     self cursorEntersItem:nil.
  1315     self cursorEntersItem:nil.
  1316     self closeEditor.        
  1316     self closeEditor.
  1317 
  1317 
  1318     enabled ifFalse:[^ self].
  1318     enabled ifFalse:[^ self].
  1319 
  1319 
  1320     sensor := self sensor.
  1320     sensor := self sensor.
  1321     lineNr := self yVisibleToLineNr:y.
  1321     lineNr := self yVisibleToLineNr:y.
  1322 
  1322 
  1323     ((button == 2) or:[button == #menu]) ifTrue:[
  1323     ((button == 2) or:[button == #menu]) ifTrue:[
  1324         (self selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[
  1324 	(self selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[
  1325             (     lineNr notNil
  1325 	    (     lineNr notNil
  1326              and:[self canSelectIndex:lineNr forAdd:false ]
  1326 	     and:[self canSelectIndex:lineNr forAdd:false ]
  1327             ) ifTrue:[
  1327 	    ) ifTrue:[
  1328                 (lineNr ~~ self selectedIndex) ifTrue: [
  1328 		(lineNr ~~ self selectedIndex) ifTrue: [
  1329                     (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
  1329 		    (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
  1330                         self selectionChanged
  1330 			self selectionChanged
  1331                     ].
  1331 		    ].
  1332                 ].
  1332 		].
  1333                 item := self selectedElement.
  1333 		item := self selectedElement.
  1334             ] ifFalse:[
  1334 	    ] ifFalse:[
  1335                 item := nil.
  1335 		item := nil.
  1336                 item := self selectedElement.
  1336 		item := self selectedElement.
  1337 "/                self deselect.
  1337 "/                self deselect.
  1338             ]
  1338 	    ]
  1339         ] ifFalse:[
  1339 	] ifFalse:[
  1340             item := self selectedElement.
  1340 	    item := self selectedElement.
  1341         ].
  1341 	].
  1342 
  1342 
  1343         item notNil ifTrue:[
  1343 	item notNil ifTrue:[
  1344             self makeSelectionVisible.
  1344 	    self makeSelectionVisible.
  1345 
  1345 
  1346             menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
  1346 	    menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
  1347             menu notNil ifTrue:[
  1347 	    menu notNil ifTrue:[
  1348                 menu isCollection ifTrue:[
  1348 		menu isCollection ifTrue:[
  1349                     menu := Menu decodeFromLiteralArray:menu.
  1349 		    menu := Menu decodeFromLiteralArray:menu.
  1350                     appl := self application.
  1350 		    appl := self application.
  1351 
  1351 
  1352                     appl notNil ifTrue:[
  1352 		    appl notNil ifTrue:[
  1353                         menu findGuiResourcesIn:appl.
  1353 			menu findGuiResourcesIn:appl.
  1354                         "/ menu receiver:appl  -- now done in findGuiResources ...
  1354 			"/ menu receiver:appl  -- now done in findGuiResources ...
  1355                     ] ifFalse:[
  1355 		    ] ifFalse:[
  1356                         menu receiver:item
  1356 			menu receiver:item
  1357                     ]
  1357 		    ]
  1358                 ].
  1358 		].
  1359                 self startUpMenu:menu.
  1359 		self startUpMenu:menu.
  1360                 ^ self
  1360 		^ self
  1361             ].
  1361 	    ].
  1362         ].
  1362 	].
  1363         super buttonPress:button x:x y:y.
  1363 	super buttonPress:button x:x y:y.
  1364         ^ self
  1364 	^ self
  1365     ].
  1365     ].
  1366     lineNr isNil ifTrue:[ ^ self ].
  1366     lineNr isNil ifTrue:[ ^ self ].
  1367     modelChangedDuringButtonPress := false.
  1367     modelChangedDuringButtonPress := false.
  1368 
  1368 
  1369     sensor ctrlDown ifTrue:[
  1369     sensor ctrlDown ifTrue:[
  1370         self buttonControlPressAtLine:lineNr x:x y:y.
  1370 	self buttonControlPressAtLine:lineNr x:x y:y.
  1371         ^ self
  1371 	^ self
  1372     ].
  1372     ].
  1373 
  1373 
  1374     isSelected  := self isInSelection:lineNr.
  1374     isSelected  := self isInSelection:lineNr.
  1375 
  1375 
  1376     (self canDrag and:[sensor shiftDown not]) ifTrue:[
  1376     (self canDrag and:[sensor shiftDown not]) ifTrue:[
  1377         dragDistance := UserPreferences current motionDistanceToStartDrag.
  1377 	dragDistance := UserPreferences current motionDistanceToStartDrag.
  1378 
  1378 
  1379         isSelected ifTrue:[
  1379 	isSelected ifTrue:[
  1380             buttonMotionAction := 
  1380 	    buttonMotionAction :=
  1381                 [:p|
  1381 		[:p|
  1382                     ((x@y) dist:p) > dragDistance ifTrue:[
  1382 		    ((x@y) dist:p) > dragDistance ifTrue:[
  1383                         self startDragAt:p.
  1383 			self startDragAt:p.
  1384                     ]
  1384 		    ]
  1385                 ].
  1385 		].
  1386             buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ].
  1386 	    buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ].
  1387             ^ self.
  1387 	    ^ self.
  1388         ].
  1388 	].
  1389 
  1389 
  1390         self selectOnButtonPress ifFalse: [
  1390 	self selectOnButtonPress ifFalse: [
  1391             |oldSelection|
  1391 	    |oldSelection|
  1392 
  1392 
  1393             "/ set selection to line;
  1393 	    "/ set selection to line;
  1394             "/ set the model without change notification (objects to drag)
  1394 	    "/ set the model without change notification (objects to drag)
  1395 
  1395 
  1396             oldSelection := selection copy.
  1396 	    oldSelection := selection copy.
  1397             self selectAndUpdateModelWithoutChangeNotification: lineNr.
  1397 	    self selectAndUpdateModelWithoutChangeNotification: lineNr.
  1398             self windowGroup processExposeEvents.
  1398 	    self windowGroup processExposeEvents.
  1399 
  1399 
  1400             buttonMotionAction := 
  1400 	    buttonMotionAction :=
  1401                 [:p|
  1401 		[:p|
  1402                     ((x@y) dist:p) > dragDistance ifTrue:[
  1402 		    ((x@y) dist:p) > dragDistance ifTrue:[
  1403                         |handler|
  1403 			|handler|
  1404 
  1404 
  1405                         handler := self startDragAt:p.
  1405 			handler := self startDragAt:p.
  1406                         handler contentsWillChange.
  1406 			handler contentsWillChange.
  1407                         "/ restore old selection
  1407 			"/ restore old selection
  1408                         self selectAndUpdateModelWithoutChangeNotification: oldSelection.
  1408 			self selectAndUpdateModelWithoutChangeNotification: oldSelection.
  1409                         self windowGroup processExposeEvents.
  1409 			self windowGroup processExposeEvents.
  1410                     ].
  1410 		    ].
  1411                 ].
  1411 		].
  1412 
  1412 
  1413             buttonReleaseAction := [
  1413 	    buttonReleaseAction := [
  1414                 (self canSelectIndex:lineNr forAdd:false) ifTrue:[
  1414 		(self canSelectIndex:lineNr forAdd:false) ifTrue:[
  1415                     "/ notify selection change
  1415 		    "/ notify selection change
  1416                     self selectionChanged.
  1416 		    self selectionChanged.
  1417                 ] ifFalse:[
  1417 		] ifFalse:[
  1418                     "/ restore old selection
  1418 		    "/ restore old selection
  1419                     self selectAndUpdateModelWithoutChangeNotification: oldSelection.
  1419 		    self selectAndUpdateModelWithoutChangeNotification: oldSelection.
  1420                 ].
  1420 		].
  1421             ].
  1421 	    ].
  1422             ^ self
  1422 	    ^ self
  1423         ].
  1423 	].
  1424     ].
  1424     ].
  1425 
  1425 
  1426     multipleSelectOk ifFalse:[
  1426     multipleSelectOk ifFalse:[
  1427         (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[
  1427 	(isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[
  1428             self buttonPressOrReleaseAtLine:lineNr x:x y:y.
  1428 	    self buttonPressOrReleaseAtLine:lineNr x:x y:y.
  1429 
  1429 
  1430             (dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[
  1430 	    (dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[
  1431                 buttonMotionAction := 
  1431 		buttonMotionAction :=
  1432                     [:p|
  1432 		    [:p|
  1433                         ((x@y) dist:p) > dragDistance ifTrue:[
  1433 			((x@y) dist:p) > dragDistance ifTrue:[
  1434                             self startDragAt:p.
  1434 			    self startDragAt:p.
  1435                         ].
  1435 			].
  1436                     ].
  1436 		    ].
  1437             ].
  1437 	    ].
  1438         ].
  1438 	].
  1439         ^ self
  1439 	^ self
  1440     ].
  1440     ].
  1441     startLine := lineNr.
  1441     startLine := lineNr.
  1442 
  1442 
  1443     sensor shiftDown ifTrue:[ |min max|
  1443     sensor shiftDown ifTrue:[ |min max|
  1444         (isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[
  1444 	(isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[
  1445             ^ self
  1445 	    ^ self
  1446         ].
  1446 	].
  1447 
  1447 
  1448         multipleSelectOk ifTrue:[
  1448 	multipleSelectOk ifTrue:[
  1449             startLine := self firstInSelection.
  1449 	    startLine := self firstInSelection.
  1450             startLine isNil ifTrue:[ startLine := lineNr ].
  1450 	    startLine isNil ifTrue:[ startLine := lineNr ].
  1451 
  1451 
  1452             startLine <= lineNr ifTrue:[
  1452 	    startLine <= lineNr ifTrue:[
  1453                 self selectFrom:startLine to:lineNr.
  1453 		self selectFrom:startLine to:lineNr.
  1454             ] ifFalse:[
  1454 	    ] ifFalse:[
  1455                 startLine := self lastInSelection.
  1455 		startLine := self lastInSelection.
  1456                 self selectFrom:lineNr to:startLine.
  1456 		self selectFrom:lineNr to:startLine.
  1457             ].
  1457 	    ].
  1458         ]
  1458 	]
  1459     ] ifFalse:[
  1459     ] ifFalse:[
  1460         (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[
  1460 	(isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[
  1461             ^ self
  1461 	    ^ self
  1462         ].
  1462 	].
  1463         self buttonPressOrReleaseAtLine:lineNr x:x y:y.
  1463 	self buttonPressOrReleaseAtLine:lineNr x:x y:y.
  1464     ].
  1464     ].
  1465 
  1465 
  1466     multipleSelectOk ifTrue:[
  1466     multipleSelectOk ifTrue:[
  1467         buttonMotionAction := 
  1467 	buttonMotionAction :=
  1468             [:p| |ln|
  1468 	    [:p| |ln|
  1469                 (p y between:0 and:height) ifTrue:[ |ln|
  1469 		(p y between:0 and:height) ifTrue:[ |ln|
  1470                     ln := self yVisibleToLineNr:p y.
  1470 		    ln := self yVisibleToLineNr:p y.
  1471                     ln isNil ifTrue:[ln := self size].
  1471 		    ln isNil ifTrue:[ln := self size].
  1472 
  1472 
  1473                     (ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[
  1473 		    (ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[
  1474                         self selectFrom:startLine to:ln.
  1474 			self selectFrom:startLine to:ln.
  1475                         dragDistance := nil.   "/ selection changed - no longer dragable
  1475 			dragDistance := nil.   "/ selection changed - no longer dragable
  1476                     ]
  1476 		    ]
  1477                 ].
  1477 		].
  1478 
  1478 
  1479                 (dragDistance notNil and:[(x dist:p x) > dragDistance]) ifTrue:[
  1479 		(dragDistance notNil and:[(x dist:p x) > dragDistance]) ifTrue:[
  1480                     self startDragAt:p.
  1480 		    self startDragAt:p.
  1481                 ].
  1481 		].
  1482             ].
  1482 	    ].
  1483     ].
  1483     ].
  1484 
  1484 
  1485     "Modified: / 27-03-2007 / 08:43:58 / cg"
  1485     "Modified: / 27-03-2007 / 08:43:58 / cg"
  1486 !
  1486 !
  1487 
  1487 
  1488 buttonPressOrReleaseAtLine:aLnNr x:x y:y
  1488 buttonPressOrReleaseAtLine:aLnNr x:x y:y
  1489     "handle a button press or release at a line
  1489     "handle a button press or release at a line
  1490     "
  1490     "
  1491     aLnNr == self selectedIndex ifTrue:[
  1491     aLnNr == self selectedIndex ifTrue:[
  1492         editorView notNil ifTrue:[^ self].
  1492 	editorView notNil ifTrue:[^ self].
  1493 
  1493 
  1494         self openEditorAction notNil ifTrue:[
  1494 	self openEditorAction notNil ifTrue:[
  1495             self openEditorAtX:x y:y.
  1495 	    self openEditorAtX:x y:y.
  1496             editorView notNil ifTrue:[^ self].
  1496 	    editorView notNil ifTrue:[^ self].
  1497         ].
  1497 	].
  1498 
  1498 
  1499         ignoreReselect ifFalse:[
  1499 	ignoreReselect ifFalse:[
  1500             (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
  1500 	    (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
  1501                 self selection:nil
  1501 		self selection:nil
  1502             ] ifFalse:[
  1502 	    ] ifFalse:[
  1503                 self selectionChanged
  1503 		self selectionChanged
  1504             ].
  1504 	    ].
  1505         ].
  1505 	].
  1506     ] ifFalse:[
  1506     ] ifFalse:[
  1507         (self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
  1507 	(self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
  1508             self selectionChanged
  1508 	    self selectionChanged
  1509         ]
  1509 	]
  1510     ].
  1510     ].
  1511 !
  1511 !
  1512 
  1512 
  1513 buttonRelease:button x:x y:y
  1513 buttonRelease:button x:x y:y
  1514     "a button was released
  1514     "a button was released
  1517 
  1517 
  1518     makeSelectionVisible := modelChangedDuringButtonPress.
  1518     makeSelectionVisible := modelChangedDuringButtonPress.
  1519     buttonMotionAction   := modelChangedDuringButtonPress := nil.
  1519     buttonMotionAction   := modelChangedDuringButtonPress := nil.
  1520 
  1520 
  1521     buttonReleaseAction notNil ifTrue:[
  1521     buttonReleaseAction notNil ifTrue:[
  1522         buttonReleaseAction value.
  1522 	buttonReleaseAction value.
  1523         buttonReleaseAction := nil.
  1523 	buttonReleaseAction := nil.
  1524     ].
  1524     ].
  1525 
  1525 
  1526     self cursorEntersItem:nil.
  1526     self cursorEntersItem:nil.
  1527     self stopAutoScroll.
  1527     self stopAutoScroll.
  1528 
  1528 
  1529     (makeSelectionVisible == true and:[self hasSelection]) ifTrue:[
  1529     (makeSelectionVisible == true and:[self hasSelection]) ifTrue:[
  1530         self makeSelectionVisible
  1530 	self makeSelectionVisible
  1531     ].
  1531     ].
  1532 !
  1532 !
  1533 
  1533 
  1534 characterPress:aKey x:x y:y
  1534 characterPress:aKey x:x y:y
  1535     " a character is pressed - lookup and change selection
  1535     " a character is pressed - lookup and change selection
  1541 
  1541 
  1542     lnNr := self firstInSelection.
  1542     lnNr := self firstInSelection.
  1543     lnNr isNil ifTrue:[lnNr := 0].
  1543     lnNr isNil ifTrue:[lnNr := 0].
  1544 
  1544 
  1545     self sensor shiftDown ifTrue:[
  1545     self sensor shiftDown ifTrue:[
  1546         stp := -1.              "/ search backward
  1546 	stp := -1.              "/ search backward
  1547         to1 :=  1.
  1547 	to1 :=  1.
  1548         fr2 := size.
  1548 	fr2 := size.
  1549     ] ifFalse:[
  1549     ] ifFalse:[
  1550         stp := 1.               "/ search forward
  1550 	stp := 1.               "/ search forward
  1551         to1 := size.
  1551 	to1 := size.
  1552         fr2 := 1.
  1552 	fr2 := 1.
  1553     ].
  1553     ].
  1554 
  1554 
  1555     idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey.
  1555     idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey.
  1556 
  1556 
  1557     idx == 0 ifTrue:[
  1557     idx == 0 ifTrue:[
  1558         idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey.
  1558 	idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey.
  1559         idx == 0 ifTrue:[^ self].
  1559 	idx == 0 ifTrue:[^ self].
  1560     ].
  1560     ].
  1561 
  1561 
  1562     self selection:idx.
  1562     self selection:idx.
  1563 
  1563 
  1564     keyActionStyle == #selectAndDoubleClick ifTrue:[
  1564     keyActionStyle == #selectAndDoubleClick ifTrue:[
  1565         self doubleClicked
  1565 	self doubleClicked
  1566     ].
  1566     ].
  1567 !
  1567 !
  1568 
  1568 
  1569 characterSearchItemStringAt:anIndex
  1569 characterSearchItemStringAt:anIndex
  1570     "for first-character search:
  1570     "for first-character search:
  1574     |item s|
  1574     |item s|
  1575 
  1575 
  1576     item := self at:anIndex ifAbsent:nil.
  1576     item := self at:anIndex ifAbsent:nil.
  1577 
  1577 
  1578     item isHierarchicalItem ifTrue:[
  1578     item isHierarchicalItem ifTrue:[
  1579         item := item string
  1579 	item := item string
  1580     ].
  1580     ].
  1581     item isNil ifTrue:[^ nil].
  1581     item isNil ifTrue:[^ nil].
  1582 
  1582 
  1583     (Error catch:[
  1583     (Error catch:[
  1584         s := item asString
  1584 	s := item asString
  1585     ]) ifTrue:[
  1585     ]) ifTrue:[
  1586         s := item displayString
  1586 	s := item displayString
  1587     ].
  1587     ].
  1588     ^ s
  1588     ^ s
  1589 !
  1589 !
  1590 
  1590 
  1591 containerChangedSize
  1591 containerChangedSize
  1592     "/ stupid kludge for motif-style (which draws a frame at the right-edge)
  1592     "/ stupid kludge for motif-style (which draws a frame at the right-edge)
  1593     "/ cg: I think it should not (see normal SelectionInListView, which does only
  1593     "/ cg: I think it should not (see normal SelectionInListView, which does only
  1594     "/     draw the frame at the top and bottom, but NOT at the left and right
  1594     "/     draw the frame at the top and bottom, but NOT at the left and right
  1595 
  1595 
  1596     self hasSelection ifTrue:[
  1596     self hasSelection ifTrue:[
  1597         (hilightFrameColor notNil 
  1597 	(hilightFrameColor notNil
  1598         or:[hilightStyle == #motif
  1598 	or:[hilightStyle == #motif
  1599         or:[hilightLevel ~~ 0]]) ifTrue:[
  1599 	or:[hilightLevel ~~ 0]]) ifTrue:[
  1600            "/ invalidate the right-edge
  1600 	   "/ invalidate the right-edge
  1601             self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
  1601 	    self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
  1602         ]
  1602 	]
  1603     ].
  1603     ].
  1604 
  1604 
  1605     super containerChangedSize.
  1605     super containerChangedSize.
  1606 !
  1606 !
  1607 
  1607 
  1609     "the cursor enters an item or nil
  1609     "the cursor enters an item or nil
  1610     "
  1610     "
  1611     |lnNr x|
  1611     |lnNr x|
  1612 
  1612 
  1613     (shown and:[self size ~~ 0]) ifFalse:[
  1613     (shown and:[self size ~~ 0]) ifFalse:[
  1614         cursorItem := nil.
  1614 	cursorItem := nil.
  1615         ^ self.  
  1615 	^ self.
  1616     ].
  1616     ].
  1617 
  1617 
  1618     anItemOrNil == cursorItem ifTrue:[ ^ self ].
  1618     anItemOrNil == cursorItem ifTrue:[ ^ self ].
  1619 
  1619 
  1620     2 timesRepeat:[
  1620     2 timesRepeat:[
  1621         cursorItem notNil ifTrue:[
  1621 	cursorItem notNil ifTrue:[
  1622             lnNr := self identityIndexOf:cursorItem.
  1622 	    lnNr := self identityIndexOf:cursorItem.
  1623             lnNr notNil ifTrue:[
  1623 	    lnNr notNil ifTrue:[
  1624                 x := self xVisibleOfItem:cursorItem.
  1624 		x := self xVisibleOfItem:cursorItem.
  1625                 self invalidateLineAt:lnNr fromX:x
  1625 		self invalidateLineAt:lnNr fromX:x
  1626             ].
  1626 	    ].
  1627         ].
  1627 	].
  1628         "/ set the new item
  1628 	"/ set the new item
  1629         cursorItem := anItemOrNil.
  1629 	cursorItem := anItemOrNil.
  1630     ].
  1630     ].
  1631     cursorItem notNil ifTrue:[
  1631     cursorItem notNil ifTrue:[
  1632         self makeLineVisible:lnNr
  1632 	self makeLineVisible:lnNr
  1633     ].
  1633     ].
  1634 !
  1634 !
  1635 
  1635 
  1636 doubleClicked
  1636 doubleClicked
  1637     "handle a double click
  1637     "handle a double click
  1638     "
  1638     "
  1639     |arg|
  1639     |arg|
  1640 
  1640 
  1641     doubleClickActionBlock notNil ifTrue:[
  1641     doubleClickActionBlock notNil ifTrue:[
  1642         arg := self selectedIndex.
  1642 	arg := self selectedIndex.
  1643 
  1643 
  1644         arg ~~ 0 ifTrue:[
  1644 	arg ~~ 0 ifTrue:[
  1645             doubleClickActionBlock valueWithOptionalArgument:arg and:self.
  1645 	    doubleClickActionBlock valueWithOptionalArgument:arg and:self.
  1646         ]
  1646 	]
  1647     ].
  1647     ].
  1648 !
  1648 !
  1649 
  1649 
  1650 findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter
  1650 findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter
  1651     "find a line starting with a character
  1651     "find a line starting with a character
  1654      size     "{ Class:SmallInteger }"
  1654      size     "{ Class:SmallInteger }"
  1655      start    "{ Class:SmallInteger }"
  1655      start    "{ Class:SmallInteger }"
  1656      stop     "{ Class:SmallInteger }"
  1656      stop     "{ Class:SmallInteger }"
  1657     |
  1657     |
  1658     (size := self size) ~~ 0 ifTrue:[
  1658     (size := self size) ~~ 0 ifTrue:[
  1659         aStep > 0 ifTrue:[
  1659 	aStep > 0 ifTrue:[
  1660             aStart > aStop ifTrue:[^ 0].
  1660 	    aStart > aStop ifTrue:[^ 0].
  1661         ] ifFalse:[
  1661 	] ifFalse:[
  1662             (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
  1662 	    (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
  1663         ].
  1663 	].
  1664 
  1664 
  1665         start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
  1665 	start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
  1666         stop  := aStop  < 0 ifTrue:[1] ifFalse:[aStop  min:size].
  1666 	stop  := aStop  < 0 ifTrue:[1] ifFalse:[aStop  min:size].
  1667         char  := aCharacter asUppercase.
  1667 	char  := aCharacter asUppercase.
  1668 
  1668 
  1669         start to:stop by:aStep do:[:anIndex|
  1669 	start to:stop by:aStep do:[:anIndex|
  1670             lbl := self characterSearchItemStringAt:anIndex.
  1670 	    lbl := self characterSearchItemStringAt:anIndex.
  1671             lbl notNil ifTrue:[
  1671 	    lbl notNil ifTrue:[
  1672                 cmp := lbl string at:1 ifAbsent:nil.
  1672 		cmp := lbl string at:1 ifAbsent:nil.
  1673 
  1673 
  1674                 cmp notNil ifTrue:[
  1674 		cmp notNil ifTrue:[
  1675                     (char == cmp or:[char == cmp asUppercase]) ifTrue:[
  1675 		    (char == cmp or:[char == cmp asUppercase]) ifTrue:[
  1676                         (self canSelectIndex:anIndex forAdd:false) ifTrue:[
  1676 			(self canSelectIndex:anIndex forAdd:false) ifTrue:[
  1677                             ^ anIndex
  1677 			    ^ anIndex
  1678                         ].
  1678 			].
  1679                         ^ 0
  1679 			^ 0
  1680                     ]
  1680 		    ]
  1681                 ]
  1681 		]
  1682             ]
  1682 	    ]
  1683         ]
  1683 	]
  1684     ].
  1684     ].
  1685     ^ 0
  1685     ^ 0
  1686 
  1686 
  1687     "Modified: / 15-09-2006 / 11:26:29 / User"
  1687     "Modified: / 15-09-2006 / 11:26:29 / User"
  1688 !
  1688 !
  1690 invalidateLineOfItem:anItem
  1690 invalidateLineOfItem:anItem
  1691     |lnNr x|
  1691     |lnNr x|
  1692 
  1692 
  1693     lnNr := self identityIndexOf:enterItem.
  1693     lnNr := self identityIndexOf:enterItem.
  1694     lnNr notNil ifTrue:[
  1694     lnNr notNil ifTrue:[
  1695         x := self xVisibleOfItem:enterItem.
  1695 	x := self xVisibleOfItem:enterItem.
  1696         self invalidateLineAt:lnNr fromX:x
  1696 	self invalidateLineAt:lnNr fromX:x
  1697     ].
  1697     ].
  1698 !
  1698 !
  1699 
  1699 
  1700 keyPress:aKey x:x y:y
  1700 keyPress:aKey x:x y:y
  1701     "a key was pressed - handle page-keys here
  1701     "a key was pressed - handle page-keys here
  1702     "
  1702     "
  1703     <resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine
  1703     <resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine
  1704                           #BeginOfText #BeginOfLine #Return
  1704 			  #BeginOfText #BeginOfLine #Return
  1705                           #CmdReturn #CmdCursorUp #CmdCursorDown #SelectAll)>
  1705 			  #CmdReturn #CmdCursorUp #CmdCursorDown #SelectAll)>
  1706 
  1706 
  1707     |lineNr listSize shifted newSel step start|
  1707     |lineNr listSize shifted newSel step start|
  1708 
  1708 
  1709     enabled ifFalse:[ ^ self ].
  1709     enabled ifFalse:[ ^ self ].
  1710 
  1710 
  1711     listSize := self size.
  1711     listSize := self size.
  1712     listSize == 0 ifTrue:[^ self].
  1712     listSize == 0 ifTrue:[^ self].
  1713 
  1713 
  1714     aKey isCharacter ifTrue:[
  1714     aKey isCharacter ifTrue:[
  1715         keyActionStyle notNil ifTrue:[
  1715 	keyActionStyle notNil ifTrue:[
  1716             keyActionStyle == #pass ifTrue:[
  1716 	    keyActionStyle == #pass ifTrue:[
  1717                 super keyPress:aKey x:x y:y
  1717 		super keyPress:aKey x:x y:y
  1718             ] ifFalse:[
  1718 	    ] ifFalse:[
  1719                 self characterPress:aKey x:x y:y.
  1719 		self characterPress:aKey x:x y:y.
  1720             ].
  1720 	    ].
  1721         ].
  1721 	].
  1722         ^ self
  1722 	^ self
  1723     ].
  1723     ].
  1724 
  1724 
  1725     aKey == #Escape ifTrue:[
  1725     aKey == #Escape ifTrue:[
  1726         cursorItem notNil ifTrue:[
  1726 	cursorItem notNil ifTrue:[
  1727             self cursorEntersItem:nil.
  1727 	    self cursorEntersItem:nil.
  1728             self makeSelectionVisible.
  1728 	    self makeSelectionVisible.
  1729         ].
  1729 	].
  1730         super keyPress:aKey x:x y:y.
  1730 	super keyPress:aKey x:x y:y.
  1731         ^ self
  1731 	^ self
  1732     ].
  1732     ].
  1733 
  1733 
  1734     ((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[
  1734     ((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[
  1735         self cursorEntersItem:nil.
  1735 	self cursorEntersItem:nil.
  1736 
  1736 
  1737         1 to:listSize do:[:i|
  1737 	1 to:listSize do:[:i|
  1738             (self canSelectIndex:i forAdd:false) ifTrue:[
  1738 	    (self canSelectIndex:i forAdd:false) ifTrue:[
  1739                 self selection:i.
  1739 		self selection:i.
  1740                 ^ self
  1740 		^ self
  1741             ].
  1741 	    ].
  1742         ].
  1742 	].
  1743         ^ self
  1743 	^ self
  1744     ].
  1744     ].
  1745 
  1745 
  1746     ((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[
  1746     ((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[
  1747         self cursorEntersItem:nil.
  1747 	self cursorEntersItem:nil.
  1748 
  1748 
  1749         listSize to:1 by:-1 do:[:i|
  1749 	listSize to:1 by:-1 do:[:i|
  1750             (self canSelectIndex:i forAdd:false) ifTrue:[
  1750 	    (self canSelectIndex:i forAdd:false) ifTrue:[
  1751                 self selection:i.
  1751 		self selection:i.
  1752                 ^ self
  1752 		^ self
  1753             ].
  1753 	    ].
  1754         ].
  1754 	].
  1755         ^ self
  1755 	^ self
  1756     ].
  1756     ].
  1757     lineNr := self cursorLine.
  1757     lineNr := self cursorLine.
  1758 
  1758 
  1759     aKey == #Return ifTrue:[
  1759     aKey == #Return ifTrue:[
  1760         returnKeyActionStyle == #pass ifTrue:[
  1760 	returnKeyActionStyle == #pass ifTrue:[
  1761             super keyPress:aKey x:x y:y
  1761 	    super keyPress:aKey x:x y:y
  1762         ] ifFalse:[
  1762 	] ifFalse:[
  1763             lineNr ~~ 0 ifTrue:[
  1763 	    lineNr ~~ 0 ifTrue:[
  1764                 self cursorEntersItem:nil.
  1764 		self cursorEntersItem:nil.
  1765 
  1765 
  1766                 (self canSelectIndex:lineNr forAdd:false) ifTrue:[
  1766 		(self canSelectIndex:lineNr forAdd:false) ifTrue:[
  1767                     self selection:lineNr
  1767 		    self selection:lineNr
  1768                 ].
  1768 		].
  1769             ].
  1769 	    ].
  1770 
  1770 
  1771             returnKeyActionStyle == #doubleClick ifTrue:[
  1771 	    returnKeyActionStyle == #doubleClick ifTrue:[
  1772                 self doubleClicked
  1772 		self doubleClicked
  1773             ].
  1773 	    ].
  1774         ].
  1774 	].
  1775         ^ self
  1775 	^ self
  1776     ].
  1776     ].
  1777 
  1777 
  1778     aKey == #SelectAll ifTrue:[
  1778     aKey == #SelectAll ifTrue:[
  1779         self selectAll.
  1779 	self selectAll.
  1780         ^ self
  1780 	^ self
  1781     ].
  1781     ].
  1782 
  1782 
  1783     (lineNr == 0 and:[selection notNil]) ifTrue:[
  1783     (lineNr == 0 and:[selection notNil]) ifTrue:[
  1784         multipleSelectOk ifFalse:[lineNr := selection]
  1784 	multipleSelectOk ifFalse:[lineNr := selection]
  1785                           ifTrue:[lineNr := selection last].
  1785 			  ifTrue:[lineNr := selection last].
  1786     ].
  1786     ].
  1787 
  1787 
  1788     aKey == #CmdReturn ifTrue:[
  1788     aKey == #CmdReturn ifTrue:[
  1789         "/ toggle selection of the item
  1789 	"/ toggle selection of the item
  1790         lineNr ~~ 0 ifTrue:[
  1790 	lineNr ~~ 0 ifTrue:[
  1791             (self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ]
  1791 	    (self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ]
  1792                                        ifFalse:[ self addToSelection:lineNr ].
  1792 				       ifFalse:[ self addToSelection:lineNr ].
  1793 
  1793 
  1794             self cursorEntersItem:(self at:lineNr).
  1794 	    self cursorEntersItem:(self at:lineNr).
  1795         ].
  1795 	].
  1796         ^ self
  1796 	^ self
  1797     ].
  1797     ].
  1798 
  1798 
  1799     (aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]) ifTrue:[
  1799     (aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]) ifTrue:[
  1800         aKey == #CmdCursorDown ifTrue:[
  1800 	aKey == #CmdCursorDown ifTrue:[
  1801             lineNr := lineNr + 1.
  1801 	    lineNr := lineNr + 1.
  1802             lineNr > listSize ifTrue:[lineNr := 1].
  1802 	    lineNr > listSize ifTrue:[lineNr := 1].
  1803         ] ifFalse:[
  1803 	] ifFalse:[
  1804             lineNr := lineNr - 1.
  1804 	    lineNr := lineNr - 1.
  1805             lineNr < 1 ifTrue:[lineNr := listSize].
  1805 	    lineNr < 1 ifTrue:[lineNr := listSize].
  1806         ].
  1806 	].
  1807         self cursorEntersItem:(self at:lineNr).
  1807 	self cursorEntersItem:(self at:lineNr).
  1808         ^ self
  1808 	^ self
  1809     ].
  1809     ].
  1810 
  1810 
  1811     (aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[
  1811     (aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[
  1812         super keyPress:aKey x:x y:y.
  1812 	super keyPress:aKey x:x y:y.
  1813         ^ self
  1813 	^ self
  1814     ].
  1814     ].
  1815     shifted := (multipleSelectOk and:[self sensor shiftDown]).
  1815     shifted := (multipleSelectOk and:[self sensor shiftDown]).
  1816     self cursorEntersItem:nil.
  1816     self cursorEntersItem:nil.
  1817 
  1817 
  1818     aKey == #CursorDown ifTrue:[ step :=  1.]
  1818     aKey == #CursorDown ifTrue:[ step :=  1.]
  1819                        ifFalse:[ step := -1.].
  1819 		       ifFalse:[ step := -1.].
  1820 
  1820 
  1821     shifted ifFalse:[ |compressed|
  1821     shifted ifFalse:[ |compressed|
  1822         compressed := self sensor compressKeyPressEventsWithKey:aKey.
  1822 	compressed := self sensor compressKeyPressEventsWithKey:aKey.
  1823 
  1823 
  1824         compressed ~~ 0 ifTrue:[
  1824 	compressed ~~ 0 ifTrue:[
  1825             aKey == #CursorDown ifTrue:[
  1825 	    aKey == #CursorDown ifTrue:[
  1826                 lineNr := lineNr + compressed.
  1826 		lineNr := lineNr + compressed.
  1827                 lineNr > listSize ifTrue:[lineNr := 1].
  1827 		lineNr > listSize ifTrue:[lineNr := 1].
  1828             ] ifFalse:[
  1828 	    ] ifFalse:[
  1829                 lineNr := lineNr - compressed.
  1829 		lineNr := lineNr - compressed.
  1830                 lineNr < 1 ifTrue:[lineNr := listSize].
  1830 		lineNr < 1 ifTrue:[lineNr := listSize].
  1831             ].
  1831 	    ].
  1832         ].
  1832 	].
  1833     ].
  1833     ].
  1834     start  := lineNr.
  1834     start  := lineNr.
  1835     lineNr := lineNr + step.
  1835     lineNr := lineNr + step.
  1836 
  1836 
  1837     [ lineNr ~~ start ] whileTrue:[
  1837     [ lineNr ~~ start ] whileTrue:[
  1838         (lineNr between:1 and:listSize) ifFalse:[
  1838 	(lineNr between:1 and:listSize) ifFalse:[
  1839             lineNr < 1 ifTrue:[ lineNr := listSize ]
  1839 	    lineNr < 1 ifTrue:[ lineNr := listSize ]
  1840                       ifFalse:[ lineNr := 1 ].
  1840 		      ifFalse:[ lineNr := 1 ].
  1841         ] ifTrue:[
  1841 	] ifTrue:[
  1842             (self canSelectIndex:lineNr forAdd:shifted) ifTrue:[
  1842 	    (self canSelectIndex:lineNr forAdd:shifted) ifTrue:[
  1843                 shifted ifFalse:[
  1843 		shifted ifFalse:[
  1844                     self selection:lineNr.
  1844 		    self selection:lineNr.
  1845                     ^ self
  1845 		    ^ self
  1846                 ].
  1846 		].
  1847                 (self isInSelection:lineNr) ifFalse:[
  1847 		(self isInSelection:lineNr) ifFalse:[
  1848                     selection isNil ifTrue:[ newSel := Array with:lineNr ]
  1848 		    selection isNil ifTrue:[ newSel := Array with:lineNr ]
  1849                                    ifFalse:[ newSel := selection copyWith:lineNr ].
  1849 				   ifFalse:[ newSel := selection copyWith:lineNr ].
  1850                 ] ifTrue:[
  1850 		] ifTrue:[
  1851                     (start ~~ 0 and:[selection size > 1]) ifFalse:[
  1851 		    (start ~~ 0 and:[selection size > 1]) ifFalse:[
  1852                         ^ self
  1852 			^ self
  1853                     ].
  1853 		    ].
  1854                     newSel := selection copyWithout:start.
  1854 		    newSel := selection copyWithout:start.
  1855                 ].
  1855 		].
  1856                 self selectWithoutScroll:newSel redraw:true.
  1856 		self selectWithoutScroll:newSel redraw:true.
  1857                 self makeLineVisible:lineNr.
  1857 		self makeLineVisible:lineNr.
  1858                 self selectionChanged.
  1858 		self selectionChanged.
  1859                 ^ self
  1859 		^ self
  1860             ].
  1860 	    ].
  1861             lineNr := lineNr + step.
  1861 	    lineNr := lineNr + step.
  1862         ]
  1862 	]
  1863     ].
  1863     ].
  1864 !
  1864 !
  1865 
  1865 
  1866 pointerEntersItem:anItemOrNil
  1866 pointerEntersItem:anItemOrNil
  1867     "the pointer moves over an item or nil
  1867     "the pointer moves over an item or nil
  1868     "
  1868     "
  1869     |newItem|
  1869     |newItem|
  1870 
  1870 
  1871     (shown and:[self size ~~ 0]) ifFalse:[
  1871     (shown and:[self size ~~ 0]) ifFalse:[
  1872         enterItem := nil.
  1872 	enterItem := nil.
  1873         ^ self.  
  1873 	^ self.
  1874     ].
  1874     ].
  1875 
  1875 
  1876     highlightEnterItem ifTrue:[ newItem := anItemOrNil ]
  1876     highlightEnterItem ifTrue:[ newItem := anItemOrNil ]
  1877                       ifFalse:[ newItem := nil ].
  1877 		      ifFalse:[ newItem := nil ].
  1878 
  1878 
  1879     anItemOrNil == enterItem ifTrue:[ ^ self ].
  1879     anItemOrNil == enterItem ifTrue:[ ^ self ].
  1880 
  1880 
  1881     enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
  1881     enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
  1882     enterItem := anItemOrNil.
  1882     enterItem := anItemOrNil.
  1896     "/ stupid kludge for motif-style (which draws a frame at the right-edge)
  1896     "/ stupid kludge for motif-style (which draws a frame at the right-edge)
  1897     "/ cg: I think it should not (see normal SelectionInListView, which does only
  1897     "/ cg: I think it should not (see normal SelectionInListView, which does only
  1898     "/     draw the frame at the top and bottom, but NOT at the left and right
  1898     "/     draw the frame at the top and bottom, but NOT at the left and right
  1899 
  1899 
  1900     self hasSelection ifTrue:[
  1900     self hasSelection ifTrue:[
  1901         selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
  1901 	selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
  1902 
  1902 
  1903         (hilightFrameColor notNil 
  1903 	(hilightFrameColor notNil
  1904         or:[hilightStyle == #motif
  1904 	or:[hilightStyle == #motif
  1905         or:[hilightLevel ~~ 0]]) ifTrue:[
  1905 	or:[hilightLevel ~~ 0]]) ifTrue:[
  1906            "/ invalidate the right-edge
  1906 	   "/ invalidate the right-edge
  1907             self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
  1907 	    self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
  1908         ].
  1908 	].
  1909     ].
  1909     ].
  1910     super sizeChanged:how.
  1910     super sizeChanged:how.
  1911 
  1911 
  1912     selectionWasVisible ifTrue:[
  1912     selectionWasVisible ifTrue:[
  1913         self makeSelectionVisible
  1913 	self makeSelectionVisible
  1914     ].
  1914     ].
  1915 ! !
  1915 ! !
  1916 
  1916 
  1917 !SelectionInListModelView methodsFor:'focus handling'!
  1917 !SelectionInListModelView methodsFor:'focus handling'!
  1918 
  1918 
  1929 wantsFocusWithPointerEnter
  1929 wantsFocusWithPointerEnter
  1930     "return true, if I want the focus when
  1930     "return true, if I want the focus when
  1931      the mouse pointer enters"
  1931      the mouse pointer enters"
  1932 
  1932 
  1933     (editorView notNil and:[editorView realized]) ifTrue:[
  1933     (editorView notNil and:[editorView realized]) ifTrue:[
  1934         ^ false
  1934 	^ false
  1935     ].
  1935     ].
  1936 
  1936 
  1937     (UserPreferences current focusFollowsMouse ~~ false
  1937     (UserPreferences current focusFollowsMouse ~~ false
  1938     and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true)
  1938     and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true)
  1939     ]) ifTrue:[
  1939     ]) ifTrue:[
  1940         self size > 0 ifTrue:[
  1940 	self size > 0 ifTrue:[
  1941             ^ true
  1941 	    ^ true
  1942         ]
  1942 	]
  1943     ].
  1943     ].
  1944     ^ false
  1944     ^ false
  1945 ! !
  1945 ! !
  1946 
  1946 
  1947 !SelectionInListModelView methodsFor:'initialization & release'!
  1947 !SelectionInListModelView methodsFor:'initialization & release'!
  1963 !
  1963 !
  1964 
  1964 
  1965 initStyle
  1965 initStyle
  1966     "setup viewStyle specifics
  1966     "setup viewStyle specifics
  1967     "
  1967     "
  1968     <resource: #style (#'selection.selectOnMenuButton' 
  1968     <resource: #style (#'selection.selectOnMenuButton'
  1969                        #'selection.font')>
  1969 		       #'selection.font')>
  1970     super initStyle.
  1970     super initStyle.
  1971 
  1971 
  1972     lineMask isNil ifTrue:[
  1972     lineMask isNil ifTrue:[
  1973         lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
  1973 	lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
  1974     ].
  1974     ].
  1975 
  1975 
  1976     hilightFrameColor   := nil.
  1976     hilightFrameColor   := nil.
  1977     hilightStyle        := DefaultHilightStyle.
  1977     hilightStyle        := DefaultHilightStyle.
  1978     highlightMode       := #label.
  1978     highlightMode       := #label.
  1979     textStartLeft       := 4.
  1979     textStartLeft       := 4.
  1980     selectOnMenuButton  := styleSheet at:#'selection.selectOnMenuButton' default:nil.
  1980     selectOnMenuButton  := styleSheet at:#'selection.selectOnMenuButton' default:nil.
  1981     selectOnMenuButton isNil ifTrue:[
  1981     selectOnMenuButton isNil ifTrue:[
  1982         selectOnMenuButton := UserPreferences current selectOnRightClick
  1982 	selectOnMenuButton := UserPreferences current selectOnRightClick
  1983     ].
  1983     ].
  1984 
  1984 
  1985     super font:(styleSheet fontAt:#'selection.font').
  1985     super font:(styleSheet fontAt:#'selection.font').
  1986 
  1986 
  1987     device hasGrayscales ifTrue:[
  1987     device hasGrayscales ifTrue:[
  1988         "
  1988 	"
  1989          must get rid of these hard codings
  1989 	 must get rid of these hard codings
  1990         "
  1990 	"
  1991         (hilightStyle == #next) ifTrue:[
  1991 	(hilightStyle == #next) ifTrue:[
  1992             hilightFgColor := fgColor.
  1992 	    hilightFgColor := fgColor.
  1993             hilightBgColor := White.
  1993 	    hilightBgColor := White.
  1994             hilightFrameColor := fgColor
  1994 	    hilightFrameColor := fgColor
  1995         ] ifFalse:[
  1995 	] ifFalse:[
  1996             (hilightStyle == #motif) ifTrue:[
  1996 	    (hilightStyle == #motif) ifTrue:[
  1997                 fgColor := White.
  1997 		fgColor := White.
  1998                 bgColor := Grey.
  1998 		bgColor := Grey.
  1999                 viewBackground := bgColor.
  1999 		viewBackground := bgColor.
  2000                 hilightFgColor := bgColor.
  2000 		hilightFgColor := bgColor.
  2001                 hilightBgColor := fgColor.
  2001 		hilightBgColor := fgColor.
  2002             ] ifFalse:[
  2002 	    ] ifFalse:[
  2003                 (hilightStyle == #openwin) ifTrue:[
  2003 		(hilightStyle == #openwin) ifTrue:[
  2004                     hilightFgColor := fgColor.
  2004 		    hilightFgColor := fgColor.
  2005                     hilightBgColor := Color grey.
  2005 		    hilightBgColor := Color grey.
  2006                 ]
  2006 		]
  2007             ]
  2007 	    ]
  2008         ]
  2008 	]
  2009     ].
  2009     ].
  2010 
  2010 
  2011     hilightFgColor isNil ifTrue:[
  2011     hilightFgColor isNil ifTrue:[
  2012         hilightFgColor := bgColor.
  2012 	hilightFgColor := bgColor.
  2013     ].
  2013     ].
  2014     hilightBgColor isNil ifTrue:[
  2014     hilightBgColor isNil ifTrue:[
  2015         hilightBgColor := fgColor.
  2015 	hilightBgColor := fgColor.
  2016     ].
  2016     ].
  2017     DefaultForegroundColor notNil ifTrue:[
  2017     DefaultForegroundColor notNil ifTrue:[
  2018         fgColor := DefaultForegroundColor
  2018 	fgColor := DefaultForegroundColor
  2019     ].
  2019     ].
  2020     DefaultBackgroundColor notNil ifTrue:[
  2020     DefaultBackgroundColor notNil ifTrue:[
  2021         bgColor := viewBackground := DefaultBackgroundColor
  2021 	bgColor := viewBackground := DefaultBackgroundColor
  2022     ].
  2022     ].
  2023 
  2023 
  2024     DefaultHilightForegroundColor notNil ifTrue:[
  2024     DefaultHilightForegroundColor notNil ifTrue:[
  2025         hilightFgColor := DefaultHilightForegroundColor
  2025 	hilightFgColor := DefaultHilightForegroundColor
  2026     ].
  2026     ].
  2027     DefaultHilightBackgroundColor notNil ifTrue:[
  2027     DefaultHilightBackgroundColor notNil ifTrue:[
  2028         hilightBgColor := DefaultHilightBackgroundColor
  2028 	hilightBgColor := DefaultHilightBackgroundColor
  2029     ].
  2029     ].
  2030     DefaultHilightFrameColor notNil ifTrue:[
  2030     DefaultHilightFrameColor notNil ifTrue:[
  2031         hilightFrameColor := DefaultHilightFrameColor
  2031 	hilightFrameColor := DefaultHilightFrameColor
  2032     ].
  2032     ].
  2033 
  2033 
  2034     hilightLevel := DefaultHilightLevel ? 0.
  2034     hilightLevel := DefaultHilightLevel ? 0.
  2035     lineSpacing  := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2].
  2035     lineSpacing  := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2].
  2036 
  2036 
  2037     hilightFgColor isNil ifTrue:[
  2037     hilightFgColor isNil ifTrue:[
  2038         hilightFgColor := bgColor.
  2038 	hilightFgColor := bgColor.
  2039         hilightBgColor := fgColor.
  2039 	hilightBgColor := fgColor.
  2040     ].
  2040     ].
  2041 
  2041 
  2042     hilightFgColorNoFocus isNil ifTrue:[
  2042     hilightFgColorNoFocus isNil ifTrue:[
  2043         hilightFgColorNoFocus := hilightFgColor.
  2043 	hilightFgColorNoFocus := hilightFgColor.
  2044     ].
  2044     ].
  2045     hilightBgColorNoFocus isNil ifTrue:[
  2045     hilightBgColorNoFocus isNil ifTrue:[
  2046         hilightBgColorNoFocus := hilightBgColor lightened.
  2046 	hilightBgColorNoFocus := hilightBgColor lightened.
  2047     ].
  2047     ].
  2048 !
  2048 !
  2049 
  2049 
  2050 initialize
  2050 initialize
  2051     "setup default attributes/behavior
  2051     "setup default attributes/behavior
  2083     "update the layout of the editor
  2083     "update the layout of the editor
  2084     "
  2084     "
  2085     |lnNr item y0 x0 y1|
  2085     |lnNr item y0 x0 y1|
  2086 
  2086 
  2087     editorView isNil ifTrue:[
  2087     editorView isNil ifTrue:[
  2088         ^ self
  2088 	^ self
  2089     ].
  2089     ].
  2090 
  2090 
  2091     (    (lnNr := self selectedIndex) == 0
  2091     (    (lnNr := self selectedIndex) == 0
  2092      or:[(item := self at:lnNr ifAbsent:nil) isNil]
  2092      or:[(item := self at:lnNr ifAbsent:nil) isNil]
  2093     ) ifTrue:[
  2093     ) ifTrue:[
  2094         "/ there is no more single selection; thus close the editor
  2094 	"/ there is no more single selection; thus close the editor
  2095         ^ self closeEditor
  2095 	^ self closeEditor
  2096     ].
  2096     ].
  2097 
  2097 
  2098     x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
  2098     x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
  2099     y0 := self yVisibleOfLine:lnNr.
  2099     y0 := self yVisibleOfLine:lnNr.
  2100     y1 := self yVisibleOfLine:(lnNr + 1).
  2100     y1 := self yVisibleOfLine:(lnNr + 1).
  2101 
  2101 
  2102     minimumEditorHeight notNil ifTrue:[
  2102     minimumEditorHeight notNil ifTrue:[
  2103         y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
  2103 	y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
  2104     ].
  2104     ].
  2105     "/ Changed by cg:
  2105     "/ Changed by cg:
  2106     "/ editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h + 2 "- 1") ).
  2106     "/ editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h + 2 "- 1") ).
  2107     editorView layout:( Rectangle left:x0 top:y0-2 right:(width - 1 - margin) bottom:y1 ).
  2107     editorView layout:( Rectangle left:x0 top:y0-2 right:(width - 1 - margin) bottom:y1 ).
  2108 !
  2108 !
  2121 
  2121 
  2122     item := self at:lnNr ifAbsent:nil.
  2122     item := self at:lnNr ifAbsent:nil.
  2123     item isNil ifTrue:[^ self].
  2123     item isNil ifTrue:[^ self].
  2124 
  2124 
  2125     x < (self xVisibleOfItem:item) ifTrue:[
  2125     x < (self xVisibleOfItem:item) ifTrue:[
  2126         "/ not part of the selection frame; ignorre
  2126 	"/ not part of the selection frame; ignorre
  2127         ^ self
  2127 	^ self
  2128     ].
  2128     ].
  2129     editor := self openEditor.
  2129     editor := self openEditor.
  2130     editor isNil ifTrue:[^ self].
  2130     editor isNil ifTrue:[^ self].
  2131 
  2131 
  2132     y0 := (y - editor origin y) max:0.
  2132     y0 := (y - editor origin y) max:0.
  2135     "/ simulate clicking into the editor
  2135     "/ simulate clicking into the editor
  2136 
  2136 
  2137     "/ Changed by cg:
  2137     "/ Changed by cg:
  2138     "/ but only if there was no initial selection
  2138     "/ but only if there was no initial selection
  2139     editor isInputField ifTrue:[
  2139     editor isInputField ifTrue:[
  2140         editor hasSelection ifFalse:[
  2140 	editor hasSelection ifFalse:[
  2141             self sensor 
  2141 	    self sensor
  2142                 pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor);
  2142 		pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor);
  2143                 pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor).
  2143 		pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor).
  2144         ]
  2144 	]
  2145     ].
  2145     ].
  2146 
  2146 
  2147     "/ to clear the selection
  2147     "/ to clear the selection
  2148     self invalidateLineAt:lnNr.
  2148     self invalidateLineAt:lnNr.
  2149 ! !
  2149 ! !
  2185     cachedMaxIdx == 0 ifTrue:[ ^ 0 ].
  2185     cachedMaxIdx == 0 ifTrue:[ ^ 0 ].
  2186 
  2186 
  2187     y1 := cachedLinesY at:cachedMaxIdx.
  2187     y1 := cachedLinesY at:cachedMaxIdx.
  2188 
  2188 
  2189     (minimumEditorHeight notNil and:[openEditorAction notNil]) ifTrue:[
  2189     (minimumEditorHeight notNil and:[openEditorAction notNil]) ifTrue:[
  2190         y0 := cachedLinesY at:(cachedMaxIdx - 1) ifAbsent:0.
  2190 	y0 := cachedLinesY at:(cachedMaxIdx - 1) ifAbsent:0.
  2191         y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
  2191 	y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
  2192     ].
  2192     ].
  2193     ^ y1
  2193     ^ y1
  2194 ! !
  2194 ! !
  2195 
  2195 
  2196 !SelectionInListModelView methodsFor:'selection'!
  2196 !SelectionInListModelView methodsFor:'selection'!
  2199     "add line to selection without scrolling but raise a change notification
  2199     "add line to selection without scrolling but raise a change notification
  2200     "
  2200     "
  2201     |oldSelect forAdd|
  2201     |oldSelect forAdd|
  2202 
  2202 
  2203     (self isInSelection:lineNr) ifTrue:[
  2203     (self isInSelection:lineNr) ifTrue:[
  2204         ^ self
  2204 	^ self
  2205     ].
  2205     ].
  2206 
  2206 
  2207     multipleSelectOk ifTrue:[ forAdd := selection notNil ]
  2207     multipleSelectOk ifTrue:[ forAdd := selection notNil ]
  2208                     ifFalse:[ forAdd := false ].
  2208 		    ifFalse:[ forAdd := false ].
  2209 
  2209 
  2210     (self canSelectIndex:lineNr forAdd:forAdd) ifFalse:[
  2210     (self canSelectIndex:lineNr forAdd:forAdd) ifFalse:[
  2211         ^ self
  2211 	^ self
  2212     ].
  2212     ].
  2213 
  2213 
  2214     self closeEditor.
  2214     self closeEditor.
  2215     self cursorEntersItem:nil.
  2215     self cursorEntersItem:nil.
  2216 
  2216 
  2217     multipleSelectOk ifFalse:[
  2217     multipleSelectOk ifFalse:[
  2218         oldSelect := selection.
  2218 	oldSelect := selection.
  2219         selection := lineNr.
  2219 	selection := lineNr.
  2220         oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ].
  2220 	oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ].
  2221     ] ifTrue:[
  2221     ] ifTrue:[
  2222         selection notNil ifTrue:[ selection := selection copyWith:lineNr ]
  2222 	selection notNil ifTrue:[ selection := selection copyWith:lineNr ]
  2223                         ifFalse:[ selection := OrderedCollection with:lineNr ].
  2223 			ifFalse:[ selection := OrderedCollection with:lineNr ].
  2224     ].
  2224     ].
  2225     self invalidateSelectionAt:lineNr.
  2225     self invalidateSelectionAt:lineNr.
  2226     self selectionChanged.
  2226     self selectionChanged.
  2227 !
  2227 !
  2228 
  2228 
  2255 
  2255 
  2256 isInSelection:aNumber
  2256 isInSelection:aNumber
  2257     "return true, if line, aNumber is in the selection
  2257     "return true, if line, aNumber is in the selection
  2258     "
  2258     "
  2259     multipleSelectOk ifFalse:[
  2259     multipleSelectOk ifFalse:[
  2260         ^ (aNumber == selection)
  2260 	^ (aNumber == selection)
  2261     ].
  2261     ].
  2262     selection notNil ifTrue:[
  2262     selection notNil ifTrue:[
  2263         ^ selection includesIdentical:aNumber
  2263 	^ selection includesIdentical:aNumber
  2264     ].
  2264     ].
  2265     ^ false
  2265     ^ false
  2266 !
  2266 !
  2267 
  2267 
  2268 isSelectionVisible
  2268 isSelectionVisible
  2273 
  2273 
  2274 isSelectionVisibleIn:anExtentPoint
  2274 isSelectionVisibleIn:anExtentPoint
  2275     "returns true if any selected element is visible"
  2275     "returns true if any selected element is visible"
  2276 
  2276 
  2277     self selectionDo:[:aLineNr|
  2277     self selectionDo:[:aLineNr|
  2278         (self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
  2278 	(self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
  2279     ].
  2279     ].
  2280     ^ false
  2280     ^ false
  2281 !
  2281 !
  2282 
  2282 
  2283 lastInSelection
  2283 lastInSelection
  2305 
  2305 
  2306     firstLine := self firstInSelection.
  2306     firstLine := self firstInSelection.
  2307     (firstLine isNil or:[firstLine == 0]) ifTrue:[^ self].
  2307     (firstLine isNil or:[firstLine == 0]) ifTrue:[^ self].
  2308 
  2308 
  2309     self selectionDo:[:aLnNr|
  2309     self selectionDo:[:aLnNr|
  2310         (self lineIsFullyVisible:aLnNr) ifTrue:[^ self].
  2310 	(self lineIsFullyVisible:aLnNr) ifTrue:[^ self].
  2311     ].    
  2311     ].
  2312     self makeLineVisible:(self firstInSelection).
  2312     self makeLineVisible:(self firstInSelection).
  2313 !
  2313 !
  2314 
  2314 
  2315 numberOfSelections
  2315 numberOfSelections
  2316     "return the number of selected items
  2316     "return the number of selected items
  2322 
  2322 
  2323 removeFromSelection:lineNr
  2323 removeFromSelection:lineNr
  2324     "remove line from selection without scrolling but raise a change notification
  2324     "remove line from selection without scrolling but raise a change notification
  2325     "
  2325     "
  2326     (self isInSelection:lineNr) ifFalse:[
  2326     (self isInSelection:lineNr) ifFalse:[
  2327         ^ self
  2327 	^ self
  2328     ].
  2328     ].
  2329     self closeEditor.
  2329     self closeEditor.
  2330     self cursorEntersItem:nil.
  2330     self cursorEntersItem:nil.
  2331 
  2331 
  2332     (multipleSelectOk and:[self numberOfSelections > 1]) ifTrue:[
  2332     (multipleSelectOk and:[self numberOfSelections > 1]) ifTrue:[
  2333         selection := selection copyWithout:lineNr.
  2333 	selection := selection copyWithout:lineNr.
  2334     ] ifFalse:[
  2334     ] ifFalse:[
  2335         selection := nil
  2335 	selection := nil
  2336     ].
  2336     ].
  2337     self invalidateSelectionAt:lineNr.
  2337     self invalidateSelectionAt:lineNr.
  2338     self selectionChanged.
  2338     self selectionChanged.
  2339 !
  2339 !
  2340 
  2340 
  2341 selectAll
  2341 selectAll
  2342     "select all entries. 
  2342     "select all entries.
  2343      Model and/or actionBlock notification IS done."
  2343      Model and/or actionBlock notification IS done."
  2344 
  2344 
  2345     self selectFrom:1 to:self size.
  2345     self selectFrom:1 to:self size.
  2346 !
  2346 !
  2347 
  2347 
  2355 selectElement:anElement ifAbsent:exceptionalValue
  2355 selectElement:anElement ifAbsent:exceptionalValue
  2356     |idx|
  2356     |idx|
  2357 
  2357 
  2358     idx := self identityIndexOf:anElement.
  2358     idx := self identityIndexOf:anElement.
  2359     idx == 0 ifTrue:[
  2359     idx == 0 ifTrue:[
  2360         ^ exceptionalValue value
  2360 	^ exceptionalValue value
  2361     ].
  2361     ].
  2362     self selection:idx
  2362     self selection:idx
  2363 !
  2363 !
  2364 
  2364 
  2365 selectFrom:aStart to:aStop
  2365 selectFrom:aStart to:aStop
  2371 
  2371 
  2372     start := aStart.
  2372     start := aStart.
  2373     stop  := aStop.
  2373     stop  := aStop.
  2374 
  2374 
  2375     aStart < aStop ifTrue:[
  2375     aStart < aStop ifTrue:[
  2376         start := aStart max:1.
  2376 	start := aStart max:1.
  2377         stop  := aStop  min:(self size).
  2377 	stop  := aStop  min:(self size).
  2378         step  := 1.
  2378 	step  := 1.
  2379         start > stop ifTrue:[^ self].
  2379 	start > stop ifTrue:[^ self].
  2380 
  2380 
  2381     ] ifFalse:[
  2381     ] ifFalse:[
  2382         start := aStart min:(self size).
  2382 	start := aStart min:(self size).
  2383         stop  := aStop  max:1.
  2383 	stop  := aStop  max:1.
  2384         step  := -1.
  2384 	step  := -1.
  2385         start < stop ifTrue:[^ self].
  2385 	start < stop ifTrue:[^ self].
  2386     ].
  2386     ].
  2387     nsel := OrderedCollection new.
  2387     nsel := OrderedCollection new.
  2388 
  2388 
  2389     start to:stop by:step do:[:i|
  2389     start to:stop by:step do:[:i|
  2390         (self canSelectIndex:i forAdd:true) ifTrue:[
  2390 	(self canSelectIndex:i forAdd:true) ifTrue:[
  2391             nsel add:i.
  2391 	    nsel add:i.
  2392         ].
  2392 	].
  2393     ].
  2393     ].
  2394 
  2394 
  2395     (self selectWithoutScroll:nsel redraw:true) ifTrue:[
  2395     (self selectWithoutScroll:nsel redraw:true) ifTrue:[
  2396         self selectionChanged
  2396 	self selectionChanged
  2397     ].
  2397     ].
  2398 !
  2398 !
  2399 
  2399 
  2400 selectedElement
  2400 selectedElement
  2401     "return the single selected item or nil
  2401     "return the single selected item or nil
  2402     "
  2402     "
  2403     |index|
  2403     |index|
  2404 
  2404 
  2405     (index := self selectedIndex) ~~ 0 ifTrue:[
  2405     (index := self selectedIndex) ~~ 0 ifTrue:[
  2406         ^ self at:index ifAbsent:nil
  2406 	^ self at:index ifAbsent:nil
  2407     ].
  2407     ].
  2408     ^ nil
  2408     ^ nil
  2409 !
  2409 !
  2410 
  2410 
  2411 selectedIndex
  2411 selectedIndex
  2412     "returns the index of the selected line or 0. If more
  2412     "returns the index of the selected line or 0. If more
  2413      lines are selected, 0 is returned
  2413      lines are selected, 0 is returned
  2414     "
  2414     "
  2415     selection notNil ifTrue:[
  2415     selection notNil ifTrue:[
  2416         multipleSelectOk ifFalse:[ ^ selection ].
  2416 	multipleSelectOk ifFalse:[ ^ selection ].
  2417 
  2417 
  2418         selection size == 1 ifTrue:[
  2418 	selection size == 1 ifTrue:[
  2419             ^ selection at:1
  2419 	    ^ selection at:1
  2420         ]
  2420 	]
  2421     ].
  2421     ].
  2422     ^ 0
  2422     ^ 0
  2423 !
  2423 !
  2424 
  2424 
  2425 selection
  2425 selection
  2426     "return the selection index or collection of indices 
  2426     "return the selection index or collection of indices
  2427      in case of multiple selection enabled
  2427      in case of multiple selection enabled
  2428     "
  2428     "
  2429     ^ selection
  2429     ^ selection
  2430 
  2430 
  2431 !
  2431 !
  2434     "select something or deselect if the argument is nil;
  2434     "select something or deselect if the argument is nil;
  2435      scroll to make the selected line visible.
  2435      scroll to make the selected line visible.
  2436      The model and/or actionBlock IS notified.
  2436      The model and/or actionBlock IS notified.
  2437     "
  2437     "
  2438     (self selectWithoutScroll:something redraw:true) ifTrue:[
  2438     (self selectWithoutScroll:something redraw:true) ifTrue:[
  2439         self makeSelectionVisible.
  2439 	self makeSelectionVisible.
  2440         self selectionChanged
  2440 	self selectionChanged
  2441     ].
  2441     ].
  2442 
  2442 
  2443 !
  2443 !
  2444 
  2444 
  2445 selectionAsCollection
  2445 selectionAsCollection
  2457     "perform aBlock for each nr in the selection.
  2457     "perform aBlock for each nr in the selection.
  2458      For single selection, it is called once for the items nr.
  2458      For single selection, it is called once for the items nr.
  2459      For multiple selections, it is called for each.
  2459      For multiple selections, it is called for each.
  2460     "
  2460     "
  2461     selection notNil ifTrue:[
  2461     selection notNil ifTrue:[
  2462         multipleSelectOk ifTrue:[
  2462 	multipleSelectOk ifTrue:[
  2463             selection do:aBlock
  2463 	    selection do:aBlock
  2464         ] ifFalse:[
  2464 	] ifFalse:[
  2465             aBlock value:selection
  2465 	    aBlock value:selection
  2466         ].
  2466 	].
  2467     ].
  2467     ].
  2468 
  2468 
  2469 
  2469 
  2470 !
  2470 !
  2471 
  2471 
  2472 selectionValue
  2472 selectionValue
  2473     "return the selection value i.e. the text in the selected line.
  2473     "return the selection value i.e. the text in the selected line.
  2474      For multiple selections a collection containing the entries is returned.
  2474      For multiple selections a collection containing the entries is returned.
  2475     "
  2475     "
  2476     multipleSelectOk ifTrue:[
  2476     multipleSelectOk ifTrue:[
  2477         selection isNil ifTrue:[^ #()].
  2477 	selection isNil ifTrue:[^ #()].
  2478         ^ selection collect:[:nr| self at:nr ]
  2478 	^ selection collect:[:nr| self at:nr ]
  2479     ].
  2479     ].
  2480     selection isNil ifTrue:[^ nil].
  2480     selection isNil ifTrue:[^ nil].
  2481     ^ self at:selection ifAbsent:nil.
  2481     ^ self at:selection ifAbsent:nil.
  2482 !
  2482 !
  2483 
  2483 
  2498     "select something or deselect if the argument is nil;
  2498     "select something or deselect if the argument is nil;
  2499      scroll to make the selected line visible.
  2499      scroll to make the selected line visible.
  2500      *** No model and/or actionBlock notification is done here.
  2500      *** No model and/or actionBlock notification is done here.
  2501     "
  2501     "
  2502     (self selectWithoutScroll:something redraw:true) ifTrue:[
  2502     (self selectWithoutScroll:something redraw:true) ifTrue:[
  2503         self makeSelectionVisible
  2503 	self makeSelectionVisible
  2504     ]
  2504     ]
  2505 
  2505 
  2506 ! !
  2506 ! !
  2507 
  2507 
  2508 !SelectionInListModelView methodsFor:'selection private'!
  2508 !SelectionInListModelView methodsFor:'selection private'!
  2517     "return true, if the object identified by its index is selectable
  2517     "return true, if the object identified by its index is selectable
  2518     "
  2518     "
  2519     |item isOk|
  2519     |item isOk|
  2520 
  2520 
  2521     selectConditionBlock notNil ifTrue:[
  2521     selectConditionBlock notNil ifTrue:[
  2522         isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd.
  2522 	isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd.
  2523 
  2523 
  2524         isOk ifFalse:[
  2524 	isOk ifFalse:[
  2525             ^ false
  2525 	    ^ false
  2526         ]
  2526 	]
  2527     ].
  2527     ].
  2528 
  2528 
  2529     item := self at:anIndex ifAbsent:nil.
  2529     item := self at:anIndex ifAbsent:nil.
  2530     item isNil ifTrue:[^ false].
  2530     item isNil ifTrue:[^ false].
  2531 
  2531 
  2532     item isHierarchicalItem ifTrue:[
  2532     item isHierarchicalItem ifTrue:[
  2533         ^ item isSelectable
  2533 	^ item isSelectable
  2534     ].
  2534     ].
  2535     ^ true
  2535     ^ true
  2536 !
  2536 !
  2537 
  2537 
  2538 deselectWithoutRedraw
  2538 deselectWithoutRedraw
  2539     "clear the selection without redraw and scrolling;
  2539     "clear the selection without redraw and scrolling;
  2540      the model and/or actionBlock is notified
  2540      the model and/or actionBlock is notified
  2541     "
  2541     "
  2542     (self selectWithoutScroll:nil redraw:false) ifTrue:[
  2542     (self selectWithoutScroll:nil redraw:false) ifTrue:[
  2543         self selectionChanged
  2543 	self selectionChanged
  2544     ]
  2544     ]
  2545 !
  2545 !
  2546 
  2546 
  2547 selectAndUpdateModelWithoutChangeNotification: aLineNo
  2547 selectAndUpdateModelWithoutChangeNotification: aLineNo
  2548     |arg|
  2548     |arg|
  2562     selection = something ifTrue:[^ false].
  2562     selection = something ifTrue:[^ false].
  2563 
  2563 
  2564     oldSelect := selection.
  2564     oldSelect := selection.
  2565 
  2565 
  2566     (something isNil or:[something == 0]) ifTrue:[
  2566     (something isNil or:[something == 0]) ifTrue:[
  2567         selection := nil
  2567 	selection := nil
  2568     ] ifFalse:[
  2568     ] ifFalse:[
  2569         something isNumber ifTrue:[
  2569 	something isNumber ifTrue:[
  2570             selection := multipleSelectOk ifTrue:[Array with:something]
  2570 	    selection := multipleSelectOk ifTrue:[Array with:something]
  2571                                          ifFalse:[something]
  2571 					 ifFalse:[something]
  2572         ] ifFalse:[
  2572 	] ifFalse:[
  2573             something size == 0 ifTrue:[
  2573 	    something size == 0 ifTrue:[
  2574                 selection := nil
  2574 		selection := nil
  2575             ] ifFalse:[
  2575 	    ] ifFalse:[
  2576                 selection := multipleSelectOk ifTrue:[something]
  2576 		selection := multipleSelectOk ifTrue:[something]
  2577                                              ifFalse:[something at:1]
  2577 					     ifFalse:[something at:1]
  2578             ]
  2578 	    ]
  2579         ]
  2579 	]
  2580     ].
  2580     ].
  2581     selection = oldSelect ifTrue:[^ false].
  2581     selection = oldSelect ifTrue:[^ false].
  2582 
  2582 
  2583     modelChangedDuringButtonPress notNil ifTrue:[
  2583     modelChangedDuringButtonPress notNil ifTrue:[
  2584         modelChangedDuringButtonPress := true.
  2584 	modelChangedDuringButtonPress := true.
  2585     ].
  2585     ].
  2586 
  2586 
  2587     self closeEditor.
  2587     self closeEditor.
  2588     self cursorEntersItem:nil.
  2588     self cursorEntersItem:nil.
  2589 
  2589 
  2590     
  2590 
  2591     (doRedraw and:[shown]) ifFalse:[
  2591     (doRedraw and:[shown]) ifFalse:[
  2592         ^ true
  2592 	^ true
  2593     ].
  2593     ].
  2594 
  2594 
  2595     multipleSelectOk ifFalse:[
  2595     multipleSelectOk ifFalse:[
  2596         oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
  2596 	oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
  2597         selection notNil ifTrue:[self invalidateSelectionAt:selection].
  2597 	selection notNil ifTrue:[self invalidateSelectionAt:selection].
  2598     ] ifTrue:[
  2598     ] ifTrue:[
  2599         (selection notNil and:[oldSelect notNil]) ifTrue:[
  2599 	(selection notNil and:[oldSelect notNil]) ifTrue:[
  2600             selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
  2600 	    selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
  2601             oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
  2601 	    oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
  2602         ] ifFalse:[
  2602 	] ifFalse:[
  2603             oldSelect isNil ifTrue:[oldSelect := selection].
  2603 	    oldSelect isNil ifTrue:[oldSelect := selection].
  2604             oldSelect do:[:i|self invalidateSelectionAt:i]
  2604 	    oldSelect do:[:i|self invalidateSelectionAt:i]
  2605         ]
  2605 	]
  2606     ].
  2606     ].
  2607     ^ true
  2607     ^ true
  2608 ! !
  2608 ! !
  2609 
  2609 
  2610 !SelectionInListModelView class methodsFor:'documentation'!
  2610 !SelectionInListModelView class methodsFor:'documentation'!
  2611 
  2611 
  2612 version
  2612 version
  2613     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.143 2009-05-27 06:05:59 ca Exp $'
  2613     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.144 2009-08-07 10:50:41 sr Exp $'
  2614 ! !
  2614 ! !