From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:47:43 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>MenuEditorExample</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none color sampleText sampleList sampleTable <imports></imports> <category>Examples-Help</category> <attributes> <package>MenuEditor-Example</package> </attributes> </class> <comment> Examples.MenuEditorExample
MenuEditorExample demonstrates a menu created using the MenuEditor. Browse the resource methods for the menu specification, and examine the canvas to see where it is invoked.
</comment> <methods> Examples.MenuEditorExample <category>actions</category>
applyColor | c | c := ColorValue perform: self color value. self backgroundColor: c.
backgroundColor: aColor "For each sample widget, change the background color layer." | wrapper lookPref | self sampleWidgets do: [ :widgetID | wrapper := (self builder componentAt: widgetID). lookPref := wrapper lookPreferences backgroundColor: aColor. wrapper lookPreferences: lookPref].
disableDarkColors | menu submenu darkColors | darkColors := #(#black #red #blue #magenta). menu := self builder menuAt: #colorMenu. menu menuItems do: [ :menuItem | (darkColors includes: menuItem nameKey) ifTrue: [menuItem disable]]. submenu := (menu atNameKey: #colors) submenu. submenu menuItems do: [ :menuItem | (darkColors includes: menuItem nameKey) ifTrue: [menuItem disable]].
enableDarkColors | menu submenu darkColors | darkColors := #(#black #red #blue #magenta). menu := self builder menuAt: #colorMenu. menu menuItems do: [ :menuItem | (darkColors includes: menuItem nameKey) ifTrue: [menuItem enable]]. submenu := (menu atNameKey: #colors) submenu. submenu menuItems do: [ :menuItem | (darkColors includes: menuItem nameKey) ifTrue: [menuItem enable]].
</methods> <methods> Examples.MenuEditorExample <category>aspects</category>
color ^color
sampleList ^sampleList
sampleTable ^sampleTable
sampleText ^sampleText
</methods> <methods> Examples.MenuEditorExample <category>initialize-release</category>
initialize | tableList | color := #white 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.MenuEditorExample <category>private</category>
sampleWidgets ^#( #actionButton #checkBox #radioButton #menuButton #inputField #slider #label #divider #box #region #list #table #textEditor )
</methods> <methods> Examples.MenuEditorExample class <category>resources</category>
colorMenu "MenuEditor new openOnClass: self andSelector: #colorMenu" <resource: #menu> ^#(#Menu #( #(#MenuItem #rawLabel: 'white' #nameKey: #white #value: #white ) #(#MenuItem #rawLabel: 'black' #nameKey: #black #value: #black ) #(#MenuItem #rawLabel: 'colors' #nameKey: #colors #submenu: #(#Menu #( #(#MenuItem #rawLabel: 'red' #nameKey: #red #value: #red ) #(#MenuItem #rawLabel: 'green' #nameKey: #green #value: #green ) #(#MenuItem #rawLabel: 'blue' #nameKey: #blue #value: #blue ) #(#MenuItem #rawLabel: 'cyan' #nameKey: #cyan #value: #cyan ) #(#MenuItem #rawLabel: 'magenta' #nameKey: #magenta #value: #magenta ) #(#MenuItem #rawLabel: 'yellow' #nameKey: #yellow #value: #yellow ) ) #(6 ) nil ) ) ) #(2 1 ) nil ) decodeAsLiteralArray
</methods> <methods> Examples.MenuEditorExample class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'MenuEditorExample' #min: #(#Point 40 20 ) #bounds: #(#Rectangle 636 362 995 842 ) ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#Point 9 15 ) #label: 'Color:' ) #(#MenuButtonSpec #layout: #(#Rectangle 66 18 166 43 ) #model: #color #menu: #colorMenu ) #(#ActionButtonSpec #layout: #(#Rectangle 66 49 166 80 ) #model: #applyColor #label: 'Apply' #isDefault: true #defaultable: true ) #(#DividerSpec #layout: #(#Rectangle 16 97 334 101 ) ) #(#ActionButtonSpec #layout: #(#Point 173 9 ) #model: #disableDarkColors #label: 'Disable Dark Colors' #defaultable: true ) #(#ActionButtonSpec #layout: #(#Point 173 50 ) #model: #enableDarkColors #label: 'Enable Dark Colors' #defaultable: true ) #(#CompositeSpecCollection #collection: #( #(#CheckBoxSpec #layout: #(#Point 7 37 ) #name: #checkBox #label: 'Check Box' ) #(#RadioButtonSpec #layout: #(#Point 7 60 ) #name: #radioButton #label: 'Radio Button' ) #(#MenuButtonSpec #layout: #(#Rectangle 7 96 107 121 ) #name: #menuButton #label: 'Choice1' ) #(#InputFieldSpec #layout: #(#Rectangle 7 126 107 147 ) #name: #inputField ) #(#SliderSpec #layout: #(#Rectangle 7 155 87 179 ) #name: #slider #orientation: #horizontal ) #(#LabelSpec #layout: #(#Point 5 192 ) #name: #label #label: 'Label' ) #(#DividerSpec #layout: #(#Rectangle 6 225 106 229 ) #name: #divider ) #(#GroupBoxSpec #layout: #(#Rectangle 5 229 56 287 ) #name: #box #label: 'Box' ) #(#RegionSpec #layout: #(#Rectangle 0 292 74 342 ) #name: #region #lineWidth: 4 #regionType: #ellipse ) #(#SequenceViewSpec #layout: #(#Rectangle 186 1 286 101 ) #name: #list #model: #sampleList ) #(#TableViewSpec #layout: #(#Rectangle 186 119 286 219 ) #name: #table #model: #sampleTable #showHGrid: true #showVGrid: true ) #(#TextEditorSpec #layout: #(#Rectangle 186 238 286 338 ) #name: #textEditor #model: #sampleText ) #(#ActionButtonSpec #layout: #(#Point 7 0 ) #name: #actionButton #label: 'Action' #defaultable: true ) ) #compositeSpec: #(#CompositeSpec #layout: #(#Rectangle 29 116 315 458 ) ) ) ) ) )
</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>