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