SelectionInListModelView.st
author Claus Gittinger <cg@exept.de>
Thu, 27 Jun 2013 16:02:41 +0200
changeset 4258 d6ea83906c4e
parent 4242 20d8ff7dc6a9
child 4273 d56dfb04df83
permissions -rw-r--r--
class: SelectionInListModelView comment/format in: #contentsChanged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     1
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
     3
	      All Rights Reserved
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     4
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     5
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     6
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     9
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    10
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    11
"
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    13
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ListModelView subclass:#SelectionInListModelView
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
    15
	instanceVariableNames:'selection multipleSelectOk selectOnButtonMenu actionBlock
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    16
		doubleClickActionBlock selectConditionBlock buttonMotionAction
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    17
		buttonReleaseAction highlightMode useIndex ignoreReselect
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    18
		toggleSelect hilightFgColor hilightBgColor hilightFgColorNoFocus
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    19
		hilightBgColorNoFocus hilightLevel hilightFrameColor hilightStyle
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    20
		dropSource editorView openEditorAction closeEditorAction
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    21
		highlightEnterItem enterItem cursorItem lineMask keyActionStyle
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
    22
		returnKeyActionStyle strikeOut modelChangedDuringButtonPress
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
    23
		selectOnButtonPress selectOnMenuButton minimumEditorHeight
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
    24
		extraSpaceAtBottomForDrop'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
		DefaultHilightForegroundColor DefaultHilightLevel
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
		DefaultHilightFrameColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
	poolDictionaries:''
1430
ae9e48cc7b9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1423
diff changeset
    29
	category:'Views-Lists'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    34
claus
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    35
"
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    36
self claus
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    37
"
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    38
    |top list view|
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    39
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    40
    list := List new.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    41
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    42
    1 to:100 do:[:i| list add:('element: ', i printString) ].
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    43
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    44
    top  := StandardSystemView new; extent:300@300.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    45
    view := ScrollableView for:SelectionInListModelView miniScroller:true
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    46
			origin:0.0@0.0 corner:1.0@1.0 in:top.
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    47
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    48
    view minimumEditorHeight:100.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    49
    view openEditorAction:[:ln :aGC| |f|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    50
	f := SimpleView in:aGC.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    51
	f viewBackground:(Color red).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    52
	f
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    53
    ].
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    54
    view list:list.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    55
    top  open.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    56
!
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
    57
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    58
copyright
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    59
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    60
 COPYRIGHT (c) 1999 by eXept Software AG
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    61
	      All Rights Reserved
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    62
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    63
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    64
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    65
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    66
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    67
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    68
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    69
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    70
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    71
!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    72
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
documentation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    SelectionInListModelView is mostly like SelectionInListView,
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    but derives from the ListModelView and thus the list is kept
3387
6da21b625d1e warning comments
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    77
    in the list.
6da21b625d1e warning comments
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    78
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    [Instance variables:]
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    80
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    81
	selection               <misc>       the current selection. nil, a number or collection of numbers
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    82
	multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    83
	selectOnButtonMenu      <Boolean>    enable/disable selection will change on menu pressed
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    84
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    85
	buttonReleaseAction     <Action>     called if the mouse button is released
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    86
	buttonMotionAction      <Action>     called during mouse motion with one argument the point
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    87
					     under the mouse.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    88
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    89
	actionBlock             <Block>      action evaluated on single click (0/1/2 arguments)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    90
	doubleClickActionBlock  <Block>      action evaluated on double click (0/1/2 arguments)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    91
	selectConditionBlock    <Block>      action evaluated before selection changed (0/1/2 arguments)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    92
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    93
	keyActionStyle          <Symbol>     controls how to respond to keyboard selects
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    94
	returnKeyActionStyle    <Symbol>     controls how to respond to return key
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    95
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    96
	useIndex                <Boolean>    representation of the model selection
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    97
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    98
	ignoreReselect          <Boolean>    if set, a click on an already selected entry is ignored
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    99
	toggleSelect            <Boolean>    a click on an entry unselects it and vice versa
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   100
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   101
	highlightMode           <Symbol>     how to draw the selection
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   102
	hilightFgColor          <Color>      foregroundColor of highlighted items
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   103
	hilightBgColor          <Color>      backgroundColor of highlighted items
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   104
	hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   105
	hilightFrameColor       <Color>      rectangle around highlighted items
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   106
	hilightStyle            <Boolean>    actions on widget are enabled/disabled
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   107
	strikeOut               <Boolean>    turn on/off strikeOut mode
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   108
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   109
	dropTarget              <DropTarget> keeps information about the drop operation
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   110
	dropSource              <DropSource> keeps information about the drag operation
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   111
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   112
	editorView              <View>       editor on current selected item
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   113
	openEditorAction        <Action>     action to get an editor on the current selection from user
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   114
	closeEditorAction       <Action>     action invoked before the editor is closed.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   115
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   116
	enterItem               <Item/nil>   item over which the mouse pointer is located
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   117
					     or nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   118
	highlightEnterItem      <Boolean>    enable or disable highlight of enterItem
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   119
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    [author:]
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   121
	Claus Atzkern
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    [see also:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   125
	ListModelView
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   126
	HierarchicalListView
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
examples
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
"
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   132
									[exBegin]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    |top list view|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    list := List new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    1 to:100 do:[:i| list add:('element: ', i printString) ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    view := ScrollableView for:SelectionInListModelView miniScroller:true
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   140
			origin:0.0@0.0 corner:1.0@1.0 in:top.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    top  open.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   143
									[exEnd]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   144
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   145
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   146
									[exBegin]
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   147
    |top list view|
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   148
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   149
    list := List new.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   150
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   151
    1 to:100 do:[:i| list add:('element: ', i printString) ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   152
    top  := StandardSystemView new; extent:300@300.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   153
    view := ScrollableView for:SelectionInListModelView miniScroller:true
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   154
			origin:0.0@0.0 corner:1.0@1.0 in:top.
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   155
    view list:list.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   156
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   157
    view openEditorAction:[:ln :aGC| |field|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   158
	field := EditField new.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   159
	field level:0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   160
	field acceptOnLostFocus:true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   161
	field acceptAction:[:x| list at:ln put:(field contents) ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   162
	field font:(aGC font).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   163
	field contents:(list at:ln).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   164
	field
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   165
    ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   166
    top open.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   167
									[exEnd]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   168
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   169
									[exBegin]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    |top list view item|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    list := HierarchicalList new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    item := HierarchicalItem::Example labeled:'Test'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    item expand.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    list showRoot:false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    list root:item.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    view := ScrollableView for:SelectionInListModelView miniScroller:true
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   180
			origin:0.0@0.0 corner:1.0@1.0 in:top.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    view doubleClickAction:[:i| (list at:i) toggleExpand ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    top  open.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   185
									[exEnd]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
!SelectionInListModelView class methodsFor:'defaults'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    "extract values from the styleSheet and cache them in class variables"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    <resource: #style   (
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   196
                        #'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   197
                        #'selection.hilightFrameColor'      #'selection.hilightLevel'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   198
                        #'selection.foregroundColor'        #'selection.backgroundColor'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   199
                        #'selection.shadowColor'            #'selection.lightColor'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   200
                        #'selection.font'                   #'selection.hilightStyle'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   201
                        #'text.foregroundColor'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   202
                        )>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    DefaultHilightForegroundColor  := StyleSheet colorAt:'selection.hilightForegroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    DefaultHilightBackgroundColor  := StyleSheet colorAt:'selection.hilightBackgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    DefaultHilightFrameColor       := StyleSheet colorAt:'selection.hilightFrameColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    DefaultHilightLevel            := StyleSheet at:'selection.hilightLevel' default:0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    DefaultHilightStyle            := StyleSheet at:'selection.hilightStyle' default:(StyleSheet name).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    DefaultForegroundColor         := StyleSheet colorAt:'selection.foregroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    DefaultBackgroundColor         := StyleSheet colorAt:'selection.backgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    DefaultShadowColor             := StyleSheet colorAt:'selection.shadowColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    DefaultLightColor              := StyleSheet colorAt:'selection.lightColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    DefaultForegroundColor isNil ifTrue:[
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   215
        DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    ].
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   217
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   218
    DefaultFont := SelectionInListView defaultFont. 
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   219
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
     self updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   224
    "Modified: / 14-08-2010 / 11:55:20 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
!SelectionInListModelView methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   229
cursorLine
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   230
    "returns the index of the cursor line or 0
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   231
    "
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   232
    |index|
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   233
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   234
    cursorItem isNil ifTrue:[^ 0 ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   235
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   236
    index := self identityIndexOf:cursorItem.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   237
    index == 0 ifTrue:[ cursorItem := nil ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   238
    ^ index
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   239
!
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   240
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
list:aList
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   242
    self deselectWithoutRedraw.
2867
bbdc2721ec0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
   243
    ^ super list:aList
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
   246
!SelectionInListModelView methodsFor:'accessing-actions'!
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   247
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   248
action
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   249
    "get the action block to be performed on select
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   250
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   251
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   252
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   253
	-  1 argument     index or item
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   254
	-  2 argument     index or item, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   255
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   256
    ^ actionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   257
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   258
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   259
action:aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   260
    "set the action block to be performed on select
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   261
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   262
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   263
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   264
	-  1 argument     index or item
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   265
	-  2 argument     index or item, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   266
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   267
    actionBlock := aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   268
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   269
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   270
doubleClickAction
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   271
    "get the action block to be performed on doubleclick.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   272
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   273
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   274
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   275
	-  1 argument     selectedIndex
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   276
	-  2 argument     selectedIndex, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   277
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   278
    ^ doubleClickActionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   279
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   280
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   281
doubleClickAction:aOneArgAction
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   282
    "set the action block to be performed on doubleclick.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   283
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   284
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   285
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   286
	-  1 argument     selectedIndex
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   287
	-  2 argument     selectedIndex, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   288
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   289
    doubleClickActionBlock := aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   290
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   291
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   292
keyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   293
    "defines how the view should respond to alpha-keys pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   294
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   295
	#select               -> will select next entry starting with that
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   296
				 character and perform the click-action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   297
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   298
	#selectAndDoubleclick -> will select next & perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   299
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   300
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   301
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   302
	nil                   -> will ignore key
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   303
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   304
     the default (set in #initialize) is #select
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   305
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   306
    ^ keyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   307
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   308
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   309
keyActionStyle:aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   310
    "defines how the view should respond to alpha-keys pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   311
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   312
	#select               -> will select next entry starting with that
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   313
				 character and perform the click-action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   314
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   315
	#selectAndDoubleclick -> will select next & perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   316
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   317
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   318
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   319
	nil                   -> will ignore key
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   320
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   321
     the default (set in #initialize) is #select
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   322
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   323
    keyActionStyle := aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   324
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   325
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   326
returnKeyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   327
    "defines how the view should respond to a return key pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   328
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   329
	#doubleClick          -> perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   330
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   331
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   332
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   333
	nil                   -> will ignore key
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   334
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   335
     the default (set in #initialize) is #doubleClick
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   336
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   337
    ^ returnKeyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   338
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   339
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   340
returnKeyActionStyle:aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   341
    "defines how the view should respond to a return key pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   342
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   343
	#doubleClick          -> perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   344
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   345
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   346
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   347
	nil                   -> will ignore key
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   348
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   349
     the default (set in #initialize) is #doubleClick
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   350
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   351
    returnKeyActionStyle := aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   352
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   353
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   354
selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   355
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   356
     change is performed; the change will not be done, if the evaluation
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   357
     returns false
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   358
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   359
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   360
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   361
	-  1 argument     index
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   362
	-  2 argument     index, isForAdd
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   363
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   364
    ^ selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   365
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   366
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   367
selectConditionBlock:aOneArgBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   368
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   369
     change is performed; the change will not be done, if the evaluation
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   370
     returns false.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   371
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   372
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   373
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   374
	-  1 argument     index
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   375
	-  2 argument     index, isForAdd
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   376
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   377
    selectConditionBlock := aOneArgBlock.
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   378
! !
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   379
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   380
!SelectionInListModelView methodsFor:'accessing-attributes'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   382
highlightEnterItem
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   383
    "enable or disable to highlight the item over which the mouse pointer is located
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   384
    "
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   385
    ^ highlightEnterItem
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   386
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   387
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   388
highlightEnterItem:aBool
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   389
    "enable or disable to highlight the item over which the mouse pointer is located
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   390
    "
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   391
    highlightEnterItem ~~ aBool ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   392
	highlightEnterItem := aBool.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   393
	self pointerEntersItem:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   394
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   395
	highlightEnterItem ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   396
	    self enableMotionEvents
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   397
	].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   398
    ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   399
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   400
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
    "get the mode how to draw a selected line:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   403
	#line           draw whole line selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   404
	#label          draw label selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   405
	#dropMode       set during drop
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    ^ highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
highlightMode:aMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    "set the mode how to draw a selected line:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   412
	#line           draw whole line selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   413
	#label          draw label selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   414
	#dropMode       set during drop
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   416
    highlightMode ~~ aMode ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   417
	highlightMode := aMode.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   418
	self invalidateSelection.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   419
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   420
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   421
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   422
highlightWithUnderline
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   423
    ^ false
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   424
!
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   425
2644
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   426
hilightBackgroundColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   427
    "returns the color used for the hilighted background
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   428
    "
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   429
    ^ hilightBgColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   430
!
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   431
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   432
hilightForegroundColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   433
    "returns the color used for the hilighted foreground
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   434
    "
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   435
    ^ hilightFgColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   436
!
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   437
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   438
strikeout
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   439
    "turn on/off strikeOut mode
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   440
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   441
    ^ strikeOut
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   444
strikeout:aBoolean
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   445
    "turn on/off strikeOut mode
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   446
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   447
    strikeOut ~~ aBoolean ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   448
	strikeOut := aBoolean.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   449
	self invalidateSelection.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   450
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   451
! !
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   452
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   453
!SelectionInListModelView methodsFor:'accessing-behavior'!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   454
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   455
ignoreReselect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   456
    "get the ignoreReselect flag - see method #ignoreReselect: for more details
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   457
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   458
    ^ ignoreReselect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   459
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   460
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   461
ignoreReselect:aBoolean
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   462
    "set/clear the ignoreReselect flag -
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   463
     if set, a click on an already selected entry is ignored.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   464
     Otherwise the notification is done, even if no
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   465
     change in the selection occurs.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   466
     (for example, in browser to update a method).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   467
     Setting ignoreReselect to false makes sense if data is shown
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   468
     which may change by itself (i.e. without the user doing anything)
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   469
     For example, the inspector uses this, and redisplays the value,
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   470
     if the selection is the same.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   471
     The default is true, meaning that a click on an already selected
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   472
     does not lead to a notification via the actionBlock/change mechanism.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   473
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   474
    ignoreReselect := aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   475
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   476
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   477
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
multipleSelectOk
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
    "allow/disallow multiple selections; the default is false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
    ^ multipleSelectOk
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
multipleSelectOk:aState
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   487
    "allow/disallow multiple selections. If enabled, the
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   488
     user may select multiple entries in the list, and the program
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   489
     always gets a collection of selected items (indexes if useIndex is true,
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   490
     values otherwise). The default is false, for single selections.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
    "
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   492
    |state|
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   493
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   494
    state := aState ? false.
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   495
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   496
    multipleSelectOk == state ifTrue:[ ^ self ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   497
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   498
    selection isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   499
	multipleSelectOk := state.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   500
	^ self.
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   501
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   502
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   503
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   504
	selection := Array with:selection.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   505
	multipleSelectOk := true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   506
	^ self
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   507
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   508
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   509
    selection size == 1 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   510
	selection := selection first.
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   511
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   512
	self selection:nil
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   513
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   514
    multipleSelectOk := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   517
selectOnButtomMenu
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   518
    <resource: #obsolete>
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   519
    self obsoleteMethodWarning:'use selectOnButtonMenu'.
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   520
    ^ self selectOnButtonMenu
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   521
!
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   522
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   523
selectOnButtomMenu:aBoolean
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   524
    <resource: #obsolete>
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   525
    self obsoleteMethodWarning:'use selectOnButtonMenu:'.
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   526
    ^ self selectOnButtonMenu:aBoolean
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   527
!
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   528
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   529
selectOnButtonMenu
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   530
    <resource: #obsolete>
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   531
    "define the button-menu-press behavior; if true the line under the mouse
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   532
     will be selected before the menu is opened. Otherwise the menu is opened
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   533
     on the current selection."
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   534
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   535
    self obsoleteMethodWarning:'use selectOnMenuButton'.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   536
    ^ self selectOnMenuButton
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   537
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   538
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   539
selectOnButtonMenu:aBoolean
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   540
    <resource: #obsolete>
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   541
    "define the button-menu-press behavior; if true the line under the mouse
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   542
     will be selected before the menu is opened. Otherwise the menu is opened
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   543
     on the current selection."
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   544
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   545
    self obsoleteMethodWarning:'use selectOnMenuButton:'.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   546
    self selectOnMenuButton:aBoolean.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   547
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   548
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   549
selectOnButtonPress
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   550
    "get the selectOnButtonPress flag - see method #selectOnButtonPress: for more details
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   551
    "
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   552
    ^ selectOnButtonPress ? true
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   553
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   554
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   555
selectOnButtonPress:aBoolean
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   556
    "set/clear the selectOnButtonPress flag -
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   557
     if set (default), the selection changed on button press. This was the
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   558
     behaviour until now.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   559
     if cleared, the selection is changed on button release. This new behaviour allows to start
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   560
     a drag without changing the real selection. The selection is changed during the
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   561
     drag and restored after the drop.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   562
    "
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   563
    selectOnButtonPress := aBoolean
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   564
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   565
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   566
selectOnMenuButton
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   567
    "define the button-menu-press behavior; if true the line under the mouse
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   568
     will be selected before the menu is opened. Otherwise the menu is opened
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   569
     on the current selection."
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   570
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
   571
    selectOnMenuButton isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   572
	^ UserPreferences current selectOnRightClick
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
   573
    ].
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   574
    ^ selectOnMenuButton
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   575
!
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   576
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   577
selectOnMenuButton:aBoolean
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   578
    "define the button-menu-press behavior; if true the line under the mouse
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   579
     will be selected before the menu is opened. Otherwise the menu is opened
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   580
     on the current selection."
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   581
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   582
    selectOnMenuButton := aBoolean.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   583
!
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   584
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   585
toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   586
    "get the toggleSelect flag - see method #toggleSelect: for more details
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   587
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   588
    ^ toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   589
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   590
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   591
toggleSelect:aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   592
    "turn on/off toggle select. If true, clicking on a selected entry
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   593
     unselects it and vice versa. The default is false, which means
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   594
     that clicking on an already selected entry does not change its
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   595
     select status (see also ignoreReselect:).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   596
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   597
    toggleSelect := aBoolean.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   598
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   599
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   600
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   601
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    ^ useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
useIndex:aBoolean
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    useIndex := aBoolean ? true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   622
!SelectionInListModelView methodsFor:'accessing-editor'!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   623
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   624
closeEditor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   625
    "close the current editor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   626
    "
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   627
    |editor action|
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   628
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   629
    (editor := editorView) notNil ifTrue:[
2856
d3a3253d3851 forget editor after it really did close itself.
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
   630
"/        editorView := nil.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   631
	action := self closeEditorAction.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   632
	action notNil ifTrue:[action value:editor.].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   633
	editor destroy.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   634
	editorView := nil.
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   635
    ].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   636
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   637
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   638
closeEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   639
    "get the block which is evaluated before the editor is closed; the argument
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   640
     to the action is the editor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   641
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   642
    ^ closeEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   643
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   644
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   645
closeEditorAction:anOneArgAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   646
    "get the block which is evaluated before the editor is closed; the argument
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   647
     to the action is the editor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   648
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   649
    closeEditorAction := anOneArgAction.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   650
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   651
2527
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   652
hasOpenEditor
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   653
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   654
    ^ editorView notNil
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   655
!
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   656
3524
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   657
minimumEditorHeight
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   658
    "answer the minumium height of the editor or nil.
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   659
     If the height is nil the height of the line is used"
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   660
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   661
    ^ minimumEditorHeight
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   662
!
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   663
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   664
minimumEditorHeight:aHeightOrNil
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   665
    "set the minumium height of the editor or nil.
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   666
     If the height is nil the height of the line is used"
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   667
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   668
    minimumEditorHeight := aHeightOrNil.
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   669
!
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   670
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   671
openEditor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   672
    "opens the editor on the current selection;
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   673
     returns the editorView or nil if no openEditorAction is defined
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   674
     or no single selection exists ...
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   675
    "
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   676
    |lnNr action|
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   677
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   678
    self closeEditor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   679
    shown ifFalse:[^ nil].
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   680
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   681
    action := self openEditorAction.
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   682
    action isNil ifTrue:[^ nil].
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   683
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   684
    lnNr := self selectedIndex.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   685
    lnNr == 0 ifTrue:[^ nil].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   686
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   687
    self makeSelectionVisible.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   688
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   689
    editorView := action valueWithOptionalArgument:lnNr and:self.
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   690
    editorView isNil ifTrue:[^ nil].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   691
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   692
    editorView superView isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   693
	self addSubView:editorView
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   694
    ].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   695
    self computeEditorLayout.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   696
    editorView realize.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   697
    self windowGroup focusView:editorView.
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   698
    ^ editorView
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   699
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   700
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   701
openEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   702
    "get the block which is evaluated to get the editor which is set for the
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   703
     line; the arguments to the block is the line number and the widget itself
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   704
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   705
    ^ openEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   706
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   707
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   708
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   709
openEditorAction:aTwoArgAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   710
    "set the block which is evaluated to get the editor which is set for the
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   711
     line; the arguments to the block is the line number and the widget itself
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   712
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   713
    openEditorAction := aTwoArgAction.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   714
! !
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   715
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
!SelectionInListModelView methodsFor:'change & update'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
argForChangeMessage
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
    "return the argument for a selectionChange;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
     depending on the setting of useIndex, this is either the numeric
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
     index of the selection or the value (i.e. the string)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   723
    useIndex         ifFalse:[ ^ self selectionValue ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   724
    multipleSelectOk ifFalse:[ ^ selection ? 0 ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   725
    ^ selection ? #()
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   728
contentsChanged
4258
d6ea83906c4e class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4242
diff changeset
   729
    "this one is sent, whenever contents changes its size"
d6ea83906c4e class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4242
diff changeset
   730
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   731
    super contentsChanged.
3482
1ee6b7daa983 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3461
diff changeset
   732
    self computeEditorLayout.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   733
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   734
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   735
lineChangedAt:aLnNr with:arg
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   736
    super lineChangedAt:aLnNr with:arg.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   737
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   738
    (editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   739
	self computeEditorLayout.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   740
    ]
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   741
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   742
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
listSizeChanged:aLnNr nLines:aDeltaLines
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   744
    |changed cnts|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
    super listSizeChanged:aLnNr nLines:aDeltaLines.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
    selection isNil ifTrue:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   750
    self size == 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   751
	selection := nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   752
	^ self selectionChanged
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   755
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   756
	selection < aLnNr ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   757
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   758
	selection := selection + aDeltaLines.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   759
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   760
	(aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   761
	    selection := nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   762
	    ^ self selectionChanged
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   763
	]
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   764
    ] ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   765
	changed := false.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   766
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   767
	aDeltaLines < 0  ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   768
	    selection keysAndValuesDo:[:i :ln|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   769
		ln >= aLnNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   770
		    changed := true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   771
		    selection at:i put:(ln + aDeltaLines)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   772
		]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   773
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   774
	] ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   775
	    cnts := 0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   776
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   777
	    selection keysAndValuesDo:[:i :ln||new|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   778
		ln >= aLnNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   779
		    changed := true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   780
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   781
		    (new := ln + aDeltaLines) < aLnNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   782
			cnts := cnts + 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   783
			new  := nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   784
		    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   785
		    selection at:i put:new
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   786
		]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   787
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   788
	    cnts ~~ 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   789
		cnts == selection size ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   790
		    selection := nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   791
		] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   792
		    selection := selection select:[:ln| ln notNil]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   793
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   794
		^ self selectionChanged.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   795
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   796
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   797
	changed ifFalse:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   800
    (useIndex and:[model notNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   801
	model setValue:(self argForChangeMessage)
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   802
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   805
originChanged:delta
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   806
    "setup the origin of the editing view
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   807
    "
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   808
    self computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   809
    super originChanged:delta.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   810
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   811
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   812
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   813
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
selectionChanged
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
    "selection has changed. Call actionblock and/or send changeMessage if defined
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   817
    |arg|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   819
    self closeEditor.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   820
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
    (model isNil and:[actionBlock isNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   822
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
    arg := self argForChangeMessage.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
    model notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   828
	model removeDependent:self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   829
	"/ change models value to force a change notification: reselect mode
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   830
	arg = model value ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   831
	    model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   832
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   833
	self sendChangeMessage:#value: with:arg.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   834
	model notNil ifTrue:[  "/ argggh could be nilled
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   835
	    model addDependent:self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   836
	    self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   837
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
    actionBlock notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   841
	actionBlock valueWithOptionalArgument:arg and:self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   845
updateFromModel
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   846
    "update selection from the model
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   847
    "
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   848
    |value newSelection|
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   849
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   850
    model isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   851
	^ self
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   852
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
   853
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
   854
    buttonMotionAction notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   855
	"running in button motion; discard change notification
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   856
	"
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   857
	^ self
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   858
    ].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   859
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   860
    value := model value.
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   861
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   862
    (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   863
	multipleSelectOk ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   864
	    newSelection := self identityIndexOf:value
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   865
	] ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   866
	    value size == 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   867
		newSelection := nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   868
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   869
		newSelection := OrderedCollection new.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   870
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   871
		value do:[:e||index|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   872
		    index := self identityIndexOf:e.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   873
		    index ~~ 0 ifTrue:[ newSelection add:index ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   874
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   875
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   876
		newSelection isEmpty ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   877
		    newSelection := nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   878
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   879
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   880
	].
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   881
    ] ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   882
	newSelection := value copy
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   883
    ].
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   884
    self setSelection:newSelection.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
!SelectionInListModelView methodsFor:'drag & drop'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
canDrag
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   890
    "returns true if dragging is enabled"
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   891
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
    ^ dropSource notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   894
    "Modified: / 18-07-2010 / 09:07:20 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   897
dragAutoScroll:aContext
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   898
    "called by the DragAndDropManager to scroll during a drag/drop operation
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   899
     if necassery (decided by the widget itself); If a scroll is done return
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   900
     true otherwise false (used to restore the background)"
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   901
3899
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   902
    |scrollUp targetY deltaY pixels|
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   903
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   904
    targetY  := aContext targetPoint y.
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   905
    scrollUp := (targetY < (height // 2)).
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   906
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   907
    scrollUp ifTrue:[
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   908
        self yOriginOfContents = 0 ifTrue:[ ^ false].
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   909
        deltaY := targetY.
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   910
    ] ifFalse:[
3899
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   911
        deltaY := height - targetY.
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   912
        self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ].
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   913
    ].
3899
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   914
    pixels := 24 min:(height // 4).
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   915
    deltaY > pixels ifTrue:[^ false].
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   916
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   917
    deltaY <= (pixels // 2) ifTrue:[
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   918
        deltaY <= (pixels // 4)
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   919
            ifTrue:[ pixels := pixels * 3]
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   920
            ifFalse:[ pixels := pixels * 2 ].            
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   921
    ].
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   922
    aContext contentsWillChange.
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   923
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   924
    scrollUp 
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   925
        ifTrue:[ self scrollUp:pixels ]
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   926
        ifFalse:[ self scrollDown:pixels ].
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   927
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   928
    ^ true
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   929
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   930
    "Modified: / 18-07-2010 / 09:08:29 / cg"
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   931
!
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   932
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
dropSource
2891
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   934
    "returns the dropSource or nil"
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   935
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   936
    ^ dropSource
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   939
dropSource:aDropSourceOrNil
2891
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   940
    "set the dropSource or nil"
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   941
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
    dropSource := aDropSourceOrNil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
startDragAt:aPoint
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   946
    "start drag at a point"
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   947
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
   948
    buttonMotionAction := buttonReleaseAction := nil.
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
   949
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
    dropSource notNil ifTrue:[
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   951
        dropSource startDragSelector notNil ifTrue:[
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   952
            ^ dropSource startDragIn:self at:aPoint
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   953
        ] ifFalse:[
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   954
            ^ DragAndDropManager new
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   955
                startDragFrom:self dropSource:dropSource offset:#center
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   956
        ]
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   957
    ].
3684
8e409d2d8a52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3608
diff changeset
   958
    ^ nil
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   959
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   960
    "Modified: / 18-07-2010 / 09:07:26 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
!SelectionInListModelView methodsFor:'drawing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   965
drawElementsFrom:start to:stop x:x y:y w:w
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   966
    "draw the items between start to stop without clearing the background
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   967
    "
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   968
    |y0 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   969
     y1 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   970
     x0 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   971
    |
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   972
    x0 := textStartLeft - viewOrigin x.
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   973
    y1 := y.
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   974
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   975
    start to:stop do:[:i|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   976
	y0 := y1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   977
	y1 := self yVisibleOfLine:(i + 1).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   978
	self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   979
    ].
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   980
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   981
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   982
!
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   983
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
   984
drawFrom:start to:stop x:x y:y w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
    "draw the lines between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
    "
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   987
    highlightMode notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   988
	self selectionDo:[:lnNr|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   989
	    (lnNr between:start and:stop) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   990
		self drawSelectionFrameAt:lnNr x:x w:w
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   991
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   992
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
    ].
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   994
    super drawFrom:start to:stop x:x y:y w:w.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   997
drawLabelAt:anIndex x:xI y:y h:h
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
    "draw the label at position x/y without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1000
    |item y0 x1 x w drawStrikeOut xOut0 xOut1|
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1001
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1002
    x := xI + 1.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1003
    editorView notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1004
	"/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1005
	self selectedIndex == anIndex ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1006
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1007
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1008
    item := self at:anIndex ifAbsent:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1009
    item isNil ifTrue:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1011
    drawStrikeOut := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1012
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1013
    (highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1014
	strikeOut ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1015
	    drawStrikeOut := true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1016
	    self paint:fgColor on:bgColor
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1017
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1018
	    (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1019
		self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1020
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1021
		self paint:hilightFgColor on:hilightBgColor
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1022
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1023
	]
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1024
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1025
	enterItem == item ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1026
	    self paint:hilightBgColor on:bgColor.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1027
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1028
	    self paint:fgColor on:bgColor.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1029
	].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1030
    ].
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1031
    listRenderer display:item atX:x y:y lineHeight:h.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1033
    drawStrikeOut ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1034
	xOut0 := self xVisibleOfItem:item.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1035
	highlightMode == #label ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1036
	    xOut1 := xOut0 + (listRenderer widthFor:item).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1037
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1038
	    xOut1 := width - margin.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1039
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1040
	y0 := y + (h // 2).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1041
	self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1042
	y0 := y0 - 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1043
	self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1044
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1045
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1046
    cursorItem == item ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1047
	"/ textStartLeft
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1048
	self maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1049
	self mask:lineMask.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1050
	w := listRenderer widthFor:item.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1051
	self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1052
	self mask:nil.
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1053
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1054
	enterItem == item ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1055
	    self highlightWithUnderline ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1056
		"/ underline the hilite...
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1057
		y0 := y + h - 2.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1058
		x1 := x + (listRenderer widthFor:item).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1059
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1060
		self displayLineFromX:x y:y0 toX:x1 y:y0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1061
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1062
	].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1063
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1066
drawSelectionFrameAt:lnNr x:x w:w
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1067
    "draw the background and foreground of the selection frame
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1068
     at a lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
    "
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1070
    |item xMax xLftDmg xRgtDmg x0 x1 y0 y1 hL wL|
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1071
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1072
    (strikeOut or:[highlightMode isNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1073
	^ self
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1074
    ].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1075
    editorView notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1076
	"/ there is an open editor; do not redraw selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1077
	^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1078
    ].
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1079
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1080
    (    highlightMode == #line
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1081
     or:[highlightMode == #label
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1082
     or:[highlightMode == #dropMode]]
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1083
    ) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1084
	"/ highlightMode not supported
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1085
	^ self
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1086
    ].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1087
    (item := self at:lnNr ifAbsent:nil) isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1088
	"/ list might change during drawing; item no longer visible
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1089
	^ self
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1090
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1091
    xMax := x + w.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1092
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1093
    "/ CLEAR THE BACKGROUND
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1094
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1095
    y0 := self yVisibleOfLine:lnNr.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1096
    y1 := self yVisibleOfLine:(lnNr + 1).
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1097
    hL := y1 - y0.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1098
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1099
    highlightMode == #line ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1100
	x0 := x.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1101
	x1 := xMax.
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1102
    ] ifFalse:[ "/ is #label or #rectangle
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1103
	x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1104
	x0 >= xMax ifTrue:[ ^ self ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1105
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1106
	x1 := x0 + (listRenderer widthFor:item) + textStartLeft + 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1107
	x1 < x ifTrue:[ ^ self ].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1108
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1109
    xLftDmg := x0 max:x.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1110
    xRgtDmg := x1 min:xMax.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1111
    xRgtDmg > xLftDmg ifFalse:[^ self].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1112
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1113
    (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1114
	self paint:hilightBgColorNoFocus.
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1115
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1116
	self paint:hilightBgColor.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1117
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1118
    self fillRectangleX:xLftDmg y:y0 width:(xRgtDmg - xLftDmg) height:hL.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1119
    wL := x1 - x0.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1120
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1121
    "/ DRAW THE FRAME
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
    hilightFrameColor notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1124
	hilightLevel == 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1125
	    self paint:hilightFrameColor.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1126
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1127
	    highlightMode == #line ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1128
		self displayLineFromX:x0 y:y0 toX:x1 y:y0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1129
		y1 := y0 + hL - 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1130
		self displayLineFromX:x0 y:y1 toX:x1 y:y1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1131
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1132
		self displayRectangleX:x0 y:y0 width:wL height:hL
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1133
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1134
	    ^ self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1135
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1137
	hilightStyle == #motif ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1138
	    self paint:bgColor.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1139
	    y1 := y0 + 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1140
	    highlightMode == #line ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1141
		self displayLineFromX:x0 y:y1 toX:x1 y:y1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1142
		y1 := y0 + hL - 2.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1143
		self displayLineFromX:x0 y:y1 toX:x1 y:y1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1144
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1145
		self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1146
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1147
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1148
	hilightLevel == 0 ifTrue:[ ^ self ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1151
    "/ draw edge
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1152
    highlightMode == #line ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1153
	x0 := margin.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1154
	wL := width - x0 - x0.
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1155
    ].
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1156
    self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
4206
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1159
drawSelectionFrameFrom:start to:stop x:x y:y w:w
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1160
    "draw the selection frame between start to stop without clearing the background
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1161
    "
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1162
    highlightMode notNil ifTrue:[
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1163
        self selectionDo:[:lnNr|
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1164
            (lnNr between:start and:stop) ifTrue:[
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1165
                self drawSelectionFrameAt:lnNr x:x w:w
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1166
            ]
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1167
        ]
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1168
    ].
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1169
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1170
    "Created: / 24-04-2013 / 14:06:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1171
!
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1172
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1173
invalidateSelection
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1174
    "invalidate the current selection
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1175
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1176
    shown ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1177
	self selectionDo:[:aLnNr|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1178
	    self invalidateLineAt:aLnNr
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1179
	].
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1180
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1181
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1182
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1183
invalidateSelectionAt:aLineNr
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1184
    "redraw a line which changed its selection status.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1185
     optimized when drawing only the label.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
    "
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1187
    |item x|
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1188
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1189
    editorView notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1190
	"/ there is an open editor; do not redraw selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1191
	^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1192
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1193
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1194
    (shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1195
	^ self
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
  1196
    ].
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
  1197
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1198
    highlightMode == #label ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1199
	item := self at:aLineNr ifAbsent:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1200
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1201
	item isNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1202
	    ^ self
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1203
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1204
	x := (self xVisibleOfItem:item) - (textStartLeft // 2)
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1205
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1206
	x := 0.
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1207
    ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1208
    self invalidateLineAt:aLineNr fromX:x
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
!SelectionInListModelView methodsFor:'event handling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1213
activateMenu
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1214
    |item menu appl|
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1215
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1216
    enabled ifFalse:[^ self].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1217
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1218
    item := self selectedElement.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1219
    item notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1220
        menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1221
        menu notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1222
            menu isCollection ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1223
                menu := Menu decodeFromLiteralArray:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1224
                appl := self application.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1225
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1226
                appl notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1227
                    menu findGuiResourcesIn:appl.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1228
                    "/ menu receiver:appl  -- now done in findGuiResources ...
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1229
                ] ifFalse:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1230
                    menu receiver:item
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1231
                ]
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1232
            ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1233
            self startUpMenu:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1234
            ^ self
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1235
        ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1236
    ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1237
    super activateMenu
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1238
!
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1239
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1240
buttonControlPressAtLine:lineNr x:x y:y
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1241
    "handle a button control press
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
    "
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1243
    |isInSelection prvLine chgSet doAdd|
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
  1244
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1245
    isInSelection := self isInSelection:lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1247
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1248
	isInSelection ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1249
	    self deselect
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1250
	]ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1251
	    (self canSelectIndex:lineNr forAdd:false) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1252
		self buttonPressOrReleaseAtLine:lineNr x:x y:y.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1253
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1254
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1255
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
    ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1257
    isInSelection ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1258
	self removeFromSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1259
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1260
	self addToSelection:lineNr.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1261
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1262
	(self isInSelection:lineNr) ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1263
	    "/ cannot add to selection
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1264
	    ^ self
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1265
	].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1266
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1267
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1268
    prvLine := lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1269
    chgSet  := IdentitySet new.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1270
    doAdd   := isInSelection not.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1271
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1272
    buttonMotionAction := [:p| |rowNr mustRestore step f|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1273
	rowNr := self yVisibleToLineNr:(p y).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1274
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1275
	(rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1276
	    rowNr == lineNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1277
		mustRestore := true
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1278
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1279
		rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1280
			      ifFalse:[ mustRestore := (rowNr > prvLine) ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1281
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1282
	    prvLine > rowNr ifTrue:[ step := -1 ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1283
			  ifFalse:[ step :=  1 ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1284
	    mustRestore ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1285
		[ prvLine ~~ rowNr ] whileTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1286
		    (chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1287
			doAdd ifFalse:[ self addToSelection:prvLine ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1288
			       ifTrue:[ self removeFromSelection:prvLine ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1289
		    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1290
		    prvLine := prvLine + step.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1291
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1292
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1293
		[ prvLine ~~ rowNr ] whileTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1294
		    prvLine := prvLine + step.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1295
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1296
		    doAdd ~~ (self isInSelection:rowNr) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1297
			chgSet add:prvLine.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1298
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1299
			doAdd ifTrue:[ self addToSelection:prvLine ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1300
			     ifFalse:[ self removeFromSelection:prvLine ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1301
		    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1302
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1303
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1304
	].
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1305
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1306
!
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1307
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1308
buttonMotion:buttonMask x:x y:y
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1309
    "mouse-move while button was pressed - handle selection changes
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1310
    "
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1311
    |lnNr item|
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1312
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1313
    self stopAutoScroll.
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1314
2441
9ca40d634ff8 attention - do no motionAction, if no button is pressed
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
  1315
    (buttonMask ~~ 0 and:[buttonMotionAction notNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1316
	buttonMotionAction value:(x@y).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1317
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1318
	(autoScroll and:[buttonMotionAction notNil]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1319
	    "/ if moved outside of view, start autoscroll
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1320
	    (y between:0 and:height) ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1321
		y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1322
		     ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1323
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1324
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1325
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1327
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1328
    (enabled and:[highlightEnterItem]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1329
	self sensor anyButtonPressed ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1330
	    lnNr := self yVisibleToLineNr:y.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1331
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1332
	    lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1333
		       ifFalse:[ item := nil ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1334
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1335
	    self pointerEntersItem:item.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1336
	]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1337
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
buttonMultiPress:button x:x y:y
2948
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1341
    "button was pressed multiple - handle a doubleClick action"
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1342
3704
c9b2102bfd1c handle doubleClick - element under point is not selected
ca
parents: 3684
diff changeset
  1343
    |lnNr item|
c9b2102bfd1c handle doubleClick - element under point is not selected
ca
parents: 3684
diff changeset
  1344
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1345
    buttonMotionAction := buttonReleaseAction := nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1349
    (button == 1) ifTrue:[
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1350
        (     (lnNr := self yVisibleToLineNr:y)   notNil
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1351
         and:[(item := self at:lnNr ifAbsent:nil) notNil]
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1352
        ) ifTrue:[
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1353
            self selectedIndex == lnNr ifFalse:[
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1354
                self breakPoint:#ca
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1355
            ].
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1356
            self doubleClicked.
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1357
"/            doubleClickActionBlock notNil ifTrue:[
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1358
"/                doubleClickActionBlock valueWithOptionalArgument:lnNr and:self.
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1359
"/            ].
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1360
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1361
        ^ self.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
    ].
2947
caa98c08d3cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2920
diff changeset
  1363
2948
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1364
    super buttonMultiPress:button x:x y:y
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1365
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1366
    "Modified: / 30-06-2011 / 20:04:28 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1367
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
buttonPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1370
    "a button was pressed - handle selection here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
    "
3146
b7294baadfb7 button press, move and release behaviour
ca
parents: 3137
diff changeset
  1372
    |sensor item menu appl isSelected lineNr startLine dragDistance|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1374
    modelChangedDuringButtonPress := buttonMotionAction := buttonReleaseAction := nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1376
    self pointerEntersItem:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1377
    self cursorEntersItem:nil.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1378
    self closeEditor.
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1379
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1380
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1382
    sensor := self sensor.
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1383
    lineNr := self yVisibleToLineNr:y.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1384
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1385
    (button == 2) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1386
        (self selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1387
            (     lineNr notNil
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1388
             and:[self canSelectIndex:lineNr forAdd:false ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1389
            ) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1390
                (lineNr ~~ self selectedIndex) ifTrue: [
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1391
                    (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1392
                        self selectionChanged
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1393
                    ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1394
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1395
            ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1396
        ].
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1397
        item := self selectedElement.
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1398
        item notNil ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1399
            self makeSelectionVisible.
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1400
"/ now in activateMenu...
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1401
"/            menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1402
"/            menu notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1403
"/                menu isCollection ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1404
"/                    menu := Menu decodeFromLiteralArray:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1405
"/                    appl := self application.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1406
"/
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1407
"/                    appl notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1408
"/                        menu findGuiResourcesIn:appl.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1409
"/                        "/ menu receiver:appl  -- now done in findGuiResources ...
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1410
"/                    ] ifFalse:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1411
"/                        menu receiver:item
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1412
"/                    ]
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1413
"/                ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1414
"/                self startUpMenu:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1415
"/                ^ self
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1416
"/            ].
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1417
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1418
        super buttonPress:button x:x y:y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1419
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
    ].
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1421
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1422
    lineNr isNil ifTrue:[ ^ self ].
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1423
    modelChangedDuringButtonPress := false.
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
  1424
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1425
    sensor ctrlDown ifTrue:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1426
        self buttonControlPressAtLine:lineNr x:x y:y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1427
        ^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1428
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1429
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1430
    isSelected  := self isInSelection:lineNr.
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1431
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1432
    (self canDrag and:[sensor shiftDown not]) ifTrue:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1433
        dragDistance := UserPreferences current motionDistanceToStartDrag.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1434
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1435
        isSelected ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1436
            buttonMotionAction :=
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1437
                [:p|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1438
                    ((x@y) dist:p) > dragDistance ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1439
                        self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1440
                    ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1441
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1442
            buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1443
            ^ self.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1444
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1445
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1446
        self selectOnButtonPress ifFalse: [
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1447
            |oldSelection|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1448
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1449
            "/ set selection to line;
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1450
            "/ set the model without change notification (objects to drag)
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1451
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1452
            oldSelection := selection copy.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1453
            self selectAndUpdateModelWithoutChangeNotification: lineNr.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1454
            self windowGroup processExposeEvents.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1455
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1456
            buttonMotionAction :=
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1457
                [:p|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1458
                    ((x@y) dist:p) > dragDistance ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1459
                        |handler|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1460
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1461
                        handler := self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1462
                        handler contentsWillChange.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1463
                        "/ restore old selection
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1464
                        self selectAndUpdateModelWithoutChangeNotification: oldSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1465
                        self windowGroup processExposeEvents.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1466
                    ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1467
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1468
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1469
            buttonReleaseAction := [
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1470
                (self canSelectIndex:lineNr forAdd:false) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1471
                    "/ notify selection change
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1472
                    self selectionChanged.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1473
                ] ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1474
                    "/ restore old selection
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1475
                    self selectAndUpdateModelWithoutChangeNotification: oldSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1476
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1477
            ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1478
            ^ self
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1479
        ].
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1480
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1482
    multipleSelectOk ifFalse:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1483
        (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1484
            self buttonPressOrReleaseAtLine:lineNr x:x y:y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1485
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1486
            (dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1487
                buttonMotionAction :=
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1488
                    [:p|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1489
                        ((x@y) dist:p) > dragDistance ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1490
                            self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1491
                        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1492
                    ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1493
            ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1494
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1495
        ^ self
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1496
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1497
    startLine := lineNr.
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1498
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1499
    sensor shiftDown ifTrue:[ |min max|
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1500
        (isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1501
            ^ self
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1502
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1503
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1504
        multipleSelectOk ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1505
            startLine := self firstInSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1506
            startLine isNil ifTrue:[ startLine := lineNr ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1507
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1508
            startLine <= lineNr ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1509
                self selectFrom:startLine to:lineNr.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1510
            ] ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1511
                startLine := self lastInSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1512
                self selectFrom:lineNr to:startLine.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1513
            ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1514
        ]
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1515
    ] ifFalse:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1516
        (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1517
            ^ self
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1518
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1519
        self buttonPressOrReleaseAtLine:lineNr x:x y:y.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1522
    multipleSelectOk ifTrue:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1523
        buttonMotionAction :=
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1524
            [:p| |ln|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1525
                (p y between:0 and:height) ifTrue:[ |ln|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1526
                    ln := self yVisibleToLineNr:p y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1527
                    ln isNil ifTrue:[ln := self size].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1528
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1529
                    (ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1530
                        self selectFrom:startLine to:ln.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1531
                        dragDistance := nil.   "/ selection changed - no longer dragable
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1532
                    ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1533
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1534
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1535
                (dragDistance notNil and:[(x dist:p x) > dragDistance]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1536
                    self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1537
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1538
            ].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1539
    ].
3221
af3fae427c7e use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3205
diff changeset
  1540
af3fae427c7e use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3205
diff changeset
  1541
    "Modified: / 27-03-2007 / 08:43:58 / cg"
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1542
!
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1543
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1544
buttonPressOrReleaseAtLine:aLnNr x:x y:y
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1545
    "handle a button press or release at a line
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1546
    "
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1547
    aLnNr == self selectedIndex ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1548
	editorView notNil ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1549
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1550
	self openEditorAction notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1551
	    self openEditorAtX:x y:y.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1552
	    editorView notNil ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1553
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1554
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1555
	ignoreReselect ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1556
	    (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1557
		self selection:nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1558
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1559
		self selectionChanged
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1560
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1561
	].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1562
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1563
	(self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1564
	    self selectionChanged
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1565
	]
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1566
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1567
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1568
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1569
buttonRelease:button x:x y:y
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1570
    "a button was released"
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1571
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1572
    |makeSelectionVisible|
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1573
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1574
    button == 1 ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1575
        makeSelectionVisible := modelChangedDuringButtonPress.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1576
        buttonMotionAction   := modelChangedDuringButtonPress := nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1577
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1578
        buttonReleaseAction notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1579
            buttonReleaseAction value.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1580
            buttonReleaseAction := nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1581
        ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1582
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1583
        self cursorEntersItem:nil.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1584
    ].
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1585
    self stopAutoScroll.
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1586
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1587
    (makeSelectionVisible == true and:[self hasSelection]) ifTrue:[
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1588
        self makeSelectionVisible
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1589
    ].
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1590
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1591
    super buttonRelease:button x:x y:y
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1592
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1593
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1594
characterPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
    " a character is pressed - lookup and change selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1596
    "
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2455
diff changeset
  1597
    |lnNr size idx stp to1 fr2|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1599
    size := self size.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1600
    size > 1 ifFalse:[^ self].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1601
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1602
    lnNr := self firstInSelection.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1603
    lnNr isNil ifTrue:[lnNr := 0].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2455
diff changeset
  1605
    self sensor shiftDown ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1606
	stp := -1.              "/ search backward
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1607
	to1 :=  1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1608
	fr2 := size.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1610
	stp := 1.               "/ search forward
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1611
	to1 := size.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1612
	fr2 := 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1613
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
    idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
    idx == 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1618
	idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1619
	idx == 0 ifTrue:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
    ].
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1621
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1622
    self selection:idx.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1623
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1624
    keyActionStyle == #selectAndDoubleClick ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1625
	self doubleClicked
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1626
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1627
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1628
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1629
characterSearchItemStringAt:anIndex
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1630
    "for first-character search:
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1631
     return a lines item-string.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1632
     For multi-col items, this may be different from the actual string
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1633
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1634
    |item s|
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1635
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1636
    item := self at:anIndex ifAbsent:nil.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1637
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1638
    item isHierarchicalItem ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1639
	item := item string
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1640
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1641
    item isNil ifTrue:[^ nil].
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1642
2455
44300555526c Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 2447
diff changeset
  1643
    (Error catch:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1644
	s := item asString
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1645
    ]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1646
	s := item displayString
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1647
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1648
    ^ s
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1649
!
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1650
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1651
containerChangedSize
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1652
    "/ stupid kludge for motif-style (which draws a frame at the right-edge)
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1653
    "/ cg: I think it should not (see normal SelectionInListView, which does only
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1654
    "/     draw the frame at the top and bottom, but NOT at the left and right
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1655
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1656
    self hasSelection ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1657
	(hilightFrameColor notNil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1658
	or:[hilightStyle == #motif
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1659
	or:[hilightLevel ~~ 0]]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1660
	   "/ invalidate the right-edge
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1661
	    self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1662
	]
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1663
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1664
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1665
    super containerChangedSize.
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1666
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1667
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1668
cursorEntersItem:anItemOrNil
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1669
    "the cursor enters an item or nil
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1670
    "
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1671
    |lnNr x|
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1672
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1673
    (shown and:[self size ~~ 0]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1674
	cursorItem := nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1675
	^ self.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1676
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1677
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1678
    anItemOrNil == cursorItem ifTrue:[ ^ self ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1679
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1680
    2 timesRepeat:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1681
	cursorItem notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1682
	    lnNr := self identityIndexOf:cursorItem.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1683
	    lnNr notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1684
		x := self xVisibleOfItem:cursorItem.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1685
		self invalidateLineAt:lnNr fromX:x
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1686
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1687
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1688
	"/ set the new item
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1689
	cursorItem := anItemOrNil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1690
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1691
    cursorItem notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1692
	self makeLineVisible:lnNr
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1693
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1694
!
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1695
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1696
doubleClicked
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1697
    "handle a double click
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1698
    "
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1699
    |arg|
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1700
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1701
    doubleClickActionBlock notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1702
	arg := self selectedIndex.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1703
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1704
	arg ~~ 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1705
	    doubleClickActionBlock valueWithOptionalArgument:arg and:self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1706
	]
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1707
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1708
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1710
findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1711
    "find a line starting with a character
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
    "
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1713
    |char lbl cmp
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
     size     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1715
     start    "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
     stop     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
    |
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1718
    (size := self size) ~~ 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1719
	aStep > 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1720
	    aStart > aStop ifTrue:[^ 0].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1721
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1722
	    (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1723
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1724
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1725
	start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1726
	stop  := aStop  < 0 ifTrue:[1] ifFalse:[aStop  min:size].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1727
	char  := aCharacter asUppercase.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1729
	start to:stop by:aStep do:[:anIndex|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1730
	    lbl := self characterSearchItemStringAt:anIndex.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1731
	    lbl notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1732
		cmp := lbl string at:1 ifAbsent:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1733
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1734
		cmp notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1735
		    (char == cmp or:[char == cmp asUppercase]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1736
			(self canSelectIndex:anIndex forAdd:false) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1737
			    ^ anIndex
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1738
			].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1739
			^ 0
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1740
		    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1741
		]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1742
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1743
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1744
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1745
    ^ 0
3081
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1746
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1747
    "Modified: / 15-09-2006 / 11:26:29 / User"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1749
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1750
invalidateLineOfItem:anItem
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1751
    |lnNr x|
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1752
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1753
    lnNr := self identityIndexOf:enterItem.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1754
    lnNr notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1755
	x := self xVisibleOfItem:enterItem.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1756
	self invalidateLineAt:lnNr fromX:x
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1757
    ].
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1758
!
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1759
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
    "a key was pressed - handle page-keys here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
    "
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1763
    <resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1764
                          #BeginOfText #BeginOfLine #Return
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1765
                          #CmdReturn #CmdCursorUp #CmdCursorDown #SelectAll)>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1767
    |lineNr listSize shifted newSel step start|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1769
    enabled ifFalse:[ ^ self ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1770
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1771
    listSize := self size.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1772
    listSize == 0 ifTrue:[^ self].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1773
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1774
    aKey isCharacter ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1775
        keyActionStyle notNil ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1776
            keyActionStyle == #pass ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1777
                super keyPress:aKey x:x y:y
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1778
            ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1779
                self characterPress:aKey x:x y:y.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1780
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1781
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1782
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1783
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1784
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1785
    aKey == #Escape ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1786
        cursorItem notNil ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1787
            self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1788
            self makeSelectionVisible.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1789
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1790
        super keyPress:aKey x:x y:y.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1791
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1794
    ((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1795
        self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1796
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1797
        1 to:listSize do:[:i|
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1798
            (self canSelectIndex:i forAdd:false) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1799
                self selection:i.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1800
                ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1801
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1802
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1803
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1804
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1805
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1806
    ((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1807
        self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1808
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1809
        listSize to:1 by:-1 do:[:i|
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1810
            (self canSelectIndex:i forAdd:false) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1811
                self selection:i.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1812
                ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1813
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1814
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1815
        ^ self
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1816
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1817
    lineNr := self cursorLine.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1818
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1819
    aKey == #Return ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1820
        returnKeyActionStyle == #pass ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1821
            super keyPress:aKey x:x y:y
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1822
        ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1823
            lineNr ~~ 0 ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1824
                self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1825
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1826
                (self canSelectIndex:lineNr forAdd:false) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1827
                    self selection:lineNr
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1828
                ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1829
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1830
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1831
            returnKeyActionStyle == #doubleClick ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1832
                self doubleClicked
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1833
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1834
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1835
        ^ self
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1836
    ].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1837
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  1838
    aKey == #SelectAll ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1839
        self selectAll.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1840
        ^ self
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  1841
    ].
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  1842
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1843
    (lineNr == 0 and:[selection notNil]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1844
        multipleSelectOk ifFalse:[lineNr := selection]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1845
                          ifTrue:[lineNr := selection last].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1846
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1847
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1848
    aKey == #CmdReturn ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1849
        "/ toggle selection of the item
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1850
        lineNr ~~ 0 ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1851
            (self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1852
                                       ifFalse:[ self addToSelection:lineNr ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1853
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1854
            self cursorEntersItem:(self at:lineNr).
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1855
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1856
        ^ self
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1857
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1858
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1859
    (aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1860
        aKey == #CmdCursorDown ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1861
            lineNr := lineNr + 1.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1862
            lineNr > listSize ifTrue:[lineNr := 1].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1863
        ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1864
            lineNr := lineNr - 1.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1865
            lineNr < 1 ifTrue:[lineNr := listSize].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1866
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1867
        self cursorEntersItem:(self at:lineNr).
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1868
        ^ self
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1869
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1870
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1871
    (aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1872
        super keyPress:aKey x:x y:y.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1873
        ^ self
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1874
    ].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1875
    shifted := (multipleSelectOk and:[self sensor shiftDown]).
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1876
    self cursorEntersItem:nil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1877
2671
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1878
    aKey == #CursorDown ifTrue:[ step :=  1.]
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1879
                       ifFalse:[ step := -1.].
2671
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1880
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1881
    shifted ifFalse:[ |compressed|
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1882
        compressed := self sensor compressKeyPressEventsWithKey:aKey.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1883
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1884
        compressed ~~ 0 ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1885
            aKey == #CursorDown ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1886
                lineNr := lineNr + compressed.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1887
                lineNr > listSize ifTrue:[lineNr := 1].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1888
            ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1889
                lineNr := lineNr - compressed.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1890
                lineNr < 1 ifTrue:[lineNr := listSize].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1891
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1892
        ].
2671
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1893
    ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1894
    start  := lineNr.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1895
    lineNr := lineNr + step.
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  1896
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1897
    [ lineNr ~~ start ] whileTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1898
        (lineNr between:1 and:listSize) ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1899
            lineNr < 1 ifTrue:[ lineNr := listSize ]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1900
                      ifFalse:[ lineNr := 1 ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1901
        ] ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1902
            (self canSelectIndex:lineNr forAdd:shifted) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1903
                shifted ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1904
                    self selection:lineNr.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1905
                    ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1906
                ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1907
                (self isInSelection:lineNr) ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1908
                    selection isNil ifTrue:[ newSel := Array with:lineNr ]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1909
                                   ifFalse:[ newSel := selection copyWith:lineNr ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1910
                ] ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1911
                    (start ~~ 0 and:[selection size > 1]) ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1912
                        ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1913
                    ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1914
                    newSel := selection copyWithout:start.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1915
                ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1916
                self selection:newSel.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1917
"/                self selectWithoutScroll:newSel redraw:true.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1918
"/                self makeLineVisible:lineNr.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1919
"/                self selectionChanged.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1920
                ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1921
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1922
            lineNr := lineNr + step.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1923
        ]
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1924
    ].
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1925
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1926
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1927
pointerEntersItem:anItemOrNil
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1928
    "the pointer moves over an item or nil
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1929
    "
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1930
    |newItem|
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1931
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1932
    (shown and:[self size ~~ 0]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1933
	enterItem := nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1934
	^ self.
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1935
    ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1936
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1937
    highlightEnterItem ifTrue:[ newItem := anItemOrNil ]
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1938
		      ifFalse:[ newItem := nil ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1939
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1940
    anItemOrNil == enterItem ifTrue:[ ^ self ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1941
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1942
    enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1943
    enterItem := anItemOrNil.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1944
    enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1945
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1946
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1947
pointerLeave:state
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1948
    self pointerEntersItem:nil.
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1949
    super pointerLeave:state.
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1950
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1951
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1952
sizeChanged:how
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1953
    |selectionWasVisible|
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1954
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1955
    selectionWasVisible := false.
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1956
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1957
    "/ stupid kludge for motif-style (which draws a frame at the right-edge)
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1958
    "/ cg: I think it should not (see normal SelectionInListView, which does only
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1959
    "/     draw the frame at the top and bottom, but NOT at the left and right
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1960
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1961
    self hasSelection ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1962
	selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1963
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1964
	(hilightFrameColor notNil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1965
	or:[hilightStyle == #motif
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1966
	or:[hilightLevel ~~ 0]]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1967
	   "/ invalidate the right-edge
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1968
	    self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1969
	].
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1970
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1971
    super sizeChanged:how.
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1972
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1973
    selectionWasVisible ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1974
	self makeSelectionVisible
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1975
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1976
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1977
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1978
!SelectionInListModelView methodsFor:'focus handling'!
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1979
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1980
showFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1981
    self invalidateSelection.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1982
    super showFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1983
!
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1984
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1985
showNoFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1986
    self invalidateSelection.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1987
    super showNoFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1988
!
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1989
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1990
wantsFocusWithPointerEnter
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1991
    "return true, if I want the focus when
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1992
     the mouse pointer enters"
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1993
2701
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1994
    (editorView notNil and:[editorView realized]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1995
	^ false
2701
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1996
    ].
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1997
2959
afaf27dffcc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1998
    (UserPreferences current focusFollowsMouse ~~ false
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1999
    and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true)
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2000
    ]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2001
	self size > 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2002
	    ^ true
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2003
	]
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2004
    ].
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2005
    ^ false
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2006
! !
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2007
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2493
diff changeset
  2008
!SelectionInListModelView methodsFor:'initialization & release'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2009
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2010
fetchResources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2011
    "fetch device colors and ..., to avoid reallocation at redraw time;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2012
     *** called after a create or snapin to fetch all device resources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2013
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2014
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2015
    super fetchResources.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2016
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2017
    hilightFgColor    := self colorOnDevice:hilightFgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
    hilightBgColor    := self colorOnDevice:hilightBgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2019
    hilightFrameColor := self colorOnDevice:hilightFrameColor.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2020
    lineMask          := lineMask  onDevice:device.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2021
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2022
    hilightFgColorNoFocus := self colorOnDevice:hilightFgColorNoFocus.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2023
    hilightBgColorNoFocus := self colorOnDevice:hilightBgColorNoFocus.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2024
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2025
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2026
initStyle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
    "setup viewStyle specifics
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2028
    "
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2029
    <resource: #style (#'selection.selectOnMenuButton'
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2030
                       #'selection.font')>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2031
    super initStyle.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2032
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2033
    lineMask isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2034
        lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2035
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2036
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  2037
    hilightFrameColor   := nil.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  2038
    hilightStyle        := DefaultHilightStyle.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  2039
    highlightMode       := #label.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  2040
    textStartLeft       := 4.
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
  2041
    selectOnMenuButton  := styleSheet at:#'selection.selectOnMenuButton' default:nil.
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
  2042
    selectOnMenuButton isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2043
        selectOnMenuButton := UserPreferences current selectOnRightClick
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
  2044
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2045
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
  2046
    self font:(SelectionInListView defaultFont).
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  2047
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2048
    device hasGrayscales ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2049
        "
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2050
         must get rid of these hard codings
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2051
        "
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2052
        (hilightStyle == #next) ifTrue:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2053
            hilightFgColor := fgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2054
            hilightBgColor := White.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2055
            hilightFrameColor := fgColor
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2056
        ] ifFalse:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2057
            (hilightStyle == #motif) ifTrue:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2058
                fgColor := White.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2059
                bgColor := Grey.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2060
                viewBackground := bgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2061
                hilightFgColor := bgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2062
                hilightBgColor := fgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2063
            ] ifFalse:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2064
                (hilightStyle == #openwin) ifTrue:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2065
                    hilightFgColor := fgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2066
                    hilightBgColor := Color grey.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2067
                ]
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2068
            ]
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2069
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2070
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2071
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2072
    hilightFgColor isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2073
        hilightFgColor := bgColor.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2075
    hilightBgColor isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2076
        hilightBgColor := fgColor.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2077
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2078
    DefaultForegroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2079
        fgColor := DefaultForegroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2080
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2081
    DefaultBackgroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2082
        bgColor := viewBackground := DefaultBackgroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2083
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2084
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2085
    DefaultHilightForegroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2086
        hilightFgColor := DefaultHilightForegroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2087
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
    DefaultHilightBackgroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2089
        hilightBgColor := DefaultHilightBackgroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2090
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
    DefaultHilightFrameColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2092
        hilightFrameColor := DefaultHilightFrameColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2093
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2094
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  2095
    hilightLevel := DefaultHilightLevel ? 0.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  2096
    lineSpacing  := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2].
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  2097
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2098
    hilightFgColor isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2099
        hilightFgColor := bgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2100
        hilightBgColor := fgColor.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2101
    ].
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2102
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2103
    hilightFgColorNoFocus isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2104
        hilightFgColorNoFocus := hilightFgColor.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2105
    ].
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2106
    hilightBgColorNoFocus isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2107
        hilightBgColorNoFocus := hilightBgColor lightened.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2108
    ].
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
  2109
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
  2110
    "Modified: / 14-08-2010 / 12:23:09 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2113
initialize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2114
    "setup default attributes/behavior
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2115
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2116
    multipleSelectOk     := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2117
    useIndex             := true.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2118
    ignoreReselect       := true.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2119
    toggleSelect         := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2120
    highlightEnterItem   := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2121
    strikeOut            := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2122
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2123
    keyActionStyle       := #select.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2124
    returnKeyActionStyle := #doubleClick.
2324
ada66df6ac14 support of highlighting items under mouse
ca
parents: 2323
diff changeset
  2125
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2126
    extraSpaceAtBottomForDrop := 20.
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2127
2324
ada66df6ac14 support of highlighting items under mouse
ca
parents: 2323
diff changeset
  2128
    super initialize.
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2129
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2130
    "Modified: / 03-11-2010 / 01:34:54 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2131
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2132
1745
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2133
mapped
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2134
    "get selection from model; scroll to selection
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2135
    "
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2136
    super mapped.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2137
    self makeSelectionVisible.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2138
!
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2139
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2140
realize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2141
    "get selection from model; scroll to selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2142
    "
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
  2143
    self updateFromModel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2144
    super realize.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2146
2493
8b70a26f1694 method category rename
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  2147
!SelectionInListModelView methodsFor:'private-editor'!
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2148
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2149
computeEditorLayout
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2150
    "update the layout of the editor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2151
    "
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2152
    |lnNr item y0 x0 y1|
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2153
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2154
    editorView isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2155
	^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2156
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2157
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2158
    (    (lnNr := self selectedIndex) == 0
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2159
     or:[(item := self at:lnNr ifAbsent:nil) isNil]
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2160
    ) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2161
	"/ there is no more single selection; thus close the editor
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2162
	^ self closeEditor
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2163
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2164
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2165
    x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2166
    y0 := self yVisibleOfLine:lnNr.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2167
    y1 := self yVisibleOfLine:(lnNr + 1).
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2168
3524
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
  2169
    minimumEditorHeight notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2170
	y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
3524
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
  2171
    ].
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2172
    "/ Changed by cg:
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2173
    "/ editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h + 2 "- 1") ).
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2174
    editorView layout:( Rectangle left:x0 top:y0-2 right:(width - 1 - margin) bottom:y1 ).
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2175
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2176
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2177
openEditorAtX:x y:y
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2178
    "opens an editor on the current single selection
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2179
    "
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2180
    |item lnNr x0 y0 editor|
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2181
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2182
    self closeEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2183
    shown ifFalse:[^ self ].
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
  2184
    self openEditorAction isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2185
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2186
    lnNr := self selectedIndex.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2187
    lnNr == 0 ifTrue:[^ self].
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2188
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2189
    item := self at:lnNr ifAbsent:nil.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2190
    item isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2191
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  2192
    x < (self xVisibleOfItem:item) ifTrue:[
3778
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2193
        "/ not part of the selection frame; ignorre
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2194
        ^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2195
    ].
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2196
    editor := self openEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2197
    editor isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2198
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2199
    y0 := (y - editor origin y) max:0.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2200
    x0 := (x - editor origin x) max:0.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2201
2125
67e0f2c9ad4d event types are private to WindowEvent;
ca
parents: 2070
diff changeset
  2202
    "/ simulate clicking into the editor
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2203
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2204
    "/ Changed by cg:
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2205
    "/ but only if there was no initial selection
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2206
    editor isInputField ifTrue:[
3778
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2207
        editor hasSelection ifFalse:[
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2208
            self sensor
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2209
                pushEvent:(WindowEvent buttonPress:1 x:x0 y:y0 view:editor);
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2210
                pushEvent:(WindowEvent buttonRelease:1 x:x0 y:y0 view:editor).
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2211
        ]
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2212
    ].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2213
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2214
    "/ to clear the selection
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2215
    self invalidateLineAt:lnNr.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2216
! !
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2217
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2218
!SelectionInListModelView methodsFor:'protocol'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2219
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2220
lostSynchronisation
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2221
    "called when the changes derived from the model are faster than the handling
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2222
    "
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2223
    self deselectWithoutRedraw.
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2224
    super lostSynchronisation.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2225
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2226
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2227
!SelectionInListModelView methodsFor:'queries'!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2228
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2229
isCursorKeyConsumer
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2230
    "return true, if the receiver can be controlled by cursor keys;
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2231
     i.e. it can handle some keyboard input,
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2232
     isCursorKeyConsumer are potential candidates for getting the keyboard
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2233
     focus initially within dialogBoxes, or when the focus-follows-pointer
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2234
     mode is off.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2235
     Return false here, this is redefined in SelectionInListView."
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2236
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2237
    ^ true
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2238
! !
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2239
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2240
!SelectionInListModelView methodsFor:'scroller interface'!
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2241
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2242
heightOfContents
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2243
    "answer the height of the contents in pixels.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2244
     If the minimumEditorHeight and the openEditorAction is defined,
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2245
     we have to involve the minimumEditorHeight in the computation,
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2246
     to allow opening the editor fullyvisible at the last line."
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2247
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2248
    |cachedLinesY cachedMaxIdx y0 y1|
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2249
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2250
    cachedLinesY := self startOfLinesY.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2251
    cachedMaxIdx := cachedLinesY size.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2252
    cachedMaxIdx == 0 ifTrue:[ ^ 0 ].
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2253
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2254
    y1 := cachedLinesY at:cachedMaxIdx.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2255
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2256
    (minimumEditorHeight notNil and:[openEditorAction notNil]) ifTrue:[
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2257
        y0 := cachedLinesY at:(cachedMaxIdx - 1) ifAbsent:0.
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2258
        y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2259
    ].
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2260
    ^ y1 + extraSpaceAtBottomForDrop.
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2261
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2262
    "Modified: / 03-11-2010 / 01:35:05 / cg"
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2263
! !
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2264
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2265
!SelectionInListModelView methodsFor:'selection'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2266
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2267
addToSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2268
    "add line to selection without scrolling but raise a change notification
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2269
    "
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2270
    |oldSelect forAdd|
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2271
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2272
    (self isInSelection:lineNr) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2273
	^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2274
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2275
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2276
    multipleSelectOk ifTrue:[ forAdd := selection notNil ]
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2277
		    ifFalse:[ forAdd := false ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2278
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2279
    (self canSelectIndex:lineNr forAdd:forAdd) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2280
	^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2281
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2282
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2283
    self closeEditor.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2284
    self cursorEntersItem:nil.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2285
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2286
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2287
	oldSelect := selection.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2288
	selection := lineNr.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2289
	oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2290
    ] ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2291
	selection notNil ifTrue:[ selection := selection copyWith:lineNr ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2292
			ifFalse:[ selection := OrderedCollection with:lineNr ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2293
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2294
    self invalidateSelectionAt:lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2295
    self selectionChanged.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2296
!
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2297
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2298
deselect
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2299
    "clear selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2300
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2301
    self selection:nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2302
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2303
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2304
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2305
firstInSelection
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2306
    "returns the minimum index of selected indices or nil if nothing is selected
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2308
    |min|
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2309
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2310
    multipleSelectOk   ifFalse:[ ^ selection ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2311
    selection size == 0 ifTrue:[ ^ nil ].
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2312
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2313
    min := selection at:1.
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2314
    selection do:[:aNumber| min := min min:aNumber ].
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2315
    ^ min
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2316
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2318
hasSelection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2319
    "returns true if a selection exists
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
    ^ selection notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2322
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2323
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2324
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2325
isInSelection:aNumber
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2326
    "return true, if line, aNumber is in the selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2327
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2328
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2329
	^ (aNumber == selection)
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2330
    ].
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2331
    selection notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2332
	^ selection includesIdentical:aNumber
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2333
    ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2334
    ^ false
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2337
isSelectionVisible
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2338
    "returns true if any selected element is visible"
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2339
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2340
    ^ self isSelectionVisibleIn:(self extent)
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2341
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2342
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2343
isSelectionVisibleIn:anExtentPoint
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2344
    "returns true if any selected element is visible"
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2345
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2346
    self selectionDo:[:aLineNr|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2347
	(self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2348
    ].
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2349
    ^ false
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2350
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2351
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2352
lastInSelection
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2353
    "returns the maximum index of selected indices or nil if nothing is selected
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2354
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2355
    |max|
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2356
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2357
    multipleSelectOk   ifFalse:[ ^ selection ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2358
    selection size == 0 ifTrue:[ ^ nil ].
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2359
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2360
    max := 1.
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2361
    selection do:[:aNumber| max := max max:aNumber ].
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2362
    ^ max
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2363
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2364
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2365
makeSelectionVisible
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2366
    "scroll to make the selection line visible
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2367
     dont scroll, if any in the selection isVisible
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2368
    "
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2369
    |firstLine|
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2370
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2371
    modelChangedDuringButtonPress notNil ifTrue:[^ self].
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2372
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2373
    firstLine := self firstInSelection.
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2374
    (firstLine isNil or:[firstLine == 0]) ifTrue:[^ self].
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2375
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2376
    self selectionDo:[:aLnNr|
3889
67eb713ccfec changed: #makeSelectionVisible
fm
parents: 3873
diff changeset
  2377
        (self lineIsFullyVisible:aLnNr) ifTrue:[^ self].
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2378
    ].
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  2379
    self makeLineVisible:(self firstInSelection).
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2380
!
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2381
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2382
numberOfSelections
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2383
    "return the number of selected items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2384
    "
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2385
    selection isNil   ifTrue:[ ^ 0 ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2386
    multipleSelectOk ifFalse:[ ^ 1 ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2387
  ^ selection size
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2388
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2389
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2390
removeFromSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2391
    "remove line from selection without scrolling but raise a change notification
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2392
    "
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2393
    (self isInSelection:lineNr) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2394
	^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2395
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2396
    self closeEditor.
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2397
    self cursorEntersItem:nil.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2398
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2399
    (multipleSelectOk and:[self numberOfSelections > 1]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2400
	selection := selection copyWithout:lineNr.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2401
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2402
	selection := nil
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2403
    ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2404
    self invalidateSelectionAt:lineNr.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2405
    self selectionChanged.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2406
!
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2407
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2408
selectAll
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2409
    "select all entries.
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2410
     Model and/or actionBlock notification IS done."
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2411
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2412
    self selectFrom:1 to:self size.
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2413
!
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2414
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
selectElement:anElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
    "select the element. Scroll to make the new selection visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
     Model and/or actionBlock notification IS done.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2418
    "
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2419
    self selectElement:anElement ifAbsent:[self deselect]
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2420
!
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2421
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2422
selectElement:anElement ifAbsent:exceptionalValue
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2423
    |idx|
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2424
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2425
    idx := self identityIndexOf:anElement.
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2426
    idx == 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2427
	^ exceptionalValue value
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2428
    ].
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2429
    self selection:idx
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2430
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
4085
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2432
selectElementForWhich:aBlock ifAbsent:exceptionalValue
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2433
    1 to:self size do:[:idx |
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2434
        (aBlock value:(self at:idx)) ifTrue:[
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2435
            self selection:idx.
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2436
            ^ self
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2437
        ].
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2438
    ].
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2439
    ^ exceptionalValue value
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2440
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2441
    "Created: / 06-10-2011 / 13:32:28 / cg"
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2442
!
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2443
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2444
selectFrom:aStart to:aStop
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2445
    "select lines between start and stop
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2446
    "
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2447
    |start stop step nsel|
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2448
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2449
    multipleSelectOk ifFalse:[^ self].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2450
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2451
    start := aStart.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2452
    stop  := aStop.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2453
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2454
    aStart < aStop ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2455
	start := aStart max:1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2456
	stop  := aStop  min:(self size).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2457
	step  := 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2458
	start > stop ifTrue:[^ self].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2459
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2460
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2461
	start := aStart min:(self size).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2462
	stop  := aStop  max:1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2463
	step  := -1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2464
	start < stop ifTrue:[^ self].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2465
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2466
    nsel := OrderedCollection new.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2467
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2468
    start to:stop by:step do:[:i|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2469
	(self canSelectIndex:i forAdd:true) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2470
	    nsel add:i.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2471
	].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2472
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2473
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2474
    (self selectWithoutScroll:nsel redraw:true) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2475
	self selectionChanged
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2476
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2477
!
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2478
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2479
selectedElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2480
    "return the single selected item or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2482
    |index|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2483
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2484
    (index := self selectedIndex) ~~ 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2485
	^ self at:index ifAbsent:nil
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2486
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2487
    ^ nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2488
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2489
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2490
selectedIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2491
    "returns the index of the selected line or 0. If more
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2492
     lines are selected, 0 is returned
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2493
    "
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2494
    selection notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2495
	multipleSelectOk ifFalse:[ ^ selection ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2496
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2497
	selection size == 1 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2498
	    ^ selection at:1
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2499
	]
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2500
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2501
    ^ 0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2503
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2504
selection
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2505
    "return the selection index or collection of indices
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2506
     in case of multiple selection enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2508
    ^ selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2509
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2510
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2511
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2512
selection:something
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2513
    "select something or deselect if the argument is nil;
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
     scroll to make the selected line visible.
3873
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2515
     The model and/or actionBlock IS notified."
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2516
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2517
    (self selectWithoutScroll:something redraw:true) ifTrue:[
3873
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2518
        self makeSelectionVisible.
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2519
        self selectionChanged
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2520
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2521
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2522
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2523
selectionAsCollection
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2524
    "return the selection as a collection of line numbers.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2525
     This allows users of this class to enumerate independent of
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2526
     the multipleSelect style.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2527
    "
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2528
    selection isNil  ifTrue:[ ^ #() ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2529
    multipleSelectOk ifTrue:[ ^ selection ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2530
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2531
  ^ OrderedCollection with:selection
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2532
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2533
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2534
selectionDo:aBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2535
    "perform aBlock for each nr in the selection.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2536
     For single selection, it is called once for the items nr.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
     For multiple selections, it is called for each.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2539
    selection notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2540
	multipleSelectOk ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2541
	    selection do:aBlock
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2542
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2543
	    aBlock value:selection
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2544
	].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2545
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2546
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2547
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2548
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2550
selectionValue
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2551
    "return the selection value i.e. the text in the selected line.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2552
     For multiple selections a collection containing the entries is returned.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2553
    "
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2554
    multipleSelectOk ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2555
	selection isNil ifTrue:[^ #()].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2556
	^ selection collect:[:nr| self at:nr ]
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2557
    ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2558
    selection isNil ifTrue:[^ nil].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2559
    ^ self at:selection ifAbsent:nil.
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2560
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2561
2346
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2562
selectionValueAsCollection
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2563
    "return the selection values as a collection - allows selectionValues to
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2564
     be enumerated independent of the multiSelect settings
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2565
    "
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2566
    |value|
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2567
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2568
    value := self selectionValue.
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2569
    multipleSelectOk ifTrue:[^ value].
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2570
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2571
    value notNil ifTrue:[^ Array with:value ].
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2572
  ^ #()
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2573
!
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2574
1542
8607d072c319 accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents: 1537
diff changeset
  2575
setSelection:something
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2576
    "select something or deselect if the argument is nil;
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2577
     scroll to make the selected line visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2578
     *** No model and/or actionBlock notification is done here.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2579
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2580
    (self selectWithoutScroll:something redraw:true) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2581
	self makeSelectionVisible
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2582
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2583
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2584
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2586
!SelectionInListModelView methodsFor:'selection private'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2587
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2588
canSelectIndex:anIndex
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2589
    "return true, if the object identified by its index is selectable
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2590
    "
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2591
    ^ self canSelectIndex:anIndex forAdd:false
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2592
!
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2593
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2594
canSelectIndex:anIndex forAdd:isForAdd
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2595
    "return true, if the object identified by its index is selectable
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2596
    "
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2597
    |item isOk|
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2598
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2599
    selectConditionBlock notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2600
	isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2601
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2602
	isOk ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2603
	    ^ false
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2604
	]
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2605
    ].
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2606
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2607
    item := self at:anIndex ifAbsent:nil.
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  2608
    item isNil ifTrue:[^ false].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2609
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  2610
    item isHierarchicalItem ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2611
	^ item isSelectable
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2612
    ].
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2613
    ^ true
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2614
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2615
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2616
deselectWithoutRedraw
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2617
    "clear the selection without redraw and scrolling;
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2618
     the model and/or actionBlock is notified
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2619
    "
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2620
    (self selectWithoutScroll:nil redraw:false) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2621
	self selectionChanged
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2622
    ]
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2623
!
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2624
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2625
selectAndUpdateModelWithoutChangeNotification: aLineNo
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2626
    |arg|
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2627
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2628
    self selectWithoutScroll:aLineNo redraw:true.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2629
    modelChangedDuringButtonPress := false.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2630
    model isNil ifTrue:[ ^ self ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2631
    arg := self argForChangeMessage.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2632
    self sendChangeMessage:#setValue: with:arg.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2633
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2634
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2635
selectWithoutScroll:something redraw:doRedraw
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2636
    "change selection to something; returns true if selection changed
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2637
    "
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2638
    |oldSelect size|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2639
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  2640
    selection = something ifTrue:[^ false].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  2641
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
    oldSelect := selection.
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2643
    selection := nil.   "/reset selection
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2644
    size := self size.
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2645
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2646
    ( size > 0 and:[ something notNil ] ) ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2647
        something isNumber ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2648
            (something between:1 and:size) ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2649
                selection := multipleSelectOk ifTrue:[Array with:something]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2650
                                             ifFalse:[something]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2651
            ]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2652
        ] ifFalse:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2653
            something size > 0 ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2654
                selection := OrderedCollection new.
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2655
                something do:[:each|
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2656
                    each isNumber ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2657
                        (each between:1 and:size) ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2658
                            selection add: each.
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2659
                        ]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2660
                    ]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2661
                ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2662
                selection isEmpty ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2663
                    selection := nil.
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2664
                ] ifFalse:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2665
                    multipleSelectOk ifFalse:[ selection := selection first ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2666
                ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2667
            ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2668
        ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2669
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2670
    selection = oldSelect ifTrue:[^ false].
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2671
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2672
    modelChangedDuringButtonPress notNil ifTrue:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2673
        modelChangedDuringButtonPress := true.
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2674
    ].
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2675
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2676
    self closeEditor.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2677
    self cursorEntersItem:nil.
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2678
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2679
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2680
    (doRedraw and:[shown]) ifFalse:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2681
        ^ true
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2682
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2683
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
    multipleSelectOk ifFalse:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2685
        oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2686
        selection notNil ifTrue:[self invalidateSelectionAt:selection].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
    ] ifTrue:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2688
        (selection notNil and:[oldSelect notNil]) ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2689
            selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2690
            oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2691
        ] ifFalse:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2692
            oldSelect isNil ifTrue:[oldSelect := selection].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2693
            oldSelect do:[:i|self invalidateSelectionAt:i]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2694
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
    ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2696
    ^ true
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2697
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2698
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2699
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2700
3778
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2701
version_CVS
4258
d6ea83906c4e class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4242
diff changeset
  2702
    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.160 2013-06-27 14:02:41 cg Exp $'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2703
! !
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  2704