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