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