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