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