author | Claus Gittinger <cg@exept.de> |
Tue, 17 Jun 1997 14:43:55 +0200 | |
changeset 162 | d3f0d5dd53b1 |
parent 158 | 6e7f892308ae |
child 165 | f7df2a53d042 |
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 |
||
162 | 20 |
MultiSelectionInList subclass:#ListHolder |
21 |
instanceVariableNames:'painter propertyList masterElement disabledChanged' |
|
22 |
classVariableNames:'' |
|
119 | 23 |
poolDictionaries:'' |
24 |
privateIn:UIPainterView |
|
25 |
! |
|
26 |
||
162 | 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 |
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 |
|
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
565 |
|cls code skip| |
60 | 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:[ |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
585 |
skip := false. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
586 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
587 |
skip := SimpleDialog implements:modelSelector asSymbol |
60 | 588 |
]. |
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
589 |
skip ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
590 |
"/ kludge .. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
591 |
(protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
592 |
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
|
593 |
] ifFalse:[ |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
594 |
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
|
595 |
]. |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
596 |
code := code , thisCode |
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
597 |
]. |
62 | 598 |
]. |
599 |
]. |
|
600 |
||
78 | 601 |
(menuSelector := aProp menu) notNil ifTrue:[ |
62 | 602 |
(cls implements:menuSelector asSymbol) ifFalse:[ |
603 |
"/ kludge .. |
|
604 |
thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). |
|
605 |
code := code , thisCode |
|
60 | 606 |
] |
111 | 607 |
]. |
608 |
||
609 |
aProp spec aspectSelectors do:[:aSel| |
|
610 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
611 |
"/ kludge .. |
|
612 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
613 |
code := code , thisCode |
|
614 |
] |
|
615 |
]. |
|
137 | 616 |
aProp spec actionSelectors do:[:aSel| |
617 |
(cls implements:aSel asSymbol) ifFalse:[ |
|
618 |
"/ kludge .. |
|
619 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
620 |
code := code , thisCode |
|
621 |
] |
|
622 |
]. |
|
111 | 623 |
|
60 | 624 |
]. |
625 |
^ code |
|
626 |
||
158
6e7f892308ae
do not generate accept/cancel and help action methods,
Claus Gittinger <cg@exept.de>
parents:
156
diff
changeset
|
627 |
"Modified: 17.6.1997 / 14:07:36 / cg" |
89 | 628 |
! |
60 | 629 |
|
630 |
generateClassDefinition |
|
631 |
|defCode| |
|
632 |
||
633 |
defCode := superclassName , ' subclass:#' , className , '\'. |
|
634 |
defCode := defCode , ' instanceVariableNames:'''. |
|
635 |
defCode := defCode , self subviewVariableNames , '''\'. |
|
636 |
defCode := defCode , ' classVariableNames:''''\'. |
|
637 |
defCode := defCode , ' poolDictionaries:''''\'. |
|
638 |
defCode := defCode , ' category:''' , categoryName , '''\'. |
|
639 |
defCode := defCode , Character excla asString , '\\'. |
|
640 |
||
641 |
^ defCode withCRs |
|
642 |
||
643 |
||
644 |
||
89 | 645 |
! |
60 | 646 |
|
647 |
generateCode |
|
648 |
"generate code for the windowSpec method" |
|
649 |
||
650 |
|code| |
|
651 |
||
134 | 652 |
self resetModification. |
653 |
||
60 | 654 |
code := ''. |
655 |
||
656 |
"/ (Smalltalk classNamed:className asSymbol) isNil ifTrue:[ |
|
657 |
"/ code := code , self generateClassDefinition. |
|
658 |
"/ ]. |
|
659 |
"/ code := code , self generateInitMethod. |
|
660 |
||
661 |
code := code , self generateWindowSpecMethodSource. |
|
662 |
||
663 |
"/ code := code , self generateAspectMethods. |
|
664 |
||
665 |
^ code withCRs |
|
666 |
||
667 |
"Modified: 5.9.1995 / 20:57:53 / claus" |
|
89 | 668 |
! |
60 | 669 |
|
670 |
generateInitCodeForView:aView |
|
671 |
|code c name p outlets moreCode sym typ val| |
|
672 |
||
673 |
" <name> := <ViewClass> in:<name-of-superview>" |
|
674 |
||
675 |
code := ''. |
|
676 |
||
677 |
p := self propertyOfView:aView. |
|
678 |
name := p at:#variableName. |
|
679 |
c := ' ' , name , ' := ' , |
|
78 | 680 |
(aView class name) , ' in:' , (self uniqueNameOf:(aView superView)) , '.\'. |
60 | 681 |
|
682 |
" <name> origin:(...) extent:(...)" |
|
683 |
||
684 |
c := c , ' ' , name , ' origin:(', aView origin printString , ')' |
|
685 |
, ' extent:(', aView extent printString , ').\'. |
|
686 |
||
687 |
moreCode := p at:#initCode ifAbsent:nil. |
|
688 |
moreCode notNil ifTrue:[ |
|
689 |
c := c , moreCode , '\' withCRs |
|
690 |
]. |
|
691 |
||
692 |
code := code , c withCRs. |
|
693 |
||
694 |
" <name> <symbol>:<value>" |
|
695 |
||
696 |
outlets := p at:#outlets ifAbsent:[nil]. |
|
697 |
outlets notNil ifTrue:[ |
|
698 |
outlets do:[:selectorOutlet | |
|
699 |
sym := selectorOutlet at:#selector. |
|
700 |
typ := selectorOutlet at:#type. |
|
701 |
val := selectorOutlet at:#value. |
|
702 |
c := ' ' , name , ' ' , sym. |
|
703 |
(typ == #number) ifTrue:[ |
|
704 |
c := c , val printString |
|
705 |
]. |
|
706 |
(typ == #string) ifTrue:[ |
|
707 |
c := c , '''' , val , '''' |
|
708 |
]. |
|
709 |
(typ == #text) ifTrue:[ |
|
710 |
c := c , '''' , val asString , '''' |
|
711 |
]. |
|
712 |
(typ == #strings) ifTrue:[ |
|
713 |
c := c , '#( '. |
|
714 |
val asText do:[:aString | |
|
715 |
c := c , '''' , aString , ''' ' |
|
716 |
]. |
|
717 |
c := c , ')' |
|
718 |
]. |
|
719 |
(typ == #block) ifTrue:[ |
|
720 |
c := c , val |
|
721 |
]. |
|
722 |
(typ == #color) ifTrue:[ |
|
723 |
c := c , '(Color name:''' , val , ''')' |
|
724 |
]. |
|
725 |
c := c , '.' , Character cr asString. |
|
726 |
code := code , c |
|
727 |
] |
|
728 |
]. |
|
729 |
||
730 |
self subviewsOf:aView do:[:v | |
|
731 |
code := code , (self generateInitCodeForView:v) |
|
732 |
]. |
|
733 |
^ code. |
|
734 |
||
735 |
"Modified: 5.9.1995 / 20:06:07 / claus" |
|
736 |
! |
|
737 |
||
738 |
generateInitMethod |
|
739 |
|defCode code| |
|
740 |
||
741 |
defCode := Character excla asString , |
|
742 |
className , ' methodsFor:''initialization''' , |
|
743 |
Character excla asString , '\\'. |
|
744 |
||
745 |
defCode := defCode , 'initialize\'. |
|
746 |
defCode := defCode , ' super initialize.\'. |
|
747 |
defCode := defCode , ' self setupSubViews.\'. |
|
748 |
defCode := defCode , ' self setupLocalStuff\'. |
|
749 |
defCode := defCode , Character excla asString , '\\'. |
|
750 |
||
751 |
defCode := defCode , 'setupSubViews\'. |
|
752 |
code := defCode withCRs. |
|
753 |
||
754 |
self subviewsOf:self do:[:v | |
|
755 |
code := code , (self generateInitCodeForView:v) |
|
756 |
]. |
|
757 |
code := code , ' ^ self\' withCRs. |
|
758 |
||
759 |
defCode := Character excla asString , '\\'. |
|
760 |
defCode := defCode , 'setupLocalStuff\'. |
|
761 |
defCode := defCode , ' ^ self\'. |
|
762 |
defCode := defCode , Character excla asString , ' ' , |
|
763 |
Character excla asString , '\\'. |
|
764 |
||
765 |
code := code , defCode withCRs. |
|
766 |
^ code. |
|
767 |
||
768 |
||
769 |
||
770 |
||
771 |
! |
|
772 |
||
78 | 773 |
generateWindowSpecMethodSource |
774 |
|t s spec specArray str code| |
|
60 | 775 |
|
78 | 776 |
specArray := OrderedCollection new. |
60 | 777 |
|
78 | 778 |
self subViews do:[:aView| |
779 |
aView ~~ inputView ifTrue:[ |
|
780 |
specArray add:(self fullSpecFor:aView) |
|
60 | 781 |
] |
782 |
]. |
|
78 | 783 |
spec := FullSpec new. |
784 |
spec fromBuilder:self components:(SpecCollection new collection:specArray). |
|
60 | 785 |
specArray := spec literalArrayEncoding. |
786 |
||
787 |
str := WriteStream on:String new. |
|
86 | 788 |
UISpecification prettyPrintSpecArray:specArray on:str indent:5. |
60 | 789 |
|
790 |
code := Character excla asString |
|
791 |
, className , ' class methodsFor:''interface specs''' |
|
792 |
, Character excla asString , '\\' |
|
793 |
||
794 |
, methodName , '\' |
|
795 |
, ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
796 |
, ' "do not manually edit this - the painter/builder may not be able to\' |
|
797 |
, ' handle the specification if its corrupted."\\' |
|
798 |
, ' "\' |
|
799 |
, ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
800 |
, ' ' , className , ' new openInterface:#' , methodName , '\' |
|
801 |
, ' "\'. |
|
802 |
||
803 |
methodName = 'windowSpec' ifTrue:[ |
|
804 |
code := code , ' "' , className , ' open"\' |
|
805 |
]. |
|
806 |
code := code |
|
807 |
, '\' |
|
808 |
, ' <resource: #canvas>\\' |
|
809 |
, ' ^\' |
|
810 |
, ' ', str contents |
|
811 |
, '\' |
|
812 |
, Character excla asString |
|
813 |
, ' ' |
|
814 |
, Character excla asString |
|
815 |
, '\\'. |
|
816 |
||
817 |
^ code withCRs |
|
818 |
||
819 |
"Modified: 5.9.1995 / 21:01:35 / claus" |
|
89 | 820 |
! |
60 | 821 |
|
822 |
storeContentsOn:aStream |
|
111 | 823 |
listHolder propertiesDo:[:p| p storeOn:aStream] |
60 | 824 |
! |
825 |
||
826 |
subviewsOf:aView do:aBlock |
|
827 |
|subs v| |
|
828 |
||
829 |
(subs := aView subViews) notNil ifTrue:[ |
|
830 |
subs do:[:v| |
|
831 |
(v ~~ inputView and:[v notNil]) ifTrue:[ |
|
111 | 832 |
(listHolder detectProperty:[:p|p view == v]) notNil ifTrue:[ |
60 | 833 |
(v superView == aView) ifTrue:[ |
834 |
aBlock value:v |
|
835 |
] |
|
836 |
] |
|
837 |
] |
|
838 |
] |
|
839 |
] |
|
840 |
||
841 |
! ! |
|
842 |
||
843 |
!UIPainterView methodsFor:'initialization'! |
|
844 |
||
137 | 845 |
destroy |
846 |
"remove dependencies |
|
847 |
" |
|
848 |
listHolder notNil ifTrue:[ |
|
849 |
listHolder removeDependent:self. |
|
850 |
]. |
|
851 |
super destroy. |
|
852 |
! |
|
853 |
||
60 | 854 |
initialize |
62 | 855 |
"setup attributes |
856 |
" |
|
60 | 857 |
super initialize. |
858 |
||
859 |
superclassName := 'ApplicationModel'. |
|
860 |
className := 'NewApplication'. |
|
861 |
methodName := 'windowSpec'. |
|
862 |
categoryName := 'Applications'. |
|
111 | 863 |
listHolder := ListHolder for:self. |
60 | 864 |
HandCursor := Cursor leftHand. |
865 |
||
866 |
! |
|
867 |
||
78 | 868 |
initializeCreatedObject:anObject |
869 |
"set default properties for a created object |
|
870 |
" |
|
871 |
|props spec cls| |
|
60 | 872 |
|
78 | 873 |
cls := anObject class. |
874 |
spec := anObject specClass fromView:anObject. |
|
875 |
props := ViewProperty new. |
|
876 |
props view:anObject. |
|
877 |
props spec:spec. |
|
111 | 878 |
props name:(self uniqueNameFor:spec). |
879 |
listHolder add:props. |
|
60 | 880 |
|
82 | 881 |
((spec respondsTo:#label:) and:[self supportsLabel:anObject]) ifTrue:[ |
78 | 882 |
anObject label:(props name). |
883 |
spec label:(props name) |
|
60 | 884 |
]. |
885 |
||
134 | 886 |
undoHistory withinTransaction:#create text:(props name) do:[ |
887 |
undoHistory addUndoSelector:#undoCreate: withArgs:(props identifier) |
|
60 | 888 |
]. |
889 |
! |
|
890 |
||
891 |
setupFromSpec:specOrSpecArray |
|
78 | 892 |
|spec builder| |
60 | 893 |
|
111 | 894 |
listHolder disableNotificationsWhileEvaluating:[ |
895 |
self removeAll. |
|
896 |
spec := UISpecification from:specOrSpecArray. |
|
897 |
builder := UIBuilder new. |
|
898 |
spec window setupView:self topView for:builder. |
|
899 |
self addSpec:(spec component) builder:builder in:self. |
|
900 |
self realizeAllSubViews. |
|
901 |
inputView raise. |
|
902 |
] |
|
60 | 903 |
! ! |
904 |
||
905 |
!UIPainterView methodsFor:'menus'! |
|
906 |
||
121 | 907 |
showMiddleButtonMenu |
908 |
"show the middle button menu; this returns nil |
|
62 | 909 |
" |
111 | 910 |
|menu canPaste| |
60 | 911 |
|
121 | 912 |
self enabled ifFalse:[ |
913 |
^ nil |
|
914 |
]. |
|
111 | 915 |
menu := MenuPanel fromSpec:(self class menu) receiver:self. |
60 | 916 |
|
917 |
canPaste := self canPaste:(self getSelection). |
|
918 |
||
128 | 919 |
self hasSelection ifTrue:[ |
920 |
canPaste := (canPaste and:[self canPasteInto:(self selection)]) |
|
921 |
] ifFalse:[ |
|
111 | 922 |
menu disableAll |
923 |
]. |
|
128 | 924 |
menu enabledAt:#paste put:canPaste. |
134 | 925 |
menu enabledAt:#undo put:(undoHistory isEmpty not). |
121 | 926 |
menu startUp. |
927 |
^ nil |
|
60 | 928 |
|
62 | 929 |
|
930 |
||
60 | 931 |
! ! |
932 |
||
933 |
!UIPainterView methodsFor:'removing components'! |
|
934 |
||
78 | 935 |
remove:anObject |
936 |
"remove anObject from the contents do redraw |
|
60 | 937 |
" |
134 | 938 |
anObject notNil ifTrue:[ |
939 |
listHolder remove:anObject |
|
940 |
] |
|
60 | 941 |
! |
942 |
||
943 |
removeAll |
|
62 | 944 |
"remove all objects and properties |
945 |
" |
|
111 | 946 |
listHolder disableNotificationsWhileEvaluating:[ |
131 | 947 |
self select:nil. |
134 | 948 |
listHolder removeAll. |
949 |
self removeUndoHistory. |
|
111 | 950 |
] |
60 | 951 |
! ! |
952 |
||
953 |
!UIPainterView methodsFor:'searching'! |
|
954 |
||
89 | 955 |
findContainerViewAt:aPoint |
956 |
"find container view responds to aPoint. |
|
957 |
" |
|
958 |
|view| |
|
959 |
||
960 |
(view := self findObjectAt:aPoint) isNil ifTrue:[ |
|
961 |
^ self |
|
962 |
]. |
|
963 |
||
964 |
[(view specClass supportsSubComponents or:[(view := view superView) == self]) |
|
965 |
] whileFalse:[ |
|
966 |
[(self propertyOfView:view) isNil] whileTrue:[ |
|
967 |
(view := view superView) == self ifTrue:[^ self] |
|
968 |
]. |
|
969 |
]. |
|
970 |
^ view |
|
971 |
! |
|
972 |
||
60 | 973 |
findObjectAt:aPoint |
974 |
"find the origin/corner of the currentWidget |
|
975 |
" |
|
976 |
|view| |
|
977 |
||
978 |
view := super findObjectAt:aPoint. |
|
979 |
||
980 |
view notNil ifTrue:[ |
|
981 |
"can be a view within a view not visible |
|
982 |
" |
|
983 |
[ (self propertyOfView:view) isNil ] whileTrue:[ |
|
984 |
(view := view superView) == self ifTrue:[^ nil] |
|
985 |
] |
|
986 |
]. |
|
987 |
^ view |
|
988 |
! |
|
989 |
||
990 |
findViewWithId:aViewId |
|
62 | 991 |
"finds view assigned to identifier and returns the view or nil |
60 | 992 |
" |
993 |
|prop| |
|
994 |
||
995 |
prop := self propertyOfIdentifier:aViewId. |
|
996 |
||
997 |
prop notNil ifTrue:[^ prop view] |
|
998 |
ifFalse:[^ nil] |
|
78 | 999 |
! |
1000 |
||
1001 |
propertyOfIdentifier:anId |
|
1002 |
"returns property assigned to unique identifier |
|
1003 |
" |
|
1004 |
anId notNil ifTrue:[ |
|
111 | 1005 |
^ listHolder detectProperty:[:p| p identifier == anId ] |
78 | 1006 |
]. |
1007 |
^ nil |
|
1008 |
! |
|
1009 |
||
1010 |
propertyOfName:aString |
|
1011 |
"returns property assigned to name |
|
1012 |
" |
|
111 | 1013 |
|name| |
1014 |
||
1015 |
aString isNil ifFalse:[ |
|
1016 |
name := aString string withoutSeparators. |
|
1017 |
||
1018 |
name = 'self' ifFalse:[ |
|
1019 |
^ listHolder detectProperty:[:p| p name = name ]. |
|
1020 |
] |
|
78 | 1021 |
]. |
1022 |
^ nil |
|
1023 |
! |
|
1024 |
||
1025 |
propertyOfView:aView |
|
1026 |
"returns property assigned to view |
|
1027 |
" |
|
1028 |
(aView isNil or:[aView == self]) ifFalse:[ |
|
111 | 1029 |
^ listHolder detectProperty:[:p| p view == aView ] |
78 | 1030 |
]. |
1031 |
^ nil |
|
1032 |
! |
|
1033 |
||
111 | 1034 |
uniqueNameFor:aSpecOrString |
78 | 1035 |
"generate and return an unique name for a class |
1036 |
" |
|
1037 |
|next name size| |
|
1038 |
||
111 | 1039 |
aSpecOrString isString ifFalse:[name := aSpecOrString className asString] |
1040 |
ifTrue:[name := aSpecOrString]. |
|
78 | 1041 |
|
111 | 1042 |
(name endsWith:'Spec') ifTrue:[ |
1043 |
name := name copyFrom:1 to:(name size - 4). |
|
1044 |
] ifFalse:[ |
|
1045 |
name := name copy |
|
1046 |
]. |
|
78 | 1047 |
name at:1 put:(name at:1) asLowercase. |
111 | 1048 |
size := name size + 1. |
1049 |
next := 0. |
|
78 | 1050 |
|
111 | 1051 |
listHolder propertiesDo:[:p| |
1052 |
|n| |
|
78 | 1053 |
n := p name. |
1054 |
||
1055 |
(n size >= size and:[n startsWith:name]) ifTrue:[ |
|
1056 |
next := next max:(p extractNumberStartingAt:size) |
|
1057 |
] |
|
1058 |
]. |
|
1059 |
next := next + 1. |
|
1060 |
name := name, next printString. |
|
1061 |
^ name |
|
1062 |
||
1063 |
||
1064 |
||
1065 |
! |
|
1066 |
||
1067 |
uniqueNameOf:aView |
|
111 | 1068 |
|prop| |
78 | 1069 |
|
111 | 1070 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
1071 |
prop name isNil ifTrue:[ |
|
1072 |
prop name:(self uniqueNameFor:(prop spec)). |
|
1073 |
]. |
|
1074 |
^ prop name |
|
78 | 1075 |
]. |
111 | 1076 |
^ 'self' |
78 | 1077 |
|
60 | 1078 |
! ! |
1079 |
||
71 | 1080 |
!UIPainterView methodsFor:'selection'! |
1081 |
||
1082 |
addTreeFrom:aView to:aCollection |
|
1083 |
"add aView and contained subcomponents to collection |
|
1084 |
" |
|
78 | 1085 |
(self propertyOfView:aView) notNil ifTrue:[ |
71 | 1086 |
aCollection add:aView. |
1087 |
||
1088 |
(aView subViews notNil) ifTrue:[ |
|
1089 |
aView subViews do:[:subView| |
|
1090 |
self addTreeFrom:subView to:aCollection |
|
1091 |
] |
|
1092 |
]. |
|
1093 |
] |
|
1094 |
||
1095 |
! |
|
1096 |
||
1097 |
selectSubComponents |
|
1098 |
"select all subcomponents for current selection |
|
1099 |
" |
|
1100 |
|startAtView aCollection| |
|
1101 |
||
1102 |
aCollection := OrderedCollection new. |
|
1103 |
startAtView := self singleSelection. |
|
1104 |
||
1105 |
startAtView isNil ifTrue:[ |
|
1106 |
self subViews notNil ifTrue:[ |
|
1107 |
self subViews do:[:subView| |
|
1108 |
subView ~~ inputView ifTrue:[ |
|
1109 |
self addTreeFrom:subView to:aCollection |
|
1110 |
] |
|
1111 |
] |
|
1112 |
] |
|
1113 |
] ifFalse:[ |
|
1114 |
self addTreeFrom:startAtView to:aCollection |
|
1115 |
]. |
|
1116 |
||
1117 |
aCollection size > 1 ifTrue:[ |
|
128 | 1118 |
self updateSelectionFrom:aCollection. |
111 | 1119 |
self selectionChanged |
71 | 1120 |
] |
1121 |
! ! |
|
1122 |
||
78 | 1123 |
!UIPainterView methodsFor:'specification'! |
1124 |
||
1125 |
addSpec:aSpecification builder:aBuilder in:aFrame |
|
1126 |
"build view and subviews from aSpecification into a frame. The top view |
|
1127 |
is returned. The contained components of a spec are set to nil |
|
1128 |
" |
|
1129 |
aBuilder applicationClass:(Smalltalk classNamed:className). |
|
1130 |
||
111 | 1131 |
aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s n| |
78 | 1132 |
p := ViewProperty new. |
1133 |
s := aSpec copy. |
|
1134 |
p spec:s. |
|
1135 |
p view:aView. |
|
1136 |
||
1137 |
s class supportsSubComponents ifTrue:[ |
|
1138 |
s component:nil |
|
1139 |
]. |
|
1140 |
||
111 | 1141 |
n := s name. |
1142 |
||
1143 |
(n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[ |
|
1144 |
s name:(self uniqueNameFor:s) |
|
78 | 1145 |
]. |
111 | 1146 |
listHolder add:p |
78 | 1147 |
]. |
1148 |
||
1149 |
^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
60 | 1150 |
|
78 | 1151 |
! |
1152 |
||
1153 |
fullSpecFor:anObject |
|
1154 |
"generate a full spec for an object |
|
62 | 1155 |
" |
78 | 1156 |
|mySpec subSpecs| |
1157 |
||
1158 |
mySpec := self specFor:anObject. |
|
1159 |
||
1160 |
(mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
|
1161 |
(anObject subViews notNil) ifTrue:[ |
|
1162 |
anObject subViews do:[:aSubView||spec| |
|
1163 |
spec := self fullSpecFor:aSubView. |
|
1164 |
spec notNil ifTrue:[ |
|
1165 |
subSpecs isNil ifTrue:[ |
|
1166 |
subSpecs := OrderedCollection new |
|
1167 |
]. |
|
1168 |
subSpecs add:spec. |
|
1169 |
]. |
|
1170 |
]. |
|
1171 |
subSpecs notNil ifTrue:[ |
|
1172 |
mySpec component:(SpecCollection new collection:subSpecs) |
|
1173 |
] |
|
1174 |
] |
|
1175 |
]. |
|
1176 |
^ mySpec |
|
1177 |
||
60 | 1178 |
|
1179 |
||
1180 |
||
1181 |
||
1182 |
||
1183 |
! |
|
1184 |
||
78 | 1185 |
specFor:anObject |
1186 |
"returns spec assigned to an object |
|
62 | 1187 |
" |
78 | 1188 |
|prop spec| |
60 | 1189 |
|
78 | 1190 |
(prop := self propertyOfView:anObject) notNil ifTrue:[ |
1191 |
spec := prop spec copy. |
|
1192 |
spec layoutFromView:anObject |
|
60 | 1193 |
]. |
78 | 1194 |
^ spec |
1195 |
||
1196 |
||
1197 |
||
60 | 1198 |
! |
1199 |
||
146 | 1200 |
specForSelection |
1201 |
"returns spec assigned to current single selection or nil |
|
1202 |
" |
|
1203 |
^ self specFor:(self singleSelection) |
|
1204 |
||
1205 |
||
1206 |
! |
|
1207 |
||
78 | 1208 |
updateFromSpec:aSpec |
1209 |
"update current selected view from specification |
|
62 | 1210 |
" |
78 | 1211 |
|props name builder v| |
1212 |
||
1213 |
self singleSelection notNil ifTrue:[ |
|
1214 |
self withSelectionHiddenDo:[ |
|
1215 |
self transaction:#specification selectionDo:[:aView| |
|
1216 |
builder := UIBuilder new. |
|
1217 |
props := self propertyOfView:aView. |
|
82 | 1218 |
name := (aSpec name) withoutSeparators. |
78 | 1219 |
|
82 | 1220 |
name = props name ifFalse:[ |
1221 |
(self propertyOfName:name) notNil ifTrue:[ |
|
1222 |
name := props name |
|
78 | 1223 |
] |
1224 |
]. |
|
82 | 1225 |
aSpec name:name. |
134 | 1226 |
self createUndoSpecModify:props. |
78 | 1227 |
|
1228 |
aSpec needsRebuildForAttributes ifTrue:[ |
|
1229 |
v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
1230 |
v realize. |
|
1231 |
aView destroy. |
|
1232 |
device sync. device flush. |
|
1233 |
aView becomeSameAs:v. |
|
1234 |
inputView raise. |
|
1235 |
] ifFalse:[ |
|
1236 |
aSpec setAttributesIn:aView with:builder. |
|
1237 |
self elementChangedSize:aView. |
|
1238 |
]. |
|
1239 |
props spec:(aSpec copy). |
|
111 | 1240 |
listHolder propertyChanged:props. |
78 | 1241 |
] |
111 | 1242 |
] |
82 | 1243 |
] |
60 | 1244 |
! ! |
1245 |
||
1246 |
!UIPainterView methodsFor:'testing'! |
|
1247 |
||
1248 |
isHorizontalResizable:aComponent |
|
62 | 1249 |
"returns true if instance is horizontal resizeable |
1250 |
" |
|
60 | 1251 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
1252 |
^ aComponent orientation == #horizontal |
|
1253 |
]. |
|
1254 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
1255 |
^ aComponent orientation == #horizontal |
|
1256 |
]. |
|
1257 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
1258 |
^ aComponent orientation == #horizontal |
|
1259 |
]. |
|
1260 |
^ true |
|
1261 |
||
1262 |
||
1263 |
! |
|
1264 |
||
1265 |
isVerticalResizable:aComponent |
|
62 | 1266 |
"returns true if instance is vertical resizeable |
1267 |
" |
|
60 | 1268 |
(aComponent isKindOf:EditField) ifTrue:[ |
1269 |
^ false |
|
1270 |
]. |
|
1271 |
(aComponent isKindOf:ComboBoxView) ifTrue:[ |
|
1272 |
^ false |
|
1273 |
]. |
|
1274 |
(aComponent isKindOf:CheckBox) ifTrue:[ |
|
1275 |
^ false |
|
1276 |
]. |
|
1277 |
(aComponent isKindOf:ScrollBar) ifTrue:[ |
|
1278 |
^ aComponent orientation == #vertical |
|
1279 |
]. |
|
1280 |
(aComponent isKindOf:Scroller) ifTrue:[ |
|
1281 |
^ aComponent orientation == #vertical |
|
1282 |
]. |
|
1283 |
(aComponent isKindOf:Slider) ifTrue:[ |
|
1284 |
^ aComponent orientation == #vertical |
|
1285 |
]. |
|
1286 |
^ true |
|
1287 |
||
1288 |
||
82 | 1289 |
! |
1290 |
||
1291 |
supportsLabel:aComponent |
|
1292 |
"returns true if component supports label |
|
1293 |
" |
|
1294 |
(aComponent respondsTo:#label:) ifTrue:[ |
|
1295 |
( (aComponent isKindOf:ArrowButton) |
|
1296 |
or:[aComponent isKindOf:CheckToggle] |
|
1297 |
) ifFalse:[ |
|
1298 |
^ true |
|
1299 |
] |
|
1300 |
]. |
|
1301 |
^ false |
|
60 | 1302 |
! ! |
1303 |
||
1304 |
!UIPainterView methodsFor:'transaction'! |
|
1305 |
||
1306 |
transaction:aType objects:something do:aOneArgBlock |
|
1307 |
"opens a transaction and evaluates a block within the transaction; the |
|
1308 |
argument to the block is a view from derived from something |
|
1309 |
" |
|
134 | 1310 |
self withinTransaction:aType objects:something do:[ |
1311 |
self forEach:something do:aOneArgBlock |
|
60 | 1312 |
] |
1313 |
! |
|
1314 |
||
134 | 1315 |
withinTransaction:aType objects:objects do:aNoneArgBlock |
1316 |
"evaluate a block with no arguments within a transaction |
|
60 | 1317 |
" |
134 | 1318 |
|text size prop| |
1319 |
||
1320 |
objects isNil ifTrue:[ ^ self ]. |
|
1321 |
||
1322 |
size := objects size. |
|
60 | 1323 |
|
134 | 1324 |
objects isCollection ifTrue:[ |
1325 |
size == 0 ifTrue:[ ^ self ]. |
|
1326 |
size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ] |
|
1327 |
] ifFalse:[ |
|
1328 |
prop := self propertyOfView:objects |
|
1329 |
]. |
|
60 | 1330 |
|
134 | 1331 |
prop notNil ifTrue:[ |
1332 |
text := prop name |
|
1333 |
] ifFalse:[ |
|
1334 |
text := size printString, ' elements' |
|
60 | 1335 |
]. |
134 | 1336 |
|
1337 |
undoHistory withinTransaction:aType text:text do:[ |
|
1338 |
aNoneArgBlock value |
|
1339 |
] |
|
60 | 1340 |
! ! |
1341 |
||
1342 |
!UIPainterView methodsFor:'undo actions'! |
|
1343 |
||
134 | 1344 |
createUndoLayout:aView |
1345 |
"create undo action before changing a views layout |
|
60 | 1346 |
" |
134 | 1347 |
|lyt args prop| |
60 | 1348 |
|
1349 |
undoHistory isTransactionOpen ifTrue:[ |
|
1350 |
prop := self propertyOfView:aView. |
|
134 | 1351 |
|
60 | 1352 |
prop notNil ifTrue:[ |
134 | 1353 |
args := Array new:3. |
1354 |
args at:1 put:(prop identifier). |
|
1355 |
||
1356 |
(lyt := aView geometryLayout) notNil ifTrue:[ |
|
1357 |
args at:2 put:#geometryLayout: |
|
1358 |
] ifFalse:[ |
|
146 | 1359 |
lyt := aView extent. |
134 | 1360 |
args at:2 put:#extent: |
1361 |
]. |
|
1362 |
args at:3 put:(lyt copy). |
|
1363 |
undoHistory addUndoSelector:#undoLayout: withArgs:args. |
|
60 | 1364 |
] |
1365 |
] |
|
1366 |
! |
|
1367 |
||
134 | 1368 |
createUndoRemove:aView |
1369 |
"create undo method before deleting views |
|
60 | 1370 |
" |
134 | 1371 |
|frame prop pId spec| |
1372 |
||
1373 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
1374 |
spec := self fullSpecFor:aView. |
|
1375 |
frame := aView superView. |
|
60 | 1376 |
|
134 | 1377 |
(self canPasteInto:frame) ifTrue:[ |
1378 |
(frame := self propertyOfView:frame) notNil ifTrue:[ |
|
1379 |
pId := frame identifier |
|
1380 |
] |
|
1381 |
]. |
|
1382 |
undoHistory addUndoSelector:#undoRemove: |
|
1383 |
withArgs:(Array with:spec with:(prop identifier) with:pId) |
|
1384 |
] |
|
1385 |
! |
|
60 | 1386 |
|
134 | 1387 |
createUndoSpecModify:aProp |
1388 |
"undo method when changing the specification for an object |
|
1389 |
" |
|
1390 |
aProp notNil ifTrue:[ |
|
1391 |
undoHistory addUndoSelector:#undoSpecModify: |
|
1392 |
withArgs:(Array with:(aProp spec) with:(aProp identifier)) |
|
1393 |
] |
|
1394 |
! |
|
60 | 1395 |
|
134 | 1396 |
undoCreate:something |
1397 |
"undo method for creating or pasting an object |
|
1398 |
" |
|
1399 |
self forEach:something do:[:anId|self remove:(self findViewWithId:anId)]. |
|
1400 |
! |
|
60 | 1401 |
|
134 | 1402 |
undoLayout:args |
1403 |
"undo method to set the old layout; see 'createUndoLayout:' |
|
1404 |
" |
|
1405 |
|view| |
|
1406 |
||
1407 |
(view := self findViewWithId:(args at:1)) notNil ifTrue:[ |
|
146 | 1408 |
view perform:(args at:2) with:(args at:3). |
1409 |
self changed:#layout. |
|
60 | 1410 |
] |
1411 |
! |
|
1412 |
||
134 | 1413 |
undoRemove:args |
1414 |
"undo method when removing an object; see 'createUndoRemove:' |
|
1415 |
" |
|
1416 |
|frame prop view| |
|
1417 |
||
1418 |
(args at:3) notNil ifTrue:[ |
|
1419 |
frame := self findViewWithId:(args at:3). |
|
1420 |
]. |
|
1421 |
frame isNil ifTrue:[ |
|
1422 |
frame := self |
|
1423 |
]. |
|
1424 |
view := self addSpec:(args at:1) builder:(UIBuilder new) in:frame. |
|
1425 |
view realize. |
|
1426 |
inputView raise. |
|
1427 |
||
1428 |
prop := self propertyOfView:view. |
|
1429 |
prop identifier:(args at:2). |
|
1430 |
||
1431 |
! |
|
1432 |
||
1433 |
undoSpecModify:args |
|
1434 |
"undo method when changing a spec; see 'createUndoSpecModify:' |
|
60 | 1435 |
" |
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1436 |
|builder view spec v props| |
60 | 1437 |
|
134 | 1438 |
props := self propertyOfIdentifier:(args at:2). |
60 | 1439 |
|
134 | 1440 |
props notNil ifTrue:[ |
1441 |
view := props view. |
|
1442 |
spec := args at:1. |
|
1443 |
builder := UIBuilder new. |
|
1444 |
props spec:spec. |
|
80
3316c52ef2b7
write back specification to properties after undo modification
ca
parents:
78
diff
changeset
|
1445 |
|
134 | 1446 |
spec needsRebuildForAttributes ifTrue:[ |
1447 |
v := spec buildViewWithLayoutFor:builder in:view superView. |
|
1448 |
v realize. |
|
1449 |
view destroy. |
|
1450 |
view become:v |
|
1451 |
] ifFalse:[ |
|
1452 |
spec setAttributesIn:view with:builder. |
|
1453 |
self elementChangedSize:view. |
|
1454 |
]. |
|
1455 |
listHolder propertyChanged:props. |
|
1456 |
] |
|
60 | 1457 |
|
1458 |
! ! |
|
1459 |
||
111 | 1460 |
!UIPainterView::ListHolder class methodsFor:'instance creation'! |
1461 |
||
1462 |
for:aPainter |
|
1463 |
^ self new for:aPainter |
|
1464 |
! ! |
|
1465 |
||
1466 |
!UIPainterView::ListHolder methodsFor:'accessing'! |
|
1467 |
||
1468 |
painter |
|
1469 |
"returns painter |
|
1470 |
" |
|
1471 |
^ painter |
|
1472 |
! |
|
1473 |
||
1474 |
propertyAt:anIndex |
|
1475 |
"returns property at an index |
|
1476 |
" |
|
1477 |
^ propertyList at:anIndex |
|
1478 |
! ! |
|
1479 |
||
1480 |
!UIPainterView::ListHolder methodsFor:'adding & removing'! |
|
1481 |
||
1482 |
add:aProperty |
|
1483 |
"add property and update list |
|
1484 |
" |
|
1485 |
|idx list name last| |
|
1486 |
||
1487 |
list := self list. |
|
1488 |
idx := self findParentProperty:aProperty. |
|
1489 |
name := aProperty name. |
|
1490 |
||
1491 |
idx == 0 ifTrue:[ |
|
1492 |
last := list size |
|
1493 |
] ifFalse:[ |
|
1494 |
last := self lastInGroupStartingAt:idx. |
|
1495 |
name := (String new:(4+((list at:idx) leftIndent))), name. |
|
1496 |
]. |
|
1497 |
propertyList add:aProperty afterIndex:last. |
|
1498 |
list add:name afterIndex:last. |
|
1499 |
self changed:#size |
|
1500 |
||
1501 |
||
1502 |
! |
|
1503 |
||
1504 |
remove:aView |
|
1505 |
"remove all view relevant resources |
|
1506 |
" |
|
1507 |
|start| |
|
1508 |
||
1509 |
aView notNil ifTrue:[ |
|
1510 |
start := self findProperty:[:p| p view == aView ]. |
|
1511 |
||
1512 |
start ~~ 0 ifTrue:[ |
|
1513 |
self basicRemove:start. |
|
1514 |
self changed:#size. |
|
1515 |
] |
|
1516 |
] |
|
1517 |
! |
|
1518 |
||
1519 |
removeAll |
|
1520 |
masterElement := nil. |
|
1521 |
self selection:#(). |
|
1522 |
||
1523 |
[propertyList notEmpty] whileTrue:[ |
|
1524 |
self basicRemove:1 |
|
1525 |
]. |
|
1526 |
self changed:#size. |
|
1527 |
||
1528 |
! ! |
|
1529 |
||
1530 |
!UIPainterView::ListHolder methodsFor:'change & update'! |
|
1531 |
||
1532 |
changed:aParameter |
|
1533 |
"notify all dependents that the receiver has changed somehow. |
|
1534 |
Each dependent gets a '#update:'-message with aParameter |
|
1535 |
as argument. In case of disabled no notifications are raised |
|
1536 |
" |
|
1537 |
disabledChanged ifFalse:[ |
|
1538 |
super changed:aParameter |
|
1539 |
] |
|
1540 |
! |
|
1541 |
||
1542 |
disableNotificationsWhileEvaluating:aBlock |
|
1543 |
"perform block without notification; after evaluation of block, |
|
1544 |
a #size changed notification is raised |
|
1545 |
" |
|
1546 |
|oldState| |
|
1547 |
||
1548 |
oldState := disabledChanged. |
|
1549 |
disabledChanged := true. |
|
1550 |
aBlock value. |
|
1551 |
disabledChanged := oldState. |
|
1552 |
self changed:#size. |
|
1553 |
! |
|
1554 |
||
1555 |
propertyChanged:aProperty |
|
1556 |
"property list changed; update list names |
|
1557 |
" |
|
1558 |
|list idx oldName newName wspName view indent mid| |
|
1559 |
||
1560 |
view := aProperty view. |
|
1561 |
idx := self findProperty:[:p| p view == view ]. |
|
1562 |
||
1563 |
idx == 0 ifTrue:[ |
|
1564 |
^ self error |
|
1565 |
]. |
|
1566 |
||
1567 |
list := self list. |
|
1568 |
oldName := list at:idx. |
|
1569 |
wspName := oldName string withoutSeparators. |
|
1570 |
newName := aProperty name. |
|
1571 |
||
1572 |
wspName = newName ifFalse:[ |
|
1573 |
mid := self masterElement. |
|
1574 |
list at:idx put:((String new:(oldName leftIndent)), newName). |
|
1575 |
||
1576 |
idx == mid ifTrue:[ |
|
1577 |
masterElement := nil. |
|
1578 |
self masterElement:idx |
|
1579 |
]. |
|
1580 |
]. |
|
1581 |
self changed:#property |
|
1582 |
||
1583 |
! ! |
|
1584 |
||
1585 |
!UIPainterView::ListHolder methodsFor:'enumerating'! |
|
1586 |
||
1587 |
propertiesDo:aBlock |
|
1588 |
"evaluate a block for each property |
|
1589 |
" |
|
1590 |
propertyList do:aBlock |
|
1591 |
! ! |
|
1592 |
||
1593 |
!UIPainterView::ListHolder methodsFor:'initialization'! |
|
1594 |
||
1595 |
for:aPainter |
|
1596 |
"initialize for a painter |
|
1597 |
" |
|
119 | 1598 |
painter := aPainter. |
121 | 1599 |
disabledChanged := false. |
111 | 1600 |
self list:(OrderedCollection new). |
1601 |
propertyList := OrderedCollection new. |
|
1602 |
self selection:#(). |
|
1603 |
self addDependent:painter. |
|
1604 |
||
1605 |
! ! |
|
1606 |
||
1607 |
!UIPainterView::ListHolder methodsFor:'private'! |
|
1608 |
||
1609 |
basicRemove:start |
|
1610 |
"remove all resources assigned to a group starting at start; |
|
1611 |
no notifications are raised |
|
1612 |
" |
|
1613 |
|end view superView| |
|
1614 |
||
1615 |
end := self lastInGroupStartingAt:start. |
|
1616 |
view := (propertyList at:start) view. |
|
1617 |
||
1618 |
view notNil ifTrue:[ |
|
1619 |
superView := view superView. |
|
1620 |
view destroy. |
|
1621 |
superView sizeChanged:nil. |
|
1622 |
]. |
|
1623 |
||
1624 |
propertyList removeFromIndex:start toIndex:end. |
|
1625 |
self list removeFromIndex:start toIndex:end. |
|
1626 |
! |
|
1627 |
||
1628 |
masterElement |
|
1629 |
"returns index of master |
|
1630 |
" |
|
1631 |
^ self indexOfName:masterElement. |
|
1632 |
! |
|
1633 |
||
1634 |
masterElement:newIndex |
|
1635 |
"change master of selection |
|
1636 |
" |
|
1637 |
|name list oldIdx| |
|
1638 |
||
1639 |
(oldIdx := self masterElement) ~~ newIndex ifTrue:[ |
|
1640 |
list := self list. |
|
1641 |
||
1642 |
oldIdx ~~ 0 ifTrue:[ |
|
1643 |
list at:oldIdx put:masterElement |
|
1644 |
]. |
|
1645 |
newIndex ~~ 0 ifTrue:[ |
|
1646 |
masterElement := list at:newIndex. |
|
1647 |
name := Text string:masterElement. |
|
1648 |
name emphasizeFrom:(1+(name leftIndent)) with:#(#bold #underline). |
|
1649 |
list at:newIndex put:name. |
|
1650 |
] ifFalse:[ |
|
1651 |
masterElement := nil |
|
1652 |
]. |
|
1653 |
self changed:#list. |
|
1654 |
] |
|
1655 |
! ! |
|
1656 |
||
1657 |
!UIPainterView::ListHolder methodsFor:'searching'! |
|
1658 |
||
1659 |
detectProperty:aBlock |
|
1660 |
"find the property, for which evaluation of the argument, aBlock |
|
1661 |
returns true; return the property or nil if none detected |
|
1662 |
" |
|
1663 |
|idx| |
|
1664 |
||
1665 |
idx := self findProperty:aBlock. |
|
1666 |
idx ~~ 0 ifTrue:[ ^ propertyList at:idx ]. |
|
1667 |
^ nil |
|
1668 |
! |
|
1669 |
||
1670 |
findParentProperty:aChildProp |
|
1671 |
"returns index of parent or 0 |
|
1672 |
" |
|
1673 |
|view index| |
|
1674 |
||
1675 |
view := aChildProp view. |
|
1676 |
||
1677 |
view notNil ifTrue:[ |
|
1678 |
[ (view := view superView) notNil ] whileTrue:[ |
|
1679 |
index := self findProperty:[:aProp| aProp view == view ]. |
|
1680 |
index ~~ 0 ifTrue:[ |
|
1681 |
^ index |
|
1682 |
] |
|
1683 |
] |
|
1684 |
]. |
|
1685 |
^ 0 |
|
1686 |
||
1687 |
||
1688 |
! |
|
1689 |
||
1690 |
findProperty:aBlock |
|
1691 |
"find the first property, for which evaluation of the argument, aBlock |
|
1692 |
returns true; return its index or 0 if none detected |
|
1693 |
" |
|
1694 |
^ propertyList findFirst:aBlock |
|
1695 |
! |
|
1696 |
||
1697 |
indexOfName:aString |
|
1698 |
"returns index assigned to a string or 0 |
|
1699 |
" |
|
1700 |
|name list size| |
|
1701 |
||
1702 |
aString notNil ifTrue:[ |
|
1703 |
name := aString string withoutSeparators. |
|
1704 |
size := name size. |
|
1705 |
list := self list. |
|
1706 |
||
1707 |
list keysAndValuesDo:[:anIndex :aName| |
|
1708 |
|el| |
|
1709 |
||
1710 |
el := aName string. |
|
1711 |
(el endsWith:name) ifTrue:[ |
|
1712 |
(el size - el leftIndent) == name size ifTrue:[ |
|
1713 |
^ anIndex |
|
1714 |
] |
|
1715 |
] |
|
1716 |
] |
|
1717 |
]. |
|
1718 |
^ 0 |
|
1719 |
||
1720 |
! |
|
1721 |
||
1722 |
lastInGroupStartingAt:start |
|
1723 |
"returns last index of a group |
|
1724 |
" |
|
1725 |
|end list idt| |
|
1726 |
||
1727 |
list := self list. |
|
1728 |
||
1729 |
start < list size ifTrue:[ |
|
1730 |
idt := (list at:start) leftIndent. |
|
1731 |
end := list findFirst:[:el|(el leftIndent) <= idt] startingAt:(start+1). |
|
1732 |
end ~~ 0 ifTrue:[ |
|
1733 |
^ end - 1 |
|
1734 |
] |
|
1735 |
]. |
|
1736 |
^ list size |
|
1737 |
! ! |
|
1738 |
||
1739 |
!UIPainterView::ListHolder methodsFor:'selection'! |
|
1740 |
||
1741 |
selectGroup |
|
1742 |
"select all elements assigned to master |
|
1743 |
" |
|
1744 |
|start end sel size| |
|
1745 |
||
119 | 1746 |
painter enabled ifTrue:[ |
111 | 1747 |
(start := self masterElement) ~~ 0 ifTrue:[ |
1748 |
end := self lastInGroupStartingAt:start. |
|
1749 |
size := end - start + 1. |
|
1750 |
sel := Array new:size. |
|
1751 |
||
1752 |
1 to:size do:[:i| |
|
1753 |
sel at:i put:start. |
|
1754 |
start := start + 1 |
|
1755 |
]. |
|
1756 |
self selectionIndex:sel. |
|
1757 |
] ifFalse:[ |
|
1758 |
(self selectionIndex) size == 0 ifFalse:[ |
|
1759 |
self selectionIndex:#() |
|
1760 |
]. |
|
1761 |
] |
|
1762 |
] |
|
1763 |
! |
|
1764 |
||
1765 |
selectedProperty |
|
1766 |
"returns current selected instance; in case of multiple selection |
|
1767 |
or no selection nil is returned |
|
1768 |
" |
|
1769 |
|selection| |
|
1770 |
selection := self selectionIndex. |
|
1771 |
||
1772 |
selection size == 1 ifTrue:[ |
|
137 | 1773 |
propertyList size ~~ 0 ifTrue:[ |
1774 |
^ propertyList at:(selection first) |
|
1775 |
] |
|
111 | 1776 |
]. |
1777 |
^ nil |
|
1778 |
! |
|
1779 |
||
1780 |
selectionIndex:aList |
|
1781 |
|masterIndex aSel| |
|
1782 |
||
119 | 1783 |
painter enabled ifTrue:[aSel := aList] |
1784 |
ifFalse:[aSel := nil]. |
|
111 | 1785 |
|
1786 |
aSel size ~~ 0 ifTrue:[masterIndex := aSel at:1] |
|
1787 |
ifFalse:[masterIndex := 0]. |
|
1788 |
||
1789 |
self masterElement:masterIndex. |
|
1790 |
super selectionIndex:aSel |
|
1791 |
! ! |
|
1792 |
||
162 | 1793 |
!UIPainterView::ViewProperty class methodsFor:'documentation'! |
1794 |
||
1795 |
version |
|
1796 |
^ '$Header$' |
|
1797 |
! ! |
|
1798 |
||
1799 |
!UIPainterView::ViewProperty class methodsFor:'instance creation'! |
|
1800 |
||
1801 |
new |
|
1802 |
Identifier notNil ifTrue:[Identifier := Identifier + 1] |
|
1803 |
ifFalse:[Identifier := 1]. |
|
1804 |
||
1805 |
^ self basicNew initialize |
|
1806 |
! ! |
|
1807 |
||
1808 |
!UIPainterView::ViewProperty methodsFor:'accessing'! |
|
1809 |
||
1810 |
identifier |
|
1811 |
"return the unique identifier assigned to property |
|
1812 |
" |
|
1813 |
^ identifier |
|
1814 |
! |
|
1815 |
||
1816 |
identifier:anIdentifier |
|
1817 |
"set the unique identifier assigned to property; called after an restore of |
|
1818 |
a deleted instance |
|
1819 |
" |
|
1820 |
identifier := anIdentifier |
|
1821 |
! |
|
1822 |
||
1823 |
spec |
|
1824 |
"return the value of the instance variable 'spec' (automatically generated)" |
|
1825 |
||
1826 |
^ spec! |
|
1827 |
||
1828 |
spec:something |
|
1829 |
"set the value of the instance variable 'spec' (automatically generated)" |
|
1830 |
||
1831 |
spec := something.! |
|
1832 |
||
1833 |
view |
|
1834 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1835 |
||
1836 |
^ view! |
|
1837 |
||
1838 |
view:something |
|
1839 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1840 |
||
1841 |
view := something.! ! |
|
1842 |
||
1843 |
!UIPainterView::ViewProperty methodsFor:'initialization'! |
|
1844 |
||
1845 |
initialize |
|
1846 |
super initialize. |
|
1847 |
identifier := Identifier |
|
1848 |
! ! |
|
1849 |
||
1850 |
!UIPainterView::ViewProperty methodsFor:'misc'! |
|
1851 |
||
1852 |
extractNumberStartingAt:anIndex |
|
1853 |
"return the number from the name starting at anIndex or 0. |
|
1854 |
" |
|
1855 |
|val| |
|
1856 |
||
1857 |
val := 0. |
|
1858 |
||
1859 |
self name from:anIndex do:[:c| |
|
1860 |
c isDigit ifTrue:[val := val * 10 + c digitValue] |
|
1861 |
ifFalse:[^ 0] |
|
1862 |
]. |
|
1863 |
^ val |
|
1864 |
||
1865 |
! ! |
|
1866 |
||
1867 |
!UIPainterView::ViewProperty methodsFor:'spec messages'! |
|
1868 |
||
1869 |
doesNotUnderstand:aMessage |
|
1870 |
spec notNil ifTrue:[ |
|
1871 |
(spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec] |
|
1872 |
]. |
|
1873 |
^ nil |
|
1874 |
! |
|
1875 |
||
1876 |
layout |
|
1877 |
spec layout |
|
1878 |
! |
|
1879 |
||
1880 |
layout:aLayout |
|
1881 |
spec layout:aLayout |
|
1882 |
! |
|
1883 |
||
1884 |
name |
|
1885 |
^ spec name |
|
1886 |
! |
|
1887 |
||
1888 |
name:aName |
|
1889 |
spec name:aName |
|
1890 |
! ! |
|
1891 |
||
60 | 1892 |
!UIPainterView class methodsFor:'documentation'! |
1893 |
||
1894 |
version |
|
1895 |
^ '$Header$' |
|
1896 |
! ! |