IFontDialog

The IFontDialog class displays a font dialog from which the user can choose a font. Once the user chooses a font, you can use accessor functions to retrieve information about the chosen font.

The easiest way to use this class is to specify an IFont object on the IFontDialog::Settings constructor. This causes the following to happen:

OS/2 Considerations

In OS/2 Presentation Manager, you can have modal windows that do not use the desktop as their parent. However, Presentation Manager can change the owner window of your dialog to something other than what you specified to prevent your application from being hung. See the Presentation Manager Programming Reference, Volume 2 for more information under WinLoadDlg.

The easiest way to ensure that your dialog is modal is to use the desktop as the parent and an application window as the owner. Presentation Manager only disables the owner window and its child windows (the child windows of the child windows, and so forth) while a modal dialog is displayed. If you specify 0 for parent, the desktop automatically becomes the parent of the dialog.


IFontDialog - Member Functions and Data by Group

Constructors & Destructor

You can construct and destruct objects of this class, but you cannot copy them.


[view class]
~IFontDialog
public:
virtual ~IFontDialog()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IFontDialog


Overload 1
public:
IFontDialog( IWindow* parent, IWindow* owner, IHandler* handler, const Style& style = defaultStyle ( ), const Settings& settings = Settings ( 0 ) )

You can construct an object of this class by using this constructor, which accepts a parent, owner, handler, style, and settings as parameters.

To add a IFontDialogHandler to a modal IFontDialog, you must specify the handler on the constructor. Once you create a modal IFontDialog, the dialog does not return control to the application until the user closes the dialog. At that time, it is too late to add a handler.

The parameters for this constructor are the following:

parent
The parent of the dialog box. If you specify 0, the desktop becomes the parent of the dialog.
owner
The owner window.
handler
A pointer to an IHandler object.
style
Use the styles provided by IFontDialog to specify the style. The default creates a modal dialog. To construct a modeless dialog, specify the modeless style. Optional.
settings
Use the settings provided by IFontDialog::Settings to specify the setting. Optional.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
IFontDialog( IWindow* parent, IWindow* owner, const Settings& settings, const Style& style = defaultStyle ( ) )

You can construct an object of this class by using this constructor, which accepts a parent, owner, settings, and style as parameters.

The parameters for this constructor are the following:

parent
The parent of the dialog box. If you specify 0, the desktop becomes the parent of the dialog.
owner
The owner window.
settings
Use the settings provided by IFontDialog::Settings to specify the setting.
style
Use the styles provided by IFontDialog to specify the style. The default creates a modal dialog. To construct a modeless dialog, specify the modeless style. Optional.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 3
public:
IFontDialog( IWindow* parent, IWindow* owner, const Style& style, const Settings& settings )

You can construct an object of this class by using this constructor, which accepts a parent, owner, style, and settings as parameters.

The parameters for this constructor are the following:

parent
The parent of the dialog box. If you specify 0, the desktop becomes the parent of the dialog.
owner
The owner window.
style
Use the styles provided by IFontDialog to specify the style. The default creates a modal dialog. To construct a modeless dialog, specify the modeless style.
settings
Use the settings provided by IFontDialog::Settings to specify the setting.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 4
public:
IFontDialog( IWindow* parent, IWindow* owner, const Style& style = defaultStyle ( ) )

You can construct an object of this class by using this constructor, which accepts a parent, owner, and style as parameters.

The parameters for this constructor are the following:

parent
The parent of the dialog box. If you specify 0, the desktop becomes the parent of the dialog.
owner
The owner window.
style
Use the styles provided by IFontDialog to specify the style. The default creates a modal dialog. To construct a modeless dialog, specify the modeless style. Optional.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Getting Information about the Chosen Font

Use these members to retrieve information about the font selected in the font dialog.


[view class]
emHeight
public:
unsigned long emHeight() const

Returns the height of the Em square for the font.

In traditional composition, the em is a unit of measurement exactly as wide and high as the point size being set. It is called em because the letter M in early fonts was usually cast on a square body. In digital font technology, the em square is a logical rectangle against which digital glyphs (the visible parts of the characters) are laid out. The em square is used to scale fonts to a specific point size. Because the height of the em square is given in pixels, it can be considered the point size in device units. For example, a font could be referred to as a 50-ppem (pixels per em square) font. The pixel size determines the physical point size. A 75-ppem font on a 300-dpi device is an 18-point font; on a 150-dpi device it is a 36-point font. The number of pixels required for the desired point size is computed using the resolution of the output device and the em-square size.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes


[view class]
externalLeading
public:
unsigned long externalLeading() const

Returns the amount of white space between lines of text.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes


[view class]
fontFamily
public:
IString fontFamily() const

Returns the font's family name.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes


[view class]
fontWeight
public:
unsigned long fontWeight() const

Returns the weight class (boldness) of the font.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Ignored

AIX Considerations

This function always returns 0.


[view class]
fontWidth
public:
unsigned long fontWidth() const

Returns the width class of the font.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Ignored

AIX Considerations

This function always returns 0.


[view class]
nominalPointSize
public:
unsigned long nominalPointSize() const

For a bitmap font, the height of the font is returned. For a vector font, the optimal size for the font is returned.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes

AIX Considerations

For scalable fonts, this function returns 0.


[view class]
pointSize
public:
unsigned long pointSize() const

Returns the font's point size.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
xHeight
public:
unsigned long xHeight() const

Returns the height above the baseline for lowercase letters.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes


Getting Information about the Dialog

Use these members to retrieve information about the dialog.


[view class]
backgroundColor
public:
virtual IColor backgroundColor() const

Returns the background color for the dialog frame.

Supported Platforms

Windows OS/2 AIX
Yes Yes No


[view class]
buttonPressedId
public:
unsigned long buttonPressedId() const

Returns the ID of the push button used to end the dialog.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
id
public:
virtual unsigned long id() const

Returns the window identifier of the IFontDialog window.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
isModeless
public:
bool isModeless() const

If the font dialog is modeless, true is returned.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
pressedOK
public:
bool pressedOK() const

If the user ended the dialog by selecting the OK push button, true is returned.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
returnValue
public:
long returnValue() const

If an error occurs, the return code is returned.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
cancel
public:
static const unsigned long cancel

Returned push button ID value when the user dismisses the dialog by pressing the Cancel button.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
ok
public:
static const unsigned long ok

Returned push button ID value when the user dismisses the dialog by pressing the OK button.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Setting Information about the Dialog

Use these members to set specific information about the dialog.


[view class]
setBackgroundColor
public:
virtual IFontDialog& setBackgroundColor( const IColor& color )

Sets the background color for the font dialog frame.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setId
public:
virtual IFontDialog& setId(unsigned long newIdentifier)

Sets the window identifier of the window.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Styles

The style members provide a set of valid font dialog styles for IFontDialog::setDefaultStyle and the constructors of the IFontDialog class.


[view class]
convertToGUIStyle
public:
virtual unsigned long convertToGUIStyle( const IBitFlag& style, bool extendedOnly = false ) const

Converts a style object into a value appropriate for the presentation system. The default action is to return the base GUI styles for the platform. Extended styles, those defined by the application and the Open Class Library, are returned if you set extendedOnly to true.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
defaultStyle
public:
static Style defaultStyle()

Returns the default style. The default style is classDefaultStyle unless you have changed it using setDefaultStyle.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setDefaultStyle
public:
static void setDefaultStyle(const Style& newDefault)

Sets the default style for all subsequent font dialogs.

style
Use the styles provided by IFontDialog to specify the default style.

This member function is not thread safe. In a multithreaded application, it should only be called when a conflict is not possible. A conflict can arise if you set the default style on one thread at the same time that it is being queried on another. In this situation, the query would take place while the style is in an unknown state.

When you create a window class and do not specifically specify window styles in the constructor, the Open Class Library queries the default style. Therefore, the only safe place to call this member function is when no other application threads that create windows are active.

Another way to avoid a conflict in a multithreaded application is to specifically specify window styles on window construction, rather than calling this member function.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
applyButton
public:
static const Style applyButton

Adds an Apply push button to the dialog. The apply button is processed only in a modeless dialog.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
bitmapOnly
public:
static const Style bitmapOnly

Specifies that the dialog present only bitmap font choices.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
classDefaultStyle
public:
static const Style classDefaultStyle

Specifies the original default style for this class. This is a static variable set to 0 indicating that no style flags are set.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
fixedWidthOnly
public:
static const Style fixedWidthOnly

Specifies that the dialog present fixed-width (monospace) fonts only.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
helpButton
public:
static const Style helpButton

Adds a Help push button to the dialog. This push button sends a help message to the owner of the dialog.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
modeless
public:
static const Style modeless

Specifies that the dialog is modeless. The constructor for a modeless dialog returns immediately. To determine the font chosen by the user, create an IFontDialogHandler and use IFontDialog::modelessResults.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
noStyle
public:
static const Style noStyle

Disables all of the valid styles. Use this style only when you are not using any other styles.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
noSynthesize
public:
static const Style noSynthesize

Specifies that the dialog does not manipulate bitmap fonts to synthesize features, such as italics or bold.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
proportionalOnly
public:
static const Style proportionalOnly

Specifies that the dialog present proportionally-spaced fonts only.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes

Windows Considerations
This style is ignored in Windows.

[view class]
resetButton
public:
static const Style resetButton

Adds a Reset push button to the dialog. When this push button is selected, the values for the dialog are restored to their initial values.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes

Windows Considerations
This style is ignored in Windows.

[view class]
vectorOnly
public:
static const Style vectorOnly

Specifies that the dialog present vector fonts only.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IFontDialog - Inherited Member Functions and Data

Inherited Public Functions

IFrameWindow
INotifier
IWindow

Inherited Public Data

IFrameWindow
IWindow
INotifier

Inherited Protected Functions

IFrameWindow
IWindow
INotifier

Inherited Protected Data

IFrameWindow