author | tz |
Wed, 08 Jul 1998 22:18:47 +0200 | |
changeset 886 | 3c67610b9631 |
parent 858 | 6b2e9e31cf06 |
child 887 | 79a6e12e1d0f |
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 |
|
742 | 7 |
inclusion of the above copyright notice. This software may not |
60 | 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 |
|
278 | 14 |
instanceVariableNames:'treeView listHolder superclassName className methodName |
770 | 15 |
categoryName handleColor handleMasterColor' |
742 | 16 |
classVariableNames:'HandCursor RedefineAspectMethods' |
60 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-UIPainter' |
|
19 |
! |
|
20 |
||
211 | 21 |
Object subclass:#ViewProperty |
22 |
instanceVariableNames:'view spec identifier' |
|
23 |
classVariableNames:'Identifier' |
|
24 |
poolDictionaries:'' |
|
25 |
privateIn:UIPainterView |
|
26 |
! |
|
27 |
||
60 | 28 |
!UIPainterView class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
156 | 32 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
33 |
All Rights Reserved |
|
60 | 34 |
|
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
742 | 37 |
inclusion of the above copyright notice. This software may not |
60 | 38 |
be provided or otherwise made available to, or used by, any |
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
128 | 46 |
buildIn view used by the UIPainter; from this view, the layout of the |
47 |
new application derives from. |
|
48 |
||
49 |
[see also:] |
|
50 |
UIBuilder |
|
51 |
UIObjectView |
|
156 | 52 |
|
53 |
[author:] |
|
54 |
Claus Gittinger |
|
55 |
Claus Atzkern |
|
60 | 56 |
" |
57 |
! ! |
|
58 |
||
698 | 59 |
!UIPainterView class methodsFor:'code generation mode'! |
60 |
||
742 | 61 |
redefineAspectMethods |
698 | 62 |
"redefine methods yes or no. If a method is defined in super class |
63 |
should the message be reinstalled ? |
|
64 |
" |
|
742 | 65 |
^ RedefineAspectMethods ? false |
698 | 66 |
|
67 |
! |
|
68 |
||
742 | 69 |
redefineAspectMethods:aBoolean |
698 | 70 |
"redefine methods yes or no. If a method is defined in super class |
71 |
should the message be reinstalled ? |
|
72 |
" |
|
742 | 73 |
RedefineAspectMethods := aBoolean |
698 | 74 |
|
75 |
||
76 |
! ! |
|
77 |
||
60 | 78 |
!UIPainterView class methodsFor:'defaults'! |
79 |
||
80 |
defaultMenuMessage |
|
81 |
"This message is the default yo be sent to the menuHolder to get a menu |
|
82 |
" |
|
121 | 83 |
^ #showMiddleButtonMenu |
60 | 84 |
|
85 |
||
86 |
! ! |
|
87 |
||
88 |
!UIPainterView methodsFor:'accessing'! |
|
89 |
||
90 |
application |
|
91 |
^ nil |
|
92 |
||
93 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
94 |
! |
|
95 |
||
78 | 96 |
applicationName |
97 |
^ self className |
|
98 |
! |
|
99 |
||
100 |
applicationName:aName |
|
101 |
self className:aName |
|
102 |
! |
|
103 |
||
60 | 104 |
className |
105 |
^ className |
|
106 |
! |
|
107 |
||
78 | 108 |
className:aName |
109 |
className := aName |
|
60 | 110 |
! |
111 |
||
112 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
78 | 113 |
className := aClassName. |
60 | 114 |
superclassName := aSuperclassName. |
78 | 115 |
methodName := aSelector. |
60 | 116 |
|
117 |
! |
|
118 |
||
223 | 119 |
findInputViewIn:aSuperView |
120 |
"returns index of input view into superview or nil |
|
121 |
" |
|
122 |
aSuperView == self ifTrue:[ |
|
123 |
^ self subViews findFirst:[:v| v == inputView ] |
|
124 |
]. |
|
125 |
^ 0 |
|
126 |
! |
|
127 |
||
128 |
inputView |
|
129 |
^ inputView |
|
111 | 130 |
! |
131 |
||
60 | 132 |
methodName |
133 |
^ methodName |
|
134 |
! |
|
135 |
||
78 | 136 |
methodName:aName |
137 |
methodName := aName |
|
60 | 138 |
! |
139 |
||
140 |
selectNames:aStringOrCollection |
|
141 |
|prop coll s| |
|
142 |
||
143 |
(aStringOrCollection isNil or:[aStringOrCollection isEmpty]) ifTrue:[ |
|
131 | 144 |
^ self select:nil |
60 | 145 |
]. |
146 |
||
147 |
(s := aStringOrCollection) isString ifFalse:[ |
|
148 |
s size == 1 ifTrue:[ |
|
149 |
s := s first |
|
150 |
] ifFalse:[ |
|
151 |
coll := OrderedCollection new. |
|
152 |
||
153 |
s do:[:aName| |
|
154 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
155 |
coll add:(prop view) |
|
156 |
] |
|
157 |
]. |
|
158 |
coll size == 1 ifTrue:[ ^ self select:(coll at:1) ]. |
|
131 | 159 |
coll size == 0 ifTrue:[ ^ self select:nil ]. |
60 | 160 |
|
161 |
^ self select:coll. |
|
162 |
] |
|
163 |
]. |
|
164 |
||
165 |
prop := self propertyOfName:s. |
|
131 | 166 |
prop isNil ifTrue:[^ self select:nil] |
60 | 167 |
ifFalse:[^ self select:(prop view)] |
168 |
||
169 |
! ! |
|
170 |
||
111 | 171 |
!UIPainterView methodsFor:'change & update'! |
172 |
||
223 | 173 |
layoutChanged |
754 | 174 |
|
238 | 175 |
treeView layoutChanged |
111 | 176 |
! ! |
177 |
||
60 | 178 |
!UIPainterView methodsFor:'copy & cut & paste'! |
179 |
||
180 |
copySelection |
|
181 |
"copy the selection into the cut&paste-buffer |
|
182 |
" |
|
698 | 183 |
|specs coll sel| |
184 |
||
185 |
sel := treeView selection. |
|
71 | 186 |
|
128 | 187 |
coll := self minSetOfSuperViews:(self selection). |
60 | 188 |
|
71 | 189 |
coll notNil ifTrue:[ |
776 | 190 |
"/ self select:nil. |
78 | 191 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
698 | 192 |
self setSelection:specs. |
776 | 193 |
"/ treeView selection: sel |
60 | 194 |
]. |
78 | 195 |
|
196 |
||
60 | 197 |
! |
198 |
||
723 | 199 |
deleteSelection |
698 | 200 |
"cut the selection into the cut&paste-buffer |
62 | 201 |
and open a transaction |
60 | 202 |
" |
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
203 |
|specs coll oldSelectedNode newSelectedNode| |
71 | 204 |
|
128 | 205 |
coll := self minSetOfSuperViews:(self selection). |
60 | 206 |
|
78 | 207 |
coll notNil ifTrue:[ |
238 | 208 |
treeView cvsEventsDisabledDo:[ |
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
209 |
|
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
210 |
oldSelectedNode := treeView selectedNode. |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
211 |
oldSelectedNode parent children size <= 1 ifTrue: [ |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
212 |
newSelectedNode := oldSelectedNode parent |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
213 |
] |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
214 |
ifFalse: [ |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
215 |
newSelectedNode := oldSelectedNode parent children |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
216 |
at: (oldSelectedNode parent indexOfChild: oldSelectedNode) - 1 |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
217 |
ifAbsent: [oldSelectedNode parent children at: 2] |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
218 |
]. |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
219 |
|
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
220 |
selection := nil. |
111 | 221 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
60 | 222 |
|
134 | 223 |
self withinTransaction:#cut objects:coll do:[ |
224 |
coll reverseDo:[:aView| |
|
225 |
self createUndoRemove:aView. |
|
226 |
self remove:aView |
|
111 | 227 |
] |
228 |
]. |
|
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
229 |
treeView selection: nil. |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
230 |
treeView selection: (treeView model indexOf:newSelectedNode). |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
231 |
self setSelection:treeView selectedNode contents view withRedraw: true. |
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
232 |
|
698 | 233 |
] |
234 |
] |
|
235 |
! |
|
236 |
||
723 | 237 |
deleteTotalSelection |
698 | 238 |
"delete the selection; copy the selection into the cut&paste-buffer |
239 |
and open a transaction |
|
240 |
" |
|
241 |
|specs coll| |
|
242 |
||
243 |
coll := self minSetOfSuperViews:(self selection). |
|
244 |
||
245 |
coll notNil ifTrue:[ |
|
246 |
treeView cvsEventsDisabledDo:[ |
|
247 |
self select:nil. |
|
248 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
249 |
||
250 |
self withinTransaction:#cut objects:coll do:[ |
|
251 |
coll reverseDo:[:aView| |
|
252 |
self remove:aView |
|
253 |
] |
|
254 |
]. |
|
255 |
treeView selection: (Array with: 1) |
|
111 | 256 |
] |
60 | 257 |
] |
258 |
! |
|
259 |
||
260 |
pasteBuffer |
|
62 | 261 |
"add the objects in the paste-buffer to the object view |
60 | 262 |
" |
223 | 263 |
|sel| |
264 |
||
265 |
sel := self pasteSpecifications:(self getSelection) keepLayout:false. |
|
266 |
||
267 |
sel notNil ifTrue:[ |
|
268 |
self select:sel. |
|
269 |
]. |
|
89 | 270 |
|
271 |
! |
|
272 |
||
392 | 273 |
pasteFromClipBoard:aString |
274 |
^ self |
|
275 |
||
276 |
||
277 |
! |
|
278 |
||
89 | 279 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
223 | 280 |
"add the specs to the object view; returns list of pasted components |
89 | 281 |
" |
278 | 282 |
|
283 |
^ self |
|
284 |
pasteSpecifications:aSpecificationOrList |
|
285 |
keepLayout:keepLayout |
|
286 |
at:nil |
|
287 |
||
288 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
289 |
! |
|
290 |
||
291 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
292 |
"add the specs to the object view; returns list of pasted components |
|
293 |
" |
|
312 | 294 |
|paste frame pasteOrigin pasteOffset builder newSel bounds| |
60 | 295 |
|
89 | 296 |
(self canPaste:aSpecificationOrList) ifFalse:[ |
223 | 297 |
^ nil |
89 | 298 |
]. |
223 | 299 |
|
776 | 300 |
aSpecificationOrList isCollection ifTrue:[ |
301 |
paste := aSpecificationOrList |
|
302 |
] ifFalse:[ |
|
303 |
paste := Array with:aSpecificationOrList |
|
304 |
]. |
|
305 |
(frame := self singleSelection) isNil ifTrue:[ |
|
306 |
frame := self |
|
307 |
]. |
|
308 |
self selection:nil. |
|
309 |
||
310 |
newSel := OrderedCollection new. |
|
311 |
builder := UIBuilder new isEditing:true. |
|
312 |
||
313 |
className notNil ifTrue:[ |
|
314 |
builder applicationClass:(self resolveName:className) |
|
315 |
]. |
|
316 |
||
317 |
keepLayout ifFalse:[ |
|
318 |
pasteOffset := 0@0. |
|
319 |
||
320 |
aPointOrNil isNil ifTrue:[ |
|
321 |
pasteOrigin := self sensor mousePoint. |
|
322 |
pasteOrigin := device translatePoint:pasteOrigin |
|
323 |
from:device rootView id |
|
324 |
to:frame id. |
|
165 | 325 |
] ifFalse:[ |
776 | 326 |
pasteOrigin := device translatePoint:aPointOrNil |
327 |
from:self id |
|
328 |
to:frame id. |
|
329 |
] |
|
330 |
]. |
|
331 |
keepLayout ifFalse:[ |
|
332 |
bounds := Rectangle origin:0@0 extent:(frame bounds extent) |
|
333 |
]. |
|
60 | 334 |
|
776 | 335 |
paste do:[:aSpec| |
336 |
|view| |
|
395 | 337 |
|
776 | 338 |
view := self addSpec:aSpec builder:builder in:frame. |
89 | 339 |
|
165 | 340 |
keepLayout ifFalse:[ |
776 | 341 |
(bounds containsPoint:pasteOrigin) ifFalse:[ |
342 |
self moveObject:view to:pasteOffset. |
|
343 |
] ifTrue:[ |
|
344 |
self moveObject:view to:pasteOrigin + pasteOffset. |
|
345 |
]. |
|
346 |
pasteOffset := pasteOffset + 4 |
|
312 | 347 |
]. |
776 | 348 |
view realize. |
349 |
newSel add:view. |
|
350 |
]. |
|
60 | 351 |
|
776 | 352 |
self withinTransaction:#paste objects:newSel do:[ |
353 |
undoHistory addUndoSelector:#undoCreate: |
|
354 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]) |
|
355 |
]. |
|
60 | 356 |
|
776 | 357 |
self realizeAllSubViews. |
358 |
newSel do:[:v| v raise]. |
|
359 |
inputView raise. |
|
360 |
self elementChangedSize:frame. |
|
134 | 361 |
|
776 | 362 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 363 |
^ newSel |
89 | 364 |
! |
365 |
||
366 |
pasteWithLayout |
|
367 |
"add the objects in the paste-buffer to the object view; don't change the |
|
368 |
layout |
|
369 |
" |
|
223 | 370 |
|sel| |
371 |
||
372 |
sel := self pasteSpecifications:(self getSelection) keepLayout:true. |
|
89 | 373 |
|
223 | 374 |
sel notNil ifTrue:[ |
375 |
self select:sel. |
|
376 |
]. |
|
60 | 377 |
! ! |
378 |
||
379 |
!UIPainterView methodsFor:'drag & drop'! |
|
380 |
||
288 | 381 |
canDrop:something |
382 |
"returns true if something can be droped |
|
698 | 383 |
" |
288 | 384 |
(something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[ |
385 |
^ something first theObject isKindOf:UISpecification |
|
223 | 386 |
]. |
387 |
^ false |
|
388 |
! |
|
389 |
||
285 | 390 |
canPaste |
391 |
"returns true if something to be past exists and can be paste into |
|
392 |
the selection if exists |
|
393 |
" |
|
394 |
^ self canPaste:(self getSelection) |
|
395 |
! |
|
396 |
||
223 | 397 |
canPaste:something |
398 |
"returns true if something could be paste |
|
399 |
" |
|
400 |
|el size| |
|
401 |
||
402 |
((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
403 |
^ false |
|
404 |
]. |
|
405 |
something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]] |
|
406 |
ifFalse:[el := something]. |
|
407 |
||
408 |
(el isKindOf:UISpecification) ifFalse:[ |
|
409 |
^ false |
|
410 |
]. |
|
411 |
||
412 |
size == 1 ifTrue:[ |
|
413 |
^ self canPasteInto:(self singleSelection) |
|
414 |
]. |
|
415 |
^ true |
|
416 |
! |
|
417 |
||
418 |
canPasteInto:aView |
|
419 |
"can paste into a view |
|
420 |
" |
|
285 | 421 |
|prop| |
60 | 422 |
|
223 | 423 |
aView notNil ifTrue:[ |
285 | 424 |
(prop := self propertyRespondsToView:aView) notNil ifTrue:[ |
425 |
^ prop spec class supportsSubComponents |
|
426 |
]. |
|
427 |
^ aView specClass supportsSubComponents. |
|
89 | 428 |
]. |
429 |
^ false |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
430 |
|
60 | 431 |
! |
432 |
||
433 |
drop:anObjectOrCollection at:aPoint |
|
278 | 434 |
|spec newSel oldSel dragOffset| |
435 |
||
288 | 436 |
self selection notNil ifTrue:[ |
437 |
oldSel := self singleSelection. |
|
438 |
||
439 |
(self canPasteInto:oldSel) ifFalse:[ |
|
440 |
oldSel := nil. |
|
441 |
self setSelection:nil withRedraw:true |
|
442 |
] |
|
231 | 443 |
]. |
89 | 444 |
spec := (anObjectOrCollection at:1) theObject. |
278 | 445 |
dragOffset := DragAndDropManager dragOffsetQuerySignal raise. |
446 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
60 | 447 |
|
223 | 448 |
oldSel isNil ifTrue:[self select:newSel] |
449 |
ifFalse:[self select:oldSel] |
|
60 | 450 |
! ! |
451 |
||
361 | 452 |
!UIPainterView methodsFor:'event handling'! |
453 |
||
454 |
keyPress:key x:x y:y view:aView |
|
376 | 455 |
"a delegated keyEvent from aView" |
456 |
||
361 | 457 |
self keyPress:key x:x y:y |
458 |
||
376 | 459 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 460 |
! |
461 |
||
462 |
keyRelease:key x:x y:y view:aView |
|
376 | 463 |
"a delegated keyEvent from aView" |
464 |
||
361 | 465 |
self keyRelease:key x:x y:y |
466 |
||
376 | 467 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 468 |
! |
469 |
||
470 |
sizeChanged:how |
|
471 |
||
472 |
super sizeChanged:how. |
|
473 |
||
474 |
self layoutChanged |
|
361 | 475 |
! ! |
476 |
||
78 | 477 |
!UIPainterView methodsFor:'generating output'! |
478 |
||
352 | 479 |
aspectMethods |
480 |
"extract a list of aspect methods - for browsing" |
|
481 |
||
482 |
|cls methods skip selector protoSpec| |
|
483 |
||
484 |
className isNil ifTrue:[ |
|
485 |
self warn:'set the class first'. |
|
486 |
^ #() |
|
487 |
]. |
|
488 |
||
489 |
cls := self resolveName:className. |
|
490 |
methods := IdentitySet new. |
|
491 |
||
492 |
treeView propertiesDo:[:aProp| |
|
493 |
|selector| |
|
494 |
||
495 |
(selector := aProp model) notNil ifTrue:[ |
|
496 |
selector isArray ifFalse:[ |
|
497 |
selector := selector asSymbol. |
|
498 |
(cls implements:selector) ifTrue:[ |
|
499 |
skip := false. |
|
500 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
501 |
skip := SimpleDialog implements:selector asSymbol |
|
502 |
]. |
|
503 |
skip ifFalse:[ |
|
504 |
methods add:(cls compiledMethodAt:selector) |
|
505 |
]. |
|
506 |
]. |
|
507 |
]. |
|
508 |
]. |
|
509 |
||
510 |
(selector := aProp menu) notNil ifTrue:[ |
|
511 |
selector isArray ifFalse:[ |
|
512 |
selector := selector asSymbol. |
|
513 |
(cls implements:selector) ifTrue:[ |
|
514 |
methods add:(cls compiledMethodAt:selector) |
|
515 |
] |
|
516 |
]. |
|
517 |
]. |
|
518 |
||
519 |
(aProp spec aspectSelectors) do:[:aSel | |
|
520 |
|selector| |
|
521 |
||
522 |
aSel isArray ifFalse:[ |
|
523 |
selector := aSel asSymbol. |
|
524 |
(cls implements:selector) ifTrue:[ |
|
525 |
methods add:(cls compiledMethodAt:selector) |
|
526 |
] |
|
527 |
]. |
|
528 |
]. |
|
529 |
aProp spec actionSelectors do:[:aSel| |
|
530 |
|selector| |
|
531 |
||
532 |
aSel isArray ifFalse:[ |
|
533 |
selector := aSel asSymbol. |
|
534 |
(cls implements:selector) ifTrue:[ |
|
535 |
methods add:(cls compiledMethodAt:selector) |
|
536 |
] |
|
537 |
]. |
|
538 |
]. |
|
539 |
aProp spec valueSelectors do:[:aSel| |
|
540 |
|selector| |
|
541 |
||
542 |
aSel isArray ifFalse:[ |
|
543 |
selector := aSel asSymbol. |
|
544 |
(cls implements:selector) ifTrue:[ |
|
545 |
methods add:(cls compiledMethodAt:selector) |
|
546 |
] |
|
547 |
]. |
|
548 |
] |
|
549 |
]. |
|
550 |
||
551 |
protoSpec := treeView canvasSpec. |
|
552 |
||
553 |
(selector := protoSpec menu) notNil ifTrue:[ |
|
554 |
selector isArray ifFalse:[ |
|
555 |
selector := selector asSymbol. |
|
556 |
(cls implements:selector) ifTrue:[ |
|
557 |
methods add:(cls compiledMethodAt:selector) |
|
558 |
] |
|
559 |
]. |
|
560 |
]. |
|
561 |
||
562 |
^ methods |
|
563 |
||
564 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
|
565 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
|
566 |
! |
|
567 |
||
60 | 568 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
568 | 569 |
|selector args showIt code alreadyInSuperclass numArgs method| |
288 | 570 |
|
571 |
selector := aspect asSymbol. |
|
141 | 572 |
|
288 | 573 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
574 |
||
568 | 575 |
numArgs := selector numArgs. |
576 |
method := aspect. |
|
577 |
||
578 |
numArgs == 1 ifTrue:[ |
|
579 |
args := 'anArgument'. |
|
580 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
581 |
] ifFalse:[ |
|
288 | 582 |
args := ''. |
149 | 583 |
showIt := ' ...''.\'. |
568 | 584 |
|
585 |
numArgs ~~ 0 ifTrue:[ |
|
586 |
method := ''. |
|
587 |
||
588 |
selector keywords keysAndValuesDo:[:i :key| |
|
589 |
method := method, key, 'arg', i printString, ' ' |
|
590 |
] |
|
591 |
] |
|
149 | 592 |
]. |
141 | 593 |
|
288 | 594 |
code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
568 | 595 |
method , args , '\' , |
352 | 596 |
' "automatically generated by UIPainter ..."\\' , |
597 |
' "*** the code below performs no action"\' , |
|
598 |
' "*** (except for some feedback on the Transcript)"\' , |
|
599 |
' "*** Please change as required and accept in the browser."\' , |
|
288 | 600 |
'\' . |
601 |
||
602 |
alreadyInSuperclass ifTrue:[ |
|
603 |
code := code , |
|
604 |
' "action for ' , aspect , ' is already provided in a superclass."\' , |
|
605 |
' "It may be redefined here ..."\\'. |
|
606 |
] ifFalse:[ |
|
607 |
code := code , |
|
608 |
' "action to be added ..."\\'. |
|
609 |
]. |
|
610 |
||
611 |
code := code , |
|
612 |
' Transcript showCR:self class name, '': '. |
|
613 |
alreadyInSuperclass ifTrue:[ |
|
614 |
code := code , 'inherited '. |
|
615 |
]. |
|
616 |
code := code , 'action for ' , aspect , showIt. |
|
617 |
||
618 |
alreadyInSuperclass ifTrue:[ |
|
619 |
code := code , |
|
620 |
' super ' , aspect , args , '.\'. |
|
621 |
]. |
|
622 |
||
623 |
code := code , |
|
624 |
'!! !!\\'. |
|
625 |
^ code withCRs |
|
626 |
||
352 | 627 |
"Modified: / 25.10.1997 / 19:18:50 / cg" |
60 | 628 |
! |
629 |
||
630 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
631 |
|modelClass modelValue modelGen code| |
134 | 632 |
|
149 | 633 |
modelClass := protoSpec defaultModelClassFor:aspect. |
352 | 634 |
modelValue := protoSpec defaultModelValueFor:aspect. |
635 |
||
636 |
modelValue isNil ifTrue:[ |
|
637 |
modelGen := modelClass name , ' new' |
|
638 |
] ifFalse:[ |
|
639 |
modelGen := modelValue storeString , ' asValue' |
|
640 |
]. |
|
134 | 641 |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
642 |
code := '!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
60 | 643 |
aspect , '\' , |
352 | 644 |
' "automatically generated by UIPainter ..."\\' , |
645 |
' "*** the code below creates a default model when invoked."\' , |
|
646 |
' "*** (which may not be the one you wanted)"\' , |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
647 |
' "*** Please change as required and accept in the browser."\'. |
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
648 |
|
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
649 |
code := (code , |
60 | 650 |
'\' , |
651 |
' |holder|\' , |
|
652 |
'\' , |
|
653 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
352 | 654 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelGen , ').\' , |
60 | 655 |
' ].\' , |
656 |
' ^ holder\' , |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
657 |
'!! !!\\') withCRs. |
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
658 |
^ code |
352 | 659 |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
660 |
"Modified: / 5.6.1998 / 01:17:41 / cg" |
60 | 661 |
! |
662 |
||
663 |
generateAspectMethods |
|
352 | 664 |
"generate aspect, action & menu methods |
665 |
- but do not overwrite existing ones. |
|
666 |
Return a string ready to compile into the application class." |
|
667 |
||
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
668 |
|cls code skip menuSelector protoSpec thisCode |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
669 |
definedMethodSelectors| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
670 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
671 |
definedMethodSelectors := IdentitySet new. |
60 | 672 |
|
78 | 673 |
code := ''. |
674 |
||
60 | 675 |
className isNil ifTrue:[ |
698 | 676 |
self warn:'Set first the class!!'. |
78 | 677 |
^ code |
60 | 678 |
]. |
698 | 679 |
|
680 |
(cls := self resolveName:className) isNil ifTrue:[ |
|
681 |
self warn:'Class ', className asString, ' does not exist!!'. |
|
682 |
^ code |
|
683 |
]. |
|
60 | 684 |
|
316 | 685 |
treeView propertiesDo:[:aProp| |
352 | 686 |
|modelSelector menuSelector| |
687 |
||
134 | 688 |
protoSpec := aProp spec. |
175 | 689 |
|
78 | 690 |
(modelSelector := aProp model) notNil ifTrue:[ |
698 | 691 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
692 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
693 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
694 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
695 |
sym := aSel asSymbol. |
352 | 696 |
skip := false. |
698 | 697 |
|
352 | 698 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
699 |
skip := SimpleDialog implements:sym |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
700 |
]. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
701 |
(definedMethodSelectors includes:sym) ifTrue:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
702 |
skip := true. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
703 |
]. |
698 | 704 |
|
352 | 705 |
skip ifFalse:[ |
706 |
"/ kludge .. |
|
796
05b2883a23b0
fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents:
784
diff
changeset
|
707 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
05b2883a23b0
fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents:
784
diff
changeset
|
708 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
05b2883a23b0
fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents:
784
diff
changeset
|
709 |
ifTrue:[ |
698 | 710 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
352 | 711 |
] ifFalse:[ |
698 | 712 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
352 | 713 |
]. |
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
714 |
code := code, thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
715 |
definedMethodSelectors add:sym. |
698 | 716 |
] |
717 |
] |
|
62 | 718 |
]. |
719 |
||
698 | 720 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
721 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
722 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
723 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
724 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
725 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
726 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
727 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
728 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
729 |
] |
698 | 730 |
]. |
731 |
||
732 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
733 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
734 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
735 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
736 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
737 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
738 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
739 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
740 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
741 |
] |
698 | 742 |
]. |
743 |
||
744 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
745 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
746 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
747 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
748 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
749 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
750 |
"/ uppercase: - assume its a globals name. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
751 |
aSel first isUppercase ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
752 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
753 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
754 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
755 |
] |
376 | 756 |
] |
698 | 757 |
]. |
316 | 758 |
]. |
759 |
||
352 | 760 |
^ code |
698 | 761 |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
762 |
"Modified: / 5.6.1998 / 01:21:35 / cg" |
698 | 763 |
! |
764 |
||
765 |
generateCodeFrom:aListOfSelectors in:aClass do:aBlock |
|
766 |
||
744 | 767 |
self class redefineAspectMethods ifTrue:[ |
698 | 768 |
aListOfSelectors do:[:aSelector| |
769 |
(aSelector isArray or:[aClass implements:aSelector]) ifFalse:[ |
|
770 |
aBlock value:aSelector |
|
771 |
] |
|
772 |
] |
|
773 |
] ifFalse:[ |
|
774 |
aListOfSelectors do:[:aSelector| |
|
775 |
(aSelector isArray or:[aClass canUnderstand:aSelector]) ifFalse:[ |
|
776 |
aBlock value:aSelector |
|
777 |
] |
|
778 |
] |
|
779 |
] |
|
780 |
||
781 |
||
376 | 782 |
! |
783 |
||
784 |
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
|
785 |
^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
|
786 |
selectorSpec , '\' , |
|
787 |
' "automatically generated by UIPainter ..."\\' , |
|
788 |
' "*** the code here does nothing. It is invoked when"\' , |
|
789 |
' "*** ' , commentWhen , '"\' , |
|
790 |
' "*** Please change as required and accept in the browser."\' , |
|
791 |
'\' , |
|
792 |
' "specific code to be added below ..."\' , |
|
793 |
' "' , (noteOrNil ? '') , '"\' , |
|
794 |
'\' , |
|
795 |
(defaultCode ? '^ self.') , |
|
796 |
'!! !!\\') withCRs |
|
797 |
||
798 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
|
799 |
"Created: / 31.10.1997 / 17:31:53 / cg" |
|
800 |
! |
|
801 |
||
802 |
generateHookMethods |
|
803 |
"generate hook methods |
|
804 |
- but do not overwrite existing ones. |
|
805 |
Return a string ready to compile into the application class." |
|
806 |
||
807 |
|cls code skip menuSelector protoSpec thisCode| |
|
808 |
||
809 |
code := ''. |
|
810 |
||
811 |
className isNil ifTrue:[ |
|
812 |
self warn:'set the class first'. |
|
813 |
^ code |
|
814 |
]. |
|
815 |
cls := self resolveName:className. |
|
816 |
||
817 |
code := code , (self generateHookMethodsInClass:cls). |
|
818 |
||
819 |
^ code |
|
820 |
||
821 |
"Created: / 31.10.1997 / 17:21:29 / cg" |
|
822 |
"Modified: / 31.10.1997 / 17:38:11 / cg" |
|
823 |
! |
|
824 |
||
825 |
generateHookMethodsInClass:targetClass |
|
826 |
|code| |
|
827 |
||
828 |
code := ''. |
|
829 |
||
830 |
(targetClass implements:#postBuildWith:) ifFalse:[ |
|
831 |
code := code |
|
832 |
, (self |
|
833 |
generateHookMethodFor:'postBuildWith:aBuilder' |
|
834 |
comment:'the widgets have been built, but before the view is opened' |
|
708 | 835 |
note:'or after the super send' |
836 |
defaultCode:' super postBuildWith:aBuilder' |
|
376 | 837 |
inClass:targetClass) |
838 |
]. |
|
839 |
(targetClass implements:#postOpenWith:) ifFalse:[ |
|
840 |
code := code |
|
841 |
, (self |
|
842 |
generateHookMethodFor:'postOpenWith:aBuilder' |
|
843 |
comment:'the topView has been opened, but before events are dispatched for it' |
|
708 | 844 |
note:'or after the super send' |
845 |
defaultCode:' super postOpenWith:aBuilder' |
|
376 | 846 |
inClass:targetClass) |
847 |
]. |
|
848 |
(targetClass implements:#closeRequest) ifFalse:[ |
|
849 |
code := code |
|
850 |
, (self |
|
851 |
generateHookMethodFor:'closeRequest' |
|
852 |
comment:'the topView has been asked to close' |
|
853 |
note:'return without the ''super closeRequest'' to stay open' |
|
708 | 854 |
defaultCode:' ^super closeRequest' |
376 | 855 |
inClass:targetClass) |
856 |
]. |
|
857 |
^ code |
|
858 |
||
859 |
"Modified: / 31.10.1997 / 17:30:34 / cg" |
|
860 |
"Created: / 31.10.1997 / 17:32:49 / cg" |
|
316 | 861 |
! |
862 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
863 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
864 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
865 |
aspect , '\' , |
352 | 866 |
' "automatically generated by UIPainter ..."\\' , |
867 |
' "*** the code below returns a default value when invoked."\' , |
|
868 |
' "*** (which may not be the one you wanted)"\' , |
|
869 |
' "*** Please change as required and accept in the browser."\' , |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
870 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
871 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
872 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
873 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
874 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
875 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
876 |
|
352 | 877 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
878 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
879 |
|
78 | 880 |
generateWindowSpecMethodSource |
457 | 881 |
|spec str code category cls mthd specCode| |
60 | 882 |
|
310 | 883 |
spec := OrderedCollection new. |
60 | 884 |
|
78 | 885 |
self subViews do:[:aView| |
886 |
aView ~~ inputView ifTrue:[ |
|
310 | 887 |
spec add:(self fullSpecFor:aView) |
60 | 888 |
] |
889 |
]. |
|
310 | 890 |
spec := treeView generateFullSpecForComponents:spec. |
891 |
str := WriteStream on:String new. |
|
892 |
UISpecification prettyPrintSpecArray:spec on:str indent:5. |
|
464 | 893 |
specCode := str contents. |
457 | 894 |
|
895 |
(specCode includes:$!!) ifTrue:[ |
|
896 |
"/ oops - must be chunk format ... |
|
897 |
str := WriteStream on:String new. |
|
898 |
str nextPutAllAsChunk:specCode. |
|
899 |
specCode := str contents. |
|
900 |
]. |
|
60 | 901 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
902 |
"/ 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
|
903 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
904 |
category := 'interface specs'. |
330 | 905 |
cls := self resolveName:className. |
906 |
||
907 |
cls notNil ifTrue:[ |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
908 |
(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
|
909 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
910 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
911 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
912 |
|
238 | 913 |
code := '!!' |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
914 |
, className , ' class methodsFor:' , category storeString |
238 | 915 |
, '!!' , '\\' |
60 | 916 |
|
917 |
, methodName , '\' |
|
742 | 918 |
, ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!') |
919 |
, '\\ "\' |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
920 |
, (' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\') |
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
921 |
, (' ' , className , ' new openInterface:#' , methodName , '\') |
742 | 922 |
,(methodName = 'windowSpec' |
923 |
ifTrue:[' ' , className , ' open\'] ifFalse: ['']) |
|
60 | 924 |
, ' "\'. |
925 |
||
926 |
code := code |
|
927 |
, '\' |
|
928 |
, ' <resource: #canvas>\\' |
|
929 |
, ' ^\' |
|
457 | 930 |
, ' ', specCode |
60 | 931 |
, '\' |
238 | 932 |
, '!! !!' |
60 | 933 |
, '\\'. |
934 |
||
935 |
^ code withCRs |
|
936 |
||
937 |
"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
|
938 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 939 |
! ! |
940 |
||
754 | 941 |
!UIPainterView methodsFor:'grid manipulation'! |
942 |
||
943 |
newGrid |
|
944 |
"define a new grid - this is a private helper which has to be |
|
945 |
called after any change in the grid. It (re)creates the gridPixmap, |
|
946 |
clears the view and redraws all visible objects." |
|
947 |
||
948 |
|defaultViewBackground| |
|
949 |
||
950 |
gridPixmap := nil. |
|
951 |
defaultViewBackground := self class defaultViewBackgroundColor. |
|
952 |
||
953 |
shown ifTrue:[ |
|
954 |
self viewBackground: (defaultViewBackground isColor |
|
955 |
ifTrue: [defaultViewBackground] |
|
956 |
ifFalse:[Black]). |
|
957 |
self clear. |
|
958 |
]. |
|
959 |
||
960 |
gridShown ifTrue:[ |
|
961 |
self defineGrid. |
|
962 |
gridPixmap colorMap: (defaultViewBackground isColor |
|
963 |
ifTrue: [Array with:defaultViewBackground with:Color darkGray] |
|
964 |
ifFalse:[Array with:White with:Black]). |
|
965 |
self viewBackground:gridPixmap. |
|
966 |
]. |
|
967 |
||
968 |
self invalidate |
|
969 |
||
970 |
! ! |
|
971 |
||
60 | 972 |
!UIPainterView methodsFor:'initialization'! |
973 |
||
770 | 974 |
create |
975 |
"colors on device |
|
976 |
" |
|
977 |
super create. |
|
978 |
||
979 |
handleColor := handleColor on:device. |
|
980 |
handleMasterColor := handleMasterColor on:device. |
|
981 |
! |
|
982 |
||
60 | 983 |
initialize |
62 | 984 |
"setup attributes |
985 |
" |
|
60 | 986 |
super initialize. |
770 | 987 |
superclassName := 'ApplicationModel'. |
988 |
className := 'NewApplication'. |
|
989 |
methodName := 'windowSpec'. |
|
990 |
categoryName := 'Applications'. |
|
991 |
HandCursor := Cursor leftHand. |
|
992 |
handleColor := Color black. |
|
993 |
handleMasterColor := Color red. |
|
60 | 994 |
|
712 | 995 |
self backgroundColor: self class defaultViewBackgroundColor. |
60 | 996 |
! |
997 |
||
998 |
setupFromSpec:specOrSpecArray |
|
784 | 999 |
|
78 | 1000 |
|spec builder| |
60 | 1001 |
|
784 | 1002 |
Cursor wait showWhile: [ |
1003 |
self removeAll. |
|
1004 |
spec := UISpecification from:specOrSpecArray. |
|
1005 |
builder := UIBuilder new isEditing:true. |
|
1006 |
"set applicationClass, in order that subspecifications may be resolved" |
|
1007 |
className notNil ifTrue:[ |
|
1008 |
builder applicationClass:(self resolveName:className). |
|
1009 |
]. |
|
1010 |
spec window setupView:self topView for:builder. |
|
1011 |
self addSpec:(spec component) builder:builder in:self. |
|
1012 |
self realizeAllSubViews. |
|
1013 |
inputView raise. |
|
1014 |
treeView setAttributesFromWindowSpec:(spec window) |
|
1015 |
] |
|
1016 |
||
223 | 1017 |
! |
1018 |
||
1019 |
treeView:aTreeView |
|
361 | 1020 |
treeView := aTreeView. |
1021 |
||
1022 |
treeView delegate:( |
|
376 | 1023 |
"/ |
1024 |
"/ I want to handle everything typed |
|
1025 |
"/ in the treeView, except for Return and Cursor-keys |
|
1026 |
"/ |
|
1027 |
KeyboardForwarder |
|
1028 |
toView:self |
|
1029 |
condition:nil |
|
1030 |
filter:[:k | (k isSymbol |
|
1031 |
and:[k ~~ #Return |
|
1032 |
and:[(k startsWith:#Cursor) not]]) |
|
1033 |
] |
|
361 | 1034 |
) |
1035 |
||
376 | 1036 |
"Modified: / 31.10.1997 / 20:22:09 / cg" |
60 | 1037 |
! ! |
1038 |
||
1039 |
!UIPainterView methodsFor:'menus'! |
|
1040 |
||
121 | 1041 |
showMiddleButtonMenu |
1042 |
"show the middle button menu; this returns nil |
|
62 | 1043 |
" |
223 | 1044 |
self enabled ifTrue:[ |
754 | 1045 |
(MenuPanel fromSpec:(UIPainter menuEdit) receiver:self superView application) startUp |
111 | 1046 |
]. |
121 | 1047 |
^ nil |
60 | 1048 |
|
62 | 1049 |
|
1050 |
||
60 | 1051 |
! ! |
1052 |
||
754 | 1053 |
!UIPainterView methodsFor:'private handles'! |
1054 |
||
1055 |
showSelected:aComponent |
|
1056 |
"show object selected |
|
1057 |
" |
|
1058 |
|wasClipped| |
|
1059 |
||
1060 |
selectionHiddenLevel == 0 ifTrue:[ |
|
1061 |
(treeView selection size > 1 and: |
|
1062 |
[(treeView model list at: treeView selection first) contents view == aComponent]) |
|
770 | 1063 |
ifTrue: [self paint: handleMasterColor] |
1064 |
ifFalse:[self paint: handleColor]. |
|
754 | 1065 |
|
1066 |
(wasClipped := clipChildren) ifTrue:[ |
|
1067 |
self clippedByChildren:(clipChildren := false). |
|
1068 |
]. |
|
1069 |
||
1070 |
self handlesOf:aComponent do:[:rectangle :what| |
|
1071 |
what == #view ifTrue:[self displayRectangle:rectangle] |
|
1072 |
ifFalse:[self fillRectangle:rectangle] |
|
1073 |
]. |
|
1074 |
||
1075 |
wasClipped ifTrue:[ |
|
1076 |
self clippedByChildren:(clipChildren := true). |
|
1077 |
] |
|
1078 |
] |
|
1079 |
||
1080 |
||
1081 |
! ! |
|
1082 |
||
335 | 1083 |
!UIPainterView methodsFor:'queries'! |
1084 |
||
1085 |
resolveName:aName |
|
1086 |
|appl| |
|
1087 |
||
1088 |
appl := self application. |
|
1089 |
||
1090 |
appl notNil ifTrue:[ |
|
1091 |
^ appl resolveName:aName |
|
1092 |
]. |
|
1093 |
^ Smalltalk resolveName:aName inClass:self class |
|
1094 |
! ! |
|
1095 |
||
60 | 1096 |
!UIPainterView methodsFor:'removing components'! |
1097 |
||
78 | 1098 |
remove:anObject |
1099 |
"remove anObject from the contents do redraw |
|
60 | 1100 |
" |
134 | 1101 |
anObject notNil ifTrue:[ |
238 | 1102 |
treeView removeView:anObject. |
134 | 1103 |
] |
60 | 1104 |
! |
1105 |
||
1106 |
removeAll |
|
62 | 1107 |
"remove all objects and properties |
1108 |
" |
|
776 | 1109 |
self select:nil. |
1110 |
treeView removeAll. |
|
1111 |
self removeUndoHistory. |
|
60 | 1112 |
! ! |
1113 |
||
1114 |
!UIPainterView methodsFor:'searching'! |
|
1115 |
||
285 | 1116 |
findContainerOfView:aView |
1117 |
"returns the super view assigned to a view |
|
89 | 1118 |
" |
285 | 1119 |
|p| |
89 | 1120 |
|
285 | 1121 |
(p := self propertyOfParentForView:aView) isNil ifTrue:[ |
89 | 1122 |
^ self |
1123 |
]. |
|
285 | 1124 |
^ p view |
89 | 1125 |
! |
1126 |
||
60 | 1127 |
findObjectAt:aPoint |
1128 |
"find the origin/corner of the currentWidget |
|
1129 |
" |
|
285 | 1130 |
|view prop| |
60 | 1131 |
|
1132 |
view := super findObjectAt:aPoint. |
|
285 | 1133 |
prop := self propertyRespondsToView:view. |
60 | 1134 |
|
285 | 1135 |
prop notNil ifTrue:[^ prop view]. |
1136 |
^ nil |
|
60 | 1137 |
! |
1138 |
||
1139 |
findViewWithId:aViewId |
|
62 | 1140 |
"finds view assigned to identifier and returns the view or nil |
60 | 1141 |
" |
1142 |
|prop| |
|
1143 |
||
1144 |
prop := self propertyOfIdentifier:aViewId. |
|
1145 |
||
1146 |
prop notNil ifTrue:[^ prop view] |
|
1147 |
ifFalse:[^ nil] |
|
78 | 1148 |
! |
1149 |
||
1150 |
propertyOfIdentifier:anId |
|
1151 |
"returns property assigned to unique identifier |
|
1152 |
" |
|
1153 |
anId notNil ifTrue:[ |
|
238 | 1154 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 1155 |
]. |
1156 |
^ nil |
|
1157 |
! |
|
1158 |
||
1159 |
propertyOfName:aString |
|
1160 |
"returns property assigned to name |
|
1161 |
" |
|
111 | 1162 |
|name| |
1163 |
||
1164 |
aString isNil ifFalse:[ |
|
1165 |
name := aString string withoutSeparators. |
|
238 | 1166 |
^ treeView propertyDetect:[:p| p name = name ]. |
78 | 1167 |
]. |
1168 |
^ nil |
|
1169 |
! |
|
1170 |
||
285 | 1171 |
propertyOfParentForView:aSubView |
1172 |
"returns the property of the parent or nil |
|
1173 |
" |
|
1174 |
|item| |
|
1175 |
||
1176 |
(item := treeView detectItemRespondsToView:aSubView) notNil ifTrue:[ |
|
1177 |
(item := item parent) notNil ifTrue:[^ item contents] |
|
1178 |
]. |
|
1179 |
^ nil |
|
1180 |
! |
|
1181 |
||
78 | 1182 |
propertyOfView:aView |
1183 |
"returns property assigned to view |
|
1184 |
" |
|
1185 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
238 | 1186 |
^ treeView propertyDetect:[:p| p view == aView ] |
78 | 1187 |
]. |
1188 |
^ nil |
|
1189 |
! |
|
1190 |
||
285 | 1191 |
propertyRespondsToView:aView |
1192 |
"detect the property responding to the argument a view. The property of the view or |
|
1193 |
the first subview providing the properties is returned. If no property is detected |
|
1194 |
nil is returned. |
|
1195 |
" |
|
1196 |
|item| |
|
1197 |
||
1198 |
item := treeView detectItemRespondsToView:aView. |
|
1199 |
||
1200 |
(item notNil and:[item parent notNil]) ifTrue:[ |
|
1201 |
^ item contents |
|
1202 |
]. |
|
1203 |
^ nil |
|
1204 |
! |
|
1205 |
||
111 | 1206 |
uniqueNameFor:aSpecOrString |
78 | 1207 |
"generate and return an unique name for a class |
1208 |
" |
|
1209 |
|next name size| |
|
1210 |
||
712 | 1211 |
aSpecOrString isString ifFalse:[name := aSpecOrString userFriendlyName] |
111 | 1212 |
ifTrue:[name := aSpecOrString]. |
78 | 1213 |
|
111 | 1214 |
size := name size + 1. |
1215 |
next := 0. |
|
78 | 1216 |
|
238 | 1217 |
treeView propertiesDo:[:p| |
111 | 1218 |
|n| |
78 | 1219 |
n := p name. |
1220 |
||
1221 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
1222 |
next := next max:(p extractNumberStartingAt:size) |
|
1223 |
] |
|
1224 |
]. |
|
1225 |
next := next + 1. |
|
1226 |
name := name, next printString. |
|
1227 |
^ name |
|
1228 |
||
1229 |
||
1230 |
||
662 | 1231 |
|
78 | 1232 |
! |
1233 |
||
1234 |
uniqueNameOf:aView |
|
111 | 1235 |
|prop| |
78 | 1236 |
|
111 | 1237 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
1238 |
prop name isNil ifTrue:[ |
|
1239 |
prop name:(self uniqueNameFor:(prop spec)). |
|
1240 |
]. |
|
1241 |
^ prop name |
|
78 | 1242 |
]. |
111 | 1243 |
^ 'self' |
78 | 1244 |
|
60 | 1245 |
! ! |
1246 |
||
223 | 1247 |
!UIPainterView methodsFor:'selection basics'! |
1248 |
||
1249 |
addToSelection:anObject |
|
1250 |
"add an object to the selection |
|
1251 |
" |
|
1252 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
1253 |
selection isCollection ifFalse:[ |
|
1254 |
selection isNil ifTrue:[ |
|
1255 |
selection := anObject |
|
1256 |
] ifFalse:[ |
|
1257 |
selection := OrderedCollection with:selection with:anObject |
|
1258 |
] |
|
1259 |
] ifTrue:[ |
|
1260 |
selection add:anObject |
|
1261 |
]. |
|
1262 |
self showSelected:anObject. |
|
238 | 1263 |
treeView cvsSelectionAdd:anObject. |
223 | 1264 |
] |
1265 |
||
1266 |
||
1267 |
! |
|
1268 |
||
1269 |
removeFromSelection:anObject |
|
1270 |
"remove an object from the selection |
|
1271 |
" |
|
1272 |
(self isSelected:anObject) ifTrue:[ |
|
1273 |
self showUnselected:anObject. |
|
1274 |
||
1275 |
selection size > 1 ifTrue:[ |
|
1276 |
selection remove:anObject ifAbsent:nil. |
|
1277 |
self showSelection. |
|
1278 |
] ifFalse:[ |
|
1279 |
selection := nil |
|
1280 |
]. |
|
238 | 1281 |
treeView cvsSelectionRemove:anObject. |
223 | 1282 |
] |
1283 |
||
1284 |
! |
|
1285 |
||
1286 |
select:something |
|
1287 |
"change selection to something |
|
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
1288 |
" |
760 | 1289 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
1290 |
something isNil |
|
1291 |
ifTrue: [treeView selection: (Array with: 1)] |
|
1292 |
ifFalse:[treeView cvsSelection:something]. |
|
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
1293 |
self setSelection:something withRedraw:true |
223 | 1294 |
] |
1295 |
||
1296 |
! |
|
1297 |
||
285 | 1298 |
updateSelectionFromModel:aSelOrNil |
223 | 1299 |
"update selection from a new selection |
1300 |
" |
|
768 | 1301 |
|aSet| |
1302 |
||
223 | 1303 |
selectionHiddenLevel == 0 ifTrue:[ |
285 | 1304 |
aSelOrNil size ~~ 0 ifTrue:[ |
768 | 1305 |
self selectionDo:[:el| |
1306 |
(aSelOrNil includes:el) ifFalse:[ |
|
1307 |
aSet isNil ifTrue:[ |
|
1308 |
aSet := IdentitySet new |
|
1309 |
]. |
|
1310 |
self showUnselected:el addAffectedViewsTo:aSet. |
|
1311 |
] |
|
1312 |
]. |
|
1313 |
self handleAffectedViews:aSet. |
|
285 | 1314 |
] ifFalse:[ |
768 | 1315 |
self hideSelection. |
285 | 1316 |
] |
223 | 1317 |
]. |
285 | 1318 |
self setSelection:aSelOrNil withRedraw:false. |
223 | 1319 |
self showSelection |
1320 |
||
1321 |
! ! |
|
1322 |
||
78 | 1323 |
!UIPainterView methodsFor:'specification'! |
1324 |
||
1325 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
1326 |
"build view and subviews from aSpecification into a frame. The top view |
|
1327 |
is returned. The contained components of a spec are set to nil |
|
1328 |
" |
|
330 | 1329 |
|cls| |
212 | 1330 |
|
330 | 1331 |
cls := self resolveName:className. |
1332 |
||
1333 |
cls notNil ifTrue:[ |
|
1334 |
aBuilder applicationClass:cls. |
|
212 | 1335 |
]. |
78 | 1336 |
|
111 | 1337 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 1338 |
p := ViewProperty new. |
1339 |
s := aSpec copy. |
|
1340 |
p spec:s. |
|
1341 |
p view:aView. |
|
1342 |
||
1343 |
s class supportsSubComponents ifTrue:[ |
|
1344 |
s component:nil |
|
1345 |
]. |
|
1346 |
||
111 | 1347 |
n := s name. |
1348 |
||
1349 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
1350 |
s name:(self uniqueNameFor:s) |
|
78 | 1351 |
]. |
238 | 1352 |
treeView addProperty:p. |
78 | 1353 |
]. |
1354 |
||
1355 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 1356 |
|
212 | 1357 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 1358 |
! |
1359 |
||
1360 |
fullSpecFor:anObject |
|
1361 |
"generate a full spec for an object |
|
62 | 1362 |
" |
78 | 1363 |
|mySpec subSpecs| |
1364 |
||
1365 |
mySpec := self specFor:anObject. |
|
1366 |
||
1367 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
1368 |
(anObject subViews notNil) ifTrue:[ |
|
1369 |
anObject subViews do:[:aSubView||spec| |
|
1370 |
spec := self fullSpecFor:aSubView. |
|
1371 |
spec notNil ifTrue:[ |
|
1372 |
subSpecs isNil ifTrue:[ |
|
1373 |
subSpecs := OrderedCollection new |
|
1374 |
]. |
|
1375 |
subSpecs add:spec. |
|
1376 |
]. |
|
1377 |
]. |
|
1378 |
subSpecs notNil ifTrue:[ |
|
1379 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
1380 |
] |
|
1381 |
] |
|
1382 |
]. |
|
1383 |
^ mySpec |
|
1384 |
||
60 | 1385 |
|
1386 |
||
1387 |
||
1388 |
||
1389 |
||
1390 |
! |
|
1391 |
||
285 | 1392 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilder |
1393 |
|v| |
|
1394 |
||
1395 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
1396 |
v := aSpec buildViewWithLayoutFor:aBuilder in:(self findContainerOfView:aView). |
|
1397 |
v realize. |
|
1398 |
aView destroy. |
|
1399 |
device sync. |
|
1400 |
device flush. |
|
1401 |
aView becomeSameAs:v. |
|
1402 |
inputView raise. |
|
1403 |
] ifFalse:[ |
|
1404 |
aSpec setAttributesIn:aView with:aBuilder. |
|
1405 |
self elementChangedSize:aView. |
|
1406 |
]. |
|
1407 |
||
1408 |
! |
|
1409 |
||
78 | 1410 |
specFor:anObject |
1411 |
"returns spec assigned to an object |
|
62 | 1412 |
" |
78 | 1413 |
|prop spec| |
60 | 1414 |
|
78 | 1415 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
1416 |
spec := prop spec copy. |
|
1417 |
spec layoutFromView:anObject |
|
60 | 1418 |
]. |
78 | 1419 |
^ spec |
1420 |
||
1421 |
||
1422 |
||
60 | 1423 |
! |
1424 |
||
146 | 1425 |
specForSelection |
1426 |
"returns spec assigned to current single selection or nil |
|
1427 |
" |
|
1428 |
^ self specFor:(self singleSelection) |
|
1429 |
||
1430 |
||
1431 |
! |
|
1432 |
||
78 | 1433 |
updateFromSpec:aSpec |
1434 |
"update current selected view from specification |
|
62 | 1435 |
" |
327
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1436 |
|props name builder| |
78 | 1437 |
|
281 | 1438 |
aSpec class == WindowSpec ifTrue:[ |
698 | 1439 |
^ treeView canvasSpec:aSpec |
281 | 1440 |
]. |
1441 |
||
78 | 1442 |
self singleSelection notNil ifTrue:[ |
1443 |
self withSelectionHiddenDo:[ |
|
1444 |
self transaction:#specification selectionDo:[:aView| |
|
395 | 1445 |
builder := UIBuilder new isEditing:true. |
212 | 1446 |
className notNil ifTrue:[ |
330 | 1447 |
builder applicationClass:(self resolveName:className). |
212 | 1448 |
]. |
78 | 1449 |
props := self propertyOfView:aView. |
82 | 1450 |
name := (aSpec name) withoutSeparators. |
78 | 1451 |
|
82 | 1452 |
name = props name ifFalse:[ |
1453 |
(self propertyOfName:name) notNil ifTrue:[ |
|
1454 |
name := props name |
|
78 | 1455 |
] |
1456 |
]. |
|
82 | 1457 |
aSpec name:name. |
134 | 1458 |
self createUndoSpecModify:props. |
285 | 1459 |
self rebuildView:aView fromSpec:aSpec withBuilder:builder. |
78 | 1460 |
props spec:(aSpec copy). |
238 | 1461 |
treeView propertyChanged:props. |
78 | 1462 |
] |
111 | 1463 |
] |
82 | 1464 |
] |
212 | 1465 |
|
1466 |
"Modified: 4.7.1997 / 23:49:44 / cg" |
|
60 | 1467 |
! ! |
1468 |
||
285 | 1469 |
!UIPainterView methodsFor:'testing'! |
1470 |
||
1471 |
canChangeLayoutOfView:aView |
|
1472 |
"returns true if the view can change its layout which is dependant on |
|
1473 |
its parent view. |
|
1474 |
" |
|
1475 |
|item prnt| |
|
1476 |
||
1477 |
( (item := treeView itemOfView:aView) isNil |
|
1478 |
or:[(prnt := item parent) isNil] |
|
1479 |
) ifTrue:[ |
|
1480 |
^ false |
|
1481 |
]. |
|
1482 |
^ (prnt parent isNil or:[prnt contents spec class isLayoutContainer not]) |
|
1483 |
! |
|
1484 |
||
1485 |
canKeepLayoutInSelection |
|
1486 |
"returns true if layout can be kept during a paste operation |
|
1487 |
" |
|
1488 |
|prop| |
|
1489 |
||
1490 |
prop := self propertyOfView:(self singleSelection). |
|
1491 |
^ (prop isNil or:[prop spec class isLayoutContainer not]) |
|
1492 |
! |
|
1493 |
||
1494 |
canMove:something |
|
1495 |
"checks whether something is not nil and if all widgets derived from |
|
1496 |
something can change their layout ( move, align, ... operation ). |
|
1497 |
" |
|
1498 |
something notNil ifTrue:[ |
|
1499 |
self forEach:something do:[:aView| |
|
1500 |
(self canChangeLayoutOfView:aView) ifFalse:[^ false] |
|
1501 |
]. |
|
1502 |
^ true |
|
1503 |
]. |
|
1504 |
^ false |
|
1505 |
! |
|
1506 |
||
1507 |
canMoveOrAlignSelection |
|
1508 |
"returns true if a selection exists and all elements in the selection |
|
1509 |
can be moved or aligned |
|
1510 |
" |
|
1511 |
^ self canMove:(self selection) |
|
1512 |
||
1513 |
! ! |
|
1514 |
||
60 | 1515 |
!UIPainterView methodsFor:'transaction'! |
1516 |
||
1517 |
transaction:aType objects:something do:aOneArgBlock |
|
1518 |
"opens a transaction and evaluates a block within the transaction; the |
|
1519 |
argument to the block is a view from derived from something |
|
1520 |
" |
|
134 | 1521 |
self withinTransaction:aType objects:something do:[ |
1522 |
self forEach:something do:aOneArgBlock |
|
60 | 1523 |
] |
1524 |
! |
|
1525 |
||
134 | 1526 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
1527 |
"evaluate a block with no arguments within a transaction |
|
60 | 1528 |
" |
134 | 1529 |
|text size prop| |
1530 |
||
1531 |
objects isNil ifTrue:[ ^ self ]. |
|
1532 |
||
1533 |
size := objects size. |
|
60 | 1534 |
|
134 | 1535 |
objects isCollection ifTrue:[ |
1536 |
size == 0 ifTrue:[ ^ self ]. |
|
1537 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
1538 |
] ifFalse:[ |
|
1539 |
prop := self propertyOfView:objects |
|
1540 |
]. |
|
60 | 1541 |
|
134 | 1542 |
prop notNil ifTrue:[ |
1543 |
text := prop name |
|
1544 |
] ifFalse:[ |
|
1545 |
text := size printString, ' elements' |
|
60 | 1546 |
]. |
134 | 1547 |
|
1548 |
undoHistory withinTransaction:aType text:text do:[ |
|
1549 |
aNoneArgBlock value |
|
1550 |
] |
|
60 | 1551 |
! ! |
1552 |
||
1553 |
!UIPainterView methodsFor:'undo actions'! |
|
1554 |
||
134 | 1555 |
createUndoLayout:aView |
1556 |
"create undo action before changing a views layout |
|
60 | 1557 |
" |
134 | 1558 |
|lyt args prop| |
60 | 1559 |
|
1560 |
undoHistory isTransactionOpen ifTrue:[ |
|
1561 |
prop := self propertyOfView:aView. |
|
134 | 1562 |
|
60 | 1563 |
prop notNil ifTrue:[ |
134 | 1564 |
args := Array new:3. |
1565 |
args at:1 put:(prop identifier). |
|
1566 |
||
1567 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
1568 |
args at:2 put:#geometryLayout: |
|
1569 |
] ifFalse:[ |
|
146 | 1570 |
lyt := aView extent. |
134 | 1571 |
args at:2 put:#extent: |
1572 |
]. |
|
1573 |
args at:3 put:(lyt copy). |
|
1574 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 1575 |
] |
1576 |
] |
|
1577 |
! |
|
1578 |
||
134 | 1579 |
createUndoRemove:aView |
1580 |
"create undo method before deleting views |
|
60 | 1581 |
" |
285 | 1582 |
|prop pid| |
134 | 1583 |
|
1584 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
285 | 1585 |
(pid := self propertyOfParentForView:aView) notNil ifTrue:[ |
1586 |
pid := pid identifier |
|
1587 |
]. |
|
60 | 1588 |
|
134 | 1589 |
undoHistory addUndoSelector:#undoRemove: |
285 | 1590 |
withArgs:(Array with:(self fullSpecFor:aView) |
1591 |
with:(prop identifier) |
|
1592 |
with:pid) |
|
134 | 1593 |
] |
1594 |
! |
|
60 | 1595 |
|
134 | 1596 |
createUndoSpecModify:aProp |
1597 |
"undo method when changing the specification for an object |
|
1598 |
" |
|
1599 |
aProp notNil ifTrue:[ |
|
1600 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1601 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1602 |
] |
|
1603 |
! |
|
60 | 1604 |
|
134 | 1605 |
undoCreate:something |
1606 |
"undo method for creating or pasting an object |
|
1607 |
" |
|
1608 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1609 |
! |
|
60 | 1610 |
|
134 | 1611 |
undoLayout:args |
1612 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1613 |
" |
|
1614 |
|view| |
|
1615 |
||
1616 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1617 |
view perform:(args at:2) with:(args at:3). |
223 | 1618 |
self layoutChanged. |
60 | 1619 |
] |
1620 |
! |
|
1621 |
||
134 | 1622 |
undoRemove:args |
1623 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1624 |
" |
|
1625 |
|frame prop view| |
|
1626 |
||
1627 |
(args at:3) notNil ifTrue:[ |
|
1628 |
frame := self findViewWithId:(args at:3). |
|
1629 |
]. |
|
1630 |
frame isNil ifTrue:[ |
|
1631 |
frame := self |
|
1632 |
]. |
|
395 | 1633 |
view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame. |
134 | 1634 |
view realize. |
1635 |
inputView raise. |
|
1636 |
||
1637 |
prop := self propertyOfView:view. |
|
1638 |
prop identifier:(args at:2). |
|
1639 |
||
1640 |
! |
|
1641 |
||
1642 |
undoSpecModify:args |
|
1643 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1644 |
" |
327
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1645 |
|builder view spec props| |
60 | 1646 |
|
134 | 1647 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1648 |
|
134 | 1649 |
props notNil ifTrue:[ |
1650 |
view := props view. |
|
1651 |
spec := args at:1. |
|
395 | 1652 |
builder := UIBuilder new isEditing:true. |
1653 |
||
212 | 1654 |
className notNil ifTrue:[ |
330 | 1655 |
builder applicationClass:(self resolveName:className). |
212 | 1656 |
]. |
134 | 1657 |
props spec:spec. |
285 | 1658 |
self rebuildView:view fromSpec:spec withBuilder:builder. |
238 | 1659 |
treeView propertyChanged:props. |
211 | 1660 |
] |
1661 |
! ! |
|
1662 |
||
1663 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
1664 |
||
1665 |
new |
|
1666 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1667 |
ifFalse:[Identifier := 1]. |
|
1668 |
||
1669 |
^ self basicNew initialize |
|
1670 |
! ! |
|
1671 |
||
1672 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1673 |
||
1674 |
identifier |
|
1675 |
"return the unique identifier assigned to property |
|
1676 |
" |
|
1677 |
^ identifier |
|
1678 |
! |
|
1679 |
||
1680 |
identifier:anIdentifier |
|
1681 |
"set the unique identifier assigned to property; called after an restore of |
|
1682 |
a deleted instance |
|
1683 |
" |
|
1684 |
identifier := anIdentifier |
|
1685 |
! |
|
1686 |
||
1687 |
spec |
|
1688 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1689 |
||
1690 |
^ spec! |
|
1691 |
||
1692 |
spec:something |
|
1693 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1694 |
||
1695 |
spec := something.! |
|
1696 |
||
1697 |
view |
|
1698 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1699 |
||
1700 |
^ view! |
|
1701 |
||
1702 |
view:something |
|
1703 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1704 |
||
1705 |
view := something.! ! |
|
1706 |
||
1707 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1708 |
||
1709 |
initialize |
|
1710 |
super initialize. |
|
1711 |
identifier := Identifier |
|
1712 |
! ! |
|
1713 |
||
1714 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1715 |
||
1716 |
extractNumberStartingAt:anIndex |
|
1717 |
"return the number from the name starting at anIndex or 0. |
|
1718 |
" |
|
1719 |
|val| |
|
1720 |
||
1721 |
val := 0. |
|
1722 |
||
1723 |
self name from:anIndex do:[:c| |
|
1724 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1725 |
ifFalse:[^ 0] |
|
1726 |
]. |
|
1727 |
^ val |
|
1728 |
||
1729 |
! ! |
|
1730 |
||
1731 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1732 |
||
1733 |
doesNotUnderstand:aMessage |
|
1734 |
spec notNil ifTrue:[ |
|
1735 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1736 |
]. |
|
1737 |
^ nil |
|
1738 |
! |
|
1739 |
||
1740 |
layout |
|
1741 |
spec layout |
|
1742 |
! |
|
1743 |
||
1744 |
layout:aLayout |
|
1745 |
spec layout:aLayout |
|
1746 |
! |
|
1747 |
||
1748 |
name |
|
1749 |
^ spec name |
|
1750 |
! |
|
1751 |
||
1752 |
name:aName |
|
1753 |
spec name:aName |
|
1754 |
! ! |
|
1755 |
||
60 | 1756 |
!UIPainterView class methodsFor:'documentation'! |
1757 |
||
1758 |
version |
|
1759 |
^ '$Header$' |
|
1760 |
! ! |