UIPainter.st
changeset 1071 560a9eb1a5d8
parent 1068 dcb2cba5787f
child 1103 ecc91379704b
equal deleted inserted replaced
1070:1735e40c6825 1071:560a9eb1a5d8
  1853 helpIcon
  1853 helpIcon
  1854 
  1854 
  1855     ^Icon helpIcon
  1855     ^Icon helpIcon
  1856 !
  1856 !
  1857 
  1857 
  1858 modifiedChannel
       
  1859     "returns a boolean value holder which is set to true if something is modified
       
  1860      and not accepted"
       
  1861 
       
  1862     ^ builder booleanValueAspectFor:#modifiedChannel
       
  1863 !
       
  1864 
       
  1865 noteBookView
  1858 noteBookView
  1866     "returns the notebook view; initialize the tools embedded in the notebook"
  1859     "returns the notebook view; initialize the tools embedded in the notebook"
  1867 
  1860 
  1868     |noteBook modifiedChannel helpTool layoutTool specTool|
  1861     |noteBook modifiedChannel helpTool layoutTool specTool|
  1869 
  1862 
  2154 
  2147 
  2155 propertyChanged
  2148 propertyChanged
  2156     "called by the painter/canvas whenever the property of the current selected
  2149     "called by the painter/canvas whenever the property of the current selected
  2157      widget has changed"
  2150      widget has changed"
  2158 
  2151 
  2159     |property|
  2152     |property spec|
  2160 
  2153 
  2161     (property := treeView propertySelected) notNil ifTrue:[
  2154     (property := treeView propertySelected) notNil ifTrue:[
  2162 	self specTool specification:(property spec copy).
  2155         spec := property spec copy.
  2163 	self setViewInLayoutTool:(property view).
  2156         self specTool specification:spec.
  2164 	self modifiedChannel value:false
  2157         self setViewInLayoutTool:(property view) spec:spec.
       
  2158         self modifiedChannel value:false
  2165     ] ifFalse:[
  2159     ] ifFalse:[
  2166 	self layoutTool layoutView notNil ifTrue:[
  2160         self layoutTool layoutView notNil ifTrue:[
  2167 	    self modifiedChannel value:false.
  2161             self modifiedChannel value:false.
  2168 	    self treeSelection
  2162             self treeSelection
  2169 	]
  2163         ]
  2170     ]
  2164     ]
  2171 !
  2165 !
  2172 
  2166 
  2173 update:something with:aParameter from:someObject
  2167 update:something with:aParameter from:someObject
  2174     "catches change notifications"
  2168     "catches change notifications"
  2475     ].
  2469     ].
  2476 
  2470 
  2477     "Modified: / 5.2.1998 / 09:44:58 / stefan"
  2471     "Modified: / 5.2.1998 / 09:44:58 / stefan"
  2478 !
  2472 !
  2479 
  2473 
  2480 setViewInLayoutTool:aView
  2474 setViewInLayoutTool:aView spec:aSpec
  2481     "sets view for layout tool"
  2475     "sets view for layout tool"
  2482 
  2476 
  2483     |type|
  2477     |type|
  2484 
  2478 
  2485     self painter topView == aView ifTrue:[
  2479     self painter topView == aView ifTrue:[
  2486 	type := #Extent
  2480         type := #Extent
  2487     ].
  2481     ].
  2488     self layoutTool layoutView:aView type:type
  2482     self layoutTool layoutView:aView type:type spec:aSpec
  2489 
  2483 
  2490 !
  2484 !
  2491 
  2485 
  2492 specClass:aClass
  2486 specClass:aClass
  2493     "sets the specClass and updates the Help Tool"
  2487     "sets the specClass and updates the Help Tool"
  2618     "called whenever the selection of the treeview has changed"
  2612     "called whenever the selection of the treeview has changed"
  2619 
  2613 
  2620     |view list spec slices size property tabComponent|
  2614     |view list spec slices size property tabComponent|
  2621 
  2615 
  2622     self isModified ifTrue:[
  2616     self isModified ifTrue:[
  2623 	(self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
  2617         (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
  2624 	    self accept
  2618             self accept
  2625 	]
  2619         ]
  2626     ].
  2620     ].
  2627 
  2621 
  2628     treeView isCanvasSelected ifTrue:[
  2622     treeView isCanvasSelected ifTrue:[
  2629 	spec := treeView canvasSpec.
  2623         spec := treeView canvasSpec.
  2630 	view := self painter topView.
  2624         view := self painter topView.
  2631     ] ifFalse:[
  2625     ] ifFalse:[
  2632 	(property := treeView propertySelected) notNil ifTrue:[
  2626         (property := treeView propertySelected) notNil ifTrue:[
  2633 	    treeView canResizeSelectedWidget ifTrue:[
  2627             treeView canResizeSelectedWidget ifTrue:[
  2634 		view := property view.
  2628                 view := property view.
  2635 	    ].
  2629             ].
  2636 	    spec := property spec copy.
  2630             spec := property spec copy.
  2637 	]
  2631         ]
  2638     ].
  2632     ].
  2639     tabComponent := builder componentAt:#noteBook.
  2633     tabComponent := builder componentAt:#noteBook.
  2640     self setViewInLayoutTool:view.
  2634     self setViewInLayoutTool:view spec:spec.
  2641     self specTool specification:spec.
  2635     self specTool specification:spec.
  2642 
  2636 
  2643     spec notNil ifTrue:[
  2637     spec notNil ifTrue:[
  2644 	self helpTool helpKey:(spec activeHelpKey).
  2638         self helpTool helpKey:(spec activeHelpKey).
  2645 	slices := spec class slices.
  2639         slices := spec class slices.
  2646 	size   := slices size.
  2640         size   := slices size.
  2647 
  2641 
  2648 	view notNil ifTrue:[
  2642         view notNil ifTrue:[
  2649 	    self treeView isCanvasSelected 
  2643             self treeView isCanvasSelected 
  2650 	    ifFalse:
  2644             ifFalse:
  2651 	    [
  2645             [
  2652 		list := Array new:(size + 2).
  2646                 list := Array new:(size + 2).
  2653 		list at:(size + 2) put:(UILayoutTool label).
  2647                 list at:(size + 2) put:(UILayoutTool label).
  2654 	    ]
  2648             ]
  2655 	    ifTrue:
  2649             ifTrue:
  2656 	    [
  2650             [
  2657 		list := Array new:(size + 1).
  2651                 list := Array new:(size + 1).
  2658 		list at:(size + 1) put:(UILayoutTool label).
  2652                 list at:(size + 1) put:(UILayoutTool label).
  2659 	    ].
  2653             ].
  2660 	] ifFalse:[
  2654         ] ifFalse:[
  2661 	    list := Array new:(size + 1).
  2655             list := Array new:(size + 1).
  2662 	].
  2656         ].
  2663 
  2657 
  2664 	1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
  2658         1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
  2665 	self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)].
  2659         self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)].
  2666 
  2660 
  2667 	self tabList value:list.
  2661         self tabList value:list.
  2668 	self showHelp:spec class name for:self.
  2662         self showHelp:spec class name for:self.
  2669 	tabComponent enabled:true.
  2663         tabComponent enabled:true.
  2670 
  2664 
  2671 	(tabSelection := tabComponent selection) isNil ifTrue:[
  2665         (tabSelection := tabComponent selection) isNil ifTrue:[
  2672 	    tabComponent setSelection:(tabSelection := list first)
  2666             tabComponent setSelection:(tabSelection := list first)
  2673 	].
  2667         ].
  2674 	self raiseTabView
  2668         self raiseTabView
  2675     ] ifFalse:[
  2669     ] ifFalse:[
  2676 	self helpTool helpKey:nil.
  2670         self helpTool helpKey:nil.
  2677 	tabComponent enabled:false.
  2671         tabComponent enabled:false.
  2678 	self defaultInfoLabel.
  2672         self defaultInfoLabel.
  2679     ].
  2673     ].
  2680     self modifiedChannel value:false.
  2674     self modifiedChannel value:false.
  2681 
  2675 
  2682     self updateChannels
  2676     self updateChannels
  2683 ! !
  2677 ! !
  2927 !UIPainter methodsFor:'user actions'!
  2921 !UIPainter methodsFor:'user actions'!
  2928 
  2922 
  2929 accept
  2923 accept
  2930     "accepts all modifications done to the attributes of the current section"
  2924     "accepts all modifications done to the attributes of the current section"
  2931 
  2925 
  2932     |painter layout spec layoutTool|
  2926     |painter layout spec layoutTool layoutView t|
  2933 
  2927 
  2934     self acceptChannel value:true; value:false.  "/ force editFields to accept
  2928     self acceptChannel value:true; value:false.  "/ force editFields to accept
  2935     self modifiedChannel value:false.
  2929     self modifiedChannel value:false.
  2936     modified := true.
       
  2937 
  2930 
  2938     painter := self painter.
  2931     painter := self painter.
       
  2932     spec := self specTool specification.
  2939 
  2933 
  2940     self isLayoutToolSelected ifTrue:[
  2934     self isLayoutToolSelected ifTrue:[
  2941         layoutTool := self layoutTool.
  2935         layoutTool := self layoutTool.
  2942 
  2936 
  2943         (layout := layoutTool layout) notNil ifTrue:[
  2937         (layout := layoutTool layout) notNil ifTrue:[
  2944             layoutTool layoutType == #Extent ifTrue:[
  2938             layoutTool layoutType == #Extent ifTrue:[
  2945                 layoutTool layoutView == painter topView ifTrue:[
  2939                 layoutView := layoutTool layoutView.
  2946                     layoutTool layoutView extent:layout
  2940 
       
  2941                 layoutView == painter topView ifTrue:[
       
  2942                     layoutView extent:layout
  2947                 ] ifFalse:[
  2943                 ] ifFalse:[
  2948                     painter setExtent:layout
  2944                     spec useDefaultExtent:(layoutTool aspectFor:#useDefaultExtent) value.
       
  2945                     spec useDefaultExtent ifTrue:[
       
  2946                         "/ temporarily unfreeze the widgets size
       
  2947                         "/ (but remember, the old setting, which is actually
       
  2948                         "/ controlled by the resizeForLabel attribute)
       
  2949                         t := layoutView sizeFixed.
       
  2950                         layoutView sizeFixed:false.
       
  2951                         layout := layoutView preferredExtent.    
       
  2952                         layoutView sizeFixed:t.
       
  2953                     ].
       
  2954                     painter setExtent:layout.
       
  2955                     painter updateFromSpec:spec.
  2949                 ]
  2956                 ]
  2950             ] ifFalse:[
  2957             ] ifFalse:[
  2951                 painter setLayout:layout
  2958                 painter setLayout:layout
  2952             ]
  2959             ]
  2953         ]
  2960         ]
  2954     ] ifFalse:[
  2961     ] ifFalse:[
  2955         spec := self specTool specification.
       
  2956 
       
  2957         self isHelpToolSelected ifTrue:[
  2962         self isHelpToolSelected ifTrue:[
  2958             self helpTool accept.      
  2963             self helpTool accept.      
  2959             spec activeHelpKey:self helpTool helpKey.
  2964             spec activeHelpKey:self helpTool helpKey.
  2960         ].      
  2965         ].      
  2961         painter updateFromSpec:spec
  2966         painter updateFromSpec:spec
  2962     ]             
  2967     ].
       
  2968 
       
  2969     modified := false.
  2963 !
  2970 !
  2964 
  2971 
  2965 addWidget: aSpecClass
  2972 addWidget: aSpecClass
  2966     "adds a widget from aSpecClass to the current widget"
  2973     "adds a widget from aSpecClass to the current widget"
  2967 
  2974 
  2999      reread the old attributes"
  3006      reread the old attributes"
  3000 
  3007 
  3001     |spec key view|
  3008     |spec key view|
  3002 
  3009 
  3003     self isModified ifTrue:[
  3010     self isModified ifTrue:[
  3004 	(spec := self painter specForSelection) notNil ifTrue:[
  3011         (spec := self painter specForSelection) notNil ifTrue:[
  3005 	    key := spec activeHelpKey.
  3012             key := spec activeHelpKey.
  3006 	].
  3013         ].
  3007 	self helpTool helpKey:key.
  3014         self helpTool helpKey:key.
  3008 
  3015 
  3009 	treeView isCanvasSelected ifTrue: [
  3016         treeView isCanvasSelected ifTrue: [
  3010 	    spec := treeView canvasSpec.
  3017             spec := treeView canvasSpec.
  3011 	].
  3018         ].
  3012 	self specTool specification:spec.
  3019         self specTool specification:spec.
  3013 	view := self layoutTool layoutView.
  3020         view := self layoutTool layoutView.
  3014 
  3021 
  3015 	self setViewInLayoutTool:view.
  3022         self setViewInLayoutTool:view spec:spec.
  3016 	spec class == DataSetSpec ifTrue:[
  3023         spec class == DataSetSpec ifTrue:[
  3017 	    view columnDescriptors:(spec columns)
  3024             view columnDescriptors:(spec columns)
  3018 	].        
  3025         ].        
  3019 	self modifiedChannel value:false.
  3026         self modifiedChannel value:false.
  3020 	modified := false
  3027         modified := false
  3021     ]
  3028     ]
  3022 !
  3029 !
  3023 
  3030 
  3024 doBrowseAspectMethods
  3031 doBrowseAspectMethods
  3025     "opens a browser on the aspect methods"
  3032     "opens a browser on the aspect methods"