Not implemented under MacOS
The ChooseFont class implements the pre-defined font-selection dialog. This is a top-level object (i.e. it should not be opened as the child of a window).
To use the dialog, you must first create it using
The style property is impelemted under Windows only (it is ignored under Linux). It defines the fonts which can be selected:
0 = Screen fonts only 1 = Printer fonts 2 = Both
You can also add the following to style:
4 = Include strikeout/underline/color effects 8 = Exclude OEM fonts 16 = ANSI character set fonts only (no Symbol) 32 = Fixed Pitch only 64 = Scalable only 128 = TrueType only
If you have included 4 in the style property, you can also optionally set the initial color selection as the first element of the color property (foreground color only).
Under Windows, if you want to restrict the range of valid font sizes, set the range property to be a two-element vector of the minimum and maximum size, in the current scale of the object. (Remember that the scale defaults to 1, 'character' units.) Setting range to be an empty vector means there is no restriction. (This property is not available under Linux.)
When you are ready to show the dialog, call the Show method. This displays the modal dialog. The user can then select a font; if the Cancel button is pressed, the Show method returns 0. If the OK button is pressed, the Show method returns 1. The font property will contain the selected font as a 4-element nested vector of (Font Face) (Size) (Style) (Character set). You can also read the color property to retrieve the color (if any) selected by the user (only the first element is used).
∇DEMO_ChooseFont;⎕IO;VERSION;DLG  ⍝ Sample function demonstrating use of the ChooseFont object  ⍝  ⍝ Can't run this on a Mac, because it doesn't support the  ⍝ ChooseFont object  ⎕IO←1  VERSION←'⎕' ⎕WI 'version'  →(VERSION=0)/MAC  DLG←'⎕' ⎕NEW 'ChooseFont' ⋄ DLG.scale←3  ⍝  ⍝ Say we want to offer 'effects' (color and strikeout etc)  DLG.style←4  ⍝  ⍝ Set initial values, Arial 12-point bold, red  DLG.font←('Arial' 12 1)  DLG.color←255  ⍝  ⍝ Show the dialog. If user presses Cancel, quit  :If 1=DLG.Show  ⍝ He pressed OK  'Selected font: ',⍕DLG.font  'Selected color: ',⍕1↑DLG.color  :EndIf  →0  MAC:  'This demo cannot be run on the Macintosh because the'  'ChooseFont object is not supported' ∇
Copyright © 1996-2010 MicroAPL Ltd