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