author | ca |
Thu, 07 May 1998 14:42:54 +0200 | |
changeset 817 | d350f49ae748 |
parent 806 | 4faf081e981d |
child 897 | 43f9bdc12ae4 |
permissions | -rw-r--r-- |
181 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
14 |
||
15 |
NoteBookView subclass:#UIGalleryView |
|
16 |
instanceVariableNames:'majorKey minorKeys minorKeysHolder' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-UIPainter' |
|
20 |
! |
|
21 |
||
22 |
View subclass:#Canvas |
|
23 |
instanceVariableNames:'dragMode clientSpecHolder inputView selection specification |
|
24 |
lastClickPoint menuSelector raiseMenuSelector uiBuilder' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:UIGalleryView |
|
28 |
! |
|
29 |
||
30 |
DropObject subclass:#DropSpec |
|
31 |
instanceVariableNames:'' |
|
247 | 32 |
classVariableNames:'' |
181 | 33 |
poolDictionaries:'' |
34 |
privateIn:UIGalleryView::Canvas |
|
35 |
! |
|
36 |
||
37 |
!UIGalleryView class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
41 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
42 |
All Rights Reserved |
|
43 |
||
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
" |
|
51 |
||
52 |
||
53 |
! |
|
54 |
||
55 |
documentation |
|
56 |
" |
|
57 |
implements a selection panel, keeping widgets which could be placed |
|
58 |
into other components by drag & drop or copy @ paste. The objects |
|
59 |
which are draged/droped must be kind of UISpecification's. |
|
60 |
The UISelectionPanel used by the UIPainter is implemented in this way. |
|
61 |
||
62 |
[author:] |
|
63 |
Claus Gittinger |
|
64 |
Claus Atzkern |
|
65 |
||
66 |
[see also:] |
|
67 |
UIPainter |
|
68 |
UISelectionPanel |
|
69 |
" |
|
70 |
||
71 |
! |
|
72 |
||
73 |
examples |
|
74 |
" |
|
75 |
opens a gallery |
|
76 |
||
77 |
[exBegin] |
|
78 |
|top sel| |
|
79 |
||
80 |
top := StandardSystemView new label:'gallery'; extent:500@300. |
|
81 |
sel := UIGalleryView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
|
82 |
||
83 |
sel labels:#( 'Buttons' |
|
84 |
'Panels' |
|
85 |
'Text' |
|
86 |
). |
|
87 |
||
191 | 88 |
sel minorKeys:#( #standardButtonToggle |
89 |
#standardPanels |
|
90 |
#standardText |
|
181 | 91 |
). |
92 |
||
93 |
sel majorKey:UISelectionPanel. |
|
94 |
top open. |
|
95 |
[exEnd] |
|
96 |
" |
|
97 |
! ! |
|
98 |
||
99 |
!UIGalleryView methodsFor:'accessing'! |
|
100 |
||
101 |
builder |
|
102 |
"get the builder used to setup a window from a specification (or nil in case |
|
103 |
of using a new builder) |
|
104 |
" |
|
105 |
^ canvas builder |
|
106 |
! |
|
107 |
||
108 |
builder:aBuilderOrNil |
|
109 |
"set the builder used to setup a window from a specification (or nil in case |
|
110 |
of using a new builder) |
|
111 |
" |
|
112 |
canvas builder:aBuilderOrNil |
|
113 |
! |
|
114 |
||
115 |
canvas:aCanvas |
|
116 |
^ self |
|
117 |
||
118 |
! |
|
119 |
||
120 |
labels:listOfLabels minorKeys:listOfMinorKeys majorKey:aMajorKey |
|
121 |
"setup for labels, selectors and class provider |
|
122 |
" |
|
123 |
self labels:listOfLabels. |
|
124 |
minorKeys := listOfMinorKeys. |
|
125 |
majorKey := aMajorKey. |
|
126 |
! |
|
127 |
||
128 |
majorKey |
|
129 |
"get the class providing the window specifications |
|
130 |
" |
|
131 |
^ majorKey |
|
132 |
! |
|
133 |
||
134 |
majorKey:aKey |
|
135 |
"get the class providing the window specifications |
|
136 |
" |
|
335 | 137 |
|appl| |
138 |
||
139 |
appl := self application. |
|
140 |
||
141 |
appl notNil ifTrue:[ |
|
142 |
majorKey := appl resolveName:aKey |
|
143 |
] ifFalse:[ |
|
144 |
majorKey := Smalltalk resolveName:aKey inClass:self class |
|
145 |
]. |
|
181 | 146 |
self selection:nil |
147 |
! |
|
148 |
||
149 |
minorKeys |
|
150 |
"get the list of selector keys |
|
151 |
" |
|
152 |
^ minorKeys |
|
153 |
! |
|
154 |
||
155 |
minorKeys:aListOfSelectors |
|
156 |
"set the list of selectors |
|
157 |
" |
|
158 |
minorKeys := aListOfSelectors. |
|
159 |
tabRaw selection:nil. |
|
160 |
! ! |
|
161 |
||
162 |
!UIGalleryView methodsFor:'accessing holders'! |
|
163 |
||
164 |
clientSpecHolder |
|
165 |
"get the holder which keeps the current selection or in case of |
|
166 |
no selection the specification under the cursor |
|
167 |
" |
|
168 |
^ canvas clientSpecHolder |
|
169 |
! |
|
170 |
||
171 |
clientSpecHolder:aHolder |
|
172 |
"set the holder which keeps the current selection or in case of |
|
173 |
no selection the specification under the cursor |
|
174 |
" |
|
175 |
canvas clientSpecHolder:aHolder |
|
176 |
! |
|
177 |
||
178 |
menuSelector |
|
179 |
^ canvas menuSelector |
|
180 |
! |
|
181 |
||
182 |
menuSelector:aSelector |
|
183 |
^ canvas menuSelector:aSelector |
|
184 |
! |
|
185 |
||
186 |
minorKeysHolder |
|
187 |
"get the holder keeping the minor keys; the selectors to access |
|
188 |
specifications from a class associated with the majorKey. |
|
189 |
" |
|
190 |
^ minorKeysHolder |
|
191 |
! |
|
192 |
||
193 |
minorKeysHolder:aValueHolder |
|
194 |
"set the holder keeping the minor keys; the selectors to access |
|
195 |
specifications from a class associated with the majorKey. |
|
196 |
" |
|
197 |
minorKeysHolder notNil ifTrue:[ |
|
198 |
minorKeysHolder removeDependent:self. |
|
199 |
]. |
|
200 |
||
201 |
(minorKeysHolder := aValueHolder) notNil ifTrue:[ |
|
202 |
minorKeysHolder addDependent:self. |
|
203 |
]. |
|
204 |
self minorKeys:(minorKeysHolder value) |
|
205 |
! ! |
|
206 |
||
207 |
!UIGalleryView methodsFor:'change & update'! |
|
208 |
||
209 |
selectionChangedTo:something |
|
210 |
"selection changed |
|
211 |
" |
|
212 |
|specification selector selection application| |
|
213 |
||
214 |
selection := tabRaw listIndexOf:something. |
|
215 |
||
683 | 216 |
minorKeysHolder notNil ifTrue:[ |
217 |
minorKeys := minorKeysHolder value. |
|
218 |
]. |
|
181 | 219 |
(selection notNil and:[minorKeys size >= selection]) ifTrue:[ |
220 |
selector := minorKeys at:selection. |
|
221 |
||
222 |
(majorKey respondsTo:selector) ifTrue:[ |
|
223 |
specification := majorKey perform:selector |
|
224 |
] ifFalse:[ |
|
225 |
(application := self application) notNil ifTrue:[ |
|
226 |
Object messageNotUnderstoodSignal handle:[:ex| |
|
227 |
(application class respondsTo:selector) ifTrue:[ |
|
228 |
specification := application class perform:selector |
|
229 |
] |
|
230 |
] do:[ |
|
231 |
specification := application aspectFor:selector |
|
232 |
] |
|
233 |
] |
|
234 |
] |
|
235 |
]. |
|
236 |
canvas specification:specification. |
|
237 |
||
238 |
! |
|
239 |
||
240 |
update |
|
241 |
self selectionChangedTo:(tabRaw selection). |
|
242 |
! |
|
243 |
||
244 |
update:something with:aParameter from:changedObject |
|
245 |
"one of my models changed its value |
|
246 |
" |
|
247 |
changedObject == minorKeysHolder ifTrue:[ |
|
248 |
^ self minorKeys:( minorKeysHolder value) |
|
249 |
]. |
|
250 |
super update:something with:aParameter from:changedObject. |
|
251 |
||
252 |
! ! |
|
253 |
||
254 |
!UIGalleryView methodsFor:'initialization'! |
|
255 |
||
256 |
destroy |
|
257 |
minorKeysHolder notNil ifTrue:[ |
|
258 |
minorKeysHolder removeDependent:self. |
|
259 |
minorKeysHolder := nil. |
|
260 |
]. |
|
261 |
super destroy. |
|
262 |
! |
|
263 |
||
264 |
initialize |
|
265 |
"setup default attributes |
|
266 |
" |
|
267 |
canvas := Canvas. |
|
268 |
||
269 |
super initialize. |
|
683 | 270 |
|
181 | 271 |
tabRaw action:[:something| self selectionChangedTo:something ]. |
272 |
||
273 |
! ! |
|
274 |
||
275 |
!UIGalleryView::Canvas methodsFor:'accessing'! |
|
276 |
||
277 |
builder |
|
278 |
"get the builder used to setup a window from a specification (or nil in case |
|
279 |
of using a new builder) |
|
280 |
" |
|
281 |
^ uiBuilder |
|
282 |
! |
|
283 |
||
284 |
builder:something |
|
285 |
"set the builder used to setup a window from a specification (or nil in case |
|
286 |
of using a new builder) |
|
287 |
" |
|
288 |
uiBuilder := something. |
|
289 |
! |
|
290 |
||
291 |
clientSpecHolder |
|
292 |
"get the holder which keeps the current selection or in case of |
|
293 |
no selection the specification under the cursor |
|
294 |
" |
|
295 |
^ clientSpecHolder |
|
296 |
! |
|
297 |
||
298 |
clientSpecHolder:aHolder |
|
299 |
"set the holder which keeps the current selection or in case of |
|
300 |
no selection the specification under the cursor |
|
301 |
" |
|
302 |
(clientSpecHolder := aHolder) notNil ifTrue:[ |
|
303 |
clientSpecHolder value:selection |
|
304 |
]. |
|
305 |
! |
|
306 |
||
307 |
menuSelector |
|
308 |
"return the value of the instance variable 'menuSelector' (automatically generated)" |
|
309 |
||
310 |
^ menuSelector! |
|
311 |
||
312 |
menuSelector:something |
|
313 |
"set the value of the instance variable 'menuSelector' (automatically generated)" |
|
314 |
||
315 |
menuSelector := something.! |
|
316 |
||
317 |
specification |
|
318 |
"get current specification |
|
319 |
" |
|
320 |
^ specification |
|
321 |
||
322 |
||
323 |
! |
|
324 |
||
325 |
specification:aSpecOrSpecArray |
|
326 |
"set a new specification |
|
327 |
" |
|
328 |
|builder| |
|
329 |
||
330 |
self selection:nil. |
|
331 |
||
332 |
self subViews copy do:[:aSubView| |
|
333 |
aSubView ~~ inputView ifTrue:[ |
|
334 |
aSubView destroy |
|
335 |
] |
|
336 |
]. |
|
337 |
||
338 |
aSpecOrSpecArray notNil ifTrue:[ |
|
339 |
specification := UISpecification from:aSpecOrSpecArray. |
|
205 | 340 |
|
341 |
(specification respondsTo:#buildViewFor:in:) ifFalse:[ |
|
342 |
specification := nil. |
|
343 |
^ self |
|
344 |
]. |
|
396 | 345 |
(builder := uiBuilder) isNil ifTrue:[ |
720 | 346 |
builder := UIBuilder new isEditing:true. |
347 |
builder showDefaults:true. |
|
396 | 348 |
]. |
349 |
||
181 | 350 |
specification buildViewFor:builder in:self. |
351 |
||
352 |
subViews do:[:v| |
|
353 |
(v ~~ inputView and:[(self findSpecFor:v) notNil]) ifTrue:[ |
|
354 |
v borderWidth:1. |
|
355 |
] |
|
356 |
]. |
|
357 |
self shown ifTrue:[ |
|
358 |
self realizeAllSubViews. |
|
359 |
inputView raise |
|
360 |
] |
|
361 |
] ifFalse:[ |
|
362 |
specification := nil |
|
363 |
] |
|
364 |
||
365 |
||
366 |
||
367 |
! ! |
|
368 |
||
369 |
!UIGalleryView::Canvas methodsFor:'building'! |
|
370 |
||
371 |
buildSpecFrom:aSpec |
|
372 |
"build spec out of spec |
|
373 |
" |
|
374 |
|spec comp coll| |
|
375 |
||
376 |
(aSpec notNil and:[aSpec canUIDrag]) ifFalse:[ |
|
377 |
^ nil |
|
378 |
]. |
|
379 |
||
380 |
spec := aSpec copy. |
|
381 |
||
382 |
(aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[ |
|
383 |
^ spec |
|
384 |
]. |
|
385 |
comp := aSpec component. |
|
386 |
spec component:nil. |
|
387 |
||
388 |
comp canUIDrag ifFalse:[ |
|
389 |
^ spec |
|
390 |
]. |
|
391 |
coll := OrderedCollection new. |
|
392 |
||
393 |
comp do:[:anEntry||spc| |
|
394 |
(spc := self buildSpecFrom:anEntry) notNil ifTrue:[ |
|
395 |
coll add:spc |
|
396 |
] |
|
397 |
]. |
|
398 |
coll isEmpty ifTrue:[ |
|
399 |
^ spec |
|
400 |
]. |
|
401 |
comp := comp copy. |
|
402 |
comp collection:coll. |
|
403 |
spec component:comp. |
|
404 |
^ spec |
|
405 |
||
406 |
||
407 |
||
408 |
||
409 |
! ! |
|
410 |
||
411 |
!UIGalleryView::Canvas methodsFor:'drag & drop'! |
|
412 |
||
413 |
startDrag |
|
414 |
"start drag of selection |
|
415 |
" |
|
416 |
|dragObj spec name| |
|
417 |
||
418 |
spec := self findSpecFor:selection. |
|
419 |
||
420 |
spec notNil ifTrue:[ |
|
421 |
spec := self buildSpecFrom:spec. |
|
422 |
name := spec className asString. |
|
423 |
name := name copyFrom:1 to:(name size - ('Spec' size) + 1). |
|
424 |
name at:1 put:(name at:1) asLowercase. |
|
425 |
name at:(name size) put:$1. |
|
426 |
spec name:name. |
|
427 |
||
428 |
self showUnselected. |
|
429 |
dragObj := DropSpec for:selection specification:spec. |
|
430 |
self showSelected. |
|
431 |
DragAndDropManager startDrag:dragObj from:inputView. |
|
432 |
] |
|
433 |
||
278 | 434 |
! |
435 |
||
436 |
startDragWithOffset:offs |
|
437 |
"start drag of selection |
|
438 |
" |
|
720 | 439 |
|dragObj spec o| |
278 | 440 |
|
441 |
spec := self findSpecFor:selection. |
|
442 |
||
443 |
spec notNil ifTrue:[ |
|
444 |
spec := self buildSpecFrom:spec. |
|
720 | 445 |
spec name:(spec copy userFriendlyName, $1). |
278 | 446 |
|
447 |
self showUnselected. |
|
448 |
dragObj := DropSpec for:selection specification:spec. |
|
449 |
self showSelected. |
|
450 |
||
451 |
o := lastClickPoint - selection origin. |
|
452 |
||
453 |
DragAndDropManager |
|
454 |
startDrag:dragObj |
|
455 |
from:inputView |
|
456 |
offset:o. |
|
457 |
] |
|
458 |
||
459 |
"Created: 11.8.1997 / 00:44:17 / cg" |
|
460 |
"Modified: 11.8.1997 / 00:48:35 / cg" |
|
181 | 461 |
! ! |
462 |
||
463 |
!UIGalleryView::Canvas methodsFor:'event handling'! |
|
464 |
||
465 |
buttonMotion:state x:x y:y |
|
466 |
"start a drag on selection |
|
467 |
" |
|
468 |
|sensor| |
|
469 |
||
289 | 470 |
(state ~~ 0 and:[lastClickPoint notNil and:[selection notNil]]) ifTrue:[ |
181 | 471 |
sensor := self sensor. |
472 |
sensor anyButtonPressed ifTrue:[ |
|
473 |
(lastClickPoint dist:(x@y)) > 10.0 ifTrue:[ |
|
278 | 474 |
^ self startDragWithOffset:(x@y) - lastClickPoint |
181 | 475 |
] |
476 |
] |
|
477 |
] |
|
478 |
! |
|
479 |
||
480 |
buttonPress:button x:x y:y |
|
481 |
"change selection |
|
482 |
" |
|
483 |
|application| |
|
484 |
||
485 |
button == 1 ifTrue:[ |
|
486 |
lastClickPoint := Point x:x y:y. |
|
487 |
self selection:(self findObjectAtX:x y:y). |
|
488 |
] ifFalse:[ |
|
489 |
lastClickPoint := nil. |
|
490 |
||
491 |
(menuSelector notNil and:[(application := self application) notNil]) ifTrue:[ |
|
492 |
Object messageNotUnderstoodSignal handle:[:ex| |
|
493 |
] do:[ |
|
494 |
application aspectFor:menuSelector |
|
495 |
] |
|
496 |
] |
|
497 |
] |
|
498 |
||
499 |
! |
|
500 |
||
501 |
exposeX:x y:y width:w height:h |
|
502 |
"handle an expose event from device; redraw selection |
|
503 |
" |
|
504 |
super exposeX:x y:y width:w height:h. |
|
505 |
||
506 |
(selection notNil and:[self sensor hasExposeEventFor:selection]) ifFalse:[ |
|
507 |
self showSelected. |
|
508 |
]. |
|
509 |
||
510 |
||
511 |
! ! |
|
512 |
||
513 |
!UIGalleryView::Canvas methodsFor:'initialization'! |
|
514 |
||
515 |
initialize |
|
516 |
super initialize. |
|
517 |
||
518 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
|
519 |
inputView eventReceiver:self. |
|
520 |
inputView enableButtonEvents. |
|
521 |
inputView enableButtonMotionEvents. |
|
522 |
inputView enableMotionEvents. |
|
523 |
||
524 |
||
525 |
! ! |
|
526 |
||
527 |
!UIGalleryView::Canvas methodsFor:'searching'! |
|
528 |
||
529 |
findObjectAtX:x y:y |
|
530 |
"find the origin/corner of the currentWidget |
|
531 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
532 |
|point id p| |
181 | 533 |
|
534 |
point := Point x:x y:y. |
|
535 |
id := inputView id. |
|
536 |
||
537 |
subViews do:[:v| |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
538 |
|pX pY| |
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
539 |
|
181 | 540 |
v ~~ inputView ifTrue:[ |
541 |
p := device translatePoint:point from:id to:(v id). |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
542 |
pX := p x. |
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
543 |
pY := p y. |
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
544 |
( pX >= 0 and:[pX <= v width |
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
545 |
and:[pY >= 0 and:[pY <= v height |
181 | 546 |
and:[(self findSpecFor:v) notNil]]]] |
547 |
) ifTrue:[ |
|
548 |
^ v |
|
549 |
] |
|
550 |
] |
|
551 |
]. |
|
552 |
^ nil |
|
553 |
||
554 |
||
555 |
! |
|
556 |
||
557 |
findSpecFor:anObject |
|
558 |
"returns subspec assigned to instance or nil |
|
559 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
560 |
|name| |
181 | 561 |
|
562 |
anObject notNil ifTrue:[ |
|
563 |
name := anObject name. |
|
564 |
||
565 |
specification do:[:aSpec| |
|
566 |
aSpec name = name ifTrue:[ |
|
567 |
aSpec canUIDrag ifTrue:[^ aSpec] |
|
568 |
ifFalse:[^ nil] |
|
569 |
] |
|
570 |
] |
|
571 |
]. |
|
572 |
^ nil |
|
573 |
||
574 |
||
575 |
! ! |
|
576 |
||
577 |
!UIGalleryView::Canvas methodsFor:'selection'! |
|
578 |
||
579 |
handlesOf:aComponent do:aOneArgBlock |
|
580 |
"evaluate the block on each handle; the argument to the block |
|
581 |
is a rectangle |
|
582 |
" |
|
583 |
aComponent notNil ifTrue:[ |
|
584 |
aOneArgBlock value:(aComponent origin - (2@2) extent:6@6). |
|
585 |
aOneArgBlock value:(aComponent corner - (1@1) extent:6@6). |
|
586 |
aOneArgBlock value:(aComponent topRight - (1@2) extent:6@6). |
|
587 |
aOneArgBlock value:(aComponent bottomLeft - (2@1) extent:6@6). |
|
588 |
aOneArgBlock value:(aComponent leftCenter - (2@0) extent:6@6). |
|
589 |
aOneArgBlock value:(aComponent rightCenter - (1@0) extent:6@6). |
|
590 |
aOneArgBlock value:(aComponent topCenter - (0@2) extent:6@6). |
|
591 |
aOneArgBlock value:(aComponent bottomCenter - (0@1) extent:6@6). |
|
592 |
] |
|
593 |
||
594 |
||
595 |
! |
|
596 |
||
597 |
selection:anObject |
|
598 |
"selection changed |
|
599 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
600 |
|spec| |
181 | 601 |
|
602 |
selection ~~ anObject ifTrue:[ |
|
603 |
self showUnselected. |
|
604 |
spec := self findSpecFor:anObject. |
|
605 |
||
606 |
spec notNil ifTrue:[ |
|
607 |
selection := anObject. |
|
608 |
self showSelected |
|
609 |
] ifFalse:[ |
|
610 |
selection := nil |
|
611 |
]. |
|
612 |
clientSpecHolder notNil ifTrue:[ |
|
613 |
clientSpecHolder value:spec |
|
614 |
] |
|
615 |
] |
|
616 |
||
617 |
||
618 |
! |
|
619 |
||
620 |
showSelected |
|
621 |
"show selected |
|
622 |
" |
|
623 |
self shown ifFalse:[^ self]. |
|
624 |
||
625 |
selection notNil ifTrue:[ |
|
626 |
self clippedByChildren:false. |
|
627 |
||
628 |
self handlesOf:selection do:[:aRectangle| |
|
629 |
self fillRectangle:aRectangle |
|
630 |
]. |
|
631 |
self clippedByChildren:true. |
|
632 |
]. |
|
633 |
||
634 |
||
635 |
! |
|
636 |
||
637 |
showUnselected |
|
638 |
"show unselected |
|
639 |
" |
|
640 |
|r currSel| |
|
641 |
||
642 |
(currSel := selection) isNil ifTrue:[ |
|
643 |
^ self |
|
644 |
]. |
|
645 |
selection := nil. |
|
646 |
self shown ifFalse:[^ self]. |
|
647 |
||
648 |
self clippedByChildren:false. |
|
649 |
||
650 |
self handlesOf:currSel do:[:aRectangle| |
|
651 |
self clearRectangle:aRectangle |
|
652 |
]. |
|
653 |
self clippedByChildren:true. |
|
654 |
r := currSel bounds. |
|
655 |
||
656 |
subViews do:[:sv| |
|
657 |
|absOrg absFrame| |
|
658 |
||
659 |
sv ~~ inputView ifTrue:[ |
|
660 |
(sv bounds intersects:r) ifTrue:[ |
|
661 |
sv borderColor:(Color gray:5). |
|
662 |
sv borderColor:(Color black). |
|
663 |
||
664 |
sv withAllSubViewsDo:[:v| |
|
665 |
v fill:v viewBackground. |
|
666 |
v exposeX:0 y:0 width:9999 height:9999. |
|
667 |
] |
|
668 |
] |
|
669 |
] |
|
670 |
]. |
|
671 |
selection := currSel. |
|
672 |
||
673 |
! ! |
|
674 |
||
675 |
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
|
676 |
||
677 |
for:aView specification:aSpec |
|
678 |
"create drop object for a view derived from a specification |
|
679 |
" |
|
806 | 680 |
|point extent root device inst displayObject| |
181 | 681 |
|
682 |
device := aView device. |
|
683 |
root := device rootView. |
|
684 |
extent := aView extent. |
|
685 |
point := device translatePoint:0@0 from:(aView id) to:(root id). |
|
686 |
||
687 |
(point x > 0 and:[point y > 0]) ifTrue:[ |
|
688 |
point := point + extent. |
|
689 |
(point x < root width and:[point y < root height]) ifTrue:[ |
|
690 |
aView topView raise. |
|
691 |
device sync. |
|
692 |
aView invalidate. |
|
693 |
aView windowGroup processExposeEvents. |
|
806 | 694 |
displayObject := Image fromView:aView grab:false. |
181 | 695 |
] |
696 |
]. |
|
806 | 697 |
displayObject isNil ifTrue:[ |
698 |
displayObject := Form extent:extent depth:1. |
|
699 |
displayObject colorMap:(Array with:Color white with:Color black). |
|
700 |
displayObject fill:(Color colorId:0). |
|
701 |
displayObject paint:(Color colorId:1). |
|
702 |
displayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y. |
|
181 | 703 |
]. |
704 |
aSpec class == UISubSpecification ifTrue:[ |
|
705 |
aSpec layout:(LayoutOrigin fromPoint:0@0) |
|
706 |
]. |
|
240 | 707 |
|
806 | 708 |
inst := self new. |
709 |
inst displayObject:displayObject. |
|
710 |
inst theObject:aSpec. |
|
711 |
^ inst. |
|
181 | 712 |
! ! |
713 |
||
714 |
!UIGalleryView class methodsFor:'documentation'! |
|
715 |
||
716 |
version |
|
717 |
^ '$Header$' |
|
718 |
! ! |