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