author | Claus Gittinger <cg@exept.de> |
Mon, 19 Nov 2007 19:30:36 +0100 | |
changeset 2199 | c542a84adeb6 |
parent 1895 | b7d6683ebaca |
child 2200 | f258c24270b5 |
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 |
23 |
menuSelector uiBuilder hiddenCounter' |
|
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. |
181 | 159 |
! ! |
160 |
||
1399 | 161 |
!UIGalleryView methodsFor:'accessing-holders'! |
181 | 162 |
|
163 |
clientSpecHolder |
|
164 |
"get the holder which keeps the current selection or in case of |
|
165 |
no selection the specification under the cursor |
|
166 |
" |
|
167 |
^ canvas clientSpecHolder |
|
168 |
! |
|
169 |
||
170 |
clientSpecHolder:aHolder |
|
171 |
"set the holder which keeps the current selection or in case of |
|
172 |
no selection the specification under the cursor |
|
173 |
" |
|
174 |
canvas clientSpecHolder:aHolder |
|
175 |
! |
|
176 |
||
177 |
menuSelector |
|
178 |
^ canvas menuSelector |
|
179 |
! |
|
180 |
||
181 |
menuSelector:aSelector |
|
182 |
^ canvas menuSelector:aSelector |
|
183 |
! |
|
184 |
||
185 |
minorKeysHolder |
|
186 |
"get the holder keeping the minor keys; the selectors to access |
|
187 |
specifications from a class associated with the majorKey. |
|
188 |
" |
|
189 |
^ minorKeysHolder |
|
190 |
! |
|
191 |
||
192 |
minorKeysHolder:aValueHolder |
|
193 |
"set the holder keeping the minor keys; the selectors to access |
|
194 |
specifications from a class associated with the majorKey. |
|
195 |
" |
|
196 |
minorKeysHolder notNil ifTrue:[ |
|
1120 | 197 |
minorKeysHolder removeDependent:self. |
181 | 198 |
]. |
199 |
||
200 |
(minorKeysHolder := aValueHolder) notNil ifTrue:[ |
|
1120 | 201 |
minorKeysHolder addDependent:self. |
181 | 202 |
]. |
203 |
self minorKeys:(minorKeysHolder value) |
|
204 |
! ! |
|
205 |
||
206 |
!UIGalleryView methodsFor:'change & update'! |
|
207 |
||
1142 | 208 |
selectionHasChanged |
181 | 209 |
"selection changed |
210 |
" |
|
211 |
|specification selector selection application| |
|
212 |
||
1140 | 213 |
selection := self listIndexOf:(self selection). |
181 | 214 |
|
683 | 215 |
minorKeysHolder notNil ifTrue:[ |
1128 | 216 |
minorKeys := minorKeysHolder value. |
683 | 217 |
]. |
181 | 218 |
(selection notNil and:[minorKeys size >= selection]) ifTrue:[ |
1128 | 219 |
selector := minorKeys at:selection. |
181 | 220 |
|
1128 | 221 |
(majorKey respondsTo:selector) ifTrue:[ |
222 |
specification := majorKey perform:selector |
|
223 |
] ifFalse:[ |
|
224 |
(application := self application) notNil ifTrue:[ |
|
1576
ac7705f0a48d
Object messageNotUnderstoodSignal -> MessageNotUnderstood
ca
parents:
1568
diff
changeset
|
225 |
MessageNotUnderstood handle:[:ex| |
1128 | 226 |
(application class respondsTo:selector) ifTrue:[ |
227 |
specification := application class perform:selector |
|
228 |
] |
|
229 |
] do:[ |
|
230 |
specification := application aspectFor:selector |
|
231 |
] |
|
232 |
] |
|
233 |
] |
|
181 | 234 |
]. |
2199 | 235 |
"/ self withWaitCursorDo:[ |
1337 | 236 |
canvas specification:specification. |
2199 | 237 |
"/ ] |
181 | 238 |
! |
239 |
||
240 |
update |
|
1142 | 241 |
self selectionHasChanged. |
181 | 242 |
! |
243 |
||
244 |
update:something with:aParameter from:changedObject |
|
245 |
"one of my models changed its value |
|
246 |
" |
|
247 |
changedObject == minorKeysHolder ifTrue:[ |
|
1128 | 248 |
^ self minorKeys:( minorKeysHolder value) |
181 | 249 |
]. |
250 |
super update:something with:aParameter from:changedObject. |
|
251 |
||
252 |
! ! |
|
253 |
||
1337 | 254 |
!UIGalleryView methodsFor:'initialization & release'! |
181 | 255 |
|
256 |
initialize |
|
257 |
"setup default attributes |
|
258 |
" |
|
1729
cf1c2f488ba8
oops - do not mix class & instance in canvas-slot
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
259 |
canvas := Canvas in:self. |
181 | 260 |
|
261 |
super initialize. |
|
683 | 262 |
|
1142 | 263 |
self action:[:something| self selectionHasChanged ]. |
1582 | 264 |
! |
265 |
||
266 |
release |
|
267 |
minorKeysHolder notNil ifTrue:[ |
|
268 |
minorKeysHolder removeDependent:self. |
|
269 |
minorKeysHolder := nil. |
|
270 |
]. |
|
271 |
super release. |
|
181 | 272 |
! ! |
273 |
||
274 |
!UIGalleryView::Canvas methodsFor:'accessing'! |
|
275 |
||
276 |
builder |
|
277 |
"get the builder used to setup a window from a specification (or nil in case |
|
278 |
of using a new builder) |
|
279 |
" |
|
280 |
^ uiBuilder |
|
281 |
! |
|
282 |
||
283 |
builder:something |
|
284 |
"set the builder used to setup a window from a specification (or nil in case |
|
285 |
of using a new builder) |
|
286 |
" |
|
287 |
uiBuilder := something. |
|
288 |
! |
|
289 |
||
290 |
clientSpecHolder |
|
291 |
"get the holder which keeps the current selection or in case of |
|
292 |
no selection the specification under the cursor |
|
293 |
" |
|
294 |
^ clientSpecHolder |
|
295 |
! |
|
296 |
||
297 |
clientSpecHolder:aHolder |
|
298 |
"set the holder which keeps the current selection or in case of |
|
299 |
no selection the specification under the cursor |
|
300 |
" |
|
1674 | 301 |
|spec| |
302 |
||
303 |
spec := clientSpecHolder value. |
|
304 |
||
305 |
aHolder notNil ifTrue:[ clientSpecHolder := aHolder ] |
|
306 |
ifFalse:[ clientSpecHolder := nil asValue ]. |
|
307 |
||
308 |
clientSpecHolder value:spec. |
|
181 | 309 |
! |
310 |
||
311 |
menuSelector |
|
312 |
"return the value of the instance variable 'menuSelector' (automatically generated)" |
|
313 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
314 |
^ menuSelector |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
315 |
! |
181 | 316 |
|
317 |
menuSelector:something |
|
318 |
"set the value of the instance variable 'menuSelector' (automatically generated)" |
|
319 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
320 |
menuSelector := something. |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
321 |
! |
181 | 322 |
|
323 |
specification |
|
324 |
"get current specification |
|
325 |
" |
|
1674 | 326 |
^ specification |
181 | 327 |
! |
328 |
||
329 |
specification:aSpecOrSpecArray |
|
330 |
"set a new specification |
|
331 |
" |
|
332 |
|builder| |
|
333 |
||
334 |
self selection:nil. |
|
1674 | 335 |
self destroySubViews. |
181 | 336 |
|
1674 | 337 |
( aSpecOrSpecArray notNil |
338 |
and:[(specification := UISpecification from:aSpecOrSpecArray) notNil |
|
339 |
and:[specification respondsTo:#'buildViewFor:in:']] |
|
340 |
) ifFalse:[ |
|
341 |
specification := nil. |
|
342 |
^ self |
|
181 | 343 |
]. |
344 |
||
1674 | 345 |
(builder := uiBuilder) isNil ifTrue:[ |
346 |
builder := UIBuilder new isEditing:true. |
|
347 |
builder showDefaults:true. |
|
348 |
]. |
|
205 | 349 |
|
1674 | 350 |
specification buildViewFor:builder in:self. |
396 | 351 |
|
1674 | 352 |
subViews size ~~ 0 ifTrue:[ |
1561 | 353 |
subViews do:[:v| |
1671 | 354 |
(self findSpecFor:v) notNil ifTrue:[ |
1674 | 355 |
v borderWidth:1 |
1561 | 356 |
] |
357 |
]. |
|
1674 | 358 |
realized ifTrue:[ self realizeAllSubViews ]. |
359 |
]. |
|
181 | 360 |
! ! |
361 |
||
362 |
!UIGalleryView::Canvas methodsFor:'building'! |
|
363 |
||
364 |
buildSpecFrom:aSpec |
|
365 |
"build spec out of spec |
|
366 |
" |
|
367 |
|spec comp coll| |
|
368 |
||
369 |
(aSpec notNil and:[aSpec canUIDrag]) ifFalse:[ |
|
1120 | 370 |
^ nil |
181 | 371 |
]. |
372 |
||
373 |
spec := aSpec copy. |
|
374 |
||
375 |
(aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[ |
|
1120 | 376 |
^ spec |
181 | 377 |
]. |
378 |
comp := aSpec component. |
|
379 |
spec component:nil. |
|
380 |
||
381 |
comp canUIDrag ifFalse:[ |
|
382 |
^ spec |
|
383 |
]. |
|
384 |
coll := OrderedCollection new. |
|
385 |
||
386 |
comp do:[:anEntry||spc| |
|
1120 | 387 |
(spc := self buildSpecFrom:anEntry) notNil ifTrue:[ |
388 |
coll add:spc |
|
389 |
] |
|
181 | 390 |
]. |
391 |
coll isEmpty ifTrue:[ |
|
392 |
^ spec |
|
393 |
]. |
|
394 |
comp := comp copy. |
|
395 |
comp collection:coll. |
|
396 |
spec component:comp. |
|
397 |
^ spec |
|
398 |
||
399 |
||
400 |
||
401 |
||
402 |
! ! |
|
403 |
||
404 |
!UIGalleryView::Canvas methodsFor:'drag & drop'! |
|
405 |
||
1675 | 406 |
startDragFrom:evView |
1671 | 407 |
"start drag at a point |
181 | 408 |
" |
1674 | 409 |
|spec dragObj offset clickPos| |
1671 | 410 |
|
411 |
clickPos := lastClickPoint. |
|
412 |
clickPos isNil ifTrue:[^ self]. |
|
413 |
lastClickPoint := nil. |
|
414 |
||
1674 | 415 |
spec := clientSpecHolder value. |
1671 | 416 |
spec isNil ifTrue:[^ self]. |
181 | 417 |
|
1675 | 418 |
self selectionHiddenDo:[ |
419 |
spec := self buildSpecFrom:spec. |
|
420 |
spec name:nil. |
|
1674 | 421 |
|
1675 | 422 |
dragObj := DropSpec for:selection specification:spec. |
423 |
offset := clickPos - selection origin. |
|
424 |
]. |
|
278 | 425 |
|
1675 | 426 |
DragAndDropManager startDrag:dragObj from:evView offset:offset. |
181 | 427 |
! ! |
428 |
||
429 |
!UIGalleryView::Canvas methodsFor:'event handling'! |
|
430 |
||
1671 | 431 |
processEvent:anEvent |
1895 | 432 |
"filter keyboard events. |
433 |
Return true, if I have eaten the event" |
|
434 |
||
1674 | 435 |
|evView p| |
181 | 436 |
|
1671 | 437 |
evView := anEvent view. |
438 |
evView isNil ifTrue:[ ^ false ]. |
|
181 | 439 |
|
1671 | 440 |
evView == self ifFalse:[ |
1674 | 441 |
(evView isComponentOf:self) ifFalse:[ ^ false ]. |
1671 | 442 |
]. |
181 | 443 |
|
1674 | 444 |
anEvent isButtonEvent ifFalse:[ |
445 |
anEvent isInputEvent ifTrue:[^ true]. |
|
1675 | 446 |
anEvent isDamage ifTrue:[ self redrawSelection ]. |
1671 | 447 |
^ false |
448 |
]. |
|
181 | 449 |
|
1671 | 450 |
anEvent isButtonReleaseEvent ifTrue:[ |
1674 | 451 |
lastClickPoint := nil. |
1671 | 452 |
^ true |
181 | 453 |
]. |
454 |
||
1674 | 455 |
anEvent isButtonMotionEvent ifTrue:[ |
456 |
(lastClickPoint notNil and:[anEvent state ~~ 0]) ifTrue:[ |
|
457 |
p := Point x:(anEvent x) y:(anEvent y). |
|
1671 | 458 |
|
1674 | 459 |
(lastClickPoint dist:p) > 10.0 ifTrue:[ |
1675 | 460 |
self startDragFrom:evView. |
461 |
lastClickPoint := nil. |
|
1671 | 462 |
] |
463 |
]. |
|
464 |
^ true |
|
465 |
]. |
|
466 |
||
1674 | 467 |
anEvent isButtonPressEvent ifTrue:[ |button application| |
468 |
button := anEvent button. |
|
469 |
lastClickPoint := nil. |
|
470 |
||
471 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
472 |
p := Point x:(anEvent x) y:(anEvent y). |
|
473 |
p := device translatePoint:p fromView:evView toView:self. |
|
474 |
||
475 |
self selection:(self findObjectAt:p). |
|
476 |
||
477 |
selection notNil ifTrue:[ |
|
478 |
lastClickPoint := p |
|
479 |
] |
|
480 |
] ifFalse:[ |
|
481 |
(menuSelector notNil and:[(application := self application) notNil]) ifTrue:[ |
|
482 |
MessageNotUnderstood catch:[ |
|
483 |
application aspectFor:menuSelector |
|
484 |
] |
|
1671 | 485 |
] |
486 |
]. |
|
487 |
^ true |
|
488 |
]. |
|
489 |
||
490 |
^ true |
|
181 | 491 |
! ! |
492 |
||
493 |
!UIGalleryView::Canvas methodsFor:'initialization'! |
|
494 |
||
495 |
initialize |
|
496 |
super initialize. |
|
1674 | 497 |
clientSpecHolder := nil asValue. |
1675 | 498 |
hiddenCounter := 0. |
1128 | 499 |
! |
500 |
||
1671 | 501 |
realize |
502 |
super realize. |
|
503 |
self windowGroup addPreEventHook:self. |
|
504 |
! ! |
|
505 |
||
181 | 506 |
!UIGalleryView::Canvas methodsFor:'searching'! |
507 |
||
1674 | 508 |
findObjectAt:aPoint |
181 | 509 |
"find the origin/corner of the currentWidget |
510 |
" |
|
1674 | 511 |
|p x y| |
181 | 512 |
|
1673 | 513 |
subViews size == 0 ifTrue:[^ nil]. |
181 | 514 |
|
515 |
subViews do:[:v| |
|
1674 | 516 |
p := device translatePoint:aPoint fromView:self toView:v. |
517 |
x := p x. |
|
518 |
y := p y. |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
519 |
|
1674 | 520 |
( x >= 0 and:[x <= v width |
521 |
and:[y >= 0 and:[y <= v height |
|
1671 | 522 |
and:[(self findSpecFor:v) notNil]]]] |
523 |
) ifTrue:[ |
|
524 |
^ v |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
525 |
] |
181 | 526 |
]. |
1671 | 527 |
^ nil |
181 | 528 |
! |
529 |
||
1674 | 530 |
findSpecFor:aView |
181 | 531 |
"returns subspec assigned to instance or nil |
532 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
533 |
|name| |
181 | 534 |
|
1674 | 535 |
aView notNil ifTrue:[ |
536 |
name := aView name. |
|
181 | 537 |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
538 |
specification do:[:aSpec| |
1674 | 539 |
(aSpec notNil and:[aSpec name = name]) ifTrue:[ |
540 |
aSpec canUIDrag ifTrue:[^ aSpec ]. |
|
541 |
^ nil |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
542 |
] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
543 |
] |
181 | 544 |
]. |
545 |
^ nil |
|
546 |
||
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
547 |
"Modified: / 18.5.1999 / 14:47:25 / cg" |
181 | 548 |
! ! |
549 |
||
550 |
!UIGalleryView::Canvas methodsFor:'selection'! |
|
551 |
||
552 |
handlesOf:aComponent do:aOneArgBlock |
|
553 |
"evaluate the block on each handle; the argument to the block |
|
554 |
is a rectangle |
|
555 |
" |
|
556 |
aComponent notNil ifTrue:[ |
|
1120 | 557 |
aOneArgBlock value:(aComponent origin - (2@2) extent:6@6). |
558 |
aOneArgBlock value:(aComponent corner - (1@1) extent:6@6). |
|
559 |
aOneArgBlock value:(aComponent topRight - (1@2) extent:6@6). |
|
560 |
aOneArgBlock value:(aComponent bottomLeft - (2@1) extent:6@6). |
|
561 |
aOneArgBlock value:(aComponent leftCenter - (2@0) extent:6@6). |
|
562 |
aOneArgBlock value:(aComponent rightCenter - (1@0) extent:6@6). |
|
563 |
aOneArgBlock value:(aComponent topCenter - (0@2) extent:6@6). |
|
564 |
aOneArgBlock value:(aComponent bottomCenter - (0@1) extent:6@6). |
|
181 | 565 |
] |
566 |
||
567 |
||
568 |
! |
|
569 |
||
1675 | 570 |
redrawSelection |
571 |
"redraw all items selected |
|
181 | 572 |
" |
1675 | 573 |
(shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[ |
574 |
self clippedByChildren:false. |
|
181 | 575 |
|
1675 | 576 |
self handlesOf:selection do:[:aRectangle| |
577 |
self fillRectangle:aRectangle |
|
578 |
]. |
|
579 |
self clippedByChildren:true. |
|
1671 | 580 |
]. |
581 |
! |
|
582 |
||
1674 | 583 |
selection:aView |
1671 | 584 |
"selection changed |
585 |
" |
|
586 |
|spec| |
|
587 |
||
1674 | 588 |
selection == aView ifTrue:[^ self]. |
1671 | 589 |
|
1675 | 590 |
self selectionHiddenDo:[ |
591 |
spec := self findSpecFor:aView. |
|
592 |
||
593 |
spec notNil ifTrue:[ selection := aView ] |
|
594 |
ifFalse:[ selection := nil ]. |
|
595 |
||
596 |
clientSpecHolder value:spec. |
|
597 |
]. |
|
598 |
! |
|
599 |
||
600 |
selectionHiddenDo:aOneArgBlock |
|
601 |
|r| |
|
602 |
||
603 |
[ hiddenCounter := hiddenCounter + 1. |
|
604 |
||
605 |
hiddenCounter == 1 ifTrue:[ |
|
606 |
(shown and:[selection notNil]) ifTrue:[ |
|
607 |
self clippedByChildren:false. |
|
608 |
||
609 |
self handlesOf:selection do:[:aRectangle| |
|
610 |
self clearRectangle:aRectangle |
|
611 |
]. |
|
612 |
self clippedByChildren:true. |
|
1671 | 613 |
|
1675 | 614 |
r := selection bounds. |
615 |
||
616 |
subViews do:[:sv| |
|
617 |
|absOrg absFrame| |
|
618 |
||
619 |
(sv bounds intersects:r) ifTrue:[ |
|
620 |
sv borderColor:(Color white). "/ to force a redraw |
|
621 |
sv borderColor:(Color black). |
|
1671 | 622 |
|
1675 | 623 |
sv withAllSubViewsDo:[:v| |
624 |
v realized ifTrue:[ |
|
625 |
v fill:v viewBackground. |
|
626 |
v exposeX:0 y:0 width:v width height:v height. |
|
627 |
] |
|
628 |
] |
|
629 |
] |
|
630 |
] |
|
631 |
]. |
|
632 |
]. |
|
633 |
aOneArgBlock value. |
|
634 |
] ensure:[ |
|
635 |
hiddenCounter := hiddenCounter - 1. |
|
636 |
self redrawSelection. |
|
637 |
]. |
|
181 | 638 |
! ! |
639 |
||
640 |
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
|
641 |
||
642 |
for:aView specification:aSpec |
|
643 |
"create drop object for a view derived from a specification |
|
644 |
" |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
645 |
|point extent rootView device inst displayObject| |
181 | 646 |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
647 |
device := aView device. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
648 |
rootView := device rootView. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
649 |
extent := aView extent. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
650 |
point := device translatePoint:0@0 fromView:aView toView:rootView. |
181 | 651 |
|
652 |
(point x > 0 and:[point y > 0]) ifTrue:[ |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
653 |
point := point + extent. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
654 |
(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
|
655 |
aView topView raise. |
1568
a9d61da29e8b
no need for device sync - flush will do
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
656 |
device flush. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
657 |
aView invalidate. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
658 |
aView windowGroup processExposeEvents. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
659 |
displayObject := Image fromView:aView grab:false. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
660 |
] |
181 | 661 |
]. |
806 | 662 |
displayObject isNil ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
663 |
displayObject := Form extent:extent depth:1. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
664 |
displayObject colorMap:(Array with:Color white with:Color black). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
665 |
displayObject fill:(Color colorId:0). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
666 |
displayObject paint:(Color colorId:1). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
667 |
displayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y. |
181 | 668 |
]. |
669 |
aSpec class == UISubSpecification ifTrue:[ |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
670 |
aSpec layout:(LayoutOrigin fromPoint:0@0) |
181 | 671 |
]. |
240 | 672 |
|
806 | 673 |
inst := self new. |
674 |
inst displayObject:displayObject. |
|
675 |
inst theObject:aSpec. |
|
676 |
^ inst. |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
677 |
|
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
678 |
"Modified: / 10.10.2001 / 14:03:00 / cg" |
181 | 679 |
! ! |
680 |
||
681 |
!UIGalleryView class methodsFor:'documentation'! |
|
682 |
||
683 |
version |
|
684 |
^ '$Header$' |
|
685 |
! ! |