Framework | CommonPanels.framework |
Declared in | FontPanel.h |
The Fonts Panel programming interface is a collection of functions and data types that support the use of a Fonts panel in a Carbon application. The Fonts panel is the preferred user interface for fonts in Mac OS X.
Checks whether the Fonts panel is visible.
Boolean FPIsFontPanelVisible ( void );
Returns true
if the Fonts panel is visible; false
otherwise. See the Mac Types documentation for a description of the Boolean
data type.
FontPanel.h
Shows or hides the Fonts panel.
OSStatus FPShowHideFontPanel ( void );
A result code. See “Fonts Panel Results Codes.”
The function FPShowHideFontPanel
shows the Fonts panel if the panel is not visible and hides the Fonts panel if the panel is visible.
FontPanel.h
Sets the selections that appear in the Fonts panel.
OSStatus SetFontInfoForSelection ( OSType iStyleType, UInt32 iNumStyles, void *iStyles, EventTargetRef iFPEventTarget );
The type of style data you are passing to the Fonts panel. Pass kFontSelectionQDType
if you supply a FontSelectionQDStyle
data structure in the iStyles
parameter. Pass kFontSelectionATSUIType
if you supply ATSUStyle
data in the iStyles
parameter.
The number of styles passed in the iStyles
parameter.
A pointer to an array of data structures that correspond to the style type specified by the iStyleType
parameter.
The event target you want to receive the Carbon event kEventFontSelection
that is associated with the Fonts panel. You typically specify the event target for the window that is sending the style selection to the Fonts panel.
A result code. See “Fonts Panel Results Codes.”
You can programmatically set a selection in the Fonts panel by calling the function SetFontInfoForSelection
. You can call this function even when the Fonts panel is not open or visible. When the Fonts panel becomes visible later, the style information specified in the most recent call to SetFontInfoForSelection
is selected in the panel.
FontPanel.h
Contains QuickDraw style font information.
struct FontSelectionQDStyle { UInt32 version; FMFontFamilyInstance instance; FMFontSize size; Boolean hasColor; UInt8 reserved; RGBColor color; }; typedef struct FontSelectionQDStyle FontSelectionQDStyle; typedef FontSelectionQDStyle * FontSelectionQDStylePtr;
version
Specifies the version number of the data structure.
instance
Specifies a font family instance.
size
Specifies the font size in points.
hasColor
Specifies whether the font has a color other than black.
reserved
Reserved for future use.
color
Specifies the font color.
You should use this data structure to specify QuickDraw-style font information when you call the function SetFontInfoForSelection
. When you use this data structure, you must pass the constant kFontSelectionQDType
in the iStyleTyp
e parameter of the function.
FontPanel.h
A pointer to a data structure that contains QuickDraw style font information.
typedef FontSelectionQDStyle * FontSelectionQDStylePtr;
See FontSelectionQDStyle
for more information.
FontPanel.h
Specifies a Carbon event related to font selection or handling.
enum { kEventClassFont = 'font' };
kEventClassFont
Specifies a Carbon event related to font selection or handling.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
FontPanel.h
Specify a Fonts panel Carbon event.
enum { kEventFontPanelClosed = 1, kEventFontSelection = 2 };
kEventFontPanelClosed
Specifies a close event in the Fonts panel. Your application should update the user interface as necessary. For example, you may need to change a Hide Fonts Panel menu command to Show Fonts Panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kEventFontSelection
Specifies a selection event in the Fonts panel. Your application can obtain the selections from the event parameters associated with this event. Your application must check for all those parameters it handles and apply the selections to the text.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
When the user closes the Fonts panel, the action generates the Carbon event kEventWindowClosed
. You can then update any menu items or other controls whose state may need to change. The event kEventWindowClosed
has no parameters. However, when the user selects an item in the Fonts panel, the system sends the Carbon event kEventFontSelection
to the event target you specified when your application called the Fonts Panel function SetFontInfoForSelection
. The event kEventFontSelection
has parameters that reflect the current Fonts panel selection.
FontPanel.h
Specify the type of font information.
enum { kFontSelectionATSUIType = 'astl', kFontSelectionQDType = 'qstl' };
kFontSelectionATSUIType
Specifies ATSUI data (ATSUStyle
).
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kFontSelectionQDType
Specifies QuickDraw data (FontSelectionQDStyle
).
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
These constants specify the type of font information passed to the function SetFontInfoForSelection
.
FontPanel.h
Specify the supported versions of the FontSelectionQDStyle
data structure.
enum { kFontSelectionQDStyleVersionZero = 0 };
kFontSelectionQDStyleVersionZero
Specifies version 0 of a QuickDraw font selection.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
You should always set the version
field in the FontSelectionQDStyle
data structure to this constant
FontPanel.h
Specifies the four-character code for the show/hide Fonts panel command.
enum { kHICommandShowHideFontPanel = 'shfp' };
kHICommandShowHideFontPanel
Specifies the four-character code for the show/hide Fonts panel command.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
If the user closes the Fonts panel directly, your application receives a kEventFontPanelClosed
Carbon event. You can then call the Carbon Event Manager function GetEventParameter
to extract the HI command from the event.
FontPanel.h
Specify font event parameters and their associated data types.
enum { typeATSUFontID = typeUInt32, typeATSUSize = typeFixed, typeFMFontFamily = typeSInt16, typeFMFontStyle = typeSInt16, typeFMFontSize = typeSInt16, typeFontColor = typeRGBColor, kEventParamATSUFontID = 'auid', kEventParamATSUFontSize = 'ausz', kEventParamFMFontFamily = 'fmfm', kEventParamFMFontStyle = 'fmst', kEventParamFMFontSize = 'fmsz', kEventParamFontColor = 'fclr' };
typeATSUFontID
Specifies that an ATSUFontID
is of type UInt32
.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
typeATSUSize
Specifies that an ATSUSize
is of type Fixed
.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
typeFMFontFamily
Specifies that an FMFontFamily
is of type SInt16
.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
typeFMFontStyle
Specifies that an FMFontStyle
is of type SInt16
.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
typeFMFontSize
Specifies that an FMFontSize
is of type SInt16
.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
typeFontColor
Specifies that a font color is of type RGBColor
.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kEventParamATSUFontID
Specifies the four-character code associated with an ATSUFontID
selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kEventParamATSUFontSize
Specifies the four-character code associated with an ATSUFontSize
selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kEventParamFMFontFamily
Specifies the four-character code associated with an FMFontFamily
selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kEventParamFMFontStyle
Specifies the four-character code associated with an FMFontStyle
selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kEventParamFMFontSize
Specifies the four-character code associated with an FMFontSize
selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
kEventParamFontColor
Specifies the four-character code associated with a font color selection in the Fonts panel.
Available in Mac OS X v10.2 and later.
Declared in FontPanel.h
.
Table 1 lists the parameters and data types associated with the Carbon event kEventFontSelection
.
Parameter |
Data type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
FontPanel.h
The most common result codes returned by the Fonts Panel programming interface are listed below.
Result Code | Value | Description |
---|---|---|
fontPanelShowErr |
-8880 | The Fonts panel could not be opened. Available in Mac OS X v10.2 and later. |
fontPanelSelectionStyleErr |
-8881 | Your application specified an invalid style
type in the Available in Mac OS X v10.2 and later. |
fontPanelFontSelectionQDStyleVersionErr |
-8882 | Your application specified an invalid version
in the Available in Mac OS X v10.2 and later. |
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-26)