author | Claus Gittinger <cg@exept.de> |
Mon, 01 Jun 2009 08:36:33 +0200 | |
changeset 2552 | 6b958036f5c4 |
parent 2542 | 5cb4a0bdc44c |
child 2553 | 2f9ced7fddeb |
permissions | -rw-r--r-- |
181 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
1120 | 3 |
All Rights Reserved |
181 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1399 | 12 |
"{ Package: 'stx:libtool2' }" |
13 |
||
181 | 14 |
NoteBookView subclass:#UIGalleryView |
15 |
instanceVariableNames:'majorKey minorKeys minorKeysHolder' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-UIPainter' |
|
19 |
! |
|
20 |
||
21 |
View subclass:#Canvas |
|
1675 | 22 |
instanceVariableNames:'clientSpecHolder selection specification lastClickPoint |
2542 | 23 |
menuSelector uiBuilder hiddenCounter showBorders |
24 |
didWarnAboutUnknownSpecs' |
|
181 | 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. |
2200 | 160 |
! |
161 |
||
162 |
showBorders:aBoolean |
|
163 |
"show borders around dragable objects" |
|
164 |
||
165 |
canvas showBorders:aBoolean. |
|
166 |
! ! |
|
167 |
||
168 |
!UIGalleryView methodsFor:'accessing-colors'! |
|
169 |
||
170 |
viewBackground:aColor |
|
171 |
canvas notNil ifTrue:[ |
|
172 |
canvas viewBackground:aColor. |
|
173 |
]. |
|
174 |
^ super viewBackground:aColor |
|
181 | 175 |
! ! |
176 |
||
1399 | 177 |
!UIGalleryView methodsFor:'accessing-holders'! |
181 | 178 |
|
179 |
clientSpecHolder |
|
180 |
"get the holder which keeps the current selection or in case of |
|
181 |
no selection the specification under the cursor |
|
182 |
" |
|
183 |
^ canvas clientSpecHolder |
|
184 |
! |
|
185 |
||
186 |
clientSpecHolder:aHolder |
|
187 |
"set the holder which keeps the current selection or in case of |
|
188 |
no selection the specification under the cursor |
|
189 |
" |
|
190 |
canvas clientSpecHolder:aHolder |
|
191 |
! |
|
192 |
||
193 |
menuSelector |
|
194 |
^ canvas menuSelector |
|
195 |
! |
|
196 |
||
197 |
menuSelector:aSelector |
|
198 |
^ canvas menuSelector:aSelector |
|
199 |
! |
|
200 |
||
201 |
minorKeysHolder |
|
202 |
"get the holder keeping the minor keys; the selectors to access |
|
203 |
specifications from a class associated with the majorKey. |
|
204 |
" |
|
205 |
^ minorKeysHolder |
|
206 |
! |
|
207 |
||
208 |
minorKeysHolder:aValueHolder |
|
209 |
"set the holder keeping the minor keys; the selectors to access |
|
210 |
specifications from a class associated with the majorKey. |
|
211 |
" |
|
212 |
minorKeysHolder notNil ifTrue:[ |
|
1120 | 213 |
minorKeysHolder removeDependent:self. |
181 | 214 |
]. |
215 |
||
216 |
(minorKeysHolder := aValueHolder) notNil ifTrue:[ |
|
1120 | 217 |
minorKeysHolder addDependent:self. |
181 | 218 |
]. |
219 |
self minorKeys:(minorKeysHolder value) |
|
220 |
! ! |
|
221 |
||
222 |
!UIGalleryView methodsFor:'change & update'! |
|
223 |
||
1142 | 224 |
selectionHasChanged |
181 | 225 |
"selection changed |
226 |
" |
|
227 |
|specification selector selection application| |
|
228 |
||
1140 | 229 |
selection := self listIndexOf:(self selection). |
181 | 230 |
|
683 | 231 |
minorKeysHolder notNil ifTrue:[ |
1128 | 232 |
minorKeys := minorKeysHolder value. |
683 | 233 |
]. |
181 | 234 |
(selection notNil and:[minorKeys size >= selection]) ifTrue:[ |
1128 | 235 |
selector := minorKeys at:selection. |
181 | 236 |
|
1128 | 237 |
(majorKey respondsTo:selector) ifTrue:[ |
238 |
specification := majorKey perform:selector |
|
239 |
] ifFalse:[ |
|
240 |
(application := self application) notNil ifTrue:[ |
|
1576
ac7705f0a48d
Object messageNotUnderstoodSignal -> MessageNotUnderstood
ca
parents:
1568
diff
changeset
|
241 |
MessageNotUnderstood handle:[:ex| |
1128 | 242 |
(application class respondsTo:selector) ifTrue:[ |
243 |
specification := application class perform:selector |
|
244 |
] |
|
245 |
] do:[ |
|
246 |
specification := application aspectFor:selector |
|
247 |
] |
|
248 |
] |
|
249 |
] |
|
181 | 250 |
]. |
2199 | 251 |
"/ self withWaitCursorDo:[ |
2242
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
252 |
[ |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
253 |
canvas specification:specification. |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
254 |
] on:NotFoundError do:[:ex| |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
255 |
Transcript showCR:ex description. |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
256 |
ex proceed. |
63b5fdc3c8a3
No debugger when there are unavailable classes in the widget gallery
Stefan Vogel <sv@exept.de>
parents:
2204
diff
changeset
|
257 |
] |
2199 | 258 |
"/ ] |
181 | 259 |
! |
260 |
||
261 |
update |
|
1142 | 262 |
self selectionHasChanged. |
181 | 263 |
! |
264 |
||
265 |
update:something with:aParameter from:changedObject |
|
266 |
"one of my models changed its value |
|
267 |
" |
|
268 |
changedObject == minorKeysHolder ifTrue:[ |
|
1128 | 269 |
^ self minorKeys:( minorKeysHolder value) |
181 | 270 |
]. |
271 |
super update:something with:aParameter from:changedObject. |
|
272 |
||
273 |
! ! |
|
274 |
||
1337 | 275 |
!UIGalleryView methodsFor:'initialization & release'! |
181 | 276 |
|
277 |
initialize |
|
278 |
"setup default attributes |
|
279 |
" |
|
1729
cf1c2f488ba8
oops - do not mix class & instance in canvas-slot
Claus Gittinger <cg@exept.de>
parents:
1675
diff
changeset
|
280 |
canvas := Canvas in:self. |
181 | 281 |
|
282 |
super initialize. |
|
683 | 283 |
|
1142 | 284 |
self action:[:something| self selectionHasChanged ]. |
1582 | 285 |
! |
286 |
||
287 |
release |
|
288 |
minorKeysHolder notNil ifTrue:[ |
|
289 |
minorKeysHolder removeDependent:self. |
|
290 |
minorKeysHolder := nil. |
|
291 |
]. |
|
292 |
super release. |
|
181 | 293 |
! ! |
294 |
||
2495 | 295 |
!UIGalleryView::Canvas class methodsFor:'documentation'! |
296 |
||
297 |
documentation |
|
298 |
" |
|
299 |
I am the canvas of a gallery. Most of what I do is to allow dragging of widget out |
|
300 |
of myself and to care for the drawing of the selection. |
|
301 |
The arrangement into multiple pages is done by my container, which holds me |
|
302 |
in a subcanvas. |
|
303 |
" |
|
304 |
! ! |
|
305 |
||
181 | 306 |
!UIGalleryView::Canvas methodsFor:'accessing'! |
307 |
||
308 |
builder |
|
309 |
"get the builder used to setup a window from a specification (or nil in case |
|
310 |
of using a new builder) |
|
311 |
" |
|
312 |
^ uiBuilder |
|
313 |
! |
|
314 |
||
315 |
builder:something |
|
316 |
"set the builder used to setup a window from a specification (or nil in case |
|
317 |
of using a new builder) |
|
318 |
" |
|
319 |
uiBuilder := something. |
|
320 |
! |
|
321 |
||
322 |
clientSpecHolder |
|
323 |
"get the holder which keeps the current selection or in case of |
|
324 |
no selection the specification under the cursor |
|
325 |
" |
|
326 |
^ clientSpecHolder |
|
327 |
! |
|
328 |
||
329 |
clientSpecHolder:aHolder |
|
330 |
"set the holder which keeps the current selection or in case of |
|
331 |
no selection the specification under the cursor |
|
332 |
" |
|
1674 | 333 |
|spec| |
334 |
||
335 |
spec := clientSpecHolder value. |
|
336 |
||
337 |
aHolder notNil ifTrue:[ clientSpecHolder := aHolder ] |
|
338 |
ifFalse:[ clientSpecHolder := nil asValue ]. |
|
339 |
||
340 |
clientSpecHolder value:spec. |
|
181 | 341 |
! |
342 |
||
343 |
menuSelector |
|
344 |
"return the value of the instance variable 'menuSelector' (automatically generated)" |
|
345 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
346 |
^ menuSelector |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
347 |
! |
181 | 348 |
|
349 |
menuSelector:something |
|
350 |
"set the value of the instance variable 'menuSelector' (automatically generated)" |
|
351 |
||
1455
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
352 |
menuSelector := something. |
5d4d3c5ca76c
Button select is identical to button 1.
Stefan Vogel <sv@exept.de>
parents:
1399
diff
changeset
|
353 |
! |
181 | 354 |
|
2200 | 355 |
showBorders:aBoolean |
356 |
showBorders := aBoolean. |
|
357 |
! |
|
358 |
||
181 | 359 |
specification |
360 |
"get current specification |
|
361 |
" |
|
1674 | 362 |
^ specification |
181 | 363 |
! |
364 |
||
365 |
specification:aSpecOrSpecArray |
|
2542 | 366 |
"set a new specification" |
367 |
||
368 |
|builder newSpec| |
|
181 | 369 |
|
370 |
self selection:nil. |
|
1674 | 371 |
self destroySubViews. |
181 | 372 |
|
2542 | 373 |
specification := nil. |
374 |
aSpecOrSpecArray isNil ifTrue:[^ self]. |
|
375 |
||
376 |
"/ only warn once - otherwise, its annoying |
|
377 |
Array missingClassInLiteralArrayErrorSignal handle:[:ex | |
|
378 |
didWarnAboutUnknownSpecs == true ifFalse:[ |
|
379 |
Dialog warn:(ex description,'\\(Will not warn again - please check for unloaded classes/packages)' withCRs). |
|
380 |
]. |
|
381 |
didWarnAboutUnknownSpecs := true. |
|
382 |
ex proceed. |
|
383 |
] do:[ |
|
384 |
newSpec := UISpecification from:aSpecOrSpecArray. |
|
181 | 385 |
]. |
2542 | 386 |
newSpec isNil ifTrue:[^ self]. |
387 |
(newSpec respondsTo:#'buildViewFor:in:') ifFalse:[^ self]. |
|
388 |
specification := newSpec. |
|
181 | 389 |
|
1674 | 390 |
(builder := uiBuilder) isNil ifTrue:[ |
391 |
builder := UIBuilder new isEditing:true. |
|
392 |
builder showDefaults:true. |
|
393 |
]. |
|
205 | 394 |
|
1674 | 395 |
specification buildViewFor:builder in:self. |
396 | 396 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
397 |
"/ components notEmptyOrNil ifTrue:[ self halt ]. |
1674 | 398 |
subViews size ~~ 0 ifTrue:[ |
2200 | 399 |
showBorders ifTrue:[ |
400 |
subViews do:[:v| |
|
401 |
(self findSpecFor:v) notNil ifTrue:[ |
|
402 |
v borderWidth:1 |
|
403 |
]. |
|
404 |
]. |
|
1561 | 405 |
]. |
1674 | 406 |
realized ifTrue:[ self realizeAllSubViews ]. |
407 |
]. |
|
181 | 408 |
! ! |
409 |
||
410 |
!UIGalleryView::Canvas methodsFor:'building'! |
|
411 |
||
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
412 |
recursiveBuildSpecFromSpecPrototype:aSpec |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
413 |
"build spec out of spec prototype" |
2495 | 414 |
|
181 | 415 |
|spec comp coll| |
416 |
||
417 |
(aSpec notNil and:[aSpec canUIDrag]) ifFalse:[ |
|
2495 | 418 |
^ nil |
181 | 419 |
]. |
420 |
||
421 |
spec := aSpec copy. |
|
422 |
(aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[ |
|
2495 | 423 |
^ spec |
181 | 424 |
]. |
425 |
comp := aSpec component. |
|
426 |
spec component:nil. |
|
427 |
||
428 |
comp canUIDrag ifFalse:[ |
|
2495 | 429 |
^ spec |
181 | 430 |
]. |
431 |
coll := OrderedCollection new. |
|
432 |
||
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
433 |
comp do:[:anEntry| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
434 |
|spc| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
435 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
436 |
(spc := self recursiveBuildSpecFromSpecPrototype:anEntry) notNil ifTrue:[ |
2495 | 437 |
coll add:spc |
438 |
] |
|
181 | 439 |
]. |
440 |
coll isEmpty ifTrue:[ |
|
2495 | 441 |
^ spec |
181 | 442 |
]. |
443 |
comp := comp copy. |
|
444 |
comp collection:coll. |
|
445 |
spec component:comp. |
|
2495 | 446 |
^ spec |
181 | 447 |
! ! |
448 |
||
449 |
!UIGalleryView::Canvas methodsFor:'drag & drop'! |
|
450 |
||
1675 | 451 |
startDragFrom:evView |
2495 | 452 |
"start drag at lastClickPoint" |
453 |
||
2204 | 454 |
|spec dragObj offset clickPos dragAndDropManager| |
1671 | 455 |
|
456 |
clickPos := lastClickPoint. |
|
457 |
clickPos isNil ifTrue:[^ self]. |
|
458 |
lastClickPoint := nil. |
|
459 |
||
1674 | 460 |
spec := clientSpecHolder value. |
1671 | 461 |
spec isNil ifTrue:[^ self]. |
181 | 462 |
|
2495 | 463 |
self withSelectionHiddenDo:[ |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
464 |
spec := self recursiveBuildSpecFromSpecPrototype:spec. |
1675 | 465 |
spec name:nil. |
1674 | 466 |
|
1675 | 467 |
dragObj := DropSpec for:selection specification:spec. |
468 |
offset := clickPos - selection origin. |
|
469 |
]. |
|
278 | 470 |
|
2204 | 471 |
dragAndDropManager := DragAndDropManager new. |
472 |
dragAndDropManager giveFocusToTargetWidget:false. |
|
473 |
||
2495 | 474 |
dragAndDropManager |
475 |
startDrag:dragObj |
|
476 |
from:self |
|
477 |
offset:offset |
|
478 |
atEnd:nil |
|
479 |
display:nil. |
|
181 | 480 |
! ! |
481 |
||
482 |
!UIGalleryView::Canvas methodsFor:'event handling'! |
|
483 |
||
1671 | 484 |
processEvent:anEvent |
1895 | 485 |
"filter keyboard events. |
486 |
Return true, if I have eaten the event" |
|
487 |
||
1674 | 488 |
|evView p| |
181 | 489 |
|
1671 | 490 |
evView := anEvent view. |
491 |
evView isNil ifTrue:[ ^ false ]. |
|
181 | 492 |
|
2201 | 493 |
(anEvent isButtonPressEvent or:[anEvent isButtonReleaseEvent])ifTrue:[ |
494 |
lastClickPoint := nil. |
|
495 |
]. |
|
1671 | 496 |
evView == self ifFalse:[ |
1674 | 497 |
(evView isComponentOf:self) ifFalse:[ ^ false ]. |
1671 | 498 |
]. |
181 | 499 |
|
1674 | 500 |
anEvent isButtonEvent ifFalse:[ |
501 |
anEvent isInputEvent ifTrue:[^ true]. |
|
2201 | 502 |
|
1675 | 503 |
anEvent isDamage ifTrue:[ self redrawSelection ]. |
1671 | 504 |
^ false |
505 |
]. |
|
181 | 506 |
|
2201 | 507 |
anEvent isButtonReleaseEvent ifTrue:[ ^ true ]. |
181 | 508 |
|
1674 | 509 |
anEvent isButtonMotionEvent ifTrue:[ |
510 |
(lastClickPoint notNil and:[anEvent state ~~ 0]) ifTrue:[ |
|
511 |
p := Point x:(anEvent x) y:(anEvent y). |
|
2201 | 512 |
p := device translatePoint:p fromView:evView toView:self. |
1671 | 513 |
|
2201 | 514 |
(lastClickPoint dist:p) > 20.0 ifTrue:[ |
1675 | 515 |
self startDragFrom:evView. |
516 |
lastClickPoint := nil. |
|
1671 | 517 |
] |
518 |
]. |
|
519 |
^ true |
|
520 |
]. |
|
521 |
||
2495 | 522 |
anEvent isButtonPressEvent ifTrue:[ |
523 |
|button application| |
|
524 |
||
1674 | 525 |
button := anEvent button. |
526 |
||
527 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
528 |
p := Point x:(anEvent x) y:(anEvent y). |
|
529 |
p := device translatePoint:p fromView:evView toView:self. |
|
530 |
||
531 |
self selection:(self findObjectAt:p). |
|
532 |
||
533 |
selection notNil ifTrue:[ |
|
2201 | 534 |
lastClickPoint := p. |
1674 | 535 |
] |
536 |
] ifFalse:[ |
|
537 |
(menuSelector notNil and:[(application := self application) notNil]) ifTrue:[ |
|
538 |
MessageNotUnderstood catch:[ |
|
539 |
application aspectFor:menuSelector |
|
540 |
] |
|
1671 | 541 |
] |
542 |
]. |
|
543 |
^ true |
|
544 |
]. |
|
545 |
||
546 |
^ true |
|
181 | 547 |
! ! |
548 |
||
2201 | 549 |
!UIGalleryView::Canvas methodsFor:'focus handling'! |
550 |
||
551 |
subviewsInFocusOrder |
|
552 |
"returns none views - focus not handled within buildin canvas" |
|
553 |
||
554 |
^ #() |
|
555 |
! ! |
|
556 |
||
181 | 557 |
!UIGalleryView::Canvas methodsFor:'initialization'! |
558 |
||
2200 | 559 |
destroy |
560 |
|winGrp| |
|
561 |
||
562 |
winGrp := self windowGroup. |
|
563 |
winGrp notNil ifTrue:[ |
|
564 |
winGrp removePreEventHook:self. |
|
565 |
]. |
|
566 |
super destroy. |
|
567 |
! |
|
568 |
||
181 | 569 |
initialize |
570 |
super initialize. |
|
1674 | 571 |
clientSpecHolder := nil asValue. |
1675 | 572 |
hiddenCounter := 0. |
2200 | 573 |
showBorders := true. |
1128 | 574 |
! |
575 |
||
1671 | 576 |
realize |
2200 | 577 |
|winGrp| |
578 |
||
1671 | 579 |
super realize. |
2200 | 580 |
winGrp := self windowGroup. |
581 |
winGrp notNil ifTrue:[ |
|
582 |
winGrp addPreEventHook:self. |
|
583 |
]. |
|
1671 | 584 |
! ! |
585 |
||
181 | 586 |
!UIGalleryView::Canvas methodsFor:'searching'! |
587 |
||
1674 | 588 |
findObjectAt:aPoint |
2495 | 589 |
|seeIfWidgetIsHit p x y| |
181 | 590 |
|
2495 | 591 |
seeIfWidgetIsHit := |
592 |
[:v | |
|
593 |
p := device translatePoint:aPoint fromView:self toView:v. |
|
594 |
x := p x. |
|
595 |
y := p y. |
|
181 | 596 |
|
2495 | 597 |
( x >= 0 and:[x <= v width |
598 |
and:[y >= 0 and:[y <= v height |
|
599 |
and:[(self findSpecFor:v) notNil]]]] |
|
600 |
) ifTrue:[ |
|
601 |
^ v |
|
602 |
] |
|
603 |
]. |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
604 |
|
2495 | 605 |
subViews notNil ifTrue:[ subViews do:seeIfWidgetIsHit ]. |
606 |
components notNil ifTrue:[ components do:seeIfWidgetIsHit ]. |
|
1671 | 607 |
^ nil |
181 | 608 |
! |
609 |
||
2495 | 610 |
findSpecFor:aWidget |
611 |
"returns the spec which is assigned to aWidget or nil" |
|
612 |
||
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
613 |
|name| |
181 | 614 |
|
2495 | 615 |
aWidget notNil ifTrue:[ |
616 |
name := aWidget name. |
|
181 | 617 |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
618 |
specification do:[:aSpec| |
1674 | 619 |
(aSpec notNil and:[aSpec name = name]) ifTrue:[ |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
620 |
aSpec canUIDrag ifFalse:[^ nil ]. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
621 |
^ aSpec |
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
622 |
] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
623 |
] |
181 | 624 |
]. |
625 |
^ nil |
|
626 |
||
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
627 |
"Modified: / 18.5.1999 / 14:47:25 / cg" |
181 | 628 |
! ! |
629 |
||
630 |
!UIGalleryView::Canvas methodsFor:'selection'! |
|
631 |
||
632 |
handlesOf:aComponent do:aOneArgBlock |
|
2534
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
633 |
"evaluate the block on each handle; the argument to the block is a rectangle" |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
634 |
|
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
635 |
|ext| |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
636 |
|
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
637 |
ext := 6@6. |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
638 |
|
181 | 639 |
aComponent notNil ifTrue:[ |
2534
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
640 |
aOneArgBlock value:(aComponent origin - (2@2) extent:ext). |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
641 |
aOneArgBlock value:(aComponent corner - (1@1) extent:ext). |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
642 |
aOneArgBlock value:(aComponent topRight - (1@2) extent:ext). |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
643 |
aOneArgBlock value:(aComponent bottomLeft - (2@1) extent:ext). |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
644 |
aOneArgBlock value:(aComponent leftCenter rounded - (2@0) extent:ext). |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
645 |
aOneArgBlock value:(aComponent rightCenter rounded - (1@0) extent:ext). |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
646 |
aOneArgBlock value:(aComponent topCenter rounded - (0@2) extent:ext). |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
647 |
aOneArgBlock value:(aComponent bottomCenter rounded - (0@1) extent:ext). |
181 | 648 |
] |
649 |
! |
|
650 |
||
1675 | 651 |
redrawSelection |
2495 | 652 |
"redraw all items selected" |
653 |
||
1675 | 654 |
(shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[ |
655 |
self clippedByChildren:false. |
|
181 | 656 |
|
1675 | 657 |
self handlesOf:selection do:[:aRectangle| |
2534
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
658 |
self paint:Color black. |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
659 |
self fillRectangle:aRectangle. |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
660 |
|
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
661 |
self paint:Color white. |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
662 |
self displayRectangle:(aRectangle insetBy:-1). |
1675 | 663 |
]. |
664 |
self clippedByChildren:true. |
|
1671 | 665 |
]. |
666 |
! |
|
667 |
||
1674 | 668 |
selection:aView |
2495 | 669 |
"selection changed" |
670 |
||
1671 | 671 |
|spec| |
672 |
||
1674 | 673 |
selection == aView ifTrue:[^ self]. |
1671 | 674 |
|
2495 | 675 |
self withSelectionHiddenDo:[ |
1675 | 676 |
spec := self findSpecFor:aView. |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
677 |
|
2495 | 678 |
selection := (spec isNil) ifTrue:[nil] ifFalse:[aView]. |
1675 | 679 |
clientSpecHolder value:spec. |
680 |
]. |
|
681 |
! |
|
682 |
||
2495 | 683 |
withSelectionHiddenDo:aOneArgBlock |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
684 |
[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
685 |
|r forceExpose| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
686 |
|
2495 | 687 |
hiddenCounter := hiddenCounter + 1. |
1675 | 688 |
hiddenCounter == 1 ifTrue:[ |
689 |
(shown and:[selection notNil]) ifTrue:[ |
|
690 |
self clippedByChildren:false. |
|
691 |
||
692 |
self handlesOf:selection do:[:aRectangle| |
|
2495 | 693 |
self clearRectangle:aRectangle. |
694 |
self invalidateRectangle:aRectangle repairNow:false. |
|
1675 | 695 |
]. |
696 |
self clippedByChildren:true. |
|
1671 | 697 |
|
1675 | 698 |
r := selection bounds. |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
699 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
700 |
forceExpose := |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
701 |
[:sv| |
2495 | 702 |
|absOrg absFrame| |
1675 | 703 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
704 |
(sv bounds intersects:r) ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
705 |
sv isView ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
706 |
sv borderColor:(Color white). "/ kludge to force a redraw |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
707 |
sv borderColor:(Color black). |
1671 | 708 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
709 |
sv withAllSubViewsDo:[:v| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
710 |
v realized ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
711 |
v fill:v viewBackground. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
712 |
v exposeX:0 y:0 width:v width height:v height. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
713 |
] |
2495 | 714 |
] |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
715 |
] ifFalse:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
716 |
sv invalidate. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
717 |
]. |
1675 | 718 |
] |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
719 |
]. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
720 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
721 |
(subViews ? #()) do:forceExpose. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
722 |
(components ? #()) do:forceExpose. |
1675 | 723 |
]. |
724 |
]. |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
725 |
self repairDamage. "/ ensure that any outstanding clear/redraw of the unselect are done before |
1675 | 726 |
aOneArgBlock value. |
727 |
] ensure:[ |
|
2495 | 728 |
self repairDamage. "/ ensure that any outstanding clear/redraw of the unselect are done before |
729 |
||
1675 | 730 |
hiddenCounter := hiddenCounter - 1. |
731 |
self redrawSelection. |
|
732 |
]. |
|
181 | 733 |
! ! |
734 |
||
735 |
!UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
|
736 |
||
2495 | 737 |
for:aWidget specification:aSpec |
738 |
"create drop object for a widget derived from a specification" |
|
739 |
||
740 |
|point extent rootView device inst displayObject view| |
|
181 | 741 |
|
2495 | 742 |
device := aWidget device. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
743 |
rootView := device rootView. |
2495 | 744 |
extent := aWidget extent. |
745 |
aWidget isView ifTrue:[ |
|
746 |
view := aWidget. |
|
747 |
point := device translatePoint:0@0 fromView:aWidget toView:rootView. |
|
748 |
] ifFalse:[ |
|
749 |
view := aWidget container. |
|
750 |
point := device translatePoint:(aWidget origin) fromView:view toView:rootView. |
|
751 |
]. |
|
181 | 752 |
(point x > 0 and:[point y > 0]) ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
753 |
point := point + extent. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
754 |
(point x < rootView width and:[point y < rootView height]) ifTrue:[ |
2495 | 755 |
aWidget topView raise. |
1568
a9d61da29e8b
no need for device sync - flush will do
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
756 |
device flush. |
2495 | 757 |
aWidget invalidate. |
758 |
aWidget windowGroup processExposeEvents. |
|
759 |
displayObject := Image fromView:aWidget grab:false. |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
760 |
] |
181 | 761 |
]. |
806 | 762 |
displayObject isNil ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
763 |
displayObject := Form extent:extent depth:1. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
764 |
displayObject colorMap:(Array with:Color white with:Color black). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
765 |
displayObject fill:(Color colorId:0). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
766 |
displayObject paint:(Color colorId:1). |
2495 | 767 |
displayObject displayRectangleX:0 y:0 width:aWidget extent x height:aWidget extent y. |
181 | 768 |
]. |
769 |
aSpec class == UISubSpecification ifTrue:[ |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
770 |
aSpec layout:(LayoutOrigin fromPoint:0@0) |
181 | 771 |
]. |
240 | 772 |
|
806 | 773 |
inst := self new. |
774 |
inst displayObject:displayObject. |
|
775 |
inst theObject:aSpec. |
|
2495 | 776 |
^ inst. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
777 |
|
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
778 |
"Modified: / 10.10.2001 / 14:03:00 / cg" |
181 | 779 |
! ! |
780 |
||
781 |
!UIGalleryView class methodsFor:'documentation'! |
|
782 |
||
783 |
version |
|
784 |
^ '$Header$' |
|
785 |
! ! |