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