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