From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:48:45 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>Font2Example</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none platformFonts <imports></imports> <category>Examples-Help</category> <attributes> <package>Font2-Example</package> </attributes> </class> <comment> Examples.Font2Example
Font2Example demonstrates collecting the host window manager's available fonts, and presenting them for selection in a list. A sample of the selected font is shown in a Label.
</comment> <methods> Examples.Font2Example <category>change messages</category>
changedFont | widget newStyle newFont fd ca | newFont := self platformFonts selection. newFont isNil ifTrue: [^self]. widget := (self builder componentAt: #alphabet) widget. "Create and install a custom text style." fd := FontDescription new name: newFont. ca := CharacterAttributes newWithDefaultAttributes. ca setDefaultQuery: fd. newStyle := TextAttributes characterAttributes: ca. newStyle gridForFont: nil withLead: 2. "Install the new font." widget textStyle: newStyle. "Redisplay the widget." widget invalidate. "Repaint the window in case the new label is smaller than the old label." self builder window refresh.
</methods> <methods> Examples.Font2Example <category>initialize-release</category>
initialize "Do not include vertical fonts, if they exist they have an @ character in the first position of their name" platformFonts := SelectionInList with: (Screen default listFontNames select: [:each | each first ~= $@]). platformFonts selectionIndexHolder onChangeSend: #changedFont to: self.
</methods> <methods> Examples.Font2Example <category>accessing</category>
platformFonts ^platformFonts
</methods> <methods> Examples.Font2Example class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#FullSpec #window: #(#WindowSpec #label: 'Font2Example' #bounds: #(#Rectangle 241 339 718 748 ) ) #component: #(#SpecCollection #collection: #( #(#LabelSpec #layout: #(#AlignmentOrigin 25 0 -5 1 0 1 ) #name: #alphabet #label: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ) #(#SequenceViewSpec #layout: #(#LayoutFrame 1 0 30 0 -1 1 -40 1 ) #flags: 15 #model: #platformFonts ) #(#LabelSpec #layout: #(#Point 10 10 ) #label: 'Select a platform font -- it will be displayed in the alphabet below' #style: #small ) ) ) )
</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>