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