author | Claus Gittinger <cg@exept.de> |
Fri, 13 Oct 2006 17:58:08 +0200 | |
changeset 2115 | be5e920d6158 |
parent 2112 | 74dfb69c88d4 |
child 2116 | 90fc11105f36 |
permissions | -rw-r--r-- |
60 | 1 |
" |
156 | 2 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 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 |
" |
|
1387 | 12 |
"{ Package: 'stx:libtool2' }" |
13 |
||
60 | 14 |
UIObjectView subclass:#UIPainterView |
278 | 15 |
instanceVariableNames:'treeView listHolder superclassName className methodName |
1467
b46624bb6994
use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents:
1450
diff
changeset
|
16 |
categoryName handleColorBlack handleColorWhite handleMasterColor' |
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
17 |
classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances' |
60 | 18 |
poolDictionaries:'' |
19 |
category:'Interface-UIPainter' |
|
20 |
! |
|
21 |
||
211 | 22 |
Object subclass:#ViewProperty |
23 |
instanceVariableNames:'view spec identifier' |
|
24 |
classVariableNames:'Identifier' |
|
25 |
poolDictionaries:'' |
|
26 |
privateIn:UIPainterView |
|
27 |
! |
|
28 |
||
60 | 29 |
!UIPainterView class methodsFor:'documentation'! |
30 |
||
31 |
copyright |
|
32 |
" |
|
156 | 33 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 34 |
All Rights Reserved |
60 | 35 |
|
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
742 | 38 |
inclusion of the above copyright notice. This software may not |
60 | 39 |
be provided or otherwise made available to, or used by, any |
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
! |
|
44 |
||
45 |
documentation |
|
46 |
" |
|
128 | 47 |
buildIn view used by the UIPainter; from this view, the layout of the |
48 |
new application derives from. |
|
49 |
||
50 |
[see also:] |
|
1834 | 51 |
UIBuilder |
52 |
UIObjectView |
|
156 | 53 |
|
54 |
[author:] |
|
1834 | 55 |
Claus Gittinger |
56 |
Claus Atzkern |
|
60 | 57 |
" |
58 |
! ! |
|
59 |
||
1225 | 60 |
!UIPainterView class methodsFor:'initialization'! |
61 |
||
62 |
initialize |
|
63 |
||
1494 | 64 |
AspectsAsInstances := true. "/ false. |
1225 | 65 |
RedefineAspectMethods := false. |
66 |
||
67 |
"Created: / 22.9.1999 / 12:32:31 / stefan" |
|
68 |
! ! |
|
69 |
||
698 | 70 |
!UIPainterView class methodsFor:'code generation mode'! |
71 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
72 |
generateAspectsAsInstanceVariables |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
73 |
"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
|
74 |
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
|
75 |
" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
76 |
^ AspectsAsInstances |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
77 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
78 |
"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
|
79 |
"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
|
80 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
81 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
82 |
generateAspectsAsInstanceVariables:aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
83 |
"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
|
84 |
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
|
85 |
" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
86 |
AspectsAsInstances := aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
87 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
88 |
"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
|
89 |
"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
|
90 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
91 |
|
742 | 92 |
redefineAspectMethods |
698 | 93 |
"redefine methods yes or no. If a method is defined in super class |
94 |
should the message be reinstalled ? |
|
95 |
" |
|
1225 | 96 |
^ RedefineAspectMethods |
698 | 97 |
|
1225 | 98 |
"Modified: / 22.9.1999 / 12:33:03 / stefan" |
698 | 99 |
! |
100 |
||
742 | 101 |
redefineAspectMethods:aBoolean |
698 | 102 |
"redefine methods yes or no. If a method is defined in super class |
103 |
should the message be reinstalled ? |
|
104 |
" |
|
742 | 105 |
RedefineAspectMethods := aBoolean |
698 | 106 |
|
107 |
||
108 |
! ! |
|
109 |
||
60 | 110 |
!UIPainterView class methodsFor:'defaults'! |
111 |
||
1834 | 112 |
defaultMenuMessage |
60 | 113 |
"This message is the default yo be sent to the menuHolder to get a menu |
114 |
" |
|
121 | 115 |
^ #showMiddleButtonMenu |
60 | 116 |
|
117 |
||
118 |
! ! |
|
119 |
||
120 |
!UIPainterView methodsFor:'accessing'! |
|
121 |
||
122 |
application |
|
123 |
^ nil |
|
124 |
||
125 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
126 |
! |
|
127 |
||
78 | 128 |
applicationName |
129 |
^ self className |
|
130 |
! |
|
131 |
||
132 |
applicationName:aName |
|
133 |
self className:aName |
|
134 |
! |
|
135 |
||
1977 | 136 |
class:aClass superclassName:aSuperclassName selector:aSelector |
137 |
self assert:(aClass isBehavior). |
|
138 |
className := aClass name. |
|
139 |
superclassName := aSuperclassName. |
|
140 |
methodName := aSelector. |
|
141 |
! |
|
142 |
||
60 | 143 |
className |
144 |
^ className |
|
145 |
! |
|
146 |
||
78 | 147 |
className:aName |
1977 | 148 |
self assert:(aName isString). |
78 | 149 |
className := aName |
60 | 150 |
! |
151 |
||
152 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
1977 | 153 |
self assert:(aClassName isString). |
78 | 154 |
className := aClassName. |
60 | 155 |
superclassName := aSuperclassName. |
78 | 156 |
methodName := aSelector. |
60 | 157 |
! |
158 |
||
159 |
methodName |
|
160 |
^ methodName |
|
161 |
! |
|
162 |
||
78 | 163 |
methodName:aName |
164 |
methodName := aName |
|
60 | 165 |
! |
166 |
||
167 |
selectNames:aStringOrCollection |
|
1031 | 168 |
|prop coll s n newSel| |
169 |
||
170 |
(aStringOrCollection size == 0) ifTrue:[ |
|
1834 | 171 |
newSel := nil. |
1031 | 172 |
] ifFalse:[ |
1834 | 173 |
(s := aStringOrCollection) isString ifFalse:[ |
174 |
s size == 1 ifTrue:[ |
|
175 |
s := s first |
|
176 |
] ifFalse:[ |
|
177 |
coll := OrderedCollection new. |
|
178 |
||
179 |
s do:[:aName| |
|
180 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
181 |
coll add:(prop view) |
|
182 |
] |
|
183 |
]. |
|
184 |
(n := coll size) == 1 ifTrue:[ |
|
185 |
newSel := coll at:1 |
|
186 |
] ifFalse:[ |
|
187 |
n == 0 ifTrue:[ |
|
188 |
newSel := nil |
|
189 |
] ifFalse:[ |
|
190 |
newSel := coll |
|
191 |
] |
|
192 |
]. |
|
193 |
^ self select:newSel. |
|
194 |
] |
|
195 |
]. |
|
196 |
||
197 |
prop := self propertyOfName:s. |
|
198 |
prop isNil ifTrue:[ |
|
199 |
newSel := nil |
|
200 |
] ifFalse:[ |
|
201 |
newSel := prop view |
|
202 |
]. |
|
60 | 203 |
]. |
204 |
||
1031 | 205 |
^ self select:newSel |
60 | 206 |
! ! |
207 |
||
111 | 208 |
!UIPainterView methodsFor:'change & update'! |
209 |
||
223 | 210 |
layoutChanged |
1445 | 211 |
treeView notNil ifTrue:[ |
1834 | 212 |
treeView layoutChanged |
1445 | 213 |
] |
111 | 214 |
! ! |
215 |
||
60 | 216 |
!UIPainterView methodsFor:'copy & cut & paste'! |
217 |
||
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
218 |
commonContainerOf:someComponents |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
219 |
|container| |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
220 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
221 |
container := someComponents first container. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
222 |
[container notNil |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
223 |
and:[ (someComponents conform:[:eachComponent | eachComponent isComponentOf:container]) not]] |
1834 | 224 |
whileTrue:[ |
225 |
container := container container. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
226 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
227 |
^ container |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
228 |
! |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
229 |
|
60 | 230 |
copySelection |
1959 | 231 |
"copy the selection into the cut & paste-buffer" |
232 |
||
698 | 233 |
|specs coll sel| |
234 |
||
235 |
sel := treeView selection. |
|
71 | 236 |
|
128 | 237 |
coll := self minSetOfSuperViews:(self selection). |
60 | 238 |
|
71 | 239 |
coll notNil ifTrue:[ |
776 | 240 |
"/ self select:nil. |
1870 | 241 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
242 |
self setClipboardObject:specs. |
|
776 | 243 |
"/ treeView selection: sel |
60 | 244 |
]. |
245 |
! |
|
246 |
||
723 | 247 |
deleteSelection |
1959 | 248 |
"delete the selection buffered" |
249 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
250 |
self deleteSelectionBuffered: true |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
251 |
! |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
252 |
|
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
253 |
deleteSelectionBuffered: buffered |
698 | 254 |
"cut the selection into the cut&paste-buffer |
1959 | 255 |
and open a transaction" |
256 |
||
1574 | 257 |
|specs coll index oldSelection newSelection treeModel children size nd| |
71 | 258 |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
259 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
260 |
|
128 | 261 |
coll := self minSetOfSuperViews:(self selection). |
60 | 262 |
|
78 | 263 |
coll notNil ifTrue:[ |
1870 | 264 |
treeView cvsEventsDisabledDo:[ |
265 |
treeModel := treeView model. |
|
266 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
|
267 |
||
268 |
oldSelection notNil ifTrue:[ |
|
269 |
children := oldSelection parent children. |
|
270 |
(size := children size) > 1 ifTrue:[ |
|
271 |
index := children identityIndexOf:oldSelection. |
|
272 |
size == index ifTrue:[ |
|
273 |
index := index - 1 |
|
274 |
]. |
|
275 |
newSelection := children at:index ifAbsent:1. |
|
276 |
] ifFalse:[ |
|
277 |
newSelection := oldSelection parent |
|
278 |
]. |
|
279 |
newSelection := treeModel indexOf:newSelection. |
|
280 |
] ifFalse:[ |
|
281 |
newSelection := 1 |
|
282 |
]. |
|
283 |
||
284 |
self hideSelection. |
|
285 |
selection := nil. |
|
286 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
287 |
||
288 |
self withinTransaction:#cut objects:coll do:[ |
|
289 |
coll reverseDo:[:aView| |
|
290 |
self createUndoRemove:aView. |
|
291 |
self remove:aView. |
|
292 |
] |
|
293 |
]. |
|
294 |
buffered ifTrue: [self setClipboardObject:specs]. |
|
295 |
treeView selection:nil. |
|
296 |
treeView selection:(Array with: newSelection). |
|
297 |
(nd := treeView selectedNode) notNil ifTrue:[ |
|
298 |
self setSelection:nd contents view withRedraw:true. |
|
299 |
] |
|
300 |
] |
|
698 | 301 |
] |
302 |
! |
|
303 |
||
723 | 304 |
deleteTotalSelection |
1959 | 305 |
"delete the selection" |
306 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
307 |
self deleteSelectionBuffered: false |
60 | 308 |
! |
309 |
||
1832 | 310 |
getSelectedViewsAndSpecs |
311 |
"return an array filed with selected views and corresponding specs. |
|
1959 | 312 |
Nil if there is none." |
313 |
||
1832 | 314 |
|specs coll sel| |
315 |
||
316 |
sel := treeView selection. |
|
317 |
||
318 |
coll := self minSetOfSuperViews:(self selection). |
|
319 |
||
320 |
coll isNil ifTrue:[^ nil]. |
|
321 |
||
322 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
323 |
^ Array with: coll with: specs |
|
324 |
! |
|
325 |
||
60 | 326 |
pasteBuffer |
1959 | 327 |
"add the objects in the paste-buffer to the object view" |
328 |
||
223 | 329 |
|sel| |
330 |
||
1872 | 331 |
sel := self pasteSpecifications:(self getClipboardObject) keepLayout:false. |
223 | 332 |
|
333 |
sel notNil ifTrue:[ |
|
1872 | 334 |
self select:sel. |
223 | 335 |
]. |
89 | 336 |
! |
337 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
338 |
pasteKeepingPosition |
1834 | 339 |
"add the objects in the paste-buffer to the object view; |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
340 |
translate the layout as appropriate, to position the component |
1959 | 341 |
at the same absolute position (relative to topView) as before" |
342 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
343 |
|sel| |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
344 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
345 |
sel := self |
1872 | 346 |
pasteSpecifications:(self getClipboardObject) |
347 |
keepLayout:true |
|
348 |
keepPosition:true |
|
349 |
at:nil. |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
350 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
351 |
sel notNil ifTrue:[ |
1872 | 352 |
self select:sel. |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
353 |
]. |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
354 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
355 |
|
89 | 356 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
1959 | 357 |
"add the specs to the object view; returns list of pasted components" |
278 | 358 |
|
359 |
^ self |
|
1959 | 360 |
pasteSpecifications:aSpecificationOrList |
361 |
keepLayout:keepLayout |
|
362 |
at:nil |
|
278 | 363 |
|
364 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
365 |
! |
|
366 |
||
367 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
1959 | 368 |
"add the specs to the object view; returns list of pasted components" |
369 |
||
1834 | 370 |
^ self |
1959 | 371 |
pasteSpecifications:aSpecificationOrList |
372 |
keepLayout:keepLayout |
|
373 |
keepPosition:false |
|
374 |
at:aPointOrNil |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
375 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
376 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
377 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
378 |
"add the specs to the object view; returns list of pasted components" |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
379 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
380 |
|paste pasteOrigin pasteOffset builder newSel bounds containerToPasteInto| |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
381 |
|
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
382 |
treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
383 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
384 |
containerToPasteInto := self singleSelection. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
385 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
386 |
self selection size > 0 ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
387 |
containerToPasteInto := self commonContainerOf:self selection |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
388 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
389 |
containerToPasteInto := self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
390 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
391 |
self selection:containerToPasteInto. |
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
392 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
393 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
394 |
(self canPasteInto:containerToPasteInto) ifFalse:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
395 |
containerToPasteInto notNil ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
396 |
"/ search up parent list for something we can paste into |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
397 |
[containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
398 |
containerToPasteInto := containerToPasteInto container. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
399 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
400 |
self selection:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
401 |
]. |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
402 |
]. |
1752 | 403 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
404 |
containerToPasteInto := self |
1752 | 405 |
]. |
60 | 406 |
|
89 | 407 |
(self canPaste:aSpecificationOrList) ifFalse:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
408 |
Dialog warn:'Cannot paste into selected component (not a container ?)'. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
409 |
^ nil |
89 | 410 |
]. |
223 | 411 |
|
776 | 412 |
aSpecificationOrList isCollection ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
413 |
paste := aSpecificationOrList |
776 | 414 |
] ifFalse:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
415 |
paste := Array with:aSpecificationOrList |
776 | 416 |
]. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
417 |
self setClipboardObject:nil. |
776 | 418 |
|
419 |
newSel := OrderedCollection new. |
|
420 |
builder := UIBuilder new isEditing:true. |
|
421 |
||
422 |
className notNil ifTrue:[ |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
423 |
builder applicationClass:(self resolveName:className) |
776 | 424 |
]. |
425 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
426 |
(keepLayout not or:[keepPosition]) ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
427 |
pasteOffset := 0@0. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
428 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
429 |
keepPosition ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
430 |
pasteOrigin := device translatePoint:0@0 |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
431 |
fromView:self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
432 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
433 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
434 |
aPointOrNil isNil ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
435 |
pasteOrigin := self sensor mousePoint. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
436 |
pasteOrigin := device translatePoint:pasteOrigin |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
437 |
fromView:nil |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
438 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
439 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
440 |
pasteOrigin := device translatePoint:aPointOrNil |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
441 |
fromView:self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
442 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
443 |
] |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
444 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
445 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
446 |
bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent) |
776 | 447 |
]. |
60 | 448 |
|
776 | 449 |
paste do:[:aSpec| |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
450 |
|view newOrigin| |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
451 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
452 |
view := self addSpec:aSpec builder:builder in:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
453 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
454 |
keepPosition ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
455 |
self moveObject:view to:(view origin + pasteOrigin). |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
456 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
457 |
keepLayout ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
458 |
(bounds containsPoint:pasteOrigin) ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
459 |
newOrigin := pasteOffset. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
460 |
] ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
461 |
newOrigin := pasteOrigin + pasteOffset. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
462 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
463 |
self moveObject:view to:newOrigin. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
464 |
pasteOffset := pasteOffset + 4 |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
465 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
466 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
467 |
view realize. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
468 |
newSel add:view. |
776 | 469 |
]. |
60 | 470 |
|
776 | 471 |
self withinTransaction:#paste objects:newSel do:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
472 |
undoHistory addUndoSelector:#undoCreate: |
1954 | 473 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]). |
474 |
self undoHistoryChanged. |
|
776 | 475 |
]. |
60 | 476 |
|
776 | 477 |
self realizeAllSubViews. |
478 |
newSel do:[:v| v raise]. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
479 |
self elementChangedSize:containerToPasteInto. |
134 | 480 |
|
776 | 481 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 482 |
^ newSel |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
483 |
|
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
484 |
"Modified: / 10.10.2001 / 14:15:12 / cg" |
89 | 485 |
! |
486 |
||
487 |
pasteWithLayout |
|
1959 | 488 |
"add the objects in the paste-buffer to the object view; |
489 |
don't change the layout" |
|
490 |
||
223 | 491 |
|sel| |
492 |
||
1872 | 493 |
sel := self pasteSpecifications:(self getClipboardObject) keepLayout:true. |
89 | 494 |
|
223 | 495 |
sel notNil ifTrue:[ |
1872 | 496 |
self select:sel. |
223 | 497 |
]. |
60 | 498 |
! ! |
499 |
||
500 |
!UIPainterView methodsFor:'drag & drop'! |
|
501 |
||
1953 | 502 |
canDrop:aCollectionOfDropObjects |
1914 | 503 |
"returns true if something can be dropped" |
504 |
||
2112 | 505 |
^ (aCollectionOfDropObjects size == 1 |
506 |
and:[ self enabled |
|
507 |
and:[ self numberOfSelections <= 1 |
|
508 |
and:[ aCollectionOfDropObjects first theObject isKindOf:UISpecification ]]]) |
|
509 |
||
510 |
"Modified: / 13-10-2006 / 11:38:01 / cg" |
|
223 | 511 |
! |
512 |
||
285 | 513 |
canPaste |
1914 | 514 |
"returns true if there is something which can be pasted in the clipboard" |
515 |
||
1872 | 516 |
^ self canPaste:(self getClipboardObject) |
285 | 517 |
! |
518 |
||
223 | 519 |
canPaste:something |
1914 | 520 |
"returns true if something could be pasted" |
521 |
||
223 | 522 |
|el size| |
523 |
||
524 |
((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
1914 | 525 |
^ false |
223 | 526 |
]. |
1914 | 527 |
something isCollection |
528 |
ifTrue:[something notEmpty ifTrue:[el := something first]] |
|
529 |
ifFalse:[el := something]. |
|
223 | 530 |
|
531 |
(el isKindOf:UISpecification) ifFalse:[ |
|
1914 | 532 |
^ false |
223 | 533 |
]. |
534 |
||
535 |
size == 1 ifTrue:[ |
|
1914 | 536 |
^ self canPasteInto:(self singleSelection) |
223 | 537 |
]. |
1914 | 538 |
^ true |
223 | 539 |
! |
540 |
||
541 |
canPasteInto:aView |
|
1914 | 542 |
"return true, if I can paste into a view" |
543 |
||
285 | 544 |
|prop| |
60 | 545 |
|
1870 | 546 |
aView isNil ifTrue:[ ^ false ]. |
547 |
||
548 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
549 |
^ prop spec class supportsSubComponents |
|
89 | 550 |
]. |
1870 | 551 |
^ aView specClass supportsSubComponents. |
60 | 552 |
! |
553 |
||
1953 | 554 |
drop:aCollectionOfDropObjects at:aPoint |
1833 | 555 |
|spec newSel oldSel dragOffset widg doit| |
556 |
||
557 |
doit := true. |
|
288 | 558 |
self selection notNil ifTrue:[ |
1953 | 559 |
oldSel := self singleSelection. |
560 |
||
561 |
"/ search selections hierarchy for a widget into which we can paste |
|
562 |
widg := oldSel. |
|
563 |
[widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
|
564 |
widg notNil ifTrue:[ |
|
565 |
widg := widg container |
|
566 |
]. |
|
567 |
]. |
|
568 |
||
569 |
oldSel := nil. |
|
570 |
self setSelection:widg withRedraw:true. |
|
231 | 571 |
]. |
1953 | 572 |
spec := (aCollectionOfDropObjects at:1) theObject. |
1833 | 573 |
doit ifTrue:[ |
1953 | 574 |
dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
575 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
576 |
||
577 |
self select:(oldSel ? newSel) |
|
1833 | 578 |
]. |
1060
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
579 |
|
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
580 |
"Modified: / 18.3.1999 / 18:29:43 / stefan" |
1520
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
581 |
"Modified: / 30.10.2001 / 14:02:35 / cg" |
60 | 582 |
! ! |
583 |
||
361 | 584 |
!UIPainterView methodsFor:'event handling'! |
585 |
||
586 |
keyPress:key x:x y:y view:aView |
|
376 | 587 |
"a delegated keyEvent from aView" |
588 |
||
361 | 589 |
self keyPress:key x:x y:y |
590 |
||
376 | 591 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 592 |
! |
593 |
||
594 |
keyRelease:key x:x y:y view:aView |
|
376 | 595 |
"a delegated keyEvent from aView" |
596 |
||
361 | 597 |
self keyRelease:key x:x y:y |
598 |
||
376 | 599 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 600 |
! |
601 |
||
602 |
sizeChanged:how |
|
603 |
||
1834 | 604 |
super sizeChanged:how. |
754 | 605 |
|
606 |
self layoutChanged |
|
361 | 607 |
! ! |
608 |
||
78 | 609 |
!UIPainterView methodsFor:'generating output'! |
610 |
||
352 | 611 |
aspectMethods |
612 |
"extract a list of aspect methods - for browsing" |
|
613 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
614 |
|cls methods| |
352 | 615 |
|
616 |
className isNil ifTrue:[ |
|
1834 | 617 |
self warn:'No class defined !!'. |
618 |
^ #() |
|
352 | 619 |
]. |
620 |
||
621 |
cls := self resolveName:className. |
|
622 |
methods := IdentitySet new. |
|
623 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
624 |
self aspectSelectorsAndTypesDo: |
1834 | 625 |
[:selector :typeSymbol | |
626 |
|skip| |
|
627 |
||
628 |
(cls includesSelector:selector) ifTrue:[ |
|
629 |
||
630 |
skip := false. |
|
631 |
(typeSymbol == #modelAspect) ifTrue:[ |
|
632 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
633 |
skip := SimpleDialog includesSelector:(selector asSymbol) |
|
634 |
]. |
|
635 |
]. |
|
636 |
skip ifFalse:[ |
|
637 |
methods add:(cls compiledMethodAt:selector) |
|
638 |
]. |
|
639 |
] |
|
640 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
641 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
642 |
^ methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
643 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
644 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
645 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
646 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
647 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
648 |
aspectSelectorsAndTypesDo:aTwoArgBlock |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
649 |
"evaluate aBlock for every aspect methods selector; 2nd arg describes the aspects type" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
650 |
|
1726 | 651 |
|cls selector protoSpec| |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
652 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
653 |
className isNil ifTrue:[ |
1834 | 654 |
self warn:'No class defined !!'. |
655 |
^ self |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
656 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
657 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
658 |
cls := self resolveName:className. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
659 |
|
352 | 660 |
treeView propertiesDo:[:aProp| |
1834 | 661 |
|selector| |
662 |
||
663 |
(selector := aProp model) notNil ifTrue:[ |
|
664 |
selector isArray ifFalse:[ |
|
665 |
aTwoArgBlock value:(selector asSymbol) value:#modelAspect |
|
666 |
]. |
|
667 |
]. |
|
668 |
||
669 |
(selector := aProp menu) notNil ifTrue:[ |
|
670 |
selector isArray ifFalse:[ |
|
671 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
|
672 |
]. |
|
673 |
]. |
|
674 |
||
675 |
(aProp spec aspectSelectors) do:[:aSel | |
|
676 |
aSel isArray ifFalse:[ |
|
677 |
aTwoArgBlock value:(aSel asSymbol) value:#channelAspect |
|
678 |
]. |
|
679 |
]. |
|
680 |
aProp spec actionSelectors do:[:aSel| |
|
681 |
aSel isArray ifFalse:[ |
|
682 |
aTwoArgBlock value:(aSel asSymbol) value:#actionSelector |
|
683 |
]. |
|
684 |
]. |
|
685 |
aProp spec valueSelectors do:[:aSel| |
|
686 |
aSel isArray ifFalse:[ |
|
687 |
aTwoArgBlock value:(aSel asSymbol) value:#valueSelector |
|
688 |
]. |
|
689 |
] |
|
352 | 690 |
]. |
691 |
||
692 |
protoSpec := treeView canvasSpec. |
|
693 |
||
694 |
(selector := protoSpec menu) notNil ifTrue:[ |
|
1834 | 695 |
selector isArray ifFalse:[ |
696 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
|
697 |
]. |
|
352 | 698 |
]. |
699 |
! |
|
700 |
||
60 | 701 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
568 | 702 |
|selector args showIt code alreadyInSuperclass numArgs method| |
288 | 703 |
|
704 |
selector := aspect asSymbol. |
|
141 | 705 |
|
288 | 706 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
707 |
||
568 | 708 |
numArgs := selector numArgs. |
709 |
method := aspect. |
|
710 |
||
711 |
numArgs == 1 ifTrue:[ |
|
1834 | 712 |
args := 'anArgument'. |
713 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
714 |
] ifFalse:[ |
|
715 |
args := ''. |
|
716 |
showIt := ' ...''.\'. |
|
717 |
||
718 |
numArgs ~~ 0 ifTrue:[ |
|
719 |
method := ''. |
|
720 |
||
721 |
selector keywords keysAndValuesDo:[:i :key| |
|
722 |
method := method, key, 'arg', i printString, ' ' |
|
723 |
] |
|
724 |
] |
|
149 | 725 |
]. |
141 | 726 |
|
288 | 727 |
code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
1834 | 728 |
method , args , '\' , |
729 |
' "automatically generated by UIPainter ..."\\' , |
|
730 |
' "*** the code below performs no action"\' , |
|
731 |
' "*** (except for some feedback on the Transcript)"\' , |
|
732 |
' "*** Please change as required and accept in the browser."\' , |
|
733 |
'\' . |
|
288 | 734 |
|
735 |
alreadyInSuperclass ifTrue:[ |
|
1834 | 736 |
code := code , |
737 |
' "action for ' , aspect , ' is already provided in a superclass."\' , |
|
738 |
' "It may be redefined here ..."\\'. |
|
288 | 739 |
] ifFalse:[ |
1834 | 740 |
code := code , |
741 |
' "action to be added ..."\\'. |
|
288 | 742 |
]. |
743 |
||
744 |
code := code , |
|
1834 | 745 |
' Transcript showCR:self class name, '': '. |
288 | 746 |
alreadyInSuperclass ifTrue:[ |
1834 | 747 |
code := code , 'inherited '. |
288 | 748 |
]. |
749 |
code := code , 'action for ' , aspect , showIt. |
|
750 |
||
751 |
alreadyInSuperclass ifTrue:[ |
|
1834 | 752 |
code := code , |
753 |
' super ' , aspect , args , '.\'. |
|
288 | 754 |
]. |
755 |
||
756 |
code := code , |
|
1834 | 757 |
'!! !!\\'. |
288 | 758 |
^ code withCRs |
759 |
||
352 | 760 |
"Modified: / 25.10.1997 / 19:18:50 / cg" |
60 | 761 |
! |
762 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
763 |
generateAspectMethodCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
764 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
765 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
766 |
Return a string ready to compile into the application class." |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
767 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
768 |
^ self generateAspectMethodCodeFiltering:nil |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
769 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
770 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
771 |
generateAspectMethodCodeFiltering:aFilterOrEmpty |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
772 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
773 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
774 |
Return a string ready to compile into the application class." |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
775 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
776 |
|cls codePieces skip protoSpec thisCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
777 |
definedMethodSelectors iVars t exportSels| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
778 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
779 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
780 |
cls isNil ifTrue:[ |
2024 | 781 |
^ nil |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
782 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
783 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
784 |
codePieces := OrderedCollection new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
785 |
definedMethodSelectors := IdentitySet new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
786 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
787 |
treeView propertiesDo:[:aProp| |
2024 | 788 |
|modelSelector| |
789 |
||
790 |
protoSpec := aProp spec. |
|
791 |
||
792 |
(modelSelector := aProp model) notNil ifTrue:[ |
|
793 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
|
794 |
do:[:aSel| |
|
795 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
796 |
skip := false. |
|
797 |
||
798 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
799 |
skip := SimpleDialog includesSelector:aSel |
|
800 |
]. |
|
801 |
(definedMethodSelectors includes:aSel) ifTrue:[ |
|
802 |
skip := true. |
|
803 |
]. |
|
804 |
||
805 |
skip ifFalse:[ |
|
806 |
"/ kludge .. |
|
807 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
|
808 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
|
809 |
ifTrue:[ |
|
810 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
811 |
] ifFalse:[ |
|
812 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
813 |
]. |
|
814 |
codePieces add:thisCode. |
|
815 |
definedMethodSelectors add:aSel. |
|
816 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
817 |
] ifTrue:[ |
|
818 |
Transcript showCR:'*** no code generated for aspect: ' , aSel , ' (method already exists)' |
|
819 |
]. |
|
820 |
]. |
|
821 |
]. |
|
822 |
]. |
|
823 |
||
824 |
"/ for each aspect, generate getter (if not yet implemented) |
|
825 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
|
826 |
do:[:aSel| |
|
827 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
828 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
829 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
830 |
codePieces add:thisCode. |
|
831 |
definedMethodSelectors add:aSel. |
|
832 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
833 |
] |
|
834 |
] |
|
835 |
]. |
|
836 |
||
837 |
"/ exported aspects - need setter methods |
|
838 |
exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol]. |
|
839 |
self generateCodeFrom:exportSels in:cls |
|
840 |
do:[:aSel| |
|
841 |
|aspect| |
|
842 |
||
843 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
844 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
845 |
aspect := (aSel copyWithoutLast:1) asSymbol. |
|
846 |
thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls). |
|
847 |
codePieces add:thisCode. |
|
848 |
definedMethodSelectors add:aSel. |
|
849 |
Transcript showCR:'export code generated for aspect: ' , aSel |
|
850 |
] |
|
851 |
] |
|
852 |
]. |
|
853 |
||
854 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
855 |
do:[:aSel| |
|
856 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
857 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
858 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
859 |
codePieces add:thisCode. |
|
860 |
definedMethodSelectors add:aSel. |
|
861 |
Transcript showCR:'action generated for aspect: ' , aSel |
|
862 |
] |
|
863 |
] |
|
864 |
]. |
|
865 |
||
866 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
867 |
do:[:aSel| |
|
868 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
869 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
870 |
"/ uppercase: - assume its a globals name. |
|
871 |
aSel isUppercaseFirst ifFalse:[ |
|
872 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
|
873 |
codePieces add:thisCode. |
|
874 |
definedMethodSelectors add:aSel. |
|
875 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
876 |
] |
|
877 |
] |
|
878 |
] |
|
879 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
880 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
881 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
882 |
AspectsAsInstances ifTrue:[ |
2024 | 883 |
iVars := cls instVarNames asOrderedCollection. |
884 |
definedMethodSelectors do:[:ivar | |
|
885 |
(iVars includes:ivar) ifFalse:[ |
|
886 |
iVars add:ivar |
|
887 |
] |
|
888 |
]. |
|
889 |
iVars := iVars asArray. |
|
890 |
t := cls shallowCopy. |
|
891 |
t setInstanceVariableString:iVars asStringCollection asString. |
|
892 |
codePieces addFirst:(t definition , '!!\' withCRs). |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
893 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
894 |
|
1834 | 895 |
^ String |
2024 | 896 |
streamContents: |
897 |
[:codeStream | |
|
898 |
codePieces do:[:eachPiece | codeStream nextPutAll:eachPiece]. |
|
899 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
900 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
901 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
902 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
903 |
|
60 | 904 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
905 |
|modelClass modelValueString modelValue modelGen code| |
134 | 906 |
|
149 | 907 |
modelClass := protoSpec defaultModelClassFor:aspect. |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
908 |
modelValueString := protoSpec defaultModelValueStringFor:aspect. |
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
909 |
modelValueString notNil ifTrue:[ |
1834 | 910 |
modelGen := modelValueString |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
911 |
] ifFalse:[ |
1834 | 912 |
modelValue := protoSpec defaultModelValueFor:aspect. |
913 |
modelValue isNil ifTrue:[ |
|
914 |
modelGen := modelClass name , ' new' |
|
915 |
] ifFalse:[ |
|
916 |
modelGen := modelValue storeString , ' asValue' |
|
917 |
]. |
|
352 | 918 |
|
919 |
]. |
|
134 | 920 |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
921 |
code := '!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
60 | 922 |
aspect , '\' , |
352 | 923 |
' "automatically generated by UIPainter ..."\\' , |
924 |
' "*** the code below creates a default model when invoked."\' , |
|
925 |
' "*** (which may not be the one you wanted)"\' , |
|
1441
36916e4ce9ab
generate better comments (in aspect methods)
Claus Gittinger <cg@exept.de>
parents:
1429
diff
changeset
|
926 |
' "*** Please change as required and accept it in the browser."\' , |
36916e4ce9ab
generate better comments (in aspect methods)
Claus Gittinger <cg@exept.de>
parents:
1429
diff
changeset
|
927 |
' "*** (and replace this comment by something more useful ;-)"\' . |
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
928 |
|
1474 | 929 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
930 |
AspectsAsInstances ifTrue:[ |
1834 | 931 |
code := code , '\' , |
932 |
' ' , aspect , ' isNil ifTrue:[\' , |
|
933 |
' ' , aspect , ' := ' , modelGen , '.\'. |
|
934 |
modelClass ~~ TriggerValue ifTrue:[ |
|
935 |
code := code , |
|
936 |
'"/ if your app needs to be notified of changes, uncomment one of the lines below:\' , |
|
937 |
'"/ ' , aspect , ' addDependent:self.\' , |
|
938 |
'"/ ' , aspect , ' onChangeSend:#', aspect ,'Changed to:self.\'. |
|
939 |
]. |
|
940 |
code := code , |
|
941 |
' ].\' , |
|
942 |
' ^ ' , aspect ,'.\' , |
|
943 |
'!! !!\\' |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
944 |
] ifFalse:[ |
1834 | 945 |
code := code , '\' , |
946 |
' |holder|\' , |
|
947 |
'\' , |
|
948 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
949 |
' holder := ', modelGen, '.\', |
|
950 |
' builder aspectAt:#' , aspect , ' put:holder.\'. |
|
951 |
modelClass ~~ TriggerValue ifTrue:[ |
|
952 |
code := code , |
|
953 |
'"/ if your app needs to be notified of changes, uncomment one of the lines below:\' , |
|
954 |
'"/ holder addDependent:self.\' , |
|
955 |
'"/ holder onChangeSend:#', aspect ,'Changed to:self.\'. |
|
956 |
]. |
|
957 |
code := code , |
|
958 |
' ].\' , |
|
959 |
' ^ holder.\' , |
|
960 |
'!! !!\\' |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
961 |
]. |
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
962 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
963 |
^ code withCRs |
352 | 964 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
965 |
"Modified: / 29.7.1998 / 11:29:16 / cg" |
1225 | 966 |
"Modified: / 22.9.1999 / 12:33:47 / stefan" |
60 | 967 |
! |
968 |
||
1358 | 969 |
generateAspectSelectorsMethod |
970 |
"generate aspectSelectors method. |
|
971 |
Return a string ready to compile into the application class." |
|
972 |
||
973 |
|cls code spec| |
|
974 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
975 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
976 |
cls isNil ifTrue:[ |
1834 | 977 |
^ nil |
1358 | 978 |
]. |
979 |
||
980 |
spec := treeView exportedAspects. |
|
981 |
spec size == 0 ifTrue:[^ nil]. |
|
982 |
||
983 |
"/ make it an array ... |
|
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
984 |
spec := spec collect:[:entry | |subAspect type| |
1834 | 985 |
subAspect := entry subAspect asSymbol. |
986 |
(type := entry type) isNil ifTrue:[ |
|
987 |
subAspect |
|
988 |
] ifFalse:[ |
|
989 |
Array with:subAspect with:type asSymbol |
|
990 |
]. |
|
991 |
]. |
|
1358 | 992 |
spec := spec asArray. |
993 |
||
994 |
code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' . |
|
995 |
||
996 |
code := code , 'aspectSelectors |
|
997 |
"This resource specification was automatically generated |
|
998 |
by the UIPainter of ST/X." |
|
999 |
||
1000 |
"Do not manually edit this. If it is corrupted, |
|
1001 |
the UIPainter may not be able to read the specification." |
|
1002 |
||
1003 |
"Return a description of exported aspects; |
|
1004 |
these can be connected to aspects of an embedding application |
|
1005 |
(if this app is embedded in a subCanvas)." |
|
1006 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1007 |
^ #(\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1008 |
spec do:[:el | code := code , (' ' , el storeString , '\') ]. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1009 |
code := code , ' ).\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1010 |
code := code , '\!!\'. |
1358 | 1011 |
code := code withCRs. |
1012 |
^ code |
|
1013 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1014 |
"Modified: / 18.2.2000 / 02:08:34 / cg" |
1358 | 1015 |
! |
1016 |
||
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1017 |
generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1018 |
|code| |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1019 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1020 |
code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1021 |
aspect , ':something\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1022 |
' "automatically generated by UIPainter ..."\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1023 |
' "This method is used when I am embedded as subApplication,"\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1024 |
' "and the mainApp wants to connect its aspects to mine."\'. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1025 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1026 |
AspectsAsInstances ifTrue:[ |
1834 | 1027 |
code := (code , '\' , |
1028 |
'"/ ' , aspect , ' notNil ifTrue:[\' , |
|
1029 |
'"/ ' , aspect , ' removeDependent:self.\' , |
|
1030 |
'"/ ].\' , |
|
1031 |
' ' , aspect ,' := something.\' , |
|
1032 |
'"/ ' , aspect ,' notNil ifTrue:[\' , |
|
1033 |
'"/ ' , aspect , ' addDependent:self.\' , |
|
1034 |
'"/ ].\' , |
|
1035 |
' ^ self.\' , |
|
1036 |
'!! !!\\') |
|
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1037 |
] ifFalse:[ |
1834 | 1038 |
code := (code , '\' , |
1039 |
'"/ |holder|\' , |
|
1040 |
'\' , |
|
1041 |
'"/ (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' , |
|
1042 |
'"/ holder removeDependent:self.\' , |
|
1043 |
'"/ ].\' , |
|
1044 |
' builder aspectAt:#' , aspect , ' put:something.\', |
|
1045 |
'"/ something notNil ifTrue:[\' , |
|
1046 |
'"/ something addDependent:self.\' , |
|
1047 |
'"/ ].\' , |
|
1048 |
' ^ self.\' , |
|
1049 |
'!! !!\\') |
|
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1050 |
]. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1051 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1052 |
^ code withCRs |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1053 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1054 |
"Modified: / 29.7.1998 / 11:29:16 / cg" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1055 |
"Modified: / 22.9.1999 / 12:33:47 / stefan" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1056 |
! |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1057 |
|
698 | 1058 |
generateCodeFrom:aListOfSelectors in:aClass do:aBlock |
1696 | 1059 |
|realSelectors redefCondition redefMessage| |
1060 |
||
1061 |
realSelectors := aListOfSelectors select:[:sel | sel isArray not]. |
|
698 | 1062 |
|
744 | 1063 |
self class redefineAspectMethods ifTrue:[ |
1834 | 1064 |
redefCondition := [:cls :sel | (cls includesSelector:sel) not]. |
1065 |
redefMessage := ' skipped - already implemented in the class'. |
|
698 | 1066 |
] ifFalse:[ |
1834 | 1067 |
redefCondition := [:cls :sel | (cls canUnderstand:sel) not]. |
1068 |
redefMessage := ' skipped - already implemented in the class (or superclass)'. |
|
1696 | 1069 |
]. |
1070 |
||
1071 |
realSelectors do:[:aSelector| |
|
1834 | 1072 |
(redefCondition value:aClass value:aSelector) ifTrue:[ |
1073 |
aBlock value:aSelector asSymbol |
|
1074 |
] ifFalse:[ |
|
1075 |
Transcript showCR:('#' , aSelector , redefMessage) |
|
1076 |
] |
|
698 | 1077 |
] |
376 | 1078 |
! |
1079 |
||
1080 |
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
|
1081 |
^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
|
1082 |
selectorSpec , '\' , |
|
1083 |
' "automatically generated by UIPainter ..."\\' , |
|
1084 |
' "*** the code here does nothing. It is invoked when"\' , |
|
1085 |
' "*** ' , commentWhen , '"\' , |
|
1086 |
' "*** Please change as required and accept in the browser."\' , |
|
1087 |
'\' , |
|
1088 |
' "specific code to be added below ..."\' , |
|
1089 |
' "' , (noteOrNil ? '') , '"\' , |
|
1090 |
'\' , |
|
1091 |
(defaultCode ? '^ self.') , |
|
1092 |
'!! !!\\') withCRs |
|
1093 |
||
1094 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
|
1095 |
"Created: / 31.10.1997 / 17:31:53 / cg" |
|
1096 |
! |
|
1097 |
||
1098 |
generateHookMethods |
|
1099 |
"generate hook methods |
|
1100 |
- but do not overwrite existing ones. |
|
1101 |
Return a string ready to compile into the application class." |
|
1102 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1103 |
|cls| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1104 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1105 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1106 |
cls isNil ifTrue:[ |
1834 | 1107 |
^ nil |
376 | 1108 |
]. |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1109 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1110 |
^ self generateHookMethodsInClass:cls. |
376 | 1111 |
! |
1112 |
||
1113 |
generateHookMethodsInClass:targetClass |
|
1114 |
|code| |
|
1115 |
||
1116 |
code := ''. |
|
1117 |
||
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1118 |
(targetClass includesSelector:#postBuildWith:) ifFalse:[ |
1834 | 1119 |
code := code |
1120 |
, (self |
|
1121 |
generateHookMethodFor:'postBuildWith:aBuilder' |
|
1122 |
comment:'the widgets have been built, but before the view is opened' |
|
1123 |
note:'or after the super send' |
|
1124 |
defaultCode:' super postBuildWith:aBuilder' |
|
1125 |
inClass:targetClass) |
|
376 | 1126 |
]. |
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1127 |
(targetClass includesSelector:#postOpenWith:) ifFalse:[ |
1834 | 1128 |
code := code |
1129 |
, (self |
|
1130 |
generateHookMethodFor:'postOpenWith:aBuilder' |
|
1131 |
comment:'the topView has been opened, but before events are dispatched for it' |
|
1132 |
note:'or after the super send' |
|
1133 |
defaultCode:' super postOpenWith:aBuilder' |
|
1134 |
inClass:targetClass) |
|
376 | 1135 |
]. |
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1136 |
(targetClass includesSelector:#closeRequest) ifFalse:[ |
1834 | 1137 |
code := code |
1138 |
, (self |
|
1139 |
generateHookMethodFor:'closeRequest' |
|
1140 |
comment:'the topView has been asked to close' |
|
1141 |
note:'return without the ''super closeRequest'' to stay open' |
|
1142 |
defaultCode:' ^super closeRequest' |
|
1143 |
inClass:targetClass) |
|
376 | 1144 |
]. |
1145 |
^ code |
|
1146 |
||
1147 |
"Modified: / 31.10.1997 / 17:30:34 / cg" |
|
1148 |
"Created: / 31.10.1997 / 17:32:49 / cg" |
|
316 | 1149 |
! |
1150 |
||
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1151 |
generateMenuMethodFor:menuSel inClass:targetClass |
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1152 |
|selector args showIt code alreadyInSuperclass numArgs method category| |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1153 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1154 |
selector := menuSel asSymbol. |
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1155 |
category := UserPreferences current categoryForMenuActionsMethods. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1156 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1157 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1158 |
|
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1159 |
code := '!!' , targetClass name , ' methodsFor:''' , category , '''!!\\'. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1160 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1161 |
selector = 'openAboutThisApplication' ifTrue:[ |
1834 | 1162 |
code := code , |
1163 |
'openAboutThisApplication\' , |
|
1164 |
' "opens an about box for this application."\\' , |
|
1165 |
' "automatically generated by UIPainter ..."\\' , |
|
1166 |
||
1167 |
' |rev box myClass clsRev image msg|\\' , |
|
1168 |
||
1169 |
' rev := ''''.\' , |
|
1170 |
' myClass := self class.\' , |
|
1171 |
||
1172 |
' (clsRev := myClass revision) notNil ifTrue:[\' , |
|
1173 |
' rev := '' (rev: '', clsRev printString, '')''].\\' , |
|
1174 |
||
1175 |
' msg := Character cr asString , myClass name asBoldText, rev.\' , |
|
1176 |
' msg := (msg , ''\\*** add more info here ***\\'') withCRs.\\' , |
|
1177 |
' box := AboutBox title:msg.\' , |
|
1178 |
||
1179 |
' "/ *** add a #defaultIcon method in the class\' , |
|
1180 |
' "/ *** and uncomment the following line:\' , |
|
1181 |
' "/ image := self class defaultIcon.\\' , |
|
1182 |
' image notNil ifTrue:[\' , |
|
1183 |
' box image:image\' , |
|
1184 |
' ].\' , |
|
1185 |
' box label:(resources string:''About %1'' with:myClass name).\' , |
|
1186 |
' box autoHideAfter:10 with:[].\' , |
|
1187 |
' box showAtPointer.\' , |
|
1188 |
'!! !!\\'. |
|
1189 |
^ code withCRs |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1190 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1191 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1192 |
selector = 'menuOpen' ifTrue:[ |
1834 | 1193 |
code := code , |
1194 |
'menuOpen\' , |
|
1195 |
' "automatically generated by UIPainter ..."\\' , |
|
1196 |
' "*** the code below opens a dialog for file selection"\' , |
|
1197 |
' "*** and invokes the #doOpen: method with the selected file."\' , |
|
1198 |
' "*** Please change as required and accept in the browser."\\' , |
|
1199 |
' |file|\\' , |
|
1200 |
' file :=\' , |
|
1201 |
' (FileSelectionBrowser\' , |
|
1202 |
' request: ''Open''\' , |
|
1203 |
' fileName: ''''\' , |
|
1204 |
' "/ inDirectory: lastOpenDirectory\' , |
|
1205 |
' withFileFilters: #(''*'')).\\' , |
|
1206 |
' file notNil ifTrue:[\' , |
|
1207 |
' "/ lastOpenDirectory := file asFilename directory.\' , |
|
1208 |
' self doOpen:file\' , |
|
1209 |
' ]\' , |
|
1210 |
'!! !!\'. |
|
1211 |
^ code withCRs |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1212 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1213 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1214 |
numArgs := selector numArgs. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1215 |
method := selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1216 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1217 |
numArgs == 1 ifTrue:[ |
1834 | 1218 |
args := 'anArgument'. |
1219 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
1220 |
] ifFalse:[ |
|
1221 |
args := ''. |
|
1222 |
showIt := ' ...''.\'. |
|
1223 |
||
1224 |
numArgs ~~ 0 ifTrue:[ |
|
1225 |
method := ''. |
|
1226 |
||
1227 |
selector keywords keysAndValuesDo:[:i :key| |
|
1228 |
method := method, key, 'arg', i printString, ' ' |
|
1229 |
] |
|
1230 |
] |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1231 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1232 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1233 |
code := code , |
1834 | 1234 |
method , args , '\' , |
1235 |
' "automatically generated by UIPainter ..."\\' , |
|
1236 |
' "*** the code below performs no action"\' , |
|
1237 |
' "*** (except for some feedback on the Transcript)"\' , |
|
1238 |
' "*** Please change as required and accept in the browser."\' , |
|
1239 |
'\' . |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1240 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1241 |
alreadyInSuperclass ifTrue:[ |
1834 | 1242 |
code := code , |
1243 |
' "action for ' , selector , ' is already provided in a superclass."\' , |
|
1244 |
' "It may be redefined here ..."\\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1245 |
] ifFalse:[ |
1834 | 1246 |
code := code , |
1247 |
' "action to be added ..."\\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1248 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1249 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1250 |
code := code , |
1834 | 1251 |
' Transcript showCR:self class name, '': '. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1252 |
alreadyInSuperclass ifTrue:[ |
1834 | 1253 |
code := code , 'inherited '. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1254 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1255 |
code := code , 'menu action for ' , selector , showIt. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1256 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1257 |
alreadyInSuperclass ifTrue:[ |
1834 | 1258 |
code := code , |
1259 |
' super ' , selector , args , '.\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1260 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1261 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1262 |
code := code , |
1834 | 1263 |
'!! !!\\'. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1264 |
^ code withCRs |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1265 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1266 |
"Created: / 23.8.1998 / 16:46:51 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1267 |
"Modified: / 23.8.1998 / 18:13:05 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1268 |
! |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1269 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1270 |
generateMenuMethods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1271 |
"generate menu methods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1272 |
- but do not overwrite existing ones. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1273 |
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
|
1274 |
|
1069 | 1275 |
|cls code menuSelector thisCode |
1276 |
definedMethodSelectors |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1277 |
specArray fullSpec winSpec menuSpec |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1278 |
| |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1279 |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1280 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1281 |
cls isNil ifTrue:[ |
1834 | 1282 |
^ nil |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1283 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1284 |
|
1058 | 1285 |
specArray := treeView generateFullSpecForComponents:#() named:nil. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1286 |
fullSpec := specArray decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1287 |
winSpec := fullSpec window. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1288 |
menuSelector := winSpec menu. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1289 |
|
1834 | 1290 |
(menuSelector notNil |
1069 | 1291 |
and:[ (cls respondsTo:menuSelector) ]) ifFalse:[ |
1834 | 1292 |
self warn:'No menu defined (yet)'. |
1293 |
^ nil. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1294 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1295 |
menuSpec := cls perform:menuSelector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1296 |
menuSpec := menuSpec decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1297 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1298 |
definedMethodSelectors := IdentitySet new. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1299 |
code := ''. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1300 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1301 |
menuSpec allItemsDo:[:item | |
1834 | 1302 |
|sel| |
1303 |
||
1304 |
(sel := item value) notNil ifTrue:[ |
|
1305 |
(definedMethodSelectors includes:sel) ifFalse:[ |
|
1306 |
self generateCodeFrom:(Array with:sel) in:cls do:[:aSel| |
|
1307 |
thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
|
1308 |
code := code, thisCode. |
|
1309 |
]. |
|
1310 |
definedMethodSelectors add:sel. |
|
1311 |
]. |
|
1312 |
] |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1313 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1314 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1315 |
(definedMethodSelectors includes:#menuOpen) ifTrue:[ |
1834 | 1316 |
self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel| |
1317 |
thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
|
1318 |
code := code, thisCode. |
|
1319 |
]. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1320 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1321 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1322 |
^ code |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1323 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1324 |
"Created: / 23.8.1998 / 16:12:09 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1325 |
"Modified: / 23.8.1998 / 18:12:23 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1326 |
! |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1327 |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1328 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1329 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1330 |
aspect , '\' , |
352 | 1331 |
' "automatically generated by UIPainter ..."\\' , |
1332 |
' "*** the code below returns a default value when invoked."\' , |
|
1333 |
' "*** (which may not be the one you wanted)"\' , |
|
1334 |
' "*** Please change as required and accept in the browser."\' , |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1335 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1336 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1337 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1338 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1339 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1340 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1341 |
|
352 | 1342 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1343 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
1344 |
|
78 | 1345 |
generateWindowSpecMethodSource |
457 | 1346 |
|spec str code category cls mthd specCode| |
60 | 1347 |
|
310 | 1348 |
spec := OrderedCollection new. |
60 | 1349 |
|
78 | 1350 |
self subViews do:[:aView| |
1834 | 1351 |
|vSpec| |
1352 |
||
1353 |
"/ care for wrapped views ... |
|
1354 |
vSpec := self fullSpecFor:aView. |
|
1355 |
vSpec isNil ifTrue:[ |
|
1356 |
aView subViews size == 1 ifTrue:[ |
|
1357 |
vSpec := self fullSpecFor:(aView subViews first). |
|
1358 |
] |
|
1359 |
]. |
|
1360 |
vSpec isNil ifTrue:[ |
|
1361 |
self warn:'Oops - could not create spec for some view' |
|
1362 |
]. |
|
1363 |
spec add:vSpec |
|
60 | 1364 |
]. |
1058 | 1365 |
|
1366 |
spec := treeView generateFullSpecForComponents:spec named:methodName. |
|
310 | 1367 |
str := WriteStream on:String new. |
1368 |
UISpecification prettyPrintSpecArray:spec on:str indent:5. |
|
464 | 1369 |
specCode := str contents. |
457 | 1370 |
|
1371 |
(specCode includes:$!!) ifTrue:[ |
|
1834 | 1372 |
"/ oops - must be chunk format ... |
1373 |
str := WriteStream on:String new. |
|
1374 |
str nextPutAllAsChunk:specCode. |
|
1375 |
specCode := str contents. |
|
457 | 1376 |
]. |
60 | 1377 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1378 |
"/ 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
|
1379 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1380 |
category := 'interface specs'. |
330 | 1381 |
cls := self resolveName:className. |
1382 |
||
1383 |
cls notNil ifTrue:[ |
|
1834 | 1384 |
(mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[ |
1385 |
category := mthd category. |
|
1386 |
] |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1387 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
1388 |
|
238 | 1389 |
code := '!!' |
1834 | 1390 |
, className , ' class methodsFor:' , category storeString |
1391 |
, '!!' , '\\' |
|
1392 |
||
1393 |
, methodName , '\' |
|
1394 |
, ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!') |
|
1395 |
, '\\ "\' |
|
1396 |
, (' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\'). |
|
1013 | 1397 |
|
1050
355a8ff451b6
care for as-yet-unspecified class in show-spec menu item.
Claus Gittinger <cg@exept.de>
parents:
1039
diff
changeset
|
1398 |
(cls notNil and:[cls isSubclassOf:ApplicationModel]) ifTrue:[ |
1834 | 1399 |
code := code |
1400 |
, (' ' , className , ' new openInterface:#' , methodName , '\'). |
|
1013 | 1401 |
]. |
1402 |
||
1403 |
code := code |
|
1834 | 1404 |
,(methodName = 'windowSpec' |
1405 |
ifTrue:[' ' , className , ' open\'] ifFalse: ['']) |
|
1406 |
, ' "\'. |
|
1407 |
||
1408 |
code := code |
|
1409 |
, '\' |
|
1410 |
, ' <resource: #canvas>\\' |
|
1411 |
, ' ^ ' , specCode |
|
1412 |
, '\' |
|
1413 |
, '!! !!' |
|
1414 |
, '\\'. |
|
60 | 1415 |
|
1416 |
^ code withCRs |
|
1417 |
||
1013 | 1418 |
"Modified: / 5.9.1995 / 21:01:35 / claus" |
1419 |
"Modified: / 15.10.1998 / 11:29:53 / cg" |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1420 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1421 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1422 |
targetClass |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1423 |
|cls| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1424 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1425 |
className isNil ifTrue:[ |
1834 | 1426 |
self warn:'No TargetClass defined !!'. |
1427 |
^ nil |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1428 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1429 |
(cls := self resolveName:className) isNil ifTrue:[ |
1834 | 1430 |
self warn:('Class ', className asString, ' does not exist !!'). |
1431 |
^ nil |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1432 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1433 |
^ cls. |
60 | 1434 |
! ! |
1435 |
||
754 | 1436 |
!UIPainterView methodsFor:'grid manipulation'! |
1437 |
||
1438 |
newGrid |
|
1439 |
"define a new grid - this is a private helper which has to be |
|
1440 |
called after any change in the grid. It (re)creates the gridPixmap, |
|
1441 |
clears the view and redraws all visible objects." |
|
1442 |
||
1443 |
|defaultViewBackground| |
|
1444 |
||
1445 |
gridPixmap := nil. |
|
1446 |
defaultViewBackground := self class defaultViewBackgroundColor. |
|
1447 |
||
1448 |
shown ifTrue:[ |
|
1834 | 1449 |
self viewBackground: (defaultViewBackground isColor |
1450 |
ifTrue: [defaultViewBackground] |
|
1451 |
ifFalse:[Black]). |
|
1452 |
self clear. |
|
754 | 1453 |
]. |
1454 |
||
1455 |
gridShown ifTrue:[ |
|
1834 | 1456 |
self defineGrid. |
1457 |
gridPixmap colorMap: (defaultViewBackground isColor |
|
1458 |
ifTrue: [Array with:defaultViewBackground with:Color darkGray] |
|
1459 |
ifFalse:[Array with:White with:Black]). |
|
1460 |
self viewBackground:gridPixmap. |
|
754 | 1461 |
]. |
1462 |
||
1463 |
self invalidate |
|
1464 |
||
1465 |
! ! |
|
1466 |
||
1832 | 1467 |
!UIPainterView methodsFor:'group & ungroup'! |
1468 |
||
1469 |
group |
|
1470 |
||
1471 |
self groupSelectionWithLayout: false |
|
1472 |
! |
|
1473 |
||
1474 |
groupSelectionWithLayout: withLayout |
|
1475 |
| spec rect views box layout specs canvas view oldSelection cS nViews menu item xOffset yOffset | |
|
1476 |
||
1477 |
menu := Menu new. |
|
1478 |
menu receiver: self. |
|
1479 |
item := MenuItem label:'Box' value:[spec := ViewSpec new]. |
|
1480 |
menu addItem: item. |
|
1481 |
item := MenuItem label:'TBox' value:[spec := TBoxSpec new]. |
|
1482 |
menu addItem: item. |
|
1483 |
item := MenuItem label:'FramedBox' value:[spec := FramedBoxSpec new]. |
|
1484 |
menu addItem: item. |
|
1485 |
item := MenuItem label:'HorizontalPanel' value:[spec := HorizontalPanelViewSpec new]. |
|
1486 |
menu addItem: item. |
|
1487 |
item := MenuItem label:'VerticalPanel' value:[spec := VerticalPanelViewSpec new]. |
|
1488 |
menu addItem: item. |
|
1489 |
(MenuPanel menu: menu) startUp. |
|
1490 |
canvas := self painter. |
|
1491 |
cS := canvas getSelectedViewsAndSpecs. |
|
1492 |
cS isNil ifTrue:[^self]. |
|
1493 |
views := cS first. |
|
1834 | 1494 |
specs := cS last. |
1832 | 1495 |
rect := views first frame. |
1496 |
2 to: views size do:[:i| rect := rect merge: (views at: i) frame]. |
|
1834 | 1497 |
layout := LayoutFrame leftFraction:0.0 offset: rect origin x |
1498 |
rightFraction:0.0 offset: rect corner x + 1 |
|
1499 |
topFraction:0.0 offset: rect origin y |
|
1500 |
bottomFraction:0.0 offset:rect corner y + 1. |
|
1832 | 1501 |
oldSelection := canvas selection. |
1502 |
canvas select: views first superView. |
|
1503 |
spec layout: layout. |
|
1504 |
spec class == VerticalPanelViewSpec ifTrue:[ |
|
1834 | 1505 |
spec verticalLayout: #topSpace. |
1506 |
spec horizontalLayout: #fit. |
|
1832 | 1507 |
]. |
1508 |
spec class == HorizontalPanelViewSpec ifTrue:[ |
|
1834 | 1509 |
spec verticalLayout: #fit. |
1510 |
spec horizontalLayout: #leftSpace. |
|
1832 | 1511 |
]. |
1512 |
||
1513 |
box := self pasteSpecifications:spec keepLayout:true at:nil. |
|
1514 |
||
1515 |
xOffset := box origin x. |
|
1516 |
yOffset := box origin y. |
|
1517 |
withLayout ifFalse:[ |
|
1834 | 1518 |
1 to: specs size do:[:i| |
1519 |
view := views at: i. |
|
1520 |
layout := LayoutFrame leftFraction:0.0 offset: (view origin x - xOffset) |
|
1521 |
rightFraction:0.0 offset: (view corner x - xOffset + 1) |
|
1522 |
topFraction:0.0 offset: (view origin y - yOffset ) |
|
1523 |
bottomFraction:0.0 offset: (view corner y - yOffset + 1). |
|
1524 |
(specs at: i) layout: layout. |
|
1525 |
]. |
|
1526 |
]. |
|
1832 | 1527 |
canvas selection: oldSelection. |
1528 |
canvas deleteSelection. |
|
1529 |
canvas selection:box. |
|
1530 |
nViews := canvas pasteSpecifications:specs keepLayout:true. |
|
1531 |
canvas selection: box. |
|
1532 |
! |
|
1533 |
||
1534 |
groupWithLayout |
|
1535 |
||
1536 |
self groupSelectionWithLayout: true |
|
1537 |
! |
|
1538 |
||
1539 |
ungroup |
|
1540 |
||
1541 |
self ungroupSelectionWithLayout: false |
|
1542 |
! |
|
1543 |
||
1544 |
ungroupSelectionWithLayout: withLayout |
|
1545 |
||
1546 |
| canvas cS views specs frame view layout superView| |
|
1547 |
||
1548 |
canvas := self painter. |
|
1549 |
cS := canvas getSelectedViewsAndSpecs. |
|
1550 |
cS isNil ifTrue:[^self]. |
|
1551 |
views := cS first first subViews copy. |
|
1552 |
superView := cS first first superView. |
|
1553 |
cS last first component isNil ifTrue:[^self]. |
|
1554 |
cS last first component collection isEmpty ifTrue:[^self]. |
|
1834 | 1555 |
specs := cS last first component collection copy. |
1832 | 1556 |
frame := cS first first frame. |
1557 |
canvas deleteSelection. |
|
1558 |
withLayout ifFalse:[ |
|
1834 | 1559 |
1 to: specs size do:[:i| |
1560 |
view := views at: i. |
|
1561 |
layout := LayoutFrame leftFraction:0.0 offset: (view origin x + frame origin x) |
|
1562 |
rightFraction:0.0 offset: (view corner x + frame origin x + 1) |
|
1563 |
topFraction:0.0 offset: (view origin y + frame origin y ) |
|
1564 |
bottomFraction:0.0 offset: (view corner y + frame origin y + 1). |
|
1565 |
(specs at: i) layout: layout. |
|
1566 |
]. |
|
1567 |
]. |
|
1832 | 1568 |
canvas selection: superView. |
1569 |
canvas pasteSpecifications:specs keepLayout:true. |
|
1570 |
canvas selection: superView. |
|
1571 |
! |
|
1572 |
||
1573 |
ungroupWithLayout |
|
1574 |
||
1575 |
self ungroupSelectionWithLayout: true |
|
1576 |
! ! |
|
1577 |
||
60 | 1578 |
!UIPainterView methodsFor:'initialization'! |
1579 |
||
770 | 1580 |
create |
1959 | 1581 |
"colors on device" |
1582 |
||
770 | 1583 |
super create. |
1959 | 1584 |
handleColorBlack := handleColorBlack onDevice:device. |
1585 |
handleColorWhite := handleColorWhite onDevice:device. |
|
1201 | 1586 |
handleMasterColor := handleMasterColor onDevice:device. |
770 | 1587 |
! |
1588 |
||
60 | 1589 |
initialize |
62 | 1590 |
"setup attributes |
1591 |
" |
|
60 | 1592 |
super initialize. |
770 | 1593 |
superclassName := 'ApplicationModel'. |
1594 |
className := 'NewApplication'. |
|
1595 |
methodName := 'windowSpec'. |
|
1596 |
categoryName := 'Applications'. |
|
1597 |
HandCursor := Cursor leftHand. |
|
1467
b46624bb6994
use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents:
1450
diff
changeset
|
1598 |
handleColorBlack := Color black. |
b46624bb6994
use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents:
1450
diff
changeset
|
1599 |
handleColorWhite := Color white. |
770 | 1600 |
handleMasterColor := Color red. |
60 | 1601 |
|
712 | 1602 |
self backgroundColor: self class defaultViewBackgroundColor. |
60 | 1603 |
! |
1604 |
||
1605 |
setupFromSpec:specOrSpecArray |
|
784 | 1606 |
|
78 | 1607 |
|spec builder| |
60 | 1608 |
|
784 | 1609 |
Cursor wait showWhile: [ |
1834 | 1610 |
self removeAll. |
1611 |
specOrSpecArray notNil ifTrue:[ |
|
1612 |
spec := UISpecification from:specOrSpecArray. |
|
1613 |
]. |
|
1614 |
builder := UIBuilder new isEditing:true. |
|
1615 |
"set applicationClass, in order that subspecifications may be resolved" |
|
1616 |
className notNil ifTrue:[ |
|
1617 |
builder applicationClass:(self resolveName:className). |
|
1618 |
]. |
|
1619 |
spec notNil ifTrue:[ |
|
1620 |
spec window setupView:self topView for:builder. |
|
1621 |
self addSpec:(spec component) builder:builder in:self. |
|
1622 |
]. |
|
1623 |
self realizeAllSubViews. |
|
1624 |
spec notNil ifTrue:[ |
|
1625 |
treeView setAttributesFromWindowSpec:(spec window) |
|
1626 |
]. |
|
1671 | 1627 |
]. |
223 | 1628 |
! |
1629 |
||
1630 |
treeView:aTreeView |
|
361 | 1631 |
treeView := aTreeView. |
1632 |
||
1633 |
treeView delegate:( |
|
1834 | 1634 |
"/ |
1635 |
"/ I want to handle everything typed |
|
1636 |
"/ in the treeView, except for Return and Cursor-keys |
|
1637 |
"/ |
|
1638 |
KeyboardForwarder |
|
1639 |
toView:self |
|
1640 |
condition:nil |
|
1641 |
filter:[:k | (k isSymbol |
|
1642 |
and:[k ~~ #Return |
|
1643 |
and:[k ~~ #Tab |
|
1644 |
and:[(k startsWith:#Cursor) not]]]) |
|
1645 |
] |
|
361 | 1646 |
) |
1647 |
||
376 | 1648 |
"Modified: / 31.10.1997 / 20:22:09 / cg" |
60 | 1649 |
! ! |
1650 |
||
1651 |
!UIPainterView methodsFor:'menus'! |
|
1652 |
||
121 | 1653 |
showMiddleButtonMenu |
1654 |
"show the middle button menu; this returns nil |
|
62 | 1655 |
" |
1635 | 1656 |
|
1657 |
|m| |
|
1658 |
||
223 | 1659 |
self enabled ifTrue:[ |
1834 | 1660 |
m := MenuPanel fromSpec:(UIPainter menuEdit) receiver:self superView application. |
1661 |
self startUpMenu:m |
|
111 | 1662 |
]. |
121 | 1663 |
^ nil |
60 | 1664 |
! ! |
1665 |
||
1714 | 1666 |
!UIPainterView methodsFor:'private-handles'! |
754 | 1667 |
|
1832 | 1668 |
painter |
1669 |
^ treeView canvas |
|
1670 |
! |
|
1671 |
||
754 | 1672 |
showSelected:aComponent |
1673 |
"show object selected |
|
1674 |
" |
|
1543 | 1675 |
|wasClipped sel hColor bg| |
754 | 1676 |
|
1677 |
selectionHiddenLevel == 0 ifTrue:[ |
|
1834 | 1678 |
sel := treeView selection. |
1679 |
(sel size > 1 and: |
|
1680 |
[(treeView model list at: sel first) contents view == aComponent]) |
|
1681 |
ifTrue: [ |
|
1682 |
hColor := handleMasterColor |
|
1683 |
] ifFalse:[ |
|
1684 |
bg := aComponent viewBackground. |
|
1685 |
bg isColor ifTrue:[ |
|
1686 |
bg brightness < 0.5 ifTrue:[ |
|
1687 |
hColor := handleColorWhite |
|
1688 |
] ifFalse:[ |
|
1689 |
hColor := handleColorBlack |
|
1690 |
] |
|
1691 |
] ifFalse:[ |
|
1692 |
hColor := handleColorBlack |
|
1693 |
] |
|
1694 |
]. |
|
1695 |
||
1696 |
self paint:hColor. |
|
1697 |
||
1698 |
(wasClipped := clipChildren) ifTrue:[ |
|
1699 |
self clippedByChildren:(clipChildren := false). |
|
1700 |
]. |
|
1701 |
||
1702 |
self handlesOf:aComponent do:[:aRectangle :what| |l t w h| |
|
1703 |
l := aRectangle left + 1. |
|
1704 |
t := aRectangle top + 1. |
|
1705 |
w := aRectangle width - 2. |
|
1706 |
h := aRectangle height - 2. |
|
1707 |
||
1708 |
what == #view ifTrue:[self displayRectangleX:l y:t width:w height:h] |
|
1709 |
ifFalse:[self fillRectangleX:l y:t width:w height:h] |
|
1710 |
]. |
|
1711 |
||
1712 |
wasClipped ifTrue:[ |
|
1713 |
self clippedByChildren:(clipChildren := true). |
|
1714 |
] |
|
754 | 1715 |
] |
1543 | 1716 |
|
1717 |
"Modified: / 6.12.2001 / 00:00:16 / cg" |
|
754 | 1718 |
! ! |
1719 |
||
335 | 1720 |
!UIPainterView methodsFor:'queries'! |
1721 |
||
1722 |
resolveName:aName |
|
1723 |
|appl| |
|
1724 |
||
1725 |
appl := self application. |
|
1726 |
||
1727 |
appl notNil ifTrue:[ |
|
1834 | 1728 |
^ appl resolveName:aName |
335 | 1729 |
]. |
1730 |
^ Smalltalk resolveName:aName inClass:self class |
|
1731 |
! ! |
|
1732 |
||
60 | 1733 |
!UIPainterView methodsFor:'removing components'! |
1734 |
||
78 | 1735 |
remove:anObject |
1736 |
"remove anObject from the contents do redraw |
|
60 | 1737 |
" |
134 | 1738 |
anObject notNil ifTrue:[ |
1834 | 1739 |
treeView removeView:anObject. |
134 | 1740 |
] |
60 | 1741 |
! |
1742 |
||
1743 |
removeAll |
|
62 | 1744 |
"remove all objects and properties |
1745 |
" |
|
776 | 1746 |
self select:nil. |
1747 |
treeView removeAll. |
|
1748 |
self removeUndoHistory. |
|
60 | 1749 |
! ! |
1750 |
||
1751 |
!UIPainterView methodsFor:'searching'! |
|
1752 |
||
285 | 1753 |
findContainerOfView:aView |
1754 |
"returns the super view assigned to a view |
|
89 | 1755 |
" |
285 | 1756 |
|p| |
89 | 1757 |
|
285 | 1758 |
(p := self propertyOfParentForView:aView) isNil ifTrue:[ |
1834 | 1759 |
^ self |
89 | 1760 |
]. |
285 | 1761 |
^ p view |
89 | 1762 |
! |
1763 |
||
60 | 1764 |
findObjectAt:aPoint |
1765 |
"find the origin/corner of the currentWidget |
|
1766 |
" |
|
285 | 1767 |
|view prop| |
60 | 1768 |
|
1769 |
view := super findObjectAt:aPoint. |
|
1870 | 1770 |
prop := self propertyOfView:view. |
60 | 1771 |
|
285 | 1772 |
prop notNil ifTrue:[^ prop view]. |
1870 | 1773 |
^ nil |
60 | 1774 |
! |
1775 |
||
1776 |
findViewWithId:aViewId |
|
62 | 1777 |
"finds view assigned to identifier and returns the view or nil |
60 | 1778 |
" |
1779 |
|prop| |
|
1780 |
||
1781 |
prop := self propertyOfIdentifier:aViewId. |
|
1782 |
||
1783 |
prop notNil ifTrue:[^ prop view] |
|
1834 | 1784 |
ifFalse:[^ nil] |
78 | 1785 |
! |
1786 |
||
1787 |
propertyOfIdentifier:anId |
|
1788 |
"returns property assigned to unique identifier |
|
1789 |
" |
|
1790 |
anId notNil ifTrue:[ |
|
1834 | 1791 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 1792 |
]. |
1793 |
^ nil |
|
1794 |
! |
|
1795 |
||
1796 |
propertyOfName:aString |
|
1797 |
"returns property assigned to name |
|
1798 |
" |
|
111 | 1799 |
|name| |
1800 |
||
1801 |
aString isNil ifFalse:[ |
|
1834 | 1802 |
name := aString string withoutSeparators. |
238 | 1803 |
^ treeView propertyDetect:[:p| p name = name ]. |
78 | 1804 |
]. |
1805 |
^ nil |
|
1806 |
! |
|
1807 |
||
285 | 1808 |
propertyOfParentForView:aSubView |
1809 |
"returns the property of the parent or nil |
|
1810 |
" |
|
1811 |
|item| |
|
1812 |
||
1870 | 1813 |
(item := treeView detectItemCorespondingToView:aSubView) notNil ifTrue:[ |
1814 |
(item := item parent) notNil ifTrue:[^ item contents] |
|
285 | 1815 |
]. |
1816 |
^ nil |
|
1817 |
! |
|
1818 |
||
78 | 1819 |
propertyOfView:aView |
1870 | 1820 |
"detect the property for the argument, a view. The property of the view or |
285 | 1821 |
the first subview providing the properties is returned. If no property is detected |
1822 |
nil is returned. |
|
1823 |
" |
|
1824 |
|item| |
|
1825 |
||
1870 | 1826 |
item := treeView detectItemCorespondingToView:aView. |
285 | 1827 |
|
1828 |
(item notNil and:[item parent notNil]) ifTrue:[ |
|
1870 | 1829 |
^ item contents |
285 | 1830 |
]. |
1831 |
^ nil |
|
1832 |
! |
|
1833 |
||
111 | 1834 |
uniqueNameFor:aSpecOrString |
78 | 1835 |
"generate and return an unique name for a class |
1836 |
" |
|
1837 |
|next name size| |
|
1838 |
||
712 | 1839 |
aSpecOrString isString ifFalse:[name := aSpecOrString userFriendlyName] |
1834 | 1840 |
ifTrue:[name := aSpecOrString]. |
78 | 1841 |
|
111 | 1842 |
size := name size + 1. |
1843 |
next := 0. |
|
78 | 1844 |
|
238 | 1845 |
treeView propertiesDo:[:p| |
1834 | 1846 |
|n| |
1847 |
n := p name. |
|
1848 |
||
1849 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
1850 |
next := next max:(p extractNumberStartingAt:size) |
|
1851 |
] |
|
78 | 1852 |
]. |
1853 |
next := next + 1. |
|
1854 |
name := name, next printString. |
|
1855 |
^ name |
|
1856 |
||
1857 |
||
1858 |
||
662 | 1859 |
|
78 | 1860 |
! |
1861 |
||
1862 |
uniqueNameOf:aView |
|
111 | 1863 |
|prop| |
78 | 1864 |
|
111 | 1865 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
1834 | 1866 |
prop name isNil ifTrue:[ |
1867 |
prop name:(self uniqueNameFor:(prop spec)). |
|
1868 |
]. |
|
1869 |
^ prop name |
|
78 | 1870 |
]. |
111 | 1871 |
^ 'self' |
78 | 1872 |
|
60 | 1873 |
! ! |
1874 |
||
223 | 1875 |
!UIPainterView methodsFor:'selection basics'! |
1876 |
||
1877 |
addToSelection:anObject |
|
1878 |
"add an object to the selection |
|
1879 |
" |
|
1880 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
1834 | 1881 |
selection isCollection ifFalse:[ |
1882 |
selection isNil ifTrue:[ |
|
1883 |
selection := anObject |
|
1884 |
] ifFalse:[ |
|
1885 |
selection := OrderedCollection with:selection with:anObject |
|
1886 |
] |
|
1887 |
] ifTrue:[ |
|
1888 |
"/ to enforce the change-message (value is identical to oldValue) |
|
1889 |
selection isList ifTrue:[ |
|
1890 |
selection add:anObject |
|
1891 |
] ifFalse:[ |
|
1892 |
selection := selection asOrderedCollection. |
|
1893 |
selection := selection copyWith:anObject |
|
1894 |
] |
|
1895 |
]. |
|
1896 |
self showSelected:anObject. |
|
1897 |
treeView cvsSelectionAdd:anObject. |
|
223 | 1898 |
] |
1899 |
||
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1900 |
"Modified: / 11.2.2000 / 01:39:05 / cg" |
223 | 1901 |
! |
1902 |
||
1903 |
removeFromSelection:anObject |
|
1904 |
"remove an object from the selection |
|
1905 |
" |
|
1906 |
(self isSelected:anObject) ifTrue:[ |
|
1834 | 1907 |
self showUnselected:anObject. |
1908 |
||
1909 |
selection size > 1 ifTrue:[ |
|
1910 |
selection isList ifTrue:[ |
|
1911 |
selection remove:anObject ifAbsent:nil |
|
1912 |
] ifFalse:[ |
|
1913 |
"/ to enforce the change-message (value is identical to oldValue) |
|
1914 |
selection := selection asOrderedCollection. |
|
1915 |
selection := selection copyWithout:anObject |
|
1916 |
]. |
|
1917 |
self showSelection. |
|
1918 |
] ifFalse:[ |
|
1919 |
selection := nil |
|
1920 |
]. |
|
1921 |
treeView cvsSelectionRemove:anObject. |
|
223 | 1922 |
] |
1923 |
||
1347
c4046d0b638e
care for multiSelect into a non-list;
Claus Gittinger <cg@exept.de>
parents:
1338
diff
changeset
|
1924 |
"Modified: / 11.2.2000 / 01:41:11 / cg" |
223 | 1925 |
! |
1926 |
||
1927 |
select:something |
|
1928 |
"change selection to something |
|
1834 | 1929 |
" |
1930 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
|
1931 |
something isNil |
|
1932 |
ifTrue: [treeView selection: (Array with: 1)] |
|
1933 |
ifFalse:[treeView cvsSelection:something]. |
|
1934 |
self setSelection:something withRedraw:true |
|
223 | 1935 |
] |
1936 |
||
1937 |
! |
|
1938 |
||
1830 | 1939 |
selectNextUpInHierarchy |
1940 |
| sel | |
|
1941 |
||
1942 |
(sel := self selection) isNil ifTrue:[^self]. |
|
1943 |
sel isCollection ifTrue:[ |
|
1834 | 1944 |
sel := self selection first. |
1830 | 1945 |
]. |
1946 |
sel := sel superView. |
|
1947 |
sel isNil ifTrue:[^self]. |
|
1948 |
treeView cvsSelection: sel. |
|
1949 |
self selection: sel. |
|
1950 |
! |
|
1951 |
||
285 | 1952 |
updateSelectionFromModel:aSelOrNil |
223 | 1953 |
"update selection from a new selection |
1954 |
" |
|
1427 | 1955 |
|list| |
768 | 1956 |
|
2039 | 1957 |
self shown ifFalse:[^ self]. |
1958 |
||
223 | 1959 |
selectionHiddenLevel == 0 ifTrue:[ |
2039 | 1960 |
aSelOrNil size ~~ 0 ifTrue:[ |
1961 |
list := OrderedCollection new. |
|
1962 |
||
1963 |
self selectionDo:[:el| |
|
1964 |
(aSelOrNil includes:el) ifFalse:[list add:el] |
|
1965 |
]. |
|
1966 |
self showUnselected:list. |
|
1967 |
] ifFalse:[ |
|
1968 |
self hideSelection. |
|
1969 |
] |
|
223 | 1970 |
]. |
285 | 1971 |
self setSelection:aSelOrNil withRedraw:false. |
223 | 1972 |
self showSelection |
1973 |
! ! |
|
1974 |
||
78 | 1975 |
!UIPainterView methodsFor:'specification'! |
1976 |
||
1977 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
1978 |
"build view and subviews from aSpecification into a frame. The top view |
|
1979 |
is returned. The contained components of a spec are set to nil |
|
1980 |
" |
|
330 | 1981 |
|cls| |
212 | 1982 |
|
330 | 1983 |
cls := self resolveName:className. |
1984 |
||
1985 |
cls notNil ifTrue:[ |
|
1834 | 1986 |
aBuilder applicationClass:cls. |
212 | 1987 |
]. |
78 | 1988 |
|
111 | 1989 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
1834 | 1990 |
p := ViewProperty new. |
1991 |
s := aSpec copy. |
|
1992 |
p spec:s. |
|
1993 |
p view:aView. |
|
1994 |
||
1995 |
s class supportsSubComponents ifTrue:[ |
|
1996 |
s component:nil |
|
1997 |
]. |
|
1998 |
||
1999 |
n := s name. |
|
2000 |
||
2001 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
2002 |
s name:(self uniqueNameFor:s) |
|
2003 |
]. |
|
2004 |
treeView addProperty:p. |
|
78 | 2005 |
]. |
2006 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 2007 |
|
212 | 2008 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 2009 |
! |
2010 |
||
2011 |
fullSpecFor:anObject |
|
2012 |
"generate a full spec for an object |
|
62 | 2013 |
" |
78 | 2014 |
|mySpec subSpecs| |
2015 |
||
2016 |
mySpec := self specFor:anObject. |
|
2017 |
||
2018 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
1834 | 2019 |
(anObject subViews notNil) ifTrue:[ |
2020 |
anObject subViews do:[:aSubView||spec| |
|
2021 |
spec := self fullSpecFor:aSubView. |
|
2022 |
spec notNil ifTrue:[ |
|
2023 |
subSpecs isNil ifTrue:[ |
|
2024 |
subSpecs := OrderedCollection new |
|
2025 |
]. |
|
2026 |
subSpecs add:spec. |
|
2027 |
]. |
|
2028 |
]. |
|
2029 |
subSpecs notNil ifTrue:[ |
|
2030 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
2031 |
] |
|
2032 |
] |
|
78 | 2033 |
]. |
2034 |
^ mySpec |
|
2035 |
||
60 | 2036 |
|
2037 |
||
2038 |
||
2039 |
||
2040 |
||
2041 |
! |
|
2042 |
||
1173 | 2043 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil |
2044 |
|v builder| |
|
2045 |
||
2046 |
(builder := aBuilderOrNil) isNil ifTrue:[ |
|
1834 | 2047 |
"/ create a dummy builder |
2048 |
builder := UIBuilder new isEditing:true. |
|
2049 |
className notNil ifTrue:[ |
|
2050 |
builder applicationClass:(self resolveName:className). |
|
2051 |
]. |
|
1173 | 2052 |
]. |
285 | 2053 |
|
1252
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
2054 |
aSpec class isLayoutContainer ifTrue:[ |
1834 | 2055 |
"/ TODO: |
2056 |
"/ go through subviews and let them resize to their default/preferred |
|
2057 |
"/ needed if we change a containers layout from fit to non-fit. |
|
2058 |
||
2059 |
(aView subViews ? #()) do:[:aSubView | |
|
2060 |
|fix spec prop| |
|
2061 |
||
2062 |
(prop := self propertyOfView:aSubView) notNil ifTrue:[ |
|
2063 |
spec := prop spec. |
|
2064 |
||
2065 |
spec useDefaultExtent ifTrue:[ |
|
2066 |
fix := aSubView sizeFixed:false. |
|
2067 |
aSubView extent:aSubView preferredExtent. |
|
2068 |
aSubView sizeFixed:fix |
|
2069 |
] |
|
2070 |
] |
|
2071 |
]. |
|
1252
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
2072 |
]. |
f886528c2b35
when changing a layoutContainer
Claus Gittinger <cg@exept.de>
parents:
1230
diff
changeset
|
2073 |
|
285 | 2074 |
aSpec needsRebuildForAttributes ifTrue:[ |
1834 | 2075 |
"/ needs a full rebuild (in case view class depends upon spec-attribute) |
2076 |
v := aSpec buildViewWithLayoutFor:builder in:(self findContainerOfView:aView). |
|
2077 |
v realize. |
|
2078 |
aView destroy. |
|
2079 |
device sync. |
|
2080 |
device flush. |
|
2081 |
aView becomeSameAs:v. |
|
2082 |
"/ inputView raise. |
|
285 | 2083 |
] ifFalse:[ |
1834 | 2084 |
aSpec setAttributesIn:aView with:builder. |
2085 |
self elementChangedSize:aView. |
|
285 | 2086 |
]. |
1832 | 2087 |
|
285 | 2088 |
! |
2089 |
||
78 | 2090 |
specFor:anObject |
2091 |
"returns spec assigned to an object |
|
62 | 2092 |
" |
78 | 2093 |
|prop spec| |
60 | 2094 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2095 |
(prop := self propertyOfView:anObject) isNil ifTrue:[^ nil]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2096 |
spec := prop spec copy. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2097 |
spec layoutFromView:anObject. |
78 | 2098 |
^ spec |
60 | 2099 |
! |
2100 |
||
146 | 2101 |
specForSelection |
2102 |
"returns spec assigned to current single selection or nil |
|
2103 |
" |
|
2104 |
^ self specFor:(self singleSelection) |
|
2105 |
||
2106 |
||
2107 |
! |
|
2108 |
||
78 | 2109 |
updateFromSpec:aSpec |
2110 |
"update current selected view from specification |
|
62 | 2111 |
" |
1173 | 2112 |
|props name| |
78 | 2113 |
|
281 | 2114 |
aSpec class == WindowSpec ifTrue:[ |
1834 | 2115 |
^ treeView canvasSpec:aSpec |
281 | 2116 |
]. |
2117 |
||
78 | 2118 |
self singleSelection notNil ifTrue:[ |
1834 | 2119 |
self withSelectionHiddenDo:[ |
2120 |
self transaction:#specification selectionDo:[:aView| |
|
2121 |
props := self propertyOfView:aView. |
|
2122 |
name := (aSpec name) withoutSeparators. |
|
2123 |
||
2124 |
name = props name ifFalse:[ |
|
2125 |
(self propertyOfName:name) notNil ifTrue:[ |
|
2126 |
name := props name |
|
2127 |
] |
|
2128 |
]. |
|
2129 |
||
2130 |
aSpec name:name. |
|
2131 |
self createUndoSpecModify:props. |
|
2132 |
self rebuildView:aView fromSpec:aSpec withBuilder:nil. |
|
2133 |
props spec:(aSpec copy). |
|
2134 |
treeView propertyChanged:props. |
|
2135 |
] |
|
2136 |
] |
|
82 | 2137 |
] |
212 | 2138 |
|
1520
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2139 |
"Modified: / 30.10.2001 / 13:59:45 / cg" |
60 | 2140 |
! ! |
2141 |
||
285 | 2142 |
!UIPainterView methodsFor:'testing'! |
2143 |
||
2144 |
canChangeLayoutOfView:aView |
|
2145 |
"returns true if the view can change its layout which is dependant on |
|
2146 |
its parent view. |
|
2147 |
" |
|
2148 |
|item prnt| |
|
2149 |
||
2150 |
( (item := treeView itemOfView:aView) isNil |
|
2151 |
or:[(prnt := item parent) isNil] |
|
2152 |
) ifTrue:[ |
|
1834 | 2153 |
^ false |
285 | 2154 |
]. |
2155 |
^ (prnt parent isNil or:[prnt contents spec class isLayoutContainer not]) |
|
2156 |
! |
|
2157 |
||
1230
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2158 |
canExchangeSelectionLayouts |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2159 |
"returns true if the selection size is exactly 2 |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2160 |
and all elements in the selection can be moved or aligned |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2161 |
" |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2162 |
selection size == 2 ifFalse:[ |
1834 | 2163 |
^ false |
1230
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2164 |
]. |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2165 |
^ self canMoveOrAlignSelection |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2166 |
|
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2167 |
! |
23e5d0c133e8
added exchangeLayouts function
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
2168 |
|
285 | 2169 |
canKeepLayoutInSelection |
2170 |
"returns true if layout can be kept during a paste operation |
|
2171 |
" |
|
2172 |
|prop| |
|
2173 |
||
2174 |
prop := self propertyOfView:(self singleSelection). |
|
2175 |
^ (prop isNil or:[prop spec class isLayoutContainer not]) |
|
2176 |
! |
|
2177 |
||
2178 |
canMove:something |
|
2179 |
"checks whether something is not nil and if all widgets derived from |
|
2180 |
something can change their layout ( move, align, ... operation ). |
|
2181 |
" |
|
2182 |
something notNil ifTrue:[ |
|
1834 | 2183 |
self forEach:something do:[:aView| |
2184 |
(self canChangeLayoutOfView:aView) ifFalse:[^ false] |
|
2185 |
]. |
|
2186 |
^ true |
|
285 | 2187 |
]. |
2188 |
^ false |
|
2189 |
! |
|
2190 |
||
2191 |
canMoveOrAlignSelection |
|
2192 |
"returns true if a selection exists and all elements in the selection |
|
2193 |
can be moved or aligned |
|
2194 |
" |
|
2195 |
^ self canMove:(self selection) |
|
2196 |
||
2197 |
! ! |
|
2198 |
||
60 | 2199 |
!UIPainterView methodsFor:'transaction'! |
2200 |
||
2201 |
transaction:aType objects:something do:aOneArgBlock |
|
2202 |
"opens a transaction and evaluates a block within the transaction; the |
|
2203 |
argument to the block is a view from derived from something |
|
2204 |
" |
|
134 | 2205 |
self withinTransaction:aType objects:something do:[ |
1834 | 2206 |
self forEach:something do:aOneArgBlock |
60 | 2207 |
] |
2208 |
! |
|
2209 |
||
1954 | 2210 |
withinTransaction:aType objects:objects do:aNoArgBlock |
134 | 2211 |
"evaluate a block with no arguments within a transaction |
60 | 2212 |
" |
134 | 2213 |
|text size prop| |
2214 |
||
2215 |
objects isNil ifTrue:[ ^ self ]. |
|
2216 |
||
2217 |
size := objects size. |
|
60 | 2218 |
|
134 | 2219 |
objects isCollection ifTrue:[ |
1954 | 2220 |
size == 0 ifTrue:[ ^ self ]. |
2221 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
134 | 2222 |
] ifFalse:[ |
1954 | 2223 |
prop := self propertyOfView:objects |
134 | 2224 |
]. |
60 | 2225 |
|
134 | 2226 |
prop notNil ifTrue:[ |
1954 | 2227 |
text := prop name |
134 | 2228 |
] ifFalse:[ |
1954 | 2229 |
text := size printString, ' elements' |
60 | 2230 |
]. |
134 | 2231 |
|
1954 | 2232 |
undoHistory withinTransaction:aType text:text do:aNoArgBlock. |
2233 |
self undoHistoryChanged. |
|
60 | 2234 |
! ! |
2235 |
||
2236 |
!UIPainterView methodsFor:'undo actions'! |
|
2237 |
||
134 | 2238 |
createUndoLayout:aView |
2239 |
"create undo action before changing a views layout |
|
60 | 2240 |
" |
134 | 2241 |
|lyt args prop| |
60 | 2242 |
|
2243 |
undoHistory isTransactionOpen ifTrue:[ |
|
1954 | 2244 |
prop := self propertyOfView:aView. |
2245 |
||
2246 |
prop notNil ifTrue:[ |
|
2247 |
args := Array new:3. |
|
2248 |
args at:1 put:(prop identifier). |
|
2249 |
||
2250 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
2251 |
args at:2 put:#geometryLayout: |
|
2252 |
] ifFalse:[ |
|
2253 |
lyt := aView extent. |
|
2254 |
args at:2 put:#extent: |
|
2255 |
]. |
|
2256 |
args at:3 put:(lyt copy). |
|
2257 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
2258 |
self undoHistoryChanged. |
|
2259 |
] |
|
60 | 2260 |
] |
2261 |
! |
|
2262 |
||
134 | 2263 |
createUndoRemove:aView |
2264 |
"create undo method before deleting views |
|
60 | 2265 |
" |
285 | 2266 |
|prop pid| |
134 | 2267 |
|
2268 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
1954 | 2269 |
(pid := self propertyOfParentForView:aView) notNil ifTrue:[ |
2270 |
pid := pid identifier |
|
2271 |
]. |
|
2272 |
||
2273 |
undoHistory addUndoSelector:#undoRemove: |
|
2274 |
withArgs:(Array with:(self fullSpecFor:aView) |
|
2275 |
with:(prop identifier) |
|
2276 |
with:pid). |
|
2277 |
self undoHistoryChanged. |
|
134 | 2278 |
] |
2279 |
! |
|
60 | 2280 |
|
134 | 2281 |
createUndoSpecModify:aProp |
2282 |
"undo method when changing the specification for an object |
|
2283 |
" |
|
2284 |
aProp notNil ifTrue:[ |
|
1954 | 2285 |
undoHistory addUndoSelector:#undoSpecModify: |
2286 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)). |
|
2287 |
self undoHistoryChanged. |
|
134 | 2288 |
] |
2289 |
! |
|
60 | 2290 |
|
134 | 2291 |
undoCreate:something |
2292 |
"undo method for creating or pasting an object |
|
2293 |
" |
|
2294 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
2295 |
! |
|
60 | 2296 |
|
1520
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2297 |
undoHistory |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2298 |
^ undoHistory |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2299 |
|
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2300 |
"Created: / 30.10.2001 / 13:42:45 / cg" |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2301 |
! |
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
2302 |
|
134 | 2303 |
undoLayout:args |
2304 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
2305 |
" |
|
2306 |
|view| |
|
2307 |
||
2308 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
1834 | 2309 |
view perform:(args at:2) with:(args at:3). |
2310 |
self layoutChanged. |
|
60 | 2311 |
] |
2312 |
! |
|
2313 |
||
134 | 2314 |
undoRemove:args |
2315 |
"undo method when removing an object; see 'createUndoRemove:' |
|
2316 |
" |
|
2317 |
|frame prop view| |
|
2318 |
||
2319 |
(args at:3) notNil ifTrue:[ |
|
1834 | 2320 |
frame := self findViewWithId:(args at:3). |
134 | 2321 |
]. |
2322 |
frame isNil ifTrue:[ |
|
1834 | 2323 |
frame := self |
134 | 2324 |
]. |
395 | 2325 |
view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame. |
134 | 2326 |
view realize. |
2327 |
||
2328 |
prop := self propertyOfView:view. |
|
2329 |
prop identifier:(args at:2). |
|
2330 |
! |
|
2331 |
||
2332 |
undoSpecModify:args |
|
2333 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 2334 |
" |
1173 | 2335 |
|view spec props| |
60 | 2336 |
|
134 | 2337 |
props := self propertyOfIdentifier:(args at:2). |
60 | 2338 |
|
134 | 2339 |
props notNil ifTrue:[ |
1834 | 2340 |
view := props view. |
2341 |
spec := args at:1. |
|
2342 |
||
2343 |
props spec:spec. |
|
2344 |
self rebuildView:view fromSpec:spec withBuilder:nil. |
|
2345 |
treeView propertyChanged:props. |
|
211 | 2346 |
] |
2347 |
! ! |
|
2348 |
||
2349 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
2350 |
||
2351 |
new |
|
2352 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1834 | 2353 |
ifFalse:[Identifier := 1]. |
211 | 2354 |
|
2355 |
^ self basicNew initialize |
|
2356 |
! ! |
|
2357 |
||
2358 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
2359 |
||
2360 |
identifier |
|
2361 |
"return the unique identifier assigned to property |
|
2362 |
" |
|
2363 |
^ identifier |
|
2364 |
! |
|
2365 |
||
2366 |
identifier:anIdentifier |
|
2367 |
"set the unique identifier assigned to property; called after an restore of |
|
2368 |
a deleted instance |
|
2369 |
" |
|
2370 |
identifier := anIdentifier |
|
2371 |
! |
|
2372 |
||
2373 |
spec |
|
2374 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
2375 |
||
1427 | 2376 |
^ spec |
2377 |
! |
|
211 | 2378 |
|
2379 |
spec:something |
|
2380 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
2381 |
||
1427 | 2382 |
spec := something. |
2383 |
! |
|
211 | 2384 |
|
2385 |
view |
|
2386 |
"return the value of the instance variable 'view' (automatically generated)" |
|
2387 |
||
1427 | 2388 |
^ view |
2389 |
! |
|
211 | 2390 |
|
2391 |
view:something |
|
2392 |
"set the value of the instance variable 'view' (automatically generated)" |
|
2393 |
||
1427 | 2394 |
view := something. |
2395 |
! ! |
|
211 | 2396 |
|
2397 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
2398 |
||
2399 |
initialize |
|
2400 |
super initialize. |
|
2401 |
identifier := Identifier |
|
2402 |
! ! |
|
2403 |
||
2404 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
2405 |
||
2406 |
extractNumberStartingAt:anIndex |
|
2407 |
"return the number from the name starting at anIndex or 0. |
|
2408 |
" |
|
2409 |
|val| |
|
2410 |
||
2411 |
val := 0. |
|
2412 |
||
2413 |
self name from:anIndex do:[:c| |
|
1834 | 2414 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
2415 |
ifFalse:[^ 0] |
|
211 | 2416 |
]. |
2417 |
^ val |
|
1834 | 2418 |
|
211 | 2419 |
! ! |
2420 |
||
2421 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
2422 |
||
2423 |
doesNotUnderstand:aMessage |
|
2424 |
spec notNil ifTrue:[ |
|
1834 | 2425 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
211 | 2426 |
]. |
2427 |
^ nil |
|
2428 |
! |
|
2429 |
||
2430 |
layout |
|
1664 | 2431 |
^ spec layout |
211 | 2432 |
! |
2433 |
||
2434 |
layout:aLayout |
|
2435 |
spec layout:aLayout |
|
2436 |
! |
|
2437 |
||
2438 |
name |
|
2439 |
^ spec name |
|
2440 |
! |
|
2441 |
||
2442 |
name:aName |
|
2443 |
spec name:aName |
|
2444 |
! ! |
|
2445 |
||
60 | 2446 |
!UIPainterView class methodsFor:'documentation'! |
2447 |
||
2448 |
version |
|
2449 |
^ '$Header$' |
|
2450 |
! ! |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
2451 |
|
1225 | 2452 |
UIPainterView initialize! |