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