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