Inherits from: NSPanel : NSWindow : NSResponder : NSObject
Conforms to: NSCoding
(NSResponder)
NSObject (NSObject)
Declared in: AppKit/NSFontPanel.h
The NSFontPanel class implements the Font Panel-a user-interface object that displays a list of available fonts, letting the user preview them and change the font used to display text. The actual changes are made through conversion messages sent to the shared NSFontManager instance. There's only one Font Panel for each application.
In general, you add the facilities of the Font Panel to your application, along with the NSFontManager and the Font menu, through Interface Builder. You do this by dragging a Font menu into one of your application's menus. At run time, when the user chooses the Font Panel command for the first time, the Font Panel object is created and hooked into the font conversion system. You can also create (or access) the Font Panel using the sharedFontPanel class method.
You can add a custom view object to an NSFontPanel using setAccessoryView:, or limit the fonts display by assigning a delegate to the application's font manager object. If you want the NSFontManager to instantiate the Font Panel from some class other than NSFontPanel, use NSFontManager's setFontPanelFactory: class method. <<JPM: This is ObjC-only since setFontPanelFactory isn't exposed in Java.>>See the NSFontManager class specification for more information on using the font conversion system.
Normally, the application's Font Panel displays all the
standard fonts available on the system. If this isn't appropriate
for your application-for example, if only fixed-pitch fonts should
be used-you can assign a delegate to the NSFontPanel object to
filter the available fonts. Before the NSFontPanel adds a particular
font family or face to its list, it asks its delegate to confirm
the addition by sending the delegate a fontManager:willIncludeFont: message.
If the delegate returns YES
(or doesn't
implement this method), the font is added. If the delegate returns NO
, the
font isn't added.
- Getting the Font Panel
- + sharedFontPanel
- + sharedFontPanelExists
- Enabling font changes
- - setEnabled:
- - isEnabled
- Updating the Font Panel
- - setPanelFont:isMultiple:
- Converting fonts
- - panelConvertFont:
- Working in modal loops
- - worksWhenModal
- Setting an accessory view
- - setAccessoryView:
- - accessoryView
+ (NSFontPanel *)sharedFontPanel
See Also: + sharedFontPanelExists, + setFontPanelFactory: (NSFontManager)
+ (BOOL)sharedFontPanelExists
YES
if
the shared Font Panel has been created, NO
if
it hasn't.See Also: + sharedFontPanel
- (NSView *)accessoryView
See Also: - setAccessoryView:
- (BOOL)isEnabled
YES
if
the receiver's Set button is enabled, NO
if
it isn't. The receiver continues to reflect
the font of the selection for cooperating text objects regardless of
this setting.See Also: - setEnabled:
- (NSFont *)panelConvertFont:(NSFont
*)aFont
For example, if aFont is Helvetica Oblique 12.0 point and the user has selected the Times font family (and nothing else) in the Font Panel, the font returned is Times Italic 12.0 point.
See Also: - convertFont: (NSFontManager)
- (void)setAccessoryView:(NSView
*)aView
See Also: - accessoryView
- (void)setEnabled:(BOOL)flag
YES
the
Set button is enabled; if flag is NO
it's
disabled. The receiver continues to reflect the font of the selection
for cooperating text objects regardless of this setting.See Also: - isEnabled
- (void)setPanelFont:(NSFont
*)aFont isMultiple:(BOOL)flag
NO
,
otherwise selects no font and displays a message in the preview
area indicating that multiple fonts are selected. You
normally don't use this method directly; instead, you send setSelectedFont:isMultiple: to
the shared NSFontManager, which in turn invokes this method.- (BOOL)worksWhenModal
YES
,
regardless of the setting established using the NSPanel method setWorksWhenModal:. This
allows fonts to be changed in modal windows and panels.See Also: - worksWhenModal (NSWindow) - worksWhenModal (NSPanel)