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