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