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