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