UIPainter.st
changeset 1188 4805027d9d33
parent 1186 4cea2d4e9dbc
child 1192 f3f5c92930c9
equal deleted inserted replaced
1187:e413149dabe6 1188:4805027d9d33
  2147 layoutChanged
  2147 layoutChanged
  2148     "called by the painter/canvas whenever the layout of the current selected
  2148     "called by the painter/canvas whenever the layout of the current selected
  2149      widget has changed"
  2149      widget has changed"
  2150 
  2150 
  2151     self isModified ifFalse:[
  2151     self isModified ifFalse:[
  2152 	self layoutTool update.
  2152         self layoutTool update.
  2153 	self modifiedChannel value:false
  2153         self clearModifiedFlag
  2154     ]
  2154     ]
  2155 !
  2155 !
  2156 
  2156 
  2157 propertyChanged
  2157 propertyChanged
  2158     "called by the painter/canvas whenever the property of the current selected
  2158     "called by the painter/canvas whenever the property of the current selected
  2159      widget has changed"
  2159      widget has changed"
  2160 
  2160 
  2161     |property spec|
  2161     |property spec|
  2162 
  2162 
  2163     (property := treeView propertySelected) notNil ifTrue:[
  2163     (property := treeView propertySelected) notNil ifTrue:[
  2164 	spec := property spec copy.
  2164         spec := property spec copy.
  2165 	self specTool specification:spec.
  2165         self specTool specification:spec.
  2166 	self setViewInLayoutTool:(property view) spec:spec.
  2166         self setViewInLayoutTool:(property view) spec:spec.
  2167 	self modifiedChannel value:false
  2167         self clearModifiedFlag
  2168     ] ifFalse:[
  2168     ] ifFalse:[
  2169 	self layoutTool layoutView notNil ifTrue:[
  2169         self layoutTool layoutView notNil ifTrue:[
  2170 	    self modifiedChannel value:false.
  2170             self clearModifiedFlag.
  2171 	    self treeSelection
  2171             self treeSelection
  2172 	]
  2172         ]
  2173     ]
  2173     ]
  2174 !
  2174 !
  2175 
  2175 
  2176 update:something with:aParameter from:someObject
  2176 update:something with:aParameter from:someObject
  2177     "catches change notifications"
  2177     "catches change notifications"
  2501 
  2501 
  2502 specClass:aClass
  2502 specClass:aClass
  2503     "sets the specClass and updates the Help Tool"
  2503     "sets the specClass and updates the Help Tool"
  2504 
  2504 
  2505     specClass := aClass isBehavior ifTrue:[aClass name]
  2505     specClass := aClass isBehavior ifTrue:[aClass name]
  2506 				   ifFalse:[aClass].
  2506                                    ifFalse:[aClass].
  2507 
  2507 
  2508     self helpTool buildFromClass:specClass.    
  2508     self helpTool buildFromClass:specClass.    
  2509     self helpTool updateList.
  2509     self helpTool updateList.
  2510     self modifiedChannel value: false. 
  2510     self clearModifiedFlag. 
  2511 
  2511 
  2512 ! !
  2512 ! !
  2513 
  2513 
  2514 !UIPainter methodsFor:'private tools'!
  2514 !UIPainter methodsFor:'private tools'!
  2515 
  2515 
  2628     "called whenever the selection of the treeview has changed"
  2628     "called whenever the selection of the treeview has changed"
  2629 
  2629 
  2630     |view list spec slices size property tabComponent|
  2630     |view list spec slices size property tabComponent|
  2631 
  2631 
  2632     self isModified ifTrue:[
  2632     self isModified ifTrue:[
  2633 	(self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
  2633         (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
  2634 	    self accept
  2634             self accept
  2635 	]
  2635         ]
  2636     ].
  2636     ].
  2637 
  2637 
  2638     treeView isCanvasSelected ifTrue:[
  2638     treeView isCanvasSelected ifTrue:[
  2639 	spec := treeView canvasSpec.
  2639         spec := treeView canvasSpec.
  2640 	view := self painter topView.
  2640         view := self painter topView.
  2641     ] ifFalse:[
  2641     ] ifFalse:[
  2642 	(property := treeView propertySelected) notNil ifTrue:[
  2642         (property := treeView propertySelected) notNil ifTrue:[
  2643 	    treeView canResizeSelectedWidget ifTrue:[
  2643             treeView canResizeSelectedWidget ifTrue:[
  2644 		view := property view.
  2644                 view := property view.
  2645 	    ].
  2645             ].
  2646 	    spec := property spec copy.
  2646             spec := property spec copy.
  2647 	]
  2647         ]
  2648     ].
  2648     ].
  2649     tabComponent := builder componentAt:#noteBook.
  2649     tabComponent := builder componentAt:#noteBook.
  2650     self setViewInLayoutTool:view spec:spec.
  2650     self setViewInLayoutTool:view spec:spec.
  2651     self specTool specification:spec.
  2651     self specTool specification:spec.
  2652 
  2652 
  2653     spec notNil ifTrue:[
  2653     spec notNil ifTrue:[
  2654 	self helpTool helpKey:(spec activeHelpKey).
  2654         self helpTool helpKey:(spec activeHelpKey).
  2655 	slices := spec class slices.
  2655         slices := spec class slices.
  2656 	size   := slices size.
  2656         size   := slices size.
  2657 
  2657 
  2658 	view notNil ifTrue:[
  2658         view notNil ifTrue:[
  2659 	    self treeView isCanvasSelected 
  2659             self treeView isCanvasSelected 
  2660 	    ifFalse:
  2660             ifFalse:
  2661 	    [
  2661             [
  2662 		list := Array new:(size + 2).
  2662                 list := Array new:(size + 2).
  2663 		list at:(size + 2) put:(UILayoutTool label).
  2663                 list at:(size + 2) put:(UILayoutTool label).
  2664 	    ]
  2664             ]
  2665 	    ifTrue:
  2665             ifTrue:
  2666 	    [
  2666             [
  2667 		list := Array new:(size + 1).
  2667                 list := Array new:(size + 1).
  2668 		list at:(size + 1) put:(UILayoutTool label).
  2668                 list at:(size + 1) put:(UILayoutTool label).
  2669 	    ].
  2669             ].
  2670 	] ifFalse:[
  2670         ] ifFalse:[
  2671 	    list := Array new:(size + 1).
  2671             list := Array new:(size + 1).
  2672 	].
  2672         ].
  2673 
  2673 
  2674 	1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
  2674         1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
  2675 	self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)].
  2675         self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)].
  2676 
  2676 
  2677 	self tabList value:list.
  2677         self tabList value:list.
  2678 	self showHelp:spec class name for:self.
  2678         self showHelp:spec class name for:self.
  2679 	tabComponent enabled:true.
  2679         tabComponent enabled:true.
  2680 
  2680 
  2681 	(tabSelection := tabComponent selection) isNil ifTrue:[
  2681         (tabSelection := tabComponent selection) isNil ifTrue:[
  2682 	    tabComponent setSelection:(tabSelection := list first)
  2682             tabComponent setSelection:(tabSelection := list first)
  2683 	].
  2683         ].
  2684 	self raiseTabView
  2684         self raiseTabView
  2685     ] ifFalse:[
  2685     ] ifFalse:[
  2686 	self helpTool helpKey:nil.
  2686         self helpTool helpKey:nil.
  2687 	tabComponent enabled:false.
  2687         tabComponent enabled:false.
  2688 	self defaultInfoLabel.
  2688         self defaultInfoLabel.
  2689     ].
  2689     ].
  2690     self modifiedChannel value:false.
  2690     self clearModifiedFlag.
  2691 
  2691 
  2692     self updateChannels
  2692     self updateChannels
  2693 ! !
  2693 ! !
  2694 
  2694 
  2695 !UIPainter methodsFor:'settings'!
  2695 !UIPainter methodsFor:'settings'!
  2938     "accepts all modifications done to the attributes of the current section"
  2938     "accepts all modifications done to the attributes of the current section"
  2939 
  2939 
  2940     |painter layout spec layoutTool layoutView t|
  2940     |painter layout spec layoutTool layoutView t|
  2941 
  2941 
  2942     self acceptChannel value:true; value:false.  "/ force editFields to accept
  2942     self acceptChannel value:true; value:false.  "/ force editFields to accept
  2943     self modifiedChannel value:false.
  2943     self clearModifiedFlag.
  2944 
  2944 
  2945     painter := self painter.
  2945     painter := self painter.
  2946     spec := self specTool specification.
  2946     spec := self specTool specification.
  2947 
  2947 
  2948     self isLayoutToolSelected ifTrue:[
  2948     self isLayoutToolSelected ifTrue:[
  2949 	layoutTool := self layoutTool.
  2949         layoutTool := self layoutTool.
  2950 
  2950 
  2951 	(layout := layoutTool layout) notNil ifTrue:[
  2951         (layout := layoutTool layout) notNil ifTrue:[
  2952 	    layoutTool layoutType == #Extent ifTrue:[
  2952             layoutTool layoutType == #Extent ifTrue:[
  2953 		layoutView := layoutTool layoutView.
  2953                 layoutView := layoutTool layoutView.
  2954 
  2954 
  2955 		layoutView == painter topView ifTrue:[
  2955                 layoutView == painter topView ifTrue:[
  2956 		    layoutView extent:layout
  2956                     layoutView extent:layout
  2957 		] ifFalse:[
  2957                 ] ifFalse:[
  2958 		    spec useDefaultExtent:(layoutTool aspectFor:#useDefaultExtent) value.
  2958                     spec useDefaultExtent:(layoutTool aspectFor:#useDefaultExtent) value.
  2959 		    spec useDefaultExtent ifTrue:[
  2959                     spec useDefaultExtent ifTrue:[
  2960 			"/ temporarily unfreeze the widgets size
  2960                         "/ temporarily unfreeze the widgets size
  2961 			"/ (but remember, the old setting, which is actually
  2961                         "/ (but remember, the old setting, which is actually
  2962 			"/ controlled by the resizeForLabel attribute)
  2962                         "/ controlled by the resizeForLabel attribute)
  2963 			t := layoutView sizeFixed.
  2963                         t := layoutView sizeFixed.
  2964 			layoutView sizeFixed:false.
  2964                         layoutView sizeFixed:false.
  2965 			layout := layoutView preferredExtent.    
  2965                         layout := layoutView preferredExtent.    
  2966 			layoutView sizeFixed:t.
  2966                         layoutView sizeFixed:t.
  2967 		    ].
  2967                     ].
  2968 		    painter setExtent:layout.
  2968                     painter setExtent:layout.
  2969 		    painter updateFromSpec:spec.
  2969                     painter updateFromSpec:spec.
  2970 		]
  2970                 ]
  2971 	    ] ifFalse:[
  2971             ] ifFalse:[
  2972 		painter setLayout:layout
  2972                 painter setLayout:layout
  2973 	    ]
  2973             ]
  2974 	]
  2974         ]
  2975     ] ifFalse:[
  2975     ] ifFalse:[
  2976 	self isHelpToolSelected ifTrue:[
  2976         self isHelpToolSelected ifTrue:[
  2977 	    self helpTool accept.      
  2977             self helpTool accept.      
  2978 	    spec activeHelpKey:self helpTool helpKey.
  2978             spec activeHelpKey:self helpTool helpKey.
  2979 	].      
  2979         ].      
  2980 	painter updateFromSpec:spec
  2980         painter updateFromSpec:spec
  2981     ].
  2981     ].
  2982 
  2982 
  2983     modified := false.
  2983     modified := false.
  2984 !
  2984 !
  2985 
  2985 
  3020      reread the old attributes"
  3020      reread the old attributes"
  3021 
  3021 
  3022     |spec key view|
  3022     |spec key view|
  3023 
  3023 
  3024     self isModified ifTrue:[
  3024     self isModified ifTrue:[
  3025 	(spec := self painter specForSelection) notNil ifTrue:[
  3025         (spec := self painter specForSelection) notNil ifTrue:[
  3026 	    key := spec activeHelpKey.
  3026             key := spec activeHelpKey.
  3027 	].
  3027         ].
  3028 	self helpTool helpKey:key.
  3028         self helpTool helpKey:key.
  3029 
  3029 
  3030 	treeView isCanvasSelected ifTrue: [
  3030         treeView isCanvasSelected ifTrue: [
  3031 	    spec := treeView canvasSpec.
  3031             spec := treeView canvasSpec.
  3032 	].
  3032         ].
  3033 	self specTool specification:spec.
  3033         self specTool specification:spec.
  3034 	view := self layoutTool layoutView.
  3034         view := self layoutTool layoutView.
  3035 
  3035 
  3036 	self setViewInLayoutTool:view spec:spec.
  3036         self setViewInLayoutTool:view spec:spec.
  3037 	spec class == DataSetSpec ifTrue:[
  3037         spec class == DataSetSpec ifTrue:[
  3038 	    view notNil ifTrue:[
  3038             view notNil ifTrue:[
  3039 		view columnDescriptors:(spec columns)
  3039                 view columnDescriptors:(spec columns)
  3040 	    ]
  3040             ]
  3041 	].        
  3041         ].        
  3042 	self modifiedChannel value:false.
  3042         self clearModifiedFlag.
  3043 	modified := false
  3043         modified := false
  3044     ]
  3044     ]
  3045 !
  3045 !
  3046 
  3046 
  3047 doBrowseAspectMethods
  3047 doBrowseAspectMethods
  3048     "opens a browser on the aspect methods"
  3048     "opens a browser on the aspect methods"
  3076     "launches a dialog for defining class, superclass, and selector of the application"
  3076     "launches a dialog for defining class, superclass, and selector of the application"
  3077 
  3077 
  3078     |again tmp helpDict helpKey helpTool|
  3078     |again tmp helpDict helpKey helpTool|
  3079 
  3079 
  3080     [
  3080     [
  3081 	again := false.
  3081         again := false.
  3082 
  3082 
  3083 	(tmp := specClass) isNil ifTrue:[tmp := 'NewApplication'].
  3083         (tmp := specClass) isNil ifTrue:[tmp := 'NewApplication'].
  3084 	aspects at:#classNameChannel put:tmp asValue.
  3084         aspects at:#classNameChannel put:tmp asValue.
  3085 
  3085 
  3086 	(tmp := specSelector) isNil ifTrue:[tmp := 'windowSpec'].
  3086         (tmp := specSelector) isNil ifTrue:[tmp := 'windowSpec'].
  3087 	aspects at:#methodNameChannel put:tmp asValue.
  3087         aspects at:#methodNameChannel put:tmp asValue.
  3088 
  3088 
  3089 	(tmp := specSuperclass) isNil ifTrue:[tmp := 'ApplicationModel'].
  3089         (tmp := specSuperclass) isNil ifTrue:[tmp := 'ApplicationModel'].
  3090 	aspects at:#superclassNameChannel put:tmp asValue.
  3090         aspects at:#superclassNameChannel put:tmp asValue.
  3091 
  3091 
  3092 	(self openDialogInterface:#dialogSpecForDefiningClassAndSelector) ifTrue:[
  3092         (self openDialogInterface:#dialogSpecForDefiningClassAndSelector) ifTrue:[
  3093 
  3093 
  3094 	    specClass    := (self aspectFor:#classNameChannel) value.
  3094             specClass    := (self aspectFor:#classNameChannel) value.
  3095 	    specSelector := (self aspectFor:#methodNameChannel) value.
  3095             specSelector := (self aspectFor:#methodNameChannel) value.
  3096 	    specSelector notNil ifTrue:[specSelector := specSelector asSymbol].
  3096             specSelector notNil ifTrue:[specSelector := specSelector asSymbol].
  3097 	    specSuperclass := (self aspectFor:#superclassNameChannel) value.
  3097             specSuperclass := (self aspectFor:#superclassNameChannel) value.
  3098 
  3098 
  3099 	    (again := self checkClassAndSelector not) ifFalse:[
  3099             (again := self checkClassAndSelector not) ifFalse:[
  3100 		self painter className:specClass
  3100                 self painter className:specClass
  3101 			superclassName:specSuperclass
  3101                         superclassName:specSuperclass
  3102 			      selector:specSelector.
  3102                               selector:specSelector.
  3103 	    ]
  3103             ]
  3104 	]
  3104         ]
  3105 	ifFalse:
  3105         ifFalse:
  3106 	[
  3106         [
  3107 	    ^nil
  3107             ^nil
  3108 	]
  3108         ]
  3109 
  3109 
  3110     ] doWhile:[again].
  3110     ] doWhile:[again].
  3111 
  3111 
  3112     specClass := specClass isBehavior ifTrue:[specClass name]
  3112     specClass := specClass isBehavior ifTrue:[specClass name]
  3113 				      ifFalse:[specClass].
  3113                                       ifFalse:[specClass].
  3114 
  3114 
  3115     helpTool := self helpTool.
  3115     helpTool := self helpTool.
  3116     helpDict := helpTool dictionary.
  3116     helpDict := helpTool dictionary.
  3117     helpKey  := helpTool helpKey.
  3117     helpKey  := helpTool helpKey.
  3118     helpTool buildFromClass:specClass.    
  3118     helpTool buildFromClass:specClass.    
  3119     helpTool dictionary declareAllFrom: helpDict.
  3119     helpTool dictionary declareAllFrom: helpDict.
  3120     helpTool updateList.
  3120     helpTool updateList.
  3121     helpTool helpKey: helpKey.
  3121     helpTool helpKey: helpKey.
  3122     self modifiedChannel value: false.
  3122     self clearModifiedFlag.
  3123     helpTool modified: true.
  3123     helpTool modified: true.
  3124 
  3124 
  3125     self updateInfoLabel
  3125     self updateInfoLabel
  3126 
  3126 
  3127     "Modified: / 16.7.1998 / 18:26:33 / cg"
  3127     "Modified: / 16.7.1998 / 18:26:33 / cg"