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