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