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