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