author | Claus Gittinger <cg@exept.de> |
Mon, 04 May 2015 16:42:14 +0200 | |
changeset 3210 | d74ece5bbce1 |
parent 3081 | feb178704671 |
child 3260 | f7b43e21cef8 |
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 |
||
2563 | 21 |
View subclass:#Palette |
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:'' |
2563 | 34 |
privateIn:UIGalleryView::Palette |
181 | 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 |
" |
|
2563 | 280 |
canvas := Palette 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 |
||
2563 | 295 |
!UIGalleryView::Palette class methodsFor:'documentation'! |
2495 | 296 |
|
297 |
documentation |
|
298 |
" |
|
2563 | 299 |
I am the palette of a gallery. Most of what I do is to allow dragging of a widget out |
2495 | 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 |
||
2563 | 306 |
!UIGalleryView::Palette methodsFor:'accessing'! |
181 | 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. |
|
2563 | 393 |
builder application:self application. "/ for resources like images |
1674 | 394 |
]. |
205 | 395 |
|
1674 | 396 |
specification buildViewFor:builder in:self. |
396 | 397 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
398 |
"/ components notEmptyOrNil ifTrue:[ self halt ]. |
1674 | 399 |
subViews size ~~ 0 ifTrue:[ |
2200 | 400 |
showBorders ifTrue:[ |
401 |
subViews do:[:v| |
|
402 |
(self findSpecFor:v) notNil ifTrue:[ |
|
403 |
v borderWidth:1 |
|
404 |
]. |
|
405 |
]. |
|
1561 | 406 |
]. |
1674 | 407 |
realized ifTrue:[ self realizeAllSubViews ]. |
408 |
]. |
|
181 | 409 |
! ! |
410 |
||
2563 | 411 |
!UIGalleryView::Palette methodsFor:'building'! |
181 | 412 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
413 |
recursiveBuildSpecFromSpecPrototype:aSpec |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
414 |
"build spec out of spec prototype" |
2495 | 415 |
|
181 | 416 |
|spec comp coll| |
417 |
||
418 |
(aSpec notNil and:[aSpec canUIDrag]) ifFalse:[ |
|
2495 | 419 |
^ nil |
181 | 420 |
]. |
421 |
||
422 |
spec := aSpec copy. |
|
423 |
(aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[ |
|
2495 | 424 |
^ spec |
181 | 425 |
]. |
426 |
comp := aSpec component. |
|
427 |
spec component:nil. |
|
428 |
||
429 |
comp canUIDrag ifFalse:[ |
|
2495 | 430 |
^ spec |
181 | 431 |
]. |
432 |
coll := OrderedCollection new. |
|
433 |
||
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
434 |
comp do:[:anEntry| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
435 |
|spc| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
436 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
437 |
(spc := self recursiveBuildSpecFromSpecPrototype:anEntry) notNil ifTrue:[ |
2495 | 438 |
coll add:spc |
439 |
] |
|
181 | 440 |
]. |
441 |
coll isEmpty ifTrue:[ |
|
2495 | 442 |
^ spec |
181 | 443 |
]. |
444 |
comp := comp copy. |
|
445 |
comp collection:coll. |
|
446 |
spec component:comp. |
|
2495 | 447 |
^ spec |
181 | 448 |
! ! |
449 |
||
2563 | 450 |
!UIGalleryView::Palette methodsFor:'drag & drop'! |
181 | 451 |
|
1675 | 452 |
startDragFrom:evView |
2495 | 453 |
"start drag at lastClickPoint" |
454 |
||
2204 | 455 |
|spec dragObj offset clickPos dragAndDropManager| |
1671 | 456 |
|
457 |
clickPos := lastClickPoint. |
|
458 |
clickPos isNil ifTrue:[^ self]. |
|
459 |
lastClickPoint := nil. |
|
460 |
||
1674 | 461 |
spec := clientSpecHolder value. |
1671 | 462 |
spec isNil ifTrue:[^ self]. |
181 | 463 |
|
2495 | 464 |
self withSelectionHiddenDo:[ |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
465 |
spec := self recursiveBuildSpecFromSpecPrototype:spec. |
1675 | 466 |
spec name:nil. |
1674 | 467 |
|
1675 | 468 |
dragObj := DropSpec for:selection specification:spec. |
469 |
offset := clickPos - selection origin. |
|
470 |
]. |
|
278 | 471 |
|
2204 | 472 |
dragAndDropManager := DragAndDropManager new. |
473 |
dragAndDropManager giveFocusToTargetWidget:false. |
|
474 |
||
2495 | 475 |
dragAndDropManager |
476 |
startDrag:dragObj |
|
477 |
from:self |
|
478 |
offset:offset |
|
479 |
atEnd:nil |
|
480 |
display:nil. |
|
181 | 481 |
! ! |
482 |
||
2563 | 483 |
!UIGalleryView::Palette methodsFor:'event handling'! |
181 | 484 |
|
1671 | 485 |
processEvent:anEvent |
1895 | 486 |
"filter keyboard events. |
487 |
Return true, if I have eaten the event" |
|
488 |
||
1674 | 489 |
|evView p| |
181 | 490 |
|
1671 | 491 |
evView := anEvent view. |
492 |
evView isNil ifTrue:[ ^ false ]. |
|
2553 | 493 |
(evView ~~ self and:[ (evView isComponentOf:self) not ]) ifTrue:[ ^ false ]. |
181 | 494 |
|
2201 | 495 |
(anEvent isButtonPressEvent or:[anEvent isButtonReleaseEvent])ifTrue:[ |
496 |
lastClickPoint := nil. |
|
497 |
]. |
|
1674 | 498 |
anEvent isButtonEvent ifFalse:[ |
499 |
anEvent isInputEvent ifTrue:[^ true]. |
|
2201 | 500 |
|
1675 | 501 |
anEvent isDamage ifTrue:[ self redrawSelection ]. |
1671 | 502 |
^ false |
503 |
]. |
|
181 | 504 |
|
2201 | 505 |
anEvent isButtonReleaseEvent ifTrue:[ ^ true ]. |
181 | 506 |
|
1674 | 507 |
anEvent isButtonMotionEvent ifTrue:[ |
508 |
(lastClickPoint notNil and:[anEvent state ~~ 0]) ifTrue:[ |
|
509 |
p := Point x:(anEvent x) y:(anEvent y). |
|
3081 | 510 |
p := self graphicsDevice translatePoint:p fromView:evView toView:self. |
1671 | 511 |
|
2201 | 512 |
(lastClickPoint dist:p) > 20.0 ifTrue:[ |
1675 | 513 |
self startDragFrom:evView. |
514 |
lastClickPoint := nil. |
|
1671 | 515 |
] |
516 |
]. |
|
517 |
^ true |
|
518 |
]. |
|
519 |
||
2495 | 520 |
anEvent isButtonPressEvent ifTrue:[ |
521 |
|button application| |
|
522 |
||
1674 | 523 |
button := anEvent button. |
524 |
||
525 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
526 |
p := Point x:(anEvent x) y:(anEvent y). |
|
3081 | 527 |
p := self graphicsDevice translatePoint:p fromView:evView toView:self. |
1674 | 528 |
|
529 |
self selection:(self findObjectAt:p). |
|
530 |
||
531 |
selection notNil ifTrue:[ |
|
2201 | 532 |
lastClickPoint := p. |
1674 | 533 |
] |
534 |
] ifFalse:[ |
|
535 |
(menuSelector notNil and:[(application := self application) notNil]) ifTrue:[ |
|
536 |
MessageNotUnderstood catch:[ |
|
537 |
application aspectFor:menuSelector |
|
538 |
] |
|
1671 | 539 |
] |
540 |
]. |
|
541 |
^ true |
|
542 |
]. |
|
543 |
||
544 |
^ true |
|
181 | 545 |
! ! |
546 |
||
2563 | 547 |
!UIGalleryView::Palette methodsFor:'focus handling'! |
2201 | 548 |
|
549 |
subviewsInFocusOrder |
|
550 |
"returns none views - focus not handled within buildin canvas" |
|
551 |
||
552 |
^ #() |
|
553 |
! ! |
|
554 |
||
2563 | 555 |
!UIGalleryView::Palette methodsFor:'initialization'! |
181 | 556 |
|
2200 | 557 |
destroy |
558 |
|winGrp| |
|
559 |
||
560 |
winGrp := self windowGroup. |
|
561 |
winGrp notNil ifTrue:[ |
|
562 |
winGrp removePreEventHook:self. |
|
563 |
]. |
|
564 |
super destroy. |
|
565 |
! |
|
566 |
||
181 | 567 |
initialize |
568 |
super initialize. |
|
1674 | 569 |
clientSpecHolder := nil asValue. |
1675 | 570 |
hiddenCounter := 0. |
2200 | 571 |
showBorders := true. |
1128 | 572 |
! |
573 |
||
1671 | 574 |
realize |
2200 | 575 |
|winGrp| |
576 |
||
1671 | 577 |
super realize. |
2200 | 578 |
winGrp := self windowGroup. |
579 |
winGrp notNil ifTrue:[ |
|
580 |
winGrp addPreEventHook:self. |
|
581 |
]. |
|
1671 | 582 |
! ! |
583 |
||
2563 | 584 |
!UIGalleryView::Palette methodsFor:'searching'! |
181 | 585 |
|
1674 | 586 |
findObjectAt:aPoint |
2495 | 587 |
|seeIfWidgetIsHit p x y| |
181 | 588 |
|
2495 | 589 |
seeIfWidgetIsHit := |
590 |
[:v | |
|
3081 | 591 |
p := self graphicsDevice translatePoint:aPoint fromView:self toView:v. |
2495 | 592 |
x := p x. |
593 |
y := p y. |
|
181 | 594 |
|
2495 | 595 |
( x >= 0 and:[x <= v width |
596 |
and:[y >= 0 and:[y <= v height |
|
597 |
and:[(self findSpecFor:v) notNil]]]] |
|
598 |
) ifTrue:[ |
|
599 |
^ v |
|
600 |
] |
|
601 |
]. |
|
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
602 |
|
2495 | 603 |
subViews notNil ifTrue:[ subViews do:seeIfWidgetIsHit ]. |
604 |
components notNil ifTrue:[ components do:seeIfWidgetIsHit ]. |
|
1671 | 605 |
^ nil |
181 | 606 |
! |
607 |
||
2495 | 608 |
findSpecFor:aWidget |
609 |
"returns the spec which is assigned to aWidget or nil" |
|
610 |
||
239
ce46eb6f92a5
do not clobber the global named DisplayObject - shame on ca.
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
611 |
|name| |
181 | 612 |
|
2495 | 613 |
aWidget notNil ifTrue:[ |
614 |
name := aWidget name. |
|
181 | 615 |
|
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
616 |
specification do:[:aSpec| |
1674 | 617 |
(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
|
618 |
aSpec canUIDrag ifFalse:[^ nil ]. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
619 |
^ aSpec |
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
620 |
] |
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
621 |
] |
181 | 622 |
]. |
623 |
^ nil |
|
624 |
||
1127
41253026b070
ignore nil-specs, as encountered when a specClass
Claus Gittinger <cg@exept.de>
parents:
1120
diff
changeset
|
625 |
"Modified: / 18.5.1999 / 14:47:25 / cg" |
181 | 626 |
! ! |
627 |
||
2563 | 628 |
!UIGalleryView::Palette methodsFor:'selection'! |
181 | 629 |
|
630 |
handlesOf:aComponent do:aOneArgBlock |
|
2534
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
631 |
"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
|
632 |
|
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
633 |
|ext| |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
634 |
|
2561 | 635 |
ext := 8@8. |
2534
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
636 |
|
181 | 637 |
aComponent notNil ifTrue:[ |
2561 | 638 |
aOneArgBlock value:(aComponent origin - (3@3) extent:ext). |
639 |
aOneArgBlock value:(aComponent corner - (2@2) extent:ext). |
|
640 |
aOneArgBlock value:(aComponent topRight - (2@3) extent:ext). |
|
641 |
aOneArgBlock value:(aComponent bottomLeft - (3@2) extent:ext). |
|
642 |
aOneArgBlock value:(aComponent leftCenter rounded - (3@0) extent:ext). |
|
643 |
aOneArgBlock value:(aComponent rightCenter rounded - (2@0) extent:ext). |
|
644 |
aOneArgBlock value:(aComponent topCenter rounded - (0@3) extent:ext). |
|
645 |
aOneArgBlock value:(aComponent bottomCenter rounded - (0@2) extent:ext). |
|
181 | 646 |
] |
647 |
! |
|
648 |
||
1675 | 649 |
redrawSelection |
2495 | 650 |
"redraw all items selected" |
651 |
||
1675 | 652 |
(shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[ |
653 |
self clippedByChildren:false. |
|
181 | 654 |
|
1675 | 655 |
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
|
656 |
self paint:Color black. |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
657 |
self fillRectangle:aRectangle. |
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
658 |
|
b717cb2e0cb8
nicer handles: care for handles-on-dark (white frame)
Claus Gittinger <cg@exept.de>
parents:
2504
diff
changeset
|
659 |
self paint:Color white. |
2561 | 660 |
self displayRectangle:(aRectangle insetBy:0). |
1675 | 661 |
]. |
662 |
self clippedByChildren:true. |
|
1671 | 663 |
]. |
664 |
! |
|
665 |
||
1674 | 666 |
selection:aView |
2495 | 667 |
"selection changed" |
668 |
||
1671 | 669 |
|spec| |
670 |
||
1674 | 671 |
selection == aView ifTrue:[^ self]. |
1671 | 672 |
|
2495 | 673 |
self withSelectionHiddenDo:[ |
1675 | 674 |
spec := self findSpecFor:aView. |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
675 |
|
2495 | 676 |
selection := (spec isNil) ifTrue:[nil] ifFalse:[aView]. |
1675 | 677 |
clientSpecHolder value:spec. |
678 |
]. |
|
679 |
! |
|
680 |
||
2495 | 681 |
withSelectionHiddenDo:aOneArgBlock |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
682 |
[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
683 |
|r forceExpose| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
684 |
|
2495 | 685 |
hiddenCounter := hiddenCounter + 1. |
1675 | 686 |
hiddenCounter == 1 ifTrue:[ |
687 |
(shown and:[selection notNil]) ifTrue:[ |
|
688 |
self clippedByChildren:false. |
|
689 |
||
690 |
self handlesOf:selection do:[:aRectangle| |
|
2495 | 691 |
self clearRectangle:aRectangle. |
692 |
self invalidateRectangle:aRectangle repairNow:false. |
|
1675 | 693 |
]. |
694 |
self clippedByChildren:true. |
|
1671 | 695 |
|
1675 | 696 |
r := selection bounds. |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
697 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
698 |
forceExpose := |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
699 |
[:sv| |
2495 | 700 |
|absOrg absFrame| |
1675 | 701 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
702 |
(sv bounds intersects:r) ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
703 |
sv isView ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
704 |
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
|
705 |
sv borderColor:(Color black). |
1671 | 706 |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
707 |
sv withAllSubViewsDo:[:v| |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
708 |
v realized ifTrue:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
709 |
v fill:v viewBackground. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
710 |
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
|
711 |
] |
2495 | 712 |
] |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
713 |
] ifFalse:[ |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
714 |
sv invalidate. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
715 |
]. |
1675 | 716 |
] |
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
717 |
]. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
718 |
|
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
719 |
(subViews ? #()) do:forceExpose. |
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
720 |
(components ? #()) do:forceExpose. |
1675 | 721 |
]. |
722 |
]. |
|
2502
c27a926cbe67
cleaned up the code and fixed many bugs;
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
723 |
self repairDamage. "/ ensure that any outstanding clear/redraw of the unselect are done before |
1675 | 724 |
aOneArgBlock value. |
725 |
] ensure:[ |
|
2495 | 726 |
self repairDamage. "/ ensure that any outstanding clear/redraw of the unselect are done before |
727 |
||
1675 | 728 |
hiddenCounter := hiddenCounter - 1. |
729 |
self redrawSelection. |
|
730 |
]. |
|
181 | 731 |
! ! |
732 |
||
2563 | 733 |
!UIGalleryView::Palette::DropSpec class methodsFor:'instance creation'! |
181 | 734 |
|
2495 | 735 |
for:aWidget specification:aSpec |
736 |
"create drop object for a widget derived from a specification" |
|
737 |
||
738 |
|point extent rootView device inst displayObject view| |
|
181 | 739 |
|
2495 | 740 |
device := aWidget device. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
741 |
rootView := device rootView. |
2495 | 742 |
extent := aWidget extent. |
743 |
aWidget isView ifTrue:[ |
|
744 |
view := aWidget. |
|
745 |
point := device translatePoint:0@0 fromView:aWidget toView:rootView. |
|
746 |
] ifFalse:[ |
|
747 |
view := aWidget container. |
|
748 |
point := device translatePoint:(aWidget origin) fromView:view toView:rootView. |
|
749 |
]. |
|
181 | 750 |
(point x > 0 and:[point y > 0]) ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
751 |
point := point + extent. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
752 |
(point x < rootView width and:[point y < rootView height]) ifTrue:[ |
2495 | 753 |
aWidget topView raise. |
1568
a9d61da29e8b
no need for device sync - flush will do
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
754 |
device flush. |
2495 | 755 |
aWidget invalidate. |
756 |
aWidget windowGroup processExposeEvents. |
|
757 |
displayObject := Image fromView:aWidget grab:false. |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
758 |
] |
181 | 759 |
]. |
806 | 760 |
displayObject isNil ifTrue:[ |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
761 |
displayObject := Form extent:extent depth:1. |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
762 |
displayObject colorMap:(Array with:Color white with:Color black). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
763 |
displayObject fill:(Color colorId:0). |
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
764 |
displayObject paint:(Color colorId:1). |
2495 | 765 |
displayObject displayRectangleX:0 y:0 width:aWidget extent x height:aWidget extent y. |
181 | 766 |
]. |
767 |
aSpec class == UISubSpecification ifTrue:[ |
|
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
768 |
aSpec layout:(LayoutOrigin fromPoint:0@0) |
181 | 769 |
]. |
240 | 770 |
|
806 | 771 |
inst := self new. |
772 |
inst displayObject:displayObject. |
|
773 |
inst theObject:aSpec. |
|
2495 | 774 |
^ inst. |
1501
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
775 |
|
f760ccab7a35
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
776 |
"Modified: / 10.10.2001 / 14:03:00 / cg" |
181 | 777 |
! ! |
778 |
||
779 |
!UIGalleryView class methodsFor:'documentation'! |
|
780 |
||
781 |
version |
|
782 |
^ '$Header$' |
|
783 |
! ! |
|
3081 | 784 |