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