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