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