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