author | ca |
Mon, 21 Jul 1997 10:49:25 +0200 | |
changeset 228 | ae3028e45467 |
parent 223 | 203460df426e |
child 231 | 75de472d579f |
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 |
|
223 | 340 |
oldSel := selection copy. |
89 | 341 |
spec := (anObjectOrCollection at:1) theObject. |
223 | 342 |
newSel := self pasteSpecifications:spec keepLayout:false. |
60 | 343 |
|
223 | 344 |
oldSel isNil ifTrue:[self select:newSel] |
345 |
ifFalse:[self select:oldSel] |
|
60 | 346 |
! ! |
347 |
||
78 | 348 |
!UIPainterView methodsFor:'generating output'! |
349 |
||
60 | 350 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
149 | 351 |
|args showIt| |
141 | 352 |
|
149 | 353 |
(aspect asSymbol numArgs) == 1 ifFalse:[ |
354 |
args := '\'. |
|
355 |
showIt := ' ...''.\'. |
|
356 |
] ifTrue:[ |
|
357 |
args := 'anArgument\'. |
|
358 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
359 |
]. |
|
141 | 360 |
|
60 | 361 |
^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
141 | 362 |
aspect , args , |
60 | 363 |
' "automatically generated by UIPainter ..."\' , |
364 |
'\' , |
|
365 |
' "action to be added ..."\' , |
|
149 | 366 |
' Transcript showCR:self class name , '': action for ' , aspect , showIt , |
60 | 367 |
'!! !!\\') withCRs |
368 |
! |
|
369 |
||
370 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
134 | 371 |
|modelClass| |
372 |
||
149 | 373 |
modelClass := protoSpec defaultModelClassFor:aspect. |
134 | 374 |
|
60 | 375 |
^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
376 |
aspect , '\' , |
|
377 |
' "automatically generated by UIPainter ..."\' , |
|
378 |
'\' , |
|
379 |
' |holder|\' , |
|
380 |
'\' , |
|
381 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
134 | 382 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelClass name , ' new' , ').\' , |
60 | 383 |
' ].\' , |
384 |
' ^ holder\' , |
|
385 |
'!! !!\\') withCRs |
|
386 |
! |
|
387 |
||
388 |
generateAspectMethods |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
389 |
|cls code skip| |
60 | 390 |
|
78 | 391 |
code := ''. |
392 |
||
60 | 393 |
className isNil ifTrue:[ |
69 | 394 |
self warn:'set the class first'. |
78 | 395 |
^ code |
60 | 396 |
]. |
89 | 397 |
cls := Smalltalk classNamed:className. |
60 | 398 |
|
223 | 399 |
claus propertiesDo:[:aProp | |
62 | 400 |
|modelSelector menuSelector protoSpec thisCode| |
60 | 401 |
|
134 | 402 |
protoSpec := aProp spec. |
175 | 403 |
|
78 | 404 |
(modelSelector := aProp model) notNil ifTrue:[ |
60 | 405 |
(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
|
406 |
skip := false. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
407 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
408 |
skip := SimpleDialog implements:modelSelector asSymbol |
60 | 409 |
]. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
410 |
skip ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
411 |
"/ kludge .. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
412 |
(protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
413 |
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
|
414 |
] ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
415 |
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
|
416 |
]. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
417 |
code := code , thisCode |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
418 |
]. |
62 | 419 |
]. |
420 |
]. |
|
421 |
||
78 | 422 |
(menuSelector := aProp menu) notNil ifTrue:[ |
62 | 423 |
(cls implements:menuSelector asSymbol) ifFalse:[ |
424 |
thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). |
|
425 |
code := code , thisCode |
|
60 | 426 |
] |
111 | 427 |
]. |
428 |
||
429 |
aProp spec aspectSelectors do:[:aSel| |
|
430 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
431 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
432 |
code := code , thisCode |
|
433 |
] |
|
434 |
]. |
|
137 | 435 |
aProp spec actionSelectors do:[:aSel| |
436 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
437 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
438 |
code := code , thisCode |
|
439 |
] |
|
440 |
]. |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
441 |
aProp spec valueSelectors do:[:aSel| |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
442 |
(cls implements:aSel asSymbol) ifFalse:[ |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
443 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
444 |
code := code , thisCode |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
445 |
] |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
446 |
]. |
111 | 447 |
|
60 | 448 |
]. |
449 |
^ code |
|
450 |
! |
|
451 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
452 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
453 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
454 |
aspect , '\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
455 |
' "automatically generated by UIPainter ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
456 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
457 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
458 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
459 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
460 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
461 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
462 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
463 |
|
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 |
|
78 | 468 |
generateWindowSpecMethodSource |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
469 |
|t s spec specArray str code category cls mthd| |
60 | 470 |
|
78 | 471 |
specArray := OrderedCollection new. |
60 | 472 |
|
78 | 473 |
self subViews do:[:aView| |
474 |
aView ~~ inputView ifTrue:[ |
|
475 |
specArray add:(self fullSpecFor:aView) |
|
60 | 476 |
] |
477 |
]. |
|
78 | 478 |
spec := FullSpec new. |
479 |
spec fromBuilder:self components:(SpecCollection new collection:specArray). |
|
60 | 480 |
specArray := spec literalArrayEncoding. |
481 |
||
482 |
str := WriteStream on:String new. |
|
86 | 483 |
UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
60 | 484 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
485 |
"/ 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
|
486 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
487 |
category := 'interface specs'. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
488 |
(cls := Smalltalk classNamed:className) notNil ifTrue:[ |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
489 |
(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
|
490 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
491 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
492 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
493 |
|
60 | 494 |
code := Character excla asString |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
495 |
, className , ' class methodsFor:' , category storeString |
60 | 496 |
, Character excla asString , '\\' |
497 |
||
498 |
, methodName , '\' |
|
499 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
500 |
, ' "do not manually edit this - the painter/builder may not be able to\' |
|
501 |
, ' handle the specification if its corrupted."\\' |
|
502 |
, ' "\' |
|
503 |
, ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
504 |
, ' ' , className , ' new openInterface:#' , methodName , '\' |
|
505 |
, ' "\'. |
|
506 |
||
507 |
methodName = 'windowSpec' ifTrue:[ |
|
508 |
code := code , ' "' , className , ' open"\' |
|
509 |
]. |
|
510 |
code := code |
|
511 |
, '\' |
|
512 |
, ' <resource: #canvas>\\' |
|
513 |
, ' ^\' |
|
514 |
, ' ', str contents |
|
515 |
, '\' |
|
516 |
, Character excla asString |
|
517 |
, ' ' |
|
518 |
, Character excla asString |
|
519 |
, '\\'. |
|
520 |
||
521 |
^ code withCRs |
|
522 |
||
523 |
"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
|
524 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 525 |
! ! |
526 |
||
527 |
!UIPainterView methodsFor:'initialization'! |
|
528 |
||
529 |
initialize |
|
62 | 530 |
"setup attributes |
531 |
" |
|
60 | 532 |
super initialize. |
533 |
||
534 |
superclassName := 'ApplicationModel'. |
|
535 |
className := 'NewApplication'. |
|
536 |
methodName := 'windowSpec'. |
|
537 |
categoryName := 'Applications'. |
|
538 |
HandCursor := Cursor leftHand. |
|
539 |
||
540 |
! |
|
541 |
||
542 |
setupFromSpec:specOrSpecArray |
|
78 | 543 |
|spec builder| |
60 | 544 |
|
223 | 545 |
claus cvsSetupListDo:[ |
111 | 546 |
self removeAll. |
547 |
spec := UISpecification from:specOrSpecArray. |
|
548 |
builder := UIBuilder new. |
|
549 |
spec window setupView:self topView for:builder. |
|
550 |
self addSpec:(spec component) builder:builder in:self. |
|
551 |
self realizeAllSubViews. |
|
552 |
inputView raise. |
|
553 |
] |
|
223 | 554 |
! |
555 |
||
556 |
treeView:aTreeView |
|
557 |
claus := aTreeView |
|
60 | 558 |
! ! |
559 |
||
560 |
!UIPainterView methodsFor:'menus'! |
|
561 |
||
121 | 562 |
showMiddleButtonMenu |
563 |
"show the middle button menu; this returns nil |
|
62 | 564 |
" |
223 | 565 |
|menu| |
60 | 566 |
|
223 | 567 |
self enabled ifTrue:[ |
568 |
menu := MenuPanel fromSpec:(UIPainter menuCanvas) receiver:self. |
|
60 | 569 |
|
223 | 570 |
self hasSelection ifFalse:[ |
571 |
menu disableAll |
|
572 |
]. |
|
573 |
menu enabledAt:#paste put:(self canPaste:(self getSelection)). |
|
574 |
menu enabledAt:#undo put:(undoHistory isEmpty not). |
|
575 |
menu startUp. |
|
111 | 576 |
]. |
121 | 577 |
^ nil |
60 | 578 |
|
62 | 579 |
|
580 |
||
60 | 581 |
! ! |
582 |
||
583 |
!UIPainterView methodsFor:'removing components'! |
|
584 |
||
78 | 585 |
remove:anObject |
586 |
"remove anObject from the contents do redraw |
|
60 | 587 |
" |
134 | 588 |
anObject notNil ifTrue:[ |
223 | 589 |
claus removeView:anObject. |
134 | 590 |
] |
60 | 591 |
! |
592 |
||
593 |
removeAll |
|
62 | 594 |
"remove all objects and properties |
595 |
" |
|
223 | 596 |
claus cvsEventsDisabledDo:[ |
597 |
self select:nil. |
|
598 |
claus removeAll. |
|
599 |
self removeUndoHistory. |
|
111 | 600 |
] |
60 | 601 |
! ! |
602 |
||
603 |
!UIPainterView methodsFor:'searching'! |
|
604 |
||
89 | 605 |
findContainerViewAt:aPoint |
606 |
"find container view responds to aPoint. |
|
607 |
" |
|
608 |
|view| |
|
609 |
||
610 |
(view := self findObjectAt:aPoint) isNil ifTrue:[ |
|
611 |
^ self |
|
612 |
]. |
|
613 |
||
614 |
[(view specClass supportsSubComponents or:[(view := view superView) == self]) |
|
615 |
] whileFalse:[ |
|
616 |
[(self propertyOfView:view) isNil] whileTrue:[ |
|
617 |
(view := view superView) == self ifTrue:[^ self] |
|
618 |
]. |
|
619 |
]. |
|
620 |
^ view |
|
621 |
! |
|
622 |
||
60 | 623 |
findObjectAt:aPoint |
624 |
"find the origin/corner of the currentWidget |
|
625 |
" |
|
626 |
|view| |
|
627 |
||
628 |
view := super findObjectAt:aPoint. |
|
629 |
||
630 |
view notNil ifTrue:[ |
|
631 |
"can be a view within a view not visible |
|
632 |
" |
|
633 |
[ (self propertyOfView:view) isNil ] whileTrue:[ |
|
634 |
(view := view superView) == self ifTrue:[^ nil] |
|
635 |
] |
|
636 |
]. |
|
637 |
^ view |
|
638 |
! |
|
639 |
||
640 |
findViewWithId:aViewId |
|
62 | 641 |
"finds view assigned to identifier and returns the view or nil |
60 | 642 |
" |
643 |
|prop| |
|
644 |
||
645 |
prop := self propertyOfIdentifier:aViewId. |
|
646 |
||
647 |
prop notNil ifTrue:[^ prop view] |
|
648 |
ifFalse:[^ nil] |
|
78 | 649 |
! |
650 |
||
651 |
propertyOfIdentifier:anId |
|
652 |
"returns property assigned to unique identifier |
|
653 |
" |
|
654 |
anId notNil ifTrue:[ |
|
223 | 655 |
^ claus propertyDetect:[:p| p identifier == anId ] |
78 | 656 |
]. |
657 |
^ nil |
|
658 |
! |
|
659 |
||
660 |
propertyOfName:aString |
|
661 |
"returns property assigned to name |
|
662 |
" |
|
111 | 663 |
|name| |
664 |
||
665 |
aString isNil ifFalse:[ |
|
666 |
name := aString string withoutSeparators. |
|
223 | 667 |
^ claus propertyDetect:[:p| p name = name ]. |
78 | 668 |
]. |
669 |
^ nil |
|
670 |
! |
|
671 |
||
672 |
propertyOfView:aView |
|
673 |
"returns property assigned to view |
|
674 |
" |
|
675 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
223 | 676 |
^ claus propertyDetect:[:p| p view == aView ] |
78 | 677 |
]. |
678 |
^ nil |
|
679 |
! |
|
680 |
||
111 | 681 |
uniqueNameFor:aSpecOrString |
78 | 682 |
"generate and return an unique name for a class |
683 |
" |
|
684 |
|next name size| |
|
685 |
||
111 | 686 |
aSpecOrString isString ifFalse:[name := aSpecOrString className asString] |
687 |
ifTrue:[name := aSpecOrString]. |
|
78 | 688 |
|
111 | 689 |
(name endsWith:'Spec') ifTrue:[ |
690 |
name := name copyFrom:1 to:(name size - 4). |
|
691 |
] ifFalse:[ |
|
692 |
name := name copy |
|
693 |
]. |
|
78 | 694 |
name at:1 put:(name at:1) asLowercase. |
111 | 695 |
size := name size + 1. |
696 |
next := 0. |
|
78 | 697 |
|
223 | 698 |
claus propertiesDo:[:p| |
111 | 699 |
|n| |
78 | 700 |
n := p name. |
701 |
||
702 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
703 |
next := next max:(p extractNumberStartingAt:size) |
|
704 |
] |
|
705 |
]. |
|
706 |
next := next + 1. |
|
707 |
name := name, next printString. |
|
708 |
^ name |
|
709 |
||
710 |
||
711 |
||
712 |
! |
|
713 |
||
714 |
uniqueNameOf:aView |
|
111 | 715 |
|prop| |
78 | 716 |
|
111 | 717 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
718 |
prop name isNil ifTrue:[ |
|
719 |
prop name:(self uniqueNameFor:(prop spec)). |
|
720 |
]. |
|
721 |
^ prop name |
|
78 | 722 |
]. |
111 | 723 |
^ 'self' |
78 | 724 |
|
60 | 725 |
! ! |
726 |
||
223 | 727 |
!UIPainterView methodsFor:'selection basics'! |
728 |
||
729 |
addToSelection:anObject |
|
730 |
"add an object to the selection |
|
731 |
" |
|
732 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
733 |
selection isCollection ifFalse:[ |
|
734 |
selection isNil ifTrue:[ |
|
735 |
selection := anObject |
|
736 |
] ifFalse:[ |
|
737 |
selection := OrderedCollection with:selection with:anObject |
|
738 |
] |
|
739 |
] ifTrue:[ |
|
740 |
selection add:anObject |
|
741 |
]. |
|
742 |
self showSelected:anObject. |
|
743 |
claus cvsSelectionAdd:anObject. |
|
744 |
] |
|
745 |
||
746 |
||
747 |
! |
|
748 |
||
749 |
removeFromSelection:anObject |
|
750 |
"remove an object from the selection |
|
751 |
" |
|
752 |
(self isSelected:anObject) ifTrue:[ |
|
753 |
self showUnselected:anObject. |
|
754 |
||
755 |
selection size > 1 ifTrue:[ |
|
756 |
selection remove:anObject ifAbsent:nil. |
|
757 |
self showSelection. |
|
758 |
] ifFalse:[ |
|
759 |
selection := nil |
|
760 |
]. |
|
761 |
claus cvsSelectionRemove:anObject. |
|
762 |
] |
|
763 |
||
764 |
! |
|
765 |
||
766 |
select:something |
|
767 |
"change selection to something |
|
768 |
" |
|
769 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
|
770 |
self setSelection:something withRedraw:true. |
|
771 |
claus cvsSelection:something |
|
772 |
] |
|
773 |
||
774 |
! |
|
775 |
||
776 |
updateSelectionFromModel:aSel |
|
777 |
"update selection from a new selection |
|
778 |
" |
|
779 |
|sel| |
|
780 |
||
781 |
selectionHiddenLevel == 0 ifTrue:[ |
|
782 |
self selectionDo:[:el| (aSel includes:el) ifFalse:[self showUnselected:el] ] |
|
783 |
]. |
|
784 |
||
785 |
(aSel indexOf:self) ~~ 0 ifTrue:[ |
|
786 |
aSel size > 1 ifTrue:[sel := aSel copyWithout:self] |
|
787 |
] ifFalse:[ |
|
788 |
aSel size ~~ 0 ifTrue:[sel := aSel] |
|
789 |
]. |
|
790 |
||
791 |
self setSelection:sel withRedraw:false. |
|
792 |
self showSelection |
|
793 |
||
794 |
||
795 |
! ! |
|
796 |
||
78 | 797 |
!UIPainterView methodsFor:'specification'! |
798 |
||
799 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
800 |
"build view and subviews from aSpecification into a frame. The top view |
|
801 |
is returned. The contained components of a spec are set to nil |
|
802 |
" |
|
212 | 803 |
|
804 |
className notNil ifTrue:[ |
|
805 |
aBuilder applicationClass:(Smalltalk classNamed:className). |
|
806 |
]. |
|
78 | 807 |
|
111 | 808 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 809 |
p := ViewProperty new. |
810 |
s := aSpec copy. |
|
811 |
p spec:s. |
|
812 |
p view:aView. |
|
813 |
||
814 |
s class supportsSubComponents ifTrue:[ |
|
815 |
s component:nil |
|
816 |
]. |
|
817 |
||
111 | 818 |
n := s name. |
819 |
||
820 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
821 |
s name:(self uniqueNameFor:s) |
|
78 | 822 |
]. |
223 | 823 |
claus addProperty:p. |
78 | 824 |
]. |
825 |
||
826 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 827 |
|
212 | 828 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 829 |
! |
830 |
||
831 |
fullSpecFor:anObject |
|
832 |
"generate a full spec for an object |
|
62 | 833 |
" |
78 | 834 |
|mySpec subSpecs| |
835 |
||
836 |
mySpec := self specFor:anObject. |
|
837 |
||
838 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
839 |
(anObject subViews notNil) ifTrue:[ |
|
840 |
anObject subViews do:[:aSubView||spec| |
|
841 |
spec := self fullSpecFor:aSubView. |
|
842 |
spec notNil ifTrue:[ |
|
843 |
subSpecs isNil ifTrue:[ |
|
844 |
subSpecs := OrderedCollection new |
|
845 |
]. |
|
846 |
subSpecs add:spec. |
|
847 |
]. |
|
848 |
]. |
|
849 |
subSpecs notNil ifTrue:[ |
|
850 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
851 |
] |
|
852 |
] |
|
853 |
]. |
|
854 |
^ mySpec |
|
855 |
||
60 | 856 |
|
857 |
||
858 |
||
859 |
||
860 |
||
861 |
! |
|
862 |
||
78 | 863 |
specFor:anObject |
864 |
"returns spec assigned to an object |
|
62 | 865 |
" |
78 | 866 |
|prop spec| |
60 | 867 |
|
78 | 868 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
869 |
spec := prop spec copy. |
|
870 |
spec layoutFromView:anObject |
|
60 | 871 |
]. |
78 | 872 |
^ spec |
873 |
||
874 |
||
875 |
||
60 | 876 |
! |
877 |
||
146 | 878 |
specForSelection |
879 |
"returns spec assigned to current single selection or nil |
|
880 |
" |
|
881 |
^ self specFor:(self singleSelection) |
|
882 |
||
883 |
||
884 |
! |
|
885 |
||
78 | 886 |
updateFromSpec:aSpec |
887 |
"update current selected view from specification |
|
62 | 888 |
" |
78 | 889 |
|props name builder v| |
890 |
||
891 |
self singleSelection notNil ifTrue:[ |
|
892 |
self withSelectionHiddenDo:[ |
|
893 |
self transaction:#specification selectionDo:[:aView| |
|
894 |
builder := UIBuilder new. |
|
212 | 895 |
className notNil ifTrue:[ |
896 |
builder applicationClass:(Smalltalk classNamed:className). |
|
897 |
]. |
|
78 | 898 |
props := self propertyOfView:aView. |
82 | 899 |
name := (aSpec name) withoutSeparators. |
78 | 900 |
|
82 | 901 |
name = props name ifFalse:[ |
902 |
(self propertyOfName:name) notNil ifTrue:[ |
|
903 |
name := props name |
|
78 | 904 |
] |
905 |
]. |
|
82 | 906 |
aSpec name:name. |
134 | 907 |
self createUndoSpecModify:props. |
78 | 908 |
|
909 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
910 |
v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
911 |
v realize. |
|
912 |
aView destroy. |
|
913 |
device sync. device flush. |
|
914 |
aView becomeSameAs:v. |
|
915 |
inputView raise. |
|
916 |
] ifFalse:[ |
|
917 |
aSpec setAttributesIn:aView with:builder. |
|
918 |
self elementChangedSize:aView. |
|
919 |
]. |
|
920 |
props spec:(aSpec copy). |
|
223 | 921 |
claus propertyChanged:props. |
78 | 922 |
] |
111 | 923 |
] |
82 | 924 |
] |
212 | 925 |
|
926 |
"Modified: 4.7.1997 / 23:49:44 / cg" |
|
60 | 927 |
! ! |
928 |
||
929 |
!UIPainterView methodsFor:'transaction'! |
|
930 |
||
931 |
transaction:aType objects:something do:aOneArgBlock |
|
932 |
"opens a transaction and evaluates a block within the transaction; the |
|
933 |
argument to the block is a view from derived from something |
|
934 |
" |
|
134 | 935 |
self withinTransaction:aType objects:something do:[ |
936 |
self forEach:something do:aOneArgBlock |
|
60 | 937 |
] |
938 |
! |
|
939 |
||
134 | 940 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
941 |
"evaluate a block with no arguments within a transaction |
|
60 | 942 |
" |
134 | 943 |
|text size prop| |
944 |
||
945 |
objects isNil ifTrue:[ ^ self ]. |
|
946 |
||
947 |
size := objects size. |
|
60 | 948 |
|
134 | 949 |
objects isCollection ifTrue:[ |
950 |
size == 0 ifTrue:[ ^ self ]. |
|
951 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
952 |
] ifFalse:[ |
|
953 |
prop := self propertyOfView:objects |
|
954 |
]. |
|
60 | 955 |
|
134 | 956 |
prop notNil ifTrue:[ |
957 |
text := prop name |
|
958 |
] ifFalse:[ |
|
959 |
text := size printString, ' elements' |
|
60 | 960 |
]. |
134 | 961 |
|
962 |
undoHistory withinTransaction:aType text:text do:[ |
|
963 |
aNoneArgBlock value |
|
964 |
] |
|
60 | 965 |
! ! |
966 |
||
967 |
!UIPainterView methodsFor:'undo actions'! |
|
968 |
||
134 | 969 |
createUndoLayout:aView |
970 |
"create undo action before changing a views layout |
|
60 | 971 |
" |
134 | 972 |
|lyt args prop| |
60 | 973 |
|
974 |
undoHistory isTransactionOpen ifTrue:[ |
|
975 |
prop := self propertyOfView:aView. |
|
134 | 976 |
|
60 | 977 |
prop notNil ifTrue:[ |
134 | 978 |
args := Array new:3. |
979 |
args at:1 put:(prop identifier). |
|
980 |
||
981 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
982 |
args at:2 put:#geometryLayout: |
|
983 |
] ifFalse:[ |
|
146 | 984 |
lyt := aView extent. |
134 | 985 |
args at:2 put:#extent: |
986 |
]. |
|
987 |
args at:3 put:(lyt copy). |
|
988 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 989 |
] |
990 |
] |
|
991 |
! |
|
992 |
||
134 | 993 |
createUndoRemove:aView |
994 |
"create undo method before deleting views |
|
60 | 995 |
" |
134 | 996 |
|frame prop pId spec| |
997 |
||
998 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
999 |
spec := self fullSpecFor:aView. |
|
1000 |
frame := aView superView. |
|
60 | 1001 |
|
134 | 1002 |
(self canPasteInto:frame) ifTrue:[ |
1003 |
(frame := self propertyOfView:frame) notNil ifTrue:[ |
|
1004 |
pId := frame identifier |
|
1005 |
] |
|
1006 |
]. |
|
1007 |
undoHistory addUndoSelector:#undoRemove: |
|
1008 |
withArgs:(Array with:spec with:(prop identifier) with:pId) |
|
1009 |
] |
|
1010 |
! |
|
60 | 1011 |
|
134 | 1012 |
createUndoSpecModify:aProp |
1013 |
"undo method when changing the specification for an object |
|
1014 |
" |
|
1015 |
aProp notNil ifTrue:[ |
|
1016 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1017 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1018 |
] |
|
1019 |
! |
|
60 | 1020 |
|
134 | 1021 |
undoCreate:something |
1022 |
"undo method for creating or pasting an object |
|
1023 |
" |
|
1024 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1025 |
! |
|
60 | 1026 |
|
134 | 1027 |
undoLayout:args |
1028 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1029 |
" |
|
1030 |
|view| |
|
1031 |
||
1032 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1033 |
view perform:(args at:2) with:(args at:3). |
223 | 1034 |
self layoutChanged. |
60 | 1035 |
] |
1036 |
! |
|
1037 |
||
134 | 1038 |
undoRemove:args |
1039 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1040 |
" |
|
1041 |
|frame prop view| |
|
1042 |
||
1043 |
(args at:3) notNil ifTrue:[ |
|
1044 |
frame := self findViewWithId:(args at:3). |
|
1045 |
]. |
|
1046 |
frame isNil ifTrue:[ |
|
1047 |
frame := self |
|
1048 |
]. |
|
1049 |
view := self addSpec:(args at:1) builder:(UIBuilder new) in:frame. |
|
1050 |
view realize. |
|
1051 |
inputView raise. |
|
1052 |
||
1053 |
prop := self propertyOfView:view. |
|
1054 |
prop identifier:(args at:2). |
|
1055 |
||
1056 |
! |
|
1057 |
||
1058 |
undoSpecModify:args |
|
1059 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1060 |
" |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1061 |
|builder view spec v props| |
60 | 1062 |
|
134 | 1063 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1064 |
|
134 | 1065 |
props notNil ifTrue:[ |
1066 |
view := props view. |
|
1067 |
spec := args at:1. |
|
1068 |
builder := UIBuilder new. |
|
212 | 1069 |
className notNil ifTrue:[ |
1070 |
builder applicationClass:(Smalltalk classNamed:className). |
|
1071 |
]. |
|
134 | 1072 |
props spec:spec. |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1073 |
|
134 | 1074 |
spec needsRebuildForAttributes ifTrue:[ |
1075 |
v := spec buildViewWithLayoutFor:builder in:view superView. |
|
1076 |
v realize. |
|
1077 |
view destroy. |
|
1078 |
view become:v |
|
1079 |
] ifFalse:[ |
|
1080 |
spec setAttributesIn:view with:builder. |
|
1081 |
self elementChangedSize:view. |
|
1082 |
]. |
|
223 | 1083 |
claus propertyChanged:props. |
211 | 1084 |
] |
1085 |
! ! |
|
1086 |
||
1087 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
1088 |
||
1089 |
new |
|
1090 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1091 |
ifFalse:[Identifier := 1]. |
|
1092 |
||
1093 |
^ self basicNew initialize |
|
1094 |
! ! |
|
1095 |
||
1096 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1097 |
||
1098 |
identifier |
|
1099 |
"return the unique identifier assigned to property |
|
1100 |
" |
|
1101 |
^ identifier |
|
1102 |
! |
|
1103 |
||
1104 |
identifier:anIdentifier |
|
1105 |
"set the unique identifier assigned to property; called after an restore of |
|
1106 |
a deleted instance |
|
1107 |
" |
|
1108 |
identifier := anIdentifier |
|
1109 |
! |
|
1110 |
||
1111 |
spec |
|
1112 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1113 |
||
1114 |
^ spec! |
|
1115 |
||
1116 |
spec:something |
|
1117 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1118 |
||
1119 |
spec := something.! |
|
1120 |
||
1121 |
view |
|
1122 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1123 |
||
1124 |
^ view! |
|
1125 |
||
1126 |
view:something |
|
1127 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1128 |
||
1129 |
view := something.! ! |
|
1130 |
||
1131 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1132 |
||
1133 |
initialize |
|
1134 |
super initialize. |
|
1135 |
identifier := Identifier |
|
1136 |
! ! |
|
1137 |
||
1138 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1139 |
||
1140 |
extractNumberStartingAt:anIndex |
|
1141 |
"return the number from the name starting at anIndex or 0. |
|
1142 |
" |
|
1143 |
|val| |
|
1144 |
||
1145 |
val := 0. |
|
1146 |
||
1147 |
self name from:anIndex do:[:c| |
|
1148 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1149 |
ifFalse:[^ 0] |
|
1150 |
]. |
|
1151 |
^ val |
|
1152 |
||
1153 |
! ! |
|
1154 |
||
1155 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1156 |
||
1157 |
doesNotUnderstand:aMessage |
|
1158 |
spec notNil ifTrue:[ |
|
1159 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1160 |
]. |
|
1161 |
^ nil |
|
1162 |
! |
|
1163 |
||
1164 |
layout |
|
1165 |
spec layout |
|
1166 |
! |
|
1167 |
||
1168 |
layout:aLayout |
|
1169 |
spec layout:aLayout |
|
1170 |
! |
|
1171 |
||
1172 |
name |
|
1173 |
^ spec name |
|
1174 |
! |
|
1175 |
||
1176 |
name:aName |
|
1177 |
spec name:aName |
|
1178 |
! ! |
|
1179 |
||
60 | 1180 |
!UIPainterView class methodsFor:'documentation'! |
1181 |
||
1182 |
version |
|
1183 |
^ '$Header$' |
|
1184 |
! ! |