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