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