author | Claus Gittinger <cg@exept.de> |
Fri, 04 Jul 2014 12:27:14 +0200 | |
changeset 3136 | 146b6f9e139c |
parent 3129 | 9a90a9d52bc6 |
child 3223 | 38d493fcc782 |
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' |
3097 | 18 |
classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances' |
60 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-UIPainter' |
|
21 |
! |
|
22 |
||
211 | 23 |
Object subclass:#ViewProperty |
24 |
instanceVariableNames:'view spec identifier' |
|
25 |
classVariableNames:'Identifier' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:UIPainterView |
|
28 |
! |
|
29 |
||
60 | 30 |
!UIPainterView class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
156 | 34 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 35 |
All Rights Reserved |
60 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
742 | 39 |
inclusion of the above copyright notice. This software may not |
60 | 40 |
be provided or otherwise made available to, or used by, any |
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
128 | 48 |
buildIn view used by the UIPainter; from this view, the layout of the |
49 |
new application derives from. |
|
50 |
||
51 |
[see also:] |
|
1834 | 52 |
UIBuilder |
53 |
UIObjectView |
|
156 | 54 |
|
55 |
[author:] |
|
1834 | 56 |
Claus Gittinger |
57 |
Claus Atzkern |
|
60 | 58 |
" |
59 |
! ! |
|
60 |
||
1225 | 61 |
!UIPainterView class methodsFor:'initialization'! |
62 |
||
63 |
initialize |
|
64 |
||
1494 | 65 |
AspectsAsInstances := true. "/ false. |
1225 | 66 |
RedefineAspectMethods := false. |
67 |
||
68 |
"Created: / 22.9.1999 / 12:32:31 / stefan" |
|
69 |
! ! |
|
70 |
||
698 | 71 |
!UIPainterView class methodsFor:'code generation mode'! |
72 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
73 |
generateAspectsAsInstanceVariables |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
74 |
"if on, aspects are held as instance variables; |
2244 | 75 |
if off (the default), they are kept in the bindings dictionary." |
76 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
77 |
^ AspectsAsInstances |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
78 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
79 |
"Created: / 29.7.1998 / 11:21:38 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
80 |
"Modified: / 29.7.1998 / 11:22:01 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
81 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
82 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
83 |
generateAspectsAsInstanceVariables:aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
84 |
"if on, aspects are held as instance variables; |
2244 | 85 |
if off (the default), they are kept in the bindings dictionary." |
86 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
87 |
AspectsAsInstances := aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
88 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
89 |
"Created: / 29.7.1998 / 11:21:26 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
90 |
"Modified: / 29.7.1998 / 11:22:11 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
91 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
92 |
|
2244 | 93 |
generateCommentedCode |
94 |
"comments in generated aspect methods; yes or no." |
|
95 |
||
2714
abaae556bec8
commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
96 |
^ UserPreferences current generateComments |
abaae556bec8
commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
97 |
and:[ UserPreferences current generateCommentsForAspectMethods ] |
2244 | 98 |
! |
99 |
||
100 |
generateCommentedCode:aBoolean |
|
101 |
"comments in generated aspect methods; yes or no." |
|
102 |
||
2716
ed0006640fb4
changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
103 |
UserPreferences current generateComments ifFalse:[ |
ed0006640fb4
changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
104 |
aBoolean ifTrue:[ |
ed0006640fb4
changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
105 |
UserPreferences current generateComments:true |
ed0006640fb4
changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
106 |
]. |
ed0006640fb4
changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
107 |
]. |
ed0006640fb4
changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
108 |
|
2714
abaae556bec8
commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
109 |
UserPreferences current |
2716
ed0006640fb4
changed: #generateCommentedCode:
Claus Gittinger <cg@exept.de>
parents:
2714
diff
changeset
|
110 |
generateCommentsForAspectMethods:aBoolean. |
2244 | 111 |
! |
112 |
||
742 | 113 |
redefineAspectMethods |
2244 | 114 |
"redefine methods yes or no. |
115 |
If a method is defined in super class should the message be reinstalled ?" |
|
116 |
||
1225 | 117 |
^ RedefineAspectMethods |
698 | 118 |
|
1225 | 119 |
"Modified: / 22.9.1999 / 12:33:03 / stefan" |
698 | 120 |
! |
121 |
||
742 | 122 |
redefineAspectMethods:aBoolean |
2244 | 123 |
"redefine methods yes or no. |
124 |
If a method is defined in super class should the message be reinstalled ?" |
|
125 |
||
742 | 126 |
RedefineAspectMethods := aBoolean |
698 | 127 |
! ! |
128 |
||
60 | 129 |
!UIPainterView class methodsFor:'defaults'! |
130 |
||
1834 | 131 |
defaultMenuMessage |
60 | 132 |
"This message is the default yo be sent to the menuHolder to get a menu |
133 |
" |
|
121 | 134 |
^ #showMiddleButtonMenu |
60 | 135 |
|
136 |
||
137 |
! ! |
|
138 |
||
139 |
!UIPainterView methodsFor:'accessing'! |
|
140 |
||
141 |
application |
|
142 |
^ nil |
|
143 |
||
144 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
145 |
! |
|
146 |
||
78 | 147 |
applicationName |
148 |
^ self className |
|
149 |
! |
|
150 |
||
151 |
applicationName:aName |
|
152 |
self className:aName |
|
153 |
! |
|
154 |
||
1977 | 155 |
class:aClass superclassName:aSuperclassName selector:aSelector |
156 |
self assert:(aClass isBehavior). |
|
157 |
className := aClass name. |
|
158 |
superclassName := aSuperclassName. |
|
159 |
methodName := aSelector. |
|
160 |
! |
|
161 |
||
60 | 162 |
className |
163 |
^ className |
|
164 |
! |
|
165 |
||
78 | 166 |
className:aName |
1977 | 167 |
self assert:(aName isString). |
78 | 168 |
className := aName |
60 | 169 |
! |
170 |
||
171 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
1977 | 172 |
self assert:(aClassName isString). |
78 | 173 |
className := aClassName. |
60 | 174 |
superclassName := aSuperclassName. |
78 | 175 |
methodName := aSelector. |
60 | 176 |
! |
177 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
178 |
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
|
179 |
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
|
180 |
! |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
181 |
|
60 | 182 |
methodName |
183 |
^ methodName |
|
184 |
! |
|
185 |
||
78 | 186 |
methodName:aName |
187 |
methodName := aName |
|
60 | 188 |
! |
189 |
||
190 |
selectNames:aStringOrCollection |
|
1031 | 191 |
|prop coll s n newSel| |
192 |
||
193 |
(aStringOrCollection size == 0) ifTrue:[ |
|
1834 | 194 |
newSel := nil. |
1031 | 195 |
] ifFalse:[ |
1834 | 196 |
(s := aStringOrCollection) isString ifFalse:[ |
197 |
s size == 1 ifTrue:[ |
|
198 |
s := s first |
|
199 |
] ifFalse:[ |
|
200 |
coll := OrderedCollection new. |
|
201 |
||
202 |
s do:[:aName| |
|
203 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
204 |
coll add:(prop view) |
|
205 |
] |
|
206 |
]. |
|
207 |
(n := coll size) == 1 ifTrue:[ |
|
208 |
newSel := coll at:1 |
|
209 |
] ifFalse:[ |
|
210 |
n == 0 ifTrue:[ |
|
211 |
newSel := nil |
|
212 |
] ifFalse:[ |
|
213 |
newSel := coll |
|
214 |
] |
|
215 |
]. |
|
216 |
^ self select:newSel. |
|
217 |
] |
|
218 |
]. |
|
219 |
||
220 |
prop := self propertyOfName:s. |
|
221 |
prop isNil ifTrue:[ |
|
222 |
newSel := nil |
|
223 |
] ifFalse:[ |
|
224 |
newSel := prop view |
|
225 |
]. |
|
60 | 226 |
]. |
227 |
||
1031 | 228 |
^ self select:newSel |
60 | 229 |
! ! |
230 |
||
111 | 231 |
!UIPainterView methodsFor:'change & update'! |
232 |
||
223 | 233 |
layoutChanged |
1445 | 234 |
treeView notNil ifTrue:[ |
1834 | 235 |
treeView layoutChanged |
1445 | 236 |
] |
111 | 237 |
! ! |
238 |
||
60 | 239 |
!UIPainterView methodsFor:'copy & cut & paste'! |
240 |
||
2221 | 241 |
changeSelectionAfterPasteOf:sel |
242 |
sel notNil ifTrue:[ |
|
243 |
self select:sel. |
|
244 |
]. |
|
245 |
! |
|
246 |
||
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
247 |
commonContainerOf:someComponents |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
248 |
|container| |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
249 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
250 |
container := someComponents first container. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
251 |
[container notNil |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
252 |
and:[ (someComponents conform:[:eachComponent | eachComponent isComponentOf:container]) not]] |
1834 | 253 |
whileTrue:[ |
254 |
container := container container. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
255 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
256 |
^ container |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
257 |
! |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
258 |
|
60 | 259 |
copySelection |
1959 | 260 |
"copy the selection into the cut & paste-buffer" |
261 |
||
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
262 |
|specs coll| |
71 | 263 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
264 |
coll := self minClosedViewSetFor:(self selection). |
60 | 265 |
|
71 | 266 |
coll notNil ifTrue:[ |
776 | 267 |
"/ self select:nil. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
268 |
specs := coll collect:[:eachView | self fullSpecWithAbsolutePositionFor:eachView]. |
1870 | 269 |
self setClipboardObject:specs. |
776 | 270 |
"/ treeView selection: sel |
60 | 271 |
]. |
272 |
! |
|
273 |
||
723 | 274 |
deleteSelection |
1959 | 275 |
"delete the selection buffered" |
276 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
277 |
self deleteSelectionBuffered: true |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
278 |
! |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
279 |
|
2396 | 280 |
deleteSelectionBuffered:buffered |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
281 |
"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
|
282 |
|
2396 | 283 |
|specs viewsToRemove newSelection firstView| |
71 | 284 |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
285 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
286 |
|
2396 | 287 |
viewsToRemove := self minClosedViewSetFor:(self selection). |
288 |
viewsToRemove isEmptyOrNil ifTrue:[ ^ self]. |
|
289 |
||
290 |
buffered ifTrue:[ |
|
291 |
specs := viewsToRemove collect:[:aView| self fullSpecWithAbsolutePositionFor:aView ]. |
|
292 |
self setClipboardObject:specs |
|
293 |
]. |
|
294 |
firstView := viewsToRemove first. |
|
295 |
newSelection := self findContainerOfView:firstView. |
|
296 |
||
297 |
newSelection isNil ifTrue:[ |
|
298 |
newSelection := self. |
|
299 |
] ifFalse:[ |
|
300 |
viewsToRemove size == 1 ifTrue:[ |
|
301 |
|subviews index| |
|
302 |
||
2508 | 303 |
"/ newSelection components notEmptyOrNil ifTrue:[ self halt ]. |
2396 | 304 |
subviews := newSelection subViews. |
305 |
||
306 |
subviews size > 1 ifTrue:[ |
|
307 |
index := subviews findFirst:[:eachView| eachView isSameOrComponentOf:firstView ]. |
|
308 |
index > 0 ifTrue:[ |
|
309 |
newSelection := subviews |
|
310 |
at:(index + 1) |
|
311 |
ifAbsent:[subviews at:index -1]. |
|
312 |
]. |
|
313 |
]. |
|
314 |
]. |
|
315 |
]. |
|
316 |
||
317 |
self withSelectionHiddenDo:[ |
|
318 |
self select:newSelection. |
|
319 |
||
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
320 |
treeView canvasEventsDisabledDo:[ |
2396 | 321 |
self withinTransaction:#cut objects:viewsToRemove do:[ |
322 |
viewsToRemove reverseDo:[:aView| |
|
1870 | 323 |
self createUndoRemove:aView. |
324 |
self remove:aView. |
|
325 |
] |
|
326 |
]. |
|
2396 | 327 |
]. |
328 |
self windowGroup processRealExposeEvents. |
|
329 |
]. |
|
698 | 330 |
! |
331 |
||
723 | 332 |
deleteTotalSelection |
1959 | 333 |
"delete the selection" |
334 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
335 |
self deleteSelectionBuffered: false |
60 | 336 |
! |
337 |
||
1832 | 338 |
getSelectedViewsAndSpecs |
339 |
"return an array filed with selected views and corresponding specs. |
|
1959 | 340 |
Nil if there is none." |
341 |
||
1832 | 342 |
|specs coll sel| |
343 |
||
344 |
sel := treeView selection. |
|
345 |
||
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
346 |
coll := self minClosedViewSetFor:(self selection). |
1832 | 347 |
|
348 |
coll isNil ifTrue:[^ nil]. |
|
349 |
||
350 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
351 |
^ Array with: coll with: specs |
|
352 |
! |
|
353 |
||
60 | 354 |
pasteBuffer |
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
355 |
"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
|
356 |
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
|
357 |
|
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
358 |
|sel clipboard| |
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
359 |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
360 |
self enabled ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
361 |
Dialog warn:'Operation currently disabled (In geometry test mode)'. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
362 |
^ self |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
363 |
]. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
364 |
|
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
365 |
clipboard := self getClipboardObject. |
2951 | 366 |
clipboard isString ifTrue:[ |
367 |
Dialog warn:'can only paste widgets here'. |
|
368 |
] ifFalse:[ |
|
369 |
sel := self pasteSpecifications:clipboard keepLayout:true "(clipboard size > 1)". |
|
370 |
self changeSelectionAfterPasteOf:sel. |
|
371 |
]. |
|
89 | 372 |
! |
373 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
374 |
pasteKeepingPosition |
1834 | 375 |
"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
|
376 |
translate the layout as appropriate, to position the component |
1959 | 377 |
at the same absolute position (relative to topView) as before" |
378 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
379 |
|sel| |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
380 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
381 |
sel := self |
1872 | 382 |
pasteSpecifications:(self getClipboardObject) |
383 |
keepLayout:true |
|
384 |
keepPosition:true |
|
3055 | 385 |
at:#keep. |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
386 |
|
2221 | 387 |
self changeSelectionAfterPasteOf:sel. |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
388 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
389 |
|
2395 | 390 |
pasteSpecifications:aSpecificationOrList into:aContainerOrNil beforeIndex:anIndexOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
2537 | 391 |
"add the specs to the object view; |
392 |
if given a collection of specs, returns a list of pasted widgets; |
|
393 |
if given a single spec, returns that view (sigh - a stupid bw-compatibility kludge)" |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
394 |
|
2494 | 395 |
|sensor specsToPaste pasteOffset builder newSel |
2560
efad0ef440c7
oops - need repairDamage for shown to be set (under unix; it used to
Michael Beyl <mb@exept.de>
parents:
2537
diff
changeset
|
396 |
bounds containerToPasteInto pastePoint beforeIndex count| |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
397 |
|
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
398 |
treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
399 |
|
2494 | 400 |
sensor := self window sensor. |
401 |
||
2387 | 402 |
containerToPasteInto := aContainerOrNil. |
403 |
||
2366 | 404 |
(aPointOrNilOrKeep == #keep |
2494 | 405 |
or:[ sensor shiftDown |
406 |
or:[ sensor ctrlDown ]]) ifTrue:[ |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
407 |
"/ paste into the selection |
2387 | 408 |
containerToPasteInto isNil ifTrue:[ |
409 |
containerToPasteInto := self singleSelection. |
|
410 |
]. |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
411 |
] ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
412 |
"/ ignore the selection and paste where we drop!! |
2366 | 413 |
pastePoint := aPointOrNilOrKeep. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
414 |
pastePoint isNil ifTrue:[ |
3083 | 415 |
pastePoint := self graphicsDevice |
2494 | 416 |
translatePoint:(sensor mousePoint) |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
417 |
fromView:nil |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
418 |
toView:self. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
419 |
]. |
2387 | 420 |
containerToPasteInto isNil ifTrue:[ |
421 |
containerToPasteInto := self findObjectAt:pastePoint. |
|
422 |
]. |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
423 |
]. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
424 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
425 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
426 |
self selection size > 0 ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
427 |
containerToPasteInto := self commonContainerOf:self selection |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
428 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
429 |
containerToPasteInto := self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
430 |
]. |
2221 | 431 |
"/ self selection:containerToPasteInto. |
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
432 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
433 |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
434 |
"/ search up parent list for something we can paste into |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
435 |
[containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
436 |
containerToPasteInto == self ifTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
437 |
containerToPasteInto := nil |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
438 |
] ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
439 |
containerToPasteInto := containerToPasteInto container. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
440 |
]. |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
441 |
]. |
1752 | 442 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
443 |
containerToPasteInto := self |
1752 | 444 |
]. |
60 | 445 |
|
2221 | 446 |
(self canPaste:aSpecificationOrList into:containerToPasteInto) |
447 |
ifFalse:[ |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
448 |
self enabled ifTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
449 |
Dialog warn:'Cannot paste into selected component (not a container ?)'. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
450 |
] ifFalse:[ |
2951 | 451 |
Dialog warn:'Operation currently disabled (In geometry test mode)'. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
452 |
]. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
453 |
^ nil |
89 | 454 |
]. |
223 | 455 |
|
2537 | 456 |
self hideSelection. |
457 |
||
776 | 458 |
aSpecificationOrList isCollection ifTrue:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
459 |
specsToPaste := aSpecificationOrList |
776 | 460 |
] ifFalse:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
461 |
specsToPaste := Array with:aSpecificationOrList |
776 | 462 |
]. |
2221 | 463 |
"/ self setClipboardObject:nil. |
776 | 464 |
|
465 |
newSel := OrderedCollection new. |
|
466 |
builder := UIBuilder new isEditing:true. |
|
467 |
||
468 |
className notNil ifTrue:[ |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
469 |
builder applicationClass:(self resolveName:className) |
776 | 470 |
]. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
471 |
bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent). |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
472 |
|
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
473 |
pasteOffset := 0. |
60 | 474 |
|
2395 | 475 |
(anIndexOrNil notNil and:[anIndexOrNil > 0]) ifTrue:[ |
476 |
beforeIndex := anIndexOrNil. |
|
477 |
]. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
478 |
specsToPaste do:[:eachSpec| |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
479 |
|view newOrigin uiPainterAttributes thisAbsOrigin| |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
480 |
|
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
481 |
uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. |
2388 | 482 |
eachSpec otherAttributeAt:#uiPainterAttributes put:nil. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
483 |
|
2395 | 484 |
view := self addSpec:eachSpec builder:builder in:containerToPasteInto beforeIndex:beforeIndex. |
485 |
beforeIndex notNil ifTrue:[ |
|
486 |
beforeIndex := beforeIndex + 1 |
|
487 |
]. |
|
3129 | 488 |
eachSpec keepUILayout ifTrue:[ |
489 |
view layout:eachSpec layout. |
|
490 |
] ifFalse:[ |
|
491 |
(keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[ |
|
492 |
aPointOrNilOrKeep == #keep ifTrue:[ |
|
493 |
newOrigin := uiPainterAttributes at:#origin. |
|
494 |
] ifFalse:[ |
|
495 |
thisAbsOrigin := uiPainterAttributes at:#absOrigin. |
|
496 |
||
497 |
newOrigin := self graphicsDevice |
|
498 |
translatePoint:thisAbsOrigin |
|
499 |
fromView:self |
|
500 |
toView:containerToPasteInto. |
|
501 |
]. |
|
2386 | 502 |
] ifFalse:[ |
3129 | 503 |
pastePoint isNil ifTrue:[ pastePoint := 0@0 ]. |
3083 | 504 |
newOrigin := self graphicsDevice |
3129 | 505 |
translatePoint:pastePoint |
2386 | 506 |
fromView:self |
507 |
toView:containerToPasteInto. |
|
508 |
]. |
|
3129 | 509 |
|
510 |
(bounds containsPoint:newOrigin) ifFalse:[ |
|
511 |
newOrigin := pasteOffset asPoint. |
|
512 |
pasteOffset := pasteOffset + 4. |
|
513 |
]. |
|
514 |
newOrigin notNil ifTrue:[ |
|
515 |
self moveObject:view to:newOrigin. |
|
516 |
]. |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
517 |
]. |
2395 | 518 |
view realized ifFalse:[ |
519 |
view realize. |
|
520 |
]. |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
521 |
newSel add:view. |
776 | 522 |
]. |
60 | 523 |
|
2537 | 524 |
self |
525 |
withinTransaction:#paste |
|
526 |
objects:newSel |
|
527 |
do:[ |
|
528 |
undoHistory |
|
529 |
addUndoSelector:#undoCreate: |
|
530 |
withArgs:(newSel collect:[:v| (self propertyOfView:v) identifier]). |
|
531 |
self undoHistoryChanged. |
|
532 |
]. |
|
60 | 533 |
|
776 | 534 |
self realizeAllSubViews. |
2395 | 535 |
"/ 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
|
536 |
self elementChangedSize:containerToPasteInto. |
134 | 537 |
|
2818
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
538 |
"/ nil wg if embedded in a browser |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
539 |
self windowGroup notNil ifTrue:[ |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
540 |
"/ because the new-created view will destroy the handles, when it redraws itself, |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
541 |
"/ give it a chance to do so, before we return. (bail out after half a second, in case of trouble) |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
542 |
count := 0. |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
543 |
[ (newSel conform:[:v | v shown]) or:[count > 50] ] whileFalse:[ |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
544 |
self windowGroup repairDamage. |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
545 |
Delay waitForSeconds:0.01. |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
546 |
count := count+1. |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
547 |
]. |
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
548 |
Delay waitForSeconds:0.01. |
2560
efad0ef440c7
oops - need repairDamage for shown to be set (under unix; it used to
Michael Beyl <mb@exept.de>
parents:
2537
diff
changeset
|
549 |
self windowGroup repairDamage. |
2537 | 550 |
]. |
551 |
||
776 | 552 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 553 |
^ newSel |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
554 |
|
2818
6d5a0ea87cb7
changed: #pasteSpecifications:into:beforeIndex:keepLayout:keepPosition:at:
Claus Gittinger <cg@exept.de>
parents:
2716
diff
changeset
|
555 |
"Modified: / 03-11-2010 / 07:20:06 / cg" |
89 | 556 |
! |
557 |
||
3055 | 558 |
pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
2395 | 559 |
"add the specs to the object view; returns list of pasted widgets" |
3055 | 560 |
|
561 |
^ self |
|
562 |
pasteSpecifications:aSpecificationOrList |
|
563 |
into:aContainerOrNil |
|
564 |
beforeIndex:nil |
|
565 |
keepLayout:keepLayout |
|
566 |
keepPosition:keepPosition |
|
567 |
at:aPointOrNilOrKeep |
|
2395 | 568 |
! |
569 |
||
2387 | 570 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
571 |
"add the specs to the object view; returns list of pasted widgets" |
|
572 |
||
573 |
^ self |
|
574 |
pasteSpecifications:aSpecificationOrList |
|
575 |
keepLayout:keepLayout |
|
576 |
keepPosition:true |
|
2627
07d40cde2ac9
changed: #pasteSpecifications:keepLayout:
Claus Gittinger <cg@exept.de>
parents:
2583
diff
changeset
|
577 |
at:#keep "/ nil |
2387 | 578 |
|
579 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
580 |
! |
|
581 |
||
582 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
583 |
"add the specs to the object view; returns list of pasted widgets" |
|
584 |
||
585 |
^ self |
|
586 |
pasteSpecifications:aSpecificationOrList |
|
587 |
keepLayout:keepLayout |
|
588 |
keepPosition:true |
|
589 |
at:aPointOrNil |
|
590 |
! |
|
591 |
||
592 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
|
593 |
"add the specs to the object view; returns list of pasted widgets" |
|
594 |
||
595 |
^ self pasteSpecifications:aSpecificationOrList |
|
596 |
into:nil |
|
2395 | 597 |
beforeIndex:nil |
2387 | 598 |
keepLayout:keepLayout |
599 |
keepPosition:keepPosition |
|
600 |
at:aPointOrNilOrKeep |
|
601 |
! |
|
602 |
||
2315 | 603 |
pasteWithLayout |
2369 | 604 |
"add the objects in the paste-buffer to the object view - keep the old layout" |
2315 | 605 |
|
606 |
|sel| |
|
607 |
||
2366 | 608 |
sel := self |
609 |
pasteSpecifications:(self getClipboardObject) |
|
610 |
keepLayout:true |
|
611 |
keepPosition:true |
|
612 |
at:#keep. |
|
2315 | 613 |
self changeSelectionAfterPasteOf:sel. |
614 |
! |
|
615 |
||
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
616 |
pasteWithoutLayout |
2369 | 617 |
"add the objects in the paste-buffer to the object view - do not keep the old layout" |
1959 | 618 |
|
223 | 619 |
|sel| |
620 |
||
2367 | 621 |
sel := self |
622 |
pasteSpecifications:(self getClipboardObject) |
|
623 |
keepLayout:false |
|
624 |
keepPosition:true |
|
625 |
at:#keep. |
|
2221 | 626 |
self changeSelectionAfterPasteOf:sel. |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
627 |
! |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
628 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
629 |
replaceSelectionBy:aNewSpec |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
630 |
"replace the selected widget by another one." |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
631 |
|
2395 | 632 |
|oldSelection treeModel newView oldView container specs| |
2387 | 633 |
|
634 |
(self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[ |
|
635 |
^ self |
|
636 |
]. |
|
637 |
treeModel := treeView model. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
638 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
2387 | 639 |
oldSelection isNil ifTrue:[^ self]. |
640 |
||
2395 | 641 |
oldView := oldSelection contents view. |
642 |
||
643 |
(oldSelection hasChildren and:[aNewSpec class supportsSubComponents]) ifTrue:[ |
|
644 |
specs := oldSelection children collect:[:each| |
|
645 |
self fullSpecWithAbsolutePositionFor:(each contents view) |
|
646 |
]. |
|
647 |
]. |
|
2387 | 648 |
|
649 |
aNewSpec |
|
650 |
otherAttributeAt:#uiPainterAttributes |
|
651 |
put:(Dictionary new |
|
652 |
at:#origin put:oldView origin; |
|
653 |
at:#extent put:oldView extent; |
|
654 |
at:#absOrigin put:(oldView originRelativeTo:self); |
|
655 |
yourself). |
|
656 |
||
657 |
container := self singleSelection container. |
|
658 |
||
659 |
self withinTransaction:#replaceBy objects:(Array with:oldView) do:[ |
|
2395 | 660 |
self withSelectionHiddenDo:[ |
661 |
newView := self |
|
662 |
pasteSpecifications:(Array with:aNewSpec) |
|
663 |
into:container |
|
664 |
beforeIndex:1 |
|
665 |
keepLayout:true |
|
666 |
keepPosition:true |
|
667 |
at:#keep. |
|
668 |
||
669 |
self deleteSelectionBuffered:false. |
|
670 |
||
671 |
specs size > 0 ifTrue:[ |
|
672 |
self pasteSpecifications:specs |
|
673 |
into:newView |
|
674 |
keepLayout:(aNewSpec class canResizeSubComponents) |
|
675 |
keepPosition:(aNewSpec class isLayoutContainer not) |
|
676 |
at:nil. |
|
677 |
]. |
|
678 |
self select:newView. |
|
679 |
]. |
|
2387 | 680 |
]. |
2395 | 681 |
^ newView. |
60 | 682 |
! ! |
683 |
||
684 |
!UIPainterView methodsFor:'drag & drop'! |
|
685 |
||
2116 | 686 |
canDrop:aDropContext |
687 |
^ self canDropObjects:aDropContext dropObjects |
|
688 |
||
689 |
"Created: / 13-10-2006 / 17:46:11 / cg" |
|
690 |
! |
|
691 |
||
692 |
canDropObjects:aCollectionOfDropObjects |
|
1914 | 693 |
"returns true if something can be dropped" |
694 |
||
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
695 |
^ (true "aCollectionOfDropObjects size == 1" |
2112 | 696 |
and:[ self enabled |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
697 |
and:[ true "self numberOfSelections <= 1" |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
698 |
and:[ aCollectionOfDropObjects conform:[:each| each theObject isKindOf:UISpecification] |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
699 |
]]]) |
2112 | 700 |
|
2116 | 701 |
"Created: / 13-10-2006 / 16:09:24 / cg" |
223 | 702 |
! |
703 |
||
285 | 704 |
canPaste |
1914 | 705 |
"returns true if there is something which can be pasted in the clipboard" |
706 |
||
1872 | 707 |
^ self canPaste:(self getClipboardObject) |
285 | 708 |
! |
709 |
||
223 | 710 |
canPaste:something |
1914 | 711 |
"returns true if something could be pasted" |
712 |
||
2221 | 713 |
^ self canPaste:something into:(self singleSelection) |
714 |
! |
|
715 |
||
716 |
canPaste:something into:containerToPasteInto |
|
717 |
"returns true if something could be pasted" |
|
718 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
719 |
(self enabled) ifFalse:[ |
1914 | 720 |
^ false |
223 | 721 |
]. |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
722 |
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
|
723 |
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
|
724 |
^ 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
|
725 |
]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
726 |
|
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
727 |
(something isKindOf:UISpecification) ifFalse:[ |
1914 | 728 |
^ false |
223 | 729 |
]. |
730 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
731 |
^ self canPasteInto:containerToPasteInto |
223 | 732 |
! |
733 |
||
734 |
canPasteInto:aView |
|
1914 | 735 |
"return true, if I can paste into a view" |
736 |
||
285 | 737 |
|prop| |
60 | 738 |
|
1870 | 739 |
aView isNil ifTrue:[ ^ false ]. |
2265 | 740 |
aView == self ifTrue:[ ^ true ]. |
1870 | 741 |
|
742 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
743 |
^ prop spec class supportsSubComponents |
|
89 | 744 |
]. |
1870 | 745 |
^ aView specClass supportsSubComponents. |
60 | 746 |
! |
747 |
||
2116 | 748 |
dropObjects:aCollectionOfDropObjects at:aPoint |
2537 | 749 |
|spec newSel oldSel dragOffset dropPoint widg| |
750 |
||
288 | 751 |
self selection notNil ifTrue:[ |
1953 | 752 |
oldSel := self singleSelection. |
753 |
||
754 |
"/ search selections hierarchy for a widget into which we can paste |
|
755 |
widg := oldSel. |
|
756 |
[widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
|
757 |
widg notNil ifTrue:[ |
|
758 |
widg := widg container |
|
759 |
]. |
|
760 |
]. |
|
761 |
||
762 |
oldSel := nil. |
|
763 |
self setSelection:widg withRedraw:true. |
|
231 | 764 |
]. |
1953 | 765 |
spec := (aCollectionOfDropObjects at:1) theObject. |
2537 | 766 |
|
767 |
dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
|
768 |
aPoint isNil ifTrue:[ |
|
769 |
dropPoint := #keep. |
|
770 |
] ifFalse:[ |
|
771 |
dropPoint := aPoint - dragOffset. |
|
1833 | 772 |
]. |
2537 | 773 |
newSel := self pasteSpecifications:spec keepLayout:false keepPosition:false at:dropPoint. |
774 |
||
775 |
self select:(oldSel ? newSel). |
|
1060
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
776 |
|
2116 | 777 |
"Modified: / 18-03-1999 / 18:29:43 / stefan" |
778 |
"Created: / 13-10-2006 / 16:09:27 / cg" |
|
60 | 779 |
! ! |
780 |
||
2244 | 781 |
!UIPainterView methodsFor:'drawing'! |
782 |
||
783 |
clearRectangle:visRect |
|
784 |
super clearRectangle:visRect. |
|
785 |
sketchPainter notNil ifTrue:[ |
|
786 |
sketchPainter redrawInTargetView |
|
787 |
]. |
|
788 |
||
789 |
"Created: / 16-01-2008 / 17:52:27 / cg" |
|
790 |
! |
|
791 |
||
792 |
clearView |
|
793 |
super clearView. |
|
794 |
sketchPainter notNil ifTrue:[ |
|
795 |
sketchPainter redrawInTargetView |
|
796 |
]. |
|
797 |
||
798 |
"Created: / 16-01-2008 / 17:46:08 / cg" |
|
799 |
! |
|
800 |
||
2248 | 801 |
useSketchFile:aFilename |
2443 | 802 |
"a little neat goody: allow for a tablet-sketch file (WALTROP digital notepad) |
803 |
to be used as a background of the UIPainter window. This allows for sketches to |
|
804 |
be drawn, shown in the UIPainter, and then used as a placement hint (manual placement) |
|
805 |
for the user. Not a high-tech solution, but helped a lot, when we protoyped GUIs." |
|
806 |
||
2248 | 807 |
|mime sketchPainterClass| |
808 |
||
809 |
mime := aFilename asFilename mimeTypeFromName. |
|
810 |
mime isNil ifTrue:[ |
|
811 |
mime := aFilename asFilename mimeTypeOfContents. |
|
812 |
]. |
|
813 |
||
814 |
mime notNil ifTrue:[ |
|
2278
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
815 |
(mime startsWith:'image') ifTrue:[ |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
816 |
self viewBackground:(ImageReader fromFile:aFilename). |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
817 |
^ self. |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
818 |
]. |
2444 | 819 |
mime = 'application/x-waltop-digital-notepad' ifTrue:[ |
820 |
sketchPainterClass := TOPFileDrawer. |
|
821 |
]. |
|
2248 | 822 |
]. |
823 |
sketchPainterClass isNil ifTrue:[ |
|
2444 | 824 |
self error:'Unsupported sketch file format' |
2248 | 825 |
]. |
826 |
||
827 |
sketchPainter := sketchPainterClass new. |
|
2244 | 828 |
sketchPainter targetView:self. |
829 |
sketchPainter readFile:aFilename. |
|
830 |
sketchPainter ajustSketch. |
|
831 |
self invalidate. |
|
832 |
||
833 |
"Created: / 16-01-2008 / 17:46:26 / cg" |
|
834 |
! ! |
|
835 |
||
361 | 836 |
!UIPainterView methodsFor:'event handling'! |
837 |
||
838 |
keyPress:key x:x y:y view:aView |
|
376 | 839 |
"a delegated keyEvent from aView" |
840 |
||
361 | 841 |
self keyPress:key x:x y:y |
842 |
||
376 | 843 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 844 |
! |
845 |
||
846 |
keyRelease:key x:x y:y view:aView |
|
376 | 847 |
"a delegated keyEvent from aView" |
848 |
||
361 | 849 |
self keyRelease:key x:x y:y |
850 |
||
376 | 851 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 852 |
! |
853 |
||
854 |
sizeChanged:how |
|
855 |
||
1834 | 856 |
super sizeChanged:how. |
754 | 857 |
|
858 |
self layoutChanged |
|
361 | 859 |
! ! |
860 |
||
78 | 861 |
!UIPainterView methodsFor:'generating output'! |
862 |
||
352 | 863 |
aspectMethods |
864 |
"extract a list of aspect methods - for browsing" |
|
865 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
866 |
|cls methods| |
352 | 867 |
|
868 |
className isNil ifTrue:[ |
|
1834 | 869 |
self warn:'No class defined !!'. |
870 |
^ #() |
|
352 | 871 |
]. |
872 |
||
873 |
cls := self resolveName:className. |
|
874 |
methods := IdentitySet new. |
|
875 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
876 |
self aspectSelectorsAndTypesDo: |
1834 | 877 |
[:selector :typeSymbol | |
878 |
|skip| |
|
879 |
||
880 |
(cls includesSelector:selector) ifTrue:[ |
|
881 |
||
882 |
skip := false. |
|
883 |
(typeSymbol == #modelAspect) ifTrue:[ |
|
884 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
885 |
skip := SimpleDialog includesSelector:(selector asSymbol) |
|
886 |
]. |
|
887 |
]. |
|
888 |
skip ifFalse:[ |
|
889 |
methods add:(cls compiledMethodAt:selector) |
|
890 |
]. |
|
891 |
] |
|
892 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
893 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
894 |
^ methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
895 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
896 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
897 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
898 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
899 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
900 |
aspectSelectorsAndTypesDo:aTwoArgBlock |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
901 |
"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
|
902 |
|
1726 | 903 |
|cls selector protoSpec| |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
904 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
905 |
className isNil ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
906 |
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
|
907 |
^ self |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
908 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
909 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
910 |
cls := self resolveName:className. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
911 |
|
352 | 912 |
treeView propertiesDo:[:aProp| |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
913 |
|selector| |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
914 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
915 |
(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
|
916 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
917 |
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
|
918 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
919 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
920 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
921 |
(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
|
922 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
923 |
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
|
924 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
925 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
926 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
927 |
(aProp spec aspectSelectors) do:[:aSel | |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
928 |
(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
|
929 |
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
|
930 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
931 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
932 |
aProp spec actionSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
933 |
(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
|
934 |
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
|
935 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
936 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
937 |
aProp spec valueSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
938 |
(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
|
939 |
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
|
940 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
941 |
] |
352 | 942 |
]. |
943 |
||
944 |
protoSpec := treeView canvasSpec. |
|
945 |
||
946 |
(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
|
947 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
948 |
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
|
949 |
]. |
352 | 950 |
]. |
951 |
! |
|
952 |
||
60 | 953 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 954 |
|selector args showIt codeStream alreadyInSuperclass numArgs method| |
288 | 955 |
|
956 |
selector := aspect asSymbol. |
|
141 | 957 |
|
288 | 958 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
959 |
||
568 | 960 |
numArgs := selector numArgs. |
961 |
method := aspect. |
|
962 |
||
963 |
numArgs == 1 ifTrue:[ |
|
2244 | 964 |
args := 'anArgument'. |
2295 | 965 |
showIt := ''' , anArgument printString , ''...''.'. |
1834 | 966 |
] ifFalse:[ |
2244 | 967 |
args := ''. |
968 |
showIt := ' ...''.'. |
|
969 |
||
970 |
numArgs ~~ 0 ifTrue:[ |
|
971 |
method := ''. |
|
972 |
||
973 |
selector keywords keysAndValuesDo:[:i :key| |
|
974 |
method := method, key, 'arg', i printString, ' ' |
|
975 |
] |
|
976 |
] |
|
149 | 977 |
]. |
2244 | 978 |
codeStream := WriteStream on:(String new:100). |
979 |
codeStream |
|
980 |
nextPutLine:('!!',targetClass name,' methodsFor:''actions''!!'); |
|
981 |
nextPutLine:(method,args); |
|
982 |
nextPutLine:' <resource: #uiCallback>'; |
|
983 |
cr. |
|
984 |
||
985 |
self class generateCommentedCode ifTrue:[ |
|
986 |
codeStream |
|
2295 | 987 |
nextPutAll:' "automatically generated by UIPainter..." |
2244 | 988 |
|
989 |
"*** the code below performs no action" |
|
990 |
"*** (except for some feedback on the Transcript)" |
|
991 |
"*** Please change as required and accept in the browser." |
|
992 |
"*** (and replace this comment by something more useful ;-)" |
|
993 |
||
994 |
'. |
|
995 |
||
996 |
alreadyInSuperclass ifTrue:[ |
|
997 |
codeStream |
|
998 |
nextPutLine:' "action for ' , aspect , ' is already provided in a superclass."'; |
|
999 |
nextPutLine:' "It may be redefined here..."'; |
|
1000 |
cr. |
|
1001 |
] ifFalse:[ |
|
1002 |
codeStream |
|
1003 |
nextPutLine:' "action to be defined here..."'; |
|
1004 |
cr. |
|
1005 |
]. |
|
1006 |
]. |
|
1007 |
||
1008 |
codeStream |
|
1009 |
nextPutAll:' Transcript showCR:self class name, '': '. |
|
288 | 1010 |
|
1011 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 1012 |
codeStream |
1013 |
nextPutAll:'inherited '. |
|
288 | 1014 |
]. |
2244 | 1015 |
codeStream |
1016 |
nextPutAll:'action for '; |
|
1017 |
nextPutAll:aspect; |
|
1018 |
nextPutLine:showIt. |
|
288 | 1019 |
|
1020 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 1021 |
codeStream |
1022 |
nextPutAll:' super '; |
|
1023 |
nextPutAll:aspect; |
|
1024 |
nextPutAll:args; |
|
1025 |
nextPutLine:'.'. |
|
288 | 1026 |
]. |
1027 |
||
2244 | 1028 |
codeStream |
1029 |
nextPutLine:'!! !!'; cr. |
|
1030 |
||
1031 |
^ codeStream contents. |
|
1032 |
||
1033 |
"Modified: / 12-01-2008 / 10:21:52 / cg" |
|
60 | 1034 |
! |
1035 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1036 |
generateAspectMethodCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1037 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1038 |
- but do not overwrite existing ones. |
2714
abaae556bec8
commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1039 |
Return a string ready to compile into the application class. |
abaae556bec8
commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1040 |
TODO: refactor and move to CodeGenerator" |
1683
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 |
^ self generateAspectMethodCodeFiltering:nil |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1043 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1044 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1045 |
generateAspectMethodCodeFiltering:aFilterOrEmpty |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1046 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1047 |
- but do not overwrite existing ones. |
2714
abaae556bec8
commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1048 |
Return a string ready to compile into the application class. |
abaae556bec8
commentCode flags now in userPrefs
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1049 |
TODO: refactor and move to CodeGenerator" |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1050 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1051 |
|cls codePieces skip protoSpec thisCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1052 |
definedMethodSelectors iVars t exportSels| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1053 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1054 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1055 |
cls isNil ifTrue:[ |
2024 | 1056 |
^ nil |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1057 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1058 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1059 |
codePieces := OrderedCollection new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1060 |
definedMethodSelectors := IdentitySet new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1061 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1062 |
treeView propertiesDo:[:aProp| |
2024 | 1063 |
|modelSelector| |
1064 |
||
1065 |
protoSpec := aProp spec. |
|
1066 |
||
1067 |
(modelSelector := aProp model) notNil ifTrue:[ |
|
1068 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
|
1069 |
do:[:aSel| |
|
1070 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1071 |
skip := false. |
|
1072 |
||
1073 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
1074 |
skip := SimpleDialog includesSelector:aSel |
|
1075 |
]. |
|
1076 |
(definedMethodSelectors includes:aSel) ifTrue:[ |
|
1077 |
skip := true. |
|
1078 |
]. |
|
1079 |
||
1080 |
skip ifFalse:[ |
|
1081 |
"/ kludge .. |
|
1082 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
|
1083 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
|
1084 |
ifTrue:[ |
|
1085 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
1086 |
] ifFalse:[ |
|
1087 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
1088 |
]. |
|
1089 |
codePieces add:thisCode. |
|
1090 |
definedMethodSelectors add:aSel. |
|
1091 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1092 |
] ifTrue:[ |
|
1093 |
Transcript showCR:'*** no code generated for aspect: ' , aSel , ' (method already exists)' |
|
1094 |
]. |
|
1095 |
]. |
|
1096 |
]. |
|
1097 |
]. |
|
1098 |
||
1099 |
"/ for each aspect, generate getter (if not yet implemented) |
|
1100 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
|
1101 |
do:[:aSel| |
|
1102 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1103 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1104 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
1105 |
codePieces add:thisCode. |
|
1106 |
definedMethodSelectors add:aSel. |
|
1107 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1108 |
] |
|
1109 |
] |
|
1110 |
]. |
|
1111 |
||
1112 |
"/ exported aspects - need setter methods |
|
3092 | 1113 |
exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect) asMutator]. |
2024 | 1114 |
self generateCodeFrom:exportSels in:cls |
1115 |
do:[:aSel| |
|
1116 |
|aspect| |
|
1117 |
||
1118 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1119 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
3136 | 1120 |
aspect := (aSel copyButLast) asSymbol. |
2024 | 1121 |
thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls). |
1122 |
codePieces add:thisCode. |
|
1123 |
definedMethodSelectors add:aSel. |
|
1124 |
Transcript showCR:'export code generated for aspect: ' , aSel |
|
1125 |
] |
|
1126 |
] |
|
1127 |
]. |
|
1128 |
||
1129 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
1130 |
do:[:aSel| |
|
1131 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1132 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1133 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
1134 |
codePieces add:thisCode. |
|
1135 |
definedMethodSelectors add:aSel. |
|
1136 |
Transcript showCR:'action generated for aspect: ' , aSel |
|
1137 |
] |
|
1138 |
] |
|
1139 |
]. |
|
1140 |
||
1141 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
1142 |
do:[:aSel| |
|
1143 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1144 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1145 |
"/ uppercase: - assume its a globals name. |
|
1146 |
aSel isUppercaseFirst ifFalse:[ |
|
1147 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
|
1148 |
codePieces add:thisCode. |
|
1149 |
definedMethodSelectors add:aSel. |
|
1150 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1151 |
] |
|
1152 |
] |
|
1153 |
] |
|
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 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1157 |
AspectsAsInstances ifTrue:[ |
2024 | 1158 |
iVars := cls instVarNames asOrderedCollection. |
1159 |
definedMethodSelectors do:[:ivar | |
|
1160 |
(iVars includes:ivar) ifFalse:[ |
|
1161 |
iVars add:ivar |
|
1162 |
] |
|
1163 |
]. |
|
1164 |
iVars := iVars asArray. |
|
1165 |
t := cls shallowCopy. |
|
1166 |
t setInstanceVariableString:iVars asStringCollection asString. |
|
1167 |
codePieces addFirst:(t definition , '!!\' withCRs). |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1168 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1169 |
|
1834 | 1170 |
^ String |
2024 | 1171 |
streamContents: |
1172 |
[:codeStream | |
|
1173 |
codePieces do:[:eachPiece | codeStream nextPutAll:eachPiece]. |
|
1174 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1175 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1176 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1177 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1178 |
|
60 | 1179 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 1180 |
|modelClass modelValueString modelValue modelGen codeStream| |
134 | 1181 |
|
149 | 1182 |
modelClass := protoSpec defaultModelClassFor:aspect. |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1183 |
modelValueString := protoSpec defaultModelValueStringFor:aspect. |
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1184 |
modelValueString notNil ifTrue:[ |
2244 | 1185 |
modelGen := modelValueString |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1186 |
] ifFalse:[ |
2244 | 1187 |
modelValue := protoSpec defaultModelValueFor:aspect. |
1188 |
modelValue isNil ifTrue:[ |
|
1189 |
modelGen := modelClass name , ' new' |
|
1190 |
] ifFalse:[ |
|
1191 |
modelGen := modelValue storeString , ' asValue' |
|
1192 |
]. |
|
352 | 1193 |
|
1194 |
]. |
|
134 | 1195 |
|
2244 | 1196 |
codeStream := WriteStream on:(String new:100). |
1197 |
codeStream |
|
1198 |
nextPutLine:('!!' , targetClass name , ' methodsFor:''aspects''!!'); |
|
1199 |
nextPutLine:aspect; |
|
1200 |
nextPutLine:' <resource: #uiAspect>'; |
|
1201 |
cr. |
|
1202 |
||
1203 |
self class generateCommentedCode ifTrue:[ |
|
1204 |
codeStream |
|
1205 |
nextPutAll:' "automatically generated by UIPainter ..." |
|
1206 |
||
1207 |
"*** the code below creates a default model when invoked." |
|
1208 |
"*** (which may not be the one you wanted)" |
|
1209 |
"*** Please change as required and accept it in the browser." |
|
1210 |
"*** (and replace this comment by something more useful ;-)" |
|
1211 |
||
1212 |
'. |
|
1213 |
]. |
|
1474 | 1214 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1215 |
AspectsAsInstances ifTrue:[ |
2244 | 1216 |
codeStream |
1217 |
nextPutLine:(' ',aspect,' isNil ifTrue:['); |
|
1218 |
nextPutLine:(' ',aspect,' := ',modelGen,'.'). |
|
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:'"/ ',aspect,' addDependent:self.'; |
|
1227 |
nextPutLine:'"/ ',aspect,' onChangeSend:#',aspect,'Changed to:self.'. |
|
1228 |
]. |
|
1229 |
codeStream |
|
1230 |
nextPutLine:' ].'; |
|
1231 |
nextPutLine:' ^ ',aspect,'.'. |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1232 |
] ifFalse:[ |
2244 | 1233 |
codeStream |
1234 |
nextPutLine:(' |holder|'); |
|
1235 |
cr; |
|
1236 |
nextPutLine:(' (holder := builder bindingAt:#',aspect,') isNil ifTrue:['); |
|
1237 |
nextPutLine:(' holder := ',modelGen,'.'); |
|
1238 |
nextPutLine:(' builder aspectAt:#',aspect,' put:holder.'). |
|
1239 |
||
1240 |
modelClass ~~ TriggerValue ifTrue:[ |
|
1241 |
self class generateCommentedCode ifTrue:[ |
|
1242 |
codeStream |
|
1243 |
nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'. |
|
1244 |
]. |
|