From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:47:48 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>MenuValueExample</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none letter <imports></imports> <category>Examples-Help</category> <attributes> <package>MenuValue-Example</package> </attributes> </class> <comment> Examples.MenuValueExample
MenuValueExample demonstrates how to implement a menu of values (as opposed to a menu of commands) in each of the three types of menu: menu bar, menu button and pop-up menu.
</comment> <methods> Examples.MenuValueExample <category>initialize-release</category>
initialize letter := self class firstNotice asValue. letter onChangeSend: #setCheckMark to: self.
</methods> <methods> Examples.MenuValueExample <category>aspects</category>
letter ^letter
</methods> <methods> Examples.MenuValueExample <category>interface opening</category>
postBuildWith: aBuilder self setCheckMark
</methods> <methods> Examples.MenuValueExample <category>menu messages</category>
print self letter value asComposedText hardcopy
</methods> <methods> Examples.MenuValueExample <category>change messages</category>
setCheckMark "In the pop-up menu, set the check box to indicate the currently displayed template." | menu item | menu := self builder menuAt: #templatesMenuForPopUp. item := menu menuItemAt: 1. self letter value = self class firstNotice ifTrue: [item beOn] ifFalse: [item beOff]. item := menu menuItemAt: 2. self letter value = self class secondNotice ifTrue: [item beOn] ifFalse: [item beOff]. item := menu menuItemAt: 3. self letter value = self class finalNotice ifTrue: [item beOn] ifFalse: [item beOff].
</methods> <methods> Examples.MenuValueExample <category>resources</category>
templatesMenuForMenuBar | mb menu submenu | mb := MenuBuilder new. mb beginSubMenuLabeled: 'Templates'; add: ' ' -> [self letter value: self class firstNotice]; add: ' ' -> [self letter value: self class secondNotice]; add: ' ' -> [self letter value: self class finalNotice]; endSubMenu. "Add graphic labels." menu := mb menu. submenu := (menu menuItemLabeled: 'Templates') submenu. (submenu menuItemAt: 1) labelImage: (self class oneImage). (submenu menuItemAt: 2) labelImage: (self class twoImage). (submenu menuItemAt: 3) labelImage: (self class threeImage). "Set the background color." submenu backgroundColor: ColorValue chartreuse. ^menu
templatesMenuForMenuButton | mb | mb := MenuBuilder new. mb add: 'First Notice' -> self class firstNotice; add: 'Second Notice' -> self class secondNotice; add: 'Final Notice' -> self class finalNotice. ^mb menu
templatesMenuForPopUp | mb | mb := MenuBuilder new. mb add: 'First Notice' -> [self letter value: self class firstNotice]; add: 'Second Notice' -> [self letter value: self class secondNotice]; add: 'Final Notice' -> [self letter value: self class finalNotice]. ^mb menu
</methods> <methods> Examples.MenuValueExample class <category>templates</category>
finalNotice "Answer a template to be used as the basis for a final-notice letter to a customer with an overdue balance." ^' ', Date today printString, ' -- FINAL NOTICE DEAR <name>, THIS IS YOUR FINAL NOTICE. WE MUST HEAR FROM YOU BY 5:00 PM ON <final date>. AFTER THAT, WE WILL BE FORCED TO TURN YOUR ACCOUNT OVER TO A COLLECTION AGENCY. ALISTAIR ZENGWAT CONTROLLER'.
firstNotice "Answer a template to be used as the basis for a first-notice letter to a customer with an overdue balance." ^' ', Date today printString, ' Dear <name>, Your account shows a past due balance, as shown on the accompanying statement. We would appreciate your attention to this matter at your earliest convenience. Thank you for letting us serve you. Sincerely, Alistair Zengwat Controller'.
secondNotice "Answer a template to be used as the basis for a second-notice letter to a customer with an overdue balance." ^' ', Date today printString, ' Dear <name>, Your account shows a past due balance, as shown on the accompanying statement. This is your second notice regarding this matter. Won''t you please take a moment to help us clear this up. If you have a question about the enclosed statement, please give me a call at 314-1592. Thank you for letting us serve you. Sincerely, Alistair Zengwat Controller'.
</methods> <methods> Examples.MenuValueExample class <category>resources</category>
oneImage "UIMaskEditor new openOnClass: self andSelector: #oneImage" <resource: #image> ^Image extent: 11@15 depth: 1 palette: CoveragePalette monoMaskPalette bits: #[255 224 0 0 241 224 0 0 224 224 0 0 196 96 0 0 156 32 0 0 132 32 0 0 132 32 0 0 132 32 0 0 132 32 0 0 132 32 0 0 159 32 0 0 192 96 0 0 224 224 0 0 241 224 0 0 255 224 0 0 ] pad: 32
threeImage "UIMaskEditor new openOnClass: self andSelector: #threeImage" <resource: #image> ^Image extent: 11@15 depth: 1 palette: CoveragePalette monoMaskPalette bits: #[255 224 0 0 241 224 0 0 224 224 0 0 192 96 0 0 142 32 0 0 145 32 0 0 129 32 0 0 134 32 0 0 129 32 0 0 129 32 0 0 145 32 0 0 206 96 0 0 224 224 0 0 241 224 0 0 255 224 0 0 ] pad: 32
twoImage "UIMaskEditor new openOnClass: self andSelector: #twoImage" <resource: #image> ^Image extent: 11@15 depth: 1 palette: CoveragePalette monoMaskPalette bits: #[255 224 0 0 241 224 0 0 224 224 0 0 192 96 0 0 142 32 0 0 145 32 0 0 129 32 0 0 130 32 0 0 140 32 0 0 144 32 0 0 159 32 0 0 192 96 0 0 224 224 0 0 241 224 0 0 255 224 0 0 ] pad: 32
</methods> <methods> Examples.MenuValueExample class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'MenuValueExample' #min: #(#Point 347 249 ) #bounds: #(#Rectangle 259 175 737 569 ) #flags: 4 #menu: #templatesMenuForMenuBar ) #component: #(#SpecCollection #collection: #( #(#TextEditorSpec #layout: #(#LayoutFrame 1 0 45 0 -1 1 -60 1 ) #name: #textEditor #model: #letter #menu: #templatesMenuForPopUp ) #(#MenuButtonSpec #layout: #(#Rectangle 10 15 150 40 ) #model: #letter #menu: #templatesMenuForMenuButton ) #(#LabelSpec #layout: #(#AlignmentOrigin 0 0.5 -50 1 0.5 0 ) #label: 'Use the menu bar, menu button or pop-up menu to insert' ) #(#LabelSpec #layout: #(#AlignmentOrigin 0 0.5 -30 1 0.5 0 ) #label: 'a value (a new template) in the text editor.' ) #(#ActionButtonSpec #layout: #(#LayoutFrame -70 1 15 0 -10 1 40 0 ) #model: #print #label: 'Print' #defaultable: true ) ) ) )
</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>