From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:46:34 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>ColorExample</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none color colorLayer sampleText sampleList sampleTable <imports></imports> <category>Examples-Help</category> <attributes> <package>Color-Example</package> </attributes> </class> <comment> Examples.ColorExample
ColorExample class demonstrates how to programmatically apply colors to various widgets during runtime.
</comment> <methods> Examples.ColorExample <category>actions</category>
applyColor | c layerMessage | c := ColorValue perform: self color value. layerMessage := self colorLayer value. self perform: layerMessage with: c.
backgroundColor: aColor "For each sample widget, change the indicated color layer." | wrapper lookPref | self sampleWidgets do: [ :widgetID | wrapper := (self builder componentAt: widgetID). lookPref := wrapper lookPreferences backgroundColor: aColor. wrapper lookPreferences: lookPref].
foregroundColor: aColor "For each sample widget, change the indicated color layer." | wrapper lookPref | self sampleWidgets do: [ :widgetID | wrapper := (self builder componentAt: widgetID). lookPref := wrapper lookPreferences foregroundColor: aColor. wrapper lookPreferences: lookPref].
selectionBackgroundColor: aColor "For each sample widget, change the indicated color layer." | wrapper lookPref | self sampleWidgets do: [ :widgetID | wrapper := (self builder componentAt: widgetID). lookPref := wrapper lookPreferences selectionBackgroundColor: aColor. wrapper lookPreferences: lookPref].
selectionForegroundColor: aColor "For each sample widget, change the indicated color layer." | wrapper lookPref | self sampleWidgets do: [ :widgetID | wrapper := (self builder componentAt: widgetID). lookPref := wrapper lookPreferences selectionForegroundColor: aColor. wrapper lookPreferences: lookPref].
</methods> <methods> Examples.ColorExample <category>aspects</category>
color ^color
colorLayer ^colorLayer
sampleList ^sampleList
sampleTable ^sampleTable
sampleText ^sampleText
</methods> <methods> Examples.ColorExample <category>initialize-release</category>
initialize | tableList | color := #red asValue. colorLayer := #backgroundColor: asValue. "Sample data" sampleList := SelectionInList with: ColorValue constantNames. tableList := TwoDList on: #( 'Red' 'Cyan' 'Green' 'Magenta' 'Blue' 'Yellow' ) columns: 2 rows: 3. sampleTable := TableInterface new selectionInTable: (SelectionInTable with: tableList). sampleText := ColorValue comment asValue.
</methods> <methods> Examples.ColorExample <category>private</category>
sampleWidgets ^#( #actionButton #checkBox #radioButton #menuButton #inputField #slider #label #divider #box #region #list #table #textEditor )
</methods> <methods> Examples.ColorExample class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'ColorExample' #min: #(#Point 20 20 ) #max: #(#Point 310 480 ) #bounds: #(#Rectangle 653 416 963 896 ) ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#Point 9 44 ) #label: 'Apply to:' ) #(#LabelSpec #layout: #(#Point 9 8 ) #label: 'Color:' ) #(#MenuButtonSpec #layout: #(#Rectangle 94 8 194 33 ) #model: #color #menu: #colorMenu ) #(#ActionButtonSpec #layout: #(#Rectangle 13 145 62 165 ) #name: #actionButton #label: 'Action' #defaultable: true ) #(#CheckBoxSpec #layout: #(#Point 14 170 ) #name: #checkBox #label: 'Check Box' ) #(#RadioButtonSpec #layout: #(#Point 11 193 ) #name: #radioButton #label: 'Radio Button' ) #(#MenuButtonSpec #layout: #(#Rectangle 9 229 109 254 ) #name: #menuButton #label: 'Choice1' ) #(#InputFieldSpec #layout: #(#Rectangle 10 259 110 280 ) #name: #inputField ) #(#SliderSpec #layout: #(#Rectangle 11 288 91 312 ) #name: #slider #orientation: #horizontal ) #(#LabelSpec #layout: #(#Point 9 325 ) #name: #label #label: 'Label' ) #(#DividerSpec #layout: #(#Rectangle 10 358 110 362 ) #name: #divider ) #(#GroupBoxSpec #layout: #(#Rectangle 9 362 60 420 ) #name: #box #label: 'Box' ) #(#RegionSpec #layout: #(#Rectangle 4 425 78 475 ) #name: #region #lineWidth: 4 #regionType: #ellipse ) #(#SequenceViewSpec #layout: #(#Rectangle 190 134 290 234 ) #name: #list #model: #sampleList ) #(#TableViewSpec #layout: #(#Rectangle 190 252 290 352 ) #name: #table #model: #sampleTable #showHGrid: true #showVGrid: true ) #(#TextEditorSpec #layout: #(#Rectangle 190 371 290 471 ) #name: #textEditor #model: #sampleText ) #(#ActionButtonSpec #layout: #(#Rectangle 94 81 178 106 ) #model: #applyColor #label: 'Apply' #isDefault: true #defaultable: true ) #(#MenuButtonSpec #layout: #(#Rectangle 94 44 269 69 ) #model: #colorLayer #menu: #colorLayers ) #(#DividerSpec #layout: #(#Rectangle -7 130 311 134 ) ) ) ) )
</methods> <methods> Examples.ColorExample class <category>resources</category>
colorLayers "MenuEditor new openOnClass: self andSelector: #colorLayers" <resource: #menu> ^#(#Menu #( #(#MenuItem #label: 'Foreground' ) #(#MenuItem #label: 'Background' ) #(#MenuItem #label: 'Selection Foreground' ) #(#MenuItem #label: 'Selection Background' ) ) #(4 ) #(#foregroundColor: #backgroundColor: #selectionForegroundColor: #selectionBackgroundColor: ) ) decodeAsLiteralArray
colorMenu "MenuEditor new openOnClass: self andSelector: #colorMenu" <resource: #menu> ^#(#Menu #( #(#MenuItem #label: 'white' ) #(#MenuItem #label: 'black' ) #(#MenuItem #label: 'red' ) #(#MenuItem #label: 'green' ) #(#MenuItem #label: 'blue' ) #(#MenuItem #label: 'cyan' ) #(#MenuItem #label: 'magenta' ) #(#MenuItem #label: 'yellow' ) ) #(2 6 ) #(#white #black #red #green #blue #cyan #magenta #yellow ) ) decodeAsLiteralArray
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>ApplicationModel</name> <environment>UI</environment> <super>UI.Model</super> <private>false</private> none builder uiSession eventHandlers savedWindowInformation <imports></imports> <category>UIBuilder-Framework</category> <attributes> <package>UIBuilder-Framework</package> </attributes> </class>