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