51
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
52
|
3 |
All Rights Reserved
|
51
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
UIObjectView subclass:#UIPainterView
|
52
|
14 |
instanceVariableNames:'fontPanel code viewProperties superclassName className methodName
|
|
15 |
categoryName'
|
|
16 |
classVariableNames:'HandCursor'
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'Interface-UIPainter'
|
51
|
19 |
!
|
|
20 |
|
|
21 |
Object subclass:#ViewProperty
|
52
|
22 |
instanceVariableNames:'aspectSelector changeSelector name nameIndex view elementClass
|
|
23 |
labelSelector identifier'
|
|
24 |
classVariableNames:'Identifier'
|
|
25 |
poolDictionaries:''
|
|
26 |
privateIn:UIPainterView
|
51
|
27 |
!
|
|
28 |
|
48
|
29 |
UIPainterView::ViewProperty subclass:#GroupProperties
|
52
|
30 |
instanceVariableNames:'controlledObjects group'
|
|
31 |
classVariableNames:''
|
|
32 |
poolDictionaries:''
|
|
33 |
privateIn:UIPainterView
|
51
|
34 |
!
|
|
35 |
|
|
36 |
!UIPainterView class methodsFor:'documentation'!
|
|
37 |
|
|
38 |
copyright
|
|
39 |
"
|
|
40 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
52
|
41 |
All Rights Reserved
|
51
|
42 |
|
|
43 |
This software is furnished under a license and may be used
|
|
44 |
only in accordance with the terms of that license and with the
|
|
45 |
inclusion of the above copyright notice. This software may not
|
|
46 |
be provided or otherwise made available to, or used by, any
|
|
47 |
other person. No title to or ownership of the software is
|
|
48 |
hereby transferred.
|
|
49 |
"
|
|
50 |
!
|
|
51 |
|
|
52 |
documentation
|
|
53 |
"
|
|
54 |
not yet finished, not yet published, not yet released.
|
|
55 |
"
|
|
56 |
! !
|
|
57 |
|
53
|
58 |
!UIPainterView class methodsFor:'defaults'!
|
|
59 |
|
|
60 |
defaultMenuMessage
|
|
61 |
"This message is the default yo be sent to the menuHolder to get a menu
|
|
62 |
"
|
|
63 |
^ #menu
|
|
64 |
|
|
65 |
|
|
66 |
! !
|
|
67 |
|
51
|
68 |
!UIPainterView methodsFor:'accessing'!
|
|
69 |
|
53
|
70 |
application
|
|
71 |
self halt.
|
|
72 |
^ nil
|
|
73 |
|
|
74 |
"Modified: 6.9.1995 / 00:46:44 / claus"
|
|
75 |
!
|
|
76 |
|
51
|
77 |
className
|
|
78 |
^ className
|
|
79 |
|
|
80 |
"Modified: 5.9.1995 / 18:41:30 / claus"
|
|
81 |
!
|
|
82 |
|
|
83 |
className:aString
|
|
84 |
className := aString
|
|
85 |
|
|
86 |
"Modified: 5.9.1995 / 18:47:17 / claus"
|
|
87 |
!
|
|
88 |
|
|
89 |
methodName
|
|
90 |
^ methodName
|
|
91 |
|
|
92 |
"Modified: 5.9.1995 / 18:41:34 / claus"
|
|
93 |
!
|
|
94 |
|
|
95 |
methodName:aString
|
|
96 |
methodName := aString
|
|
97 |
|
|
98 |
"Modified: 5.9.1995 / 18:47:27 / claus"
|
|
99 |
!
|
|
100 |
|
53
|
101 |
selectNames:aStringOrCollection
|
|
102 |
|prop coll s|
|
51
|
103 |
|
53
|
104 |
(aStringOrCollection isNil or:[aStringOrCollection isEmpty]) ifTrue:[
|
|
105 |
^ self unselect
|
|
106 |
].
|
|
107 |
|
|
108 |
(s := aStringOrCollection) isString ifFalse:[
|
|
109 |
s size == 1 ifTrue:[
|
|
110 |
s := s first
|
|
111 |
] ifFalse:[
|
|
112 |
coll := OrderedCollection new.
|
51
|
113 |
|
53
|
114 |
s do:[:aName|
|
|
115 |
(prop := self propertyOfName:aName) notNil ifTrue:[
|
|
116 |
coll add:(prop view)
|
|
117 |
]
|
|
118 |
].
|
|
119 |
coll size == 1 ifTrue:[ ^ self select:(coll at:1) ].
|
|
120 |
coll size == 0 ifTrue:[ ^ self unselect ].
|
51
|
121 |
|
53
|
122 |
self hideSelection.
|
|
123 |
selection := coll.
|
|
124 |
self showSelection.
|
|
125 |
^ self changed:#selection
|
51
|
126 |
]
|
|
127 |
].
|
|
128 |
|
53
|
129 |
prop := self propertyOfName:s.
|
|
130 |
prop isNil ifTrue:[^ self unselect]
|
|
131 |
ifFalse:[^ self select:(prop view)]
|
51
|
132 |
|
|
133 |
! !
|
|
134 |
|
|
135 |
!UIPainterView methodsFor:'code manipulation'!
|
|
136 |
|
|
137 |
changeClass
|
|
138 |
|box classNameHolder superclassNameHolder|
|
|
139 |
|
|
140 |
classNameHolder := (className ? 'MyClass') asValue.
|
|
141 |
superclassNameHolder := (superclassName ? 'ApplicationModel') asValue.
|
|
142 |
|
|
143 |
box := DialogBox new.
|
|
144 |
box addTextLabel:'class:'.
|
|
145 |
box addInputFieldOn:classNameHolder.
|
|
146 |
box addTextLabel:'super class:'.
|
|
147 |
box addInputFieldOn:superclassNameHolder.
|
|
148 |
box addAbortButton; addOkButton.
|
|
149 |
|
|
150 |
box open.
|
|
151 |
|
|
152 |
box accepted ifTrue:[
|
|
153 |
className := classNameHolder value.
|
|
154 |
superclassName := superclassNameHolder value.
|
|
155 |
].
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
!
|
|
163 |
|
|
164 |
changeVariables
|
|
165 |
| box names propList p n newName|
|
|
166 |
|
|
167 |
names := VariableArray new.
|
|
168 |
propList := VariableArray new.
|
|
169 |
viewProperties do:[:props |
|
|
170 |
n := props name.
|
|
171 |
n notNil ifTrue:[
|
|
172 |
names add:n.
|
|
173 |
propList add:props
|
|
174 |
]
|
|
175 |
].
|
|
176 |
box := BuilderVariablesBox new.
|
|
177 |
box list:names.
|
|
178 |
box selectAction:[:selection |
|
|
179 |
p := propList at:selection
|
|
180 |
].
|
|
181 |
box okAction:[
|
|
182 |
newName := box enterValue.
|
|
183 |
Transcript showCR:('renamed ' , (p name) , 'to:' , newName).
|
|
184 |
p name:newName
|
|
185 |
].
|
|
186 |
box showAtPointer
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
! !
|
|
191 |
|
|
192 |
!UIPainterView methodsFor:'creating subviews'!
|
|
193 |
|
|
194 |
addProperties:properties for:aView
|
|
195 |
"set properties to a view and add properties to viewProperties.
|
|
196 |
In case that properties are nil properties are created
|
|
197 |
"
|
|
198 |
|name props|
|
|
199 |
|
|
200 |
(props := properties) isNil ifTrue:[
|
|
201 |
props := self propertiesForNewView:aView.
|
|
202 |
].
|
|
203 |
|
|
204 |
viewProperties add:props.
|
|
205 |
name := props name.
|
|
206 |
|
|
207 |
(aView respondsTo:#label:) ifTrue:[
|
|
208 |
aView label:name
|
|
209 |
].
|
|
210 |
aView name:name.
|
|
211 |
^ props
|
|
212 |
!
|
|
213 |
|
|
214 |
propertiesForNewView:aView
|
|
215 |
|cls props index|
|
|
216 |
|
|
217 |
cls := aView class.
|
|
218 |
|
|
219 |
props := ViewProperty new.
|
|
220 |
props view:aView.
|
|
221 |
props elementClass:cls.
|
|
222 |
index := self variableIndexForClass:cls.
|
|
223 |
props nameIndex:index.
|
|
224 |
props name:(self variableNameForClass:cls index:index).
|
|
225 |
|
|
226 |
"/ props initCode:nil. --- add user-defined init code later
|
|
227 |
|
|
228 |
^ props
|
|
229 |
!
|
|
230 |
|
|
231 |
setupCreatedObject:anObject
|
|
232 |
"set default properties for a created object
|
|
233 |
"
|
|
234 |
|props|
|
|
235 |
|
|
236 |
props := self addProperties:nil for:anObject.
|
|
237 |
|
53
|
238 |
undoHistory transaction:#create text:(props name) do:[
|
|
239 |
self undoCreate:(props identifier).
|
51
|
240 |
].
|
|
241 |
! !
|
|
242 |
|
|
243 |
!UIPainterView methodsFor:'generating output'!
|
|
244 |
|
|
245 |
generateClassDefinition
|
|
246 |
|defCode|
|
|
247 |
|
|
248 |
defCode := superclassName , ' subclass:#' , className , '\'.
|
|
249 |
defCode := defCode , ' instanceVariableNames:'''.
|
|
250 |
defCode := defCode , self subviewVariableNames , '''\'.
|
|
251 |
defCode := defCode , ' classVariableNames:''''\'.
|
|
252 |
defCode := defCode , ' poolDictionaries:''''\'.
|
|
253 |
defCode := defCode , ' category:''' , categoryName , '''\'.
|
|
254 |
defCode := defCode , Character excla asString , '\\'.
|
|
255 |
|
|
256 |
code := code , (defCode withCRs)
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
!
|
|
261 |
|
|
262 |
generateCode
|
|
263 |
code := ''.
|
|
264 |
(Smalltalk classNamed:className) isNil ifTrue:[
|
|
265 |
self generateClassDefinition.
|
|
266 |
].
|
|
267 |
"/ self generateInitMethod.
|
|
268 |
code := code , self generateWindowSpec.
|
|
269 |
self generateOutlets.
|
|
270 |
|
|
271 |
|
|
272 |
^ code withCRs
|
|
273 |
|
|
274 |
"Modified: 5.9.1995 / 20:57:53 / claus"
|
|
275 |
! !
|
|
276 |
|
|
277 |
!UIPainterView ignoredMethodsFor:'generating output'!
|
|
278 |
|
|
279 |
generateInitCodeForGroup:aGroup
|
|
280 |
|c name p objects outlets moreCode sym typ val|
|
|
281 |
|
|
282 |
" <name> := <GroupClass> in:<name-of-superview>"
|
|
283 |
|
|
284 |
p := self propertyOfGroup:aGroup.
|
|
285 |
name := p at:#variableName.
|
|
286 |
c := ' ' , name , ' := ' , (aGroup class name) , ' new.\'.
|
|
287 |
|
|
288 |
code := code , c withCRs.
|
|
289 |
|
|
290 |
" <name> <symbol>:<value>"
|
|
291 |
|
|
292 |
objects := p at:#controlledObjects ifAbsent:[nil].
|
|
293 |
objects notNil ifTrue:[
|
52
|
294 |
objects do:[:controlledObject |
|
|
295 |
c := c , name , ' add:' , (self variableNameOf:controlledObject) , '.\'
|
|
296 |
]
|
51
|
297 |
].
|
|
298 |
|
|
299 |
code := code , c withCRs
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
!
|
|
306 |
|
|
307 |
generateInitCodeForOtherStuff
|
|
308 |
|g c name p outlets moreCode sym typ val|
|
|
309 |
|
|
310 |
"generate code for groups"
|
|
311 |
|
|
312 |
viewProperties do:[:props |
|
52
|
313 |
g := props at:#group ifAbsent:[nil].
|
|
314 |
g notNil ifTrue:[
|
|
315 |
self generateInitCodeForGroup:g
|
|
316 |
]
|
51
|
317 |
]
|
|
318 |
|
|
319 |
|
|
320 |
!
|
|
321 |
|
|
322 |
generateInitCodeForView:aView
|
|
323 |
|c name p outlets moreCode sym typ val|
|
|
324 |
|
|
325 |
" <name> := <ViewClass> in:<name-of-superview>"
|
|
326 |
|
|
327 |
p := self propertyOfView:aView.
|
|
328 |
name := p at:#variableName.
|
|
329 |
c := ' ' , name , ' := ' ,
|
52
|
330 |
(aView class name) , ' in:' , (self variableNameOf:(aView superView)) , '.\'.
|
51
|
331 |
|
|
332 |
" <name> origin:(...) extent:(...)"
|
|
333 |
|
|
334 |
c := c , ' ' , name , ' origin:(', aView origin printString , ')'
|
52
|
335 |
, ' extent:(', aView extent printString , ').\'.
|
51
|
336 |
|
|
337 |
moreCode := p at:#initCode ifAbsent:nil.
|
|
338 |
moreCode notNil ifTrue:[
|
52
|
339 |
c := c , moreCode , '\' withCRs
|
51
|
340 |
].
|
|
341 |
|
|
342 |
code := code , c withCRs.
|
|
343 |
|
|
344 |
" <name> <symbol>:<value>"
|
|
345 |
|
|
346 |
outlets := p at:#outlets ifAbsent:[nil].
|
|
347 |
outlets notNil ifTrue:[
|
52
|
348 |
outlets do:[:selectorOutlet |
|
|
349 |
sym := selectorOutlet at:#selector.
|
|
350 |
typ := selectorOutlet at:#type.
|
|
351 |
val := selectorOutlet at:#value.
|
|
352 |
c := ' ' , name , ' ' , sym.
|
|
353 |
(typ == #number) ifTrue:[
|
|
354 |
c := c , val printString
|
|
355 |
].
|
|
356 |
(typ == #string) ifTrue:[
|
|
357 |
c := c , '''' , val , ''''
|
|
358 |
].
|
|
359 |
(typ == #text) ifTrue:[
|
|
360 |
c := c , '''' , val asString , ''''
|
|
361 |
].
|
|
362 |
(typ == #strings) ifTrue:[
|
|
363 |
c := c , '#( '.
|
|
364 |
val asText do:[:aString |
|
|
365 |
c := c , '''' , aString , ''' '
|
|
366 |
].
|
|
367 |
c := c , ')'
|
|
368 |
].
|
|
369 |
(typ == #block) ifTrue:[
|
|
370 |
c := c , val
|
|
371 |
].
|
|
372 |
(typ == #color) ifTrue:[
|
|
373 |
c := c , '(Color name:''' , val , ''')'
|
|
374 |
].
|
|
375 |
c := c , '.' , Character cr asString.
|
|
376 |
code := code , c
|
|
377 |
]
|
51
|
378 |
].
|
|
379 |
|
|
380 |
self subviewsOf:aView do:[:v |
|
52
|
381 |
self generateInitCodeForView:v
|
51
|
382 |
]
|
|
383 |
|
|
384 |
"Modified: 5.9.1995 / 20:06:07 / claus"
|
|
385 |
!
|
|
386 |
|
|
387 |
generateInitMethod
|
|
388 |
|defCode|
|
|
389 |
|
|
390 |
defCode := Character excla asString ,
|
52
|
391 |
className , ' methodsFor:''initialization''' ,
|
|
392 |
Character excla asString , '\\'.
|
51
|
393 |
|
|
394 |
defCode := defCode , 'initialize\'.
|
|
395 |
defCode := defCode , ' super initialize.\'.
|
|
396 |
defCode := defCode , ' self setupSubViews.\'.
|
|
397 |
defCode := defCode , ' self setupLocalStuff\'.
|
|
398 |
defCode := defCode , Character excla asString , '\\'.
|
|
399 |
|
|
400 |
defCode := defCode , 'setupSubViews\'.
|
|
401 |
code := code , defCode withCRs.
|
|
402 |
|
|
403 |
self subviewsOf:self do:[:v |
|
52
|
404 |
self generateInitCodeForView:v
|
51
|
405 |
].
|
|
406 |
|
|
407 |
self generateInitCodeForOtherStuff.
|
|
408 |
|
|
409 |
code := code , ' ^ self\' withCRs.
|
|
410 |
|
|
411 |
defCode := Character excla asString , '\\'.
|
|
412 |
defCode := defCode , 'setupLocalStuff\'.
|
|
413 |
defCode := defCode , ' ^ self\'.
|
|
414 |
defCode := defCode , Character excla asString , ' ' ,
|
52
|
415 |
Character excla asString , '\\'.
|
51
|
416 |
|
|
417 |
code := code , defCode withCRs
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
! !
|
|
424 |
|
|
425 |
!UIPainterView methodsFor:'generating output'!
|
|
426 |
|
|
427 |
generateOutlets
|
|
428 |
^ self
|
|
429 |
!
|
|
430 |
|
53
|
431 |
generateSpecFor:something
|
|
432 |
"generate a spec for a view or collection of views
|
|
433 |
"
|
|
434 |
|spec views|
|
|
435 |
|
|
436 |
something notNil ifTrue:[
|
|
437 |
something isCollection ifTrue:[views := something]
|
|
438 |
ifFalse:[views := Array with:something].
|
|
439 |
|
|
440 |
spec := views collect:[:aView||topSpec|
|
|
441 |
topSpec := aView specClass
|
|
442 |
fromView:aView
|
|
443 |
callBack:[:spec :aSubView |
|
|
444 |
"/ aSubView geometryLayout:(aSubView geometryLayout copy)
|
|
445 |
].
|
|
446 |
topSpec
|
|
447 |
]
|
|
448 |
].
|
|
449 |
^ spec
|
|
450 |
!
|
|
451 |
|
51
|
452 |
generateWindowSpec
|
|
453 |
|spec specArray str|
|
|
454 |
|
|
455 |
subViews remove:inputView.
|
|
456 |
[
|
|
457 |
spec := FullSpec fromView:self callBack:[:newSpec :view | self stuffPropertiesFrom:view intoSpec:newSpec].
|
|
458 |
] valueNowOrOnUnwindDo:[
|
|
459 |
subViews addFirst:inputView.
|
|
460 |
].
|
|
461 |
|
|
462 |
specArray := spec literalArrayEncoding.
|
|
463 |
str := WriteStream on:String new.
|
|
464 |
self prettyPrintSpecArray:specArray on:str indent:5.
|
|
465 |
|
|
466 |
code := Character excla asString
|
|
467 |
, className , ' class methodsFor:''interface specs'''
|
|
468 |
, Character excla asString , '\\'
|
|
469 |
|
|
470 |
, methodName , '\'
|
|
471 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\'
|
|
472 |
, ' "do not manually edit this - the painter/builder may not be able to\'
|
|
473 |
, ' handle the specification if its corrupted."\\'
|
|
474 |
, ' "UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '"\'
|
|
475 |
, ' "' , className , ' new openInterface:#' , methodName , '"\'.
|
|
476 |
|
|
477 |
methodName = 'windowSpec' ifTrue:[
|
|
478 |
code := code , ' "' , className , ' open"\'
|
|
479 |
].
|
|
480 |
code := code
|
|
481 |
, '\'
|
|
482 |
, ' <resource: #canvas>\\'
|
|
483 |
, ' ^\'
|
|
484 |
, ' ', str contents
|
|
485 |
, '\'
|
|
486 |
, Character excla asString
|
|
487 |
, ' '
|
|
488 |
, Character excla asString
|
|
489 |
, '\\'.
|
|
490 |
|
|
491 |
^ code withCRs
|
|
492 |
|
|
493 |
"Modified: 5.9.1995 / 21:01:35 / claus"
|
|
494 |
!
|
|
495 |
|
|
496 |
nameOfClass
|
|
497 |
^ 'NewView'
|
|
498 |
!
|
|
499 |
|
|
500 |
outletValueOf:aSymbol for:aView
|
|
501 |
"/ |c name p outlets moreCode sym typ val|
|
|
502 |
"/
|
|
503 |
"/ p := self propertyOfView:aView.
|
|
504 |
"/ outlets := p at:#outlets ifAbsent:[^ nil].
|
|
505 |
"/ outlets notNil ifTrue:[
|
|
506 |
"/ outlets do:[:selectorOutlet |
|
|
507 |
"/ sym := selectorOutlet at:#selector.
|
|
508 |
"/ (sym == aSymbol) ifTrue:[
|
|
509 |
"/ typ := selectorOutlet at:#type.
|
|
510 |
"/ val := selectorOutlet at:#value.
|
|
511 |
"/ ^ val
|
|
512 |
"/ ]
|
|
513 |
"/ ]
|
|
514 |
"/ ].
|
|
515 |
^ nil
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
!
|
|
521 |
|
|
522 |
prettyPrintSpecArray:spec on:aStream indent:i
|
|
523 |
"just for your convenience: prettyPrint a specArray to aStream - it looks better that way"
|
|
524 |
|
|
525 |
|what oneLine|
|
|
526 |
|
|
527 |
spec isArray ifFalse:[
|
|
528 |
spec isLiteral ifTrue:[
|
|
529 |
aStream nextPutAll:spec storeString
|
|
530 |
] ifFalse:[
|
|
531 |
self halt.
|
|
532 |
].
|
|
533 |
^ self
|
|
534 |
].
|
|
535 |
|
|
536 |
spec isEmpty ifTrue:[
|
|
537 |
aStream nextPutAll:'#()'.
|
|
538 |
^ self
|
|
539 |
].
|
|
540 |
|
|
541 |
what := spec at:1.
|
|
542 |
what isArray ifTrue:[
|
|
543 |
aStream cr; spaces:i+2.
|
|
544 |
aStream nextPutAll:'#('.
|
|
545 |
"/ a spec-collection
|
|
546 |
spec do:[:element |
|
|
547 |
self prettyPrintSpecArray:element on:aStream indent:i+2.
|
|
548 |
].
|
|
549 |
aStream cr.
|
|
550 |
aStream spaces:i+1.
|
|
551 |
aStream nextPutAll:')'.
|
|
552 |
^ self.
|
|
553 |
].
|
|
554 |
|
|
555 |
oneLine := false.
|
|
556 |
(#(#LayoutFrame #LayoutOrigin #AlignmentOrigin
|
|
557 |
#Rectangle #Point
|
|
558 |
#Color #ColorValue
|
|
559 |
)
|
|
560 |
includesIdentical:what) ifTrue:[
|
|
561 |
oneLine := true
|
|
562 |
].
|
|
563 |
|
|
564 |
oneLine ifFalse:[
|
|
565 |
aStream cr.
|
|
566 |
aStream spaces:i+2.
|
|
567 |
].
|
|
568 |
aStream nextPutAll:'#('.
|
|
569 |
|
|
570 |
|
|
571 |
aStream nextPutAll:what storeString.
|
|
572 |
|
|
573 |
oneLine ifFalse:[
|
|
574 |
aStream cr.
|
|
575 |
aStream spaces:i+4.
|
|
576 |
].
|
|
577 |
|
|
578 |
2 to:spec size do:[:index |
|
|
579 |
aStream space.
|
|
580 |
self prettyPrintSpecArray:(spec at:index) on:aStream indent:i+4.
|
|
581 |
oneLine ifFalse:[
|
|
582 |
(index odd and:[index ~~ (spec size)]) ifTrue:[
|
|
583 |
aStream cr; spaces:i+4.
|
|
584 |
]
|
|
585 |
]
|
|
586 |
].
|
|
587 |
oneLine ifFalse:[
|
|
588 |
aStream cr.
|
|
589 |
aStream spaces:i+1.
|
|
590 |
].
|
|
591 |
aStream nextPutAll:')'.
|
|
592 |
|
|
593 |
"Modified: 5.9.1995 / 17:44:20 / claus"
|
|
594 |
!
|
|
595 |
|
|
596 |
storeContentsOn:aStream
|
|
597 |
viewProperties do:[:p| p storeOn:aStream]
|
|
598 |
!
|
|
599 |
|
|
600 |
stuffPropertiesFrom:view intoSpec:newSpec
|
|
601 |
"stuff any additional information (held in the properties) into the spec
|
|
602 |
which was just created from view"
|
|
603 |
|
|
604 |
|props aspectSelector changeSelector labelSelector name|
|
|
605 |
|
|
606 |
props := self propertyOfView:view.
|
|
607 |
props isNil ifTrue:[^ self].
|
|
608 |
|
|
609 |
(aspectSelector := props aspectSelector) notNil ifTrue:[
|
|
610 |
newSpec model:aspectSelector
|
|
611 |
].
|
|
612 |
(changeSelector := props changeSelector) notNil ifTrue:[
|
|
613 |
newSpec change:changeSelector
|
|
614 |
].
|
|
615 |
(labelSelector := props labelSelector) notNil ifTrue:[
|
|
616 |
newSpec label:labelSelector
|
|
617 |
].
|
|
618 |
(name := props name) notNil ifTrue:[
|
|
619 |
newSpec name:name
|
|
620 |
].
|
|
621 |
|
|
622 |
!
|
|
623 |
|
|
624 |
subviewVariableNames
|
|
625 |
|names|
|
|
626 |
|
|
627 |
names := ''.
|
|
628 |
viewProperties do:[:p| names := names , ' ' , (p name)].
|
|
629 |
^ names
|
48
|
630 |
!
|
|
631 |
|
51
|
632 |
subviewsOf:aView do:aBlock
|
|
633 |
|subs v|
|
|
634 |
|
|
635 |
(subs := aView subViews) notNil ifTrue:[
|
|
636 |
subs do:[:v|
|
|
637 |
(v ~~ inputView and:[v notNil]) ifTrue:[
|
|
638 |
(viewProperties detect:[:p | p view == v] ifNone:nil) notNil ifTrue:[
|
|
639 |
(v superView == aView) ifTrue:[
|
|
640 |
aBlock value:v
|
|
641 |
]
|
|
642 |
]
|
|
643 |
]
|
|
644 |
]
|
|
645 |
]
|
|
646 |
|
|
647 |
! !
|
|
648 |
|
|
649 |
!UIPainterView methodsFor:'group manipulations'!
|
|
650 |
|
|
651 |
groupEnterFields
|
|
652 |
|props name index group objects|
|
|
653 |
|
|
654 |
selection isNil ifTrue:[^ self].
|
|
655 |
self selectionDo:[:aView |
|
|
656 |
(aView isKindOf:EditField) ifFalse:[
|
|
657 |
self warn:'select EditFields only !!'.
|
|
658 |
^ self
|
|
659 |
]
|
|
660 |
].
|
|
661 |
self selectionHiddenDo:[
|
|
662 |
group := EnterFieldGroup new.
|
|
663 |
|
|
664 |
props := GroupProperties new.
|
|
665 |
props elementClass:EnterFieldGroup.
|
|
666 |
props group:group.
|
|
667 |
index := self variableIndexForClass:EnterFieldGroup.
|
|
668 |
props nameIndex:index.
|
|
669 |
name := self variableNameForClass:EnterFieldGroup index:index.
|
|
670 |
props name:name.
|
|
671 |
objects := OrderedCollection new.
|
|
672 |
props controlledObjects:objects.
|
|
673 |
viewProperties add:props.
|
|
674 |
|
|
675 |
self selectionDo:[:aView |
|
|
676 |
objects add:aView.
|
|
677 |
group add:aView
|
|
678 |
].
|
|
679 |
]
|
|
680 |
|
|
681 |
|
|
682 |
!
|
|
683 |
|
|
684 |
groupRadioButtons
|
|
685 |
|props name index group objects|
|
|
686 |
|
|
687 |
selection isNil ifTrue:[^ self].
|
|
688 |
self selectionDo:[:aView |
|
|
689 |
(aView isKindOf:RadioButton) ifFalse:[
|
|
690 |
self warn:'select RadioButtons only !!'.
|
|
691 |
^ self
|
|
692 |
]
|
|
693 |
].
|
|
694 |
self selectionHiddenDo:[
|
|
695 |
group := RadioButtonGroup new.
|
|
696 |
|
|
697 |
props := GroupProperties new.
|
|
698 |
props elementClass:RadioButtonGroup.
|
|
699 |
props group:group.
|
|
700 |
index := self variableIndexForClass:RadioButtonGroup.
|
|
701 |
props nameIndex:index.
|
|
702 |
name := self variableNameForClass:RadioButtonGroup index:index.
|
|
703 |
props name:name.
|
|
704 |
group groupID:name asSymbol.
|
|
705 |
objects := OrderedCollection new.
|
|
706 |
props controlledObjects:objects.
|
|
707 |
viewProperties add:props.
|
|
708 |
|
|
709 |
self selectionDo:[:aView |
|
|
710 |
aView turnOff.
|
|
711 |
objects add:aView.
|
|
712 |
group add:aView
|
|
713 |
].
|
|
714 |
]
|
|
715 |
|
|
716 |
"Modified: 5.9.1995 / 16:06:15 / claus"
|
|
717 |
! !
|
|
718 |
|
|
719 |
!UIPainterView methodsFor:'initialization'!
|
|
720 |
|
|
721 |
initialize
|
|
722 |
super initialize.
|
|
723 |
|
|
724 |
superclassName := 'ApplicationModel'.
|
|
725 |
className := 'NewApplication'.
|
|
726 |
methodName := 'windowSpec'.
|
|
727 |
categoryName := 'Applications'.
|
|
728 |
|
|
729 |
viewProperties := OrderedCollection new.
|
|
730 |
HandCursor := Cursor leftHand.
|
|
731 |
|
|
732 |
"Modified: 5.9.1995 / 19:58:06 / claus"
|
|
733 |
! !
|
|
734 |
|
|
735 |
!UIPainterView methodsFor:'interface to Builder'!
|
|
736 |
|
|
737 |
addOutletDefinitionFor:outletSymbol type:type value:outletValue for:aView
|
|
738 |
|outletProps selectorProps viewProps|
|
|
739 |
|
|
740 |
viewProps := self propertyOfView:aView.
|
|
741 |
"/ outletProps := viewProps at:#outlets ifAbsent:[nil].
|
|
742 |
"/ outletProps isNil ifTrue:[
|
|
743 |
"/ outletProps := Dictionary new.
|
|
744 |
"/ viewProps at:#outlets put:outletProps
|
|
745 |
"/ ].
|
|
746 |
"/ selectorProps := outletProps at:outletSymbol ifAbsent:[nil].
|
|
747 |
"/ selectorProps isNil ifTrue:[
|
|
748 |
"/ selectorProps := Dictionary new.
|
|
749 |
"/ outletProps at:outletSymbol put:selectorProps
|
|
750 |
"/ ].
|
|
751 |
"/
|
|
752 |
"/ selectorProps at:#selector put:outletSymbol.
|
|
753 |
"/ selectorProps at:#type put:type.
|
|
754 |
"/ selectorProps at:#value put:outletValue
|
|
755 |
|
|
756 |
!
|
|
757 |
|
|
758 |
addSpec:specOrSpecArray
|
|
759 |
|spec builder|
|
|
760 |
|
|
761 |
spec := UISpecification from:specOrSpecArray.
|
|
762 |
|
|
763 |
builder := UIBuilder new.
|
|
764 |
builder componentCreationHook:[:view :spec :aBuilder |
|
|
765 |
self createdComponent:view forSpec:spec
|
|
766 |
].
|
|
767 |
builder applicationClass:(Smalltalk classNamed:className).
|
|
768 |
spec setupView:self for:builder.
|
|
769 |
self realizeAllSubViews.
|
|
770 |
inputView raise.
|
|
771 |
|
|
772 |
"/ viewProperties := OrderedCollection new.
|
|
773 |
"/ self generatePropertiesFor:(self subViews select:[:v | v ~~ inputView]).
|
|
774 |
|
|
775 |
self changed:#tree.
|
|
776 |
|
|
777 |
|
|
778 |
"Modified: 5.9.1995 / 23:36:55 / claus"
|
|
779 |
!
|
|
780 |
|
|
781 |
applicationName
|
|
782 |
^ className
|
|
783 |
!
|
|
784 |
|
53
|
785 |
aspectAt:aSymbol
|
|
786 |
self halt.
|
|
787 |
^ nil
|
|
788 |
|
|
789 |
"Modified: 6.9.1995 / 00:45:35 / claus"
|
|
790 |
!
|
|
791 |
|
51
|
792 |
aspectSelectorForView:aView
|
|
793 |
|props aspect|
|
|
794 |
|
|
795 |
props := self propertyOfView:aView.
|
|
796 |
props isNil ifTrue:[^ nil].
|
|
797 |
^ props aspectSelector
|
|
798 |
|
|
799 |
!
|
|
800 |
|
|
801 |
changeSelectorForView:aView
|
|
802 |
|props aspect|
|
|
803 |
|
|
804 |
props := self propertyOfView:aView.
|
|
805 |
props isNil ifTrue:[^ nil].
|
|
806 |
"/ ^ props changeSelector
|
|
807 |
^ nil
|
|
808 |
!
|
|
809 |
|
53
|
810 |
createdComponent:newView forSpec:aSpec
|
|
811 |
"callBack from UISpec view building"
|
|
812 |
|
|
813 |
|props|
|
|
814 |
|
|
815 |
props := self propertiesForNewView:newView.
|
|
816 |
|
|
817 |
aSpec name notNil ifTrue:[
|
|
818 |
(self propertyOfName:(aSpec name)) isNil ifTrue:[
|
|
819 |
props name:aSpec name
|
|
820 |
]
|
|
821 |
].
|
|
822 |
|
|
823 |
props labelSelector:(aSpec labelSelector).
|
|
824 |
props aspectSelector:(aSpec modelSelector).
|
|
825 |
|
|
826 |
viewProperties add:props.
|
|
827 |
!
|
|
828 |
|
51
|
829 |
generatePropertiesFor:aCollectionOfViews
|
|
830 |
|
|
831 |
"/ done as two loops, to get bread-first naming
|
|
832 |
|
|
833 |
aCollectionOfViews do:[:aView|
|
|
834 |
|props|
|
|
835 |
|
|
836 |
props := self propertiesForNewView:aView.
|
|
837 |
viewProperties add:props.
|
|
838 |
aView name:(props name).
|
|
839 |
|
|
840 |
aView geometryLayout isNil ifTrue:[
|
|
841 |
aView geometryLayout:(aView bounds asLayout).
|
|
842 |
]
|
|
843 |
].
|
|
844 |
|
|
845 |
aCollectionOfViews do:[:aView |
|
|
846 |
|subs|
|
|
847 |
|
|
848 |
subs := aView subViews.
|
|
849 |
subs notNil ifTrue:[
|
|
850 |
self generatePropertiesFor:subs
|
|
851 |
]
|
|
852 |
].
|
|
853 |
|
|
854 |
!
|
|
855 |
|
|
856 |
inspectAttributes
|
|
857 |
|p|
|
|
858 |
|
|
859 |
self singleSelectionDo:[:aView |
|
|
860 |
p := self propertyOfView:aView.
|
|
861 |
p inspect
|
|
862 |
]
|
|
863 |
!
|
|
864 |
|
|
865 |
setAspectSelector:aspectSymbol forView:aView
|
|
866 |
|props|
|
|
867 |
|
|
868 |
props := self propertyOfView:aView.
|
|
869 |
|
53
|
870 |
props notNil ifTrue:[
|
|
871 |
self transaction:#aspect selectionDo:[:aView|
|
|
872 |
|oldAspect|
|
|
873 |
|
|
874 |
oldAspect := props aspectSelector.
|
51
|
875 |
|
53
|
876 |
undoHistory addUndoBlock:[
|
|
877 |
props aspectSelector:oldAspect.
|
|
878 |
aView superView sizeChanged:nil
|
|
879 |
]
|
51
|
880 |
].
|
53
|
881 |
props aspectSelector:aspectSymbol
|
|
882 |
]
|
51
|
883 |
!
|
|
884 |
|
|
885 |
setChangeSelector:changeSymbol forView:aView
|
|
886 |
|props|
|
|
887 |
|
|
888 |
props := self propertyOfView:aView.
|
53
|
889 |
props notNil ifTrue:[
|
|
890 |
props changeSelector:changeSymbol
|
|
891 |
]
|
51
|
892 |
!
|
|
893 |
|
|
894 |
setupFromSpec:specOrSpecArray
|
|
895 |
self removeAll.
|
|
896 |
self addSpec:specOrSpecArray
|
|
897 |
!
|
|
898 |
|
|
899 |
showFontPanel
|
|
900 |
|action|
|
|
901 |
|
|
902 |
fontPanel isNil ifTrue:[
|
52
|
903 |
fontPanel := FontPanel new
|
51
|
904 |
].
|
|
905 |
|
|
906 |
selection notNil ifTrue:[
|
52
|
907 |
action := [:family :face :style :size |
|
|
908 |
self changeFontFamily:family face:face
|
|
909 |
style:style size:size
|
|
910 |
].
|
|
911 |
fontPanel action:action.
|
|
912 |
fontPanel showAtPointer
|
51
|
913 |
]
|
|
914 |
! !
|
|
915 |
|
53
|
916 |
!UIPainterView methodsFor:'menu & submenus'!
|
|
917 |
|
|
918 |
menu
|
|
919 |
testMode ifFalse:[
|
|
920 |
selection notNil ifTrue:[^ self menuSelection ]
|
|
921 |
ifFalse:[^ self menuPainter ]
|
|
922 |
].
|
|
923 |
^ nil
|
|
924 |
!
|
|
925 |
|
|
926 |
menuPainter
|
|
927 |
"menu in case of non empty selection; for views
|
|
928 |
"
|
|
929 |
|menu gridMenu|
|
|
930 |
|
|
931 |
menu := PopUpMenu labels:(
|
|
932 |
resources array:#(
|
|
933 |
'paste'
|
|
934 |
'-'
|
|
935 |
'undo'
|
|
936 |
'grid'
|
|
937 |
)
|
|
938 |
)
|
|
939 |
selectors:#(
|
|
940 |
#pasteBuffer
|
|
941 |
nil
|
|
942 |
#undo
|
|
943 |
#grid
|
|
944 |
)
|
|
945 |
receiver:self.
|
|
946 |
|
|
947 |
|
|
948 |
undoHistory isEmpty ifTrue:[
|
|
949 |
menu disable:#undo
|
|
950 |
] ifFalse:[
|
|
951 |
menu subMenuAt:#undo put:(undoHistory popupMenu)
|
|
952 |
].
|
|
953 |
|
|
954 |
gridMenu := PopUpMenu labels:(
|
|
955 |
resources array:#(
|
|
956 |
'\c show'
|
|
957 |
'\c align'
|
|
958 |
)
|
|
959 |
)
|
|
960 |
selectors:#(
|
|
961 |
#gridShown:
|
|
962 |
#gridAlign:
|
|
963 |
).
|
|
964 |
|
|
965 |
gridMenu checkToggleAt:#gridShown: put:(self gridShown).
|
|
966 |
gridMenu checkToggleAt:#gridAlign: put:aligning.
|
|
967 |
menu subMenuAt:#grid put:gridMenu.
|
|
968 |
|
|
969 |
^ menu
|
|
970 |
|
|
971 |
|
|
972 |
!
|
|
973 |
|
|
974 |
menuSelection
|
|
975 |
"menu in case of non empty selection; for views
|
|
976 |
"
|
|
977 |
|menu arrangeMenu subMenuAlign|
|
|
978 |
|
|
979 |
menu := PopUpMenu labels:( resources array:#(
|
|
980 |
'copy'
|
|
981 |
'cut'
|
|
982 |
'paste'
|
|
983 |
'-'
|
|
984 |
'arrange'
|
|
985 |
'dimension'
|
|
986 |
)
|
|
987 |
)
|
|
988 |
selectors:#( #copySelection
|
|
989 |
#deleteSelection
|
|
990 |
#pasteBuffer
|
|
991 |
nil
|
|
992 |
#arrange
|
|
993 |
#dimension
|
|
994 |
)
|
|
995 |
receiver:self.
|
|
996 |
|
|
997 |
(self supportsSubComponents:selection) ifFalse:[
|
|
998 |
menu disable:#pasteBuffer
|
|
999 |
].
|
|
1000 |
|
|
1001 |
arrangeMenu := PopUpMenu labels:#( 'to front' 'to back' )
|
|
1002 |
selectors:#( #raiseSelection #lowerSelection )
|
|
1003 |
receiver:self.
|
|
1004 |
|
|
1005 |
|
|
1006 |
menu subMenuAt:#arrange put:arrangeMenu.
|
|
1007 |
menu subMenuAt:#dimension put:(self subMenuDimension).
|
|
1008 |
|
|
1009 |
selection size > 1 ifTrue:[
|
|
1010 |
menu addLabels:( resources array:#('align') )
|
|
1011 |
selectors:#( align ).
|
|
1012 |
|
|
1013 |
menu subMenuAt:#align put:self subMenuAlign
|
|
1014 |
].
|
|
1015 |
^ menu
|
|
1016 |
!
|
|
1017 |
|
|
1018 |
subMenuAlign
|
|
1019 |
"returns submenu alignment
|
|
1020 |
"
|
|
1021 |
|menu|
|
|
1022 |
|
|
1023 |
menu := PopUpMenu labels:(
|
|
1024 |
resources array:#(
|
|
1025 |
'align left'
|
|
1026 |
'align right'
|
|
1027 |
'align left & right'
|
|
1028 |
'align top'
|
|
1029 |
'align bottom'
|
|
1030 |
'align centered vertical'
|
|
1031 |
'align centered horizontal'
|
|
1032 |
'-'
|
|
1033 |
'spread horizontal'
|
|
1034 |
'spread vertical'
|
|
1035 |
'center horizontal in frame'
|
|
1036 |
'center vertical in frame'
|
|
1037 |
)
|
|
1038 |
)
|
|
1039 |
|
|
1040 |
selectors:#(
|
|
1041 |
alignSelectionLeft
|
|
1042 |
alignSelectionRight
|
|
1043 |
alignSelectionLeftAndRight
|
|
1044 |
alignSelectionTop
|
|
1045 |
alignSelectionBottom
|
|
1046 |
alignSelectionCenterHor
|
|
1047 |
alignSelectionCenterVer
|
|
1048 |
nil
|
|
1049 |
spreadSelectionHor
|
|
1050 |
spreadSelectionVer
|
|
1051 |
centerSelectionHor
|
|
1052 |
centerSelectionVer
|
|
1053 |
)
|
|
1054 |
receiver:self.
|
|
1055 |
^ menu
|
|
1056 |
|
|
1057 |
!
|
|
1058 |
|
|
1059 |
subMenuDimension
|
|
1060 |
"returns submenu dimension
|
|
1061 |
"
|
|
1062 |
|menu|
|
|
1063 |
|
|
1064 |
menu := PopUpMenu labels:(
|
|
1065 |
resources array:#(
|
|
1066 |
'default extent'
|
|
1067 |
'default width'
|
|
1068 |
'default height'
|
|
1069 |
'-'
|
|
1070 |
'copy extent'
|
|
1071 |
'-'
|
|
1072 |
'paste extent'
|
|
1073 |
'paste width'
|
|
1074 |
'paste height'
|
|
1075 |
)
|
|
1076 |
)
|
|
1077 |
selectors:#(
|
|
1078 |
setToDefaultExtent
|
|
1079 |
setToDefaultWidth
|
|
1080 |
setToDefaultHeight
|
|
1081 |
nil
|
|
1082 |
copyExtent
|
|
1083 |
nil
|
|
1084 |
pasteExtent
|
|
1085 |
pasteWidth
|
|
1086 |
pasteHeight
|
|
1087 |
)
|
|
1088 |
receiver:self.
|
|
1089 |
^ menu
|
|
1090 |
! !
|
|
1091 |
|
|
1092 |
!UIPainterView methodsFor:'menu actions'!
|
|
1093 |
|
|
1094 |
copySelection
|
|
1095 |
"copy the selection into the cut&paste-buffer
|
|
1096 |
"
|
|
1097 |
|specs|
|
|
1098 |
|
|
1099 |
specs := self generateSpecFor:selection.
|
|
1100 |
|
|
1101 |
specs notNil ifTrue:[
|
|
1102 |
self setSelection:specs
|
|
1103 |
].
|
|
1104 |
self unselect.
|
|
1105 |
!
|
|
1106 |
|
|
1107 |
deleteSelection
|
|
1108 |
"delete the selection
|
|
1109 |
"
|
|
1110 |
|specs text|
|
|
1111 |
|
|
1112 |
selection notNil ifTrue:[
|
|
1113 |
specs := self generateSpecFor:selection.
|
|
1114 |
text := self transactionTextFor:selection.
|
|
1115 |
|
|
1116 |
undoHistory transaction:#cut text:text do:[
|
|
1117 |
super deleteSelection
|
|
1118 |
].
|
|
1119 |
self setSelection:specs
|
|
1120 |
]
|
|
1121 |
!
|
|
1122 |
|
|
1123 |
gridAlign:aBool
|
|
1124 |
aBool ifTrue:[self alignOn]
|
|
1125 |
ifFalse:[self alignOff]
|
|
1126 |
!
|
|
1127 |
|
|
1128 |
gridShown:aBool
|
|
1129 |
aBool ifTrue:[self showGrid]
|
|
1130 |
ifFalse:[self hideGrid]
|
|
1131 |
|
|
1132 |
!
|
|
1133 |
|
|
1134 |
lowerSelection
|
|
1135 |
|
|
1136 |
self selectionDo:[:aView| aView lower ].
|
|
1137 |
!
|
|
1138 |
|
|
1139 |
pasteBuffer
|
|
1140 |
"add the objects in the paste-buffer
|
|
1141 |
"
|
|
1142 |
|sel firstEntry builder frame|
|
|
1143 |
|
|
1144 |
sel := self getSelection.
|
|
1145 |
frame := self.
|
|
1146 |
|
|
1147 |
selection notNil ifTrue:[
|
|
1148 |
(self supportsSubComponents:selection) ifTrue:[
|
|
1149 |
frame := selection
|
|
1150 |
].
|
|
1151 |
self unselect
|
|
1152 |
].
|
|
1153 |
|
|
1154 |
sel size == 0 ifTrue:[firstEntry := sel]
|
|
1155 |
ifFalse:[firstEntry := sel at:1].
|
|
1156 |
|
|
1157 |
(firstEntry isKindOf:UISpecification) ifFalse:[
|
|
1158 |
^ self
|
|
1159 |
].
|
|
1160 |
builder := UIBuilder new.
|
|
1161 |
selection := OrderedCollection new.
|
|
1162 |
|
|
1163 |
sel do:[:aSpec||v|
|
|
1164 |
builder componentCreationHook:[:view :spec :aBuilder |
|
|
1165 |
self createdComponent:view forSpec:spec
|
|
1166 |
].
|
|
1167 |
builder applicationClass:(Smalltalk classNamed:className).
|
|
1168 |
v := aSpec buildViewWithLayoutFor:builder in:frame.
|
|
1169 |
v realize.
|
|
1170 |
selection add:v.
|
|
1171 |
].
|
|
1172 |
|
|
1173 |
self transaction:#paste selectionDo:[:v|
|
|
1174 |
self undoCreate:((self propertyOfView:v) identifier)
|
|
1175 |
].
|
|
1176 |
selection size == 1 ifTrue:[
|
|
1177 |
selection := selection at:1
|
|
1178 |
].
|
|
1179 |
self showSelection.
|
|
1180 |
self realizeAllSubViews.
|
|
1181 |
inputView raise.
|
|
1182 |
self changed:#tree
|
|
1183 |
|
|
1184 |
!
|
|
1185 |
|
|
1186 |
raiseSelection
|
|
1187 |
|
|
1188 |
self selectionDo:[:aView|
|
|
1189 |
aView raise.
|
|
1190 |
inputView raise.
|
|
1191 |
].
|
|
1192 |
|
|
1193 |
! !
|
|
1194 |
|
51
|
1195 |
!UIPainterView methodsFor:'misc'!
|
|
1196 |
|
|
1197 |
changeFontFamily:family face:face style:style size:size
|
|
1198 |
|f|
|
|
1199 |
|
|
1200 |
f := Font family:family
|
|
1201 |
face:face
|
|
1202 |
style:style
|
|
1203 |
size:size.
|
|
1204 |
|
|
1205 |
f notNil ifTrue:[
|
|
1206 |
self selectionHiddenDo:[
|
|
1207 |
self selectionDo:[:aView |
|
|
1208 |
aView font:f.
|
|
1209 |
self elementChanged:aView.
|
|
1210 |
]
|
|
1211 |
]
|
|
1212 |
]
|
|
1213 |
|
|
1214 |
"Modified: 5.9.1995 / 12:13:27 / claus"
|
|
1215 |
!
|
|
1216 |
|
|
1217 |
changeVariableNameOf:aView to:newName
|
|
1218 |
|prop|
|
|
1219 |
|
|
1220 |
prop := self propertyOf:aView.
|
|
1221 |
|
|
1222 |
prop isNil ifTrue:[
|
|
1223 |
^ self error:'no such view'
|
|
1224 |
].
|
|
1225 |
|
|
1226 |
((aView respondsTo:#label:) and:[aView label = prop name]) ifTrue:[
|
|
1227 |
self selectionHiddenDo:[
|
|
1228 |
|layout|
|
|
1229 |
layout := aView geometryLayout copy.
|
|
1230 |
aView label:newName.
|
|
1231 |
aView geometryLayout:layout.
|
|
1232 |
]
|
|
1233 |
].
|
|
1234 |
|
|
1235 |
prop name:newName.
|
|
1236 |
aView name:newName.
|
|
1237 |
self changed:#widgetName
|
|
1238 |
|
|
1239 |
|
|
1240 |
|
|
1241 |
!
|
|
1242 |
|
|
1243 |
variableIndexForClass:aClass
|
|
1244 |
|max|
|
|
1245 |
|
|
1246 |
max := 0.
|
|
1247 |
|
|
1248 |
viewProperties do:[:p|
|
|
1249 |
p elementClass == aClass ifTrue:[
|
|
1250 |
max := max max:(p nameIndex)
|
|
1251 |
]
|
|
1252 |
].
|
|
1253 |
^ max + 1
|
|
1254 |
|
|
1255 |
!
|
|
1256 |
|
|
1257 |
variableNameForClass:aClass index:index
|
|
1258 |
|n|
|
|
1259 |
|
|
1260 |
n := (aClass name) , index printString.
|
|
1261 |
n at:1 put:(n at:1) asLowercase.
|
|
1262 |
^ n
|
|
1263 |
|
|
1264 |
!
|
|
1265 |
|
|
1266 |
variableNameOf:aView
|
|
1267 |
|prop|
|
|
1268 |
|
|
1269 |
aView notNil ifTrue:[
|
|
1270 |
prop := self propertyOf:aView
|
|
1271 |
].
|
|
1272 |
|
|
1273 |
prop notNil ifTrue:[^ prop name]
|
|
1274 |
ifFalse:[^ 'self']
|
|
1275 |
|
|
1276 |
! !
|
|
1277 |
|
|
1278 |
!UIPainterView methodsFor:'removing components'!
|
|
1279 |
|
|
1280 |
remove:something
|
|
1281 |
"remove something, anObject or a collection of objects from the contents
|
|
1282 |
do redraw"
|
|
1283 |
|
|
1284 |
self forEach:something do:[:anObject |
|
52
|
1285 |
self removeObject:anObject
|
51
|
1286 |
]
|
|
1287 |
|
|
1288 |
|
|
1289 |
!
|
|
1290 |
|
|
1291 |
removeAll
|
|
1292 |
"remove the argument, anObject"
|
|
1293 |
|
|
1294 |
self unselect.
|
|
1295 |
|
|
1296 |
subViews notNil ifTrue:[
|
|
1297 |
subViews copy do:[:sub |
|
|
1298 |
sub ~~ inputView ifTrue:[
|
|
1299 |
self removeTreeFrom:sub
|
|
1300 |
]
|
|
1301 |
]
|
|
1302 |
].
|
|
1303 |
|
|
1304 |
viewProperties := OrderedCollection new.
|
|
1305 |
undoHistory reinitialize.
|
|
1306 |
self changed:#tree
|
|
1307 |
!
|
|
1308 |
|
|
1309 |
removeObject:anObject
|
|
1310 |
"remove the argument, anObject"
|
|
1311 |
|
|
1312 |
self removeTreeFrom:anObject.
|
|
1313 |
self changed:#tree
|
|
1314 |
|
|
1315 |
"Modified: 5.9.1995 / 20:51:28 / claus"
|
|
1316 |
!
|
|
1317 |
|
|
1318 |
removeTreeFrom:anObject
|
|
1319 |
"remove the argument, anObject and all of its children
|
|
1320 |
"
|
|
1321 |
|props|
|
|
1322 |
|
|
1323 |
anObject notNil ifTrue:[
|
|
1324 |
(anObject subViews notNil) ifTrue:[
|
|
1325 |
anObject subViews copy do:[:sub |
|
|
1326 |
self removeTreeFrom:sub
|
|
1327 |
]
|
|
1328 |
].
|
|
1329 |
props := self propertyOf:anObject.
|
53
|
1330 |
|
|
1331 |
props notNil ifTrue:[
|
|
1332 |
self undoRemove:props.
|
|
1333 |
viewProperties remove:props
|
|
1334 |
].
|
51
|
1335 |
anObject destroy
|
|
1336 |
]
|
|
1337 |
! !
|
|
1338 |
|
53
|
1339 |
!UIPainterView methodsFor:'searching'!
|
51
|
1340 |
|
53
|
1341 |
findObjectAt:aPoint
|
|
1342 |
"find the origin/corner of the currentWidget
|
|
1343 |
"
|
|
1344 |
|view|
|
51
|
1345 |
|
53
|
1346 |
view := super findObjectAt:aPoint.
|
51
|
1347 |
|
53
|
1348 |
view notNil ifTrue:[
|
|
1349 |
"can be a view within a view not visible
|
|
1350 |
"
|
|
1351 |
[ (self propertyOfView:view) isNil ] whileTrue:[
|
|
1352 |
(view := view superView) == self ifTrue:[^ nil]
|
51
|
1353 |
]
|
|
1354 |
].
|
53
|
1355 |
^ view
|
51
|
1356 |
! !
|
|
1357 |
|
|
1358 |
!UIPainterView methodsFor:'seraching property'!
|
|
1359 |
|
|
1360 |
propertyOf:something
|
|
1361 |
|
|
1362 |
^ viewProperties detect:[:p| (p view == something or:[p group == something])]
|
|
1363 |
ifNone:nil
|
|
1364 |
|
|
1365 |
|
|
1366 |
|
|
1367 |
|
|
1368 |
|
|
1369 |
!
|
|
1370 |
|
|
1371 |
propertyOfGroup:aGroup
|
|
1372 |
|
|
1373 |
^ viewProperties detect:[:p| p group == aGroup] ifNone:nil
|
|
1374 |
!
|
|
1375 |
|
|
1376 |
propertyOfIdentifier:anIdentifier
|
|
1377 |
|
|
1378 |
^ viewProperties detect:[:p| p identifier == anIdentifier] ifNone:nil.
|
|
1379 |
!
|
|
1380 |
|
|
1381 |
propertyOfName:aString
|
|
1382 |
|
|
1383 |
aString = 'self' ifFalse:[
|
|
1384 |
^ viewProperties detect:[:p| p name = aString] ifNone:nil
|
|
1385 |
].
|
|
1386 |
^ nil
|
|
1387 |
!
|
|
1388 |
|
|
1389 |
propertyOfView:aView
|
|
1390 |
|
|
1391 |
aView == self ifFalse:[
|
|
1392 |
^ viewProperties detect:[:p| p view == aView] ifNone:nil
|
|
1393 |
].
|
|
1394 |
^ nil
|
|
1395 |
! !
|
|
1396 |
|
|
1397 |
!UIPainterView methodsFor:'testing'!
|
|
1398 |
|
|
1399 |
isHorizontalResizable:aComponent
|
|
1400 |
|
|
1401 |
(aComponent isKindOf:ScrollBar) ifTrue:[
|
|
1402 |
^ aComponent orientation == #horizontal
|
|
1403 |
].
|
|
1404 |
(aComponent isKindOf:Scroller) ifTrue:[
|
|
1405 |
^ aComponent orientation == #horizontal
|
|
1406 |
].
|
|
1407 |
(aComponent isKindOf:Slider) ifTrue:[
|
|
1408 |
^ aComponent orientation == #horizontal
|
|
1409 |
].
|
|
1410 |
^ true
|
|
1411 |
|
|
1412 |
|
|
1413 |
!
|
|
1414 |
|
|
1415 |
isVerticalResizable:aComponent
|
|
1416 |
|
|
1417 |
(aComponent isKindOf:EditField) ifTrue:[
|
|
1418 |
^ false
|
|
1419 |
].
|
53
|
1420 |
(aComponent isKindOf:ComboBoxView) ifTrue:[
|
|
1421 |
^ false
|
|
1422 |
].
|
|
1423 |
(aComponent isKindOf:CheckBox) ifTrue:[
|
|
1424 |
^ false
|
|
1425 |
].
|
51
|
1426 |
(aComponent isKindOf:ScrollBar) ifTrue:[
|
|
1427 |
^ aComponent orientation == #vertical
|
|
1428 |
].
|
|
1429 |
(aComponent isKindOf:Scroller) ifTrue:[
|
|
1430 |
^ aComponent orientation == #vertical
|
|
1431 |
].
|
|
1432 |
(aComponent isKindOf:Slider) ifTrue:[
|
|
1433 |
^ aComponent orientation == #vertical
|
|
1434 |
].
|
|
1435 |
^ true
|
|
1436 |
|
|
1437 |
|
|
1438 |
! !
|
|
1439 |
|
53
|
1440 |
!UIPainterView methodsFor:'transaction & undo'!
|
|
1441 |
|
|
1442 |
transaction:aType objects:something do:aOneArgBlock
|
|
1443 |
"opens a transaction and evaluates a block within the transaction; the
|
|
1444 |
argument to the block is a view from derived from something
|
|
1445 |
"
|
|
1446 |
|text|
|
|
1447 |
|
|
1448 |
something notNil ifTrue:[
|
|
1449 |
text := self transactionTextFor:something.
|
|
1450 |
|
|
1451 |
undoHistory transaction:aType text:text do:[
|
|
1452 |
something isCollection ifTrue:[
|
|
1453 |
something do:[:aView| aOneArgBlock value:aView ]
|
|
1454 |
] ifFalse:[
|
|
1455 |
aOneArgBlock value:something
|
|
1456 |
]
|
|
1457 |
]
|
|
1458 |
]
|
|
1459 |
!
|
|
1460 |
|
|
1461 |
transactionTextFor:anElementOrCollection
|
|
1462 |
"returns text used by transaction or nil
|
|
1463 |
"
|
|
1464 |
|props|
|
|
1465 |
|
|
1466 |
anElementOrCollection notNil ifTrue:[
|
|
1467 |
anElementOrCollection size > 1 ifTrue:[
|
|
1468 |
^ 'a collection'
|
|
1469 |
].
|
|
1470 |
|
|
1471 |
anElementOrCollection isCollection ifFalse:[
|
|
1472 |
props := self propertyOfView:anElementOrCollection
|
|
1473 |
] ifTrue:[
|
|
1474 |
anElementOrCollection notEmpty ifTrue:[
|
|
1475 |
props := self propertyOfView:(anElementOrCollection at:1)
|
|
1476 |
]
|
|
1477 |
].
|
|
1478 |
|
|
1479 |
props notNil ifTrue:[
|
|
1480 |
^ props name
|
|
1481 |
]
|
|
1482 |
].
|
|
1483 |
^ nil
|
|
1484 |
!
|
|
1485 |
|
|
1486 |
undoCreate:aViewIdentifier
|
|
1487 |
|
|
1488 |
undoHistory isTransactionOpen ifTrue:[
|
|
1489 |
undoHistory addUndoBlock:[
|
|
1490 |
|props|
|
|
1491 |
|
|
1492 |
props := self propertyOfIdentifier:aViewIdentifier.
|
|
1493 |
|
|
1494 |
props notNil ifTrue:[
|
|
1495 |
self removeObject:(props view)
|
|
1496 |
]
|
|
1497 |
]
|
|
1498 |
]
|
|
1499 |
!
|
|
1500 |
|
|
1501 |
undoRemove:propertyOfView
|
|
1502 |
|clsName layout parent aView|
|
|
1503 |
|
|
1504 |
(propertyOfView notNil and:[undoHistory isTransactionOpen]) ifFalse:[
|
|
1505 |
^ self
|
|
1506 |
].
|
|
1507 |
|
|
1508 |
aView := propertyOfView view.
|
|
1509 |
clsName := aView class.
|
|
1510 |
layout := aView geometryLayout.
|
|
1511 |
parent := aView superView.
|
|
1512 |
|
|
1513 |
parent ~~ self ifTrue:[
|
|
1514 |
parent := (self propertyOf:parent) identifier.
|
|
1515 |
] ifFalse:[
|
|
1516 |
parent := nil
|
|
1517 |
].
|
|
1518 |
propertyOfView view:nil.
|
|
1519 |
|
|
1520 |
undoHistory addUndoBlock:[
|
|
1521 |
|recreatedView props|
|
|
1522 |
|
|
1523 |
parent notNil ifTrue:[
|
|
1524 |
props := self propertyOfIdentifier:parent.
|
|
1525 |
|
|
1526 |
props notNil ifTrue:[parent := props view]
|
|
1527 |
ifFalse:[parent := self]
|
|
1528 |
] ifFalse:[
|
|
1529 |
parent := self
|
|
1530 |
].
|
|
1531 |
|
|
1532 |
recreatedView := clsName in:parent.
|
|
1533 |
recreatedView geometryLayout:layout.
|
|
1534 |
propertyOfView view:recreatedView.
|
|
1535 |
self addProperties:propertyOfView for:recreatedView.
|
|
1536 |
recreatedView realize.
|
|
1537 |
inputView raise.
|
|
1538 |
].
|
|
1539 |
aView := nil.
|
|
1540 |
|
|
1541 |
! !
|
|
1542 |
|
51
|
1543 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'!
|
|
1544 |
|
|
1545 |
new
|
|
1546 |
Identifier notNil ifTrue:[Identifier := Identifier + 1]
|
|
1547 |
ifFalse:[Identifier := 1].
|
|
1548 |
|
|
1549 |
^ self basicNew initialize
|
|
1550 |
! !
|
|
1551 |
|
|
1552 |
!UIPainterView::ViewProperty methodsFor:'accessing'!
|
|
1553 |
|
|
1554 |
aspectSelector
|
|
1555 |
"return the value of the instance variable 'aspectSelector' (automatically generated)"
|
|
1556 |
|
|
1557 |
^ aspectSelector
|
|
1558 |
!
|
|
1559 |
|
|
1560 |
aspectSelector:something
|
|
1561 |
"set the value of the instance variable 'aspectSelector' (automatically generated)"
|
|
1562 |
|
|
1563 |
aspectSelector := something.
|
|
1564 |
!
|
|
1565 |
|
|
1566 |
changeSelector
|
|
1567 |
"return the value of the instance variable 'changeSelector' (automatically generated)"
|
|
1568 |
|
|
1569 |
^ changeSelector!
|
|
1570 |
|
|
1571 |
changeSelector:something
|
|
1572 |
"set the value of the instance variable 'changeSelector' (automatically generated)"
|
|
1573 |
|
|
1574 |
changeSelector := something.!
|
|
1575 |
|
|
1576 |
elementClass
|
|
1577 |
"return the value of the instance variable 'elementClass' (automatically generated)"
|
|
1578 |
|
|
1579 |
^ elementClass!
|
|
1580 |
|
|
1581 |
elementClass:something
|
|
1582 |
"set the value of the instance variable 'elementClass' (automatically generated)"
|
|
1583 |
|
|
1584 |
elementClass := something.!
|
|
1585 |
|
|
1586 |
group
|
|
1587 |
^ nil
|
|
1588 |
!
|
|
1589 |
|
|
1590 |
identifier
|
|
1591 |
"return the unique identifier assigned to property
|
|
1592 |
"
|
|
1593 |
^ identifier
|
|
1594 |
!
|
|
1595 |
|
|
1596 |
labelSelector
|
|
1597 |
"return the value of the instance variable 'labelSelector' (automatically generated)"
|
|
1598 |
|
|
1599 |
^ labelSelector!
|
|
1600 |
|
|
1601 |
labelSelector:something
|
|
1602 |
"set the value of the instance variable 'labelSelector' (automatically generated)"
|
|
1603 |
|
|
1604 |
labelSelector := something.!
|
|
1605 |
|
|
1606 |
name
|
|
1607 |
"return the value of the instance variable 'name' (automatically generated)"
|
|
1608 |
|
|
1609 |
^ name!
|
|
1610 |
|
|
1611 |
name:something
|
|
1612 |
"set the value of the instance variable 'name' (automatically generated)"
|
|
1613 |
|
|
1614 |
name := something.!
|
|
1615 |
|
|
1616 |
nameIndex
|
|
1617 |
"return the value of the instance variable 'nameIndex' (automatically generated)"
|
|
1618 |
|
|
1619 |
^ nameIndex!
|
|
1620 |
|
|
1621 |
nameIndex:something
|
|
1622 |
"set the value of the instance variable 'nameIndex' (automatically generated)"
|
|
1623 |
|
|
1624 |
nameIndex := something.!
|
|
1625 |
|
|
1626 |
view
|
|
1627 |
"return the value of the instance variable 'view' (automatically generated)"
|
|
1628 |
|
|
1629 |
^ view!
|
|
1630 |
|
|
1631 |
view:something
|
|
1632 |
"set the value of the instance variable 'view' (automatically generated)"
|
|
1633 |
|
|
1634 |
view := something.! !
|
|
1635 |
|
|
1636 |
!UIPainterView::ViewProperty methodsFor:'initialization'!
|
|
1637 |
|
|
1638 |
initialize
|
|
1639 |
super initialize.
|
|
1640 |
identifier := Identifier
|
|
1641 |
! !
|
|
1642 |
|
48
|
1643 |
!UIPainterView::GroupProperties methodsFor:'accessing'!
|
|
1644 |
|
|
1645 |
controlledObjects
|
|
1646 |
"return the value of the instance variable 'controlledObjects' (automatically generated)"
|
|
1647 |
|
|
1648 |
^ controlledObjects!
|
|
1649 |
|
|
1650 |
controlledObjects:something
|
|
1651 |
"set the value of the instance variable 'controlledObjects' (automatically generated)"
|
|
1652 |
|
|
1653 |
controlledObjects := something.!
|
|
1654 |
|
|
1655 |
group
|
|
1656 |
"return the value of the instance variable 'group' (automatically generated)"
|
|
1657 |
|
|
1658 |
^ group!
|
|
1659 |
|
|
1660 |
group:something
|
|
1661 |
"set the value of the instance variable 'group' (automatically generated)"
|
|
1662 |
|
|
1663 |
group := something.! !
|
|
1664 |
|
51
|
1665 |
!UIPainterView class methodsFor:'documentation'!
|
|
1666 |
|
|
1667 |
version
|
|
1668 |
^ '$Header$'
|
|
1669 |
! !
|