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