author | Claus Gittinger <cg@exept.de> |
Mon, 11 May 2009 10:33:37 +0200 | |
changeset 2512 | 86e433bf6e7a |
parent 2504 | 8746b7a4d215 |
child 2534 | b717cb2e0cb8 |
permissions | -rw-r--r-- |
181 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
1120 | 3 |
All Rights Reserved |
181 | 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 |
" |
|
1399 | 12 |
"{ Package: 'stx:libtool2' }" |
13 |
||
181 | 14 |
NoteBookView subclass:#UIGalleryView |
15 |
instanceVariableNames:'majorKey minorKeys minorKeysHolder' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-UIPainter' |
|
19 |
! |
|
20 |
||
21 |
View subclass:#Canvas |
|
1675 | 22 |
instanceVariableNames:'clientSpecHolder selection specification lastClickPoint |
2200 | 23 |
menuSelector uiBuilder hiddenCounter showBorders' |
181 | 24 |
classVariableNames:'' |
25 |
poolDictionaries:'' |
|
26 |
privateIn:UIGalleryView |
|
27 |
! |
|
28 |
||
29 |
DropObject subclass:#DropSpec |
|
30 |
instanceVariableNames:'' |
|
247 | 31 |
classVariableNames:'' |
181 | 32 |
poolDictionaries:'' |
33 |
privateIn:UIGalleryView::Canvas |
|
34 |
! |
|
35 |
||
36 |
!UIGalleryView class methodsFor:'documentation'! |
|
37 |
||
38 |
copyright |
|
39 |
" |
|
40 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
1120 | 41 |
All Rights Reserved |
181 | 42 |
|
43 |
This software is furnished under a license and may be used |
|
44 |
only in accordance with the terms of that license and with the |
|
45 |
inclusion of the above copyright notice. This software may not |
|
46 |
be provided or otherwise made available to, or used by, any |
|
47 |
other person. No title to or ownership of the software is |
|
48 |
hereby transferred. |
|
49 |
" |
|
50 |
||
51 |
||
52 |
! |
|
53 |
||
54 |
documentation |
|
55 |
" |
|
56 |
implements a selection panel, keeping widgets which could be placed |
|
57 |
into other components by drag & drop or copy @ paste. The objects |
|
58 |
which are draged/droped must be kind of UISpecification's. |
|
59 |
The UISelectionPanel used by the UIPainter is implemented in this way. |
|
60 |
||
61 |
[author:] |
|
1120 | 62 |
Claus Gittinger |
63 |
Claus Atzkern |
|
181 | 64 |
|
65 |
[see also:] |
|
1120 | 66 |
UIPainter |
67 |
UISelectionPanel |
|
181 | 68 |
" |
69 |
||
70 |
! |
|
71 |
||
72 |
examples |
|
73 |
" |
|
74 |
opens a gallery |
|
75 |
||
1120 | 76 |
[exBegin] |
181 | 77 |
|top sel| |
78 |
||
79 |
top := StandardSystemView new label:'gallery'; extent:500@300. |
|
80 |
sel := UIGalleryView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
|
81 |
||
82 |
sel labels:#( 'Buttons' |
|
1120 | 83 |
'Panels' |
84 |
'Text' |
|
85 |
). |
|
181 | 86 |
|
191 | 87 |
sel minorKeys:#( #standardButtonToggle |
1120 | 88 |
#standardPanels |
89 |
#standardText |
|
90 |
). |
|
181 | 91 |
|
92 |
sel majorKey:UISelectionPanel. |
|
93 |
top open. |
|
1120 | 94 |
[exEnd] |
181 | 95 |
" |
96 |
! ! |
|
97 |
||
98 |
!UIGalleryView methodsFor:'accessing'! |
|
99 |
||
100 |
builder |
|
101 |
"get the builder used to setup a window from a specification (or nil in case |
|
102 |
of using a new builder) |
|
103 |
" |
|
104 |
^ canvas builder |
|
105 |
! |
|
106 |
||
107 |
builder:aBuilderOrNil |
|
108 |
"set the builder used to setup a window from a specification (or nil in case |
|
109 |
of using a new builder) |
|
110 |
" |
|
111 |
canvas builder:aBuilderOrNil |
|
112 |
! |
|
113 |
||
114 |
canvas:aCanvas |
|
115 |
^ self |
|
116 |
||
117 |
! |
|
118 |
||
119 |
labels:listOfLabels minorKeys:listOfMinorKeys majorKey:aMajorKey |
|
120 |
"setup for labels, selectors and class provider |
|
121 |
" |
|
122 |
self labels:listOfLabels. |
|
123 |
minorKeys := listOfMinorKeys. |
|
124 |
majorKey := aMajorKey. |
|
125 |
! |
|
126 |
||
127 |
majorKey |
|
128 |
"get the class providing the window specifications |
|
129 |
" |
|
130 |
^ majorKey |
|
131 |
! |
|
132 |
||
133 |
majorKey:aKey |
|
134 |
"get the class providing the window specifications |
|
135 |
" |
|
335 | 136 |
|appl| |
137 |
||
138 |
appl := self application. |
|
139 |
||
140 |
appl notNil ifTrue:[ |
|
1120 | 141 |
majorKey := appl resolveName:aKey |
335 | 142 |
] ifFalse:[ |
1120 | 143 |
majorKey := Smalltalk resolveName:aKey inClass:self class |
335 | 144 |
]. |
181 | 145 |
self selection:nil |
146 |
! |
|
147 |
||
148 |
minorKeys |
|
149 |
"get the list of selector keys |
|
150 |
" |
|
151 |
^ minorKeys |
|
152 |
! |
|
153 |
||
154 |
minorKeys:aListOfSelectors |
|
155 |
"set the list of selectors |
|
156 |
" |
|
157 |
minorKeys := aListOfSelectors. |
|
1140 | 158 |
self selection:nil. |
2200 | 159 |
! |
160 |
||
161 |
showBorders:aBoolean |
|
162 |
"show borders around dragable objects" |
|
163 |
||
164 |
canvas showBorders:aBoolean. |
|
165 |
! ! |
|
166 |
||
167 |
!UIGalleryView methodsFor:'accessing-colors'! |
|
168 |
||
169 |
viewBackground:aColor |
|
170 |
canvas notNil ifTrue:[ |
|
171 |
canvas viewBackground:aColor. |
|
172 |
]. |
|
173 |
^ super viewBackground:aColor |
|
181 | 174 |
! ! |
175 |
||
1399 | 176 |
!UIGalleryView methodsFor:'accessing-holders'! |
181 | 177 |
|
178 |
clientSpecHolder |
|
179 |
"get the holder which keeps the current selection or in case of |
|
180 |
no selection the specification under the cursor |
|
181 |
" |
|
182 |
^ canvas clientSpecHolder |
|
183 |
! |
|
184 |
||
185 |
clientSpecHolder:aHolder |
|
186 |
"set the holder which keeps the current selection or in case of |
|
187 |
no selection the specification under the cursor |
|
188 |
" |
|
189 |
canvas clientSpecHolder:aHolder |
|
190 |
! |
|
191 |
||
192 |
menuSelector |
|
193 |
^ canvas menuSelector |
|
194 |
! |
|
195 |
||
196 |
menuSelector:aSelector |
|
197 |
^ canvas menuSelector:aSelector |
|
198 |
! |
|
199 |
||
200 |
minorKeysHolder |
|
201 |
"get the holder keeping the minor keys; the selectors to access |
|
202 |
specifications from a class associated with the majorKey. |
|
203 |
" |
|
204 |
^ minorKeysHolder |
|
205 |
! |
|
206 |
||
207 |
minorKeysHolder:aValueHolder |
|
208 |
"set the holder keeping the minor keys; the selectors to access |
|
209 |
specifications from a class associated with the majorKey. |
|
210 |
" |
|
211 |
minorKeysHolder notNil ifTrue:[ |
|
1120 | 212 |
minorKeysHolder removeDependent:self. |
181 | 213 |
]. |
214 |
||
215 |
(minorKeysHolder := aValueHolder) notNil ifTrue:[ |
|
1120 | 216 |
minorKeysHolder addDependent:self. |
181 | 217 |
]. |
218 |
self minorKeys:(minorKeysHolder value) |
|
219 |
! ! |
|
220 |
||
221 |
!UIGalleryView methodsFor:'change & update'! |
|
222 |
||
1142 | 223 |
selectionHasChanged |
181 | 224 |
"selection changed |
225 |
" |
|
226 |
|specification selector selection application| |
|
227 |
||
1140 | 228 |
selection := self listIndexOf:(self selection). |
181 | 229 |
|
683 | 230 |
minorKeysHolder notNil ifTrue:[ |
1128 | 231 |
minorKeys := minorKeysHolder value. |
683 | 232 |
]. |
181 | 233 |
(selection notNil and:[minorKeys size >= selection]) ifTrue:[ |
1128 | 234 |
selector := minorKeys at:selection. |
181 | 235 |
|
1128 | 236 |
(majorKey respondsTo:selector) ifTrue:[ |
237 |
specification := majorKey perform:selector |
|
238 |
] ifFalse:[ |
|
239 |
(application := self application) notNil ifTrue:[ |
|
1576
ac7705f0a48d
Object messageNotUnderstoodSignal -> MessageNotUnderstood
ca
parents:
1568
diff
changeset
|
240 |
MessageNotUnderstood handle:[:ex| |
1128 | 241 |
(application class respondsTo:selector) ifTrue:[ |
242 |
specification := application class perform:selector |
|
243 |
] |
|
244 |
] do:[ |
|
245 |
specification := application aspectFor:selector |
|
246 |
] |
|
247 |
] |
|
248 |
] |
|
181 | 249 |
]. |
2199 | 250 |
"/ self withWaitCursorDo:[ |
2242
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
251 |
[ |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
252 |
canvas specification:specification. |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
253 |
] on:NotFoundError do:[:ex| |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
254 |
Transcript showCR:ex description. |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
255 |
ex proceed. |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
256 |
] |
2199 | 257 |
"/ ] |
181 | 258 |
! |
259 |
||
260 |
update |
|
1142 | 261 |
self selectionHasChanged. |
181 | 262 |
! |
263 |
||
264 |
update:something with:aParameter from:changedObject |
|
265 |
"one of my models changed its value |
|
266 |
" |
|
267 |
changedObject == minorKeysHolder ifTrue:[ |
|
1128 | 268 |
^ self minorKeys:( minorKeysHolder value) |
181 | 269 |
]. |
270 |
super update:something with:aParameter from:changedObject. |
|
271 |
||
272 |
! ! |
|
273 |
||
1337 | 274 |
!UIGalleryView methodsFor:'initialization & release'! |
181 | 275 |
|
276 |
initialize |
|
277 |
"setup default attributes |
|
278 |
" |
|
1729
cf1c2f488ba8
oops - do not mix class & instance in canvas-slot
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
279 |
canvas := Canvas in:self. |
181 | 280 |
|
281 |
super initialize. |
|
683 | 282 |
|
1142 | 283 |
self action:[:something| self selectionHasChanged ]. |
1582 | 284 |
! |
285 |
||
286 |
release |
|
287 |
minorKeysHolder notNil ifTrue:[ |
|
288 |
minorKeysHolder removeDependent:self. |
|
289 |
minorKeysHolder := nil. |
|
290 |
]. |
|
291 |
super release. |
|
181 | 292 |
! ! |
293 |
||
2495 | 294 |
!UIGalleryView::Canvas class methodsFor:'documentation'! |
295 |
||
296 |
documentation |
|
297 |
" |
|
298 |
I am the canvas of a gallery. Most of what I do is to allow dragging of widget out |
|
299 |
of myself and to care for the drawing of the selection. |
|
300 |
The arrangement into multiple pages is done by my container, which holds me |
|
301 |
in a subcanvas. |
|
302 |
" |
|
303 |
! ! |
|
304 |
||
181 | 305 |
!UIGalleryView::Canvas methodsFor:'accessing'! |
306 |
||
307 |
builder |
|
308 |
"get the builder used to setup a window from a specification (or nil in case |
|
309 |
of using a new builder) |
|
310 |
" |
|
311 |
^ uiBuilder |
|
312 |
! |
|
313 |
||
314 |
builder:something |
|
315 |
"set the builder used to setup a window from a specification (or nil in case |
|
316 |
of using a new builder) |
|
317 |
" |
|
318 |
uiBuilder := something. |
|
319 |
! |
|
320 |
||
321 |
clientSpecHolder |
|
322 |
"get the holder which keeps the current selection or in case of |
|
323 |
no selection the specification under the cursor |
|
324 |
" |
|
325 |
^ clientSpecHolder |
|
326 |
! |
|
327 |
||
328 |
clientSpecHolder:aHolder |
|
329 |
"set the holder which keeps the current selection or in case of |
|
330 |
no selection the specification under the cursor |
|
331 |
" |
|
1674 | 332 |
|spec| |
333 |
||
334 |
spec := clientSpecHolder value. |
|
335 |
||
336 |
aHolder notNil ifTrue:[ clientSpecHolder := aHolder ] |
|
337 |
ifFalse:[ clientSpecHolder := nil asValue ]. |
|
338 |
||
339 |
clientSpecHolder value:spec. |
|
181 | 340 |
! |
341 |
||
342 |
menuSelector |
|
343 |
"return the value of the instance variable 'menuSelector' (automatically generated)" |
|
344 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
345 |
^ menuSelector |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
346 |
! |
181 | 347 |
|
348 |
menuSelector:something |
|
349 |
"set the value of the instance variable 'menuSelector' (automatically generated)" |
|
350 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
351 |
menuSelector := something. |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
352 |
! |
181 | 353 |
|
2200 | 354 |
showBorders:aBoolean |
355 |
showBorders := aBoolean. |
|
356 |
! |
|
357 |
||
181 | 358 |
specification |
359 |
"get current specification |
|
360 |
" |
|
1674 | 361 |
^ specification |
181 | 362 |
! |
363 |
||
364 |
specification:aSpecOrSpecArray |
|
365 |
"set a new specification |
|
366 |
" |
|
367 |
|builder| |
|
368 |
||
369 |
self selection:nil. |
|
1674 | 370 |
self destroySubViews. |
181 | 371 |
|
1674 | 372 |
( aSpecOrSpecArray notNil |
373 |
and:[(specification := UISpecification from:aSpecOrSpecArray) notNil |
|
374 |
and:[specification respondsTo:#'buildViewFor:in:']] |
|
375 |
) ifFalse:[ |
|
376 |
specification := nil. |
|
377 |
^ self |
|
181 | 378 |
]. |
379 |
||
1674 | 380 |
(builder := uiBuilder) isNil ifTrue:[ |
381 |
builder := UIBuilder new isEditing:true. |
|
382 |
builder showDefaults:true. |
|
383 |
]. |
|
205 | 384 |
|
1674 | 385 |
specification buildViewFor:builder in:self. |
396 | 386 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
387 |
"/ components notEmptyOrNil ifTrue:[ self halt ]. |
1674 | 388 |
subViews size ~~ 0 ifTrue:[ |
2200 | 389 |
showBorders ifTrue:[ |
390 |
subViews do:[:v| |
|
391 |
(self findSpecFor:v) notNil ifTrue:[ |
|
392 |
v borderWidth:1 |
|
393 |
]. |
|
394 |
]. |
|
1561 | 395 |
]. |
1674 | 396 |
realized ifTrue:[ self realizeAllSubViews ]. |
397 |
]. |
|
181 | 398 |
! ! |
399 |
||
400 |
!UIGalleryView::Canvas methodsFor:'building'! |
|
401 |
||
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
402 |
recursiveBuildSpecFromSpecPrototype:aSpec |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
403 |
"build spec out of spec prototype" |
2495 | 404 |
|
181 | 405 |
|spec comp coll| |
406 |
||
407 |
(aSpec notNil and:[aSpec canUIDrag]) ifFalse:[ |
|
2495 | 408 |
^ nil |
181 | 409 |
]. |
410 |
||
411 |
spec := aSpec copy. |
|
412 |
(aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[ |
|
2495 | 413 |
^ spec |
181 | 414 |
]. |
415 |
comp := aSpec component. |
|
416 |
spec component:nil. |
|
417 |
||
418 |
comp canUIDrag ifFalse:[ |
|
2495 | 419 |
^ spec |
181 | 420 |
]. |
421 |
coll := OrderedCollection new. |
|
422 |
||
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
423 |
comp do:[:anEntry| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
424 |
|spc| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
425 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
426 |
(spc := self recursiveBuildSpecFromSpecPrototype:anEntry) notNil ifTrue:[ |
2495 | 427 |
coll add:spc |
428 |
] |
|
181 | 429 |
]. |
430 |
coll isEmpty ifTrue:[ |
|
2495 | 431 |
^ spec |
181 | 432 |
]. |
433 |
comp := comp copy. |
|
434 |
comp collection:coll. |
|
435 |
spec component:comp. |
|
2495 | 436 |
^ spec |
181 | 437 |
! ! |
438 |
||
439 |
!UIGalleryView::Canvas methodsFor:'drag & drop'! |
|
440 |
||
1675 | 441 |
startDragFrom:evView |
2495 | 442 |
"start drag at lastClickPoint" |
443 |
||
2204 | 444 |
|spec dragObj offset clickPos dragAndDropManager| |
1671 | 445 |
|
446 |
clickPos := lastClickPoint. |
|
447 |
clickPos isNil ifTrue:[^ self]. |
|
448 |
lastClickPoint := nil. |
|
449 |
||
1674 | 450 |
spec := clientSpecHolder value. |
1671 | 451 |
spec isNil ifTrue:[^ self]. |
181 | 452 |
|
2495 | 453 |
self withSelectionHiddenDo:[ |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
454 |
spec := self recursiveBuildSpecFromSpecPrototype:spec. |
1675 | 455 |
spec name:nil. |
1674 | 456 |
|
1675 | 457 |
dragObj := DropSpec for:selection specification:spec. |
458 |
offset := clickPos - selection origin. |
|
459 |
]. |
|
278 | 460 |
|
2204 | 461 |
dragAndDropManager := DragAndDropManager new. |
462 |
dragAndDropManager giveFocusToTargetWidget:false. |
|
463 |
||
2495 | 464 |
dragAndDropManager |
465 |
startDrag:dragObj |
|
466 |
from:self |
|
467 |
offset:offset |
|
468 |
atEnd:nil |
|
469 |
display:nil. |
|
181 | 470 |
! ! |
471 |
||
472 |
!UIGalleryView::Canvas methodsFor:'event handling'! |
|
473 |
||
1671 | 474 |
processEvent:anEvent |
1895 | 475 |
"filter keyboard events. |
476 |
Return true, if I have eaten the event" |
|
477 |
||
1674 | 478 |
|evView p| |
181 | 479 |
|
1671 | 480 |
evView := anEvent view. |
481 |
evView isNil ifTrue:[ ^ false ]. |
|
181 | 482 |
|
2201 | 483 |
(anEvent isButtonPressEvent or:[anEvent isButtonReleaseEvent])ifTrue:[ |
484 |
lastClickPoint := nil. |
|
485 |
]. |
|
1671 | 486 |
evView == self ifFalse:[ |
1674 | 487 |
(evView isComponentOf:self) ifFalse:[ ^ false ]. |
1671 | 488 |
]. |
181 | 489 |
|
1674 | 490 |
anEvent isButtonEvent ifFalse:[ |
491 |
anEvent isInputEvent ifTrue:[^ true]. |
|
2201 | 492 |
|
1675 | 493 |
anEvent isDamage ifTrue:[ self redrawSelection ]. |
1671 | 494 |
^ false |
495 |
]. |
|
181 | 496 |
|
2201 | 497 |
anEvent isButtonReleaseEvent ifTrue:[ ^ true ]. |
181 | 498 |
|
1674 | 499 |
anEvent isButtonMotionEvent ifTrue:[ |
500 |
(lastClickPoint notNil and:[anEvent state ~~ 0]) ifTrue:[ |
|
501 |
p := Point x:(anEvent x) y:(anEvent y). |
|
2201 | 502 |
p := device translatePoint:p fromView:evView toView:self. |
1671 | 503 |
|
2201 | 504 |
(lastClickPoint dist:p) > 20.0 ifTrue:[ |
1675 | 505 |
self startDragFrom:evView. |
506 |
lastClickPoint := nil. |
|
1671 | 507 |
] |
508 |
]. |
|
509 |
^ true |
|
510 |
]. |
|
511 |
||
2495 | 512 |
anEvent isButtonPressEvent ifTrue:[ |
513 |
|button application| |
|
514 |
||
1674 | 515 |
button := anEvent button. |
516 |
||
517 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
518 |
p := Point x:(anEvent x) y:(anEvent y). |
|
519 |
p := device translatePoint:p fromView:evView toView:self. |
|
520 |
||
521 |
self selection:(self findObjectAt:p). |
|
522 |
||
523 |
selection notNil ifTrue:[ |
|
2201 | 524 |
lastClickPoint := p. |
1674 | 525 |
] |
526 |
] ifFalse:[ |
|
527 |
(menuSelector notNil and:[(application := self application) notNil]) ifTrue:[ |
|
528 |
MessageNotUnderstood catch:[ |
|
529 |
application aspectFor:menuSelector |
|
530 |
] |
|
1671 | 531 |
] |
532 |
]. |
|
533 |
^ true |
|
534 |
]. |
|
535 |
||
536 |
^ true |
|
181 | 537 |
! ! |
538 |
||
2201 | 539 |
!UIGalleryView::Canvas methodsFor:'focus handling'! |
540 |
||
541 |
subviewsInFocusOrder |
|
542 |
"returns none views - focus not handled within buildin canvas" |
|
543 |
||
544 |
^ #() |
|
545 |
! ! |
|
546 |
||
181 | 547 |
!UIGalleryView::Canvas methodsFor:'initialization'! |
548 |
||
2200 | 549 |
destroy |
550 |
|winGrp| |
|
551 |
||
552 |
winGrp := self windowGroup. |
|
553 |
winGrp notNil ifTrue:[ |
|
554 |
winGrp removePreEventHook:self. |
|
555 |
]. |
|
556 |
super destroy. |
|
557 |
! |
|
558 |
||
181 | 559 |
initialize |
560 |
super initialize. |
|
1674 | 561 |
clientSpecHolder := nil asValue. |
1675 | 562 |
hiddenCounter := 0. |
2200 | 563 |
showBorders := true. |
1128 | 564 |
! |
565 |
||
1671 | 566 |
realize |
2200 | 567 |
|winGrp| |
568 |
||
1671 | 569 |
super realize. |
2200 | 570 |
winGrp := self windowGroup. |
571 |
winGrp notNil ifTrue:[ |
|
572 |
winGrp addPreEventHook:self. |
|
573 |
]. |
|
1671 | 574 |
! ! |
575 |
||
181 | 576 |
!UIGalleryView::Canvas methodsFor:'searching'! |
577 |
||
1674 | 578 |
findObjectAt:aPoint |
2495 | 579 |
|seeIfWidgetIsHit p x y| |
181 | 580 |
|
2495 | 581 |
seeIfWidgetIsHit := |
582 |
[:v | |
|
583 |
p := device translatePoint:aPoint fromView:self toView:v. |
|
584 |
x := p x. |
|
585 |
y := p y. |
|
181 | 586 |
|
2495 | 587 |
( x >= 0 and:[x <= v width |
588 |
and:[y >= 0 and:[y <= v height |
|
589 |
and:[(self findSpecFor:v) notNil]]]] |
|
590 |
) ifTrue:[ |
|
591 |
^ v |
|
592 |
] |
|
593 |
]. |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
594 |
|
2495 | 595 |
subViews notNil ifTrue:[ subViews do:seeIfWidgetIsHit ]. |
596 |
components notNil ifTrue:[ components do:seeIfWidgetIsHit ]. |
|
1671 | 597 |
^ nil |
181 | 598 |
! |
599 |
||
2495 | 600 |
findSpecFor:aWidget |
601 |
"returns the spec which is assigned to aWidget or nil" |
|
602 |
||
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
603 |
|name| |
181 | 604 |
|
2495 | 605 |
aWidget notNil ifTrue:[ |
606 |
name := aWidget name. |
|
181 | 607 |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
608 |
specification do:[:aSpec| |
1674 | 609 |
(aSpec notNil and:[aSpec name = name]) ifTrue:[ |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
610 |
aSpec canUIDrag ifFalse:[^ nil ]. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
611 |
^ aSpec |
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
612 |
] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
613 |
] |
181 | 614 |
]. |
615 |
^ nil |
|
616 |
||
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
617 |
"Modified: / 18.5.1999 / 14:47:25 / cg" |
181 | 618 |
! ! |
619 |
||
620 |
!UIGalleryView::Canvas methodsFor:'selection'! |
|
621 |
||
622 |
handlesOf:aComponent do:aOneArgBlock |
|
623 |
"evaluate the block on each handle; the argument to the block |
|
624 |
is a rectangle |
|
625 |
" |
|
626 |
aComponent notNil ifTrue:[ |
|
2504 | 627 |
aOneArgBlock value:(aComponent origin - (2@2) extent:6@6). |
628 |
aOneArgBlock value:(aComponent corner - (1@1) extent:6@6). |
|
629 |
aOneArgBlock value:(aComponent topRight - (1@2) extent:6@6). |
|
630 |
aOneArgBlock value:(aComponent bottomLeft - (2@1) extent:6@6). |
|
631 |
aOneArgBlock value:(aComponent leftCenter rounded - (2@0) extent:6@6). |
|
632 |
aOneArgBlock value:(aComponent rightCenter rounded - (1@0) extent:6@6). |
|
633 |
aOneArgBlock value:(aComponent topCenter rounded - (0@2) extent:6@6). |
|
634 |
aOneArgBlock value:(aComponent bottomCenter rounded - (0@1) extent:6@6). |
|
181 | 635 |
] |
636 |
! |
|
637 |
||
1675 | 638 |
redrawSelection |
2495 | 639 |
"redraw all items selected" |
640 |
||
1675 | 641 |
(shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[ |
642 |
self clippedByChildren:false. |
|
181 | 643 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
644 |
self paint:Color black. |
1675 | 645 |
self handlesOf:selection do:[:aRectangle| |
646 |
self fillRectangle:aRectangle |
|
647 |
]. |
|
648 |
self clippedByChildren:true. |
|
1671 | 649 |
]. |
650 |
! |
|
651 |
||
1674 | 652 |
selection:aView |
2495 | 653 |
"selection changed" |
654 |
||
1671 | 655 |
|spec| |
656 |
||
1674 | 657 |
selection == aView ifTrue:[^ self]. |
1671 | 658 |
|
2495 | 659 |
self withSelectionHiddenDo:[ |
1675 | 660 |
spec := self findSpecFor:aView. |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
661 |
|
2495 | 662 |
selection := (spec isNil) ifTrue:[nil] ifFalse:[aView]. |
1675 | 663 |
clientSpecHolder value:spec. |
664 |
]. |
|
665 |
! |
|
666 |
||
2495 | 667 |
withSelectionHiddenDo:aOneArgBlock |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
668 |
[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
669 |
|r forceExpose| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
670 |
|
2495 | 671 |
hiddenCounter := hiddenCounter + 1. |
1675 | 672 |
hiddenCounter == 1 ifTrue:[ |
673 |
(shown and:[selection notNil]) ifTrue:[ |
|
674 |
self clippedByChildren:false. |
|
675 |
||
676 |
self handlesOf:selection do:[:aRectangle| |
|
2495 | 677 |
self clearRectangle:aRectangle. |
678 |
self invalidateRectangle:aRectangle repairNow:false. |
|
1675 | 679 |
]. |
680 |
self clippedByChildren:true. |
|
1671 | 681 |
|
1675 | 682 |
r := selection bounds. |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
683 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
684 |
forceExpose := |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
685 |
[:sv| |
2495 | 686 |
|absOrg absFrame| |
1675 | 687 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
688 |
(sv bounds intersects:r) ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
689 |
sv isView ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
690 |
sv borderColor:(Color white). "/ kludge to force a redraw |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
691 |
sv borderColor:(Color black). |
1671 | 692 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
693 |
sv withAllSubViewsDo:[:v| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
694 |
v realized ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
695 |
v fill:v viewBackground. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
696 |
v exposeX:0 y:0 width:v width height:v height. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
697 |
] |
2495 | 698 |
] |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
699 |
] ifFalse:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
700 |
sv invalidate. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
701 |
]. |
1675 | 702 |
] |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
703 |
]. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
704 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
705 |
(subViews ? #()) do:forceExpose. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
706 |
(components ? #()) do:forceExpose. |
1675 | 707 |
]. |
708 |
]. |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
709 |
self repairDamage. "/ ensure that any outstanding clear/redraw of the unselect are done before |
1675 | 710 |
aOneArgBlock value. |
711 |
] ensure:[ |
|
2495 | 712 |
self repairDamage. "/ ensure that any outstanding clear/redraw of the unselect are done before |
713 |
||
1675 | 714 |
hiddenCounter := hiddenCounter - 1. |
715 |
self redrawSelection. |
|
716 |
]. |
|
181 | 717 |
! ! |
718 |
||
719 |
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
|
720 |
||
2495 | 721 |
for:aWidget specification:aSpec |
722 |
"create drop object for a widget derived from a specification" |
|
723 |
||
724 |
|point extent rootView device inst displayObject view| |
|
181 | 725 |
|
2495 | 726 |
device := aWidget device. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
727 |
rootView := device rootView. |
2495 | 728 |
extent := aWidget extent. |
729 |
aWidget isView ifTrue:[ |
|
730 |
view := aWidget. |
|
731 |
point := device translatePoint:0@0 fromView:aWidget toView:rootView. |
|
732 |
] ifFalse:[ |
|
733 |
view := aWidget container. |
|
734 |
point := device translatePoint:(aWidget origin) fromView:view toView:rootView. |
|
735 |
]. |
|
181 | 736 |
(point x > 0 and:[point y > 0]) ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
737 |
point := point + extent. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
738 |
(point x < rootView width and:[point y < rootView height]) ifTrue:[ |
2495 | 739 |
aWidget topView raise. |
1568
a9d61da29e8b
no need for device sync - flush will do
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
740 |
device flush. |
2495 | 741 |
aWidget invalidate. |
742 |
aWidget windowGroup processExposeEvents. |
|
743 |
displayObject := Image fromView:aWidget grab:false. |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
744 |
] |
181 | 745 |
]. |
806 | 746 |
displayObject isNil ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
747 |
displayObject := Form extent:extent depth:1. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
748 |
displayObject colorMap:(Array with:Color white with:Color black). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
749 |
displayObject fill:(Color colorId:0). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
750 |
displayObject paint:(Color colorId:1). |
2495 | 751 |
displayObject displayRectangleX:0 y:0 width:aWidget extent x height:aWidget extent y. |
181 | 752 |
]. |
753 |
aSpec class == UISubSpecification ifTrue:[ |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
754 |
aSpec layout:(LayoutOrigin fromPoint:0@0) |
181 | 755 |
]. |
240 | 756 |
|
806 | 757 |
inst := self new. |
758 |
inst displayObject:displayObject. |
|
759 |
inst theObject:aSpec. |
|
2495 | 760 |
^ inst. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
761 |
|
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
762 |
"Modified: / 10.10.2001 / 14:03:00 / cg" |
181 | 763 |
! ! |
764 |
||
765 |
!UIGalleryView class methodsFor:'documentation'! |
|
766 |
||
767 |
version |
|
768 |
^ '$Header$' |
|
769 |
! ! |