70 ^ #showMiddleButtonMenu |
63 ^ #showMiddleButtonMenu |
71 |
64 |
72 |
65 |
73 ! ! |
66 ! ! |
74 |
67 |
75 !UIPainterView class methodsFor:'menu specs'! |
|
76 |
|
77 menu |
|
78 "this window spec was automatically generated by the ST/X MenuEditor" |
|
79 |
|
80 "do not manually edit this - the builder may not be able to |
|
81 handle the specification if its corrupted." |
|
82 |
|
83 " |
|
84 MenuEditor new openOnClass:UIPainterView andSelector:#menu |
|
85 (Menu new fromLiteralArrayEncoding:(UIPainterView menu)) startUp |
|
86 " |
|
87 |
|
88 <resource: #menu> |
|
89 |
|
90 ^ |
|
91 |
|
92 #(#Menu |
|
93 |
|
94 #( |
|
95 #(#MenuItem |
|
96 #'label:' 'copy' |
|
97 #'value:' #copySelection |
|
98 #'shortcutKeyCharacter:' #Copy |
|
99 ) |
|
100 #(#MenuItem |
|
101 #'label:' 'cut' |
|
102 #'value:' #deleteSelection |
|
103 #'shortcutKeyCharacter:' #Cut |
|
104 ) |
|
105 #(#MenuItem |
|
106 #'label:' 'paste' |
|
107 #'nameKey:' #paste |
|
108 #'value:' #paste |
|
109 #'submenu:' |
|
110 #(#Menu |
|
111 |
|
112 #( |
|
113 #(#MenuItem |
|
114 #'label:' 'paste' |
|
115 #'value:' #pasteBuffer |
|
116 #'activeHelpKey:' #pasteBuffer |
|
117 #'shortcutKeyCharacter:' #Paste |
|
118 ) |
|
119 #(#MenuItem |
|
120 #'label:' 'keep layout' |
|
121 #'value:' #pasteWithLayout |
|
122 #'activeHelpKey:' #pasteWithLayout |
|
123 ) |
|
124 ) nil |
|
125 nil |
|
126 ) |
|
127 ) |
|
128 #(#MenuItem |
|
129 #'label:' '-' |
|
130 ) |
|
131 #(#MenuItem |
|
132 #'label:' 'undo' |
|
133 #'nameKey:' #undo |
|
134 #'value:' #undoLast |
|
135 ) |
|
136 #(#MenuItem |
|
137 #'label:' '-' |
|
138 ) |
|
139 #(#MenuItem |
|
140 #'label:' 'arrange' |
|
141 #'value:' #arrange |
|
142 #'submenu:' |
|
143 #(#Menu |
|
144 |
|
145 #( |
|
146 #(#MenuItem |
|
147 #'label:' 'to front' |
|
148 #'value:' #raiseSelection |
|
149 ) |
|
150 #(#MenuItem |
|
151 #'label:' 'to back' |
|
152 #'value:' #lowerSelection |
|
153 ) |
|
154 ) nil |
|
155 nil |
|
156 ) |
|
157 ) |
|
158 #(#MenuItem |
|
159 #'label:' 'dimension' |
|
160 #'value:' #dimension |
|
161 #'submenu:' |
|
162 #(#Menu |
|
163 |
|
164 #( |
|
165 #(#MenuItem |
|
166 #'label:' 'default extent' |
|
167 #'value:' #setToDefaultExtent |
|
168 #'activeHelpKey:' #setToDefaultExtent |
|
169 ) |
|
170 #(#MenuItem |
|
171 #'label:' 'default width' |
|
172 #'value:' #setToDefaultWidth |
|
173 #'activeHelpKey:' #setToDefaultWidth |
|
174 ) |
|
175 #(#MenuItem |
|
176 #'label:' 'default height' |
|
177 #'value:' #setToDefaultHeight |
|
178 #'activeHelpKey:' #setToDefaultHeight |
|
179 ) |
|
180 #(#MenuItem |
|
181 #'label:' 'copy extent' |
|
182 #'value:' #copyExtent |
|
183 #'activeHelpKey:' #copyExtent |
|
184 ) |
|
185 #(#MenuItem |
|
186 #'label:' 'paste extent' |
|
187 #'value:' #pasteExtent |
|
188 #'activeHelpKey:' #pasteExtent |
|
189 ) |
|
190 #(#MenuItem |
|
191 #'label:' 'paste width' |
|
192 #'value:' #pasteWidth |
|
193 #'activeHelpKey:' #pasteWidth |
|
194 ) |
|
195 #(#MenuItem |
|
196 #'label:' 'paste height' |
|
197 #'value:' #pasteHeight |
|
198 #'activeHelpKey:' #pasteHeight |
|
199 ) |
|
200 #(#MenuItem |
|
201 #'label:' 'copy layout' |
|
202 #'value:' #copyLayout |
|
203 #'activeHelpKey:' #copyLayout |
|
204 ) |
|
205 #(#MenuItem |
|
206 #'label:' 'paste layout' |
|
207 #'value:' #pasteLayout |
|
208 #'activeHelpKey:' #pasteLayout |
|
209 ) |
|
210 ) |
|
211 #(3 1 3) |
|
212 nil |
|
213 ) |
|
214 ) |
|
215 #(#MenuItem |
|
216 #'label:' 'align' |
|
217 #'value:' #align |
|
218 #'submenu:' |
|
219 #(#Menu |
|
220 |
|
221 #( |
|
222 #(#MenuItem |
|
223 #'label:' 'align left' |
|
224 #'value:' #alignSelectionLeft |
|
225 #'activeHelpKey:' #alignSelectionLeft |
|
226 #'labelImage:' |
|
227 #(#ResourceRetriever |
|
228 #UIPainter #iconAlignL |
|
229 'align left' |
|
230 ) |
|
231 ) |
|
232 #(#MenuItem |
|
233 #'label:' 'align right' |
|
234 #'value:' #alignSelectionRight |
|
235 #'activeHelpKey:' #alignSelectionRight |
|
236 #'labelImage:' |
|
237 #(#ResourceRetriever |
|
238 #UIPainter #iconAlignR |
|
239 'align right' |
|
240 ) |
|
241 ) |
|
242 #(#MenuItem |
|
243 #'label:' 'align left & right' |
|
244 #'value:' #alignSelectionLeftAndRight |
|
245 #'activeHelpKey:' #alignSelectionLeftAndRight |
|
246 #'labelImage:' |
|
247 #(#ResourceRetriever |
|
248 #UIPainter #iconAlignLR |
|
249 'align left & right' |
|
250 ) |
|
251 ) |
|
252 #(#MenuItem |
|
253 #'label:' 'align top' |
|
254 #'value:' #alignSelectionTop |
|
255 #'activeHelpKey:' #alignSelectionTop |
|
256 #'labelImage:' |
|
257 #(#ResourceRetriever |
|
258 #UIPainter #iconAlignT |
|
259 'align top' |
|
260 ) |
|
261 ) |
|
262 #(#MenuItem |
|
263 #'label:' 'align bottom' |
|
264 #'value:' #alignSelectionBottom |
|
265 #'activeHelpKey:' #alignSelectionBottom |
|
266 #'labelImage:' |
|
267 #(#ResourceRetriever |
|
268 #UIPainter #iconAlignB |
|
269 'align bottom' |
|
270 ) |
|
271 ) |
|
272 #(#MenuItem |
|
273 #'label:' 'align top & bottom' |
|
274 #'value:' #alignSelectionTopAndBottom |
|
275 #'activeHelpKey:' #alignSelectionTopAndBottom |
|
276 #'labelImage:' |
|
277 #(#ResourceRetriever |
|
278 #UIPainter #iconAlignTB |
|
279 'align top & bottom' |
|
280 ) |
|
281 ) |
|
282 #(#MenuItem |
|
283 #'label:' 'align centered horizontal' |
|
284 #'value:' #alignSelectionCenterHor |
|
285 #'activeHelpKey:' #alignSelectionCenterHor |
|
286 #'labelImage:' |
|
287 #(#ResourceRetriever |
|
288 #UIPainter #iconAlignCenterH |
|
289 'align centered horizontal' |
|
290 ) |
|
291 ) |
|
292 #(#MenuItem |
|
293 #'label:' 'align centered vertical' |
|
294 #'value:' #alignSelectionCenterVer |
|
295 #'activeHelpKey:' #alignSelectionCenterVer |
|
296 #'labelImage:' |
|
297 #(#ResourceRetriever |
|
298 #UIPainter #iconAlignCenterV |
|
299 'align centered vertical' |
|
300 ) |
|
301 ) |
|
302 #(#MenuItem |
|
303 #'label:' 'spread horizontal' |
|
304 #'value:' #spreadSelectionHor |
|
305 #'activeHelpKey:' #spreadSelectionHor |
|
306 ) |
|
307 #(#MenuItem |
|
308 #'label:' 'spread vertical' |
|
309 #'value:' #spreadSelectionVer |
|
310 #'activeHelpKey:' #spreadSelectionVer |
|
311 ) |
|
312 #(#MenuItem |
|
313 #'label:' 'center horizontal in frame' |
|
314 #'value:' #centerSelectionHor |
|
315 #'activeHelpKey:' #centerSelectionHor |
|
316 ) |
|
317 #(#MenuItem |
|
318 #'label:' 'center vertical in frame' |
|
319 #'value:' #centerSelectionVer |
|
320 #'activeHelpKey:' #centerSelectionVer |
|
321 ) |
|
322 ) |
|
323 #(8 2) |
|
324 nil |
|
325 ) |
|
326 ) |
|
327 ) nil |
|
328 nil |
|
329 ) |
|
330 ! ! |
|
331 |
|
332 !UIPainterView methodsFor:'accessing'! |
68 !UIPainterView methodsFor:'accessing'! |
333 |
69 |
334 application |
70 application |
335 ^ nil |
71 ^ nil |
336 |
72 |
403 |
150 |
404 ! ! |
151 ! ! |
405 |
152 |
406 !UIPainterView methodsFor:'change & update'! |
153 !UIPainterView methodsFor:'change & update'! |
407 |
154 |
408 changed:aParameter |
155 layoutChanged |
409 aParameter == #layout ifTrue:[ |
156 claus layoutChanged |
410 listHolder removeDependent:self. |
|
411 listHolder changed:aParameter. |
|
412 listHolder addDependent:self. |
|
413 ] ifFalse:[ |
|
414 super changed:aParameter |
|
415 ] |
|
416 ! |
|
417 |
|
418 selectionChanged |
|
419 "selection has changed |
|
420 " |
|
421 |newSel| |
|
422 |
|
423 self selectionDo:[:aView||p| |
|
424 (p := self propertyOfView:aView) notNil ifTrue:[ |
|
425 newSel isNil ifTrue:[ |
|
426 newSel := OrderedCollection new |
|
427 ]. |
|
428 newSel add:(listHolder indexOfName:(p name)) |
|
429 ] |
|
430 ]. |
|
431 listHolder removeDependent:self. |
|
432 listHolder selectionIndex:newSel. |
|
433 listHolder addDependent:self. |
|
434 ! |
|
435 |
|
436 update:what with:aParm from:aSender |
|
437 |loIdx newSel| |
|
438 |
|
439 (what == #selectionIndex and:[aSender == listHolder]) ifFalse:[ |
|
440 ^ self |
|
441 ]. |
|
442 loIdx := listHolder selectionIndex. |
|
443 |
|
444 loIdx size ~~ 0 ifTrue:[ |
|
445 newSel := loIdx collect:[:i|(listHolder propertyAt:i) view] |
|
446 ]. |
|
447 self updateSelectionFrom:newSel. |
|
448 ! |
|
449 |
|
450 updateSelectionFrom:aSel |
|
451 "update selection from a new selection |
|
452 " |
|
453 |csel| |
|
454 |
|
455 selectionHiddenLevel == 0 ifTrue:[ |
|
456 aSel isCollection ifTrue:[ |
|
457 self selectionDo:[:el| |
|
458 (aSel includes:el) ifFalse:[self showUnselected:el] |
|
459 ] |
|
460 ] ifFalse:[ |
|
461 self selectionDo:[:el| |
|
462 aSel == el ifFalse:[self showUnselected:el] |
|
463 ] |
|
464 ] |
|
465 ]. |
|
466 self setSelection:aSel withRedraw:false. |
|
467 self showSelection |
|
468 ! ! |
157 ! ! |
469 |
158 |
470 !UIPainterView methodsFor:'copy & cut & paste'! |
159 !UIPainterView methodsFor:'copy & cut & paste'! |
471 |
160 |
472 copySelection |
161 copySelection |
576 newSel size == 1 ifTrue:[ |
268 newSel size == 1 ifTrue:[ |
577 newSel := newSel at:1 |
269 newSel := newSel at:1 |
578 ]. |
270 ]. |
579 self realizeAllSubViews. |
271 self realizeAllSubViews. |
580 inputView raise. |
272 inputView raise. |
581 self select:newSel. |
|
582 self elementChangedSize:frame. |
273 self elementChangedSize:frame. |
583 ] |
274 ]. |
584 |
275 ^ newSel |
585 "Modified: 4.7.1997 / 23:49:14 / cg" |
|
586 ! |
276 ! |
587 |
277 |
588 pasteWithLayout |
278 pasteWithLayout |
589 "add the objects in the paste-buffer to the object view; don't change the |
279 "add the objects in the paste-buffer to the object view; don't change the |
590 layout |
280 layout |
591 " |
281 " |
592 self pasteSpecifications:(self getSelection) keepLayout:true |
282 |sel| |
593 |
283 |
|
284 sel := self pasteSpecifications:(self getSelection) keepLayout:true. |
|
285 |
|
286 sel notNil ifTrue:[ |
|
287 self select:sel. |
|
288 ]. |
594 ! ! |
289 ! ! |
595 |
290 |
596 !UIPainterView methodsFor:'drag & drop'! |
291 !UIPainterView methodsFor:'drag & drop'! |
597 |
292 |
598 canDrop:anObjectOrCollection |
293 canDrop:anObjectOrCollection |
|
294 anObjectOrCollection size == 1 ifTrue:[ |
|
295 ^ self canPaste:(anObjectOrCollection first theObject) |
|
296 ]. |
|
297 ^ false |
|
298 ! |
|
299 |
|
300 canPaste:something |
|
301 "returns true if something could be paste |
|
302 " |
|
303 |el size| |
|
304 |
|
305 ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
306 ^ false |
|
307 ]. |
|
308 something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]] |
|
309 ifFalse:[el := something]. |
|
310 |
|
311 (el isKindOf:UISpecification) ifFalse:[ |
|
312 ^ false |
|
313 ]. |
|
314 |
|
315 size == 1 ifTrue:[ |
|
316 ^ self canPasteInto:(self singleSelection) |
|
317 ]. |
|
318 ^ true |
|
319 |
|
320 ! |
|
321 |
|
322 canPasteInto:aView |
|
323 "can paste into a view |
|
324 " |
599 |spec| |
325 |spec| |
600 |
326 |
601 self enabled ifTrue:[ |
327 aView notNil ifTrue:[ |
602 anObjectOrCollection size == 1 ifTrue:[ |
328 spec := self specFor:aView. |
603 spec := (anObjectOrCollection at:1) theObject. |
329 |
604 ^ (spec isKindOf:UISpecification) |
330 spec isNil ifTrue:[^ aView specClass supportsSubComponents] |
605 ] |
331 ifFalse:[^ spec class supportsSubComponents] |
606 ]. |
332 ]. |
607 ^ false |
333 ^ false |
608 |
334 |
609 "Modified: 8.4.1997 / 01:01:50 / cg" |
|
610 ! |
335 ! |
611 |
336 |
612 drop:anObjectOrCollection at:aPoint |
337 drop:anObjectOrCollection at:aPoint |
613 |spec| |
338 |spec newSel oldSel| |
614 |
339 |
|
340 oldSel := selection copy. |
615 spec := (anObjectOrCollection at:1) theObject. |
341 spec := (anObjectOrCollection at:1) theObject. |
616 self pasteSpecifications:spec keepLayout:false. |
342 newSel := self pasteSpecifications:spec keepLayout:false. |
617 |
343 |
618 |
344 oldSel isNil ifTrue:[self select:newSel] |
|
345 ifFalse:[self select:oldSel] |
619 ! ! |
346 ! ! |
620 |
347 |
621 !UIPainterView methodsFor:'generating output'! |
348 !UIPainterView methodsFor:'generating output'! |
622 |
349 |
623 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
350 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
797 "Modified: 24.6.1997 / 19:12:44 / cg" |
524 "Modified: 24.6.1997 / 19:12:44 / cg" |
798 ! ! |
525 ! ! |
799 |
526 |
800 !UIPainterView methodsFor:'initialization'! |
527 !UIPainterView methodsFor:'initialization'! |
801 |
528 |
802 destroy |
|
803 "remove dependencies |
|
804 " |
|
805 listHolder notNil ifTrue:[ |
|
806 listHolder removeDependent:self. |
|
807 ]. |
|
808 super destroy. |
|
809 ! |
|
810 |
|
811 initialize |
529 initialize |
812 "setup attributes |
530 "setup attributes |
813 " |
531 " |
814 super initialize. |
532 super initialize. |
815 |
533 |
816 superclassName := 'ApplicationModel'. |
534 superclassName := 'ApplicationModel'. |
817 className := 'NewApplication'. |
535 className := 'NewApplication'. |
818 methodName := 'windowSpec'. |
536 methodName := 'windowSpec'. |
819 categoryName := 'Applications'. |
537 categoryName := 'Applications'. |
820 listHolder := ListHolder for:self. |
|
821 HandCursor := Cursor leftHand. |
538 HandCursor := Cursor leftHand. |
822 |
539 |
823 ! |
540 ! |
824 |
541 |
825 setupFromSpec:specOrSpecArray |
542 setupFromSpec:specOrSpecArray |
826 |spec builder| |
543 |spec builder| |
827 |
544 |
828 listHolder disableNotificationsWhileEvaluating:[ |
545 claus cvsSetupListDo:[ |
829 self removeAll. |
546 self removeAll. |
830 spec := UISpecification from:specOrSpecArray. |
547 spec := UISpecification from:specOrSpecArray. |
831 builder := UIBuilder new. |
548 builder := UIBuilder new. |
832 spec window setupView:self topView for:builder. |
549 spec window setupView:self topView for:builder. |
833 self addSpec:(spec component) builder:builder in:self. |
550 self addSpec:(spec component) builder:builder in:self. |
834 self realizeAllSubViews. |
551 self realizeAllSubViews. |
835 inputView raise. |
552 inputView raise. |
836 ] |
553 ] |
|
554 ! |
|
555 |
|
556 treeView:aTreeView |
|
557 claus := aTreeView |
837 ! ! |
558 ! ! |
838 |
559 |
839 !UIPainterView methodsFor:'menus'! |
560 !UIPainterView methodsFor:'menus'! |
840 |
561 |
841 showMiddleButtonMenu |
562 showMiddleButtonMenu |
842 "show the middle button menu; this returns nil |
563 "show the middle button menu; this returns nil |
843 " |
564 " |
844 |menu canPaste| |
565 |menu| |
845 |
566 |
846 self enabled ifFalse:[ |
567 self enabled ifTrue:[ |
847 ^ nil |
568 menu := MenuPanel fromSpec:(UIPainter menuCanvas) receiver:self. |
848 ]. |
569 |
849 menu := MenuPanel fromSpec:(self class menu) receiver:self. |
570 self hasSelection ifFalse:[ |
850 |
571 menu disableAll |
851 canPaste := self canPaste:(self getSelection). |
572 ]. |
852 |
573 menu enabledAt:#paste put:(self canPaste:(self getSelection)). |
853 self hasSelection ifTrue:[ |
574 menu enabledAt:#undo put:(undoHistory isEmpty not). |
854 canPaste := (canPaste and:[self canPasteInto:(self selection)]) |
575 menu startUp. |
855 ] ifFalse:[ |
576 ]. |
856 menu disableAll |
|
857 ]. |
|
858 menu enabledAt:#paste put:canPaste. |
|
859 menu enabledAt:#undo put:(undoHistory isEmpty not). |
|
860 menu startUp. |
|
861 ^ nil |
577 ^ nil |
862 |
578 |
863 |
579 |
864 |
580 |
865 ! ! |
581 ! ! |
1006 prop name:(self uniqueNameFor:(prop spec)). |
719 prop name:(self uniqueNameFor:(prop spec)). |
1007 ]. |
720 ]. |
1008 ^ prop name |
721 ^ prop name |
1009 ]. |
722 ]. |
1010 ^ 'self' |
723 ^ 'self' |
|
724 |
|
725 ! ! |
|
726 |
|
727 !UIPainterView methodsFor:'selection basics'! |
|
728 |
|
729 addToSelection:anObject |
|
730 "add an object to the selection |
|
731 " |
|
732 (self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
|
733 selection isCollection ifFalse:[ |
|
734 selection isNil ifTrue:[ |
|
735 selection := anObject |
|
736 ] ifFalse:[ |
|
737 selection := OrderedCollection with:selection with:anObject |
|
738 ] |
|
739 ] ifTrue:[ |
|
740 selection add:anObject |
|
741 ]. |
|
742 self showSelected:anObject. |
|
743 claus cvsSelectionAdd:anObject. |
|
744 ] |
|
745 |
|
746 |
|
747 ! |
|
748 |
|
749 removeFromSelection:anObject |
|
750 "remove an object from the selection |
|
751 " |
|
752 (self isSelected:anObject) ifTrue:[ |
|
753 self showUnselected:anObject. |
|
754 |
|
755 selection size > 1 ifTrue:[ |
|
756 selection remove:anObject ifAbsent:nil. |
|
757 self showSelection. |
|
758 ] ifFalse:[ |
|
759 selection := nil |
|
760 ]. |
|
761 claus cvsSelectionRemove:anObject. |
|
762 ] |
|
763 |
|
764 ! |
|
765 |
|
766 select:something |
|
767 "change selection to something |
|
768 " |
|
769 (self enabled and:[something ~= self selection]) ifTrue:[ |
|
770 self setSelection:something withRedraw:true. |
|
771 claus cvsSelection:something |
|
772 ] |
|
773 |
|
774 ! |
|
775 |
|
776 updateSelectionFromModel:aSel |
|
777 "update selection from a new selection |
|
778 " |
|
779 |sel| |
|
780 |
|
781 selectionHiddenLevel == 0 ifTrue:[ |
|
782 self selectionDo:[:el| (aSel includes:el) ifFalse:[self showUnselected:el] ] |
|
783 ]. |
|
784 |
|
785 (aSel indexOf:self) ~~ 0 ifTrue:[ |
|
786 aSel size > 1 ifTrue:[sel := aSel copyWithout:self] |
|
787 ] ifFalse:[ |
|
788 aSel size ~~ 0 ifTrue:[sel := aSel] |
|
789 ]. |
|
790 |
|
791 self setSelection:sel withRedraw:false. |
|
792 self showSelection |
|
793 |
1011 |
794 |
1012 ! ! |
795 ! ! |
1013 |
796 |
1014 !UIPainterView methodsFor:'specification'! |
797 !UIPainterView methodsFor:'specification'! |
1015 |
798 |
1295 view become:v |
1078 view become:v |
1296 ] ifFalse:[ |
1079 ] ifFalse:[ |
1297 spec setAttributesIn:view with:builder. |
1080 spec setAttributesIn:view with:builder. |
1298 self elementChangedSize:view. |
1081 self elementChangedSize:view. |
1299 ]. |
1082 ]. |
1300 listHolder propertyChanged:props. |
1083 claus propertyChanged:props. |
1301 ] |
1084 ] |
1302 |
|
1303 "Modified: 4.7.1997 / 23:49:39 / cg" |
|
1304 ! ! |
|
1305 |
|
1306 !UIPainterView methodsFor:'user actions - arrange'! |
|
1307 |
|
1308 lowerSelection |
|
1309 "lower all objects in the selection |
|
1310 " |
|
1311 self hasSelection ifTrue:[ |
|
1312 self selectionDo:[:aView| |
|
1313 aView lower. |
|
1314 aView superView changeSequenceOrderFor:aView to:1. |
|
1315 ]. |
|
1316 listHolder recompute. |
|
1317 ] |
|
1318 |
|
1319 |
|
1320 ! |
|
1321 |
|
1322 raiseSelection |
|
1323 "raise all objects in the selection |
|
1324 " |
|
1325 self hasSelection ifTrue:[ |
|
1326 self selectionDo:[:aView||sv| |
|
1327 aView raise. |
|
1328 sv := aView superView. |
|
1329 sv changeSequenceOrderFor:aView to:(sv subViews size) |
|
1330 ]. |
|
1331 inputView raise. |
|
1332 listHolder recompute. |
|
1333 ]. |
|
1334 |
|
1335 |
|
1336 ! ! |
|
1337 |
|
1338 !UIPainterView::ListHolder class methodsFor:'instance creation'! |
|
1339 |
|
1340 for:aPainter |
|
1341 ^ self new for:aPainter |
|
1342 ! ! |
|
1343 |
|
1344 !UIPainterView::ListHolder methodsFor:'accessing'! |
|
1345 |
|
1346 painter |
|
1347 "returns painter |
|
1348 " |
|
1349 ^ painter |
|
1350 ! |
|
1351 |
|
1352 propertyAt:anIndex |
|
1353 "returns property at an index |
|
1354 " |
|
1355 ^ propertyList at:anIndex |
|
1356 ! ! |
|
1357 |
|
1358 !UIPainterView::ListHolder methodsFor:'adding & removing'! |
|
1359 |
|
1360 add:aProperty |
|
1361 "add property and update list |
|
1362 " |
|
1363 |idx list name last| |
|
1364 |
|
1365 list := self list. |
|
1366 idx := self findParentProperty:aProperty. |
|
1367 name := aProperty name. |
|
1368 |
|
1369 idx == 0 ifTrue:[ |
|
1370 last := list size |
|
1371 ] ifFalse:[ |
|
1372 last := self lastInGroupStartingAt:idx. |
|
1373 name := (String new:(4+((list at:idx) leftIndent))), name. |
|
1374 ]. |
|
1375 propertyList add:aProperty afterIndex:last. |
|
1376 list add:name afterIndex:last. |
|
1377 self changed:#size |
|
1378 |
|
1379 |
|
1380 ! |
|
1381 |
|
1382 remove:aView |
|
1383 "remove all view relevant resources |
|
1384 " |
|
1385 |start| |
|
1386 |
|
1387 aView notNil ifTrue:[ |
|
1388 start := self findProperty:[:p| p view == aView ]. |
|
1389 |
|
1390 start ~~ 0 ifTrue:[ |
|
1391 self basicRemove:start. |
|
1392 self changed:#size. |
|
1393 ] |
|
1394 ] |
|
1395 ! |
|
1396 |
|
1397 removeAll |
|
1398 masterElement := nil. |
|
1399 self selection:#(). |
|
1400 |
|
1401 [propertyList notEmpty] whileTrue:[ |
|
1402 self basicRemove:1 |
|
1403 ]. |
|
1404 self changed:#size. |
|
1405 |
|
1406 ! ! |
|
1407 |
|
1408 !UIPainterView::ListHolder methodsFor:'change & update'! |
|
1409 |
|
1410 changed:aParameter |
|
1411 "notify all dependents that the receiver has changed somehow. |
|
1412 Each dependent gets a '#update:'-message with aParameter |
|
1413 as argument. In case of disabled no notifications are raised |
|
1414 " |
|
1415 disabledChanged ifFalse:[ |
|
1416 super changed:aParameter |
|
1417 ] |
|
1418 ! |
|
1419 |
|
1420 disableNotificationsWhileEvaluating:aBlock |
|
1421 "perform block without notification; after evaluation of block, |
|
1422 a #size changed notification is raised |
|
1423 " |
|
1424 |oldState| |
|
1425 |
|
1426 oldState := disabledChanged. |
|
1427 disabledChanged := true. |
|
1428 aBlock value. |
|
1429 disabledChanged := oldState. |
|
1430 self changed:#size. |
|
1431 ! |
|
1432 |
|
1433 propertyChanged:aProperty |
|
1434 "property list changed; update list names |
|
1435 " |
|
1436 |list idx oldName newName wspName view indent mid| |
|
1437 |
|
1438 view := aProperty view. |
|
1439 idx := self findProperty:[:p| p view == view ]. |
|
1440 |
|
1441 idx == 0 ifTrue:[ |
|
1442 ^ self error |
|
1443 ]. |
|
1444 |
|
1445 list := self list. |
|
1446 oldName := list at:idx. |
|
1447 wspName := oldName string withoutSeparators. |
|
1448 newName := aProperty name. |
|
1449 |
|
1450 wspName = newName ifFalse:[ |
|
1451 mid := self masterElement. |
|
1452 list at:idx put:((String new:(oldName leftIndent)), newName). |
|
1453 |
|
1454 idx == mid ifTrue:[ |
|
1455 masterElement := nil. |
|
1456 self masterElement:idx |
|
1457 ]. |
|
1458 ]. |
|
1459 self changed:#property |
|
1460 |
|
1461 ! ! |
|
1462 |
|
1463 !UIPainterView::ListHolder methodsFor:'enumerating'! |
|
1464 |
|
1465 propertiesDo:aBlock |
|
1466 "evaluate a block for each property |
|
1467 " |
|
1468 propertyList do:aBlock |
|
1469 ! ! |
|
1470 |
|
1471 !UIPainterView::ListHolder methodsFor:'initialization'! |
|
1472 |
|
1473 for:aPainter |
|
1474 "initialize for a painter |
|
1475 " |
|
1476 painter := aPainter. |
|
1477 disabledChanged := false. |
|
1478 self list:(OrderedCollection new). |
|
1479 propertyList := OrderedCollection new. |
|
1480 self selection:#(). |
|
1481 self addDependent:painter. |
|
1482 |
|
1483 ! ! |
|
1484 |
|
1485 !UIPainterView::ListHolder methodsFor:'private'! |
|
1486 |
|
1487 basicRemove:start |
|
1488 "remove all resources assigned to a group starting at start; |
|
1489 no notifications are raised |
|
1490 " |
|
1491 |end view superView| |
|
1492 |
|
1493 end := self lastInGroupStartingAt:start. |
|
1494 view := (propertyList at:start) view. |
|
1495 |
|
1496 view notNil ifTrue:[ |
|
1497 superView := view superView. |
|
1498 view destroy. |
|
1499 superView sizeChanged:nil. |
|
1500 ]. |
|
1501 |
|
1502 propertyList removeFromIndex:start toIndex:end. |
|
1503 self list removeFromIndex:start toIndex:end. |
|
1504 ! |
|
1505 |
|
1506 masterElement |
|
1507 "returns index of master |
|
1508 " |
|
1509 ^ self indexOfName:masterElement. |
|
1510 ! |
|
1511 |
|
1512 masterElement:newIndex |
|
1513 "change master of selection |
|
1514 " |
|
1515 |name list oldIdx| |
|
1516 |
|
1517 (oldIdx := self masterElement) ~~ newIndex ifTrue:[ |
|
1518 list := self list. |
|
1519 |
|
1520 oldIdx ~~ 0 ifTrue:[ |
|
1521 list at:oldIdx put:masterElement |
|
1522 ]. |
|
1523 newIndex ~~ 0 ifTrue:[ |
|
1524 masterElement := list at:newIndex. |
|
1525 name := Text string:masterElement. |
|
1526 name emphasizeFrom:(1+(name leftIndent)) with:#(#bold #underline). |
|
1527 list at:newIndex put:name. |
|
1528 ] ifFalse:[ |
|
1529 masterElement := nil |
|
1530 ]. |
|
1531 self changed:#list. |
|
1532 ] |
|
1533 ! ! |
|
1534 |
|
1535 !UIPainterView::ListHolder methodsFor:'recomputing'! |
|
1536 |
|
1537 recompute |
|
1538 |list prop size osel| |
|
1539 |
|
1540 osel := self selection copy. |
|
1541 size := self list size. |
|
1542 list := OrderedCollection new:size. |
|
1543 prop := OrderedCollection new:size. |
|
1544 |
|
1545 painter allSubViewsDo:[:v| |
|
1546 size := self indexOfView:v. |
|
1547 |
|
1548 size ~~ 0 ifTrue:[ |
|
1549 list add:(self list at:size). |
|
1550 prop add:(propertyList at:size) |
|
1551 ] |
|
1552 ]. |
|
1553 propertyList := prop. |
|
1554 self list:list. |
|
1555 self selection:osel. |
|
1556 ! ! |
|
1557 |
|
1558 !UIPainterView::ListHolder methodsFor:'searching'! |
|
1559 |
|
1560 detectProperty:aBlock |
|
1561 "find the property, for which evaluation of the argument, aBlock |
|
1562 returns true; return the property or nil if none detected |
|
1563 " |
|
1564 |idx| |
|
1565 |
|
1566 idx := self findProperty:aBlock. |
|
1567 idx ~~ 0 ifTrue:[ ^ propertyList at:idx ]. |
|
1568 ^ nil |
|
1569 ! |
|
1570 |
|
1571 findParentProperty:aChildProp |
|
1572 "returns index of parent or 0 |
|
1573 " |
|
1574 |view index| |
|
1575 |
|
1576 view := aChildProp view. |
|
1577 |
|
1578 view notNil ifTrue:[ |
|
1579 [ (view := view superView) notNil ] whileTrue:[ |
|
1580 index := self findProperty:[:aProp| aProp view == view ]. |
|
1581 index ~~ 0 ifTrue:[ |
|
1582 ^ index |
|
1583 ] |
|
1584 ] |
|
1585 ]. |
|
1586 ^ 0 |
|
1587 |
|
1588 |
|
1589 ! |
|
1590 |
|
1591 findProperty:aBlock |
|
1592 "find the first property, for which evaluation of the argument, aBlock |
|
1593 returns true; return its index or 0 if none detected |
|
1594 " |
|
1595 ^ propertyList findFirst:aBlock |
|
1596 ! |
|
1597 |
|
1598 indexOfName:aString |
|
1599 "returns index assigned to a string or 0 |
|
1600 " |
|
1601 |name list size| |
|
1602 |
|
1603 aString notNil ifTrue:[ |
|
1604 name := aString string withoutSeparators. |
|
1605 size := name size. |
|
1606 list := self list. |
|
1607 |
|
1608 list keysAndValuesDo:[:anIndex :aName| |
|
1609 |el| |
|
1610 |
|
1611 el := aName string. |
|
1612 (el endsWith:name) ifTrue:[ |
|
1613 (el size - el leftIndent) == name size ifTrue:[ |
|
1614 ^ anIndex |
|
1615 ] |
|
1616 ] |
|
1617 ] |
|
1618 ]. |
|
1619 ^ 0 |
|
1620 |
|
1621 ! |
|
1622 |
|
1623 indexOfView:aView |
|
1624 "returns index assigned to a view or 0 |
|
1625 " |
|
1626 aView notNil ifTrue:[ |
|
1627 ^ propertyList findFirst:[:p| p view == aView ] |
|
1628 ]. |
|
1629 ^ 0 |
|
1630 |
|
1631 ! |
|
1632 |
|
1633 lastInGroupStartingAt:start |
|
1634 "returns last index of a group |
|
1635 " |
|
1636 |end list idt| |
|
1637 |
|
1638 list := self list. |
|
1639 |
|
1640 start < list size ifTrue:[ |
|
1641 idt := (list at:start) leftIndent. |
|
1642 end := list findFirst:[:el|(el leftIndent) <= idt] startingAt:(start+1). |
|
1643 end ~~ 0 ifTrue:[ |
|
1644 ^ end - 1 |
|
1645 ] |
|
1646 ]. |
|
1647 ^ list size |
|
1648 ! ! |
|
1649 |
|
1650 !UIPainterView::ListHolder methodsFor:'selection'! |
|
1651 |
|
1652 selectGroup |
|
1653 "select all elements assigned to master |
|
1654 " |
|
1655 |start end sel size| |
|
1656 |
|
1657 painter enabled ifTrue:[ |
|
1658 (start := self masterElement) ~~ 0 ifTrue:[ |
|
1659 end := self lastInGroupStartingAt:start. |
|
1660 size := end - start + 1. |
|
1661 sel := Array new:size. |
|
1662 |
|
1663 1 to:size do:[:i| |
|
1664 sel at:i put:start. |
|
1665 start := start + 1 |
|
1666 ]. |
|
1667 self selectionIndex:sel. |
|
1668 ] ifFalse:[ |
|
1669 (self selectionIndex) size == 0 ifFalse:[ |
|
1670 self selectionIndex:#() |
|
1671 ]. |
|
1672 ] |
|
1673 ] |
|
1674 ! |
|
1675 |
|
1676 selectedProperty |
|
1677 "returns current selected instance; in case of multiple selection |
|
1678 or no selection nil is returned |
|
1679 " |
|
1680 |selection| |
|
1681 selection := self selectionIndex. |
|
1682 |
|
1683 selection size == 1 ifTrue:[ |
|
1684 propertyList size ~~ 0 ifTrue:[ |
|
1685 ^ propertyList at:(selection first) |
|
1686 ] |
|
1687 ]. |
|
1688 ^ nil |
|
1689 ! |
|
1690 |
|
1691 selectionIndex:aList |
|
1692 |masterIndex aSel| |
|
1693 |
|
1694 painter enabled ifTrue:[aSel := aList] |
|
1695 ifFalse:[aSel := nil]. |
|
1696 |
|
1697 aSel size ~~ 0 ifTrue:[masterIndex := aSel at:1] |
|
1698 ifFalse:[masterIndex := 0]. |
|
1699 |
|
1700 self masterElement:masterIndex. |
|
1701 super selectionIndex:aSel |
|
1702 ! ! |
1085 ! ! |
1703 |
1086 |
1704 !UIPainterView::ViewProperty class methodsFor:'instance creation'! |
1087 !UIPainterView::ViewProperty class methodsFor:'instance creation'! |
1705 |
1088 |
1706 new |
1089 new |