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