author | Claus Gittinger <cg@exept.de> |
Sat, 13 Jul 2013 22:31:53 +0200 | |
changeset 4273 | d56dfb04df83 |
parent 4258 | d6ea83906c4e |
child 4318 | ee2c154ee065 |
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 |
4258
d6ea83906c4e
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4242
diff
changeset
|
729 |
"this one is sent, whenever contents changes its size" |
d6ea83906c4e
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4242
diff
changeset
|
730 |
|
1755 | 731 |
super contentsChanged. |
3482 | 732 |
self computeEditorLayout. |
1755 | 733 |
! |
734 |
||
735 |
lineChangedAt:aLnNr with:arg |
|
736 |
super lineChangedAt:aLnNr with:arg. |
|
737 |
||
738 |
(editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[ |
|
3728 | 739 |
self computeEditorLayout. |
1755 | 740 |
] |
741 |
! |
|
742 |
||
1390 | 743 |
listSizeChanged:aLnNr nLines:aDeltaLines |
1563 | 744 |
|changed cnts| |
1390 | 745 |
|
746 |
super listSizeChanged:aLnNr nLines:aDeltaLines. |
|
747 |
||
748 |
selection isNil ifTrue:[^ self]. |
|
749 |
||
2408 | 750 |
self size == 0 ifTrue:[ |
3728 | 751 |
selection := nil. |
752 |
^ self selectionChanged |
|
1390 | 753 |
]. |
754 |
||
1563 | 755 |
multipleSelectOk ifFalse:[ |
3728 | 756 |
selection < aLnNr ifTrue:[^ self]. |
757 |
||
758 |
selection := selection + aDeltaLines. |
|
759 |
||
760 |
(aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[ |
|
761 |
selection := nil. |
|
762 |
^ self selectionChanged |
|
763 |
] |
|
1563 | 764 |
] ifTrue:[ |
3728 | 765 |
changed := false. |
766 |
||
767 |
aDeltaLines < 0 ifFalse:[ |
|
768 |
selection keysAndValuesDo:[:i :ln| |
|
769 |
ln >= aLnNr ifTrue:[ |
|
770 |
changed := true. |
|
771 |
selection at:i put:(ln + aDeltaLines) |
|
772 |
] |
|
773 |
] |
|
774 |
] ifTrue:[ |
|
775 |
cnts := 0. |
|
776 |
||
777 |
selection keysAndValuesDo:[:i :ln||new| |
|
778 |
ln >= aLnNr ifTrue:[ |
|
779 |
changed := true. |
|
780 |
||
781 |
(new := ln + aDeltaLines) < aLnNr ifTrue:[ |
|
782 |
cnts := cnts + 1. |
|
783 |
new := nil |
|
784 |
]. |
|
785 |
selection at:i put:new |
|
786 |
] |
|
787 |
]. |
|
788 |
cnts ~~ 0 ifTrue:[ |
|
789 |
cnts == selection size ifTrue:[ |
|
790 |
selection := nil |
|
791 |
] ifFalse:[ |
|
792 |
selection := selection select:[:ln| ln notNil] |
|
793 |
]. |
|
794 |
^ self selectionChanged. |
|
795 |
]. |
|
796 |
]. |
|
797 |
changed ifFalse:[^ self]. |
|
1390 | 798 |
]. |
799 |
||
1563 | 800 |
(useIndex and:[model notNil]) ifTrue:[ |
3728 | 801 |
model setValue:(self argForChangeMessage) |
1563 | 802 |
]. |
1390 | 803 |
! |
804 |
||
1755 | 805 |
originChanged:delta |
806 |
"setup the origin of the editing view |
|
807 |
" |
|
808 |
self computeEditorLayout. |
|
809 |
super originChanged:delta. |
|
810 |
||
811 |
||
812 |
! |
|
813 |
||
1390 | 814 |
selectionChanged |
815 |
"selection has changed. Call actionblock and/or send changeMessage if defined |
|
816 |
" |
|
1554 | 817 |
|arg| |
1390 | 818 |
|
1755 | 819 |
self closeEditor. |
820 |
||
1390 | 821 |
(model isNil and:[actionBlock isNil]) ifTrue:[ |
3728 | 822 |
^ self |
1390 | 823 |
]. |
824 |
||
825 |
arg := self argForChangeMessage. |
|
826 |
||
827 |
model notNil ifTrue:[ |
|
3728 | 828 |
model removeDependent:self. |
829 |
"/ change models value to force a change notification: reselect mode |
|
830 |
arg = model value ifTrue:[ |
|
831 |
model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]). |
|
832 |
]. |
|
833 |
self sendChangeMessage:#value: with:arg. |
|
834 |
model notNil ifTrue:[ "/ argggh could be nilled |
|
835 |
model addDependent:self. |
|
836 |
self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent |
|
837 |
] |
|
1390 | 838 |
]. |
839 |
||
840 |
actionBlock notNil ifTrue:[ |
|
3728 | 841 |
actionBlock valueWithOptionalArgument:arg and:self |
1390 | 842 |
]. |
843 |
! |
|
844 |
||
1554 | 845 |
updateFromModel |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
846 |
"update selection from the model |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
847 |
" |
2522 | 848 |
|value newSelection| |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
849 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
850 |
model isNil ifTrue:[ |
4273
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
851 |
^ self |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
852 |
]. |
2401 | 853 |
|
854 |
buttonMotionAction notNil ifTrue:[ |
|
4273
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
855 |
"running in button motion; discard change notification |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
856 |
" |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
857 |
^ self |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
858 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
859 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
860 |
value := model value. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
861 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
862 |
(useIndex or:[value isNil or:[value isNumber]]) ifFalse:[ |
4273
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
863 |
multipleSelectOk ifFalse:[ |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
864 |
newSelection := self identityIndexOf:value |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
865 |
] ifTrue:[ |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
866 |
value size == 0 ifTrue:[ |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
867 |
newSelection := nil |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
868 |
] ifFalse:[ |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
869 |
newSelection := OrderedCollection new. |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
870 |
|
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
871 |
value do:[:e||index| |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
872 |
index := self identityIndexOf:e. |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
873 |
index ~~ 0 ifTrue:[ newSelection add:index ]. |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
874 |
]. |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
875 |
newSelection := newSelection asNilIfEmpty. |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
876 |
] |
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
877 |
]. |
2522 | 878 |
] ifTrue:[ |
4273
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
879 |
newSelection := value copy |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
880 |
]. |
2522 | 881 |
self setSelection:newSelection. |
1390 | 882 |
! ! |
883 |
||
884 |
!SelectionInListModelView methodsFor:'drag & drop'! |
|
885 |
||
886 |
canDrag |
|
3918 | 887 |
"returns true if dragging is enabled" |
888 |
||
1390 | 889 |
^ dropSource notNil |
890 |
||
3918 | 891 |
"Modified: / 18-07-2010 / 09:07:20 / cg" |
1390 | 892 |
! |
893 |
||
2572 | 894 |
dragAutoScroll:aContext |
895 |
"called by the DragAndDropManager to scroll during a drag/drop operation |
|
896 |
if necassery (decided by the widget itself); If a scroll is done return |
|
3918 | 897 |
true otherwise false (used to restore the background)" |
898 |
||
3899 | 899 |
|scrollUp targetY deltaY pixels| |
900 |
||
901 |
targetY := aContext targetPoint y. |
|
902 |
scrollUp := (targetY < (height // 2)). |
|
903 |
||
904 |
scrollUp ifTrue:[ |
|
905 |
self yOriginOfContents = 0 ifTrue:[ ^ false]. |
|
906 |
deltaY := targetY. |
|
2572 | 907 |
] ifFalse:[ |
3899 | 908 |
deltaY := height - targetY. |
909 |
self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ]. |
|
2572 | 910 |
]. |
3899 | 911 |
pixels := 24 min:(height // 4). |
912 |
deltaY > pixels ifTrue:[^ false]. |
|
913 |
||
914 |
deltaY <= (pixels // 2) ifTrue:[ |
|
915 |
deltaY <= (pixels // 4) |
|
916 |
ifTrue:[ pixels := pixels * 3] |
|
917 |
ifFalse:[ pixels := pixels * 2 ]. |
|
918 |
]. |
|
2572 | 919 |
aContext contentsWillChange. |
920 |
||
3918 | 921 |
scrollUp |
922 |
ifTrue:[ self scrollUp:pixels ] |
|
923 |
ifFalse:[ self scrollDown:pixels ]. |
|
2572 | 924 |
|
925 |
^ true |
|
3918 | 926 |
|
927 |
"Modified: / 18-07-2010 / 09:08:29 / cg" |
|
2572 | 928 |
! |
929 |
||
1390 | 930 |
dropSource |
2891 | 931 |
"returns the dropSource or nil" |
3728 | 932 |
|
1390 | 933 |
^ dropSource |
934 |
! |
|
935 |
||
3728 | 936 |
dropSource:aDropSourceOrNil |
2891 | 937 |
"set the dropSource or nil" |
3728 | 938 |
|
1390 | 939 |
dropSource := aDropSourceOrNil. |
940 |
! |
|
941 |
||
942 |
startDragAt:aPoint |
|
3918 | 943 |
"start drag at a point" |
944 |
||
2976 | 945 |
buttonMotionAction := buttonReleaseAction := nil. |
946 |
||
1390 | 947 |
dropSource notNil ifTrue:[ |
3918 | 948 |
dropSource startDragSelector notNil ifTrue:[ |
949 |
^ dropSource startDragIn:self at:aPoint |
|
950 |
] ifFalse:[ |
|
951 |
^ DragAndDropManager new |
|
952 |
startDragFrom:self dropSource:dropSource offset:#center |
|
953 |
] |
|
3370
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
954 |
]. |
3684 | 955 |
^ nil |
3918 | 956 |
|
957 |
"Modified: / 18-07-2010 / 09:07:26 / cg" |
|
1390 | 958 |
! ! |
959 |
||
960 |
!SelectionInListModelView methodsFor:'drawing'! |
|
961 |
||
2642 | 962 |
drawElementsFrom:start to:stop x:x y:y w:w |
963 |
"draw the items between start to stop without clearing the background |
|
964 |
" |
|
965 |
|y0 "{ Class:SmallInteger }" |
|
966 |
y1 "{ Class:SmallInteger }" |
|
967 |
x0 "{ Class:SmallInteger }" |
|
968 |
| |
|
969 |
x0 := textStartLeft - viewOrigin x. |
|
970 |
y1 := y. |
|
971 |
||
972 |
start to:stop do:[:i| |
|
3728 | 973 |
y0 := y1. |
974 |
y1 := self yVisibleOfLine:(i + 1). |
|
975 |
self drawLabelAt:i x:x0 y:y0 h:(y1 - y0) |
|
2642 | 976 |
]. |
977 |
||
978 |
||
979 |
! |
|
980 |
||
1533 | 981 |
drawFrom:start to:stop x:x y:y w:w |
1390 | 982 |
"draw the lines between start to stop without clearing the background |
983 |
" |
|
1557 | 984 |
highlightMode notNil ifTrue:[ |
3728 | 985 |
self selectionDo:[:lnNr| |
986 |
(lnNr between:start and:stop) ifTrue:[ |
|
987 |
self drawSelectionFrameAt:lnNr x:x w:w |
|
988 |
] |
|
989 |
] |
|
1390 | 990 |
]. |
2642 | 991 |
super drawFrom:start to:stop x:x y:y w:w. |
1390 | 992 |
! |
993 |
||
2377 | 994 |
drawLabelAt:anIndex x:xI y:y h:h |
1390 | 995 |
"draw the label at position x/y without clearing the background |
996 |
" |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
997 |
|item y0 x1 x w drawStrikeOut xOut0 xOut1| |
1554 | 998 |
|
2377 | 999 |
x := xI + 1. |
1755 | 1000 |
editorView notNil ifTrue:[ |
3728 | 1001 |
"/ there is an open editor for the line; thus no redraw for the label (hidden by editor) |
1002 |
self selectedIndex == anIndex ifTrue:[^ self]. |
|
1755 | 1003 |
]. |
1004 |
||
2408 | 1005 |
item := self at:anIndex ifAbsent:nil. |
2377 | 1006 |
item isNil ifTrue:[^ self]. |
1390 | 1007 |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1008 |
drawStrikeOut := false. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1009 |
|
2377 | 1010 |
(highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[ |
3728 | 1011 |
strikeOut ifTrue:[ |
1012 |
drawStrikeOut := true. |
|
1013 |
self paint:fgColor on:bgColor |
|
1014 |
] ifFalse:[ |
|
1015 |
(highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[ |
|
1016 |
self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus. |
|
1017 |
] ifFalse:[ |
|
1018 |
self paint:hilightFgColor on:hilightBgColor |
|
1019 |
]. |
|
1020 |
] |
|
2377 | 1021 |
] ifFalse:[ |
3728 | 1022 |
enterItem == item ifTrue:[ |
1023 |
self paint:hilightBgColor on:bgColor. |
|
1024 |
] ifFalse:[ |
|
1025 |
self paint:fgColor on:bgColor. |
|
1026 |
]. |
|
2377 | 1027 |
]. |
3728 | 1028 |
listRenderer display:item atX:x y:y lineHeight:h. |
1390 | 1029 |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1030 |
drawStrikeOut ifTrue:[ |
3728 | 1031 |
xOut0 := self xVisibleOfItem:item. |
1032 |
highlightMode == #label ifTrue:[ |
|
1033 |
xOut1 := xOut0 + (listRenderer widthFor:item). |
|
1034 |
] ifFalse:[ |
|
1035 |
xOut1 := width - margin. |
|
1036 |
]. |
|
1037 |
y0 := y + (h // 2). |
|
1038 |
self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0. |
|
1039 |
y0 := y0 - 1. |
|
1040 |
self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0. |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1041 |
]. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1042 |
|
3338 | 1043 |
cursorItem == item ifTrue:[ |
3728 | 1044 |
"/ textStartLeft |
1045 |
self maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)). |
|
1046 |
self mask:lineMask. |
|
1047 |
w := listRenderer widthFor:item. |
|
1048 |
self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4). |
|
1049 |
self mask:nil. |
|
3338 | 1050 |
] ifFalse:[ |
3728 | 1051 |
enterItem == item ifTrue:[ |
1052 |
self highlightWithUnderline ifTrue:[ |
|
1053 |
"/ underline the hilite... |
|
1054 |
y0 := y + h - 2. |
|
1055 |
x1 := x + (listRenderer widthFor:item). |
|
1056 |
||
1057 |
self displayLineFromX:x y:y0 toX:x1 y:y0. |
|
1058 |
] |
|
1059 |
]. |
|
2377 | 1060 |
]. |
1390 | 1061 |
! |
1062 |
||
1554 | 1063 |
drawSelectionFrameAt:lnNr x:x w:w |
1064 |
"draw the background and foreground of the selection frame |
|
1065 |
at a lineNr. |
|
1390 | 1066 |
" |
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1067 |
|item xMax xLftDmg xRgtDmg x0 x1 y0 y1 hL wL| |
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1068 |
|
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1069 |
(strikeOut or:[highlightMode isNil]) ifTrue:[ |
3728 | 1070 |
^ self |
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1071 |
]. |
1755 | 1072 |
editorView notNil ifTrue:[ |
3728 | 1073 |
"/ there is an open editor; do not redraw selected |
1074 |
^ self |
|
1755 | 1075 |
]. |
3367 | 1076 |
|
1077 |
( highlightMode == #line |
|
1078 |
or:[highlightMode == #label |
|
1079 |
or:[highlightMode == #dropMode]] |
|
1080 |
) ifFalse:[ |
|
3728 | 1081 |
"/ highlightMode not supported |
1082 |
^ self |
|
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1083 |
]. |
2408 | 1084 |
(item := self at:lnNr ifAbsent:nil) isNil ifTrue:[ |
3728 | 1085 |
"/ list might change during drawing; item no longer visible |
1086 |
^ self |
|
1554 | 1087 |
]. |
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1088 |
xMax := x + w. |
1554 | 1089 |
|
1090 |
"/ CLEAR THE BACKGROUND |
|
1091 |
||
1092 |
y0 := self yVisibleOfLine:lnNr. |
|
1093 |
y1 := self yVisibleOfLine:(lnNr + 1). |
|
1094 |
hL := y1 - y0. |
|
1095 |
||
1096 |
highlightMode == #line ifTrue:[ |
|
3728 | 1097 |
x0 := x. |
1098 |
x1 := xMax. |
|
3367 | 1099 |
] ifFalse:[ "/ is #label or #rectangle |
3728 | 1100 |
x0 := (self xVisibleOfItem:item) - (textStartLeft // 2). |
1101 |
x0 >= xMax ifTrue:[ ^ self ]. |
|
1102 |
||
1103 |
x1 := x0 + (listRenderer widthFor:item) + textStartLeft + 1. |
|
1104 |
x1 < x ifTrue:[ ^ self ]. |
|
1554 | 1105 |
]. |
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1106 |
xLftDmg := x0 max:x. |
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1107 |
xRgtDmg := x1 min:xMax. |
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1108 |
xRgtDmg > xLftDmg ifFalse:[^ self]. |
1554 | 1109 |
|
3367 | 1110 |
(highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[ |
3728 | 1111 |
self paint:hilightBgColorNoFocus. |
3367 | 1112 |
] ifFalse:[ |
3728 | 1113 |
self paint:hilightBgColor. |
3137 | 1114 |
]. |
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1115 |
self fillRectangleX:xLftDmg y:y0 width:(xRgtDmg - xLftDmg) height:hL. |
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1116 |
wL := x1 - x0. |
1554 | 1117 |
|
1118 |
"/ DRAW THE FRAME |
|
1390 | 1119 |
|
1120 |
hilightFrameColor notNil ifTrue:[ |
|
3728 | 1121 |
hilightLevel == 0 ifTrue:[ |
1122 |
self paint:hilightFrameColor. |
|
1123 |
||
1124 |
highlightMode == #line ifTrue:[ |
|
1125 |
self displayLineFromX:x0 y:y0 toX:x1 y:y0. |
|
1126 |
y1 := y0 + hL - 1. |
|
1127 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
|
1128 |
] ifFalse:[ |
|
1129 |
self displayRectangleX:x0 y:y0 width:wL height:hL |
|
1130 |
]. |
|
1131 |
^ self. |
|
1132 |
] |
|
1390 | 1133 |
] ifFalse:[ |
3728 | 1134 |
hilightStyle == #motif ifTrue:[ |
1135 |
self paint:bgColor. |
|
1136 |
y1 := y0 + 1. |
|
1137 |
highlightMode == #line ifTrue:[ |
|
1138 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
|
1139 |
y1 := y0 + hL - 2. |
|
1140 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
|
1141 |
] ifFalse:[ |
|
1142 |
self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2 |
|
1143 |
] |
|
1144 |
]. |
|
1145 |
hilightLevel == 0 ifTrue:[ ^ self ]. |
|
1390 | 1146 |
]. |
1147 |
||
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1148 |
"/ draw edge |
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1149 |
highlightMode == #line ifTrue:[ |
3728 | 1150 |
x0 := margin. |
1151 |
wL := width - x0 - x0. |
|
2646
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1152 |
]. |
8be2becc5152
drawSelectionFrameAt:.. clear damaged background not items background
ca
parents:
2644
diff
changeset
|
1153 |
self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel. |
1390 | 1154 |
! |
1155 |
||
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
|
1156 |
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
|
1157 |
"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
|
1158 |
" |
95f294d62b07
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4181
diff
changeset
|
1159 |
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
|
1160 |
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
|
1161 |
(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
|
1162 |
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
|
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 |
] |
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 |
]. |
95f294d62b07
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4181
diff
changeset
|
1166 |
|
95f294d62b07
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4181
diff
changeset
|
1167 |
"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
|
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 |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1170 |
invalidateSelection |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1171 |
"invalidate the current selection |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1172 |
" |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1173 |
shown ifTrue:[ |
3728 | 1174 |
self selectionDo:[:aLnNr| |
1175 |
self invalidateLineAt:aLnNr |
|
1176 |
]. |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1177 |
]. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1178 |
! |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1179 |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
1180 |
invalidateSelectionAt:aLineNr |
1569 | 1181 |
"redraw a line which changed its selection status. |
1182 |
optimized when drawing only the label. |
|
1390 | 1183 |
" |
2323 | 1184 |
|item x| |
1569 | 1185 |
|
1755 | 1186 |
editorView notNil ifTrue:[ |
3728 | 1187 |
"/ there is an open editor; do not redraw selected |
1188 |
^ self |
|
1755 | 1189 |
]. |
1190 |
||
1569 | 1191 |
(shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[ |
3728 | 1192 |
^ self |
1557 | 1193 |
]. |
1194 |
||
2323 | 1195 |
highlightMode == #label ifTrue:[ |
3728 | 1196 |
item := self at:aLineNr ifAbsent:nil. |
1197 |
||
1198 |
item isNil ifTrue:[ |
|
1199 |
^ self |
|
1200 |
]. |
|
1201 |
x := (self xVisibleOfItem:item) - (textStartLeft // 2) |
|
1569 | 1202 |
] ifFalse:[ |
3728 | 1203 |
x := 0. |
1569 | 1204 |
]. |
2323 | 1205 |
self invalidateLineAt:aLineNr fromX:x |
1390 | 1206 |
! ! |
1207 |
||
1208 |
!SelectionInListModelView methodsFor:'event handling'! |
|
1209 |
||
3750
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1210 |
activateMenu |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1211 |
|item menu appl| |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1212 |
|
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1213 |
enabled ifFalse:[^ self]. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1214 |
|
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1215 |
item := self selectedElement. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1216 |
item notNil ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1217 |
menu := item perform:#middleButtonMenu ifNotUnderstood:nil. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1218 |
menu notNil ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1219 |
menu isCollection ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1220 |
menu := Menu decodeFromLiteralArray:menu. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1221 |
appl := self application. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1222 |
|
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1223 |
appl notNil ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1224 |
menu findGuiResourcesIn:appl. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1225 |
"/ 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
|
1226 |
] ifFalse:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1227 |
menu receiver:item |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1228 |
] |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1229 |
]. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1230 |
self startUpMenu:menu. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1231 |
^ self |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1232 |
]. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1233 |
]. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1234 |
super activateMenu |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1235 |
! |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1236 |
|
2401 | 1237 |
buttonControlPressAtLine:lineNr x:x y:y |
1238 |
"handle a button control press |
|
1390 | 1239 |
" |
2401 | 1240 |
|isInSelection prvLine chgSet doAdd| |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
1241 |
|
2401 | 1242 |
isInSelection := self isInSelection:lineNr. |
1390 | 1243 |
|
2401 | 1244 |
multipleSelectOk ifFalse:[ |
3728 | 1245 |
isInSelection ifTrue:[ |
1246 |
self deselect |
|
1247 |
]ifFalse:[ |
|
1248 |
(self canSelectIndex:lineNr forAdd:false) ifTrue:[ |
|
1249 |
self buttonPressOrReleaseAtLine:lineNr x:x y:y. |
|
1250 |
]. |
|
1251 |
]. |
|
1252 |
^ self |
|
1390 | 1253 |
]. |
2410 | 1254 |
isInSelection ifTrue:[ |
3728 | 1255 |
self removeFromSelection:lineNr |
2410 | 1256 |
] ifFalse:[ |
3728 | 1257 |
self addToSelection:lineNr. |
1258 |
||
1259 |
(self isInSelection:lineNr) ifFalse:[ |
|
1260 |
"/ cannot add to selection |
|
1261 |
^ self |
|
1262 |
]. |
|
1390 | 1263 |
]. |
1264 |
||
2401 | 1265 |
prvLine := lineNr. |
1266 |
chgSet := IdentitySet new. |
|
1267 |
doAdd := isInSelection not. |
|
1268 |
||
1269 |
buttonMotionAction := [:p| |rowNr mustRestore step f| |
|
3728 | 1270 |
rowNr := self yVisibleToLineNr:(p y). |
1271 |
||
1272 |
(rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[ |
|
1273 |
rowNr == lineNr ifTrue:[ |
|
1274 |
mustRestore := true |
|
1275 |
] ifFalse:[ |
|
1276 |
rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ] |
|
1277 |
ifFalse:[ mustRestore := (rowNr > prvLine) ]. |
|
1278 |
]. |
|
1279 |
prvLine > rowNr ifTrue:[ step := -1 ] |
|
1280 |
ifFalse:[ step := 1 ]. |
|
1281 |
mustRestore ifTrue:[ |
|
1282 |
[ prvLine ~~ rowNr ] whileTrue:[ |
|
1283 |
(chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[ |
|
1284 |
doAdd ifFalse:[ self addToSelection:prvLine ] |
|
1285 |
ifTrue:[ self removeFromSelection:prvLine ]. |
|
1286 |
]. |
|
1287 |
prvLine := prvLine + step. |
|
1288 |
]. |
|
1289 |
] ifFalse:[ |
|
1290 |
[ prvLine ~~ rowNr ] whileTrue:[ |
|
1291 |
prvLine := prvLine + step. |
|
1292 |
||
1293 |
doAdd ~~ (self isInSelection:rowNr) ifTrue:[ |
|
1294 |
chgSet add:prvLine. |
|
1295 |
||
1296 |
doAdd ifTrue:[ self addToSelection:prvLine ] |
|
1297 |
ifFalse:[ self removeFromSelection:prvLine ]. |
|
1298 |
] |
|
1299 |
]. |
|
1300 |
]. |
|
1301 |
]. |
|
1748 | 1302 |
]. |
2401 | 1303 |
! |
1748 | 1304 |
|
2401 | 1305 |
buttonMotion:buttonMask x:x y:y |
1306 |
"mouse-move while button was pressed - handle selection changes |
|
1307 |
" |
|
1308 |
|lnNr item| |
|
1309 |
||
1748 | 1310 |
self stopAutoScroll. |
1311 |
||
2441
9ca40d634ff8
attention - do no motionAction, if no button is pressed
Claus Gittinger <cg@exept.de>
parents:
2418
diff
changeset
|
1312 |
(buttonMask ~~ 0 and:[buttonMotionAction notNil]) ifTrue:[ |
3728 | 1313 |
buttonMotionAction value:(x@y). |
1314 |
||
1315 |
(autoScroll and:[buttonMotionAction notNil]) ifTrue:[ |
|
1316 |
"/ if moved outside of view, start autoscroll |
|
1317 |
(y between:0 and:height) ifFalse:[ |
|
1318 |
y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ] |
|
1319 |
ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ]. |
|
1320 |
]. |
|
1321 |
]. |
|
1322 |
^ self |
|
1390 | 1323 |
]. |
2401 | 1324 |
|
1325 |
(enabled and:[highlightEnterItem]) ifTrue:[ |
|
3728 | 1326 |
self sensor anyButtonPressed ifFalse:[ |
1327 |
lnNr := self yVisibleToLineNr:y. |
|
1328 |
||
1329 |
lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ] |
|
1330 |
ifFalse:[ item := nil ]. |
|
1331 |
||
1332 |
self pointerEntersItem:item. |
|
1333 |
] |
|
1334 |
]. |
|
1390 | 1335 |
! |
1336 |
||
1337 |
buttonMultiPress:button x:x y:y |
|
2948 | 1338 |
"button was pressed multiple - handle a doubleClick action" |
1339 |
||
3704
c9b2102bfd1c
handle doubleClick - element under point is not selected
ca
parents:
3684
diff
changeset
|
1340 |
|lnNr item| |
c9b2102bfd1c
handle doubleClick - element under point is not selected
ca
parents:
3684
diff
changeset
|
1341 |
|
2401 | 1342 |
buttonMotionAction := buttonReleaseAction := nil. |
1390 | 1343 |
|
1344 |
enabled ifFalse:[^ self]. |
|
1345 |
||
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1346 |
(button == 1) ifTrue:[ |
4043
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1347 |
( (lnNr := self yVisibleToLineNr:y) notNil |
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1348 |
and:[(item := self at:lnNr ifAbsent:nil) notNil] |
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1349 |
) ifTrue:[ |
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1350 |
self selectedIndex == lnNr ifFalse:[ |
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1351 |
self breakPoint:#ca |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1352 |
]. |
4043
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1353 |
self doubleClicked. |
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1354 |
"/ doubleClickActionBlock notNil ifTrue:[ |
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1355 |
"/ doubleClickActionBlock valueWithOptionalArgument:lnNr and:self. |
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1356 |
"/ ]. |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1357 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1358 |
^ self. |
1390 | 1359 |
]. |
2947 | 1360 |
|
2948 | 1361 |
super buttonMultiPress:button x:x y:y |
4043
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1362 |
|
532a328a9e0e
changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
3963
diff
changeset
|
1363 |
"Modified: / 30-06-2011 / 20:04:28 / cg" |
1390 | 1364 |
! |
1365 |
||
1366 |
buttonPress:button x:x y:y |
|
1367 |
"a button was pressed - handle selection here |
|
1368 |
" |
|
3146 | 1369 |
|sensor item menu appl isSelected lineNr startLine dragDistance| |
1390 | 1370 |
|
3205 | 1371 |
modelChangedDuringButtonPress := buttonMotionAction := buttonReleaseAction := nil. |
1390 | 1372 |
|
2323 | 1373 |
self pointerEntersItem:nil. |
2377 | 1374 |
self cursorEntersItem:nil. |
3728 | 1375 |
self closeEditor. |
2323 | 1376 |
|
1390 | 1377 |
enabled ifFalse:[^ self]. |
1378 |
||
2228 | 1379 |
sensor := self sensor. |
2399 | 1380 |
lineNr := self yVisibleToLineNr:y. |
2228 | 1381 |
|
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1382 |
(button == 2) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1383 |
(self selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1384 |
( lineNr notNil |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1385 |
and:[self canSelectIndex:lineNr forAdd:false ] |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1386 |
) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1387 |
(lineNr ~~ self selectedIndex) ifTrue: [ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1388 |
(self selectWithoutScroll:lineNr redraw:true) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1389 |
self selectionChanged |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1390 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1391 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1392 |
] |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1393 |
]. |
3750
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1394 |
item := self selectedElement. |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1395 |
item notNil ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1396 |
self makeSelectionVisible. |
3750
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1397 |
"/ now in activateMenu... |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1398 |
"/ menu := item perform:#middleButtonMenu ifNotUnderstood:nil. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1399 |
"/ menu notNil ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1400 |
"/ menu isCollection ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1401 |
"/ menu := Menu decodeFromLiteralArray:menu. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1402 |
"/ appl := self application. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1403 |
"/ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1404 |
"/ appl notNil ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1405 |
"/ menu findGuiResourcesIn:appl. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1406 |
"/ "/ 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
|
1407 |
"/ ] ifFalse:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1408 |
"/ menu receiver:item |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1409 |
"/ ] |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1410 |
"/ ]. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1411 |
"/ self startUpMenu:menu. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1412 |
"/ ^ self |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1413 |
"/ ]. |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1414 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1415 |
super buttonPress:button x:x y:y. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1416 |
^ self |
1390 | 1417 |
]. |
3750
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1418 |
|
2399 | 1419 |
lineNr isNil ifTrue:[ ^ self ]. |
3205 | 1420 |
modelChangedDuringButtonPress := false. |
1578 | 1421 |
|
2401 | 1422 |
sensor ctrlDown ifTrue:[ |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1423 |
self buttonControlPressAtLine:lineNr x:x y:y. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1424 |
^ self |
2401 | 1425 |
]. |
1426 |
||
2976 | 1427 |
isSelected := self isInSelection:lineNr. |
1428 |
||
1429 |
(self canDrag and:[sensor shiftDown not]) ifTrue:[ |
|
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1430 |
dragDistance := UserPreferences current motionDistanceToStartDrag. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1431 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1432 |
isSelected ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1433 |
buttonMotionAction := |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1434 |
[:p| |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1435 |
((x@y) dist:p) > dragDistance ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1436 |
self startDragAt:p. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1437 |
] |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1438 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1439 |
buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1440 |
^ self. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1441 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1442 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1443 |
self selectOnButtonPress ifFalse: [ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1444 |
|oldSelection| |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1445 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1446 |
"/ set selection to line; |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1447 |
"/ 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
|
1448 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1449 |
oldSelection := selection copy. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1450 |
self selectAndUpdateModelWithoutChangeNotification: lineNr. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1451 |
self windowGroup processExposeEvents. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1452 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1453 |
buttonMotionAction := |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1454 |
[:p| |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1455 |
((x@y) dist:p) > dragDistance ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1456 |
|handler| |
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 |
handler := self startDragAt:p. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1459 |
handler contentsWillChange. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1460 |
"/ restore old selection |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1461 |
self selectAndUpdateModelWithoutChangeNotification: oldSelection. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1462 |
self windowGroup processExposeEvents. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1463 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1464 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1465 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1466 |
buttonReleaseAction := [ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1467 |
(self canSelectIndex:lineNr forAdd:false) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1468 |
"/ notify selection change |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1469 |
self selectionChanged. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1470 |
] ifFalse:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1471 |
"/ restore old selection |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1472 |
self selectAndUpdateModelWithoutChangeNotification: oldSelection. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1473 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1474 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1475 |
^ self |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1476 |
]. |
2976 | 1477 |
]. |
1390 | 1478 |
|
2401 | 1479 |
multipleSelectOk ifFalse:[ |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1480 |
(isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1481 |
self buttonPressOrReleaseAtLine:lineNr x:x y:y. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1482 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1483 |
(dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1484 |
buttonMotionAction := |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1485 |
[:p| |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1486 |
((x@y) dist:p) > dragDistance ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1487 |
self startDragAt:p. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1488 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1489 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1490 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1491 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1492 |
^ self |
2399 | 1493 |
]. |
2401 | 1494 |
startLine := lineNr. |
2399 | 1495 |
|
2401 | 1496 |
sensor shiftDown ifTrue:[ |min max| |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1497 |
(isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1498 |
^ self |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1499 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1500 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1501 |
multipleSelectOk ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1502 |
startLine := self firstInSelection. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1503 |
startLine isNil ifTrue:[ startLine := lineNr ]. |
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 |
startLine <= lineNr ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1506 |
self selectFrom:startLine to:lineNr. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1507 |
] ifFalse:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1508 |
startLine := self lastInSelection. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1509 |
self selectFrom:lineNr to:startLine. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1510 |
]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1511 |
] |
2401 | 1512 |
] ifFalse:[ |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1513 |
(isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1514 |
^ self |
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 |
self buttonPressOrReleaseAtLine:lineNr x:x y:y. |
1390 | 1517 |
]. |
1518 |
||
2401 | 1519 |
multipleSelectOk ifTrue:[ |
3740
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1520 |
buttonMotionAction := |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1521 |
[:p| |ln| |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1522 |
(p y between:0 and:height) ifTrue:[ |ln| |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1523 |
ln := self yVisibleToLineNr:p y. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1524 |
ln isNil ifTrue:[ln := self size]. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1525 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1526 |
(ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[ |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1527 |
self selectFrom:startLine to:ln. |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1528 |
dragDistance := nil. "/ selection changed - no longer dragable |
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1529 |
] |
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 |
|
67a77c2fcb03
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3728
diff
changeset
|
1532 |
(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
|
1533 |
self startDragAt:p. |
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 |
]. |
1915 | 1536 |
]. |
3221 | 1537 |
|
1538 |
"Modified: / 27-03-2007 / 08:43:58 / cg" |
|
1915 | 1539 |
! |
1540 |
||
1541 |
buttonPressOrReleaseAtLine:aLnNr x:x y:y |
|
1542 |
"handle a button press or release at a line |
|
1543 |
" |
|
1544 |
aLnNr == self selectedIndex ifTrue:[ |
|
3728 | 1545 |
editorView notNil ifTrue:[^ self]. |
1546 |
||
1547 |
self openEditorAction notNil ifTrue:[ |
|
1548 |
self openEditorAtX:x y:y. |
|
1549 |
editorView notNil ifTrue:[^ self]. |
|
1550 |
]. |
|
1551 |
||
1552 |
ignoreReselect ifFalse:[ |
|
1553 |
(toggleSelect and:[self sensor ctrlDown]) ifTrue:[ |
|
1554 |
self selection:nil |
|
1555 |
] ifFalse:[ |
|
1556 |
self selectionChanged |
|
1557 |
]. |
|
1558 |
]. |
|
1915 | 1559 |
] ifFalse:[ |
3728 | 1560 |
(self selectWithoutScroll:aLnNr redraw:true) ifTrue:[ |
1561 |
self selectionChanged |
|
1562 |
] |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1563 |
]. |
1390 | 1564 |
! |
1565 |
||
1566 |
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
|
1567 |
"a button was released" |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1568 |
|
3205 | 1569 |
|makeSelectionVisible| |
1570 |
||
3750
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1571 |
button == 1 ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1572 |
makeSelectionVisible := modelChangedDuringButtonPress. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1573 |
buttonMotionAction := modelChangedDuringButtonPress := nil. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1574 |
|
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1575 |
buttonReleaseAction notNil ifTrue:[ |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1576 |
buttonReleaseAction value. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1577 |
buttonReleaseAction := nil. |
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1578 |
]. |
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 |
self cursorEntersItem:nil. |
2401 | 1581 |
]. |
1748 | 1582 |
self stopAutoScroll. |
3205 | 1583 |
|
1584 |
(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
|
1585 |
self makeSelectionVisible |
3205 | 1586 |
]. |
3750
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1587 |
|
948546ea76a5
fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents:
3740
diff
changeset
|
1588 |
super buttonRelease:button x:x y:y |
1390 | 1589 |
! |
1590 |
||
1591 |
characterPress:aKey x:x y:y |
|
1592 |
" a character is pressed - lookup and change selection |
|
1593 |
" |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2455
diff
changeset
|
1594 |
|lnNr size idx stp to1 fr2| |
1390 | 1595 |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1596 |
size := self size. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1597 |
size > 1 ifFalse:[^ self]. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1598 |
|
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1599 |
lnNr := self firstInSelection. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1600 |
lnNr isNil ifTrue:[lnNr := 0]. |
1390 | 1601 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2455
diff
changeset
|
1602 |
self sensor shiftDown ifTrue:[ |
3728 | 1603 |
stp := -1. "/ search backward |
1604 |
to1 := 1. |
|
1605 |
fr2 := size. |
|
1390 | 1606 |
] ifFalse:[ |
3728 | 1607 |
stp := 1. "/ search forward |
1608 |
to1 := size. |
|
1609 |
fr2 := 1. |
|
1390 | 1610 |
]. |
1611 |
||
1612 |
idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey. |
|
1613 |
||
1614 |
idx == 0 ifTrue:[ |
|
3728 | 1615 |
idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey. |
1616 |
idx == 0 ifTrue:[^ self]. |
|
1390 | 1617 |
]. |
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1618 |
|
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1619 |
self selection:idx. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1620 |
|
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1621 |
keyActionStyle == #selectAndDoubleClick ifTrue:[ |
3728 | 1622 |
self doubleClicked |
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1623 |
]. |
1390 | 1624 |
! |
1625 |
||
1768
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1626 |
characterSearchItemStringAt:anIndex |
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1627 |
"for first-character search: |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1628 |
return a lines item-string. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1629 |
For multi-col items, this may be different from the actual string |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1630 |
" |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1631 |
|item s| |
1768
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1632 |
|
2408 | 1633 |
item := self at:anIndex ifAbsent:nil. |
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1634 |
|
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1635 |
item isHierarchicalItem ifTrue:[ |
3728 | 1636 |
item := item string |
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1637 |
]. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1638 |
item isNil ifTrue:[^ nil]. |
1768
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1639 |
|
2455
44300555526c
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
2447
diff
changeset
|
1640 |
(Error catch:[ |
3728 | 1641 |
s := item asString |
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1642 |
]) ifTrue:[ |
3728 | 1643 |
s := item displayString |
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1644 |
]. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
1645 |
^ s |
1768
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1646 |
! |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1647 |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1648 |
containerChangedSize |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1649 |
"/ 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
|
1650 |
"/ 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
|
1651 |
"/ 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
|
1652 |
|
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
1653 |
self hasSelection ifTrue:[ |
3728 | 1654 |
(hilightFrameColor notNil |
1655 |
or:[hilightStyle == #motif |
|
1656 |
or:[hilightLevel ~~ 0]]) ifTrue:[ |
|
1657 |
"/ invalidate the right-edge |
|
1658 |
self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))). |
|
1659 |
] |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1660 |
]. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1661 |
|
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1662 |
super containerChangedSize. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1663 |
! |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1664 |
|
2377 | 1665 |
cursorEntersItem:anItemOrNil |
1666 |
"the cursor enters an item or nil |
|
1667 |
" |
|
1668 |
|lnNr x| |
|
1669 |
||
2408 | 1670 |
(shown and:[self size ~~ 0]) ifFalse:[ |
3728 | 1671 |
cursorItem := nil. |
1672 |
^ self. |
|
2377 | 1673 |
]. |
1674 |
||
1675 |
anItemOrNil == cursorItem ifTrue:[ ^ self ]. |
|
1676 |
||
1677 |
2 timesRepeat:[ |
|
3728 | 1678 |
cursorItem notNil ifTrue:[ |
1679 |
lnNr := self identityIndexOf:cursorItem. |
|
1680 |
lnNr notNil ifTrue:[ |
|
1681 |
x := self xVisibleOfItem:cursorItem. |
|
1682 |
self invalidateLineAt:lnNr fromX:x |
|
1683 |
]. |
|
1684 |
]. |
|
1685 |
"/ set the new item |
|
1686 |
cursorItem := anItemOrNil. |
|
2377 | 1687 |
]. |
1688 |
cursorItem notNil ifTrue:[ |
|
3728 | 1689 |
self makeLineVisible:lnNr |
2377 | 1690 |
]. |
1691 |
! |
|
1692 |
||
1390 | 1693 |
doubleClicked |
1694 |
"handle a double click |
|
1695 |
" |
|
2416
dd563121a967
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2413
diff
changeset
|
1696 |
|arg| |
dd563121a967
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2413
diff
changeset
|
1697 |
|
dd563121a967
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2413
diff
changeset
|
1698 |
doubleClickActionBlock notNil ifTrue:[ |
3728 | 1699 |
arg := self selectedIndex. |
1700 |
||
1701 |
arg ~~ 0 ifTrue:[ |
|
1702 |
doubleClickActionBlock valueWithOptionalArgument:arg and:self. |
|
1703 |
] |
|
2416
dd563121a967
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2413
diff
changeset
|
1704 |
]. |
1390 | 1705 |
! |
1706 |
||
1707 |
findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter |
|
1708 |
"find a line starting with a character |
|
1709 |
" |
|
2408 | 1710 |
|char lbl cmp |
1390 | 1711 |
size "{ Class:SmallInteger }" |
1712 |
start "{ Class:SmallInteger }" |
|
1713 |
stop "{ Class:SmallInteger }" |
|
1714 |
| |
|
2408 | 1715 |
(size := self size) ~~ 0 ifTrue:[ |
3728 | 1716 |
aStep > 0 ifTrue:[ |
1717 |
aStart > aStop ifTrue:[^ 0]. |
|
1718 |
] ifFalse:[ |
|
1719 |
(aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0] |
|
1720 |
]. |
|
1721 |
||
1722 |
start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size]. |
|
1723 |
stop := aStop < 0 ifTrue:[1] ifFalse:[aStop min:size]. |
|
1724 |
char := aCharacter asUppercase. |
|
1725 |
||
1726 |
start to:stop by:aStep do:[:anIndex| |
|
1727 |
lbl := self characterSearchItemStringAt:anIndex. |
|
1728 |
lbl notNil ifTrue:[ |
|
1729 |
cmp := lbl string at:1 ifAbsent:nil. |
|
1730 |
||
1731 |
cmp notNil ifTrue:[ |
|
1732 |
(char == cmp or:[char == cmp asUppercase]) ifTrue:[ |
|
1733 |
(self canSelectIndex:anIndex forAdd:false) ifTrue:[ |
|
1734 |
^ anIndex |
|
1735 |
]. |
|
1736 |
^ 0 |
|
1737 |
] |
|
1738 |
] |
|
1739 |
] |
|
1740 |
] |
|
1390 | 1741 |
]. |
1742 |
^ 0 |
|
3081 | 1743 |
|
1744 |
"Modified: / 15-09-2006 / 11:26:29 / User" |
|
1390 | 1745 |
! |
1746 |
||
3338 | 1747 |
invalidateLineOfItem:anItem |
1748 |
|lnNr x| |
|
1749 |
||
1750 |
lnNr := self identityIndexOf:enterItem. |
|
1751 |
lnNr notNil ifTrue:[ |
|
3728 | 1752 |
x := self xVisibleOfItem:enterItem. |
1753 |
self invalidateLineAt:lnNr fromX:x |
|
3338 | 1754 |
]. |
1755 |
! |
|
1756 |
||
1390 | 1757 |
keyPress:aKey x:x y:y |
1758 |
"a key was pressed - handle page-keys here |
|
1759 |
" |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1760 |
<resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1761 |
#BeginOfText #BeginOfLine #Return |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1762 |
#CmdReturn #CmdCursorUp #CmdCursorDown #SelectAll)> |
1390 | 1763 |
|
2413 | 1764 |
|lineNr listSize shifted newSel step start| |
1390 | 1765 |
|
2377 | 1766 |
enabled ifFalse:[ ^ self ]. |
1767 |
||
2408 | 1768 |
listSize := self size. |
2377 | 1769 |
listSize == 0 ifTrue:[^ self]. |
1770 |
||
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1771 |
aKey isCharacter ifTrue:[ |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1772 |
keyActionStyle notNil ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1773 |
keyActionStyle == #pass ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1774 |
super keyPress:aKey x:x y:y |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1775 |
] ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1776 |
self characterPress:aKey x:x y:y. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1777 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1778 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1779 |
^ self |
1390 | 1780 |
]. |
1781 |
||
2377 | 1782 |
aKey == #Escape ifTrue:[ |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1783 |
cursorItem notNil ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1784 |
self cursorEntersItem:nil. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1785 |
self makeSelectionVisible. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1786 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1787 |
super keyPress:aKey x:x y:y. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1788 |
^ self |
1390 | 1789 |
]. |
1790 |
||
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1791 |
((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[ |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1792 |
self cursorEntersItem:nil. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1793 |
|
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1794 |
1 to:listSize do:[:i| |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1795 |
(self canSelectIndex:i forAdd:false) ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1796 |
self selection:i. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1797 |
^ self |
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 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1800 |
^ self |
1390 | 1801 |
]. |
1802 |
||
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1803 |
((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[ |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1804 |
self cursorEntersItem:nil. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1805 |
|
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1806 |
listSize to:1 by:-1 do:[:i| |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1807 |
(self canSelectIndex:i forAdd:false) ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1808 |
self selection:i. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1809 |
^ self |
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 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1812 |
^ self |
2377 | 1813 |
]. |
1814 |
lineNr := self cursorLine. |
|
1815 |
||
1816 |
aKey == #Return ifTrue:[ |
|
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1817 |
returnKeyActionStyle == #pass ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1818 |
super keyPress:aKey x:x y:y |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1819 |
] ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1820 |
lineNr ~~ 0 ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1821 |
self cursorEntersItem:nil. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1822 |
|
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1823 |
(self canSelectIndex:lineNr forAdd:false) ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1824 |
self selection:lineNr |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1825 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1826 |
]. |
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 |
returnKeyActionStyle == #doubleClick ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1829 |
self doubleClicked |
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 |
^ self |
2377 | 1833 |
]. |
2413 | 1834 |
|
3607 | 1835 |
aKey == #SelectAll ifTrue:[ |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1836 |
self selectAll. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1837 |
^ self |
3607 | 1838 |
]. |
1839 |
||
2413 | 1840 |
(lineNr == 0 and:[selection notNil]) ifTrue:[ |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1841 |
multipleSelectOk ifFalse:[lineNr := selection] |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1842 |
ifTrue:[lineNr := selection last]. |
2413 | 1843 |
]. |
1844 |
||
1845 |
aKey == #CmdReturn ifTrue:[ |
|
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1846 |
"/ toggle selection of the item |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1847 |
lineNr ~~ 0 ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1848 |
(self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ] |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1849 |
ifFalse:[ self addToSelection:lineNr ]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1850 |
|
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1851 |
self cursorEntersItem:(self at:lineNr). |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1852 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1853 |
^ self |
2413 | 1854 |
]. |
1855 |
||
1856 |
(aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]) ifTrue:[ |
|
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1857 |
aKey == #CmdCursorDown ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1858 |
lineNr := lineNr + 1. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1859 |
lineNr > listSize ifTrue:[lineNr := 1]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1860 |
] ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1861 |
lineNr := lineNr - 1. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1862 |
lineNr < 1 ifTrue:[lineNr := listSize]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1863 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1864 |
self cursorEntersItem:(self at:lineNr). |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1865 |
^ self |
2413 | 1866 |
]. |
1867 |
||
1868 |
(aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[ |
|
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1869 |
super keyPress:aKey x:x y:y. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1870 |
^ self |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1871 |
]. |
2413 | 1872 |
shifted := (multipleSelectOk and:[self sensor shiftDown]). |
2377 | 1873 |
self cursorEntersItem:nil. |
1874 |
||
2671 | 1875 |
aKey == #CursorDown ifTrue:[ step := 1.] |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1876 |
ifFalse:[ step := -1.]. |
2671 | 1877 |
|
1878 |
shifted ifFalse:[ |compressed| |
|
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1879 |
compressed := self sensor compressKeyPressEventsWithKey:aKey. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1880 |
|
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1881 |
compressed ~~ 0 ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1882 |
aKey == #CursorDown ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1883 |
lineNr := lineNr + compressed. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1884 |
lineNr > listSize ifTrue:[lineNr := 1]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1885 |
] ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1886 |
lineNr := lineNr - compressed. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1887 |
lineNr < 1 ifTrue:[lineNr := listSize]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1888 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1889 |
]. |
2671 | 1890 |
]. |
2377 | 1891 |
start := lineNr. |
1892 |
lineNr := lineNr + step. |
|
2368 | 1893 |
|
2377 | 1894 |
[ lineNr ~~ start ] whileTrue:[ |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1895 |
(lineNr between:1 and:listSize) ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1896 |
lineNr < 1 ifTrue:[ lineNr := listSize ] |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1897 |
ifFalse:[ lineNr := 1 ]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1898 |
] ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1899 |
(self canSelectIndex:lineNr forAdd:shifted) ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1900 |
shifted ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1901 |
self selection:lineNr. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1902 |
^ self |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1903 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1904 |
(self isInSelection:lineNr) ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1905 |
selection isNil ifTrue:[ newSel := Array with:lineNr ] |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1906 |
ifFalse:[ newSel := selection copyWith:lineNr ]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1907 |
] ifTrue:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1908 |
(start ~~ 0 and:[selection size > 1]) ifFalse:[ |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1909 |
^ self |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1910 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1911 |
newSel := selection copyWithout:start. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1912 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1913 |
self selection:newSel. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1914 |
"/ self selectWithoutScroll:newSel redraw:true. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1915 |
"/ self makeLineVisible:lineNr. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1916 |
"/ self selectionChanged. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1917 |
^ self |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1918 |
]. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1919 |
lineNr := lineNr + step. |
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
1920 |
] |
2377 | 1921 |
]. |
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1922 |
! |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1923 |
|
2323 | 1924 |
pointerEntersItem:anItemOrNil |
1925 |
"the pointer moves over an item or nil |
|
1926 |
" |
|
3338 | 1927 |
|newItem| |
2323 | 1928 |
|
2408 | 1929 |
(shown and:[self size ~~ 0]) ifFalse:[ |
3728 | 1930 |
enterItem := nil. |
1931 |
^ self. |
|
2323 | 1932 |
]. |
1933 |
||
1934 |
highlightEnterItem ifTrue:[ newItem := anItemOrNil ] |
|
3728 | 1935 |
ifFalse:[ newItem := nil ]. |
2323 | 1936 |
|
1937 |
anItemOrNil == enterItem ifTrue:[ ^ self ]. |
|
1938 |
||
3338 | 1939 |
enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ]. |
1940 |
enterItem := anItemOrNil. |
|
1941 |
enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ]. |
|
2323 | 1942 |
! |
1943 |
||
1944 |
pointerLeave:state |
|
1945 |
self pointerEntersItem:nil. |
|
1946 |
super pointerLeave:state. |
|
1947 |
! |
|
1948 |
||
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1949 |
sizeChanged:how |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1950 |
|selectionWasVisible| |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1951 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1952 |
selectionWasVisible := false. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1953 |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1954 |
"/ 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
|
1955 |
"/ 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
|
1956 |
"/ 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
|
1957 |
|
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
1958 |
self hasSelection ifTrue:[ |
3728 | 1959 |
selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent). |
1960 |
||
1961 |
(hilightFrameColor notNil |
|
1962 |
or:[hilightStyle == #motif |
|
1963 |
or:[hilightLevel ~~ 0]]) ifTrue:[ |
|
1964 |
"/ invalidate the right-edge |
|
1965 |
self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))). |
|
1966 |
]. |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1967 |
]. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1968 |
super sizeChanged:how. |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1969 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1970 |
selectionWasVisible ifTrue:[ |
3728 | 1971 |
self makeSelectionVisible |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1972 |
]. |
1390 | 1973 |
! ! |
1974 |
||
1421 | 1975 |
!SelectionInListModelView methodsFor:'focus handling'! |
1976 |
||
3137 | 1977 |
showFocus:explicit |
1978 |
self invalidateSelection. |
|
1979 |
super showFocus:explicit |
|
1980 |
! |
|
1981 |
||
1982 |
showNoFocus:explicit |
|
1983 |
self invalidateSelection. |
|
1984 |
super showNoFocus:explicit |
|
1985 |
! |
|
1986 |
||
1421 | 1987 |
wantsFocusWithPointerEnter |
1988 |
"return true, if I want the focus when |
|
1989 |
the mouse pointer enters" |
|
1990 |
||
2701
d95a0a764f4d
do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents:
2671
diff
changeset
|
1991 |
(editorView notNil and:[editorView realized]) ifTrue:[ |
3728 | 1992 |
^ false |
2701
d95a0a764f4d
do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents:
2671
diff
changeset
|
1993 |
]. |
d95a0a764f4d
do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents:
2671
diff
changeset
|
1994 |
|
2959 | 1995 |
(UserPreferences current focusFollowsMouse ~~ false |
1421 | 1996 |
and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true) |
1997 |
]) ifTrue:[ |
|
3728 | 1998 |
self size > 0 ifTrue:[ |
1999 |
^ true |
|
2000 |
] |
|
1421 | 2001 |
]. |
2002 |
^ false |
|
2003 |
! ! |
|
2004 |
||
2501 | 2005 |
!SelectionInListModelView methodsFor:'initialization & release'! |
1390 | 2006 |
|
2007 |
fetchResources |
|
2008 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
2009 |
*** called after a create or snapin to fetch all device resources |
|
2010 |
" |
|
2011 |
||
2012 |
super fetchResources. |
|
2013 |
||
2014 |
hilightFgColor := self colorOnDevice:hilightFgColor. |
|
2015 |
hilightBgColor := self colorOnDevice:hilightBgColor. |
|
2016 |
hilightFrameColor := self colorOnDevice:hilightFrameColor. |
|
2377 | 2017 |
lineMask := lineMask onDevice:device. |
3137 | 2018 |
|
2019 |
hilightFgColorNoFocus := self colorOnDevice:hilightFgColorNoFocus. |
|
2020 |
hilightBgColorNoFocus := self colorOnDevice:hilightBgColorNoFocus. |
|
1390 | 2021 |
! |
2022 |
||
2023 |
initStyle |
|
2024 |
"setup viewStyle specifics |
|
2025 |
" |
|
3728 | 2026 |
<resource: #style (#'selection.selectOnMenuButton' |
3851 | 2027 |
#'selection.font')> |
1390 | 2028 |
super initStyle. |
2029 |
||
2377 | 2030 |
lineMask isNil ifTrue:[ |
3851 | 2031 |
lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55]. |
2377 | 2032 |
]. |
2033 |
||
2228 | 2034 |
hilightFrameColor := nil. |
2035 |
hilightStyle := DefaultHilightStyle. |
|
2036 |
highlightMode := #label. |
|
2037 |
textStartLeft := 4. |
|
3461 | 2038 |
selectOnMenuButton := styleSheet at:#'selection.selectOnMenuButton' default:nil. |
2039 |
selectOnMenuButton isNil ifTrue:[ |
|
3851 | 2040 |
selectOnMenuButton := UserPreferences current selectOnRightClick |
3461 | 2041 |
]. |
1390 | 2042 |
|
3927 | 2043 |
self font:(SelectionInListView defaultFont). |
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
2044 |
|
1390 | 2045 |
device hasGrayscales ifTrue:[ |
3851 | 2046 |
" |
2047 |
must get rid of these hard codings |
|
2048 |
" |
|
2049 |
(hilightStyle == #next) ifTrue:[ |
|
2050 |
hilightFgColor := fgColor. |
|
2051 |
hilightBgColor := White. |
|
2052 |
hilightFrameColor := fgColor |
|
2053 |
] ifFalse:[ |
|
2054 |
(hilightStyle == #motif) ifTrue:[ |
|
2055 |
fgColor := White. |
|
2056 |
bgColor := Grey. |
|
2057 |
viewBackground := bgColor. |
|
2058 |
hilightFgColor := bgColor. |
|
2059 |
hilightBgColor := fgColor. |
|
2060 |
] ifFalse:[ |
|
2061 |
(hilightStyle == #openwin) ifTrue:[ |
|
2062 |
hilightFgColor := fgColor. |
|
2063 |
hilightBgColor := Color grey. |
|
2064 |
] |
|
2065 |
] |
|
2066 |
] |
|
1390 | 2067 |
]. |
2068 |
||
2069 |
hilightFgColor isNil ifTrue:[ |
|
3851 | 2070 |
hilightFgColor := bgColor. |
1390 | 2071 |
]. |
2072 |
hilightBgColor isNil ifTrue:[ |
|
3851 | 2073 |
hilightBgColor := fgColor. |
1390 | 2074 |
]. |
2075 |
DefaultForegroundColor notNil ifTrue:[ |
|
3851 | 2076 |
fgColor := DefaultForegroundColor |
1390 | 2077 |
]. |
2078 |
DefaultBackgroundColor notNil ifTrue:[ |
|
3851 | 2079 |
bgColor := viewBackground := DefaultBackgroundColor |
1390 | 2080 |
]. |
2081 |
||
2082 |
DefaultHilightForegroundColor notNil ifTrue:[ |
|
3851 | 2083 |
hilightFgColor := DefaultHilightForegroundColor |
1390 | 2084 |
]. |
2085 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
3851 | 2086 |
hilightBgColor := DefaultHilightBackgroundColor |
1390 | 2087 |
]. |
2088 |
DefaultHilightFrameColor notNil ifTrue:[ |
|
3851 | 2089 |
hilightFrameColor := DefaultHilightFrameColor |
1390 | 2090 |
]. |
2091 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
2092 |
hilightLevel := DefaultHilightLevel ? 0. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
2093 |
lineSpacing := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2]. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
2094 |
|
1390 | 2095 |
hilightFgColor isNil ifTrue:[ |
3851 | 2096 |
hilightFgColor := bgColor. |
2097 |
hilightBgColor := fgColor. |
|
3137 | 2098 |
]. |
2099 |
||
2100 |
hilightFgColorNoFocus isNil ifTrue:[ |
|
3851 | 2101 |
hilightFgColorNoFocus := hilightFgColor. |
3137 | 2102 |
]. |
2103 |
hilightBgColorNoFocus isNil ifTrue:[ |
|
3851 | 2104 |
hilightBgColorNoFocus := hilightBgColor lightened. |
1390 | 2105 |
]. |
3927 | 2106 |
|
2107 |
"Modified: / 14-08-2010 / 12:23:09 / cg" |
|
1390 | 2108 |
! |
2109 |
||
2110 |
initialize |
|
2111 |
"setup default attributes/behavior |
|
2112 |
" |
|
2418
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2113 |
multipleSelectOk := false. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2114 |
useIndex := true. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2115 |
ignoreReselect := true. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2116 |
toggleSelect := false. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2117 |
highlightEnterItem := false. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2118 |
strikeOut := false. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2119 |
|
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2120 |
keyActionStyle := #select. |
14a9dbec8434
support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents:
2416
diff
changeset
|
2121 |
returnKeyActionStyle := #doubleClick. |
2324 | 2122 |
|
3963
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2123 |
extraSpaceAtBottomForDrop := 20. |
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2124 |
|
2324 | 2125 |
super initialize. |
3963
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2126 |
|
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2127 |
"Modified: / 03-11-2010 / 01:34:54 / cg" |
1390 | 2128 |
! |
2129 |
||
1745 | 2130 |
mapped |
2131 |
"get selection from model; scroll to selection |
|
2132 |
" |
|
2133 |
super mapped. |
|
2134 |
self makeSelectionVisible. |
|
2135 |
! |
|
2136 |
||
1390 | 2137 |
realize |
2138 |
"get selection from model; scroll to selection |
|
2139 |
" |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
2140 |
self updateFromModel. |
1390 | 2141 |
super realize. |
2142 |
! ! |
|
2143 |
||
2493 | 2144 |
!SelectionInListModelView methodsFor:'private-editor'! |
1755 | 2145 |
|
2146 |
computeEditorLayout |
|
2147 |
"update the layout of the editor |
|
2148 |
" |
|
3526 | 2149 |
|lnNr item y0 x0 y1| |
1755 | 2150 |
|
2151 |
editorView isNil ifTrue:[ |
|
3728 | 2152 |
^ self |
1755 | 2153 |
]. |
2154 |
||
2155 |
( (lnNr := self selectedIndex) == 0 |
|
2408 | 2156 |
or:[(item := self at:lnNr ifAbsent:nil) isNil] |
1755 | 2157 |
) ifTrue:[ |
3728 | 2158 |
"/ there is no more single selection; thus close the editor |
2159 |
^ self closeEditor |
|
1755 | 2160 |
]. |
2161 |
||
3526 | 2162 |
x0 := (self xVisibleOfItem:item) - (textStartLeft // 2). |
2163 |
y0 := self yVisibleOfLine:lnNr. |
|
2164 |
y1 := self yVisibleOfLine:(lnNr + 1). |
|
1755 | 2165 |
|
3524 | 2166 |
minimumEditorHeight notNil ifTrue:[ |
3728 | 2167 |
y1 := y0 + ((y1 - y0) max:minimumEditorHeight). |
3524 | 2168 |
]. |
2632 | 2169 |
"/ Changed by cg: |
2170 |
"/ editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h + 2 "- 1") ). |
|
3526 | 2171 |
editorView layout:( Rectangle left:x0 top:y0-2 right:(width - 1 - margin) bottom:y1 ). |
1755 | 2172 |
! |
2173 |
||
2174 |
openEditorAtX:x y:y |
|
2175 |
"opens an editor on the current single selection |
|
2176 |
" |
|
2225 | 2177 |
|item lnNr x0 y0 editor| |
1755 | 2178 |
|
2179 |
self closeEditor. |
|
2308 | 2180 |
shown ifFalse:[^ self ]. |
2596 | 2181 |
self openEditorAction isNil ifTrue:[^ self]. |
1755 | 2182 |
|
2225 | 2183 |
lnNr := self selectedIndex. |
2184 |
lnNr == 0 ifTrue:[^ self]. |
|
2185 |
||
2408 | 2186 |
item := self at:lnNr ifAbsent:nil. |
2308 | 2187 |
item isNil ifTrue:[^ self]. |
1755 | 2188 |
|
1915 | 2189 |
x < (self xVisibleOfItem:item) ifTrue:[ |
3778 | 2190 |
"/ not part of the selection frame; ignorre |
2191 |
^ self |
|
1755 | 2192 |
]. |
2225 | 2193 |
editor := self openEditor. |
2308 | 2194 |
editor isNil ifTrue:[^ self]. |
1755 | 2195 |
|
2225 | 2196 |
y0 := (y - editor origin y) max:0. |
2197 |
x0 := (x - editor origin x) max:0. |
|
1755 | 2198 |
|
2125 | 2199 |
"/ simulate clicking into the editor |
2632 | 2200 |
|
2201 |
"/ Changed by cg: |
|
2202 |
"/ but only if there was no initial selection |
|
2203 |
editor isInputField ifTrue:[ |
|
3778 | 2204 |
editor hasSelection ifFalse:[ |
2205 |
self sensor |
|
2206 |
pushEvent:(WindowEvent buttonPress:1 x:x0 y:y0 view:editor); |
|
2207 |
pushEvent:(WindowEvent buttonRelease:1 x:x0 y:y0 view:editor). |
|
2208 |
] |
|
2632 | 2209 |
]. |
1755 | 2210 |
|
2211 |
"/ to clear the selection |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2212 |
self invalidateLineAt:lnNr. |
1755 | 2213 |
! ! |
2214 |
||
1390 | 2215 |
!SelectionInListModelView methodsFor:'protocol'! |
2216 |
||
1458 | 2217 |
lostSynchronisation |
2218 |
"called when the changes derived from the model are faster than the handling |
|
2219 |
" |
|
1547 | 2220 |
self deselectWithoutRedraw. |
1458 | 2221 |
super lostSynchronisation. |
1390 | 2222 |
! ! |
2223 |
||
2330 | 2224 |
!SelectionInListModelView methodsFor:'queries'! |
2225 |
||
2226 |
isCursorKeyConsumer |
|
2227 |
"return true, if the receiver can be controlled by cursor keys; |
|
2228 |
i.e. it can handle some keyboard input, |
|
2229 |
isCursorKeyConsumer are potential candidates for getting the keyboard |
|
2230 |
focus initially within dialogBoxes, or when the focus-follows-pointer |
|
2231 |
mode is off. |
|
2232 |
Return false here, this is redefined in SelectionInListView." |
|
2233 |
||
2234 |
^ true |
|
2235 |
! ! |
|
2236 |
||
3526 | 2237 |
!SelectionInListModelView methodsFor:'scroller interface'! |
2238 |
||
2239 |
heightOfContents |
|
2240 |
"answer the height of the contents in pixels. |
|
2241 |
If the minimumEditorHeight and the openEditorAction is defined, |
|
2242 |
we have to involve the minimumEditorHeight in the computation, |
|
2243 |
to allow opening the editor fullyvisible at the last line." |
|
2244 |
||
2245 |
|cachedLinesY cachedMaxIdx y0 y1| |
|
2246 |
||
2247 |
cachedLinesY := self startOfLinesY. |
|
2248 |
cachedMaxIdx := cachedLinesY size. |
|
2249 |
cachedMaxIdx == 0 ifTrue:[ ^ 0 ]. |
|
2250 |
||
2251 |
y1 := cachedLinesY at:cachedMaxIdx. |
|
2252 |
||
2253 |
(minimumEditorHeight notNil and:[openEditorAction notNil]) ifTrue:[ |
|
3963
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2254 |
y0 := cachedLinesY at:(cachedMaxIdx - 1) ifAbsent:0. |
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2255 |
y1 := y0 + ((y1 - y0) max:minimumEditorHeight). |
3526 | 2256 |
]. |
3963
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2257 |
^ y1 + extraSpaceAtBottomForDrop. |
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2258 |
|
9fd5330c7e40
fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents:
3927
diff
changeset
|
2259 |
"Modified: / 03-11-2010 / 01:35:05 / cg" |
3526 | 2260 |
! ! |
2261 |
||
1390 | 2262 |
!SelectionInListModelView methodsFor:'selection'! |
2263 |
||
2401 | 2264 |
addToSelection:lineNr |
2410 | 2265 |
"add line to selection without scrolling but raise a change notification |
2266 |
" |
|
2267 |
|oldSelect forAdd| |
|
2401 | 2268 |
|
2269 |
(self isInSelection:lineNr) ifTrue:[ |
|
3728 | 2270 |
^ self |
2401 | 2271 |
]. |
2272 |
||
2410 | 2273 |
multipleSelectOk ifTrue:[ forAdd := selection notNil ] |
3728 | 2274 |
ifFalse:[ forAdd := false ]. |
2410 | 2275 |
|
2276 |
(self canSelectIndex:lineNr forAdd:forAdd) ifFalse:[ |
|
3728 | 2277 |
^ self |
2401 | 2278 |
]. |
2279 |
||
2410 | 2280 |
self closeEditor. |
2281 |
self cursorEntersItem:nil. |
|
2282 |
||
2283 |
multipleSelectOk ifFalse:[ |
|
3728 | 2284 |
oldSelect := selection. |
2285 |
selection := lineNr. |
|
2286 |
oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ]. |
|
2410 | 2287 |
] ifTrue:[ |
3728 | 2288 |
selection notNil ifTrue:[ selection := selection copyWith:lineNr ] |
2289 |
ifFalse:[ selection := OrderedCollection with:lineNr ]. |
|
2401 | 2290 |
]. |
2291 |
self invalidateSelectionAt:lineNr. |
|
2292 |
self selectionChanged. |
|
2293 |
! |
|
2294 |
||
1390 | 2295 |
deselect |
2296 |
"clear selection |
|
2297 |
" |
|
2298 |
self selection:nil |
|
2299 |
||
2300 |
! |
|
2301 |
||
2302 |
firstInSelection |
|
2399 | 2303 |
"returns the minimum index of selected indices or nil if nothing is selected |
1390 | 2304 |
" |
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2305 |
|min| |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2306 |
|
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2307 |
multipleSelectOk ifFalse:[ ^ selection ]. |
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2308 |
selection size == 0 ifTrue:[ ^ nil ]. |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2309 |
|
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2310 |
min := selection at:1. |
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2311 |
selection do:[:aNumber| min := min min:aNumber ]. |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2312 |
^ min |
1390 | 2313 |
! |
2314 |
||
2315 |
hasSelection |
|
2316 |
"returns true if a selection exists |
|
2317 |
" |
|
2318 |
^ selection notNil |
|
2319 |
||
2320 |
! |
|
2321 |
||
2322 |
isInSelection:aNumber |
|
2323 |
"return true, if line, aNumber is in the selection |
|
2324 |
" |
|
1545 | 2325 |
multipleSelectOk ifFalse:[ |
3728 | 2326 |
^ (aNumber == selection) |
1545 | 2327 |
]. |
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2328 |
selection notNil ifTrue:[ |
3728 | 2329 |
^ selection includesIdentical:aNumber |
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2330 |
]. |
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2331 |
^ false |
1390 | 2332 |
! |
2333 |
||
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2334 |
isSelectionVisible |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2335 |
"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
|
2336 |
|
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2337 |
^ self isSelectionVisibleIn:(self extent) |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2338 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2339 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2340 |
isSelectionVisibleIn:anExtentPoint |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2341 |
"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
|
2342 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2343 |
self selectionDo:[:aLineNr| |
3728 | 2344 |
(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
|
2345 |
]. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
2346 |
^ false |
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 |
|
2330 | 2349 |
lastInSelection |
2399 | 2350 |
"returns the maximum index of selected indices or nil if nothing is selected |
2330 | 2351 |
" |
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2352 |
|max| |
2330 | 2353 |
|
2409
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2354 |
multipleSelectOk ifFalse:[ ^ selection ]. |
68095c891ceb
reuse selection methods (prepared for common controller)
ca
parents:
2408
diff
changeset
|
2355 |
selection size == 0 ifTrue:[ ^ nil ]. |
2330 | 2356 |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2357 |
max := 1. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2358 |
selection do:[:aNumber| max := max max:aNumber ]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2359 |
^ max |
2330 | 2360 |
! |
2361 |
||
2362 |
makeSelectionVisible |
|
2363 |
"scroll to make the selection line visible |
|
3202 | 2364 |
dont scroll, if any in the selection isVisible |
2330 | 2365 |
" |
3202 | 2366 |
|firstLine| |
2367 |
||
3205 | 2368 |
modelChangedDuringButtonPress notNil ifTrue:[^ self]. |
2369 |
||
3202 | 2370 |
firstLine := self firstInSelection. |
2371 |
(firstLine isNil or:[firstLine == 0]) ifTrue:[^ self]. |
|
2372 |
||
2373 |
self selectionDo:[:aLnNr| |
|
3889 | 2374 |
(self lineIsFullyVisible:aLnNr) ifTrue:[^ self]. |
3728 | 2375 |
]. |
2368 | 2376 |
self makeLineVisible:(self firstInSelection). |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2377 |
! |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2378 |
|
1390 | 2379 |
numberOfSelections |
2380 |
"return the number of selected items |
|
2381 |
" |
|
2330 | 2382 |
selection isNil ifTrue:[ ^ 0 ]. |
2383 |
multipleSelectOk ifFalse:[ ^ 1 ]. |
|
2384 |
^ selection size |
|
1390 | 2385 |
! |
2386 |
||
2401 | 2387 |
removeFromSelection:lineNr |
2410 | 2388 |
"remove line from selection without scrolling but raise a change notification |
2389 |
" |
|
2401 | 2390 |
(self isInSelection:lineNr) ifFalse:[ |
3728 | 2391 |
^ self |
2401 | 2392 |
]. |
2393 |
self closeEditor. |
|
2410 | 2394 |
self cursorEntersItem:nil. |
2401 | 2395 |
|
2410 | 2396 |
(multipleSelectOk and:[self numberOfSelections > 1]) ifTrue:[ |
3728 | 2397 |
selection := selection copyWithout:lineNr. |
2401 | 2398 |
] ifFalse:[ |
3728 | 2399 |
selection := nil |
2401 | 2400 |
]. |
2410 | 2401 |
self invalidateSelectionAt:lineNr. |
2402 |
self selectionChanged. |
|
2401 | 2403 |
! |
2404 |
||
3607 | 2405 |
selectAll |
3728 | 2406 |
"select all entries. |
3607 | 2407 |
Model and/or actionBlock notification IS done." |
2408 |
||
2409 |
self selectFrom:1 to:self size. |
|
2410 |
! |
|
2411 |
||
1390 | 2412 |
selectElement:anElement |
2413 |
"select the element. Scroll to make the new selection visible. |
|
2414 |
Model and/or actionBlock notification IS done. |
|
2415 |
" |
|
2178 | 2416 |
self selectElement:anElement ifAbsent:[self deselect] |
2417 |
! |
|
2418 |
||
2419 |
selectElement:anElement ifAbsent:exceptionalValue |
|
2420 |
|idx| |
|
2421 |
||
2408 | 2422 |
idx := self identityIndexOf:anElement. |
2178 | 2423 |
idx == 0 ifTrue:[ |
3728 | 2424 |
^ exceptionalValue value |
2178 | 2425 |
]. |
2426 |
self selection:idx |
|
1390 | 2427 |
! |
2428 |
||
4085
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2429 |
selectElementForWhich:aBlock ifAbsent:exceptionalValue |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2430 |
1 to:self size do:[:idx | |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2431 |
(aBlock value:(self at:idx)) ifTrue:[ |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2432 |
self selection:idx. |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2433 |
^ self |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2434 |
]. |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2435 |
]. |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2436 |
^ exceptionalValue value |
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2437 |
|
532e33c6a5e6
added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
4043
diff
changeset
|
2438 |
"Created: / 06-10-2011 / 13:32:28 / cg" |
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 |
|
2399 | 2441 |
selectFrom:aStart to:aStop |
2442 |
"select lines between start and stop |
|
2443 |
" |
|
2444 |
|start stop step nsel| |
|
2445 |
||
2446 |
multipleSelectOk ifFalse:[^ self]. |
|
2447 |
||
2448 |
start := aStart. |
|
2449 |
stop := aStop. |
|
2450 |
||
2451 |
aStart < aStop ifTrue:[ |
|
3728 | 2452 |
start := aStart max:1. |
2453 |
stop := aStop min:(self size). |
|
2454 |
step := 1. |
|
2455 |
start > stop ifTrue:[^ self]. |
|
2399 | 2456 |
|
2457 |
] ifFalse:[ |
|
3728 | 2458 |
start := aStart min:(self size). |
2459 |
stop := aStop max:1. |
|
2460 |
step := -1. |
|
2461 |
start < stop ifTrue:[^ self]. |
|
2399 | 2462 |
]. |
2463 |
nsel := OrderedCollection new. |
|
2464 |
||
2465 |
start to:stop by:step do:[:i| |
|
3728 | 2466 |
(self canSelectIndex:i forAdd:true) ifTrue:[ |
2467 |
nsel add:i. |
|
2468 |
]. |
|
2399 | 2469 |
]. |
2470 |
||
2471 |
(self selectWithoutScroll:nsel redraw:true) ifTrue:[ |
|
3728 | 2472 |
self selectionChanged |
2399 | 2473 |
]. |
2474 |
! |
|
2475 |
||
1390 | 2476 |
selectedElement |
2477 |
"return the single selected item or nil |
|
2478 |
" |
|
1545 | 2479 |
|index| |
1390 | 2480 |
|
1545 | 2481 |
(index := self selectedIndex) ~~ 0 ifTrue:[ |
3728 | 2482 |
^ self at:index ifAbsent:nil |
1545 | 2483 |
]. |
2484 |
^ nil |
|
1390 | 2485 |
! |
2486 |
||
2487 |
selectedIndex |
|
2488 |
"returns the index of the selected line or 0. If more |
|
2489 |
lines are selected, 0 is returned |
|
2490 |
" |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
2491 |
selection notNil ifTrue:[ |
3728 | 2492 |
multipleSelectOk ifFalse:[ ^ selection ]. |
2493 |
||
2494 |
selection size == 1 ifTrue:[ |
|
2495 |
^ selection at:1 |
|
2496 |
] |
|
1545 | 2497 |
]. |
2498 |
^ 0 |
|
1390 | 2499 |
! |
2500 |
||
2501 |
selection |
|
3728 | 2502 |
"return the selection index or collection of indices |
1390 | 2503 |
in case of multiple selection enabled |
2504 |
" |
|
2505 |
^ selection |
|
2506 |
||
2507 |
! |
|
2508 |
||
1545 | 2509 |
selection:something |
2510 |
"select something or deselect if the argument is nil; |
|
1390 | 2511 |
scroll to make the selected line visible. |
3873
ec4ba667fe41
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
2512 |
The model and/or actionBlock IS notified." |
ec4ba667fe41
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
2513 |
|
1545 | 2514 |
(self selectWithoutScroll:something redraw:true) ifTrue:[ |
3873
ec4ba667fe41
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
2515 |
self makeSelectionVisible. |
ec4ba667fe41
comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
2516 |
self selectionChanged |
1545 | 2517 |
]. |
1390 | 2518 |
! |
2519 |
||
2330 | 2520 |
selectionAsCollection |
2521 |
"return the selection as a collection of line numbers. |
|
2522 |
This allows users of this class to enumerate independent of |
|
2523 |
the multipleSelect style. |
|
2524 |
" |
|
2525 |
selection isNil ifTrue:[ ^ #() ]. |
|
2526 |
multipleSelectOk ifTrue:[ ^ selection ]. |
|
2527 |
||
2528 |
^ OrderedCollection with:selection |
|
2529 |
! |
|
2530 |
||
1390 | 2531 |
selectionDo:aBlock |
2532 |
"perform aBlock for each nr in the selection. |
|
2533 |
For single selection, it is called once for the items nr. |
|
2534 |
For multiple selections, it is called for each. |
|
2535 |
" |
|
2536 |
selection notNil ifTrue:[ |
|
3728 | 2537 |
multipleSelectOk ifTrue:[ |
2538 |
selection do:aBlock |
|
2539 |
] ifFalse:[ |
|
2540 |
aBlock value:selection |
|
2541 |
]. |
|
1390 | 2542 |
]. |
2543 |
||
2544 |
||
2545 |
! |
|
2546 |
||
2330 | 2547 |
selectionValue |
2548 |
"return the selection value i.e. the text in the selected line. |
|
2549 |
For multiple selections a collection containing the entries is returned. |
|
2550 |
" |
|
2551 |
multipleSelectOk ifTrue:[ |
|
3728 | 2552 |
selection isNil ifTrue:[^ #()]. |
2553 |
^ selection collect:[:nr| self at:nr ] |
|
2330 | 2554 |
]. |
2555 |
selection isNil ifTrue:[^ nil]. |
|
2408 | 2556 |
^ self at:selection ifAbsent:nil. |
2330 | 2557 |
! |
2558 |
||
2346 | 2559 |
selectionValueAsCollection |
2560 |
"return the selection values as a collection - allows selectionValues to |
|
2561 |
be enumerated independent of the multiSelect settings |
|
2562 |
" |
|
2563 |
|value| |
|
2564 |
||
2565 |
value := self selectionValue. |
|
2566 |
multipleSelectOk ifTrue:[^ value]. |
|
2567 |
||
2568 |
value notNil ifTrue:[^ Array with:value ]. |
|
2569 |
^ #() |
|
2570 |
! |
|
2571 |
||
1542
8607d072c319
accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
2572 |
setSelection:something |
1545 | 2573 |
"select something or deselect if the argument is nil; |
1390 | 2574 |
scroll to make the selected line visible. |
2575 |
*** No model and/or actionBlock notification is done here. |
|
2576 |
" |
|
1545 | 2577 |
(self selectWithoutScroll:something redraw:true) ifTrue:[ |
3728 | 2578 |
self makeSelectionVisible |
1390 | 2579 |
] |
2580 |
||
2581 |
! ! |
|
2582 |
||
2583 |
!SelectionInListModelView methodsFor:'selection private'! |
|
2584 |
||
1641 | 2585 |
canSelectIndex:anIndex |
2586 |
"return true, if the object identified by its index is selectable |
|
2587 |
" |
|
1920 | 2588 |
^ self canSelectIndex:anIndex forAdd:false |
2589 |
! |
|
2590 |
||
2591 |
canSelectIndex:anIndex forAdd:isForAdd |
|
2592 |
"return true, if the object identified by its index is selectable |
|
2593 |
" |
|
2594 |
|item isOk| |
|
1649 | 2595 |
|
2596 |
selectConditionBlock notNil ifTrue:[ |
|
3728 | 2597 |
isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd. |
2598 |
||
2599 |
isOk ifFalse:[ |
|
2600 |
^ false |
|
2601 |
] |
|
1641 | 2602 |
]. |
2603 |
||
2408 | 2604 |
item := self at:anIndex ifAbsent:nil. |
1752 | 2605 |
item isNil ifTrue:[^ false]. |
2408 | 2606 |
|
1752 | 2607 |
item isHierarchicalItem ifTrue:[ |
3728 | 2608 |
^ item isSelectable |
1649 | 2609 |
]. |
2610 |
^ true |
|
1641 | 2611 |
! |
2612 |
||
1547 | 2613 |
deselectWithoutRedraw |
2614 |
"clear the selection without redraw and scrolling; |
|
2615 |
the model and/or actionBlock is notified |
|
2616 |
" |
|
2617 |
(self selectWithoutScroll:nil redraw:false) ifTrue:[ |
|
3728 | 2618 |
self selectionChanged |
1547 | 2619 |
] |
2620 |
! |
|
2621 |
||
3370
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2622 |
selectAndUpdateModelWithoutChangeNotification: aLineNo |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2623 |
|arg| |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2624 |
|
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2625 |
self selectWithoutScroll:aLineNo redraw:true. |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2626 |
modelChangedDuringButtonPress := false. |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2627 |
model isNil ifTrue:[ ^ self ]. |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2628 |
arg := self argForChangeMessage. |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2629 |
self sendChangeMessage:#setValue: with:arg. |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2630 |
! |
5199f62a817d
Add posibility to configure the select behaviour (select on button press
ab
parents:
3367
diff
changeset
|
2631 |
|
1545 | 2632 |
selectWithoutScroll:something redraw:doRedraw |
2633 |
"change selection to something; returns true if selection changed |
|
1390 | 2634 |
" |
4242 | 2635 |
|oldSelect size| |
1390 | 2636 |
|
1554 | 2637 |
selection = something ifTrue:[^ false]. |
2638 |
||
1390 | 2639 |
oldSelect := selection. |
4242 | 2640 |
selection := nil. "/reset selection |
2641 |
size := self size. |
|
2642 |
||
2643 |
( size > 0 and:[ something notNil ] ) ifTrue:[ |
|
2644 |
something isNumber ifTrue:[ |
|
2645 |
(something between:1 and:size) ifTrue:[ |
|
2646 |
selection := multipleSelectOk ifTrue:[Array with:something] |
|
2647 |
ifFalse:[something] |
|
2648 |
] |
|
2649 |
] ifFalse:[ |
|
2650 |
something size > 0 ifTrue:[ |
|
2651 |
selection := OrderedCollection new. |
|
2652 |
something do:[:each| |
|
2653 |
each isNumber ifTrue:[ |
|
2654 |
(each between:1 and:size) ifTrue:[ |
|
2655 |
selection add: each. |
|
2656 |
] |
|
2657 |
] |
|
2658 |
]. |
|
2659 |
selection isEmpty ifTrue:[ |
|
2660 |
selection := nil. |
|
2661 |
] ifFalse:[ |
|
2662 |
multipleSelectOk ifFalse:[ selection := selection first ]. |
|
2663 |
]. |
|
2664 |
]. |
|
2665 |
]. |
|
1545 | 2666 |
]. |
2667 |
selection = oldSelect ifTrue:[^ false]. |
|
3205 | 2668 |
|
2669 |
modelChangedDuringButtonPress notNil ifTrue:[ |
|
4242 | 2670 |
modelChangedDuringButtonPress := true. |
3205 | 2671 |
]. |
2672 |
||
1755 | 2673 |
self closeEditor. |
2377 | 2674 |
self cursorEntersItem:nil. |
1545 | 2675 |
|
3728 | 2676 |
|
1545 | 2677 |
(doRedraw and:[shown]) ifFalse:[ |
4242 | 2678 |
^ true |
1390 | 2679 |
]. |
2680 |
||
2681 |
multipleSelectOk ifFalse:[ |
|
4242 | 2682 |
oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect]. |
2683 |
selection notNil ifTrue:[self invalidateSelectionAt:selection]. |
|
1390 | 2684 |
] ifTrue:[ |
4242 | 2685 |
(selection notNil and:[oldSelect notNil]) ifTrue:[ |
2686 |
selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]]. |
|
2687 |
oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]]. |
|
2688 |
] ifFalse:[ |
|
2689 |
oldSelect isNil ifTrue:[oldSelect := selection]. |
|
2690 |
oldSelect do:[:i|self invalidateSelectionAt:i] |
|
2691 |
] |
|
1390 | 2692 |
]. |
1545 | 2693 |
^ true |
1390 | 2694 |
! ! |
2695 |
||
2696 |
!SelectionInListModelView class methodsFor:'documentation'! |
|
2697 |
||
3778 | 2698 |
version_CVS |
4273
d56dfb04df83
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4258
diff
changeset
|
2699 |
^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.161 2013-07-13 20:31:53 cg Exp $' |
1390 | 2700 |
! ! |
4181
34f4fd818a18
class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents:
4085
diff
changeset
|
2701 |