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