author | Claus Gittinger <cg@exept.de> |
Fri, 04 Jul 1997 19:00:33 +0200 | |
changeset 208 | d6107fdfe5ce |
parent 202 | 0552c63ee68b |
child 210 | e49d831bb81f |
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 |
||
180 | 20 |
MultiSelectionInList subclass:#ListHolder |
21 |
instanceVariableNames:'painter propertyList masterElement disabledChanged' |
|
22 |
classVariableNames:'' |
|
119 | 23 |
poolDictionaries:'' |
24 |
privateIn:UIPainterView |
|
25 |
! |
|
26 |
||
180 | 27 |
Object subclass:#ViewProperty |
28 |
instanceVariableNames:'view spec identifier' |
|
29 |
classVariableNames:'Identifier' |
|
60 | 30 |
poolDictionaries:'' |
31 |
privateIn:UIPainterView |
|
32 |
! |
|
33 |
||
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. |
|
89 | 475 |
|
165 | 476 |
keepLayout ifFalse:[ |
477 |
pasteOffset := 0@0. |
|
478 |
pasteOrigin := self sensor mousePoint. |
|
479 |
pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id. |
|
480 |
]. |
|
60 | 481 |
|
165 | 482 |
listHolder disableNotificationsWhileEvaluating:[ |
483 |
paste do:[:aSpec| |
|
484 |
|view| |
|
60 | 485 |
|
165 | 486 |
view := self addSpec:aSpec builder:builder in:frame. |
60 | 487 |
|
165 | 488 |
keepLayout ifFalse:[ |
489 |
(frame bounds containsPoint:pasteOrigin) ifFalse:[ |
|
490 |
self moveObject:view to:pasteOffset. |
|
491 |
] ifTrue:[ |
|
492 |
self moveObject:view to:pasteOrigin + pasteOffset. |
|
493 |
]. |
|
494 |
pasteOffset := pasteOffset + 4 |
|
111 | 495 |
]. |
165 | 496 |
view realize. |
497 |
newSel add:view. |
|
89 | 498 |
]. |
60 | 499 |
]. |
500 |
||
165 | 501 |
self withinTransaction:#paste objects:newSel do:[ |
502 |
undoHistory addUndoSelector:#undoCreate: |
|
503 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]) |
|
504 |
]. |
|
134 | 505 |
|
165 | 506 |
newSel size == 1 ifTrue:[ |
507 |
newSel := newSel at:1 |
|
508 |
]. |
|
509 |
self realizeAllSubViews. |
|
510 |
inputView raise. |
|
511 |
self select:newSel. |
|
512 |
self elementChangedSize:frame. |
|
513 |
] |
|
89 | 514 |
! |
515 |
||
516 |
pasteWithLayout |
|
517 |
"add the objects in the paste-buffer to the object view; don't change the |
|
518 |
layout |
|
519 |
" |
|
520 |
self pasteSpecifications:(self getSelection) keepLayout:true |
|
521 |
||
60 | 522 |
! ! |
523 |
||
524 |
!UIPainterView methodsFor:'drag & drop'! |
|
525 |
||
526 |
canDrop:anObjectOrCollection |
|
89 | 527 |
|spec| |
60 | 528 |
|
119 | 529 |
self enabled ifTrue:[ |
89 | 530 |
anObjectOrCollection size == 1 ifTrue:[ |
531 |
spec := (anObjectOrCollection at:1) theObject. |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
532 |
^ (spec isKindOf:UISpecification) |
89 | 533 |
] |
534 |
]. |
|
535 |
^ false |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
536 |
|
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
537 |
"Modified: 8.4.1997 / 01:01:50 / cg" |
60 | 538 |
! |
539 |
||
540 |
drop:anObjectOrCollection at:aPoint |
|
89 | 541 |
|spec| |
542 |
||
543 |
spec := (anObjectOrCollection at:1) theObject. |
|
544 |
self pasteSpecifications:spec keepLayout:false. |
|
60 | 545 |
|
546 |
||
547 |
! ! |
|
548 |
||
78 | 549 |
!UIPainterView methodsFor:'generating output'! |
550 |
||
60 | 551 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
149 | 552 |
|args showIt| |
141 | 553 |
|
149 | 554 |
(aspect asSymbol numArgs) == 1 ifFalse:[ |
555 |
args := '\'. |
|
556 |
showIt := ' ...''.\'. |
|
557 |
] ifTrue:[ |
|
558 |
args := 'anArgument\'. |
|
559 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
560 |
]. |
|
141 | 561 |
|
60 | 562 |
^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
141 | 563 |
aspect , args , |
60 | 564 |
' "automatically generated by UIPainter ..."\' , |
565 |
'\' , |
|
566 |
' "action to be added ..."\' , |
|
149 | 567 |
' Transcript showCR:self class name , '': action for ' , aspect , showIt , |
60 | 568 |
'!! !!\\') withCRs |
569 |
! |
|
570 |
||
571 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
|
134 | 572 |
|modelClass| |
573 |
||
149 | 574 |
modelClass := protoSpec defaultModelClassFor:aspect. |
134 | 575 |
|
60 | 576 |
^ ('!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
577 |
aspect , '\' , |
|
578 |
' "automatically generated by UIPainter ..."\' , |
|
579 |
'\' , |
|
580 |
' |holder|\' , |
|
581 |
'\' , |
|
582 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
134 | 583 |
' builder aspectAt:#' , aspect , ' put:(holder := ' , ' ' , modelClass name , ' new' , ').\' , |
60 | 584 |
' ].\' , |
585 |
' ^ holder\' , |
|
586 |
'!! !!\\') withCRs |
|
587 |
! |
|
588 |
||
589 |
generateAspectMethods |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
590 |
|cls code skip| |
60 | 591 |
|
78 | 592 |
code := ''. |
593 |
||
60 | 594 |
className isNil ifTrue:[ |
69 | 595 |
self warn:'set the class first'. |
78 | 596 |
^ code |
60 | 597 |
]. |
89 | 598 |
cls := Smalltalk classNamed:className. |
60 | 599 |
|
111 | 600 |
listHolder propertiesDo:[:aProp | |
62 | 601 |
|modelSelector menuSelector protoSpec thisCode| |
60 | 602 |
|
134 | 603 |
protoSpec := aProp spec. |
175 | 604 |
|
78 | 605 |
(modelSelector := aProp model) notNil ifTrue:[ |
60 | 606 |
(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
|
607 |
skip := false. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
608 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
609 |
skip := SimpleDialog implements:modelSelector asSymbol |
60 | 610 |
]. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
611 |
skip ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
612 |
"/ kludge .. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
613 |
(protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
614 |
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
|
615 |
] ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
616 |
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
|
617 |
]. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
618 |
code := code , thisCode |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
619 |
]. |
62 | 620 |
]. |
621 |
]. |
|
622 |
||
78 | 623 |
(menuSelector := aProp menu) notNil ifTrue:[ |
62 | 624 |
(cls implements:menuSelector asSymbol) ifFalse:[ |
625 |
thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). |
|
626 |
code := code , thisCode |
|
60 | 627 |
] |
111 | 628 |
]. |
629 |
||
630 |
aProp spec aspectSelectors do:[:aSel| |
|
631 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
632 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
633 |
code := code , thisCode |
|
634 |
] |
|
635 |
]. |
|
137 | 636 |
aProp spec actionSelectors do:[:aSel| |
637 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
638 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
639 |
code := code , thisCode |
|
640 |
] |
|
641 |
]. |
|
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
642 |
aProp spec valueSelectors do:[:aSel| |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
643 |
(cls implements:aSel asSymbol) ifFalse:[ |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
644 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
645 |
code := code , thisCode |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
646 |
] |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
647 |
]. |
111 | 648 |
|
60 | 649 |
]. |
650 |
^ code |
|
651 |
! |
|
652 |
||
188
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
653 |
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
654 |
^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
655 |
aspect , '\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
656 |
' "automatically generated by UIPainter ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
657 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
658 |
' "value to be added below ..."\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
659 |
' Transcript showCR:self class name , '': no value yet for ' , aspect , ' ...''.\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
660 |
'\' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
661 |
'^ nil.' , |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
662 |
'!! !!\\') withCRs |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
663 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
664 |
|
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 |
|
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
667 |
! |
8091a35bccf1
generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
ca
parents:
180
diff
changeset
|
668 |
|
78 | 669 |
generateWindowSpecMethodSource |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
670 |
|t s spec specArray str code category cls mthd| |
60 | 671 |
|
78 | 672 |
specArray := OrderedCollection new. |
60 | 673 |
|
78 | 674 |
self subViews do:[:aView| |
675 |
aView ~~ inputView ifTrue:[ |
|
676 |
specArray add:(self fullSpecFor:aView) |
|
60 | 677 |
] |
678 |
]. |
|
78 | 679 |
spec := FullSpec new. |
680 |
spec fromBuilder:self components:(SpecCollection new collection:specArray). |
|
60 | 681 |
specArray := spec literalArrayEncoding. |
682 |
||
683 |
str := WriteStream on:String new. |
|
86 | 684 |
UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
60 | 685 |
|
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
686 |
"/ 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
|
687 |
|
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
688 |
category := 'interface specs'. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
689 |
(cls := Smalltalk classNamed:className) notNil ifTrue:[ |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
690 |
(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
|
691 |
category := mthd 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 |
]. |
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
694 |
|
60 | 695 |
code := Character excla asString |
178
fb8451053c96
keep windowSpec methods category if it already exists
Claus Gittinger <cg@exept.de>
parents:
175
diff
changeset
|
696 |
, className , ' class methodsFor:' , category storeString |
60 | 697 |
, Character excla asString , '\\' |
698 |
||
699 |
, methodName , '\' |
|
700 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
701 |
, ' "do not manually edit this - the painter/builder may not be able to\' |
|
702 |
, ' handle the specification if its corrupted."\\' |
|
703 |
, ' "\' |
|
704 |
, ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
705 |
, ' ' , className , ' new openInterface:#' , methodName , '\' |
|
706 |
, ' "\'. |
|
707 |
||
708 |
methodName = 'windowSpec' ifTrue:[ |
|
709 |
code := code , ' "' , className , ' open"\' |
|
710 |
]. |
|
711 |
code := code |
|
712 |
, '\' |
|
713 |
, ' <resource: #canvas>\\' |
|
714 |
, ' ^\' |
|
715 |
, ' ', str contents |
|
716 |
, '\' |
|
717 |
, Character excla asString |
|
718 |
, ' ' |
|
719 |
, Character excla asString |
|
720 |
, '\\'. |
|
721 |
||
722 |
^ code withCRs |
|
723 |
||
724 |
"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
|
725 |
"Modified: 24.6.1997 / 19:12:44 / cg" |
60 | 726 |
! ! |
727 |
||
728 |
!UIPainterView methodsFor:'initialization'! |
|
729 |
||
137 | 730 |
destroy |
731 |
"remove dependencies |
|
732 |
" |
|
733 |
listHolder notNil ifTrue:[ |
|
734 |
listHolder removeDependent:self. |
|
735 |
]. |
|
736 |
super destroy. |
|
737 |
! |
|
738 |
||
60 | 739 |
initialize |
62 | 740 |
"setup attributes |
741 |
" |
|
60 | 742 |
super initialize. |
743 |
||
744 |
superclassName := 'ApplicationModel'. |
|
745 |
className := 'NewApplication'. |
|
746 |
methodName := 'windowSpec'. |
|
747 |
categoryName := 'Applications'. |
|
111 | 748 |
listHolder := ListHolder for:self. |
60 | 749 |
HandCursor := Cursor leftHand. |
750 |
||
751 |
! |
|
752 |
||
753 |
setupFromSpec:specOrSpecArray |
|
78 | 754 |
|spec builder| |
60 | 755 |
|
111 | 756 |
listHolder disableNotificationsWhileEvaluating:[ |
757 |
self removeAll. |
|
758 |
spec := UISpecification from:specOrSpecArray. |
|
759 |
builder := UIBuilder new. |
|
760 |
spec window setupView:self topView for:builder. |
|
761 |
self addSpec:(spec component) builder:builder in:self. |
|
762 |
self realizeAllSubViews. |
|
763 |
inputView raise. |
|
764 |
] |
|
60 | 765 |
! ! |
766 |
||
767 |
!UIPainterView methodsFor:'menus'! |
|
768 |
||
121 | 769 |
showMiddleButtonMenu |
770 |
"show the middle button menu; this returns nil |
|
62 | 771 |
" |
111 | 772 |
|menu canPaste| |
60 | 773 |
|
121 | 774 |
self enabled ifFalse:[ |
775 |
^ nil |
|
776 |
]. |
|
111 | 777 |
menu := MenuPanel fromSpec:(self class menu) receiver:self. |
60 | 778 |
|
779 |
canPaste := self canPaste:(self getSelection). |
|
780 |
||
128 | 781 |
self hasSelection ifTrue:[ |
782 |
canPaste := (canPaste and:[self canPasteInto:(self selection)]) |
|
783 |
] ifFalse:[ |
|
111 | 784 |
menu disableAll |
785 |
]. |
|
128 | 786 |
menu enabledAt:#paste put:canPaste. |
134 | 787 |
menu enabledAt:#undo put:(undoHistory isEmpty not). |
121 | 788 |
menu startUp. |
789 |
^ nil |
|
60 | 790 |
|
62 | 791 |
|
792 |
||
60 | 793 |
! ! |
794 |
||
795 |
!UIPainterView methodsFor:'removing components'! |
|
796 |
||
78 | 797 |
remove:anObject |
798 |
"remove anObject from the contents do redraw |
|
60 | 799 |
" |
134 | 800 |
anObject notNil ifTrue:[ |
801 |
listHolder remove:anObject |
|
802 |
] |
|
60 | 803 |
! |
804 |
||
805 |
removeAll |
|
62 | 806 |
"remove all objects and properties |
807 |
" |
|
111 | 808 |
listHolder disableNotificationsWhileEvaluating:[ |
131 | 809 |
self select:nil. |
134 | 810 |
listHolder removeAll. |
811 |
self removeUndoHistory. |
|
111 | 812 |
] |
60 | 813 |
! ! |
814 |
||
815 |
!UIPainterView methodsFor:'searching'! |
|
816 |
||
89 | 817 |
findContainerViewAt:aPoint |
818 |
"find container view responds to aPoint. |
|
819 |
" |
|
820 |
|view| |
|
821 |
||
822 |
(view := self findObjectAt:aPoint) isNil ifTrue:[ |
|
823 |
^ self |
|
824 |
]. |
|
825 |
||
826 |
[(view specClass supportsSubComponents or:[(view := view superView) == self]) |
|
827 |
] whileFalse:[ |
|
828 |
[(self propertyOfView:view) isNil] whileTrue:[ |
|
829 |
(view := view superView) == self ifTrue:[^ self] |
|
830 |
]. |
|
831 |
]. |
|
832 |
^ view |
|
833 |
! |
|
834 |
||
60 | 835 |
findObjectAt:aPoint |
836 |
"find the origin/corner of the currentWidget |
|
837 |
" |
|
838 |
|view| |
|
839 |
||
840 |
view := super findObjectAt:aPoint. |
|
841 |
||
842 |
view notNil ifTrue:[ |
|
843 |
"can be a view within a view not visible |
|
844 |
" |
|
845 |
[ (self propertyOfView:view) isNil ] whileTrue:[ |
|
846 |
(view := view superView) == self ifTrue:[^ nil] |
|
847 |
] |
|
848 |
]. |
|
849 |
^ view |
|
850 |
! |
|
851 |
||
852 |
findViewWithId:aViewId |
|
62 | 853 |
"finds view assigned to identifier and returns the view or nil |
60 | 854 |
" |
855 |
|prop| |
|
856 |
||
857 |
prop := self propertyOfIdentifier:aViewId. |
|
858 |
||
859 |
prop notNil ifTrue:[^ prop view] |
|
860 |
ifFalse:[^ nil] |
|
78 | 861 |
! |
862 |
||
863 |
propertyOfIdentifier:anId |
|
864 |
"returns property assigned to unique identifier |
|
865 |
" |
|
866 |
anId notNil ifTrue:[ |
|
111 | 867 |
^ listHolder detectProperty:[:p| p identifier == anId ] |
78 | 868 |
]. |
869 |
^ nil |
|
870 |
! |
|
871 |
||
872 |
propertyOfName:aString |
|
873 |
"returns property assigned to name |
|
874 |
" |
|
111 | 875 |
|name| |
876 |
||
877 |
aString isNil ifFalse:[ |
|
878 |
name := aString string withoutSeparators. |
|
879 |
||
880 |
name = 'self' ifFalse:[ |
|
881 |
^ listHolder detectProperty:[:p| p name = name ]. |
|
882 |
] |
|
78 | 883 |
]. |
884 |
^ nil |
|
885 |
! |
|
886 |
||
887 |
propertyOfView:aView |
|
888 |
"returns property assigned to view |
|
889 |
" |
|
890 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
111 | 891 |
^ listHolder detectProperty:[:p| p view == aView ] |
78 | 892 |
]. |
893 |
^ nil |
|
894 |
! |
|
895 |
||
111 | 896 |
uniqueNameFor:aSpecOrString |
78 | 897 |
"generate and return an unique name for a class |
898 |
" |
|
899 |
|next name size| |
|
900 |
||
111 | 901 |
aSpecOrString isString ifFalse:[name := aSpecOrString className asString] |
902 |
ifTrue:[name := aSpecOrString]. |
|
78 | 903 |
|
111 | 904 |
(name endsWith:'Spec') ifTrue:[ |
905 |
name := name copyFrom:1 to:(name size - 4). |
|
906 |
] ifFalse:[ |
|
907 |
name := name copy |
|
908 |
]. |
|
78 | 909 |
name at:1 put:(name at:1) asLowercase. |
111 | 910 |
size := name size + 1. |
911 |
next := 0. |
|
78 | 912 |
|
111 | 913 |
listHolder propertiesDo:[:p| |
914 |
|n| |
|
78 | 915 |
n := p name. |
916 |
||
917 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
918 |
next := next max:(p extractNumberStartingAt:size) |
|
919 |
] |
|
920 |
]. |
|
921 |
next := next + 1. |
|
922 |
name := name, next printString. |
|
923 |
^ name |
|
924 |
||
925 |
||
926 |
||
927 |
! |
|
928 |
||
929 |
uniqueNameOf:aView |
|
111 | 930 |
|prop| |
78 | 931 |
|
111 | 932 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
933 |
prop name isNil ifTrue:[ |
|
934 |
prop name:(self uniqueNameFor:(prop spec)). |
|
935 |
]. |
|
936 |
^ prop name |
|
78 | 937 |
]. |
111 | 938 |
^ 'self' |
78 | 939 |
|
60 | 940 |
! ! |
941 |
||
78 | 942 |
!UIPainterView methodsFor:'specification'! |
943 |
||
944 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
945 |
"build view and subviews from aSpecification into a frame. The top view |
|
946 |
is returned. The contained components of a spec are set to nil |
|
947 |
" |
|
948 |
aBuilder applicationClass:(Smalltalk classNamed:className). |
|
949 |
||
111 | 950 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 951 |
p := ViewProperty new. |
952 |
s := aSpec copy. |
|
953 |
p spec:s. |
|
954 |
p view:aView. |
|
955 |
||
956 |
s class supportsSubComponents ifTrue:[ |
|
957 |
s component:nil |
|
958 |
]. |
|
959 |
||
111 | 960 |
n := s name. |
961 |
||
962 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
963 |
s name:(self uniqueNameFor:s) |
|
78 | 964 |
]. |
111 | 965 |
listHolder add:p |
78 | 966 |
]. |
967 |
||
968 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 969 |
|
78 | 970 |
! |
971 |
||
972 |
fullSpecFor:anObject |
|
973 |
"generate a full spec for an object |
|
62 | 974 |
" |
78 | 975 |
|mySpec subSpecs| |
976 |
||
977 |
mySpec := self specFor:anObject. |
|
978 |
||
979 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
980 |
(anObject subViews notNil) ifTrue:[ |
|
981 |
anObject subViews do:[:aSubView||spec| |
|
982 |
spec := self fullSpecFor:aSubView. |
|
983 |
spec notNil ifTrue:[ |
|
984 |
subSpecs isNil ifTrue:[ |
|
985 |
subSpecs := OrderedCollection new |
|
986 |
]. |
|
987 |
subSpecs add:spec. |
|
988 |
]. |
|
989 |
]. |
|
990 |
subSpecs notNil ifTrue:[ |
|
991 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
992 |
] |
|
993 |
] |
|
994 |
]. |
|
995 |
^ mySpec |
|
996 |
||
60 | 997 |
|
998 |
||
999 |
||
1000 |
||
1001 |
||
1002 |
! |
|
1003 |
||
78 | 1004 |
specFor:anObject |
1005 |
"returns spec assigned to an object |
|
62 | 1006 |
" |
78 | 1007 |
|prop spec| |
60 | 1008 |
|
78 | 1009 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
1010 |
spec := prop spec copy. |
|
1011 |
spec layoutFromView:anObject |
|
60 | 1012 |
]. |
78 | 1013 |
^ spec |
1014 |
||
1015 |
||
1016 |
||
60 | 1017 |
! |
1018 |
||
146 | 1019 |
specForSelection |
1020 |
"returns spec assigned to current single selection or nil |
|
1021 |
" |
|
1022 |
^ self specFor:(self singleSelection) |
|
1023 |
||
1024 |
||
1025 |
! |
|
1026 |
||
78 | 1027 |
updateFromSpec:aSpec |
1028 |
"update current selected view from specification |
|
62 | 1029 |
" |
78 | 1030 |
|props name builder v| |
1031 |
||
1032 |
self singleSelection notNil ifTrue:[ |
|
1033 |
self withSelectionHiddenDo:[ |
|
1034 |
self transaction:#specification selectionDo:[:aView| |
|
1035 |
builder := UIBuilder new. |
|
1036 |
props := self propertyOfView:aView. |
|
82 | 1037 |
name := (aSpec name) withoutSeparators. |
78 | 1038 |
|
82 | 1039 |
name = props name ifFalse:[ |
1040 |
(self propertyOfName:name) notNil ifTrue:[ |
|
1041 |
name := props name |
|
78 | 1042 |
] |
1043 |
]. |
|
82 | 1044 |
aSpec name:name. |
134 | 1045 |
self createUndoSpecModify:props. |
78 | 1046 |
|
1047 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
1048 |
v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
1049 |
v realize. |
|
1050 |
aView destroy. |
|
1051 |
device sync. device flush. |
|
1052 |
aView becomeSameAs:v. |
|
1053 |
inputView raise. |
|
1054 |
] ifFalse:[ |
|
1055 |
aSpec setAttributesIn:aView with:builder. |
|
1056 |
self elementChangedSize:aView. |
|
1057 |
]. |
|
1058 |
props spec:(aSpec copy). |
|
111 | 1059 |
listHolder propertyChanged:props. |
78 | 1060 |
] |
111 | 1061 |
] |
82 | 1062 |
] |
60 | 1063 |
! ! |
1064 |
||
1065 |
!UIPainterView methodsFor:'transaction'! |
|
1066 |
||
1067 |
transaction:aType objects:something do:aOneArgBlock |
|
1068 |
"opens a transaction and evaluates a block within the transaction; the |
|
1069 |
argument to the block is a view from derived from something |
|
1070 |
" |
|
134 | 1071 |
self withinTransaction:aType objects:something do:[ |
1072 |
self forEach:something do:aOneArgBlock |
|
60 | 1073 |
] |
1074 |
! |
|
1075 |
||
134 | 1076 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
1077 |
"evaluate a block with no arguments within a transaction |
|
60 | 1078 |
" |
134 | 1079 |
|text size prop| |
1080 |
||
1081 |
objects isNil ifTrue:[ ^ self ]. |
|
1082 |
||
1083 |
size := objects size. |
|
60 | 1084 |
|
134 | 1085 |
objects isCollection ifTrue:[ |
1086 |
size == 0 ifTrue:[ ^ self ]. |
|
1087 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
1088 |
] ifFalse:[ |
|
1089 |
prop := self propertyOfView:objects |
|
1090 |
]. |
|
60 | 1091 |
|
134 | 1092 |
prop notNil ifTrue:[ |
1093 |
text := prop name |
|
1094 |
] ifFalse:[ |
|
1095 |
text := size printString, ' elements' |
|
60 | 1096 |
]. |
134 | 1097 |
|
1098 |
undoHistory withinTransaction:aType text:text do:[ |
|
1099 |
aNoneArgBlock value |
|
1100 |
] |
|
60 | 1101 |
! ! |
1102 |
||
1103 |
!UIPainterView methodsFor:'undo actions'! |
|
1104 |
||
134 | 1105 |
createUndoLayout:aView |
1106 |
"create undo action before changing a views layout |
|
60 | 1107 |
" |
134 | 1108 |
|lyt args prop| |
60 | 1109 |
|
1110 |
undoHistory isTransactionOpen ifTrue:[ |
|
1111 |
prop := self propertyOfView:aView. |
|
134 | 1112 |
|
60 | 1113 |
prop notNil ifTrue:[ |
134 | 1114 |
args := Array new:3. |
1115 |
args at:1 put:(prop identifier). |
|
1116 |
||
1117 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
1118 |
args at:2 put:#geometryLayout: |
|
1119 |
] ifFalse:[ |
|
146 | 1120 |
lyt := aView extent. |
134 | 1121 |
args at:2 put:#extent: |
1122 |
]. |
|
1123 |
args at:3 put:(lyt copy). |
|
1124 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 1125 |
] |
1126 |
] |
|
1127 |
! |
|
1128 |
||
134 | 1129 |
createUndoRemove:aView |
1130 |
"create undo method before deleting views |
|
60 | 1131 |
" |
134 | 1132 |
|frame prop pId spec| |
1133 |
||
1134 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
1135 |
spec := self fullSpecFor:aView. |
|
1136 |
frame := aView superView. |
|
60 | 1137 |
|
134 | 1138 |
(self canPasteInto:frame) ifTrue:[ |
1139 |
(frame := self propertyOfView:frame) notNil ifTrue:[ |
|
1140 |
pId := frame identifier |
|
1141 |
] |
|
1142 |
]. |
|
1143 |
undoHistory addUndoSelector:#undoRemove: |
|
1144 |
withArgs:(Array with:spec with:(prop identifier) with:pId) |
|
1145 |
] |
|
1146 |
! |
|
60 | 1147 |
|
134 | 1148 |
createUndoSpecModify:aProp |
1149 |
"undo method when changing the specification for an object |
|
1150 |
" |
|
1151 |
aProp notNil ifTrue:[ |
|
1152 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1153 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1154 |
] |
|
1155 |
! |
|
60 | 1156 |
|
134 | 1157 |
undoCreate:something |
1158 |
"undo method for creating or pasting an object |
|
1159 |
" |
|
1160 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1161 |
! |
|
60 | 1162 |
|
134 | 1163 |
undoLayout:args |
1164 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1165 |
" |
|
1166 |
|view| |
|
1167 |
||
1168 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1169 |
view perform:(args at:2) with:(args at:3). |
1170 |
self changed:#layout. |
|
60 | 1171 |
] |
1172 |
! |
|
1173 |
||
134 | 1174 |
undoRemove:args |
1175 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1176 |
" |
|
1177 |
|frame prop view| |
|
1178 |
||
1179 |
(args at:3) notNil ifTrue:[ |
|
1180 |
frame := self findViewWithId:(args at:3). |
|
1181 |
]. |
|
1182 |
frame isNil ifTrue:[ |
|
1183 |
frame := self |
|
1184 |
]. |
|
1185 |
view := self addSpec:(args at:1) builder:(UIBuilder new) in:frame. |
|
1186 |
view realize. |
|
1187 |
inputView raise. |
|
1188 |
||
1189 |
prop := self propertyOfView:view. |
|
1190 |
prop identifier:(args at:2). |
|
1191 |
||
1192 |
! |
|
1193 |
||
1194 |
undoSpecModify:args |
|
1195 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1196 |
" |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1197 |
|builder view spec v props| |
60 | 1198 |
|
134 | 1199 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1200 |
|
134 | 1201 |
props notNil ifTrue:[ |
1202 |
view := props view. |
|
1203 |
spec := args at:1. |
|
1204 |
builder := UIBuilder new. |
|
1205 |
props spec:spec. |
|
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1206 |
|
134 | 1207 |
spec needsRebuildForAttributes ifTrue:[ |
1208 |
v := spec buildViewWithLayoutFor:builder in:view superView. |
|
1209 |
v realize. |
|
1210 |
view destroy. |
|
1211 |
view become:v |
|
1212 |
] ifFalse:[ |
|
1213 |
spec setAttributesIn:view with:builder. |
|
1214 |
self elementChangedSize:view. |
|
1215 |
]. |
|
1216 |
listHolder propertyChanged:props. |
|
1217 |
] |
|
60 | 1218 |
|
1219 |
! ! |
|
1220 |
||
194 | 1221 |
!UIPainterView methodsFor:'user actions - arrange'! |
1222 |
||
1223 |
lowerSelection |
|
1224 |
"lower all objects in the selection |
|
1225 |
" |
|
1226 |
self hasSelection ifTrue:[ |
|
1227 |
self selectionDo:[:aView| |
|
1228 |
aView lower. |
|
1229 |
aView superView changeSequenceOrderFor:aView to:1. |
|
1230 |
]. |
|
1231 |
listHolder recompute. |
|
1232 |
] |
|
1233 |
||
1234 |
||
1235 |
! |
|
1236 |
||
1237 |
raiseSelection |
|
1238 |
"raise all objects in the selection |
|
1239 |
" |
|
1240 |
self hasSelection ifTrue:[ |
|
1241 |
self selectionDo:[:aView||sv| |
|
1242 |
aView raise. |
|
1243 |
sv := aView superView. |
|
1244 |
sv changeSequenceOrderFor:aView to:(sv subViews size) |
|
1245 |
]. |
|
1246 |
inputView raise. |
|
1247 |
listHolder recompute. |
|
1248 |
]. |
|
1249 |
||
1250 |
||
1251 |
! ! |
|
1252 |
||
111 | 1253 |
!UIPainterView::ListHolder class methodsFor:'instance creation'! |
1254 |
||
1255 |
for:aPainter |
|
1256 |
^ self new for:aPainter |
|
1257 |
! ! |
|
1258 |
||
1259 |
!UIPainterView::ListHolder methodsFor:'accessing'! |
|
1260 |
||
1261 |
painter |
|
1262 |
"returns painter |
|
1263 |
" |
|
1264 |
^ painter |
|
1265 |
! |
|
1266 |
||
1267 |
propertyAt:anIndex |
|
1268 |
"returns property at an index |
|
1269 |
" |
|
1270 |
^ propertyList at:anIndex |
|
1271 |
! ! |
|
1272 |
||
1273 |
!UIPainterView::ListHolder methodsFor:'adding & removing'! |
|
1274 |
||
1275 |
add:aProperty |
|
1276 |
"add property and update list |
|
1277 |
" |
|
1278 |
|idx list name last| |
|
1279 |
||
1280 |
list := self list. |
|
1281 |
idx := self findParentProperty:aProperty. |
|
1282 |
name := aProperty name. |
|
1283 |
||
1284 |
idx == 0 ifTrue:[ |
|
1285 |
last := list size |
|
1286 |
] ifFalse:[ |
|
1287 |
last := self lastInGroupStartingAt:idx. |
|
1288 |
name := (String new:(4+((list at:idx) leftIndent))), name. |
|
1289 |
]. |
|
1290 |
propertyList add:aProperty afterIndex:last. |
|
1291 |
list add:name afterIndex:last. |
|
1292 |
self changed:#size |
|
1293 |
||
1294 |
||
1295 |
! |
|
1296 |
||
1297 |
remove:aView |
|
1298 |
"remove all view relevant resources |
|
1299 |
" |
|
1300 |
|start| |
|
1301 |
||
1302 |
aView notNil ifTrue:[ |
|
1303 |
start := self findProperty:[:p| p view == aView ]. |
|
1304 |
||
1305 |
start ~~ 0 ifTrue:[ |
|
1306 |
self basicRemove:start. |
|
1307 |
self changed:#size. |
|
1308 |
] |
|
1309 |
] |
|
1310 |
! |
|
1311 |
||
1312 |
removeAll |
|
1313 |
masterElement := nil. |
|
1314 |
self selection:#(). |
|
1315 |
||
1316 |
[propertyList notEmpty] whileTrue:[ |
|
1317 |
self basicRemove:1 |
|
1318 |
]. |
|
1319 |
self changed:#size. |
|
1320 |
||
1321 |
! ! |
|
1322 |
||
1323 |
!UIPainterView::ListHolder methodsFor:'change & update'! |
|
1324 |
||
1325 |
changed:aParameter |
|
1326 |
"notify all dependents that the receiver has changed somehow. |
|
1327 |
Each dependent gets a '#update:'-message with aParameter |
|
1328 |
as argument. In case of disabled no notifications are raised |
|
1329 |
" |
|
1330 |
disabledChanged ifFalse:[ |
|
1331 |
super changed:aParameter |
|
1332 |
] |
|
1333 |
! |
|
1334 |
||
1335 |
disableNotificationsWhileEvaluating:aBlock |
|
1336 |
"perform block without notification; after evaluation of block, |
|
1337 |
a #size changed notification is raised |
|
1338 |
" |
|
1339 |
|oldState| |
|
1340 |
||
1341 |
oldState := disabledChanged. |
|
1342 |
disabledChanged := true. |
|
1343 |
aBlock value. |
|
1344 |
disabledChanged := oldState. |
|
1345 |
self changed:#size. |
|
1346 |
! |
|
1347 |
||
1348 |
propertyChanged:aProperty |
|
1349 |
"property list changed; update list names |
|
1350 |
" |
|
1351 |
|list idx oldName newName wspName view indent mid| |
|
1352 |
||
1353 |
view := aProperty view. |
|
1354 |
idx := self findProperty:[:p| p view == view ]. |
|
1355 |
||
1356 |
idx == 0 ifTrue:[ |
|
1357 |
^ self error |
|
1358 |
]. |
|
1359 |
||
1360 |
list := self list. |
|
1361 |
oldName := list at:idx. |
|
1362 |
wspName := oldName string withoutSeparators. |
|
1363 |
newName := aProperty name. |
|
1364 |
||
1365 |
wspName = newName ifFalse:[ |
|
1366 |
mid := self masterElement. |
|
1367 |
list at:idx put:((String new:(oldName leftIndent)), newName). |
|
1368 |
||
1369 |
idx == mid ifTrue:[ |
|
1370 |
masterElement := nil. |
|
1371 |
self masterElement:idx |
|
1372 |
]. |
|
1373 |
]. |
|
1374 |
self changed:#property |
|
1375 |
||
1376 |
! ! |
|
1377 |
||
1378 |
!UIPainterView::ListHolder methodsFor:'enumerating'! |
|
1379 |
||
1380 |
propertiesDo:aBlock |
|
1381 |
"evaluate a block for each property |
|
1382 |
" |
|
1383 |
propertyList do:aBlock |
|
1384 |
! ! |
|
1385 |
||
1386 |
!UIPainterView::ListHolder methodsFor:'initialization'! |
|
1387 |
||
1388 |
for:aPainter |
|
1389 |
"initialize for a painter |
|
1390 |
" |
|
119 | 1391 |
painter := aPainter. |
121 | 1392 |
disabledChanged := false. |
111 | 1393 |
self list:(OrderedCollection new). |
1394 |
propertyList := OrderedCollection new. |
|
1395 |
self selection:#(). |
|
1396 |
self addDependent:painter. |
|
1397 |
||
1398 |
! ! |
|
1399 |
||
1400 |
!UIPainterView::ListHolder methodsFor:'private'! |
|
1401 |
||
1402 |
basicRemove:start |
|
1403 |
"remove all resources assigned to a group starting at start; |
|
1404 |
no notifications are raised |
|
1405 |
" |
|
1406 |
|end view superView| |
|
1407 |
||
1408 |
end := self lastInGroupStartingAt:start. |
|
1409 |
view := (propertyList at:start) view. |
|
1410 |
||
1411 |
view notNil ifTrue:[ |
|
1412 |
superView := view superView. |
|
1413 |
view destroy. |
|
1414 |
superView sizeChanged:nil. |
|
1415 |
]. |
|
1416 |
||
1417 |
propertyList removeFromIndex:start toIndex:end. |
|
1418 |
self list removeFromIndex:start toIndex:end. |
|
1419 |
! |
|
1420 |
||
1421 |
masterElement |
|
1422 |
"returns index of master |
|
1423 |
" |
|
1424 |
^ self indexOfName:masterElement. |
|
1425 |
! |
|
1426 |
||
1427 |
masterElement:newIndex |
|
1428 |
"change master of selection |
|
1429 |
" |
|
1430 |
|name list oldIdx| |
|
1431 |
||
1432 |
(oldIdx := self masterElement) ~~ newIndex ifTrue:[ |
|
1433 |
list := self list. |
|
1434 |
||
1435 |
oldIdx ~~ 0 ifTrue:[ |
|
1436 |
list at:oldIdx put:masterElement |
|
1437 |
]. |
|
1438 |
newIndex ~~ 0 ifTrue:[ |
|
1439 |
masterElement := list at:newIndex. |
|
1440 |
name := Text string:masterElement. |
|
1441 |
name emphasizeFrom:(1+(name leftIndent)) with:#(#bold #underline). |
|
1442 |
list at:newIndex put:name. |
|
1443 |
] ifFalse:[ |
|
1444 |
masterElement := nil |
|
1445 |
]. |
|
1446 |
self changed:#list. |
|
1447 |
] |
|
1448 |
! ! |
|
1449 |
||
194 | 1450 |
!UIPainterView::ListHolder methodsFor:'recomputing'! |
1451 |
||
1452 |
recompute |
|
1453 |
|list prop size osel| |
|
1454 |
||
1455 |
osel := self selection copy. |
|
1456 |
size := self list size. |
|
1457 |
list := OrderedCollection new:size. |
|
1458 |
prop := OrderedCollection new:size. |
|
1459 |
||
1460 |
painter allSubViewsDo:[:v| |
|
1461 |
size := self indexOfView:v. |
|
1462 |
||
1463 |
size ~~ 0 ifTrue:[ |
|
1464 |
list add:(self list at:size). |
|
1465 |
prop add:(propertyList at:size) |
|
1466 |
] |
|
1467 |
]. |
|
1468 |
propertyList := prop. |
|
1469 |
self list:list. |
|
1470 |
self selection:osel. |
|
1471 |
! ! |
|
1472 |
||
111 | 1473 |
!UIPainterView::ListHolder methodsFor:'searching'! |
1474 |
||
1475 |
detectProperty:aBlock |
|
1476 |
"find the property, for which evaluation of the argument, aBlock |
|
1477 |
returns true; return the property or nil if none detected |
|
1478 |
" |
|
1479 |
|idx| |
|
1480 |
||
1481 |
idx := self findProperty:aBlock. |
|
1482 |
idx ~~ 0 ifTrue:[ ^ propertyList at:idx ]. |
|
1483 |
^ nil |
|
1484 |
! |
|
1485 |
||
1486 |
findParentProperty:aChildProp |
|
1487 |
"returns index of parent or 0 |
|
1488 |
" |
|
1489 |
|view index| |
|
1490 |
||
1491 |
view := aChildProp view. |
|
1492 |
||
1493 |
view notNil ifTrue:[ |
|
1494 |
[ (view := view superView) notNil ] whileTrue:[ |
|
1495 |
index := self findProperty:[:aProp| aProp view == view ]. |
|
1496 |
index ~~ 0 ifTrue:[ |
|
1497 |
^ index |
|
1498 |
] |
|
1499 |
] |
|
1500 |
]. |
|
1501 |
^ 0 |
|
1502 |
||
1503 |
||
1504 |
! |
|
1505 |
||
1506 |
findProperty:aBlock |
|
1507 |
"find the first property, for which evaluation of the argument, aBlock |
|
1508 |
returns true; return its index or 0 if none detected |
|
1509 |
" |
|
1510 |
^ propertyList findFirst:aBlock |
|
1511 |
! |
|
1512 |
||
1513 |
indexOfName:aString |
|
1514 |
"returns index assigned to a string or 0 |
|
1515 |
" |
|
1516 |
|name list size| |
|
1517 |
||
1518 |
aString notNil ifTrue:[ |
|
1519 |
name := aString string withoutSeparators. |
|
1520 |
size := name size. |
|
1521 |
list := self list. |
|
1522 |
||
1523 |
list keysAndValuesDo:[:anIndex :aName| |
|
1524 |
|el| |
|
1525 |
||
1526 |
el := aName string. |
|
1527 |
(el endsWith:name) ifTrue:[ |
|
1528 |
(el size - el leftIndent) == name size ifTrue:[ |
|
1529 |
^ anIndex |
|
1530 |
] |
|
1531 |
] |
|
1532 |
] |
|
1533 |
]. |
|
1534 |
^ 0 |
|
1535 |
||
1536 |
! |
|
1537 |
||
194 | 1538 |
indexOfView:aView |
1539 |
"returns index assigned to a view or 0 |
|
1540 |
" |
|
1541 |
aView notNil ifTrue:[ |
|
1542 |
^ propertyList findFirst:[:p| p view == aView ] |
|
1543 |
]. |
|
1544 |
^ 0 |
|
1545 |
||
1546 |
! |
|
1547 |
||
111 | 1548 |
lastInGroupStartingAt:start |
1549 |
"returns last index of a group |
|
1550 |
" |
|
1551 |
|end list idt| |
|
1552 |
||
1553 |
list := self list. |
|
1554 |
||
1555 |
start < list size ifTrue:[ |
|
1556 |
idt := (list at:start) leftIndent. |
|
1557 |
end := list findFirst:[:el|(el leftIndent) <= idt] startingAt:(start+1). |
|
1558 |
end ~~ 0 ifTrue:[ |
|
1559 |
^ end - 1 |
|
1560 |
] |
|
1561 |
]. |
|
1562 |
^ list size |
|
1563 |
! ! |
|
1564 |
||
1565 |
!UIPainterView::ListHolder methodsFor:'selection'! |
|
1566 |
||
1567 |
selectGroup |
|
1568 |
"select all elements assigned to master |
|
1569 |
" |
|
1570 |
|start end sel size| |
|
1571 |
||
119 | 1572 |
painter enabled ifTrue:[ |
111 | 1573 |
(start := self masterElement) ~~ 0 ifTrue:[ |
1574 |
end := self lastInGroupStartingAt:start. |
|
1575 |
size := end - start + 1. |
|
1576 |
sel := Array new:size. |
|
1577 |
||
1578 |
1 to:size do:[:i| |
|
1579 |
sel at:i put:start. |
|
1580 |
start := start + 1 |
|
1581 |
]. |
|
1582 |
self selectionIndex:sel. |
|
1583 |
] ifFalse:[ |
|
1584 |
(self selectionIndex) size == 0 ifFalse:[ |
|
1585 |
self selectionIndex:#() |
|
1586 |
]. |
|
1587 |
] |
|
1588 |
] |
|
1589 |
! |
|
1590 |
||
1591 |
selectedProperty |
|
1592 |
"returns current selected instance; in case of multiple selection |
|
1593 |
or no selection nil is returned |
|
1594 |
" |
|
1595 |
|selection| |
|
1596 |
selection := self selectionIndex. |
|
1597 |
||
1598 |
selection size == 1 ifTrue:[ |
|
137 | 1599 |
propertyList size ~~ 0 ifTrue:[ |
1600 |
^ propertyList at:(selection first) |
|
1601 |
] |
|
111 | 1602 |
]. |
1603 |
^ nil |
|
1604 |
! |
|
1605 |
||
1606 |
selectionIndex:aList |
|
1607 |
|masterIndex aSel| |
|
1608 |
||
119 | 1609 |
painter enabled ifTrue:[aSel := aList] |
1610 |
ifFalse:[aSel := nil]. |
|
111 | 1611 |
|
1612 |
aSel size ~~ 0 ifTrue:[masterIndex := aSel at:1] |
|
1613 |
ifFalse:[masterIndex := 0]. |
|
1614 |
||
1615 |
self masterElement:masterIndex. |
|
1616 |
super selectionIndex:aSel |
|
1617 |
! ! |
|
1618 |
||
180 | 1619 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
1620 |
||
1621 |
new |
|
1622 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1623 |
ifFalse:[Identifier := 1]. |
|
1624 |
||
1625 |
^ self basicNew initialize |
|
1626 |
! ! |
|
1627 |
||
1628 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1629 |
||
1630 |
identifier |
|
1631 |
"return the unique identifier assigned to property |
|
1632 |
" |
|
1633 |
^ identifier |
|
1634 |
! |
|
1635 |
||
1636 |
identifier:anIdentifier |
|
1637 |
"set the unique identifier assigned to property; called after an restore of |
|
1638 |
a deleted instance |
|
1639 |
" |
|
1640 |
identifier := anIdentifier |
|
1641 |
! |
|
1642 |
||
1643 |
spec |
|
1644 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1645 |
||
1646 |
^ spec! |
|
1647 |
||
1648 |
spec:something |
|
1649 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1650 |
||
1651 |
spec := something.! |
|
1652 |
||
1653 |
view |
|
1654 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1655 |
||
1656 |
^ view! |
|
1657 |
||
1658 |
view:something |
|
1659 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1660 |
||
1661 |
view := something.! ! |
|
1662 |
||
1663 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1664 |
||
1665 |
initialize |
|
1666 |
super initialize. |
|
1667 |
identifier := Identifier |
|
1668 |
! ! |
|
1669 |
||
1670 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1671 |
||
1672 |
extractNumberStartingAt:anIndex |
|
1673 |
"return the number from the name starting at anIndex or 0. |
|
1674 |
" |
|
1675 |
|val| |
|
1676 |
||
1677 |
val := 0. |
|
1678 |
||
1679 |
self name from:anIndex do:[:c| |
|
1680 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1681 |
ifFalse:[^ 0] |
|
1682 |
]. |
|
1683 |
^ val |
|
1684 |
||
1685 |
! ! |
|
1686 |
||
1687 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1688 |
||
1689 |
doesNotUnderstand:aMessage |
|
1690 |
spec notNil ifTrue:[ |
|
1691 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1692 |
]. |
|
1693 |
^ nil |
|
1694 |
! |
|
1695 |
||
1696 |
layout |
|
1697 |
spec layout |
|
1698 |
! |
|
1699 |
||
1700 |
layout:aLayout |
|
1701 |
spec layout:aLayout |
|
1702 |
! |
|
1703 |
||
1704 |
name |
|
1705 |
^ spec name |
|
1706 |
! |
|
1707 |
||
1708 |
name:aName |
|
1709 |
spec name:aName |
|
1710 |
! ! |
|
1711 |
||
60 | 1712 |
!UIPainterView class methodsFor:'documentation'! |
1713 |
||
1714 |
version |
|
1715 |
^ '$Header$' |
|
1716 |
! ! |