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