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