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