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