- Inherits from:
- NSPanel : NSWindow : NSResponder : NSObject
- Package:
- com.apple.yellow.application
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. 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, the NSFontPanel asks its delegate
to confirm the addition by sending the delegate a fontManagerWillIncludeFont message.
If the delegate returns true
(or
doesn't implement this method), the font is added. If the delegate
returns false
, the font isn't added.
- Constructors
- NSFontPanel
- Getting the Font Panel
- sharedFontPanel
- sharedFontPanelExists
- Enabling font changes
- setEnabled
- isEnabled
- Updating the Font Panel
- setPanelFont
- Converting fonts
- panelConvertFont
- Working in modal loops
- worksWhenModal
- Setting an accessory view
- setAccessoryView
- accessoryView
public NSFontPanel()
public NSFontPanel(
NSRect aRect,
int anInt,
int anInt,
boolean aBoolean)
public NSFontPanel(
NSRect aRect,
int anInt,
int anInt,
boolean aBoolean,
NSScreen aScreen)
public static NSFontPanel sharedFontPanel()
See Also: sharedFontPanelExists
public static boolean sharedFontPanelExists()
true
if
the shared Font Panel has been created, false
if
it hasn't.See Also: sharedFontPanel
public NSView accessoryView()
See Also: setAccessoryView
public boolean isEnabled()
true
if
the receiver's Set button is enabled, false
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
public 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)
public void setAccessoryView(NSView aView)
See Also: accessoryView
public void setEnabled(boolean flag)
true
the
Set button is enabled; if flag is false
it's
disabled. The receiver continues to reflect the font of the selection
for cooperating text objects regardless of this setting.See Also: isEnabled
public void setPanelFont(
NSFont aFont,
boolean flag)
false
,
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 to the shared NSFontManager,
which in turn invokes this method.public boolean worksWhenModal()
true
,
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)