135 prop isNil ifTrue:[^ self unselect] |
133 prop isNil ifTrue:[^ self unselect] |
136 ifFalse:[^ self select:(prop view)] |
134 ifFalse:[^ self select:(prop view)] |
137 |
135 |
138 ! ! |
136 ! ! |
139 |
137 |
140 !UIPainterView ignoredMethodsFor:'code manipulation'! |
|
141 |
|
142 changeClass |
|
143 |box classNameHolder superclassNameHolder| |
|
144 |
|
145 classNameHolder := (className ? 'MyClass') asValue. |
|
146 superclassNameHolder := (superclassName ? 'ApplicationModel') asValue. |
|
147 |
|
148 box := DialogBox new. |
|
149 box addTextLabel:'class:'. |
|
150 box addInputFieldOn:classNameHolder. |
|
151 box addTextLabel:'super class:'. |
|
152 box addInputFieldOn:superclassNameHolder. |
|
153 box addAbortButton; addOkButton. |
|
154 |
|
155 box open. |
|
156 |
|
157 box accepted ifTrue:[ |
|
158 className := classNameHolder value. |
|
159 superclassName := superclassNameHolder value. |
|
160 ]. |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 ! |
|
168 |
|
169 changeVariables |
|
170 | box names propList p n newName| |
|
171 |
|
172 names := VariableArray new. |
|
173 propList := VariableArray new. |
|
174 viewProperties do:[:props | |
|
175 n := props name. |
|
176 n notNil ifTrue:[ |
|
177 names add:n. |
|
178 propList add:props |
|
179 ] |
|
180 ]. |
|
181 box := BuilderVariablesBox new. |
|
182 box list:names. |
|
183 box selectAction:[:selection | |
|
184 p := propList at:selection |
|
185 ]. |
|
186 box okAction:[ |
|
187 newName := box enterValue. |
|
188 Transcript showCR:('renamed ' , (p name) , 'to:' , newName). |
|
189 p name:newName |
|
190 ]. |
|
191 box showAtPointer |
|
192 |
|
193 |
|
194 |
|
195 ! ! |
|
196 |
|
197 !UIPainterView methodsFor:'copy & cut & paste'! |
138 !UIPainterView methodsFor:'copy & cut & paste'! |
198 |
139 |
199 copySelection |
140 copySelection |
200 "copy the selection into the cut&paste-buffer |
141 "copy the selection into the cut&paste-buffer |
201 " |
142 " |
203 |
144 |
204 coll := self minSetOfSuperViews:selection. |
145 coll := self minSetOfSuperViews:selection. |
205 |
146 |
206 coll notNil ifTrue:[ |
147 coll notNil ifTrue:[ |
207 self unselect. |
148 self unselect. |
208 specs := self generateSpecFor:coll. |
149 specs := coll collect:[:aView| self fullSpecFor:aView ]. |
209 self setSelection:specs |
150 self setSelection:specs |
210 ]. |
151 ]. |
|
152 |
|
153 |
211 ! |
154 ! |
212 |
155 |
213 deleteSelection |
156 deleteSelection |
214 "delete the selection; copy the selection into the cut&paste-buffer |
157 "delete the selection; copy the selection into the cut&paste-buffer |
215 and open a transaction |
158 and open a transaction |
216 " |
159 " |
217 |text specs newSel| |
160 |text specs coll| |
218 |
161 |
219 newSel := self minSetOfSuperViews:selection. |
162 coll := self minSetOfSuperViews:selection. |
220 |
163 |
221 newSel notNil ifTrue:[ |
164 coll notNil ifTrue:[ |
222 self unselect. |
165 self unselect. |
223 specs := self generateSpecFor:newSel. |
166 specs := coll collect:[:aView| self fullSpecFor:aView ]. |
224 text := self transactionTextFor:newSel. |
167 text := self transactionTextFor:coll. |
225 |
168 |
226 undoHistory transaction:#cut text:text do:[self remove:newSel]. |
169 undoHistory transaction:#cut text:text do:[ |
227 self setSelection:specs |
170 coll reverseDo:[:o||p| |
|
171 (p := self propertyOfView:o) notNil ifTrue:[ |
|
172 self undoRemove:(p identifier) |
|
173 ]. |
|
174 self remove:o |
|
175 ] |
|
176 ]. |
|
177 |
|
178 self setSelection:specs. |
|
179 self changed:#tree. |
228 ] |
180 ] |
229 ! |
181 ! |
230 |
182 |
231 pasteBuffer |
183 pasteBuffer |
232 "add the objects in the paste-buffer to the object view |
184 "add the objects in the paste-buffer to the object view |
233 " |
185 " |
234 |paste builder frame pasteOrigin pasteOffset| |
186 |paste frame pasteOrigin pasteOffset builder| |
235 |
187 |
236 paste := self getSelection. |
188 paste := self getSelection. |
237 |
189 |
238 (self canPaste:paste) ifFalse:[ ^ self]. |
190 (self canPaste:paste) ifFalse:[ ^ self]. |
239 (paste isCollection) ifFalse:[ paste := Array with:paste]. |
191 (paste isCollection) ifFalse:[ paste := Array with:paste]. |
243 (self canPasteInto:frame) ifFalse:[ |
195 (self canPasteInto:frame) ifFalse:[ |
244 frame := self |
196 frame := self |
245 ]. |
197 ]. |
246 self unselect. |
198 self unselect. |
247 |
199 |
248 builder := UIBuilder new. |
|
249 selection := OrderedCollection new. |
200 selection := OrderedCollection new. |
250 pasteOffset := 0@0. |
201 pasteOffset := 0@0. |
251 pasteOrigin := self sensor mousePoint. |
202 pasteOrigin := self sensor mousePoint. |
252 pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id. |
203 pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id. |
|
204 builder := UIBuilder new. |
253 |
205 |
254 paste do:[:aSpec| |
206 paste do:[:aSpec| |
255 |view org| |
207 |view| |
256 |
208 |
257 builder componentCreationHook:[:aView :aSpecification :aBuilder | |
209 view := self addSpec:aSpec builder:builder in:frame. |
258 self createdComponent:aView forSpec:aSpecification builder:aBuilder. |
|
259 ]. |
|
260 builder applicationClass:(Smalltalk classNamed:className). |
|
261 view := aSpec buildViewWithLayoutFor:builder in:frame. |
|
262 |
210 |
263 (frame bounds containsPoint:pasteOrigin) ifFalse:[ |
211 (frame bounds containsPoint:pasteOrigin) ifFalse:[ |
264 self moveObject:view to:pasteOffset. |
212 self moveObject:view to:pasteOffset. |
265 ] ifTrue:[ |
213 ] ifTrue:[ |
266 self moveObject:view to:pasteOrigin + pasteOffset. |
214 self moveObject:view to:pasteOrigin + pasteOffset. |
283 self elementChangedSize:frame. |
231 self elementChangedSize:frame. |
284 self changed:#tree |
232 self changed:#tree |
285 |
233 |
286 ! ! |
234 ! ! |
287 |
235 |
288 !UIPainterView methodsFor:'creating subviews'! |
|
289 |
|
290 addProperties:properties for:aView |
|
291 "set properties to a view and add properties to viewProperties. |
|
292 In case that properties are nil properties are created |
|
293 " |
|
294 |name props| |
|
295 |
|
296 (props := properties) isNil ifTrue:[ |
|
297 props := self propertiesForNewView:aView. |
|
298 ]. |
|
299 |
|
300 viewProperties add:props. |
|
301 name := props name. |
|
302 |
|
303 aView specClass supportsLabel ifTrue:[ |
|
304 aView label:name |
|
305 ]. |
|
306 aView name:name. |
|
307 ^ props |
|
308 ! |
|
309 |
|
310 propertiesForNewView:aView |
|
311 "generate property for a view and return properties |
|
312 " |
|
313 |cls props index| |
|
314 |
|
315 cls := aView class. |
|
316 |
|
317 props := ViewProperty new. |
|
318 props view:aView. |
|
319 props elementClass:cls. |
|
320 index := self variableIndexForClass:cls. |
|
321 props nameIndex:index. |
|
322 props name:(self variableNameForClass:cls index:index). |
|
323 |
|
324 ^ props |
|
325 ! |
|
326 |
|
327 setupCreatedObject:anObject |
|
328 "set default properties for a created object |
|
329 " |
|
330 |props| |
|
331 |
|
332 props := self addProperties:nil for:anObject. |
|
333 |
|
334 undoHistory transaction:#create text:(props name) do:[ |
|
335 self undoCreate:(props identifier). |
|
336 ]. |
|
337 ! ! |
|
338 |
|
339 !UIPainterView methodsFor:'drag & drop'! |
236 !UIPainterView methodsFor:'drag & drop'! |
340 |
237 |
341 canDrop:anObjectOrCollection |
238 canDrop:anObjectOrCollection |
342 Transcript showCR:'canDrop'. |
239 Transcript showCR:'canDrop'. |
343 ^ true |
240 ^ true |
349 Transcript showCR:'drop:anObjectOrCollection at:aPoint'. |
246 Transcript showCR:'drop:anObjectOrCollection at:aPoint'. |
350 |
247 |
351 |
248 |
352 ! ! |
249 ! ! |
353 |
250 |
354 !UIPainterView methodsFor:'event handling'! |
|
355 |
|
356 keyPress:key x:x y:y |
|
357 "any key pressed |
|
358 " |
|
359 <resource: #keyboard ( #Copy #Paste) > |
|
360 |
|
361 key == #Copy ifTrue:[ |
|
362 ^ self copySelection |
|
363 ]. |
|
364 |
|
365 key == #Paste ifTrue:[ |
|
366 ^ self pasteBuffer |
|
367 ]. |
|
368 |
|
369 super keyPress:key x:x y:y |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 ! ! |
|
376 |
|
377 !UIPainterView methodsFor:'generating output'! |
251 !UIPainterView methodsFor:'generating output'! |
|
252 |
|
253 XXgenerateWindowSpecMethodSource |
|
254 |spec specArray str code| |
|
255 |
|
256 subViews remove:inputView. |
|
257 [ |
|
258 spec := FullSpec fromView:self |
|
259 ] valueNowOrOnUnwindDo:[ |
|
260 subViews addFirst:inputView. |
|
261 ]. |
|
262 specArray := spec literalArrayEncoding. |
|
263 |
|
264 str := WriteStream on:String new. |
|
265 self prettyPrintSpecArray:specArray on:str indent:5. |
|
266 |
|
267 code := Character excla asString |
|
268 , className , ' class methodsFor:''interface specs''' |
|
269 , Character excla asString , '\\' |
|
270 |
|
271 , methodName , '\' |
|
272 , ' "this window spec was automatically generated by the ST/X UIPainter"\\' |
|
273 , ' "do not manually edit this - the painter/builder may not be able to\' |
|
274 , ' handle the specification if its corrupted."\\' |
|
275 , ' "\' |
|
276 , ' UIPainter new openOnClass:' , className , ' andSelector:#' , methodName , '\' |
|
277 , ' ' , className , ' new openInterface:#' , methodName , '\' |
|
278 , ' "\'. |
|
279 |
|
280 methodName = 'windowSpec' ifTrue:[ |
|
281 code := code , ' "' , className , ' open"\' |
|
282 ]. |
|
283 code := code |
|
284 , '\' |
|
285 , ' <resource: #canvas>\\' |
|
286 , ' ^\' |
|
287 , ' ', str contents |
|
288 , '\' |
|
289 , Character excla asString |
|
290 , ' ' |
|
291 , Character excla asString |
|
292 , '\\'. |
|
293 |
|
294 ^ code withCRs |
|
295 |
|
296 "Modified: 5.9.1995 / 21:01:35 / claus" |
|
297 ! |
378 |
298 |
379 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
299 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
380 ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
300 ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
381 aspect , '\' , |
301 aspect , '\' , |
382 ' "automatically generated by UIPainter ..."\' , |
302 ' "automatically generated by UIPainter ..."\' , |
401 ! |
321 ! |
402 |
322 |
403 generateAspectMethods |
323 generateAspectMethods |
404 |cls code| |
324 |cls code| |
405 |
325 |
|
326 code := ''. |
|
327 |
406 className isNil ifTrue:[ |
328 className isNil ifTrue:[ |
407 self warn:'set the class first'. |
329 self warn:'set the class first'. |
408 ^ '' |
330 ^ code |
409 ]. |
331 ]. |
410 "/ (cls := Smalltalk at:className asSymbol) isNil ifTrue:[ |
|
411 "/ self warn:'create the class first'. |
|
412 "/ ^ '' |
|
413 "/ ]. |
|
414 |
|
415 code := ''. |
|
416 |
332 |
417 viewProperties do:[:aProp | |
333 viewProperties do:[:aProp | |
418 |modelSelector menuSelector protoSpec thisCode| |
334 |modelSelector menuSelector protoSpec thisCode| |
419 |
335 |
420 (modelSelector := aProp aspectSelector) notNil ifTrue:[ |
336 (modelSelector := aProp model) notNil ifTrue:[ |
421 (cls implements:modelSelector asSymbol) ifFalse:[ |
337 (cls implements:modelSelector asSymbol) ifFalse:[ |
422 protoSpec := aProp view specClass basicNew. |
338 protoSpec := aProp view specClass basicNew. |
423 "/ kludge .. |
339 "/ kludge .. |
424 (protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
340 (protoSpec isMemberOf:ActionButtonSpec) ifTrue:[ |
425 thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
341 thisCode := (self generateActionMethodFor:modelSelector spec:protoSpec inClass:cls). |
543 code := ''. |
459 code := ''. |
544 |
460 |
545 p := self propertyOfView:aView. |
461 p := self propertyOfView:aView. |
546 name := p at:#variableName. |
462 name := p at:#variableName. |
547 c := ' ' , name , ' := ' , |
463 c := ' ' , name , ' := ' , |
548 (aView class name) , ' in:' , (self variableNameOf:(aView superView)) , '.\'. |
464 (aView class name) , ' in:' , (self uniqueNameOf:(aView superView)) , '.\'. |
549 |
465 |
550 " <name> origin:(...) extent:(...)" |
466 " <name> origin:(...) extent:(...)" |
551 |
467 |
552 c := c , ' ' , name , ' origin:(', aView origin printString , ')' |
468 c := c , ' ' , name , ' origin:(', aView origin printString , ')' |
553 , ' extent:(', aView extent printString , ').\'. |
469 , ' extent:(', aView extent printString , ').\'. |
645 ^ self |
561 ^ self |
646 ! ! |
562 ! ! |
647 |
563 |
648 !UIPainterView methodsFor:'generating output'! |
564 !UIPainterView methodsFor:'generating output'! |
649 |
565 |
650 generateSpecFor:something |
|
651 "generate a spec for a view or collection of views |
|
652 " |
|
653 |spec views| |
|
654 |
|
655 something notNil ifTrue:[ |
|
656 something isCollection ifTrue:[views := something] |
|
657 ifFalse:[views := Array with:something]. |
|
658 |
|
659 spec := views collect:[:aView||topSpec| |
|
660 aView specClass isNil ifTrue:[ |
|
661 ^ nil |
|
662 ]. |
|
663 |
|
664 topSpec := aView specClass |
|
665 fromView:aView |
|
666 callBack:[:newSpec :view | self stuffPropertiesFrom:view intoSpec:newSpec]. |
|
667 topSpec |
|
668 ] |
|
669 ]. |
|
670 ^ spec |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 ! |
|
678 |
|
679 generateWindowSpecMethodSource |
566 generateWindowSpecMethodSource |
680 |spec specArray str code| |
567 |t s spec specArray str code| |
681 |
568 |
682 subViews remove:inputView. |
569 specArray := OrderedCollection new. |
683 [ |
570 |
684 spec := FullSpec fromView:self callBack:[:newSpec :view | self stuffPropertiesFrom:view intoSpec:newSpec]. |
571 self subViews do:[:aView| |
685 ] valueNowOrOnUnwindDo:[ |
572 aView ~~ inputView ifTrue:[ |
686 subViews addFirst:inputView. |
573 specArray add:(self fullSpecFor:aView) |
687 ]. |
574 ] |
|
575 ]. |
|
576 spec := FullSpec new. |
|
577 spec fromBuilder:self components:(SpecCollection new collection:specArray). |
688 specArray := spec literalArrayEncoding. |
578 specArray := spec literalArrayEncoding. |
689 |
579 |
690 str := WriteStream on:String new. |
580 str := WriteStream on:String new. |
691 self prettyPrintSpecArray:specArray on:str indent:5. |
581 self prettyPrintSpecArray:specArray on:str indent:5. |
692 |
582 |
828 |
718 |
829 storeContentsOn:aStream |
719 storeContentsOn:aStream |
830 viewProperties do:[:p| p storeOn:aStream] |
720 viewProperties do:[:p| p storeOn:aStream] |
831 ! |
721 ! |
832 |
722 |
833 stuffPropertiesFrom:view intoSpec:newSpec |
|
834 "stuff any additional information (held in the properties) into the spec |
|
835 which was just created from view" |
|
836 |
|
837 |props aspectSelector changeSelector labelSelector name tabable defaultable |
|
838 menuSelector initiallyInvisible| |
|
839 |
|
840 props := self propertyOfView:view. |
|
841 props isNil ifTrue:[^ self]. |
|
842 |
|
843 (aspectSelector := props aspectSelector) notNil ifTrue:[ |
|
844 newSpec model:aspectSelector |
|
845 ]. |
|
846 (changeSelector := props changeSelector) notNil ifTrue:[ |
|
847 newSpec change:changeSelector |
|
848 ]. |
|
849 (menuSelector := props menuSelector) notNil ifTrue:[ |
|
850 newSpec menu:menuSelector |
|
851 ]. |
|
852 (labelSelector := props labelSelector) notNil ifTrue:[ |
|
853 newSpec label:labelSelector |
|
854 ]. |
|
855 (tabable := props tabable) == true ifTrue:[ |
|
856 newSpec tabable:tabable |
|
857 ]. |
|
858 (defaultable := props defaultable) notNil ifTrue:[ |
|
859 newSpec defaultable:defaultable |
|
860 ]. |
|
861 (initiallyInvisible := props initiallyInvisible) notNil ifTrue:[ |
|
862 newSpec initiallyInvisible:initiallyInvisible |
|
863 ]. |
|
864 (name := props name) notNil ifTrue:[ |
|
865 newSpec name:name |
|
866 ]. |
|
867 |
|
868 ! ! |
|
869 |
|
870 !UIPainterView ignoredMethodsFor:'generating output'! |
|
871 |
|
872 subviewVariableNames |
|
873 |names| |
|
874 |
|
875 names := ''. |
|
876 viewProperties do:[:p| names := names , ' ' , (p name)]. |
|
877 ^ names |
|
878 ! ! |
|
879 |
|
880 !UIPainterView methodsFor:'generating output'! |
|
881 |
|
882 subviewsOf:aView do:aBlock |
723 subviewsOf:aView do:aBlock |
883 |subs v| |
724 |subs v| |
884 |
725 |
885 (subs := aView subViews) notNil ifTrue:[ |
726 (subs := aView subViews) notNil ifTrue:[ |
886 subs do:[:v| |
727 subs do:[:v| |
897 ! ! |
738 ! ! |
898 |
739 |
899 !UIPainterView methodsFor:'group manipulations'! |
740 !UIPainterView methodsFor:'group manipulations'! |
900 |
741 |
901 groupEnterFields |
742 groupEnterFields |
902 |props name index group objects| |
743 |props group objects| |
903 |
744 |
904 selection isNil ifTrue:[^ self]. |
745 selection isNil ifTrue:[^ self]. |
905 self selectionDo:[:aView | |
746 self selectionDo:[:aView | |
906 (aView isKindOf:EditField) ifFalse:[ |
747 (aView isKindOf:EditField) ifFalse:[ |
907 self warn:'select EditFields only !!'. |
748 self warn:'select EditFields only !!'. |
908 ^ self |
749 ^ self |
909 ] |
750 ] |
910 ]. |
751 ]. |
911 self withSelectionHiddenDo:[ |
752 self withSelectionHiddenDo:[ |
912 group := EnterFieldGroup new. |
753 group := EnterFieldGroup new. |
913 |
|
914 props := GroupProperties new. |
754 props := GroupProperties new. |
915 props elementClass:EnterFieldGroup. |
755 name := self uniqueNameFor:EnterFieldGroup. |
916 props group:group. |
756 props group:group. |
917 index := self variableIndexForClass:EnterFieldGroup. |
|
918 props nameIndex:index. |
|
919 name := self variableNameForClass:EnterFieldGroup index:index. |
|
920 props name:name. |
757 props name:name. |
|
758 group groupID:name asSymbol. |
921 objects := OrderedCollection new. |
759 objects := OrderedCollection new. |
922 props controlledObjects:objects. |
760 props controlledObjects:objects. |
923 viewProperties add:props. |
761 viewProperties add:props. |
924 |
762 |
925 self selectionDo:[:aView | |
763 self selectionDo:[:aView | |
930 |
768 |
931 |
769 |
932 ! |
770 ! |
933 |
771 |
934 groupRadioButtons |
772 groupRadioButtons |
935 |props name index group objects| |
773 |props name group objects| |
936 |
774 |
937 selection isNil ifTrue:[^ self]. |
775 selection isNil ifTrue:[^ self]. |
938 self selectionDo:[:aView | |
776 self selectionDo:[:aView | |
939 (aView isKindOf:RadioButton) ifFalse:[ |
777 (aView isKindOf:RadioButton) ifFalse:[ |
940 self warn:'select RadioButtons only !!'. |
778 self warn:'select RadioButtons only !!'. |
941 ^ self |
779 ^ self |
942 ] |
780 ] |
943 ]. |
781 ]. |
944 self withSelectionHiddenDo:[ |
782 self withSelectionHiddenDo:[ |
945 group := RadioButtonGroup new. |
783 group := RadioButtonGroup new. |
946 |
|
947 props := GroupProperties new. |
784 props := GroupProperties new. |
948 props elementClass:RadioButtonGroup. |
785 name := self uniqueNameFor:RadioButtonGroup. |
949 props group:group. |
786 props group:group. |
950 index := self variableIndexForClass:RadioButtonGroup. |
|
951 props nameIndex:index. |
|
952 name := self variableNameForClass:RadioButtonGroup index:index. |
|
953 props name:name. |
787 props name:name. |
954 group groupID:name asSymbol. |
788 group groupID:name asSymbol. |
955 objects := OrderedCollection new. |
789 objects := OrderedCollection new. |
956 props controlledObjects:objects. |
790 props controlledObjects:objects. |
957 viewProperties add:props. |
791 viewProperties add:props. |
979 categoryName := 'Applications'. |
813 categoryName := 'Applications'. |
980 viewProperties := OrderedCollection new. |
814 viewProperties := OrderedCollection new. |
981 HandCursor := Cursor leftHand. |
815 HandCursor := Cursor leftHand. |
982 |
816 |
983 "Modified: 5.9.1995 / 19:58:06 / claus" |
817 "Modified: 5.9.1995 / 19:58:06 / claus" |
984 ! ! |
818 ! |
985 |
819 |
986 !UIPainterView methodsFor:'interface to Builder'! |
820 initializeCreatedObject:anObject |
987 |
821 "set default properties for a created object |
988 addOutletDefinitionFor:outletSymbol type:type value:outletValue for:aView |
822 " |
989 |outletProps selectorProps viewProps| |
823 |props spec cls| |
990 |
824 |
991 viewProps := self propertyOfView:aView. |
825 cls := anObject class. |
992 "/ outletProps := viewProps at:#outlets ifAbsent:[nil]. |
826 spec := anObject specClass fromView:anObject. |
993 "/ outletProps isNil ifTrue:[ |
827 props := ViewProperty new. |
994 "/ outletProps := Dictionary new. |
828 props view:anObject. |
995 "/ viewProps at:#outlets put:outletProps |
829 props spec:spec. |
996 "/ ]. |
830 props name:(self uniqueNameFor:cls). |
997 "/ selectorProps := outletProps at:outletSymbol ifAbsent:[nil]. |
831 viewProperties add:props. |
998 "/ selectorProps isNil ifTrue:[ |
832 |
999 "/ selectorProps := Dictionary new. |
833 ((anObject respondsTo:#label:) and:[(spec respondsTo:#label:)]) ifTrue:[ |
1000 "/ outletProps at:outletSymbol put:selectorProps |
834 anObject label:(props name). |
1001 "/ ]. |
835 spec label:(props name) |
1002 "/ |
836 ]. |
1003 "/ selectorProps at:#selector put:outletSymbol. |
837 |
1004 "/ selectorProps at:#type put:type. |
838 undoHistory transaction:#create text:(props name) do:[ |
1005 "/ selectorProps at:#value put:outletValue |
839 self undoCreate:(props identifier). |
1006 |
840 ]. |
1007 ! |
841 ! |
1008 |
842 |
1009 addSpec:specOrSpecArray |
843 setupFromSpec:specOrSpecArray |
1010 |spec builder| |
844 |spec builder| |
1011 |
845 |
1012 spec := UISpecification from:specOrSpecArray. |
846 self removeAll. |
1013 |
847 spec := UISpecification from:specOrSpecArray. |
1014 builder := UIBuilder new. |
848 builder := UIBuilder new. |
1015 builder componentCreationHook:[:view :spec :aBuilder | |
849 spec window setupView:self topView for:builder. |
1016 self createdComponent:view forSpec:spec builder:aBuilder |
850 self addSpec:(spec component) builder:builder in:self. |
1017 ]. |
|
1018 builder applicationClass:(Smalltalk classNamed:className). |
|
1019 spec setupView:self for:builder. |
|
1020 |
|
1021 self realizeAllSubViews. |
851 self realizeAllSubViews. |
1022 inputView raise. |
852 inputView raise. |
1023 |
|
1024 "/ viewProperties := OrderedCollection new. |
|
1025 "/ self generatePropertiesFor:(self subViews select:[:v | v ~~ inputView]). |
|
1026 |
|
1027 self changed:#tree. |
853 self changed:#tree. |
1028 |
|
1029 |
|
1030 "Modified: 5.9.1995 / 23:36:55 / claus" |
|
1031 ! |
|
1032 |
|
1033 applicationName |
|
1034 ^ className |
|
1035 ! |
|
1036 |
|
1037 aspectAt:aSymbol |
|
1038 self halt. |
|
1039 ^ nil |
|
1040 |
|
1041 "Modified: 6.9.1995 / 00:45:35 / claus" |
|
1042 ! |
|
1043 |
|
1044 createdComponent:newView forSpec:aSpec builder:aBuilder |
|
1045 "callBack from UISpec view building" |
|
1046 |
|
1047 |props| |
|
1048 |
|
1049 props := self propertiesForNewView:newView. |
|
1050 |
|
1051 aSpec name notNil ifTrue:[ |
|
1052 (self propertyOfName:(aSpec name)) isNil ifTrue:[ |
|
1053 props name:aSpec name |
|
1054 ] |
|
1055 ]. |
|
1056 |
|
1057 props labelSelector:(aSpec labelSelector). |
|
1058 props aspectSelector:(aSpec modelSelector). |
|
1059 props menuSelector:(aSpec menuSelector). |
|
1060 props tabable:(aSpec tabable). |
|
1061 props defaultable:(aSpec defaultable). |
|
1062 props initiallyInvisible:(aSpec initiallyInvisible). |
|
1063 |
|
1064 viewProperties add:props. |
|
1065 ! |
|
1066 |
|
1067 generatePropertiesFor:aCollectionOfViews |
|
1068 |
|
1069 "/ done as two loops, to get bread-first naming |
|
1070 |
|
1071 aCollectionOfViews do:[:aView| |
|
1072 |props| |
|
1073 |
|
1074 props := self propertiesForNewView:aView. |
|
1075 viewProperties add:props. |
|
1076 aView name:(props name). |
|
1077 |
|
1078 aView geometryLayout isNil ifTrue:[ |
|
1079 aView geometryLayout:(aView bounds asLayout). |
|
1080 ] |
|
1081 ]. |
|
1082 |
|
1083 aCollectionOfViews do:[:aView | |
|
1084 |subs| |
|
1085 |
|
1086 subs := aView subViews. |
|
1087 subs notNil ifTrue:[ |
|
1088 self generatePropertiesFor:subs |
|
1089 ] |
|
1090 ]. |
|
1091 |
|
1092 ! |
|
1093 |
|
1094 inspectAttributes |
|
1095 |p| |
|
1096 |
|
1097 self singleSelectionDo:[:aView | |
|
1098 p := self propertyOfView:aView. |
|
1099 p inspect |
|
1100 ] |
|
1101 ! |
|
1102 |
|
1103 inspectSpec |
|
1104 |s| |
|
1105 |
|
1106 self singleSelectionDo:[:aView | |
|
1107 s := self generateSpecFor:aView. |
|
1108 s first inspect |
|
1109 ] |
|
1110 ! |
|
1111 |
|
1112 setupFromSpec:specOrSpecArray |
|
1113 self removeAll. |
|
1114 self addSpec:specOrSpecArray |
|
1115 ! |
|
1116 |
|
1117 showFontPanel |
|
1118 |action| |
|
1119 |
|
1120 fontPanel isNil ifTrue:[ |
|
1121 fontPanel := FontPanel new |
|
1122 ]. |
|
1123 |
|
1124 selection notNil ifTrue:[ |
|
1125 action := [:family :face :style :size | |
|
1126 self changeFontFamily:family face:face |
|
1127 style:style size:size |
|
1128 ]. |
|
1129 fontPanel action:action. |
|
1130 fontPanel showAtPointer |
|
1131 ] |
|
1132 ! ! |
854 ! ! |
1133 |
855 |
1134 !UIPainterView methodsFor:'menus'! |
856 !UIPainterView methodsFor:'menus'! |
1135 |
857 |
1136 menu |
858 menu |
1352 ]. |
1091 ]. |
1353 self changed:#any. |
1092 self changed:#any. |
1354 ] |
1093 ] |
1355 |
1094 |
1356 "Modified: 5.9.1995 / 12:13:27 / claus" |
1095 "Modified: 5.9.1995 / 12:13:27 / claus" |
1357 ! |
|
1358 |
|
1359 changeVariableNameOf:aView to:newName |
|
1360 |prop| |
|
1361 |
|
1362 prop := self propertyOf:aView. |
|
1363 |
|
1364 prop isNil ifTrue:[ |
|
1365 ^ self error:'no such view' |
|
1366 ]. |
|
1367 |
|
1368 ((aView respondsTo:#label:) and:[aView label = prop name]) ifTrue:[ |
|
1369 self withSelectionHiddenDo:[ |
|
1370 |layout| |
|
1371 layout := aView geometryLayout copy. |
|
1372 aView label:newName. |
|
1373 aView geometryLayout:layout. |
|
1374 ] |
|
1375 ]. |
|
1376 |
|
1377 prop name:newName. |
|
1378 aView name:newName. |
|
1379 self changed:#widgetName |
|
1380 |
|
1381 |
|
1382 |
|
1383 ! |
|
1384 |
|
1385 variableIndexForClass:aClass |
|
1386 |max| |
|
1387 |
|
1388 max := 0. |
|
1389 |
|
1390 viewProperties do:[:p| |
|
1391 p elementClass == aClass ifTrue:[ |
|
1392 max := max max:(p nameIndex) |
|
1393 ] |
|
1394 ]. |
|
1395 ^ max + 1 |
|
1396 |
|
1397 ! |
|
1398 |
|
1399 variableNameForClass:aClass index:index |
|
1400 |n| |
|
1401 |
|
1402 n := (aClass name) , index printString. |
|
1403 n at:1 put:(n at:1) asLowercase. |
|
1404 ^ n |
|
1405 |
|
1406 ! |
|
1407 |
|
1408 variableNameOf:aView |
|
1409 |prop| |
|
1410 |
|
1411 aView notNil ifTrue:[ |
|
1412 prop := self propertyOf:aView |
|
1413 ]. |
|
1414 |
|
1415 prop notNil ifTrue:[^ prop name] |
|
1416 ifFalse:[^ 'self'] |
|
1417 |
|
1418 ! ! |
1096 ! ! |
1419 |
1097 |
1420 !UIPainterView methodsFor:'removing components'! |
1098 !UIPainterView methodsFor:'removing components'! |
1421 |
1099 |
1422 remove:something |
1100 remove:anObject |
1423 "remove something, anObject or a collection of objects from the contents do redraw |
1101 "remove anObject from the contents do redraw |
1424 " |
1102 " |
1425 self forEach:something do:[:anObject | |
1103 |props| |
1426 self removeObject:anObject |
1104 |
|
1105 anObject notNil ifTrue:[ |
|
1106 (anObject subViews notNil) ifTrue:[ |
|
1107 anObject subViews copy do:[:sub | |
|
1108 self remove:sub |
|
1109 ] |
|
1110 ]. |
|
1111 (props := self propertyOfView:anObject) notNil ifTrue:[ |
|
1112 viewProperties remove:props ifAbsent:nil |
|
1113 ]. |
|
1114 anObject destroy |
1427 ] |
1115 ] |
1428 |
|
1429 |
|
1430 ! |
1116 ! |
1431 |
1117 |
1432 removeAll |
1118 removeAll |
1433 "remove all objects and properties |
1119 "remove all objects and properties |
1434 " |
1120 " |
1436 viewProperties := OrderedCollection new. |
1122 viewProperties := OrderedCollection new. |
1437 |
1123 |
1438 subViews notNil ifTrue:[ |
1124 subViews notNil ifTrue:[ |
1439 subViews copy do:[:sub | |
1125 subViews copy do:[:sub | |
1440 sub ~~ inputView ifTrue:[ |
1126 sub ~~ inputView ifTrue:[ |
1441 self removeTreeFrom:sub |
1127 self remove:sub |
1442 ] |
1128 ] |
1443 ] |
1129 ] |
1444 ]. |
1130 ]. |
1445 undoHistory reinitialize. |
1131 undoHistory reinitialize. |
1446 self changed:#tree |
1132 self changed:#tree |
1447 ! |
|
1448 |
|
1449 removeObject:anObject |
|
1450 "remove the argument, anObject |
|
1451 " |
|
1452 |spec prop| |
|
1453 |
|
1454 undoHistory isTransactionOpen ifTrue:[ |
|
1455 (prop := self propertyOfView:anObject) notNil ifTrue:[ |
|
1456 self undoRemove:(prop identifier) |
|
1457 ] |
|
1458 ]. |
|
1459 self removeTreeFrom:anObject. |
|
1460 self changed:#tree |
|
1461 ! |
|
1462 |
|
1463 removeTreeFrom:anObject |
|
1464 "remove the argument, anObject and all of its subviews |
|
1465 " |
|
1466 |props| |
|
1467 |
|
1468 anObject notNil ifTrue:[ |
|
1469 (anObject subViews notNil) ifTrue:[ |
|
1470 anObject subViews copy do:[:sub | |
|
1471 self removeTreeFrom:sub |
|
1472 ] |
|
1473 ]. |
|
1474 props := self propertyOf:anObject. |
|
1475 |
|
1476 props notNil ifTrue:[ |
|
1477 viewProperties remove:props ifAbsent:nil |
|
1478 ]. |
|
1479 anObject destroy |
|
1480 ] |
|
1481 ! ! |
1133 ! ! |
1482 |
1134 |
1483 !UIPainterView methodsFor:'searching'! |
1135 !UIPainterView methodsFor:'searching'! |
1484 |
1136 |
1485 findObjectAt:aPoint |
1137 findObjectAt:aPoint |
1506 |
1158 |
1507 prop := self propertyOfIdentifier:aViewId. |
1159 prop := self propertyOfIdentifier:aViewId. |
1508 |
1160 |
1509 prop notNil ifTrue:[^ prop view] |
1161 prop notNil ifTrue:[^ prop view] |
1510 ifFalse:[^ nil] |
1162 ifFalse:[^ nil] |
|
1163 ! |
|
1164 |
|
1165 propertyOfGroup:aGroup |
|
1166 "returns property assigned to group |
|
1167 " |
|
1168 ^ viewProperties detect:[:p| p group == aGroup] ifNone:nil |
|
1169 ! |
|
1170 |
|
1171 propertyOfIdentifier:anId |
|
1172 "returns property assigned to unique identifier |
|
1173 " |
|
1174 anId notNil ifTrue:[ |
|
1175 ^ viewProperties detect:[:p| p identifier == anId] ifNone:nil. |
|
1176 ]. |
|
1177 ^ nil |
|
1178 ! |
|
1179 |
|
1180 propertyOfName:aString |
|
1181 "returns property assigned to name |
|
1182 " |
|
1183 aString = 'self' ifFalse:[ |
|
1184 ^ viewProperties detect:[:p| p name = aString] ifNone:nil |
|
1185 ]. |
|
1186 ^ nil |
|
1187 ! |
|
1188 |
|
1189 propertyOfView:aView |
|
1190 "returns property assigned to view |
|
1191 " |
|
1192 (aView isNil or:[aView == self]) ifFalse:[ |
|
1193 ^ viewProperties detect:[:p| p view == aView] ifNone:nil |
|
1194 ]. |
|
1195 ^ nil |
|
1196 ! |
|
1197 |
|
1198 uniqueNameFor:aClass |
|
1199 "generate and return an unique name for a class |
|
1200 " |
|
1201 |next name size| |
|
1202 |
|
1203 next := 0. |
|
1204 name := aClass name asString copy. |
|
1205 size := name size + 1. |
|
1206 |
|
1207 name at:1 put:(name at:1) asLowercase. |
|
1208 |
|
1209 viewProperties do:[:p||n| |
|
1210 n := p name. |
|
1211 |
|
1212 (n size >= size and:[n startsWith:name]) ifTrue:[ |
|
1213 next := next max:(p extractNumberStartingAt:size) |
|
1214 ] |
|
1215 ]. |
|
1216 next := next + 1. |
|
1217 name := name, next printString. |
|
1218 ^ name |
|
1219 |
|
1220 |
|
1221 |
|
1222 ! |
|
1223 |
|
1224 uniqueNameOf:aView |
|
1225 |prop| |
|
1226 |
|
1227 aView notNil ifTrue:[ |
|
1228 prop := self propertyOfView:aView |
|
1229 ]. |
|
1230 |
|
1231 prop notNil ifTrue:[^ prop name] |
|
1232 ifFalse:[^ 'self'] |
1511 ! ! |
1233 ! ! |
1512 |
1234 |
1513 !UIPainterView methodsFor:'selection'! |
1235 !UIPainterView methodsFor:'selection'! |
1514 |
1236 |
1515 addTreeFrom:aView to:aCollection |
1237 addTreeFrom:aView to:aCollection |
1516 "add aView and contained subcomponents to collection |
1238 "add aView and contained subcomponents to collection |
1517 " |
1239 " |
1518 (self propertyOf:aView) notNil ifTrue:[ |
1240 (self propertyOfView:aView) notNil ifTrue:[ |
1519 aCollection add:aView. |
1241 aCollection add:aView. |
1520 |
1242 |
1521 (aView subViews notNil) ifTrue:[ |
1243 (aView subViews notNil) ifTrue:[ |
1522 aView subViews do:[:subView| |
1244 aView subViews do:[:subView| |
1523 self addTreeFrom:subView to:aCollection |
1245 self addTreeFrom:subView to:aCollection |
1553 ]. |
1275 ]. |
1554 self changed:#selection |
1276 self changed:#selection |
1555 ] |
1277 ] |
1556 ! ! |
1278 ! ! |
1557 |
1279 |
1558 !UIPainterView methodsFor:'seraching property'! |
1280 !UIPainterView methodsFor:'specification'! |
1559 |
1281 |
1560 propertyOf:something |
1282 addSpec:aSpecification builder:aBuilder in:aFrame |
1561 "returns property assigned to group or view |
1283 "build view and subviews from aSpecification into a frame. The top view |
1562 " |
1284 is returned. The contained components of a spec are set to nil |
1563 ^ viewProperties detect:[:p| (p view == something or:[p group == something])] |
1285 " |
1564 ifNone:nil |
1286 aBuilder applicationClass:(Smalltalk classNamed:className). |
1565 |
1287 |
1566 |
1288 aBuilder componentCreationHook:[:aView :aSpec :aBdr||sv p s| |
1567 |
1289 p := ViewProperty new. |
1568 |
1290 s := aSpec copy. |
1569 |
1291 p spec:s. |
1570 ! |
1292 p view:aView. |
1571 |
1293 |
1572 propertyOfGroup:aGroup |
1294 s class supportsSubComponents ifTrue:[ |
1573 "returns property assigned to group |
1295 s component:nil |
1574 " |
1296 ]. |
1575 ^ viewProperties detect:[:p| p group == aGroup] ifNone:nil |
1297 |
1576 ! |
1298 (self propertyOfName:(s name)) notNil ifTrue:[ |
1577 |
1299 s name:(self uniqueNameFor:(aView class)) |
1578 propertyOfIdentifier:anId |
1300 ]. |
1579 "returns property assigned to unique identifier |
1301 viewProperties add:p |
1580 " |
1302 ]. |
1581 anId notNil ifTrue:[ |
1303 |
1582 ^ viewProperties detect:[:p| p identifier == anId] ifNone:nil. |
1304 ^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
1583 ]. |
1305 |
1584 ^ nil |
1306 ! |
1585 ! |
1307 |
1586 |
1308 fullSpecFor:anObject |
1587 propertyOfName:aString |
1309 "generate a full spec for an object |
1588 "returns property assigned to name |
1310 " |
1589 " |
1311 |mySpec subSpecs| |
1590 aString = 'self' ifFalse:[ |
1312 |
1591 ^ viewProperties detect:[:p| p name = aString] ifNone:nil |
1313 mySpec := self specFor:anObject. |
1592 ]. |
1314 |
1593 ^ nil |
1315 (mySpec notNil and:[mySpec class supportsSubComponents]) ifTrue:[ |
1594 ! |
1316 (anObject subViews notNil) ifTrue:[ |
1595 |
1317 anObject subViews do:[:aSubView||spec| |
1596 propertyOfView:aView |
1318 spec := self fullSpecFor:aSubView. |
1597 "returns property assigned to view |
1319 spec notNil ifTrue:[ |
1598 " |
1320 subSpecs isNil ifTrue:[ |
1599 (aView isNil or:[aView == self]) ifFalse:[ |
1321 subSpecs := OrderedCollection new |
1600 ^ viewProperties detect:[:p| p view == aView] ifNone:nil |
1322 ]. |
1601 ]. |
1323 subSpecs add:spec. |
1602 ^ nil |
1324 ]. |
|
1325 ]. |
|
1326 subSpecs notNil ifTrue:[ |
|
1327 mySpec component:(SpecCollection new collection:subSpecs) |
|
1328 ] |
|
1329 ] |
|
1330 ]. |
|
1331 ^ mySpec |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 ! |
|
1339 |
|
1340 specFor:anObject |
|
1341 "returns spec assigned to an object |
|
1342 " |
|
1343 |prop spec| |
|
1344 |
|
1345 (prop := self propertyOfView:anObject) notNil ifTrue:[ |
|
1346 spec := prop spec copy. |
|
1347 spec layoutFromView:anObject |
|
1348 ]. |
|
1349 ^ spec |
|
1350 |
|
1351 |
|
1352 |
|
1353 ! |
|
1354 |
|
1355 updateFromSpec:aSpec |
|
1356 "update current selected view from specification |
|
1357 " |
|
1358 |props name builder v| |
|
1359 |
|
1360 self singleSelection notNil ifTrue:[ |
|
1361 self withSelectionHiddenDo:[ |
|
1362 self transaction:#specification selectionDo:[:aView| |
|
1363 builder := UIBuilder new. |
|
1364 props := self propertyOfView:aView. |
|
1365 name := aSpec name. |
|
1366 |
|
1367 self undoSpecModify:(props identifier). |
|
1368 |
|
1369 name = (aView name) ifFalse:[ |
|
1370 name notNil ifTrue:[ |
|
1371 name := name withoutSeparators. |
|
1372 |
|
1373 (name isEmpty or:[(self propertyOfName:name) notNil]) ifTrue:[ |
|
1374 name := nil |
|
1375 ] |
|
1376 ]. |
|
1377 name isNil ifTrue:[ |
|
1378 aSpec name:(aView name). |
|
1379 ] |
|
1380 ]. |
|
1381 |
|
1382 aSpec needsRebuildForAttributes ifTrue:[ |
|
1383 v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
1384 v realize. |
|
1385 aView destroy. |
|
1386 device sync. device flush. |
|
1387 aView becomeSameAs:v. |
|
1388 inputView raise. |
|
1389 ] ifFalse:[ |
|
1390 aSpec setAttributesIn:aView with:builder. |
|
1391 self elementChangedSize:aView. |
|
1392 ]. |
|
1393 |
|
1394 props spec:(aSpec copy). |
|
1395 ] |
|
1396 ]. |
|
1397 self changed:#tree |
|
1398 ]. |
|
1399 |
|
1400 "Modified: 1.3.1997 / 01:39:53 / cg" |
1603 ! ! |
1401 ! ! |
1604 |
1402 |
1605 !UIPainterView methodsFor:'testing'! |
1403 !UIPainterView methodsFor:'testing'! |
1606 |
1404 |
1607 isHorizontalResizable:aComponent |
1405 isHorizontalResizable:aComponent |
1691 !UIPainterView methodsFor:'undo actions'! |
1489 !UIPainterView methodsFor:'undo actions'! |
1692 |
1490 |
1693 undoCreate:aViewId |
1491 undoCreate:aViewId |
1694 "undo method when creating or pasting an object |
1492 "undo method when creating or pasting an object |
1695 " |
1493 " |
1696 |view| |
|
1697 |
|
1698 undoHistory addUndoBlock:[ |
1494 undoHistory addUndoBlock:[ |
1699 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1495 self remove:(self findViewWithId:aViewId) |
1700 self removeObject:view |
|
1701 ] |
|
1702 ] |
1496 ] |
1703 |
1497 |
1704 ! |
1498 ! |
1705 |
1499 |
1706 undoLayout:aViewId |
1500 undoLayout:aViewId |
1707 "undo method when changing the layout (position or dimension) |
1501 "undo method when changing the layout (position or dimension) |
1708 " |
1502 " |
1709 |view layout extent| |
1503 |view layout extent| |
1710 |
|
1711 undoHistory isTransactionOpen ifFalse:[^ self]. |
|
1712 |
1504 |
1713 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1505 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1714 (layout := view geometryLayout copy) isNil ifTrue:[ |
1506 (layout := view geometryLayout copy) isNil ifTrue:[ |
1715 extent := view extent copy |
1507 extent := view extent copy |
1716 ]. |
1508 ]. |
1738 ! |
1530 ! |
1739 |
1531 |
1740 undoRemove:aViewId |
1532 undoRemove:aViewId |
1741 "undo method when removing an object |
1533 "undo method when removing an object |
1742 " |
1534 " |
1743 |view prop spec parentId| |
1535 |frame prop spec parentId| |
1744 |
1536 |
1745 undoHistory isTransactionOpen ifFalse:[^ self]. |
1537 frame := self findViewWithId:aViewId. |
1746 |
1538 spec := self fullSpecFor:frame. |
1747 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1539 frame := frame superView. |
1748 spec := (self generateSpecFor:view) first. |
1540 |
1749 view := view superView. |
1541 (self canPasteInto:frame) ifTrue:[ |
1750 |
1542 (prop := self propertyOfView:frame) notNil ifTrue:[ |
1751 (self canPasteInto:view) ifTrue:[ |
1543 parentId := prop identifier |
1752 (prop := self propertyOfView:view) notNil ifTrue:[ |
1544 ] |
1753 parentId := prop identifier |
1545 ]. |
1754 ] |
1546 frame := nil. |
1755 ]. |
1547 prop := nil. |
1756 view := nil. |
1548 |
1757 prop := nil. |
1549 undoHistory addUndoBlock:[ |
1758 |
1550 |view| |
1759 undoHistory addUndoBlock:[ |
1551 |
1760 |builder| |
1552 frame := self findViewWithId:parentId. |
1761 |
1553 frame isNil ifTrue:[ |
1762 builder := UIBuilder new. |
1554 frame := self |
1763 view := self findViewWithId:parentId. |
1555 ]. |
1764 |
1556 view := self addSpec:spec builder:(UIBuilder new) in:frame. |
1765 view isNil ifTrue:[ |
1557 view realize. |
1766 view := self |
1558 inputView raise. |
1767 ]. |
|
1768 |
|
1769 builder componentCreationHook:[:aView :aSpec :aBuilder | |
|
1770 self createdComponent:aView forSpec:aSpec builder:aBuilder. |
|
1771 ]. |
|
1772 |
|
1773 builder applicationClass:(Smalltalk classNamed:className). |
|
1774 (spec buildViewWithLayoutFor:builder in:view) realize. |
|
1775 inputView raise. |
|
1776 ]. |
|
1777 ] |
1559 ] |
1778 ! |
1560 ! |
1779 |
1561 |
1780 undoSpecModify:aViewId |
1562 undoSpecModify:aViewId |
1781 "undo method when changing the specification for an object |
1563 "undo method when changing the specification for an object |
1782 " |
1564 " |
1783 |builder view spec v| |
1565 |builder view spec v| |
1784 |
1566 |
1785 undoHistory isTransactionOpen ifFalse:[^ self]. |
|
1786 |
|
1787 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1567 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1788 spec := (self generateSpecFor:view) first. |
1568 spec := self specFor:view. |
1789 view := nil. |
1569 view := nil. |
1790 |
1570 |
1791 undoHistory addUndoBlock:[ |
1571 undoHistory addUndoBlock:[ |
1792 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1572 (view := self findViewWithId:aViewId) notNil ifTrue:[ |
1793 builder := UIBuilder new. |
1573 builder := UIBuilder new. |
1806 |
1586 |
1807 |
1587 |
1808 |
1588 |
1809 ! ! |
1589 ! ! |
1810 |
1590 |
1811 !UIPainterView methodsFor:'update from Specification'! |
|
1812 |
|
1813 updateFromSpec:aSpec |
|
1814 "update current selected view from specification |
|
1815 " |
|
1816 |props name builder v| |
|
1817 |
|
1818 self singleSelection notNil ifTrue:[ |
|
1819 self withSelectionHiddenDo:[ |
|
1820 self transaction:#specification selectionDo:[:aView| |
|
1821 builder := UIBuilder new. |
|
1822 props := self propertyOfView:aView. |
|
1823 name := aSpec name. |
|
1824 |
|
1825 self undoSpecModify:(props identifier). |
|
1826 |
|
1827 name = (aView name) ifFalse:[ |
|
1828 name notNil ifTrue:[ |
|
1829 name := name withoutSeparators. |
|
1830 |
|
1831 (name isEmpty or:[(self propertyOfName:name) notNil]) ifTrue:[ |
|
1832 name := nil |
|
1833 ] |
|
1834 ]. |
|
1835 name isNil ifTrue:[ |
|
1836 aSpec name:(aView name). |
|
1837 ] |
|
1838 ]. |
|
1839 |
|
1840 aSpec needsRebuildForAttributes ifTrue:[ |
|
1841 v := aSpec buildViewWithLayoutFor:builder in:aView superView. |
|
1842 v realize. |
|
1843 aView destroy. |
|
1844 device sync. device flush. |
|
1845 aView becomeSameAs:v. |
|
1846 inputView raise. |
|
1847 ] ifFalse:[ |
|
1848 aSpec setAttributesIn:aView with:builder. |
|
1849 self elementChangedSize:aView. |
|
1850 ]. |
|
1851 |
|
1852 props tabable:aSpec tabable. |
|
1853 props defaultable:aSpec defaultable. |
|
1854 props initiallyInvisible:aSpec initiallyInvisible. |
|
1855 props aspectSelector:aSpec modelSelector. |
|
1856 props changeSelector:aSpec changeSelector. |
|
1857 props labelSelector:aSpec labelSelector. |
|
1858 props menuSelector:aSpec menuSelector. |
|
1859 ] |
|
1860 ]. |
|
1861 self changed:#tree |
|
1862 ]. |
|
1863 |
|
1864 "Modified: 1.3.1997 / 01:39:53 / cg" |
|
1865 ! ! |
|
1866 |
|
1867 !UIPainterView::ViewProperty class methodsFor:'documentation'! |
1591 !UIPainterView::ViewProperty class methodsFor:'documentation'! |
1868 |
1592 |
1869 version |
1593 version |
1870 ^ '$Header$' |
1594 ^ '$Header$' |
1871 ! ! |
1595 ! ! |
1879 ^ self basicNew initialize |
1603 ^ self basicNew initialize |
1880 ! ! |
1604 ! ! |
1881 |
1605 |
1882 !UIPainterView::ViewProperty methodsFor:'accessing'! |
1606 !UIPainterView::ViewProperty methodsFor:'accessing'! |
1883 |
1607 |
1884 aspectSelector |
|
1885 "return the value of the instance variable 'aspectSelector' (automatically generated)" |
|
1886 |
|
1887 ^ aspectSelector |
|
1888 ! |
|
1889 |
|
1890 aspectSelector:something |
|
1891 "set the value of the instance variable 'aspectSelector' (automatically generated)" |
|
1892 |
|
1893 aspectSelector := something. |
|
1894 ! |
|
1895 |
|
1896 changeSelector |
|
1897 "return the value of the instance variable 'changeSelector' (automatically generated)" |
|
1898 |
|
1899 ^ changeSelector! |
|
1900 |
|
1901 changeSelector:something |
|
1902 "set the value of the instance variable 'changeSelector' (automatically generated)" |
|
1903 |
|
1904 changeSelector := something.! |
|
1905 |
|
1906 defaultable |
|
1907 "return the value of the instance variable 'defaultable' (automatically generated)" |
|
1908 |
|
1909 ^ defaultable! |
|
1910 |
|
1911 defaultable:something |
|
1912 "set the value of the instance variable 'defaultable' (automatically generated)" |
|
1913 |
|
1914 defaultable := something.! |
|
1915 |
|
1916 elementClass |
|
1917 "return the value of the instance variable 'elementClass' (automatically generated)" |
|
1918 |
|
1919 ^ elementClass! |
|
1920 |
|
1921 elementClass:something |
|
1922 "set the value of the instance variable 'elementClass' (automatically generated)" |
|
1923 |
|
1924 elementClass := something.! |
|
1925 |
|
1926 group |
1608 group |
1927 ^ nil |
1609 ^ nil |
1928 ! |
1610 ! |
1929 |
1611 |
1930 identifier |
1612 identifier |
1931 "return the unique identifier assigned to property |
1613 "return the unique identifier assigned to property |
1932 " |
1614 " |
1933 ^ identifier |
1615 ^ identifier |
1934 ! |
1616 ! |
1935 |
1617 |
1936 initiallyInvisible |
1618 spec |
1937 "return the value of the instance variable 'initiallyInvisible' (automatically generated)" |
1619 "return the value of the instance variable 'spec' (automatically generated)" |
1938 |
1620 |
1939 ^ initiallyInvisible! |
1621 ^ spec! |
1940 |
1622 |
1941 initiallyInvisible:something |
1623 spec:something |
1942 "set the value of the instance variable 'initiallyInvisible' (automatically generated)" |
1624 "set the value of the instance variable 'spec' (automatically generated)" |
1943 |
1625 |
1944 initiallyInvisible := something.! |
1626 spec := something.! |
1945 |
|
1946 labelSelector |
|
1947 "return the value of the instance variable 'labelSelector' (automatically generated)" |
|
1948 |
|
1949 ^ labelSelector! |
|
1950 |
|
1951 labelSelector:something |
|
1952 "set the value of the instance variable 'labelSelector' (automatically generated)" |
|
1953 |
|
1954 labelSelector := something.! |
|
1955 |
|
1956 menuSelector |
|
1957 "return the value of the instance variable 'menuSelector' (automatically generated)" |
|
1958 |
|
1959 ^ menuSelector! |
|
1960 |
|
1961 menuSelector:something |
|
1962 "set the value of the instance variable 'menuSelector' (automatically generated)" |
|
1963 |
|
1964 menuSelector := something.! |
|
1965 |
|
1966 name |
|
1967 "return the value of the instance variable 'name' (automatically generated)" |
|
1968 |
|
1969 ^ view name |
|
1970 ! |
|
1971 |
|
1972 name:something |
|
1973 "set the value of the instance variable 'name' (automatically generated)" |
|
1974 |
|
1975 view name:something |
|
1976 ! |
|
1977 |
|
1978 nameIndex |
|
1979 "return the value of the instance variable 'nameIndex' (automatically generated)" |
|
1980 |
|
1981 ^ nameIndex! |
|
1982 |
|
1983 nameIndex:something |
|
1984 "set the value of the instance variable 'nameIndex' (automatically generated)" |
|
1985 |
|
1986 nameIndex := something.! |
|
1987 |
|
1988 tabable |
|
1989 "return the value of the instance variable 'tabable' (automatically generated)" |
|
1990 |
|
1991 ^ tabable! |
|
1992 |
|
1993 tabable:something |
|
1994 "set the value of the instance variable 'tabable' (automatically generated)" |
|
1995 |
|
1996 tabable := something.! |
|
1997 |
1627 |
1998 view |
1628 view |
1999 "return the value of the instance variable 'view' (automatically generated)" |
1629 "return the value of the instance variable 'view' (automatically generated)" |
2000 |
1630 |
2001 ^ view! |
1631 ^ view! |