author | Claus Gittinger <cg@exept.de> |
Wed, 25 Oct 2000 12:31:46 +0200 | |
changeset 1420 | 9a649c1bb8cf |
parent 1399 | a0687f5e1f54 |
child 1455 | 5d4d3c5ca76c |
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 |
|
25 |
instanceVariableNames:'dragMode clientSpecHolder inputView selection specification |
|
26 |
lastClickPoint menuSelector raiseMenuSelector uiBuilder' |
|
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:[ |
|
228 |
Object messageNotUnderstoodSignal handle:[:ex| |
|
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 |
destroy |
|
260 |
minorKeysHolder notNil ifTrue:[ |
|
1120 | 261 |
minorKeysHolder removeDependent:self. |
262 |
minorKeysHolder := nil. |
|
181 | 263 |
]. |
264 |
super destroy. |
|
265 |
! |
|
266 |
||
267 |
initialize |
|
268 |
"setup default attributes |
|
269 |
" |
|
270 |
canvas := Canvas. |
|
271 |
||
272 |
super initialize. |
|
683 | 273 |
|
1142 | 274 |
self action:[:something| self selectionHasChanged ]. |
181 | 275 |
|
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 |
" |
|
305 |
(clientSpecHolder := aHolder) notNil ifTrue:[ |
|
1120 | 306 |
clientSpecHolder value:selection |
181 | 307 |
]. |
308 |
! |
|
309 |
||
310 |
menuSelector |
|
311 |
"return the value of the instance variable 'menuSelector' (automatically generated)" |
|
312 |
||
313 |
^ menuSelector! |
|
314 |
||
315 |
menuSelector:something |
|
316 |
"set the value of the instance variable 'menuSelector' (automatically generated)" |
|
317 |
||
318 |
menuSelector := something.! |
|
319 |
||
320 |
specification |
|
321 |
"get current specification |
|
322 |
" |
|
323 |
^ specification |
|
324 |
||
325 |
||
326 |
! |
|
327 |
||
328 |
specification:aSpecOrSpecArray |
|
329 |
"set a new specification |
|
330 |
" |
|
331 |
|builder| |
|
332 |
||
333 |
self selection:nil. |
|
334 |
||
335 |
self subViews copy do:[:aSubView| |
|
1120 | 336 |
aSubView ~~ inputView ifTrue:[ |
337 |
aSubView destroy |
|
338 |
] |
|
181 | 339 |
]. |
340 |
||
341 |
aSpecOrSpecArray notNil ifTrue:[ |
|
1120 | 342 |
specification := UISpecification from:aSpecOrSpecArray. |
205 | 343 |
|
1120 | 344 |
(specification respondsTo:#buildViewFor:in:) ifFalse:[ |
345 |
specification := nil. |
|
346 |
^ self |
|
347 |
]. |
|
348 |
(builder := uiBuilder) isNil ifTrue:[ |
|
349 |
builder := UIBuilder new isEditing:true. |
|
350 |
builder showDefaults:true. |
|
351 |
]. |
|
396 | 352 |
|
1120 | 353 |
specification buildViewFor:builder in:self. |
181 | 354 |
|
1120 | 355 |
subViews do:[:v| |
356 |
(v ~~ inputView and:[(self findSpecFor:v) notNil]) ifTrue:[ |
|
357 |
v borderWidth:1. |
|
358 |
] |
|
359 |
]. |
|
360 |
self shown ifTrue:[ |
|
361 |
self realizeAllSubViews. |
|
362 |
inputView raise |
|
363 |
] |
|
181 | 364 |
] ifFalse:[ |
1120 | 365 |
specification := nil |
181 | 366 |
] |
367 |
||
368 |
||
369 |
||
370 |
! ! |
|
371 |
||
372 |
!UIGalleryView::Canvas methodsFor:'building'! |
|
373 |
||
374 |
buildSpecFrom:aSpec |
|
375 |
"build spec out of spec |
|
376 |
" |
|
377 |
|spec comp coll| |
|
378 |
||
379 |
(aSpec notNil and:[aSpec canUIDrag]) ifFalse:[ |
|
1120 | 380 |
^ nil |
181 | 381 |
]. |
382 |
||
383 |
spec := aSpec copy. |
|
384 |
||
385 |
(aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[ |
|
1120 | 386 |
^ spec |
181 | 387 |
]. |
388 |
comp := aSpec component. |
|
389 |
spec component:nil. |
|
390 |
||
391 |
comp canUIDrag ifFalse:[ |
|
392 |
^ spec |
|
393 |
]. |
|
394 |
coll := OrderedCollection new. |
|
395 |
||
396 |
comp do:[:anEntry||spc| |
|
1120 | 397 |
(spc := self buildSpecFrom:anEntry) notNil ifTrue:[ |
398 |
coll add:spc |
|
399 |
] |
|
181 | 400 |
]. |
401 |
coll isEmpty ifTrue:[ |
|
402 |
^ spec |
|
403 |
]. |
|
404 |
comp := comp copy. |
|
405 |
comp collection:coll. |
|
406 |
spec component:comp. |
|
407 |
^ spec |
|
408 |
||
409 |
||
410 |
||
411 |
||
412 |
! ! |
|
413 |
||
414 |
!UIGalleryView::Canvas methodsFor:'drag & drop'! |
|
415 |
||
416 |
startDrag |
|
417 |
"start drag of selection |
|
418 |
" |
|
419 |
|dragObj spec name| |
|
420 |
||
421 |
spec := self findSpecFor:selection. |
|
422 |
||
423 |
spec notNil ifTrue:[ |
|
1120 | 424 |
spec := self buildSpecFrom:spec. |
425 |
name := spec className asString. |
|
426 |
name := name copyFrom:1 to:(name size - ('Spec' size) + 1). |
|
427 |
name at:1 put:(name at:1) asLowercase. |
|
428 |
name at:(name size) put:$1. |
|
429 |
spec name:name. |
|
181 | 430 |
|
1120 | 431 |
self showUnselected. |
432 |
dragObj := DropSpec for:selection specification:spec. |
|
433 |
"/ self showSelected. |
|
434 |
DragAndDropManager startDrag:dragObj from:inputView. |
|
181 | 435 |
] |
436 |
||
278 | 437 |
! |
438 |
||
439 |
startDragWithOffset:offs |
|
440 |
"start drag of selection |
|
441 |
" |
|
720 | 442 |
|dragObj spec o| |
278 | 443 |
|
444 |
spec := self findSpecFor:selection. |
|
445 |
||
446 |
spec notNil ifTrue:[ |
|
1120 | 447 |
spec := self buildSpecFrom:spec. |
448 |
spec name:(spec copy userFriendlyName, $1). |
|
278 | 449 |
|
1120 | 450 |
self showUnselected. |
451 |
dragObj := DropSpec for:selection specification:spec. |
|
452 |
"/ self showSelected. |
|
278 | 453 |
|
1120 | 454 |
o := lastClickPoint - selection origin. |
278 | 455 |
|
1120 | 456 |
DragAndDropManager |
457 |
startDrag:dragObj |
|
458 |
from:inputView |
|
459 |
offset:o. |
|
278 | 460 |
] |
461 |
||
462 |
"Created: 11.8.1997 / 00:44:17 / cg" |
|
463 |
"Modified: 11.8.1997 / 00:48:35 / cg" |
|
181 | 464 |
! ! |
465 |
||
466 |
!UIGalleryView::Canvas methodsFor:'event handling'! |
|
467 |
||
468 |
buttonMotion:state x:x y:y |
|
469 |
"start a drag on selection |
|
470 |
" |
|
471 |
|sensor| |
|
472 |
||
289 | 473 |
(state ~~ 0 and:[lastClickPoint notNil and:[selection notNil]]) ifTrue:[ |
1120 | 474 |
sensor := self sensor. |
475 |
sensor anyButtonPressed ifTrue:[ |
|
476 |
(lastClickPoint dist:(x@y)) > 10.0 ifTrue:[ |
|
477 |
^ self startDragWithOffset:(x@y) - lastClickPoint |
|
478 |
] |
|
479 |
] |
|
181 | 480 |
] |
481 |
! |
|
482 |
||
483 |
buttonPress:button x:x y:y |
|
484 |
"change selection |
|
485 |
" |
|
486 |
|application| |
|
487 |
||
488 |
button == 1 ifTrue:[ |
|
1120 | 489 |
lastClickPoint := Point x:x y:y. |
490 |
self selection:(self findObjectAtX:x y:y). |
|
181 | 491 |
] ifFalse:[ |
1120 | 492 |
lastClickPoint := nil. |
181 | 493 |
|
1120 | 494 |
(menuSelector notNil and:[(application := self application) notNil]) ifTrue:[ |
495 |
Object messageNotUnderstoodSignal handle:[:ex| |
|
496 |
] do:[ |
|
497 |
application aspectFor:menuSelector |
|
498 |
] |
|
499 |
] |
|
181 | 500 |
] |
501 |
||
502 |
! |
|
503 |
||
504 |
exposeX:x y:y width:w height:h |
|
505 |
"handle an expose event from device; redraw selection |
|
506 |
" |
|
507 |
super exposeX:x y:y width:w height:h. |
|
508 |
||
509 |
(selection notNil and:[self sensor hasExposeEventFor:selection]) ifFalse:[ |
|
1120 | 510 |
self showSelected. |
181 | 511 |
]. |
512 |
||
513 |
||
514 |
! ! |
|
515 |
||
516 |
!UIGalleryView::Canvas methodsFor:'initialization'! |
|
517 |
||
518 |
initialize |
|
519 |
super initialize. |
|
520 |
||
521 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
|
522 |
inputView eventReceiver:self. |
|
523 |
inputView enableButtonEvents. |
|
524 |
inputView enableButtonMotionEvents. |
|
525 |
inputView enableMotionEvents. |
|
526 |
||
897
43f9bdc12ae4
make certain inputView is on top when restarting from a snapshot
Claus Gittinger <cg@exept.de>
parents:
806
diff
changeset
|
527 |
"Modified: / 20.7.1998 / 18:12:38 / cg" |
1128 | 528 |
! |
529 |
||
530 |
mapped |
|
531 |
super mapped. |
|
532 |
inputView raise. |
|
181 | 533 |
! ! |
534 |
||
535 |
!UIGalleryView::Canvas methodsFor:'searching'! |
|
536 |
||
537 |
findObjectAtX:x y:y |
|
538 |
"find the origin/corner of the currentWidget |
|
539 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
540 |
|point id p| |
181 | 541 |
|
542 |
point := Point x:x y:y. |
|
543 |
id := inputView id. |
|
544 |
||
545 |
subViews do:[:v| |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
546 |
|pX pY| |
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
547 |
|
1120 | 548 |
v ~~ inputView ifTrue:[ |
549 |
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
|
550 |
pX := p x. |
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
551 |
pY := p y. |
1120 | 552 |
( pX >= 0 and:[pX <= v width |
553 |
and:[pY >= 0 and:[pY <= v height |
|
554 |
and:[(self findSpecFor:v) notNil]]]] |
|
555 |
) ifTrue:[ |
|
556 |
^ v |
|
557 |
] |
|
558 |
] |
|
181 | 559 |
]. |
560 |
^ nil |
|
561 |
||
562 |
||
563 |
! |
|
564 |
||
565 |
findSpecFor:anObject |
|
566 |
"returns subspec assigned to instance or nil |
|
567 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
568 |
|name| |
181 | 569 |
|
570 |
anObject notNil ifTrue:[ |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
571 |
name := anObject name. |
181 | 572 |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
573 |
specification do:[:aSpec| |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
574 |
aSpec notNil ifTrue:[ |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
575 |
aSpec name = name ifTrue:[ |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
576 |
aSpec canUIDrag ifTrue:[^ aSpec] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
577 |
ifFalse:[^ nil] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
578 |
] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
579 |
] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
580 |
] |
181 | 581 |
]. |
582 |
^ nil |
|
583 |
||
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
584 |
"Modified: / 18.5.1999 / 14:47:25 / cg" |
181 | 585 |
! ! |
586 |
||
587 |
!UIGalleryView::Canvas methodsFor:'selection'! |
|
588 |
||
589 |
handlesOf:aComponent do:aOneArgBlock |
|
590 |
"evaluate the block on each handle; the argument to the block |
|
591 |
is a rectangle |
|
592 |
" |
|
593 |
aComponent notNil ifTrue:[ |
|
1120 | 594 |
aOneArgBlock value:(aComponent origin - (2@2) extent:6@6). |
595 |
aOneArgBlock value:(aComponent corner - (1@1) extent:6@6). |
|
596 |
aOneArgBlock value:(aComponent topRight - (1@2) extent:6@6). |
|
597 |
aOneArgBlock value:(aComponent bottomLeft - (2@1) extent:6@6). |
|
598 |
aOneArgBlock value:(aComponent leftCenter - (2@0) extent:6@6). |
|
599 |
aOneArgBlock value:(aComponent rightCenter - (1@0) extent:6@6). |
|
600 |
aOneArgBlock value:(aComponent topCenter - (0@2) extent:6@6). |
|
601 |
aOneArgBlock value:(aComponent bottomCenter - (0@1) extent:6@6). |
|
181 | 602 |
] |
603 |
||
604 |
||
605 |
! |
|
606 |
||
607 |
selection:anObject |
|
608 |
"selection changed |
|
609 |
" |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
610 |
|spec| |
181 | 611 |
|
612 |
selection ~~ anObject ifTrue:[ |
|
1120 | 613 |
self showUnselected. |
614 |
spec := self findSpecFor:anObject. |
|
181 | 615 |
|
1120 | 616 |
spec notNil ifTrue:[ |
617 |
selection := anObject. |
|
618 |
self showSelected |
|
619 |
] ifFalse:[ |
|
620 |
selection := nil |
|
621 |
]. |
|
622 |
clientSpecHolder notNil ifTrue:[ |
|
623 |
clientSpecHolder value:spec |
|
624 |
] |
|
181 | 625 |
] |
626 |
||
627 |
||
628 |
! |
|
629 |
||
630 |
showSelected |
|
631 |
"show selected |
|
632 |
" |
|
994
29bfed6efe87
dont reselect after startDrag.
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
633 |
shown ifFalse:[^ self]. |
181 | 634 |
|
635 |
selection notNil ifTrue:[ |
|
1120 | 636 |
self clippedByChildren:false. |
181 | 637 |
|
1120 | 638 |
self handlesOf:selection do:[:aRectangle| |
639 |
self fillRectangle:aRectangle |
|
640 |
]. |
|
641 |
self clippedByChildren:true. |
|
181 | 642 |
]. |
643 |
||
644 |
||
645 |
! |
|
646 |
||
647 |
showUnselected |
|
648 |
"show unselected |
|
649 |
" |
|
650 |
|r currSel| |
|
651 |
||
652 |
(currSel := selection) isNil ifTrue:[ |
|
1130
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
653 |
^ self |
181 | 654 |
]. |
994
29bfed6efe87
dont reselect after startDrag.
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
655 |
shown ifFalse:[^ self]. |
181 | 656 |
selection := nil. |
657 |
||
658 |
self clippedByChildren:false. |
|
659 |
||
660 |
self handlesOf:currSel do:[:aRectangle| |
|
1130
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
661 |
self clearRectangle:aRectangle |
181 | 662 |
]. |
663 |
self clippedByChildren:true. |
|
664 |
r := currSel bounds. |
|
665 |
||
666 |
subViews do:[:sv| |
|
1130
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
667 |
|absOrg absFrame| |
181 | 668 |
|
1130
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
669 |
sv ~~ inputView ifTrue:[ |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
670 |
(sv bounds intersects:r) ifTrue:[ |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
671 |
sv borderColor:(Color white). "/ to force a redraw |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
672 |
sv borderColor:(Color black). |
181 | 673 |
|
1130
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
674 |
sv withAllSubViewsDo:[:v| |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
675 |
v realized ifTrue:[ |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
676 |
v fill:v viewBackground. |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
677 |
v exposeX:0 y:0 width:v width height:v height. |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
678 |
] |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
679 |
] |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
680 |
] |
7ab9098da7bd
redraw the border when unselecting the element
Claus Gittinger <cg@exept.de>
parents:
1129
diff
changeset
|
681 |
] |
181 | 682 |
]. |
683 |
selection := currSel. |
|
684 |
||
1017 | 685 |
"Modified: / 9.11.1998 / 12:49:57 / cg" |
181 | 686 |
! ! |
687 |
||
688 |
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
|
689 |
||
690 |
for:aView specification:aSpec |
|
691 |
"create drop object for a view derived from a specification |
|
692 |
" |
|
806 | 693 |
|point extent root device inst displayObject| |
181 | 694 |
|
695 |
device := aView device. |
|
696 |
root := device rootView. |
|
697 |
extent := aView extent. |
|
698 |
point := device translatePoint:0@0 from:(aView id) to:(root id). |
|
699 |
||
700 |
(point x > 0 and:[point y > 0]) ifTrue:[ |
|
1120 | 701 |
point := point + extent. |
702 |
(point x < root width and:[point y < root height]) ifTrue:[ |
|
703 |
aView topView raise. |
|
704 |
device sync. |
|
705 |
aView invalidate. |
|
706 |
aView windowGroup processExposeEvents. |
|
707 |
displayObject := Image fromView:aView grab:false. |
|
708 |
] |
|
181 | 709 |
]. |
806 | 710 |
displayObject isNil ifTrue:[ |
1120 | 711 |
displayObject := Form extent:extent depth:1. |
712 |
displayObject colorMap:(Array with:Color white with:Color black). |
|
713 |
displayObject fill:(Color colorId:0). |
|
714 |
displayObject paint:(Color colorId:1). |
|
715 |
displayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y. |
|
181 | 716 |
]. |
717 |
aSpec class == UISubSpecification ifTrue:[ |
|
1120 | 718 |
aSpec layout:(LayoutOrigin fromPoint:0@0) |
181 | 719 |
]. |
240 | 720 |
|
806 | 721 |
inst := self new. |
722 |
inst displayObject:displayObject. |
|
723 |
inst theObject:aSpec. |
|
724 |
^ inst. |
|
181 | 725 |
! ! |
726 |
||
727 |
!UIGalleryView class methodsFor:'documentation'! |
|
728 |
||
729 |
version |
|
730 |
^ '$Header$' |
|
731 |
! ! |