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