author | Stefan Vogel <sv@exept.de> |
Mon, 25 Feb 2008 20:11:20 +0100 | |
changeset 2282 | cc1eded4d84d |
parent 2242 | 63b5fdc3c8a3 |
child 2359 | d3f8b2492371 |
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 |
||
294 |
!UIGalleryView::Canvas methodsFor:'accessing'! |
|
295 |
||
296 |
builder |
|
297 |
"get the builder used to setup a window from a specification (or nil in case |
|
298 |
of using a new builder) |
|
299 |
" |
|
300 |
^ uiBuilder |
|
301 |
! |
|
302 |
||
303 |
builder:something |
|
304 |
"set the builder used to setup a window from a specification (or nil in case |
|
305 |
of using a new builder) |
|
306 |
" |
|
307 |
uiBuilder := something. |
|
308 |
! |
|
309 |
||
310 |
clientSpecHolder |
|
311 |
"get the holder which keeps the current selection or in case of |
|
312 |
no selection the specification under the cursor |
|
313 |
" |
|
314 |
^ clientSpecHolder |
|
315 |
! |
|
316 |
||
317 |
clientSpecHolder:aHolder |
|
318 |
"set the holder which keeps the current selection or in case of |
|
319 |
no selection the specification under the cursor |
|
320 |
" |
|
1674 | 321 |
|spec| |
322 |
||
323 |
spec := clientSpecHolder value. |
|
324 |
||
325 |
aHolder notNil ifTrue:[ clientSpecHolder := aHolder ] |
|
326 |
ifFalse:[ clientSpecHolder := nil asValue ]. |
|
327 |
||
328 |
clientSpecHolder value:spec. |
|
181 | 329 |
! |
330 |
||
331 |
menuSelector |
|
332 |
"return the value of the instance variable 'menuSelector' (automatically generated)" |
|
333 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
334 |
^ menuSelector |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
335 |
! |
181 | 336 |
|
337 |
menuSelector:something |
|
338 |
"set the value of the instance variable 'menuSelector' (automatically generated)" |
|
339 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
340 |
menuSelector := something. |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
341 |
! |
181 | 342 |
|
2200 | 343 |
showBorders:aBoolean |
344 |
showBorders := aBoolean. |
|
345 |
! |
|
346 |
||
181 | 347 |
specification |
348 |
"get current specification |
|
349 |
" |
|
1674 | 350 |
^ specification |
181 | 351 |
! |
352 |
||
353 |
specification:aSpecOrSpecArray |
|
354 |
"set a new specification |
|
355 |
" |
|
356 |
|builder| |
|
357 |
||
358 |
self selection:nil. |
|
1674 | 359 |
self destroySubViews. |
181 | 360 |
|
1674 | 361 |
( aSpecOrSpecArray notNil |
362 |
and:[(specification := UISpecification from:aSpecOrSpecArray) notNil |
|
363 |
and:[specification respondsTo:#'buildViewFor:in:']] |
|
364 |
) ifFalse:[ |
|
365 |
specification := nil. |
|
366 |
^ self |
|
181 | 367 |
]. |
368 |
||
1674 | 369 |
(builder := uiBuilder) isNil ifTrue:[ |
370 |
builder := UIBuilder new isEditing:true. |
|
371 |
builder showDefaults:true. |
|
372 |
]. |
|
205 | 373 |
|
1674 | 374 |
specification buildViewFor:builder in:self. |
396 | 375 |
|
1674 | 376 |
subViews size ~~ 0 ifTrue:[ |
2200 | 377 |
showBorders ifTrue:[ |
378 |
subViews do:[:v| |
|
379 |
(self findSpecFor:v) notNil ifTrue:[ |
|
380 |
v borderWidth:1 |
|
381 |
]. |
|
382 |
]. |
|
1561 | 383 |
]. |
1674 | 384 |
realized ifTrue:[ self realizeAllSubViews ]. |
385 |
]. |
|
181 | 386 |
! ! |
387 |
||
388 |
!UIGalleryView::Canvas methodsFor:'building'! |
|
389 |
||
390 |
buildSpecFrom:aSpec |
|
391 |
"build spec out of spec |
|
392 |
" |
|
393 |
|spec comp coll| |
|
394 |
||
395 |
(aSpec notNil and:[aSpec canUIDrag]) ifFalse:[ |
|
1120 | 396 |
^ nil |
181 | 397 |
]. |
398 |
||
399 |
spec := aSpec copy. |
|
400 |
||
401 |
(aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[ |
|
1120 | 402 |
^ spec |
181 | 403 |
]. |
404 |
comp := aSpec component. |
|
405 |
spec component:nil. |
|
406 |
||
407 |
comp canUIDrag ifFalse:[ |
|
408 |
^ spec |
|
409 |
]. |
|
410 |
coll := OrderedCollection new. |
|
411 |
||
412 |
comp do:[:anEntry||spc| |
|
1120 | 413 |
(spc := self buildSpecFrom:anEntry) notNil ifTrue:[ |
414 |
coll add:spc |
|
415 |
] |
|
181 | 416 |
]. |
417 |
coll isEmpty ifTrue:[ |
|
418 |
^ spec |
|
419 |
]. |
|
420 |
comp := comp copy. |
|
421 |
comp collection:coll. |
|
422 |
spec component:comp. |
|
423 |
^ spec |
|
424 |
||
425 |
||
426 |
||
427 |
||
428 |
! ! |
|
429 |
||
430 |
!UIGalleryView::Canvas methodsFor:'drag & drop'! |
|
431 |
||
1675 | 432 |
startDragFrom:evView |
1671 | 433 |
"start drag at a point |
181 | 434 |
" |
2204 | 435 |
|spec dragObj offset clickPos dragAndDropManager| |
1671 | 436 |
|
437 |
clickPos := lastClickPoint. |
|
438 |
clickPos isNil ifTrue:[^ self]. |
|
439 |
lastClickPoint := nil. |
|
440 |
||
1674 | 441 |
spec := clientSpecHolder value. |
1671 | 442 |
spec isNil ifTrue:[^ self]. |
181 | 443 |
|
1675 | 444 |
self selectionHiddenDo:[ |
445 |
spec := self buildSpecFrom:spec. |
|
446 |
spec name:nil. |
|
1674 | 447 |
|
1675 | 448 |
dragObj := DropSpec for:selection specification:spec. |
449 |
offset := clickPos - selection origin. |
|
450 |
]. |
|
278 | 451 |
|
2204 | 452 |
dragAndDropManager := DragAndDropManager new. |
453 |
dragAndDropManager giveFocusToTargetWidget:false. |
|
454 |
||
455 |
dragAndDropManager startDrag:dragObj |
|
456 |
from:self |
|
457 |
offset:offset |
|
458 |
atEnd:nil |
|
459 |
display:nil. |
|
181 | 460 |
! ! |
461 |
||
462 |
!UIGalleryView::Canvas methodsFor:'event handling'! |
|
463 |
||
1671 | 464 |
processEvent:anEvent |
1895 | 465 |
"filter keyboard events. |
466 |
Return true, if I have eaten the event" |
|
467 |
||
1674 | 468 |
|evView p| |
181 | 469 |
|
1671 | 470 |
evView := anEvent view. |
471 |
evView isNil ifTrue:[ ^ false ]. |
|
181 | 472 |
|
2201 | 473 |
(anEvent isButtonPressEvent or:[anEvent isButtonReleaseEvent])ifTrue:[ |
474 |
lastClickPoint := nil. |
|
475 |
]. |
|
1671 | 476 |
evView == self ifFalse:[ |
1674 | 477 |
(evView isComponentOf:self) ifFalse:[ ^ false ]. |
1671 | 478 |
]. |
181 | 479 |
|
1674 | 480 |
anEvent isButtonEvent ifFalse:[ |
481 |
anEvent isInputEvent ifTrue:[^ true]. |
|
2201 | 482 |
|
1675 | 483 |
anEvent isDamage ifTrue:[ self redrawSelection ]. |
1671 | 484 |
^ false |
485 |
]. |
|
181 | 486 |
|
2201 | 487 |
anEvent isButtonReleaseEvent ifTrue:[ ^ true ]. |
181 | 488 |
|
1674 | 489 |
anEvent isButtonMotionEvent ifTrue:[ |
490 |
(lastClickPoint notNil and:[anEvent state ~~ 0]) ifTrue:[ |
|
491 |
p := Point x:(anEvent x) y:(anEvent y). |
|
2201 | 492 |
p := device translatePoint:p fromView:evView toView:self. |
1671 | 493 |
|
2201 | 494 |
(lastClickPoint dist:p) > 20.0 ifTrue:[ |
1675 | 495 |
self startDragFrom:evView. |
496 |
lastClickPoint := nil. |
|
1671 | 497 |
] |
498 |
]. |
|
499 |
^ true |
|
500 |
]. |
|
501 |
||
1674 | 502 |
anEvent isButtonPressEvent ifTrue:[ |button application| |
503 |
button := anEvent button. |
|
504 |
||
505 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
506 |
p := Point x:(anEvent x) y:(anEvent y). |
|
507 |
p := device translatePoint:p fromView:evView toView:self. |
|
508 |
||
509 |
self selection:(self findObjectAt:p). |
|
510 |
||
511 |
selection notNil ifTrue:[ |
|
2201 | 512 |
lastClickPoint := p. |
1674 | 513 |
] |
514 |
] ifFalse:[ |
|
515 |
(menuSelector notNil and:[(application := self application) notNil]) ifTrue:[ |
|
516 |
MessageNotUnderstood catch:[ |
|
517 |
application aspectFor:menuSelector |
|
518 |
] |
|
1671 | 519 |
] |
520 |
]. |
|
521 |
^ true |
|
522 |
]. |
|
523 |
||
524 |
^ true |
|
181 | 525 |
! ! |
526 |
||
2201 | 527 |
!UIGalleryView::Canvas methodsFor:'focus handling'! |
528 |
||
529 |
subviewsInFocusOrder |
|
530 |
"returns none views - focus not handled within buildin canvas" |
|
531 |
||
532 |
^ #() |
|
533 |
! ! |
|
534 |
||
181 | 535 |
!UIGalleryView::Canvas methodsFor:'initialization'! |
536 |
||
2200 | 537 |
destroy |
538 |
|winGrp| |
|
539 |
||
540 |
winGrp := self windowGroup. |
|
541 |
winGrp notNil ifTrue:[ |
|
542 |
winGrp removePreEventHook:self. |
|
543 |
]. |
|
544 |
super destroy. |
|
545 |
! |
|
546 |
||
181 | 547 |
initialize |
548 |
super initialize. |
|
1674 | 549 |
clientSpecHolder := nil asValue. |
1675 | 550 |
hiddenCounter := 0. |
2200 | 551 |
showBorders := true. |
1128 | 552 |
! |
553 |
||
1671 | 554 |
realize |
2200 | 555 |
|winGrp| |
556 |
||
1671 | 557 |
super realize. |
2200 | 558 |
winGrp := self windowGroup. |
559 |
winGrp notNil ifTrue:[ |
|
560 |
winGrp addPreEventHook:self. |
|
561 |
]. |
|
1671 | 562 |
! ! |
563 |
||
181 | 564 |
!UIGalleryView::Canvas methodsFor:'searching'! |
565 |
||
1674 | 566 |
findObjectAt:aPoint |
181 | 567 |
"find the origin/corner of the currentWidget |
568 |
" |
|
1674 | 569 |
|p x y| |
181 | 570 |
|
1673 | 571 |
subViews size == 0 ifTrue:[^ nil]. |
181 | 572 |
|
573 |
subViews do:[:v| |
|
1674 | 574 |
p := device translatePoint:aPoint fromView:self toView:v. |
575 |
x := p x. |
|
576 |
y := p y. |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
577 |
|
1674 | 578 |
( x >= 0 and:[x <= v width |
579 |
and:[y >= 0 and:[y <= v height |
|
1671 | 580 |
and:[(self findSpecFor:v) notNil]]]] |
581 |
) ifTrue:[ |
|
582 |
^ v |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
583 |
] |
181 | 584 |
]. |
1671 | 585 |
^ nil |
181 | 586 |
! |
587 |
||
1674 | 588 |
findSpecFor:aView |
181 | 589 |
"returns subspec assigned to instance or nil |
590 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
591 |
|name| |
181 | 592 |
|
1674 | 593 |
aView notNil ifTrue:[ |
594 |
name := aView name. |
|
181 | 595 |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
596 |
specification do:[:aSpec| |
1674 | 597 |
(aSpec notNil and:[aSpec name = name]) ifTrue:[ |
598 |
aSpec canUIDrag ifTrue:[^ aSpec ]. |
|
599 |
^ nil |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
600 |
] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
601 |
] |
181 | 602 |
]. |
603 |
^ nil |
|
604 |
||
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
605 |
"Modified: / 18.5.1999 / 14:47:25 / cg" |
181 | 606 |
! ! |
607 |
||
608 |
!UIGalleryView::Canvas methodsFor:'selection'! |
|
609 |
||
610 |
handlesOf:aComponent do:aOneArgBlock |
|
611 |
"evaluate the block on each handle; the argument to the block |
|
612 |
is a rectangle |
|
613 |
" |
|
614 |
aComponent notNil ifTrue:[ |
|
1120 | 615 |
aOneArgBlock value:(aComponent origin - (2@2) extent:6@6). |
616 |
aOneArgBlock value:(aComponent corner - (1@1) extent:6@6). |
|
617 |
aOneArgBlock value:(aComponent topRight - (1@2) extent:6@6). |
|
618 |
aOneArgBlock value:(aComponent bottomLeft - (2@1) extent:6@6). |
|
619 |
aOneArgBlock value:(aComponent leftCenter - (2@0) extent:6@6). |
|
620 |
aOneArgBlock value:(aComponent rightCenter - (1@0) extent:6@6). |
|
621 |
aOneArgBlock value:(aComponent topCenter - (0@2) extent:6@6). |
|
622 |
aOneArgBlock value:(aComponent bottomCenter - (0@1) extent:6@6). |
|
181 | 623 |
] |
624 |
||
625 |
||
626 |
! |
|
627 |
||
1675 | 628 |
redrawSelection |
629 |
"redraw all items selected |
|
181 | 630 |
" |
1675 | 631 |
(shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[ |
632 |
self clippedByChildren:false. |
|
181 | 633 |
|
1675 | 634 |
self handlesOf:selection do:[:aRectangle| |
635 |
self fillRectangle:aRectangle |
|
636 |
]. |
|
637 |
self clippedByChildren:true. |
|
1671 | 638 |
]. |
639 |
! |
|
640 |
||
1674 | 641 |
selection:aView |
1671 | 642 |
"selection changed |
643 |
" |
|
644 |
|spec| |
|
645 |
||
1674 | 646 |
selection == aView ifTrue:[^ self]. |
1671 | 647 |
|
1675 | 648 |
self selectionHiddenDo:[ |
649 |
spec := self findSpecFor:aView. |
|
650 |
||
651 |
spec notNil ifTrue:[ selection := aView ] |
|
652 |
ifFalse:[ selection := nil ]. |
|
653 |
||
654 |
clientSpecHolder value:spec. |
|
655 |
]. |
|
656 |
! |
|
657 |
||
658 |
selectionHiddenDo:aOneArgBlock |
|
659 |
|r| |
|
660 |
||
661 |
[ hiddenCounter := hiddenCounter + 1. |
|
662 |
||
663 |
hiddenCounter == 1 ifTrue:[ |
|
664 |
(shown and:[selection notNil]) ifTrue:[ |
|
665 |
self clippedByChildren:false. |
|
666 |
||
667 |
self handlesOf:selection do:[:aRectangle| |
|
668 |
self clearRectangle:aRectangle |
|
669 |
]. |
|
670 |
self clippedByChildren:true. |
|
1671 | 671 |
|
1675 | 672 |
r := selection bounds. |
673 |
||
674 |
subViews do:[:sv| |
|
675 |
|absOrg absFrame| |
|
676 |
||
677 |
(sv bounds intersects:r) ifTrue:[ |
|
678 |
sv borderColor:(Color white). "/ to force a redraw |
|
679 |
sv borderColor:(Color black). |
|
1671 | 680 |
|
1675 | 681 |
sv withAllSubViewsDo:[:v| |
682 |
v realized ifTrue:[ |
|
683 |
v fill:v viewBackground. |
|
684 |
v exposeX:0 y:0 width:v width height:v height. |
|
685 |
] |
|
686 |
] |
|
687 |
] |
|
688 |
] |
|
689 |
]. |
|
690 |
]. |
|
691 |
aOneArgBlock value. |
|
692 |
] ensure:[ |
|
693 |
hiddenCounter := hiddenCounter - 1. |
|
694 |
self redrawSelection. |
|
695 |
]. |
|
181 | 696 |
! ! |
697 |
||
698 |
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
|
699 |
||
700 |
for:aView specification:aSpec |
|
701 |
"create drop object for a view derived from a specification |
|
702 |
" |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
703 |
|point extent rootView device inst displayObject| |
181 | 704 |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
705 |
device := aView device. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
706 |
rootView := device rootView. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
707 |
extent := aView extent. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
708 |
point := device translatePoint:0@0 fromView:aView toView:rootView. |
181 | 709 |
|
710 |
(point x > 0 and:[point y > 0]) ifTrue:[ |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
711 |
point := point + extent. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
712 |
(point x < rootView width and:[point y < rootView height]) ifTrue:[ |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
713 |
aView topView raise. |
1568
a9d61da29e8b
no need for device sync - flush will do
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
714 |
device flush. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
715 |
aView invalidate. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
716 |
aView windowGroup processExposeEvents. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
717 |
displayObject := Image fromView:aView grab:false. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
718 |
] |
181 | 719 |
]. |
806 | 720 |
displayObject isNil ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
721 |
displayObject := Form extent:extent depth:1. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
722 |
displayObject colorMap:(Array with:Color white with:Color black). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
723 |
displayObject fill:(Color colorId:0). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
724 |
displayObject paint:(Color colorId:1). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
725 |
displayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y. |
181 | 726 |
]. |
727 |
aSpec class == UISubSpecification ifTrue:[ |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
728 |
aSpec layout:(LayoutOrigin fromPoint:0@0) |
181 | 729 |
]. |
240 | 730 |
|
806 | 731 |
inst := self new. |
732 |
inst displayObject:displayObject. |
|
733 |
inst theObject:aSpec. |
|
734 |
^ inst. |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
735 |
|
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
736 |
"Modified: / 10.10.2001 / 14:03:00 / cg" |
181 | 737 |
! ! |
738 |
||
739 |
!UIGalleryView class methodsFor:'documentation'! |
|
740 |
||
741 |
version |
|
742 |
^ '$Header$' |
|
743 |
! ! |