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