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