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