author | Claus Gittinger <cg@exept.de> |
Fri, 31 Jul 1998 19:37:50 +0200 | |
changeset 936 | f3db8359547a |
parent 925 | e6ddd46581c3 |
child 965 | 4f786b46a569 |
permissions | -rw-r--r-- |
60 | 1 |
" |
156 | 2 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
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 |
||
13 |
UIObjectView subclass:#UIPainterView |
|
278 | 14 |
instanceVariableNames:'treeView listHolder superclassName className methodName |
770 | 15 |
categoryName handleColor handleMasterColor' |
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
16 |
classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances' |
60 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-UIPainter' |
|
19 |
! |
|
20 |
||
211 | 21 |
Object subclass:#ViewProperty |
22 |
instanceVariableNames:'view spec identifier' |
|
23 |
classVariableNames:'Identifier' |
|
24 |
poolDictionaries:'' |
|
25 |
privateIn:UIPainterView |
|
26 |
! |
|
27 |
||
60 | 28 |
!UIPainterView class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
156 | 32 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
33 |
All Rights Reserved |
|
60 | 34 |
|
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
742 | 37 |
inclusion of the above copyright notice. This software may not |
60 | 38 |
be provided or otherwise made available to, or used by, any |
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
128 | 46 |
buildIn view used by the UIPainter; from this view, the layout of the |
47 |
new application derives from. |
|
48 |
||
49 |
[see also:] |
|
50 |
UIBuilder |
|
51 |
UIObjectView |
|
156 | 52 |
|
53 |
[author:] |
|
54 |
Claus Gittinger |
|
55 |
Claus Atzkern |
|
60 | 56 |
" |
57 |
! ! |
|
58 |
||
698 | 59 |
!UIPainterView class methodsFor:'code generation mode'! |
60 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
61 |
generateAspectsAsInstanceVariables |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
62 |
"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
|
63 |
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
|
64 |
" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
65 |
^ AspectsAsInstances |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
66 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
67 |
"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
|
68 |
"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
|
69 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
70 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
71 |
generateAspectsAsInstanceVariables:aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
72 |
"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
|
73 |
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
|
74 |
" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
75 |
AspectsAsInstances := aBoolean |
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 |
"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
|
78 |
"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
|
79 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
80 |
|
742 | 81 |
redefineAspectMethods |
698 | 82 |
"redefine methods yes or no. If a method is defined in super class |
83 |
should the message be reinstalled ? |
|
84 |
" |
|
742 | 85 |
^ RedefineAspectMethods ? false |
698 | 86 |
|
87 |
! |
|
88 |
||
742 | 89 |
redefineAspectMethods:aBoolean |
698 | 90 |
"redefine methods yes or no. If a method is defined in super class |
91 |
should the message be reinstalled ? |
|
92 |
" |
|
742 | 93 |
RedefineAspectMethods := aBoolean |
698 | 94 |
|
95 |
||
96 |
! ! |
|
97 |
||
60 | 98 |
!UIPainterView class methodsFor:'defaults'! |
99 |
||
100 |
defaultMenuMessage |
|
101 |
"This message is the default yo be sent to the menuHolder to get a menu |
|
102 |
" |
|
121 | 103 |
^ #showMiddleButtonMenu |
60 | 104 |
|
105 |
||
106 |
! ! |
|
107 |
||
108 |
!UIPainterView methodsFor:'accessing'! |
|
109 |
||
110 |
application |
|
111 |
^ nil |
|
112 |
||
113 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
114 |
! |
|
115 |
||
78 | 116 |
applicationName |
117 |
^ self className |
|
118 |
! |
|
119 |
||
120 |
applicationName:aName |
|
121 |
self className:aName |
|
122 |
! |
|
123 |
||
60 | 124 |
className |
125 |
^ className |
|
126 |
! |
|
127 |
||
78 | 128 |
className:aName |
129 |
className := aName |
|
60 | 130 |
! |
131 |
||
132 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
78 | 133 |
className := aClassName. |
60 | 134 |
superclassName := aSuperclassName. |
78 | 135 |
methodName := aSelector. |
60 | 136 |
|
137 |
! |
|
138 |
||
223 | 139 |
findInputViewIn:aSuperView |
140 |
"returns index of input view into superview or nil |
|
141 |
" |
|
142 |
aSuperView == self ifTrue:[ |
|
143 |
^ self subViews findFirst:[:v| v == inputView ] |
|
144 |
]. |
|
145 |
^ 0 |
|
146 |
! |
|
147 |
||
148 |
inputView |
|
149 |
^ inputView |
|
111 | 150 |
! |
151 |
||
60 | 152 |
methodName |
153 |
^ methodName |
|
154 |
! |
|
155 |
||
78 | 156 |
methodName:aName |
157 |
methodName := aName |
|
60 | 158 |
! |
159 |
||
160 |
selectNames:aStringOrCollection |
|
161 |
|prop coll s| |
|
162 |
||
163 |
(aStringOrCollection isNil or:[aStringOrCollection isEmpty]) ifTrue:[ |
|
131 | 164 |
^ self select:nil |
60 | 165 |
]. |
166 |
||
167 |
(s := aStringOrCollection) isString ifFalse:[ |
|
168 |
s size == 1 ifTrue:[ |
|
169 |
s := s first |
|
170 |
] ifFalse:[ |
|
171 |
coll := OrderedCollection new. |
|
172 |
||
173 |
s do:[:aName| |
|
174 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
175 |
coll add:(prop view) |
|
176 |
] |
|
177 |
]. |
|
178 |
coll size == 1 ifTrue:[ ^ self select:(coll at:1) ]. |
|
131 | 179 |
coll size == 0 ifTrue:[ ^ self select:nil ]. |
60 | 180 |
|
181 |
^ self select:coll. |
|
182 |
] |
|
183 |
]. |
|
184 |
||
185 |
prop := self propertyOfName:s. |
|
131 | 186 |
prop isNil ifTrue:[^ self select:nil] |
60 | 187 |
ifFalse:[^ self select:(prop view)] |
188 |
||
189 |
! ! |
|
190 |
||
111 | 191 |
!UIPainterView methodsFor:'change & update'! |
192 |
||
223 | 193 |
layoutChanged |
754 | 194 |
|
238 | 195 |
treeView layoutChanged |
111 | 196 |
! ! |
197 |
||
60 | 198 |
!UIPainterView methodsFor:'copy & cut & paste'! |
199 |
||
200 |
copySelection |
|
201 |
"copy the selection into the cut&paste-buffer |
|
202 |
" |
|
698 | 203 |
|specs coll sel| |
204 |
||
205 |
sel := treeView selection. |
|
71 | 206 |
|
128 | 207 |
coll := self minSetOfSuperViews:(self selection). |
60 | 208 |
|
71 | 209 |
coll notNil ifTrue:[ |
776 | 210 |
"/ self select:nil. |
78 | 211 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
698 | 212 |
self setSelection:specs. |
776 | 213 |
"/ treeView selection: sel |
60 | 214 |
]. |
78 | 215 |
|
216 |
||
60 | 217 |
! |
218 |
||
723 | 219 |
deleteSelection |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
220 |
"delete the selection buffered |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
221 |
" |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
222 |
self deleteSelectionBuffered: true |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
223 |
! |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
224 |
|
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
225 |
deleteSelectionBuffered: buffered |
698 | 226 |
"cut the selection into the cut&paste-buffer |
62 | 227 |
and open a transaction |
60 | 228 |
" |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
229 |
|specs coll oldSelectedNode newSelectedNode newSelection| |
71 | 230 |
|
128 | 231 |
coll := self minSetOfSuperViews:(self selection). |
60 | 232 |
|
78 | 233 |
coll notNil ifTrue:[ |
238 | 234 |
treeView cvsEventsDisabledDo:[ |
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
235 |
|
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
236 |
(oldSelectedNode := (treeView model selectedNodes at: 1 ifAbsent: nil)) notNil ifTrue: [ |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
237 |
oldSelectedNode parent children size <= 1 ifTrue: [ |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
238 |
newSelectedNode := oldSelectedNode parent |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
239 |
] |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
240 |
ifFalse: [ |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
241 |
newSelectedNode := oldSelectedNode parent children |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
242 |
at: (oldSelectedNode parent indexOfChild: oldSelectedNode) - 1 |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
243 |
ifAbsent: [oldSelectedNode parent children at: 2] |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
244 |
]. |
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
245 |
]. |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
246 |
self hideSelection. |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
247 |
selection := nil. |
111 | 248 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
60 | 249 |
|
134 | 250 |
self withinTransaction:#cut objects:coll do:[ |
251 |
coll reverseDo:[:aView| |
|
252 |
self createUndoRemove:aView. |
|
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
253 |
self remove:aView. |
111 | 254 |
] |
255 |
]. |
|
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
256 |
buffered ifTrue: [self setSelection: specs]. |
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
257 |
treeView selection: nil. |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
258 |
(newSelection := (treeView model indexOf:newSelectedNode)) > 0 ifFalse: [ |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
259 |
newSelection := 1 |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
260 |
]. |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
261 |
treeView selection: (Array with: newSelection). |
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
262 |
self setSelection:treeView selectedNode contents view withRedraw: true. |
698 | 263 |
] |
264 |
] |
|
265 |
! |
|
266 |
||
723 | 267 |
deleteTotalSelection |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
268 |
"delete the selection |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
269 |
" |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
270 |
self deleteSelectionBuffered: false |
60 | 271 |
! |
272 |
||
273 |
pasteBuffer |
|
62 | 274 |
"add the objects in the paste-buffer to the object view |
60 | 275 |
" |
223 | 276 |
|sel| |
277 |
||
278 |
sel := self pasteSpecifications:(self getSelection) keepLayout:false. |
|
279 |
||
280 |
sel notNil ifTrue:[ |
|
281 |
self select:sel. |
|
282 |
]. |
|
89 | 283 |
|
284 |
! |
|
285 |
||
392 | 286 |
pasteFromClipBoard:aString |
287 |
^ self |
|
288 |
||
289 |
||
290 |
! |
|
291 |
||
89 | 292 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
223 | 293 |
"add the specs to the object view; returns list of pasted components |
89 | 294 |
" |
278 | 295 |
|
296 |
^ self |
|
297 |
pasteSpecifications:aSpecificationOrList |
|
298 |
keepLayout:keepLayout |
|
299 |
at:nil |
|
300 |
||
301 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
302 |
! |
|
303 |
||
304 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
305 |
"add the specs to the object view; returns list of pasted components |
|
306 |
" |
|
312 | 307 |
|paste frame pasteOrigin pasteOffset builder newSel bounds| |
60 | 308 |
|
89 | 309 |
(self canPaste:aSpecificationOrList) ifFalse:[ |
223 | 310 |
^ nil |
89 | 311 |
]. |
223 | 312 |
|
776 | 313 |
aSpecificationOrList isCollection ifTrue:[ |
314 |
paste := aSpecificationOrList |
|
315 |
] ifFalse:[ |
|
316 |
paste := Array with:aSpecificationOrList |
|
317 |
]. |
|
318 |
(frame := self singleSelection) isNil ifTrue:[ |
|
319 |
frame := self |
|
320 |
]. |
|
321 |
self selection:nil. |
|
322 |
||
323 |
newSel := OrderedCollection new. |
|
324 |
builder := UIBuilder new isEditing:true. |
|
325 |
||
326 |
className notNil ifTrue:[ |
|
327 |
builder applicationClass:(self resolveName:className) |
|
328 |
]. |
|
329 |
||
330 |
keepLayout ifFalse:[ |
|
331 |
pasteOffset := 0@0. |
|
332 |
||
333 |
aPointOrNil isNil ifTrue:[ |
|
334 |
pasteOrigin := self sensor mousePoint. |
|
335 |
pasteOrigin := device translatePoint:pasteOrigin |
|
336 |
from:device rootView id |
|
337 |
to:frame id. |
|
165 | 338 |
] ifFalse:[ |
776 | 339 |
pasteOrigin := device translatePoint:aPointOrNil |
340 |
from:self id |
|
341 |
to:frame id. |
|
342 |
] |
|
343 |
]. |
|
344 |
keepLayout ifFalse:[ |
|
345 |
bounds := Rectangle origin:0@0 extent:(frame bounds extent) |
|
346 |
]. |
|
60 | 347 |
|
776 | 348 |
paste do:[:aSpec| |
349 |
|view| |
|
395 | 350 |
|
776 | 351 |
view := self addSpec:aSpec builder:builder in:frame. |
89 | 352 |
|
165 | 353 |
keepLayout ifFalse:[ |
776 | 354 |
(bounds containsPoint:pasteOrigin) ifFalse:[ |
355 |
self moveObject:view to:pasteOffset. |
|
356 |
] ifTrue:[ |
|
357 |
self moveObject:view to:pasteOrigin + pasteOffset. |
|
358 |
]. |
|
359 |
pasteOffset := pasteOffset + 4 |
|
312 | 360 |
]. |
776 | 361 |
view realize. |
362 |
newSel add:view. |
|
363 |
]. |
|
60 | 364 |
|
776 | 365 |
self withinTransaction:#paste objects:newSel do:[ |
366 |
undoHistory addUndoSelector:#undoCreate: |
|
367 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]) |
|
368 |
]. |
|
60 | 369 |
|
776 | 370 |
self realizeAllSubViews. |
371 |
newSel do:[:v| v raise]. |
|
372 |
inputView raise. |
|
373 |
self elementChangedSize:frame. |
|
134 | 374 |
|
776 | 375 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 376 |
^ newSel |
89 | 377 |
! |
378 |
||
379 |
pasteWithLayout |
|
380 |
"add the objects in the paste-buffer to the object view; don't change the |
|
381 |
layout |
|
382 |
" |
|
223 | 383 |
|sel| |
384 |
||
385 |
sel := self pasteSpecifications:(self getSelection) keepLayout:true. |
|
89 | 386 |
|
223 | 387 |
sel notNil ifTrue:[ |
388 |
self select:sel. |
|
389 |
]. |
|
60 | 390 |
! ! |
391 |
||
392 |
!UIPainterView methodsFor:'drag & drop'! |
|
393 |
||
288 | 394 |
canDrop:something |
395 |
"returns true if something can be droped |
|
698 | 396 |
" |
288 | 397 |
(something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[ |
398 |
^ something first theObject isKindOf:UISpecification |
|
223 | 399 |
]. |
400 |
^ false |
|
401 |
! |
|
402 |
||
285 | 403 |
canPaste |
404 |
"returns true if something to be past exists and can be paste into |
|
405 |
the selection if exists |
|
406 |
" |
|
407 |
^ self canPaste:(self getSelection) |
|
408 |
! |
|
409 |
||
223 | 410 |
canPaste:something |
411 |
"returns true if something could be paste |
|
412 |
" |
|
413 |
|el size| |
|
414 |
||
415 |
((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
416 |
^ false |
|
417 |
]. |
|
418 |
something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]] |
|
419 |
ifFalse:[el := something]. |
|
420 |
||
421 |
(el isKindOf:UISpecification) ifFalse:[ |
|
422 |
^ false |
|
423 |
]. |
|
424 |
||
425 |
size == 1 ifTrue:[ |
|
426 |
^ self canPasteInto:(self singleSelection) |
|
427 |
]. |
|
428 |
^ true |
|
429 |
! |
|
430 |
||
431 |
canPasteInto:aView |
|
432 |
"can paste into a view |
|
433 |
" |
|
285 | 434 |
|prop| |
60 | 435 |
|
223 | 436 |
aView notNil ifTrue:[ |
285 | 437 |
(prop := self propertyRespondsToView:aView) notNil ifTrue:[ |
438 |
^ prop spec class supportsSubComponents |
|
439 |
]. |
|
440 |
^ aView specClass supportsSubComponents. |
|
89 | 441 |
]. |
442 |
^ false |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
443 |
|
60 | 444 |
! |
445 |
||
446 |
drop:anObjectOrCollection at:aPoint |
|
278 | 447 |
|spec newSel oldSel dragOffset| |
448 |
||
288 | 449 |
self selection notNil ifTrue:[ |
450 |
oldSel := self singleSelection. |
|
451 |
||
452 |
(self canPasteInto:oldSel) ifFalse:[ |
|
453 |
oldSel := nil. |
|
454 |
self setSelection:nil withRedraw:true |
|
455 |
] |
|
231 | 456 |
]. |
89 | 457 |
spec := (anObjectOrCollection at:1) theObject. |
278 | 458 |
dragOffset := DragAndDropManager dragOffsetQuerySignal raise. |
459 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
60 | 460 |
|
223 | 461 |
oldSel isNil ifTrue:[self select:newSel] |
462 |
ifFalse:[self select:oldSel] |
|
60 | 463 |
! ! |
464 |
||
361 | 465 |
!UIPainterView methodsFor:'event handling'! |
466 |
||
467 |
keyPress:key x:x y:y view:aView |
|
376 | 468 |
"a delegated keyEvent from aView" |
469 |
||
361 | 470 |
self keyPress:key x:x y:y |
471 |
||
376 | 472 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 473 |
! |
474 |
||
475 |
keyRelease:key x:x y:y view:aView |
|
376 | 476 |
"a delegated keyEvent from aView" |
477 |
||
361 | 478 |
self keyRelease:key x:x y:y |
479 |
||
376 | 480 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 481 |
! |
482 |
||
483 |
sizeChanged:how |
|
484 |
||
485 |
super sizeChanged:how. |
|
486 |
||
487 |
self layoutChanged |
|
361 | 488 |
! ! |
489 |
||
78 | 490 |
!UIPainterView methodsFor:'generating output'! |
491 |
||
352 | 492 |
aspectMethods |
493 |
"extract a list of aspect methods - for browsing" |
|
494 |
||
495 |
|cls methods skip selector protoSpec| |
|
496 |
||
497 |
className isNil ifTrue:[ |
|
498 |
self warn:'set the class first'. |
|
499 |
^ #() |
|
500 |
]. |
|
501 |
||
502 |
cls := self resolveName:className. |
|
503 |
methods := IdentitySet new. |
|
504 |
||
505 |
treeView propertiesDo:[:aProp| |
|
506 |
|selector| |
|
507 |
||
508 |
(selector := aProp model) notNil ifTrue:[ |
|
509 |
selector isArray ifFalse:[ |
|
510 |
selector := selector asSymbol. |
|
511 |
(cls implements:selector) ifTrue:[ |
|
512 |
skip := false. |
|
513 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
514 |
skip := SimpleDialog implements:selector asSymbol |
|
515 |
]. |
|
516 |
skip ifFalse:[ |
|
517 |
methods add:(cls compiledMethodAt:selector) |
|
518 |
]. |
|
519 |
]. |
|
520 |
]. |
|
521 |
]. |
|
522 |
||
523 |
(selector := aProp menu) notNil ifTrue:[ |
|
524 |
selector isArray ifFalse:[ |
|
525 |
selector := selector asSymbol. |
|
526 |
(cls implements:selector) ifTrue:[ |
|
527 |
methods add:(cls compiledMethodAt:selector) |
|
528 |
] |
|
529 |
]. |
|
530 |
]. |
|
531 |
||
532 |
(aProp spec aspectSelectors) do:[:aSel | |
|
533 |
|selector| |
|
534 |
||
535 |
aSel isArray ifFalse:[ |
|
536 |
selector := aSel asSymbol. |
|
537 |
(cls implements:selector) ifTrue:[ |
|
538 |
methods add:(cls compiledMethodAt:selector) |
|
539 |
] |
|
540 |
]. |
|
541 |
]. |
|
542 |
aProp spec actionSelectors do:[:aSel| |
|
543 |
|selector| |
|
544 |
||
545 |
aSel isArray ifFalse:[ |
|
546 |
selector := aSel asSymbol. |
|
547 |
(cls implements:selector) ifTrue:[ |
|
548 |
methods add:(cls compiledMethodAt:selector) |
|
549 |
] |
|
550 |
]. |
|
551 |
]. |
|
552 |
aProp spec valueSelectors do:[:aSel| |
|
553 |
|selector| |
|
554 |
||
555 |
aSel isArray ifFalse:[ |
|
556 |
selector := aSel asSymbol. |
|
557 |
(cls implements:selector) ifTrue:[ |
|
558 |
methods add:(cls compiledMethodAt:selector) |
|
559 |
] |
|
560 |
]. |
|
561 |
] |
|
562 |
]. |
|
563 |
||
564 |
protoSpec := treeView canvasSpec. |
|
565 |
||
566 |
(selector := protoSpec menu) notNil ifTrue:[ |
|
567 |
selector isArray ifFalse:[ |
|
568 |
selector := selector asSymbol. |
|
569 |
(cls implements:selector) ifTrue:[ |
|
570 |
methods add:(cls compiledMethodAt:selector) |
|
571 |
] |
|
572 |
]. |
|
573 |
]. |
|
574 |
||
575 |
^ methods |
|
576 |
||
577 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
|
578 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
|
579 |
! |
|
580 |
||
60 | 581 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
568 | 582 |
|selector args showIt code alreadyInSuperclass numArgs method| |
288 | 583 |
|
584 |
selector := aspect asSymbol. |
|
141 | 585 |
|
288 | 586 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
587 |
||
568 | 588 |
numArgs := selector numArgs. |
589 |
method := aspect. |
|
590 |
||
591 |
numArgs == 1 ifTrue:[ |
|
592 |
args := 'anArgument'. |
|
593 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
594 |
] ifFalse:[ |
|
288 | 595 |
args := ''. |
149 | 596 |
showIt := ' ...''.\'. |
568 | 597 |
|
598 |
numArgs ~~ 0 ifTrue:[ |
|
599 |
method := ''. |
|
600 |
||
601 |
selector keywords keysAndValuesDo:[:i :key| |
|
602 |
method := method, key, 'arg', i printString, ' ' |
|
603 |
] |
|
604 |
] |
|
149 | 605 |
]. |
141 | 606 |
|
288 | 607 |
code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
568 | 608 |
method , args , '\' , |
352 | 609 |
' "automatically generated by UIPainter ..."\\' , |
610 |
' "*** the code below performs no action"\' , |
|
611 |
' "*** (except for some feedback on the Transcript)"\' , |
|
612 |
' "*** Please change as required and accept in the browser."\' , |
|
288 | 613 |
'\' . |
614 |
||
615 |
alreadyInSuperclass ifTrue:[ |
|
616 |
code := code , |
|
617 |
' "action for ' , aspect , ' is already provided in a superclass."\' , |
|
618 |
' "It may be redefined here ..."\\'. |
|
619 |
] ifFalse:[ |
|
620 |
code := code , |
|
621 |
' "action to be added ..."\\'. |
|
622 |
]. |
|
623 |
||
624 |
code := code , |
|
625 |
' Transcript showCR:self class name, '': '. |
|
626 |
alreadyInSuperclass ifTrue:[ |
|
627 |
code := code , 'inherited '. |
|
628 |
]. |
|
629 |
code := code , 'action for ' , aspect , showIt. |
|
630 |
||
631 |
alreadyInSuperclass ifTrue:[ |
|
632 |
code := code , |
|
633 |
' super ' , aspect , args , '.\'. |
|
634 |
]. |
|
635 |
||
636 |
code := code , |
|
637 |
'!! !!\\'. |
|
638 |
^ code withCRs |
|
639 |
||
352 | 640 |
"Modified: / 25.10.1997 / 19:18:50 / cg" |
60 | 641 |
! |
642 |
||
643 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
644 |
|modelClass modelValue modelGen code| |
134 | 645 |
|
149 | 646 |
modelClass := protoSpec defaultModelClassFor:aspect. |
352 | 647 |
modelValue := protoSpec defaultModelValueFor:aspect. |
648 |
||
649 |
modelValue isNil ifTrue:[ |
|
650 |
modelGen := modelClass name , ' new' |
|
651 |
] ifFalse:[ |
|
652 |
modelGen := modelValue storeString , ' asValue' |
|
653 |
]. |
|
134 | 654 |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
655 |
code := '!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
60 | 656 |
aspect , '\' , |
352 | 657 |
' "automatically generated by UIPainter ..."\\' , |
658 |
' "*** the code below creates a default model when invoked."\' , |
|
659 |
' "*** (which may not be the one you wanted)"\' , |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
660 |
' "*** Please change as required and accept in the browser."\'. |
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
661 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
662 |
AspectsAsInstances ifTrue:[ |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
663 |
code := (code , '\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
664 |
' ' , aspect , ' isNil ifTrue:[\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
665 |
' ' , aspect , ' := ' , ' ' , modelGen , '.\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
666 |
' ].\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
667 |
' ^ ' , aspect ,'.\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
668 |
'!! !!\\') |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
669 |
] ifFalse:[ |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
670 |
code := (code , '\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
671 |
' |holder|\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
672 |
'\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
673 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
674 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelGen , ').\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
675 |
' ].\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
676 |
' ^ holder.\' , |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
677 |
'!! !!\\') |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
678 |
]. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
679 |
^ code withCRs |
352 | 680 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
681 |
"Modified: / 29.7.1998 / 11:29:16 / cg" |
60 | 682 |
! |
683 |
||
684 |
generateAspectMethods |
|
352 | 685 |
"generate aspect, action & menu methods |
686 |
- but do not overwrite existing ones. |
|
687 |
Return a string ready to compile into the application class." |
|
688 |
||
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
689 |
|cls code skip menuSelector protoSpec thisCode |
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
690 |
definedMethodSelectors iVars t| |
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
691 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
692 |
definedMethodSelectors := IdentitySet new. |
60 | 693 |
|
78 | 694 |
code := ''. |
695 |
||
60 | 696 |
className isNil ifTrue:[ |
698 | 697 |
self warn:'Set first the class!!'. |
78 | 698 |
^ code |
60 | 699 |
]. |
698 | 700 |
|
701 |
(cls := self resolveName:className) isNil ifTrue:[ |
|
702 |
self warn:'Class ', className asString, ' does not exist!!'. |
|
703 |
^ code |
|
704 |
]. |
|
60 | 705 |
|
316 | 706 |
treeView propertiesDo:[:aProp| |
352 | 707 |
|modelSelector menuSelector| |
708 |
||
134 | 709 |
protoSpec := aProp spec. |
175 | 710 |
|
78 | 711 |
(modelSelector := aProp model) notNil ifTrue:[ |
698 | 712 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
713 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
714 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
715 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
716 |
sym := aSel asSymbol. |
352 | 717 |
skip := false. |
698 | 718 |
|
352 | 719 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
720 |
skip := SimpleDialog implements:sym |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
721 |
]. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
722 |
(definedMethodSelectors includes:sym) ifTrue:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
723 |
skip := true. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
724 |
]. |
698 | 725 |
|
352 | 726 |
skip ifFalse:[ |
727 |
"/ kludge .. |
|
796
05b2883a23b0
fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents:
784
diff
changeset
|
728 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
05b2883a23b0
fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents:
784
diff
changeset
|
729 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
05b2883a23b0
fixed aspect generation for RadioButtons
Claus Gittinger <cg@exept.de>
parents:
784
diff
changeset
|
730 |
ifTrue:[ |
698 | 731 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
352 | 732 |
] ifFalse:[ |
698 | 733 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
352 | 734 |
]. |
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
735 |
code := code, thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
736 |
definedMethodSelectors add:sym. |
698 | 737 |
] |
738 |
] |
|
62 | 739 |
]. |
740 |
||
698 | 741 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
742 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
743 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
744 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
745 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
746 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
747 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
748 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
749 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
750 |
] |
698 | 751 |
]. |
752 |
||
753 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
754 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
755 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
756 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
757 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
758 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
759 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
760 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
761 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
762 |
] |
698 | 763 |
]. |
764 |
||
765 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
766 |
do:[:aSel| |
|
858
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
767 |
|sym| |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
768 |
|
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
769 |
sym := aSel asSymbol. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
770 |
(definedMethodSelectors includes:sym) ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
771 |
"/ uppercase: - assume its a globals name. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
772 |
aSel first isUppercase ifFalse:[ |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
773 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
774 |
code := code , thisCode. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
775 |
definedMethodSelectors add:sym. |
6b2e9e31cf06
do not redefine generated aspect methods
Claus Gittinger <cg@exept.de>
parents:
796
diff
changeset
|
776 |
] |
376 | 777 |
] |
698 | 778 |
]. |
316 | 779 |
]. |
780 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
781 |
AspectsAsInstances ifTrue:[ |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
782 |
iVars := cls instVarNames asOrderedCollection. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
783 |
definedMethodSelectors do:[:ivar | |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
784 |
(iVars includes:ivar) ifFalse:[ |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
785 |
iVars add:ivar |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
786 |
] |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
787 |
]. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
788 |
iVars := iVars asArray. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
789 |
t := cls shallowCopy. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
790 |
t setInstanceVariableString:iVars asStringCollection asString. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
791 |
code := (t definition) , '!!\' withCRs , code. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
792 |
]. |
352 | 793 |
^ code |
698 | 794 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
795 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
698 | 796 |
! |
797 |
||
798 |
generateCodeFrom:aListOfSelectors in:aClass do:aBlock |
|
799 |
||
744 | 800 |
self class redefineAspectMethods ifTrue:[ |
698 | 801 |
aListOfSelectors do:[:aSelector| |
802 |
(aSelector isArray or:[aClass implements:aSelector]) ifFalse:[ |
|
803 |
aBlock value:aSelector |
|
804 |
] |
|
805 |
] |
|
806 |
] ifFalse:[ |
|
807 |
aListOfSelectors do:[:aSelector| |
|
808 |
(aSelector isArray or:[aClass canUnderstand:aSelector]) ifFalse:[ |
|
809 |
aBlock value:aSelector |
|
810 |
] |
|
811 |
] |
|
812 |
] |
|
813 |
||
814 |
||
376 | 815 |
! |
816 |
||
817 |
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
|
818 |
^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
|
819 |
selectorSpec , '\' , |
|
820 |
' "automatically generated by UIPainter ..."\\' , |
|
821 |
' "*** the code here does nothing. It is invoked when"\' , |
|
822 |
' "*** ' , commentWhen , '"\' , |
|
823 |
' "*** Please change as required and accept in the browser."\' , |
|
824 |
'\' , |
|
825 |
' "specific code to be added below ..."\' , |
|
826 |
' "' , (noteOrNil ? '') , '"\' , |
|
827 |
'\' , |
|
828 |
(defaultCode ? '^ self.') , |
|
829 |
'!! !!\\') withCRs |
|
830 |
||
831 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
|
832 |
"Created: / 31.10.1997 / 17:31:53 / cg" |
|
833 |
! |
|
834 |
||
835 |
generateHookMethods |
|
836 |
"generate hook methods |
|
837 |
- but do not overwrite existing ones. |
|
838 |
Return a string ready to compile into the application class." |
|
839 |
||
840 |
|cls code skip menuSelector protoSpec thisCode| |
|
841 |
||
842 |
code := ''. |
|
843 |
||
844 |
className isNil ifTrue:[ |
|
845 |
self warn:'set the class first'. |
|
846 |
^ code |
|
847 |
]. |
|
848 |
cls := self resolveName:className. |
|
849 |
||
850 |
code := code , (self generateHookMethodsInClass:cls). |
|
851 |
||
852 |
^ code |
|
853 |
||
854 |
"Created: / 31.10.1997 / 17:21:29 / cg" |
|
855 |
"Modified: / 31.10.1997 / 17:38:11 / cg" |
|
856 |
! |
|
857 |
||
858 |
generateHookMethodsInClass:targetClass |
|
859 |
|code| |
|
860 |
||
861 |
code := ''. |
|
862 |
||
863 |
(targetClass implements:#postBuildWith:) ifFalse:[ |
|
864 |
code := code |
|
865 |
, (self |
|
866 |
generateHookMethodFor:'postBuildWith:aBuilder' |
|
867 |
comment:'the widgets have been built, but before the view is opened' |
|
708 | 868 |
note:'or after the super send' |
869 |
defaultCode:' super postBuildWith:aBuilder' |
|
376 | 870 |
inClass:targetClass) |
871 |
]. |
|
872 |
(targetClass implements:#postOpenWith:) ifFalse:[ |
|
873 |
code := code |
|
874 |
, (self |
|
875 |
generateHookMethodFor:'postOpenWith:aBuilder' |
|
876 |
comment:'the topView has been opened, but before events are dispatched for it' |
|
708 | 877 |
note:'or after the super send' |
878 |
defaultCode:' super postOpenWith:aBuilder' |
|
376 | 879 |
inClass:targetClass) |
880 |
]. |
|
881 |
(targetClass implements:#closeRequest) ifFalse:[ |
|
882 |
code := code |
|
883 |
, (self |
|
884 |
generateHookMethodFor:'closeRequest' |
|
885 |
comment:'the topView has been asked to close' |
|
886 |
note:'return without the ''super closeRequest'' to stay open' |
|
708 | 887 |
defaultCode:' ^super closeRequest' |
376 | 888 |
inClass:targetClass) |
889 |
]. |
|
890 |
^ code |
|
891 |
||
892 |
"Modified: / 31.10.1997 / 17:30:34 / cg" |
|
893 |
"Created: / 31.10.1997 / 17:32:49 / cg" |
|
316 | 894 |
! |
895 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
896 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
897 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
898 |
aspect , '\' , |
352 | 899 |
' "automatically generated by UIPainter ..."\\' , |
900 |
' "*** the code below returns a default value when invoked."\' , |
|
901 |
' "*** (which may not be the one you wanted)"\' , |
|
902 |
' "*** Please change as required and accept in the browser."\' , |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
903 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
904 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
905 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
906 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
907 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
908 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
909 |
|
352 | 910 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
911 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
912 |
|
78 | 913 |
generateWindowSpecMethodSource |
457 | 914 |
|spec str code category cls mthd specCode| |
60 | 915 |
|
310 | 916 |
spec := OrderedCollection new. |
60 | 917 |
|
78 | 918 |
self subViews do:[:aView| |
919 |
aView ~~ inputView ifTrue:[ |
|
310 | 920 |
spec add:(self fullSpecFor:aView) |
60 | 921 |
] |
922 |
]. |
|
310 | 923 |
spec := treeView generateFullSpecForComponents:spec. |
924 |
str := WriteStream on:String new. |
|
925 |
UISpecification prettyPrintSpecArray:spec on:str indent:5. |
|
464 | 926 |
specCode := str contents. |
457 | 927 |
|
928 |
(specCode includes:$!!) ifTrue:[ |
|
929 |
"/ oops - must be chunk format ... |
|
930 |
str := WriteStream on:String new. |
|
931 |
str nextPutAllAsChunk:specCode. |
|
932 |
specCode := str contents. |
|
933 |
]. |
|
60 | 934 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
935 |
"/ 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
|
936 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
937 |
category := 'interface specs'. |
330 | 938 |
cls := self resolveName:className. |
939 |
||
940 |
cls notNil ifTrue:[ |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
941 |
(mthd := cls class compiledMethodAt:methodName asSymbol) notNil ifTrue:[ |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
942 |
category := mthd category. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
943 |
] |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
944 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
945 |
|
238 | 946 |
code := '!!' |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
947 |
, className , ' class methodsFor:' , category storeString |
238 | 948 |
, '!!' , '\\' |
60 | 949 |
|
950 |
, methodName , '\' |
|
742 | 951 |
, ((ResourceSpecEditor codeGenerationCommentForClass: UIPainter) replChar:$!! withString:'!!!!') |
952 |
, '\\ "\' |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
953 |
, (' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\') |
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
954 |
, (' ' , className , ' new openInterface:#' , methodName , '\') |
742 | 955 |
,(methodName = 'windowSpec' |
956 |
ifTrue:[' ' , className , ' open\'] ifFalse: ['']) |
|
60 | 957 |
, ' "\'. |
958 |
||
959 |
code := code |
|
960 |
, '\' |
|
961 |
, ' <resource: #canvas>\\' |
|
962 |
, ' ^\' |
|
457 | 963 |
, ' ', specCode |
60 | 964 |
, '\' |
238 | 965 |
, '!! !!' |
60 | 966 |
, '\\'. |
967 |
||
968 |
^ code withCRs |
|
969 |
||
970 |
"Modified: 5.9.1995 / 21:01:35 / claus" |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
971 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 972 |
! ! |
973 |
||
754 | 974 |
!UIPainterView methodsFor:'grid manipulation'! |
975 |
||
976 |
newGrid |
|
977 |
"define a new grid - this is a private helper which has to be |
|
978 |
called after any change in the grid. It (re)creates the gridPixmap, |
|
979 |
clears the view and redraws all visible objects." |
|
980 |
||
981 |
|defaultViewBackground| |
|
982 |
||
983 |
gridPixmap := nil. |
|
984 |
defaultViewBackground := self class defaultViewBackgroundColor. |
|
985 |
||
986 |
shown ifTrue:[ |
|
987 |
self viewBackground: (defaultViewBackground isColor |
|
988 |
ifTrue: [defaultViewBackground] |
|
989 |
ifFalse:[Black]). |
|
990 |
self clear. |
|
991 |
]. |
|
992 |
||
993 |
gridShown ifTrue:[ |
|
994 |
self defineGrid. |
|
995 |
gridPixmap colorMap: (defaultViewBackground isColor |
|
996 |
ifTrue: [Array with:defaultViewBackground with:Color darkGray] |
|
997 |
ifFalse:[Array with:White with:Black]). |
|
998 |
self viewBackground:gridPixmap. |
|
999 |
]. |
|
1000 |
||
1001 |
self invalidate |
|
1002 |
||
1003 |
! ! |
|
1004 |
||
60 | 1005 |
!UIPainterView methodsFor:'initialization'! |
1006 |
||
770 | 1007 |
create |
1008 |
"colors on device |
|
1009 |
" |
|
1010 |
super create. |
|
1011 |
||
1012 |
handleColor := handleColor on:device. |
|
1013 |
handleMasterColor := handleMasterColor on:device. |
|
1014 |
! |
|
1015 |
||
60 | 1016 |
initialize |
62 | 1017 |
"setup attributes |
1018 |
" |
|
60 | 1019 |
super initialize. |
770 | 1020 |
superclassName := 'ApplicationModel'. |
1021 |
className := 'NewApplication'. |
|
1022 |
methodName := 'windowSpec'. |
|
1023 |
categoryName := 'Applications'. |
|
1024 |
HandCursor := Cursor leftHand. |
|
1025 |
handleColor := Color black. |
|
1026 |
handleMasterColor := Color red. |
|
60 | 1027 |
|
712 | 1028 |
self backgroundColor: self class defaultViewBackgroundColor. |
60 | 1029 |
! |
1030 |
||
1031 |
setupFromSpec:specOrSpecArray |
|
784 | 1032 |
|
78 | 1033 |
|spec builder| |
60 | 1034 |
|
784 | 1035 |
Cursor wait showWhile: [ |
1036 |
self removeAll. |
|
1037 |
spec := UISpecification from:specOrSpecArray. |
|
1038 |
builder := UIBuilder new isEditing:true. |
|
1039 |
"set applicationClass, in order that subspecifications may be resolved" |
|
1040 |
className notNil ifTrue:[ |
|
1041 |
builder applicationClass:(self resolveName:className). |
|
1042 |
]. |
|
1043 |
spec window setupView:self topView for:builder. |
|
1044 |
self addSpec:(spec component) builder:builder in:self. |
|
1045 |
self realizeAllSubViews. |
|
1046 |
inputView raise. |
|
1047 |
treeView setAttributesFromWindowSpec:(spec window) |
|
1048 |
] |
|
1049 |
||
223 | 1050 |
! |
1051 |
||
1052 |
treeView:aTreeView |
|
361 | 1053 |
treeView := aTreeView. |
1054 |
||
1055 |
treeView delegate:( |
|
376 | 1056 |
"/ |
1057 |
"/ I want to handle everything typed |
|
1058 |
"/ in the treeView, except for Return and Cursor-keys |
|
1059 |
"/ |
|
1060 |
KeyboardForwarder |
|
1061 |
toView:self |
|
1062 |
condition:nil |
|
1063 |
filter:[:k | (k isSymbol |
|
1064 |
and:[k ~~ #Return |
|
1065 |
and:[(k startsWith:#Cursor) not]]) |
|
1066 |
] |
|
361 | 1067 |
) |
1068 |
||
376 | 1069 |
"Modified: / 31.10.1997 / 20:22:09 / cg" |
60 | 1070 |
! ! |
1071 |
||
1072 |
!UIPainterView methodsFor:'menus'! |
|
1073 |
||
121 | 1074 |
showMiddleButtonMenu |
1075 |
"show the middle button menu; this returns nil |
|
62 | 1076 |
" |
223 | 1077 |
self enabled ifTrue:[ |
754 | 1078 |
(MenuPanel fromSpec:(UIPainter menuEdit) receiver:self superView application) startUp |
111 | 1079 |
]. |
121 | 1080 |
^ nil |
60 | 1081 |
|
62 | 1082 |
|
1083 |
||
60 | 1084 |
! ! |
1085 |
||
754 | 1086 |
!UIPainterView methodsFor:'private handles'! |
1087 |
||
1088 |
showSelected:aComponent |
|
1089 |
"show object selected |
|
1090 |
" |
|
1091 |
|wasClipped| |
|
1092 |
||
1093 |
selectionHiddenLevel == 0 ifTrue:[ |
|
1094 |
(treeView selection size > 1 and: |
|
1095 |
[(treeView model list at: treeView selection first) contents view == aComponent]) |
|
770 | 1096 |
ifTrue: [self paint: handleMasterColor] |
1097 |
ifFalse:[self paint: handleColor]. |
|
754 | 1098 |
|
1099 |
(wasClipped := clipChildren) ifTrue:[ |
|
1100 |
self clippedByChildren:(clipChildren := false). |
|
1101 |
]. |
|
1102 |
||
1103 |
self handlesOf:aComponent do:[:rectangle :what| |
|
1104 |
what == #view ifTrue:[self displayRectangle:rectangle] |
|
1105 |
ifFalse:[self fillRectangle:rectangle] |
|
1106 |
]. |
|
1107 |
||
1108 |
wasClipped ifTrue:[ |
|
1109 |
self clippedByChildren:(clipChildren := true). |
|
1110 |
] |
|
1111 |
] |
|
1112 |
||
1113 |
||
1114 |
! ! |
|
1115 |
||
335 | 1116 |
!UIPainterView methodsFor:'queries'! |
1117 |
||
1118 |
resolveName:aName |
|
1119 |
|appl| |
|
1120 |
||
1121 |
appl := self application. |
|
1122 |
||
1123 |
appl notNil ifTrue:[ |
|
1124 |
^ appl resolveName:aName |
|
1125 |
]. |
|
1126 |
^ Smalltalk resolveName:aName inClass:self class |
|
1127 |
! ! |
|
1128 |
||
60 | 1129 |
!UIPainterView methodsFor:'removing components'! |
1130 |
||
78 | 1131 |
remove:anObject |
1132 |
"remove anObject from the contents do redraw |
|
60 | 1133 |
" |
134 | 1134 |
anObject notNil ifTrue:[ |
238 | 1135 |
treeView removeView:anObject. |
134 | 1136 |
] |
60 | 1137 |
! |
1138 |
||
1139 |
removeAll |
|
62 | 1140 |
"remove all objects and properties |
1141 |
" |
|
776 | 1142 |
self select:nil. |
1143 |
treeView removeAll. |
|
1144 |
self removeUndoHistory. |
|
60 | 1145 |
! ! |
1146 |
||
1147 |
!UIPainterView methodsFor:'searching'! |
|
1148 |
||
285 | 1149 |
findContainerOfView:aView |
1150 |
"returns the super view assigned to a view |
|
89 | 1151 |
" |
285 | 1152 |
|p| |
89 | 1153 |
|
285 | 1154 |
(p := self propertyOfParentForView:aView) isNil ifTrue:[ |
89 | 1155 |
^ self |
1156 |
]. |
|
285 | 1157 |
^ p view |
89 | 1158 |
! |
1159 |
||
60 | 1160 |
findObjectAt:aPoint |
1161 |
"find the origin/corner of the currentWidget |
|
1162 |
" |
|
285 | 1163 |
|view prop| |
60 | 1164 |
|
1165 |
view := super findObjectAt:aPoint. |
|
285 | 1166 |
prop := self propertyRespondsToView:view. |
60 | 1167 |
|
285 | 1168 |
prop notNil ifTrue:[^ prop view]. |
1169 |
^ nil |
|
60 | 1170 |
! |
1171 |
||
1172 |
findViewWithId:aViewId |
|
62 | 1173 |
"finds view assigned to identifier and returns the view or nil |
60 | 1174 |
" |
1175 |
|prop| |
|
1176 |
||
1177 |
prop := self propertyOfIdentifier:aViewId. |
|
1178 |
||
1179 |
prop notNil ifTrue:[^ prop view] |
|
1180 |
ifFalse:[^ nil] |
|
78 | 1181 |
! |
1182 |
||
1183 |
propertyOfIdentifier:anId |
|
1184 |
"returns property assigned to unique identifier |
|
1185 |
" |
|
1186 |
anId notNil ifTrue:[ |
|
238 | 1187 |
^ treeView propertyDetect:[:p| p identifier == anId ] |
78 | 1188 |
]. |
1189 |
^ nil |
|
1190 |
! |
|
1191 |
||
1192 |
propertyOfName:aString |
|
1193 |
"returns property assigned to name |
|
1194 |
" |
|
111 | 1195 |
|name| |
1196 |
||
1197 |
aString isNil ifFalse:[ |
|
1198 |
name := aString string withoutSeparators. |
|
238 | 1199 |
^ treeView propertyDetect:[:p| p name = name ]. |
78 | 1200 |
]. |
1201 |
^ nil |
|
1202 |
! |
|
1203 |
||
285 | 1204 |
propertyOfParentForView:aSubView |
1205 |
"returns the property of the parent or nil |
|
1206 |
" |
|
1207 |
|item| |
|
1208 |
||
1209 |
(item := treeView detectItemRespondsToView:aSubView) notNil ifTrue:[ |
|
1210 |
(item := item parent) notNil ifTrue:[^ item contents] |
|
1211 |
]. |
|
1212 |
^ nil |
|
1213 |
! |
|
1214 |
||
78 | 1215 |
propertyOfView:aView |
1216 |
"returns property assigned to view |
|
1217 |
" |
|
1218 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
238 | 1219 |
^ treeView propertyDetect:[:p| p view == aView ] |
78 | 1220 |
]. |
1221 |
^ nil |
|
1222 |
! |
|
1223 |
||
285 | 1224 |
propertyRespondsToView:aView |
1225 |
"detect the property responding to the argument a view. The property of the view or |
|
1226 |
the first subview providing the properties is returned. If no property is detected |
|
1227 |
nil is returned. |
|
1228 |
" |
|
1229 |
|item| |
|
1230 |
||
1231 |
item := treeView detectItemRespondsToView:aView. |
|
1232 |
||
1233 |
(item notNil and:[item parent notNil]) ifTrue:[ |
|
1234 |
^ item contents |
|
1235 |
]. |
|
1236 |
^ nil |
|
1237 |
! |
|
1238 |
||
111 | 1239 |
uniqueNameFor:aSpecOrString |
78 | 1240 |
"generate and return an unique name for a class |
1241 |
" |
|
1242 |
|next name size| |
|
1243 |
||
712 | 1244 |
aSpecOrString isString ifFalse:[name := aSpecOrString userFriendlyName] |
111 | 1245 |
ifTrue:[name := aSpecOrString]. |
78 | 1246 |
|
111 | 1247 |
size := name size + 1. |
1248 |
next := 0. |
|
78 | 1249 |
|
238 | 1250 |
treeView propertiesDo:[:p| |
111 | 1251 |
|n| |
78 | 1252 |
n := p name. |
1253 |
||
1254 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
1255 |
next := next max:(p extractNumberStartingAt:size) |
|
1256 |
] |
|
1257 |
]. |
|
1258 |
next := next + 1. |
|
1259 |
name := name, next printString. |
|
1260 |
^ name |
|
1261 |
||
1262 |
||
1263 |
||
662 | 1264 |
|
78 | 1265 |
! |
1266 |
||
1267 |
uniqueNameOf:aView |
|
111 | 1268 |
|prop| |
78 | 1269 |
|
111 | 1270 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
1271 |
prop name isNil ifTrue:[ |
|
1272 |
prop name:(self uniqueNameFor:(prop spec)). |
|
1273 |
]. |
|
1274 |
^ prop name |
|
78 | 1275 |
]. |
111 | 1276 |
^ 'self' |
78 | 1277 |
|
60 | 1278 |
! ! |
1279 |
||
223 | 1280 |
!UIPainterView methodsFor:'selection basics'! |
1281 |
||
1282 |
addToSelection:anObject |
|
1283 |
"add an object to the selection |
|
1284 |
" |
|
1285 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
1286 |
selection isCollection ifFalse:[ |
|
1287 |
selection isNil ifTrue:[ |
|
1288 |
selection := anObject |
|
1289 |
] ifFalse:[ |
|
1290 |
selection := OrderedCollection with:selection with:anObject |
|
1291 |
] |
|
1292 |
] ifTrue:[ |
|
1293 |
selection add:anObject |
|
1294 |
]. |
|
1295 |
self showSelected:anObject. |
|
238 | 1296 |
treeView cvsSelectionAdd:anObject. |
223 | 1297 |
] |
1298 |
||
1299 |
||
1300 |
! |
|
1301 |
||
1302 |
removeFromSelection:anObject |
|
1303 |
"remove an object from the selection |
|
1304 |
" |
|
1305 |
(self isSelected:anObject) ifTrue:[ |
|
1306 |
self showUnselected:anObject. |
|
1307 |
||
1308 |
selection size > 1 ifTrue:[ |
|
1309 |
selection remove:anObject ifAbsent:nil. |
|
1310 |
self showSelection. |
|
1311 |
] ifFalse:[ |
|
1312 |
selection := nil |
|
1313 |
]. |
|
238 | 1314 |
treeView cvsSelectionRemove:anObject. |
223 | 1315 |
] |
1316 |
||
1317 |
! |
|
1318 |
||
1319 |
select:something |
|
1320 |
"change selection to something |
|
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
1321 |
" |
760 | 1322 |
(self enabled and:[something ~= self selection]) ifTrue:[ |
1323 |
something isNil |
|
1324 |
ifTrue: [treeView selection: (Array with: 1)] |
|
1325 |
ifFalse:[treeView cvsSelection:something]. |
|
886
3c67610b9631
after deleting a widget do select the neighbour then the parent
tz
parents:
858
diff
changeset
|
1326 |
self setSelection:something withRedraw:true |
223 | 1327 |
] |
1328 |
||
1329 |
! |
|
1330 |
||
285 | 1331 |
updateSelectionFromModel:aSelOrNil |
223 | 1332 |
"update selection from a new selection |
1333 |
" |
|
768 | 1334 |
|aSet| |
1335 |
||
223 | 1336 |
selectionHiddenLevel == 0 ifTrue:[ |
285 | 1337 |
aSelOrNil size ~~ 0 ifTrue:[ |
768 | 1338 |
self selectionDo:[:el| |
1339 |
(aSelOrNil includes:el) ifFalse:[ |
|
1340 |
aSet isNil ifTrue:[ |
|
1341 |
aSet := IdentitySet new |
|
1342 |
]. |
|
1343 |
self showUnselected:el addAffectedViewsTo:aSet. |
|
1344 |
] |
|
1345 |
]. |
|
1346 |
self handleAffectedViews:aSet. |
|
285 | 1347 |
] ifFalse:[ |
768 | 1348 |
self hideSelection. |
285 | 1349 |
] |
223 | 1350 |
]. |
285 | 1351 |
self setSelection:aSelOrNil withRedraw:false. |
223 | 1352 |
self showSelection |
1353 |
||
1354 |
! ! |
|
1355 |
||
78 | 1356 |
!UIPainterView methodsFor:'specification'! |
1357 |
||
1358 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
1359 |
"build view and subviews from aSpecification into a frame. The top view |
|
1360 |
is returned. The contained components of a spec are set to nil |
|
1361 |
" |
|
330 | 1362 |
|cls| |
212 | 1363 |
|
330 | 1364 |
cls := self resolveName:className. |
1365 |
||
1366 |
cls notNil ifTrue:[ |
|
1367 |
aBuilder applicationClass:cls. |
|
212 | 1368 |
]. |
78 | 1369 |
|
111 | 1370 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 1371 |
p := ViewProperty new. |
1372 |
s := aSpec copy. |
|
1373 |
p spec:s. |
|
1374 |
p view:aView. |
|
1375 |
||
1376 |
s class supportsSubComponents ifTrue:[ |
|
1377 |
s component:nil |
|
1378 |
]. |
|
1379 |
||
111 | 1380 |
n := s name. |
1381 |
||
1382 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
1383 |
s name:(self uniqueNameFor:s) |
|
78 | 1384 |
]. |
238 | 1385 |
treeView addProperty:p. |
78 | 1386 |
]. |
1387 |
||
1388 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 1389 |
|
212 | 1390 |
"Modified: 4.7.1997 / 23:48:55 / cg" |
78 | 1391 |
! |
1392 |
||
1393 |
fullSpecFor:anObject |
|
1394 |
"generate a full spec for an object |
|
62 | 1395 |
" |
78 | 1396 |
|mySpec subSpecs| |
1397 |
||
1398 |
mySpec := self specFor:anObject. |
|
1399 |
||
1400 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
1401 |
(anObject subViews notNil) ifTrue:[ |
|
1402 |
anObject subViews do:[:aSubView||spec| |
|
1403 |
spec := self fullSpecFor:aSubView. |
|
1404 |
spec notNil ifTrue:[ |
|
1405 |
subSpecs isNil ifTrue:[ |
|
1406 |
subSpecs := OrderedCollection new |
|
1407 |
]. |
|
1408 |
subSpecs add:spec. |
|
1409 |
]. |
|
1410 |
]. |
|
1411 |
subSpecs notNil ifTrue:[ |
|
1412 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
1413 |
] |
|
1414 |
] |
|
1415 |
]. |
|
1416 |
^ mySpec |
|
1417 |
||
60 | 1418 |
|
1419 |
||
1420 |
||
1421 |
||
1422 |
||
1423 |
! |
|
1424 |
||
285 | 1425 |
rebuildView:aView fromSpec:aSpec withBuilder:aBuilder |
1426 |
|v| |
|
1427 |
||
1428 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
1429 |
v := aSpec buildViewWithLayoutFor:aBuilder in:(self findContainerOfView:aView). |
|
1430 |
v realize. |
|
1431 |
aView destroy. |
|
1432 |
device sync. |
|
1433 |
device flush. |
|
1434 |
aView becomeSameAs:v. |
|
1435 |
inputView raise. |
|
1436 |
] ifFalse:[ |
|
1437 |
aSpec setAttributesIn:aView with:aBuilder. |
|
1438 |
self elementChangedSize:aView. |
|
1439 |
]. |
|
1440 |
||
1441 |
! |
|
1442 |
||
78 | 1443 |
specFor:anObject |
1444 |
"returns spec assigned to an object |
|
62 | 1445 |
" |
78 | 1446 |
|prop spec| |
60 | 1447 |
|
78 | 1448 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
1449 |
spec := prop spec copy. |
|
1450 |
spec layoutFromView:anObject |
|
60 | 1451 |
]. |
78 | 1452 |
^ spec |
1453 |
||
1454 |
||
1455 |
||
60 | 1456 |
! |
1457 |
||
146 | 1458 |
specForSelection |
1459 |
"returns spec assigned to current single selection or nil |
|
1460 |
" |
|
1461 |
^ self specFor:(self singleSelection) |
|
1462 |
||
1463 |
||
1464 |
! |
|
1465 |
||
78 | 1466 |
updateFromSpec:aSpec |
1467 |
"update current selected view from specification |
|
62 | 1468 |
" |
327
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1469 |
|props name builder| |
78 | 1470 |
|
281 | 1471 |
aSpec class == WindowSpec ifTrue:[ |
698 | 1472 |
^ treeView canvasSpec:aSpec |
281 | 1473 |
]. |
1474 |
||
78 | 1475 |
self singleSelection notNil ifTrue:[ |
1476 |
self withSelectionHiddenDo:[ |
|
1477 |
self transaction:#specification selectionDo:[:aView| |
|
395 | 1478 |
builder := UIBuilder new isEditing:true. |
212 | 1479 |
className notNil ifTrue:[ |
330 | 1480 |
builder applicationClass:(self resolveName:className). |
212 | 1481 |
]. |
78 | 1482 |
props := self propertyOfView:aView. |
82 | 1483 |
name := (aSpec name) withoutSeparators. |
78 | 1484 |
|
82 | 1485 |
name = props name ifFalse:[ |
1486 |
(self propertyOfName:name) notNil ifTrue:[ |
|
1487 |
name := props name |
|
78 | 1488 |
] |
1489 |
]. |
|
82 | 1490 |
aSpec name:name. |
134 | 1491 |
self createUndoSpecModify:props. |
285 | 1492 |
self rebuildView:aView fromSpec:aSpec withBuilder:builder. |
78 | 1493 |
props spec:(aSpec copy). |
238 | 1494 |
treeView propertyChanged:props. |
78 | 1495 |
] |
111 | 1496 |
] |
82 | 1497 |
] |
212 | 1498 |
|
1499 |
"Modified: 4.7.1997 / 23:49:44 / cg" |
|
60 | 1500 |
! ! |
1501 |
||
285 | 1502 |
!UIPainterView methodsFor:'testing'! |
1503 |
||
1504 |
canChangeLayoutOfView:aView |
|
1505 |
"returns true if the view can change its layout which is dependant on |
|
1506 |
its parent view. |
|
1507 |
" |
|
1508 |
|item prnt| |
|
1509 |
||
1510 |
( (item := treeView itemOfView:aView) isNil |
|
1511 |
or:[(prnt := item parent) isNil] |
|
1512 |
) ifTrue:[ |
|
1513 |
^ false |
|
1514 |
]. |
|
1515 |
^ (prnt parent isNil or:[prnt contents spec class isLayoutContainer not]) |
|
1516 |
! |
|
1517 |
||
1518 |
canKeepLayoutInSelection |
|
1519 |
"returns true if layout can be kept during a paste operation |
|
1520 |
" |
|
1521 |
|prop| |
|
1522 |
||
1523 |
prop := self propertyOfView:(self singleSelection). |
|
1524 |
^ (prop isNil or:[prop spec class isLayoutContainer not]) |
|
1525 |
! |
|
1526 |
||
1527 |
canMove:something |
|
1528 |
"checks whether something is not nil and if all widgets derived from |
|
1529 |
something can change their layout ( move, align, ... operation ). |
|
1530 |
" |
|
1531 |
something notNil ifTrue:[ |
|
1532 |
self forEach:something do:[:aView| |
|
1533 |
(self canChangeLayoutOfView:aView) ifFalse:[^ false] |
|
1534 |
]. |
|
1535 |
^ true |
|
1536 |
]. |
|
1537 |
^ false |
|
1538 |
! |
|
1539 |
||
1540 |
canMoveOrAlignSelection |
|
1541 |
"returns true if a selection exists and all elements in the selection |
|
1542 |
can be moved or aligned |
|
1543 |
" |
|
1544 |
^ self canMove:(self selection) |
|
1545 |
||
1546 |
! ! |
|
1547 |
||
60 | 1548 |
!UIPainterView methodsFor:'transaction'! |
1549 |
||
1550 |
transaction:aType objects:something do:aOneArgBlock |
|
1551 |
"opens a transaction and evaluates a block within the transaction; the |
|
1552 |
argument to the block is a view from derived from something |
|
1553 |
" |
|
134 | 1554 |
self withinTransaction:aType objects:something do:[ |
1555 |
self forEach:something do:aOneArgBlock |
|
60 | 1556 |
] |
1557 |
! |
|
1558 |
||
134 | 1559 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
1560 |
"evaluate a block with no arguments within a transaction |
|
60 | 1561 |
" |
134 | 1562 |
|text size prop| |
1563 |
||
1564 |
objects isNil ifTrue:[ ^ self ]. |
|
1565 |
||
1566 |
size := objects size. |
|
60 | 1567 |
|
134 | 1568 |
objects isCollection ifTrue:[ |
1569 |
size == 0 ifTrue:[ ^ self ]. |
|
1570 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
1571 |
] ifFalse:[ |
|
1572 |
prop := self propertyOfView:objects |
|
1573 |
]. |
|
60 | 1574 |
|
134 | 1575 |
prop notNil ifTrue:[ |
1576 |
text := prop name |
|
1577 |
] ifFalse:[ |
|
1578 |
text := size printString, ' elements' |
|
60 | 1579 |
]. |
134 | 1580 |
|
1581 |
undoHistory withinTransaction:aType text:text do:[ |
|
1582 |
aNoneArgBlock value |
|
1583 |
] |
|
60 | 1584 |
! ! |
1585 |
||
1586 |
!UIPainterView methodsFor:'undo actions'! |
|
1587 |
||
134 | 1588 |
createUndoLayout:aView |
1589 |
"create undo action before changing a views layout |
|
60 | 1590 |
" |
134 | 1591 |
|lyt args prop| |
60 | 1592 |
|
1593 |
undoHistory isTransactionOpen ifTrue:[ |
|
1594 |
prop := self propertyOfView:aView. |
|
134 | 1595 |
|
60 | 1596 |
prop notNil ifTrue:[ |
134 | 1597 |
args := Array new:3. |
1598 |
args at:1 put:(prop identifier). |
|
1599 |
||
1600 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
1601 |
args at:2 put:#geometryLayout: |
|
1602 |
] ifFalse:[ |
|
146 | 1603 |
lyt := aView extent. |
134 | 1604 |
args at:2 put:#extent: |
1605 |
]. |
|
1606 |
args at:3 put:(lyt copy). |
|
1607 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 1608 |
] |
1609 |
] |
|
1610 |
! |
|
1611 |
||
134 | 1612 |
createUndoRemove:aView |
1613 |
"create undo method before deleting views |
|
60 | 1614 |
" |
285 | 1615 |
|prop pid| |
134 | 1616 |
|
1617 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
285 | 1618 |
(pid := self propertyOfParentForView:aView) notNil ifTrue:[ |
1619 |
pid := pid identifier |
|
1620 |
]. |
|
60 | 1621 |
|
134 | 1622 |
undoHistory addUndoSelector:#undoRemove: |
285 | 1623 |
withArgs:(Array with:(self fullSpecFor:aView) |
1624 |
with:(prop identifier) |
|
1625 |
with:pid) |
|
134 | 1626 |
] |
1627 |
! |
|
60 | 1628 |
|
134 | 1629 |
createUndoSpecModify:aProp |
1630 |
"undo method when changing the specification for an object |
|
1631 |
" |
|
1632 |
aProp notNil ifTrue:[ |
|
1633 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1634 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1635 |
] |
|
1636 |
! |
|
60 | 1637 |
|
134 | 1638 |
undoCreate:something |
1639 |
"undo method for creating or pasting an object |
|
1640 |
" |
|
1641 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1642 |
! |
|
60 | 1643 |
|
134 | 1644 |
undoLayout:args |
1645 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1646 |
" |
|
1647 |
|view| |
|
1648 |
||
1649 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1650 |
view perform:(args at:2) with:(args at:3). |
223 | 1651 |
self layoutChanged. |
60 | 1652 |
] |
1653 |
! |
|
1654 |
||
134 | 1655 |
undoRemove:args |
1656 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1657 |
" |
|
1658 |
|frame prop view| |
|
1659 |
||
1660 |
(args at:3) notNil ifTrue:[ |
|
1661 |
frame := self findViewWithId:(args at:3). |
|
1662 |
]. |
|
1663 |
frame isNil ifTrue:[ |
|
1664 |
frame := self |
|
1665 |
]. |
|
395 | 1666 |
view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame. |
134 | 1667 |
view realize. |
1668 |
inputView raise. |
|
1669 |
||
1670 |
prop := self propertyOfView:view. |
|
1671 |
prop identifier:(args at:2). |
|
1672 |
||
1673 |
! |
|
1674 |
||
1675 |
undoSpecModify:args |
|
1676 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1677 |
" |
327
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
1678 |
|builder view spec props| |
60 | 1679 |
|
134 | 1680 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1681 |
|
134 | 1682 |
props notNil ifTrue:[ |
1683 |
view := props view. |
|
1684 |
spec := args at:1. |
|
395 | 1685 |
builder := UIBuilder new isEditing:true. |
1686 |
||
212 | 1687 |
className notNil ifTrue:[ |
330 | 1688 |
builder applicationClass:(self resolveName:className). |
212 | 1689 |
]. |
134 | 1690 |
props spec:spec. |
285 | 1691 |
self rebuildView:view fromSpec:spec withBuilder:builder. |
238 | 1692 |
treeView propertyChanged:props. |
211 | 1693 |
] |
1694 |
! ! |
|
1695 |
||
1696 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
1697 |
||
1698 |
new |
|
1699 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1700 |
ifFalse:[Identifier := 1]. |
|
1701 |
||
1702 |
^ self basicNew initialize |
|
1703 |
! ! |
|
1704 |
||
1705 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1706 |
||
1707 |
identifier |
|
1708 |
"return the unique identifier assigned to property |
|
1709 |
" |
|
1710 |
^ identifier |
|
1711 |
! |
|
1712 |
||
1713 |
identifier:anIdentifier |
|
1714 |
"set the unique identifier assigned to property; called after an restore of |
|
1715 |
a deleted instance |
|
1716 |
" |
|
1717 |
identifier := anIdentifier |
|
1718 |
! |
|
1719 |
||
1720 |
spec |
|
1721 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1722 |
||
1723 |
^ spec! |
|
1724 |
||
1725 |
spec:something |
|
1726 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1727 |
||
1728 |
spec := something.! |
|
1729 |
||
1730 |
view |
|
1731 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1732 |
||
1733 |
^ view! |
|
1734 |
||
1735 |
view:something |
|
1736 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1737 |
||
1738 |
view := something.! ! |
|
1739 |
||
1740 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1741 |
||
1742 |
initialize |
|
1743 |
super initialize. |
|
1744 |
identifier := Identifier |
|
1745 |
! ! |
|
1746 |
||
1747 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1748 |
||
1749 |
extractNumberStartingAt:anIndex |
|
1750 |
"return the number from the name starting at anIndex or 0. |
|
1751 |
" |
|
1752 |
|val| |
|
1753 |
||
1754 |
val := 0. |
|
1755 |
||
1756 |
self name from:anIndex do:[:c| |
|
1757 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1758 |
ifFalse:[^ 0] |
|
1759 |
]. |
|
1760 |
^ val |
|
1761 |
||
1762 |
! ! |
|
1763 |
||
1764 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1765 |
||
1766 |
doesNotUnderstand:aMessage |
|
1767 |
spec notNil ifTrue:[ |
|
1768 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1769 |
]. |
|
1770 |
^ nil |
|
1771 |
! |
|
1772 |
||
1773 |
layout |
|
1774 |
spec layout |
|
1775 |
! |
|
1776 |
||
1777 |
layout:aLayout |
|
1778 |
spec layout:aLayout |
|
1779 |
! |
|
1780 |
||
1781 |
name |
|
1782 |
^ spec name |
|
1783 |
! |
|
1784 |
||
1785 |
name:aName |
|
1786 |
spec name:aName |
|
1787 |
! ! |
|
1788 |
||
60 | 1789 |
!UIPainterView class methodsFor:'documentation'! |
1790 |
||
1791 |
version |
|
1792 |
^ '$Header$' |
|
1793 |
! ! |