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