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