author | Claus Gittinger <cg@exept.de> |
Fri, 04 Jul 1997 23:39:10 +0200 | |
changeset 210 | e49d831bb81f |
parent 202 | 0552c63ee68b |
child 211 | 45f193f4e870 |
permissions | -rw-r--r-- |
60 | 1 |
" |
156 | 2 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
3 |
All Rights Reserved |
|
60 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
UIObjectView subclass:#UIPainterView |
|
111 | 14 |
instanceVariableNames:'listHolder superclassName className methodName categoryName' |
60 | 15 |
classVariableNames:'HandCursor' |
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-UIPainter' |
|
18 |
! |
|
19 |
||
20 |
!UIPainterView class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
156 | 24 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
25 |
All Rights Reserved |
|
60 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
128 | 38 |
buildIn view used by the UIPainter; from this view, the layout of the |
39 |
new application derives from. |
|
40 |
||
41 |
[see also:] |
|
42 |
UIBuilder |
|
43 |
UIObjectView |
|
156 | 44 |
|
45 |
[author:] |
|
46 |
Claus Gittinger |
|
47 |
Claus Atzkern |
|
60 | 48 |
" |
49 |
! ! |
|
50 |
||
51 |
!UIPainterView class methodsFor:'defaults'! |
|
52 |
||
53 |
defaultMenuMessage |
|
54 |
"This message is the default yo be sent to the menuHolder to get a menu |
|
55 |
" |
|
121 | 56 |
^ #showMiddleButtonMenu |
60 | 57 |
|
58 |
||
59 |
! ! |
|
60 |
||
111 | 61 |
!UIPainterView class methodsFor:'menu specs'! |
62 |
||
63 |
menu |
|
64 |
||
65 |
^ #(#Menu #( |
|
66 |
#(#MenuItem |
|
67 |
#'label:' 'copy' |
|
115 | 68 |
#'value:' #copySelection |
111 | 69 |
#'shortcutKeyCharacter:' #Copy |
70 |
) |
|
71 |
#(#MenuItem |
|
72 |
#'label:' 'cut' |
|
115 | 73 |
#'value:' #deleteSelection |
111 | 74 |
#'shortcutKeyCharacter:' #Cut |
75 |
) |
|
76 |
#(#MenuItem |
|
115 | 77 |
#'label:' 'paste' |
111 | 78 |
#'nameKey:' #paste |
115 | 79 |
#'value:' #paste |
111 | 80 |
#'submenu:' |
81 |
#(#Menu #( |
|
82 |
#(#MenuItem |
|
83 |
#'label:' 'paste' |
|
115 | 84 |
#'value:' #pasteBuffer |
111 | 85 |
#'shortcutKeyCharacter:' #Paste |
194 | 86 |
#'activeHelpKey:' #pasteBuffer |
111 | 87 |
) |
88 |
#(#MenuItem |
|
89 |
#'label:' 'keep layout' |
|
115 | 90 |
#'value:' #pasteWithLayout |
194 | 91 |
#'activeHelpKey:' #pasteWithLayout |
111 | 92 |
) |
93 |
) |
|
94 |
nil |
|
95 |
nil |
|
96 |
) |
|
97 |
) |
|
98 |
#(#MenuItem |
|
115 | 99 |
#'label:' 'undo' |
100 |
#'nameKey:' #undo |
|
101 |
#'value:' #undoLast) |
|
111 | 102 |
#(#MenuItem |
103 |
#'label:' 'arrange' |
|
115 | 104 |
#'value:' #arrange |
111 | 105 |
#'submenu:' |
106 |
#(#Menu #( |
|
107 |
#(#MenuItem |
|
108 |
#'label:' 'to front' |
|
115 | 109 |
#'value:' #raiseSelection |
111 | 110 |
) |
111 |
#(#MenuItem |
|
112 |
#'label:' 'to back' |
|
115 | 113 |
#'value:' #lowerSelection |
111 | 114 |
) |
115 |
) |
|
116 |
nil |
|
117 |
nil |
|
118 |
) |
|
119 |
) |
|
120 |
#(#MenuItem |
|
121 |
#'label:' 'dimension' |
|
115 | 122 |
#'value:' #dimension |
111 | 123 |
#'submenu:' |
124 |
#(#Menu #( |
|
125 |
#(#MenuItem |
|
126 |
#'label:' 'default extent' |
|
115 | 127 |
#'value:' #setToDefaultExtent |
194 | 128 |
#'activeHelpKey:' #setToDefaultExtent |
111 | 129 |
) |
130 |
#(#MenuItem |
|
131 |
#'label:' 'default width' |
|
115 | 132 |
#'value:' #setToDefaultWidth |
194 | 133 |
#'activeHelpKey:' #setToDefaultWidth |
111 | 134 |
) |
135 |
#(#MenuItem |
|
136 |
#'label:' 'default height' |
|
115 | 137 |
#'value:' #setToDefaultHeight |
194 | 138 |
#'activeHelpKey:' #setToDefaultHeight |
111 | 139 |
) |
140 |
#(#MenuItem |
|
141 |
#'label:' 'copy extent' |
|
115 | 142 |
#'value:' #copyExtent |
194 | 143 |
#'activeHelpKey:' #copyExtent |
111 | 144 |
) |
145 |
#(#MenuItem |
|
146 |
#'label:' 'paste extent' |
|
115 | 147 |
#'value:' #pasteExtent |
194 | 148 |
#'activeHelpKey:' #pasteExtent |
111 | 149 |
) |
150 |
#(#MenuItem |
|
151 |
#'label:' 'paste width' |
|
115 | 152 |
#'value:' #pasteWidth |
194 | 153 |
#'activeHelpKey:' #pasteWidth |
111 | 154 |
) |
155 |
#(#MenuItem |
|
156 |
#'label:' 'paste height' |
|
115 | 157 |
#'value:' #pasteHeight |
194 | 158 |
#'activeHelpKey:' #pasteHeight |
111 | 159 |
) |
160 |
#(#MenuItem |
|
161 |
#'label:' 'copy layout' |
|
115 | 162 |
#'value:' #copyLayout |
194 | 163 |
#'activeHelpKey:' #copyLayout |
111 | 164 |
) |
165 |
#(#MenuItem |
|
166 |
#'label:' 'paste layout' |
|
115 | 167 |
#'value:' #pasteLayout |
194 | 168 |
#'activeHelpKey:' #pasteLayout |
111 | 169 |
) |
170 |
) |
|
171 |
#(3 1 3) |
|
172 |
nil |
|
173 |
) |
|
174 |
) |
|
175 |
#(#MenuItem |
|
176 |
#'label:' 'align' |
|
115 | 177 |
#'value:' #align |
111 | 178 |
#'submenu:' |
179 |
#(#Menu #( |
|
180 |
#(#MenuItem |
|
115 | 181 |
#'value:' #alignSelectionLeft |
119 | 182 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignL 'align left' ) |
192 | 183 |
#'activeHelpKey:' #alignSelectionLeft |
111 | 184 |
) |
185 |
#(#MenuItem |
|
115 | 186 |
#'value:' #alignSelectionRight |
119 | 187 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignR 'align right' ) |
192 | 188 |
#'activeHelpKey:' #alignSelectionRight |
111 | 189 |
) |
190 |
#(#MenuItem |
|
115 | 191 |
#'value:' #alignSelectionLeftAndRight |
119 | 192 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignLR 'align left & right' ) |
192 | 193 |
#'activeHelpKey:' #alignSelectionLeftAndRight |
111 | 194 |
) |
195 |
#(#MenuItem |
|
115 | 196 |
#'value:' #alignSelectionTop |
119 | 197 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignT 'align top' ) |
192 | 198 |
#'activeHelpKey:' #alignSelectionTop |
119 | 199 |
) |
200 |
#(#MenuItem |
|
201 |
#'value:' #alignSelectionBottom |
|
202 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignB 'align bottom' ) |
|
192 | 203 |
#'activeHelpKey:' #alignSelectionBottom |
111 | 204 |
) |
205 |
#(#MenuItem |
|
119 | 206 |
#'value:' #alignSelectionTopAndBottom |
207 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignTB 'align top & bottom' ) |
|
192 | 208 |
#'activeHelpKey:' #alignSelectionTopAndBottom |
111 | 209 |
) |
210 |
#(#MenuItem |
|
115 | 211 |
#'value:' #alignSelectionCenterHor |
119 | 212 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignCenterH 'align centered horizontal' ) |
192 | 213 |
#'activeHelpKey:' #alignSelectionCenterHor |
111 | 214 |
) |
215 |
#(#MenuItem |
|
115 | 216 |
#'value:' #alignSelectionCenterVer |
119 | 217 |
#'labelImage:' #( ResourceRetriever UIPainter iconAlignCenterV 'align centered vertical' ) |
192 | 218 |
#'activeHelpKey:' #alignSelectionCenterVer |
111 | 219 |
) |
220 |
#(#MenuItem |
|
221 |
#'label:' 'spread horizontal' |
|
115 | 222 |
#'value:' #spreadSelectionHor |
194 | 223 |
#'activeHelpKey:' #spreadSelectionHor |
111 | 224 |
) |
225 |
#(#MenuItem |
|
226 |
#'label:' 'spread vertical' |
|
115 | 227 |
#'value:' #spreadSelectionVer |
194 | 228 |
#'activeHelpKey:' #spreadSelectionVer |
111 | 229 |
) |
230 |
#(#MenuItem |
|
231 |
#'label:' 'center horizontal in frame' |
|
115 | 232 |
#'value:' #centerSelectionHor |
194 | 233 |
#'activeHelpKey:' #centerSelectionHor |
111 | 234 |
) |
235 |
#(#MenuItem |
|
236 |
#'label:' 'center vertical in frame' |
|
115 | 237 |
#'value:' #centerSelectionVer |
194 | 238 |
#'activeHelpKey:' #centerSelectionVer |
111 | 239 |
) |
240 |
) |
|
119 | 241 |
#(8 2) |
111 | 242 |
nil |
243 |
) |
|
244 |
) |
|
245 |
) |
|
246 |
#(4) |
|
247 |
nil |
|
248 |
) |
|
249 |
! ! |
|
250 |
||
60 | 251 |
!UIPainterView methodsFor:'accessing'! |
252 |
||
253 |
application |
|
254 |
^ nil |
|
255 |
||
256 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
257 |
! |
|
258 |
||
78 | 259 |
applicationName |
260 |
^ self className |
|
261 |
! |
|
262 |
||
263 |
applicationName:aName |
|
264 |
self className:aName |
|
265 |
! |
|
266 |
||
60 | 267 |
className |
268 |
^ className |
|
269 |
! |
|
270 |
||
78 | 271 |
className:aName |
272 |
className := aName |
|
60 | 273 |
! |
274 |
||
275 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
78 | 276 |
className := aClassName. |
60 | 277 |
superclassName := aSuperclassName. |
78 | 278 |
methodName := aSelector. |
60 | 279 |
|
280 |
! |
|
281 |
||
111 | 282 |
listHolder |
283 |
^ listHolder |
|
284 |
! |
|
285 |
||
60 | 286 |
methodName |
287 |
^ methodName |
|
288 |
! |
|
289 |
||
78 | 290 |
methodName:aName |
291 |
methodName := aName |
|
60 | 292 |
! |
293 |
||
294 |
selectNames:aStringOrCollection |
|
295 |
|prop coll s| |
|
296 |
||
297 |
(aStringOrCollection isNil or:[aStringOrCollection isEmpty]) ifTrue:[ |
|
131 | 298 |
^ self select:nil |
60 | 299 |
]. |
300 |
||
301 |
(s := aStringOrCollection) isString ifFalse:[ |
|
302 |
s size == 1 ifTrue:[ |
|
303 |
s := s first |
|
304 |
] ifFalse:[ |
|
305 |
coll := OrderedCollection new. |
|
306 |
||
307 |
s do:[:aName| |
|
308 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
309 |
coll add:(prop view) |
|
310 |
] |
|
311 |
]. |
|
312 |
coll size == 1 ifTrue:[ ^ self select:(coll at:1) ]. |
|
131 | 313 |
coll size == 0 ifTrue:[ ^ self select:nil ]. |
60 | 314 |
|
315 |
^ self select:coll. |
|
316 |
] |
|
317 |
]. |
|
318 |
||
319 |
prop := self propertyOfName:s. |
|
131 | 320 |
prop isNil ifTrue:[^ self select:nil] |
60 | 321 |
ifFalse:[^ self select:(prop view)] |
322 |
||
323 |
! ! |
|
324 |
||
111 | 325 |
!UIPainterView methodsFor:'change & update'! |
326 |
||
327 |
changed:aParameter |
|
328 |
aParameter == #layout ifTrue:[ |
|
329 |
listHolder removeDependent:self. |
|
330 |
listHolder changed:aParameter. |
|
331 |
listHolder addDependent:self. |
|
332 |
] ifFalse:[ |
|
333 |
super changed:aParameter |
|
334 |
] |
|
335 |
! |
|
336 |
||
337 |
selectionChanged |
|
338 |
"selection has changed |
|
339 |
" |
|
340 |
|newSel| |
|
341 |
||
128 | 342 |
self selectionDo:[:aView||p| |
343 |
(p := self propertyOfView:aView) notNil ifTrue:[ |
|
344 |
newSel isNil ifTrue:[ |
|
345 |
newSel := OrderedCollection new |
|
346 |
]. |
|
347 |
newSel add:(listHolder indexOfName:(p name)) |
|
111 | 348 |
] |
349 |
]. |
|
350 |
listHolder removeDependent:self. |
|
351 |
listHolder selectionIndex:newSel. |
|
352 |
listHolder addDependent:self. |
|
353 |
! |
|
354 |
||
355 |
update:what with:aParm from:aSender |
|
356 |
|loIdx newSel| |
|
357 |
||
358 |
(what == #selectionIndex and:[aSender == listHolder]) ifFalse:[ |
|
359 |
^ self |
|
360 |
]. |
|
361 |
loIdx := listHolder selectionIndex. |
|
362 |
||
363 |
loIdx size ~~ 0 ifTrue:[ |
|
364 |
newSel := loIdx collect:[:i|(listHolder propertyAt:i) view] |
|
365 |
]. |
|
128 | 366 |
self updateSelectionFrom:newSel. |
367 |
! |
|
368 |
||
369 |
updateSelectionFrom:aSel |
|
370 |
"update selection from a new selection |
|
371 |
" |
|
372 |
|csel| |
|
373 |
||
374 |
selectionHiddenLevel == 0 ifTrue:[ |
|
375 |
aSel isCollection ifTrue:[ |
|
376 |
self selectionDo:[:el| |
|
377 |
(aSel includes:el) ifFalse:[self showUnselected:el] |
|
378 |
] |
|
379 |
] ifFalse:[ |
|
380 |
self selectionDo:[:el| |
|
381 |
aSel == el ifFalse:[self showUnselected:el] |
|
382 |
] |
|
383 |
] |
|
111 | 384 |
]. |
128 | 385 |
self setSelection:aSel withRedraw:false. |
386 |
self showSelection |
|
111 | 387 |
! ! |
388 |
||
60 | 389 |
!UIPainterView methodsFor:'copy & cut & paste'! |
390 |
||
391 |
copySelection |
|
392 |
"copy the selection into the cut&paste-buffer |
|
393 |
" |
|
71 | 394 |
|specs coll| |
395 |
||
128 | 396 |
coll := self minSetOfSuperViews:(self selection). |
60 | 397 |
|
71 | 398 |
coll notNil ifTrue:[ |
131 | 399 |
self select:nil. |
78 | 400 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
60 | 401 |
self setSelection:specs |
402 |
]. |
|
78 | 403 |
|
404 |
||
60 | 405 |
! |
406 |
||
407 |
deleteSelection |
|
62 | 408 |
"delete the selection; copy the selection into the cut&paste-buffer |
409 |
and open a transaction |
|
60 | 410 |
" |
134 | 411 |
|specs coll| |
71 | 412 |
|
128 | 413 |
coll := self minSetOfSuperViews:(self selection). |
60 | 414 |
|
78 | 415 |
coll notNil ifTrue:[ |
111 | 416 |
listHolder disableNotificationsWhileEvaluating:[ |
131 | 417 |
self select:nil. |
111 | 418 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
60 | 419 |
|
134 | 420 |
self withinTransaction:#cut objects:coll do:[ |
421 |
coll reverseDo:[:aView| |
|
422 |
self createUndoRemove:aView. |
|
423 |
self remove:aView |
|
111 | 424 |
] |
425 |
]. |
|
426 |
self setSelection:specs. |
|
427 |
] |
|
60 | 428 |
] |
429 |
! |
|
430 |
||
431 |
pasteBuffer |
|
62 | 432 |
"add the objects in the paste-buffer to the object view |
60 | 433 |
" |
89 | 434 |
self pasteSpecifications:(self getSelection) keepLayout:false |
435 |
||
436 |
! |
|
437 |
||
438 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
|
439 |
"add the specs to the object view |
|
440 |
" |
|
111 | 441 |
|paste frame pasteOrigin pasteOffset builder newSel| |
60 | 442 |
|
89 | 443 |
(self canPaste:aSpecificationOrList) ifFalse:[ |
444 |
^ self |
|
445 |
]. |
|
165 | 446 |
listHolder disableNotificationsWhileEvaluating:[ |
447 |
aSpecificationOrList isCollection ifTrue:[ |
|
448 |
paste := aSpecificationOrList |
|
449 |
] ifFalse:[ |
|
450 |
paste := Array with:aSpecificationOrList |
|
451 |
]. |
|
452 |
frame := self singleSelection. |
|
60 | 453 |
|
165 | 454 |
(self canPasteInto:frame) ifFalse:[ |
455 |
frame := self |
|
456 |
]. |
|
457 |
self setSelection:nil withRedraw:true. |
|
60 | 458 |
|
165 | 459 |
newSel := OrderedCollection new. |
460 |
builder := UIBuilder new. |
|
89 | 461 |
|
165 | 462 |
keepLayout ifFalse:[ |
463 |
pasteOffset := 0@0. |
|
464 |
pasteOrigin := self sensor mousePoint. |
|
465 |
pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id. |
|
466 |
]. |
|
60 | 467 |
|
165 | 468 |
listHolder disableNotificationsWhileEvaluating:[ |
469 |
paste do:[:aSpec| |
|
470 |
|view| |
|
60 | 471 |
|
165 | 472 |
view := self addSpec:aSpec builder:builder in:frame. |
60 | 473 |
|
165 | 474 |
keepLayout ifFalse:[ |
475 |
(frame bounds containsPoint:pasteOrigin) ifFalse:[ |
|
476 |
self moveObject:view to:pasteOffset. |
|
477 |
] ifTrue:[ |
|
478 |
self moveObject:view to:pasteOrigin + pasteOffset. |
|
479 |
]. |
|
480 |
pasteOffset := pasteOffset + 4 |
|
111 | 481 |
]. |
165 | 482 |
view realize. |
483 |
newSel add:view. |
|
89 | 484 |
]. |
60 | 485 |
]. |
486 |
||
165 | 487 |
self withinTransaction:#paste objects:newSel do:[ |
488 |
undoHistory addUndoSelector:#undoCreate: |
|
489 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]) |
|
490 |
]. |
|
134 | 491 |
|
165 | 492 |
newSel size == 1 ifTrue:[ |
493 |
newSel := newSel at:1 |
|
494 |
]. |
|
495 |
self realizeAllSubViews. |
|
496 |
inputView raise. |
|
497 |
self select:newSel. |
|
498 |
self elementChangedSize:frame. |
|
499 |
] |
|
89 | 500 |
! |
501 |
||
502 |
pasteWithLayout |
|
503 |
"add the objects in the paste-buffer to the object view; don't change the |
|
504 |
layout |
|
505 |
" |
|
506 |
self pasteSpecifications:(self getSelection) keepLayout:true |
|
507 |
||
60 | 508 |
! ! |
509 |
||
510 |
!UIPainterView methodsFor:'drag & drop'! |
|
511 |
||
512 |
canDrop:anObjectOrCollection |
|
89 | 513 |
|spec| |
60 | 514 |
|
119 | 515 |
self enabled ifTrue:[ |
89 | 516 |
anObjectOrCollection size == 1 ifTrue:[ |
517 |
spec := (anObjectOrCollection at:1) theObject. |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
518 |
^ (spec isKindOf:UISpecification) |
89 | 519 |
] |
520 |
]. |
|
521 |
^ false |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
522 |
|
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
523 |
"Modified: 8.4.1997 / 01:01:50 / cg" |
60 | 524 |
! |
525 |
||
526 |
drop:anObjectOrCollection at:aPoint |
|
89 | 527 |
|spec| |
528 |
||
529 |
spec := (anObjectOrCollection at:1) theObject. |
|
530 |
self pasteSpecifications:spec keepLayout:false. |
|
60 | 531 |
|
532 |
||
533 |
! ! |
|
534 |
||
78 | 535 |
!UIPainterView methodsFor:'generating output'! |
536 |
||
60 | 537 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
149 | 538 |
|args showIt| |
141 | 539 |
|
149 | 540 |
(aspect asSymbol numArgs) == 1 ifFalse:[ |
541 |
args := '\'. |
|
542 |
showIt := ' ...''.\'. |
|
543 |
] ifTrue:[ |
|
544 |
args := 'anArgument\'. |
|
545 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
546 |
]. |
|
141 | 547 |
|
60 | 548 |
^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
141 | 549 |
aspect , args , |
60 | 550 |
' "automatically generated by UIPainter ..."\' , |
551 |
'\' , |
|
552 |
' "action to be added ..."\' , |
|
149 | 553 |
' Transcript showCR:self class name , '': action for ' , aspect , showIt , |
60 | 554 |
'!! !!\\') withCRs |
555 |
! |
|
556 |
||
557 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
134 | 558 |
|modelClass| |
559 |
||
149 | 560 |
modelClass := protoSpec defaultModelClassFor:aspect. |
134 | 561 |
|
60 | 562 |
^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
563 |
aspect , '\' , |
|
564 |
' "automatically generated by UIPainter ..."\' , |
|
565 |
'\' , |
|
566 |
' |holder|\' , |
|
567 |
'\' , |
|
568 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
134 | 569 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelClass name , ' new' , ').\' , |
60 | 570 |
' ].\' , |
571 |
' ^ holder\' , |
|
572 |
'!! !!\\') withCRs |
|
573 |
! |
|
574 |
||
575 |
generateAspectMethods |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
576 |
|cls code skip| |
60 | 577 |
|
78 | 578 |
code := ''. |
579 |
||
60 | 580 |
className isNil ifTrue:[ |
69 | 581 |
self warn:'set the class first'. |
78 | 582 |
^ code |
60 | 583 |
]. |
89 | 584 |
cls := Smalltalk classNamed:className. |
60 | 585 |
|
111 | 586 |
listHolder propertiesDo:[:aProp | |
62 | 587 |
|modelSelector menuSelector protoSpec thisCode| |
60 | 588 |
|
134 | 589 |
protoSpec := aProp spec. |
175 | 590 |
|
78 | 591 |
(modelSelector := aProp model) notNil ifTrue:[ |
60 | 592 |
(cls implements:modelSelector asSymbol) ifFalse:[ |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
593 |
skip := false. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
594 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
595 |
skip := SimpleDialog implements:modelSelector asSymbol |
60 | 596 |
]. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
597 |
skip ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
598 |
"/ kludge .. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
599 |
(protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
600 |
thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
601 |
] ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
602 |
thisCode := (self generateAspectMethodFor:modelSelector spec:protoSpec inClass:cls). |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
603 |
]. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
604 |
code := code , thisCode |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
605 |
]. |
62 | 606 |
]. |
607 |
]. |
|
608 |
||
78 | 609 |
(menuSelector := aProp menu) notNil ifTrue:[ |
62 | 610 |
(cls implements:menuSelector asSymbol) ifFalse:[ |
611 |
thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). |
|
612 |
code := code , thisCode |
|
60 | 613 |
] |
111 | 614 |
]. |
615 |
||
616 |
aProp spec aspectSelectors do:[:aSel| |
|
617 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
618 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
619 |
code := code , thisCode |
|
620 |
] |
|
621 |
]. |
|
137 | 622 |
aProp spec actionSelectors do:[:aSel| |
623 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
624 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
625 |
code := code , thisCode |
|
626 |
] |
|
627 |
]. |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
628 |
aProp spec valueSelectors do:[:aSel| |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
629 |
(cls implements:aSel asSymbol) ifFalse:[ |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
630 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
631 |
code := code , thisCode |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
632 |
] |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
633 |
]. |
111 | 634 |
|
60 | 635 |
]. |
636 |
^ code |
|
637 |
! |
|
638 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
639 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
640 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
641 |
aspect , '\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
642 |
' "automatically generated by UIPainter ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
643 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
644 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
645 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
646 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
647 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
648 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
649 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
650 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
651 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
652 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
653 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
654 |
|
78 | 655 |
generateWindowSpecMethodSource |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
656 |
|t s spec specArray str code category cls mthd| |
60 | 657 |
|
78 | 658 |
specArray := OrderedCollection new. |
60 | 659 |
|
78 | 660 |
self subViews do:[:aView| |
661 |
aView ~~ inputView ifTrue:[ |
|
662 |
specArray add:(self fullSpecFor:aView) |
|
60 | 663 |
] |
664 |
]. |
|
78 | 665 |
spec := FullSpec new. |
666 |
spec fromBuilder:self components:(SpecCollection new collection:specArray). |
|
60 | 667 |
specArray := spec literalArrayEncoding. |
668 |
||
669 |
str := WriteStream on:String new. |
|
86 | 670 |
UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
60 | 671 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
672 |
"/ if that method already exists, do not overwrite the category |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
673 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
674 |
category := 'interface specs'. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
675 |
(cls := Smalltalk classNamed:className) notNil ifTrue:[ |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
676 |
(mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[ |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
677 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
678 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
679 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
680 |
|
60 | 681 |
code := Character excla asString |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
682 |
, className , ' class methodsFor:' , category storeString |
60 | 683 |
, Character excla asString , '\\' |
684 |
||
685 |
, methodName , '\' |
|
686 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
687 |
, ' "do not manually edit this - the painter/builder may not be able to\' |
|
688 |
, ' handle the specification if its corrupted."\\' |
|
689 |
, ' "\' |
|
690 |
, ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
691 |
, ' ' , className , ' new openInterface:#' , methodName , '\' |
|
692 |
, ' "\'. |
|
693 |
||
694 |
methodName = 'windowSpec' ifTrue:[ |
|
695 |
code := code , ' "' , className , ' open"\' |
|
696 |
]. |
|
697 |
code := code |
|
698 |
, '\' |
|
699 |
, ' <resource: #canvas>\\' |
|
700 |
, ' ^\' |
|
701 |
, ' ', str contents |
|
702 |
, '\' |
|
703 |
, Character excla asString |
|
704 |
, ' ' |
|
705 |
, Character excla asString |
|
706 |
, '\\'. |
|
707 |
||
708 |
^ code withCRs |
|
709 |
||
710 |
"Modified: 5.9.1995 / 21:01:35 / claus" |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
711 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 712 |
! ! |
713 |
||
714 |
!UIPainterView methodsFor:'initialization'! |
|
715 |
||
137 | 716 |
destroy |
717 |
"remove dependencies |
|
718 |
" |
|
719 |
listHolder notNil ifTrue:[ |
|
720 |
listHolder removeDependent:self. |
|
721 |
]. |
|
722 |
super destroy. |
|
723 |
! |
|
724 |
||
60 | 725 |
initialize |
62 | 726 |
"setup attributes |
727 |
" |
|
60 | 728 |
super initialize. |
729 |
||
730 |
superclassName := 'ApplicationModel'. |
|
731 |
className := 'NewApplication'. |
|
732 |
methodName := 'windowSpec'. |
|
733 |
categoryName := 'Applications'. |
|
111 | 734 |
listHolder := ListHolder for:self. |
60 | 735 |
HandCursor := Cursor leftHand. |
736 |
||
737 |
! |
|
738 |
||
739 |
setupFromSpec:specOrSpecArray |
|
78 | 740 |
|spec builder| |
60 | 741 |
|
111 | 742 |
listHolder disableNotificationsWhileEvaluating:[ |
743 |
self removeAll. |
|
744 |
spec := UISpecification from:specOrSpecArray. |
|
745 |
builder := UIBuilder new. |
|
746 |
spec window setupView:self topView for:builder. |
|
747 |
self addSpec:(spec component) builder:builder in:self. |
|
748 |
self realizeAllSubViews. |
|
749 |
inputView raise. |
|
750 |
] |
|
60 | 751 |
! ! |
752 |
||
753 |
!UIPainterView methodsFor:'menus'! |
|
754 |
||
121 | 755 |
showMiddleButtonMenu |
756 |
"show the middle button menu; this returns nil |
|
62 | 757 |
" |
111 | 758 |
|menu canPaste| |
60 | 759 |
|
121 | 760 |
self enabled ifFalse:[ |
761 |
^ nil |
|
762 |
]. |
|
111 | 763 |
menu := MenuPanel fromSpec:(self class menu) receiver:self. |
60 | 764 |
|
765 |
canPaste := self canPaste:(self getSelection). |
|
766 |
||
128 | 767 |
self hasSelection ifTrue:[ |
768 |
canPaste := (canPaste and:[self canPasteInto:(self selection)]) |
|
769 |
] ifFalse:[ |
|
111 | 770 |
menu disableAll |
771 |
]. |
|
128 | 772 |
menu enabledAt:#paste put:canPaste. |
134 | 773 |
menu enabledAt:#undo put:(undoHistory isEmpty not). |
121 | 774 |
menu startUp. |
775 |
^ nil |
|
60 | 776 |
|
62 | 777 |
|
778 |
||
60 | 779 |
! ! |
780 |
||
781 |
!UIPainterView methodsFor:'removing components'! |
|
782 |
||
78 | 783 |
remove:anObject |
784 |
"remove anObject from the contents do redraw |
|
60 | 785 |
" |
134 | 786 |
anObject notNil ifTrue:[ |
787 |
listHolder remove:anObject |
|
788 |
] |
|
60 | 789 |
! |
790 |
||
791 |
removeAll |
|
62 | 792 |
"remove all objects and properties |
793 |
" |
|
111 | 794 |
listHolder disableNotificationsWhileEvaluating:[ |
131 | 795 |
self select:nil. |
134 | 796 |
listHolder removeAll. |
797 |
self removeUndoHistory. |
|
111 | 798 |
] |
60 | 799 |
! ! |
800 |
||
801 |
!UIPainterView methodsFor:'searching'! |
|
802 |
||
89 | 803 |
findContainerViewAt:aPoint |
804 |
"find container view responds to aPoint. |
|
805 |
" |
|
806 |
|view| |
|
807 |
||
808 |
(view := self findObjectAt:aPoint) isNil ifTrue:[ |
|
809 |
^ self |
|
810 |
]. |
|
811 |
||
812 |
[(view specClass supportsSubComponents or:[(view := view superView) == self]) |
|
813 |
] whileFalse:[ |
|
814 |
[(self propertyOfView:view) isNil] whileTrue:[ |
|
815 |
(view := view superView) == self ifTrue:[^ self] |
|
816 |
]. |
|
817 |
]. |
|
818 |
^ view |
|
819 |
! |
|
820 |
||
60 | 821 |
findObjectAt:aPoint |
822 |
"find the origin/corner of the currentWidget |
|
823 |
" |
|
824 |
|view| |
|
825 |
||
826 |
view := super findObjectAt:aPoint. |
|
827 |
||
828 |
view notNil ifTrue:[ |
|
829 |
"can be a view within a view not visible |
|
830 |
" |
|
831 |
[ (self propertyOfView:view) isNil ] whileTrue:[ |
|
832 |
(view := view superView) == self ifTrue:[^ nil] |
|
833 |
] |
|
834 |
]. |
|
835 |
^ view |
|
836 |
! |
|
837 |
||
838 |
findViewWithId:aViewId |
|
62 | 839 |
"finds view assigned to identifier and returns the view or nil |
60 | 840 |
" |
841 |
|prop| |
|
842 |
||
843 |
prop := self propertyOfIdentifier:aViewId. |
|
844 |
||
845 |
prop notNil ifTrue:[^ prop view] |
|
846 |
ifFalse:[^ nil] |
|
78 | 847 |
! |
848 |
||
849 |
propertyOfIdentifier:anId |
|
850 |
"returns property assigned to unique identifier |
|
851 |
" |
|
852 |
anId notNil ifTrue:[ |
|
111 | 853 |
^ listHolder detectProperty:[:p| p identifier == anId ] |
78 | 854 |
]. |
855 |
^ nil |
|
856 |
! |
|
857 |
||
858 |
propertyOfName:aString |
|
859 |
"returns property assigned to name |
|
860 |
" |
|
111 | 861 |
|name| |
862 |
||
863 |
aString isNil ifFalse:[ |
|
864 |
name := aString string withoutSeparators. |
|
865 |
||
866 |
name = 'self' ifFalse:[ |
|
867 |
^ listHolder detectProperty:[:p| p name = name ]. |
|
868 |
] |
|
78 | 869 |
]. |
870 |
^ nil |
|
871 |
! |
|
872 |
||
873 |
propertyOfView:aView |
|
874 |
"returns property assigned to view |
|
875 |
" |
|
876 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
111 | 877 |
^ listHolder detectProperty:[:p| p view == aView ] |
78 | 878 |
]. |
879 |
^ nil |
|
880 |
! |
|
881 |
||
111 | 882 |
uniqueNameFor:aSpecOrString |
78 | 883 |
"generate and return an unique name for a class |
884 |
" |
|
885 |
|next name size| |
|
886 |
||
111 | 887 |
aSpecOrString isString ifFalse:[name := aSpecOrString className asString] |
888 |
ifTrue:[name := aSpecOrString]. |
|
78 | 889 |
|
111 | 890 |
(name endsWith:'Spec') ifTrue:[ |
891 |
name := name copyFrom:1 to:(name size - 4). |
|
892 |
] ifFalse:[ |
|
893 |
name := name copy |
|
894 |
]. |
|
78 | 895 |
name at:1 put:(name at:1) asLowercase. |
111 | 896 |
size := name size + 1. |
897 |
next := 0. |
|
78 | 898 |
|
111 | 899 |
listHolder propertiesDo:[:p| |
900 |
|n| |
|
78 | 901 |
n := p name. |
902 |
||
903 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
904 |
next := next max:(p extractNumberStartingAt:size) |
|
905 |
] |
|
906 |
]. |
|
907 |
next := next + 1. |
|
908 |
name := name, next printString. |
|
909 |
^ name |
|
910 |
||
911 |
||
912 |
||
913 |
! |
|
914 |
||
915 |
uniqueNameOf:aView |
|
111 | 916 |
|prop| |
78 | 917 |
|
111 | 918 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
919 |
prop name isNil ifTrue:[ |
|
920 |
prop name:(self uniqueNameFor:(prop spec)). |
|
921 |
]. |
|
922 |
^ prop name |
|
78 | 923 |
]. |
111 | 924 |
^ 'self' |
78 | 925 |
|
60 | 926 |
! ! |
927 |
||
78 | 928 |
!UIPainterView methodsFor:'specification'! |
929 |
||
930 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
931 |
"build view and subviews from aSpecification into a frame. The top view |
|
932 |
is returned. The contained components of a spec are set to nil |
|
933 |
" |
|
934 |
aBuilder applicationClass:(Smalltalk classNamed:className). |
|
935 |
||
111 | 936 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 937 |
p := ViewProperty new. |
938 |
s := aSpec copy. |
|
939 |
p spec:s. |
|
940 |
p view:aView. |
|
941 |
||
942 |
s class supportsSubComponents ifTrue:[ |
|
943 |
s component:nil |
|
944 |
]. |
|
945 |
||
111 | 946 |
n := s name. |
947 |
||
948 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
949 |
s name:(self uniqueNameFor:s) |
|
78 | 950 |
]. |
111 | 951 |
listHolder add:p |
78 | 952 |
]. |
953 |
||
954 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 955 |
|
78 | 956 |
! |
957 |
||
958 |
fullSpecFor:anObject |
|
959 |
"generate a full spec for an object |
|
62 | 960 |
" |
78 | 961 |
|mySpec subSpecs| |
962 |
||
963 |
mySpec := self specFor:anObject. |
|
964 |
||
965 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
966 |
(anObject subViews notNil) ifTrue:[ |
|
967 |
anObject subViews do:[:aSubView||spec| |
|
968 |
spec := self fullSpecFor:aSubView. |
|
969 |
spec notNil ifTrue:[ |
|
970 |
subSpecs isNil ifTrue:[ |
|
971 |
subSpecs := OrderedCollection new |
|
972 |
]. |
|
973 |
subSpecs add:spec. |
|
974 |
]. |
|
975 |
]. |
|
976 |
subSpecs notNil ifTrue:[ |
|
977 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
978 |
] |
|
979 |
] |
|
980 |
]. |
|
981 |
^ mySpec |
|
982 |
||
60 | 983 |
|
984 |
||
985 |
||
986 |
||
987 |
||
988 |
! |
|
989 |
||
78 | 990 |
specFor:anObject |
991 |
"returns spec assigned to an object |
|
62 | 992 |
" |
78 | 993 |
|prop spec| |
60 | 994 |
|
78 | 995 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
996 |
spec := prop spec copy. |
|
997 |
spec layoutFromView:anObject |
|
60 | 998 |
]. |
78 | 999 |
^ spec |
1000 |
||
1001 |
||
1002 |
||
60 | 1003 |
! |
1004 |
||
146 | 1005 |
specForSelection |
1006 |
"returns spec assigned to current single selection or nil |
|
1007 |
" |
|
1008 |
^ self specFor:(self singleSelection) |
|
1009 |
||
1010 |
||
1011 |
! |
|
1012 |
||
78 | 1013 |
updateFromSpec:aSpec |
1014 |
"update current selected view from specification |
|
62 | 1015 |
" |
78 | 1016 |
|props name builder v| |
1017 |
||
1018 |
self singleSelection notNil ifTrue:[ |
|
1019 |
self withSelectionHiddenDo:[ |
|
1020 |
self transaction:#specification selectionDo:[:aView| |
|
1021 |
builder := UIBuilder new. |
|
210
e49d831bb81f
also set the applicationClass when updating a view after a spec change
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1022 |
builder applicationClass:(Smalltalk classNamed:className). |
78 | 1023 |
props := self propertyOfView:aView. |
82 | 1024 |
name := (aSpec name) withoutSeparators. |
78 | 1025 |
|
82 | 1026 |
name = props name ifFalse:[ |
1027 |
(self propertyOfName:name) notNil ifTrue:[ |
|
1028 |
name := props name |
|
78 | 1029 |
] |
1030 |
]. |
|
82 | 1031 |
aSpec name:name. |
134 | 1032 |
self createUndoSpecModify:props. |
78 | 1033 |
|
1034 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
1035 |
v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
1036 |
v realize. |
|
1037 |
aView destroy. |
|
1038 |
device sync. device flush. |
|
1039 |
aView becomeSameAs:v. |
|
1040 |
inputView raise. |
|
1041 |
] ifFalse:[ |
|
1042 |
aSpec setAttributesIn:aView with:builder. |
|
1043 |
self elementChangedSize:aView. |
|
1044 |
]. |
|
1045 |
props spec:(aSpec copy). |
|
111 | 1046 |
listHolder propertyChanged:props. |
78 | 1047 |
] |
111 | 1048 |
] |
82 | 1049 |
] |
210
e49d831bb81f
also set the applicationClass when updating a view after a spec change
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1050 |
|
e49d831bb81f
also set the applicationClass when updating a view after a spec change
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1051 |
"Modified: 4.7.1997 / 23:37:27 / cg" |
60 | 1052 |
! ! |
1053 |
||
1054 |
!UIPainterView methodsFor:'transaction'! |
|
1055 |
||
1056 |
transaction:aType objects:something do:aOneArgBlock |
|
1057 |
"opens a transaction and evaluates a block within the transaction; the |
|
1058 |
argument to the block is a view from derived from something |
|
1059 |
" |
|
134 | 1060 |
self withinTransaction:aType objects:something do:[ |
1061 |
self forEach:something do:aOneArgBlock |
|
60 | 1062 |
] |
1063 |
! |
|
1064 |
||
134 | 1065 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
1066 |
"evaluate a block with no arguments within a transaction |
|
60 | 1067 |
" |
134 | 1068 |
|text size prop| |
1069 |
||
1070 |
objects isNil ifTrue:[ ^ self ]. |
|
1071 |
||
1072 |
size := objects size. |
|
60 | 1073 |
|
134 | 1074 |
objects isCollection ifTrue:[ |
1075 |
size == 0 ifTrue:[ ^ self ]. |
|
1076 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
1077 |
] ifFalse:[ |
|
1078 |
prop := self propertyOfView:objects |
|
1079 |
]. |
|
60 | 1080 |
|
134 | 1081 |
prop notNil ifTrue:[ |
1082 |
text := prop name |
|
1083 |
] ifFalse:[ |
|
1084 |
text := size printString, ' elements' |
|
60 | 1085 |
]. |
134 | 1086 |
|
1087 |
undoHistory withinTransaction:aType text:text do:[ |
|
1088 |
aNoneArgBlock value |
|
1089 |
] |
|
60 | 1090 |
! ! |
1091 |
||
1092 |
!UIPainterView methodsFor:'undo actions'! |
|
1093 |
||
134 | 1094 |
createUndoLayout:aView |
1095 |
"create undo action before changing a views layout |
|
60 | 1096 |
" |
134 | 1097 |
|lyt args prop| |
60 | 1098 |
|
1099 |
undoHistory isTransactionOpen ifTrue:[ |
|
1100 |
prop := self propertyOfView:aView. |
|
134 | 1101 |
|
60 | 1102 |
prop notNil ifTrue:[ |
134 | 1103 |
args := Array new:3. |
1104 |
args at:1 put:(prop identifier). |
|
1105 |
||
1106 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
1107 |
args at:2 put:#geometryLayout: |
|
1108 |
] ifFalse:[ |
|
146 | 1109 |
lyt := aView extent. |
134 | 1110 |
args at:2 put:#extent: |
1111 |
]. |
|
1112 |
args at:3 put:(lyt copy). |
|
1113 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 1114 |
] |
1115 |
] |
|
1116 |
! |
|
1117 |
||
134 | 1118 |
createUndoRemove:aView |
1119 |
"create undo method before deleting views |
|
60 | 1120 |
" |
134 | 1121 |
|frame prop pId spec| |
1122 |
||
1123 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
1124 |
spec := self fullSpecFor:aView. |
|
1125 |
frame := aView superView. |
|
60 | 1126 |
|
134 | 1127 |
(self canPasteInto:frame) ifTrue:[ |
1128 |
(frame := self propertyOfView:frame) notNil ifTrue:[ |
|
1129 |
pId := frame identifier |
|
1130 |
] |
|
1131 |
]. |
|
1132 |
undoHistory addUndoSelector:#undoRemove: |
|
1133 |
withArgs:(Array with:spec with:(prop identifier) with:pId) |
|
1134 |
] |
|
1135 |
! |
|
60 | 1136 |
|
134 | 1137 |
createUndoSpecModify:aProp |
1138 |
"undo method when changing the specification for an object |
|
1139 |
" |
|
1140 |
aProp notNil ifTrue:[ |
|
1141 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1142 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1143 |
] |
|
1144 |
! |
|
60 | 1145 |
|
134 | 1146 |
undoCreate:something |
1147 |
"undo method for creating or pasting an object |
|
1148 |
" |
|
1149 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1150 |
! |
|
60 | 1151 |
|
134 | 1152 |
undoLayout:args |
1153 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1154 |
" |
|
1155 |
|view| |
|
1156 |
||
1157 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1158 |
view perform:(args at:2) with:(args at:3). |
1159 |
self changed:#layout. |
|
60 | 1160 |
] |
1161 |
! |
|
1162 |
||
134 | 1163 |
undoRemove:args |
1164 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1165 |
" |
|
1166 |
|frame prop view| |
|
1167 |
||
1168 |
(args at:3) notNil ifTrue:[ |
|
1169 |
frame := self findViewWithId:(args at:3). |
|
1170 |
]. |
|
1171 |
frame isNil ifTrue:[ |
|
1172 |
frame := self |
|
1173 |
]. |
|
1174 |
view := self addSpec:(args at:1) builder:(UIBuilder new) in:frame. |
|
1175 |
view realize. |
|
1176 |
inputView raise. |
|
1177 |
||
1178 |
prop := self propertyOfView:view. |
|
1179 |
prop identifier:(args at:2). |
|
1180 |
||
1181 |
! |
|
1182 |
||
1183 |
undoSpecModify:args |
|
1184 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1185 |
" |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1186 |
|builder view spec v props| |
60 | 1187 |
|
134 | 1188 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1189 |
|
134 | 1190 |
props notNil ifTrue:[ |
1191 |
view := props view. |
|
1192 |
spec := args at:1. |
|
1193 |
builder := UIBuilder new. |
|
210
e49d831bb81f
also set the applicationClass when updating a view after a spec change
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1194 |
builder applicationClass:(Smalltalk classNamed:className). |
134 | 1195 |
props spec:spec. |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1196 |
|
134 | 1197 |
spec needsRebuildForAttributes ifTrue:[ |
1198 |
v := spec buildViewWithLayoutFor:builder in:view superView. |
|
1199 |
v realize. |
|
1200 |
view destroy. |
|
1201 |
view become:v |
|
1202 |
] ifFalse:[ |
|
1203 |
spec setAttributesIn:view with:builder. |
|
1204 |
self elementChangedSize:view. |
|
1205 |
]. |
|
1206 |
listHolder propertyChanged:props. |
|
1207 |
] |
|
60 | 1208 |
|
210
e49d831bb81f
also set the applicationClass when updating a view after a spec change
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1209 |
"Modified: 4.7.1997 / 23:37:20 / cg" |
60 | 1210 |
! ! |
1211 |
||
194 | 1212 |
!UIPainterView methodsFor:'user actions - arrange'! |
1213 |
||
1214 |
lowerSelection |
|
1215 |
"lower all objects in the selection |
|
1216 |
" |
|
1217 |
self hasSelection ifTrue:[ |
|
1218 |
self selectionDo:[:aView| |
|
1219 |
aView lower. |
|
1220 |
aView superView changeSequenceOrderFor:aView to:1. |
|
1221 |
]. |
|
1222 |
listHolder recompute. |
|
1223 |
] |
|
1224 |
||
1225 |
||
1226 |
! |
|
1227 |
||
1228 |
raiseSelection |
|
1229 |
"raise all objects in the selection |
|
1230 |
" |
|
1231 |
self hasSelection ifTrue:[ |
|
1232 |
self selectionDo:[:aView||sv| |
|
1233 |
aView raise. |
|
1234 |
sv := aView superView. |
|
1235 |
sv changeSequenceOrderFor:aView to:(sv subViews size) |
|
1236 |
]. |
|
1237 |
inputView raise. |
|
1238 |
listHolder recompute. |
|
1239 |
]. |
|
1240 |
||
1241 |
||
1242 |
! ! |
|
1243 |
||
60 | 1244 |
!UIPainterView class methodsFor:'documentation'! |
1245 |
||
1246 |
version |
|
1247 |
^ '$Header$' |
|
1248 |
! ! |