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