Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Implements | |
Package | com.apple.cocoa.application |
Companion guide |
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.
Creates an empty NSFontPanel.
public NSFontPanel
()
Creates a new NSFontPanel.
public NSFontPanel
(NSRect contentRect, int styleMask, int backingType, boolean defer)
The contentRect argument specifies the location and size of the panel’s content area in screen coordinates. Note that the window server limits window position coordinates to ±16,000 and sizes to 10,000.
The styleMask argument specifies the panel’s style. Either it can be NSWindow.BorderlessWindowMask
, or it can contain any of the options described in NSWindow’s “Constants,” combined using the C bitwise OR operator.
Borderless windows display none of the usual peripheral elements and are generally useful only for display or caching purposes; you should normally not need to create them. Also, note that an NSWindow’s style mask should include NSWindow.TitledWindowMask
if it includes any of the others.
The backingType argument specifies how the drawing done in the panel is buffered by the object’s window device, and possible values are described in NSWindow’s “Constants.”
The defer argument determines whether the window server creates a window device for the new panel immediately. If defer is true
, it defers creating the window until the panel is moved onscreen. All display messages sent are postponed until the panel is created, just before it’s moved onscreen. Deferring the creation of the window improves launch time and minimizes the virtual memory load on the window server.
The new panel creates an instance of NSView to be its default content view. You can replace it with your own object by using the setContentView
method.
Creates a new NSFontPanel.
public NSFontPanel
(NSRect contentRect, int styleMask, int backingType, boolean defer, NSScreen aScreen)
This constructor is equivalent to the preceding one, except contentRect is specified relative to the lower-left corner of aScreen.
If aScreen is null
, contentRect is interpreted relative to the lower-left corner of the main screen. The main screen is the one that contains the current key window, or, if there is no key window, the one that contains the main menu. If there’s neither a key window nor a main menu (if there’s no active application), the main screen is the one where the origin of the screen coordinate system is located.
Returns the single NSFontPanel instance for the application, creating it if necessary.
public static NSFontPanel sharedFontPanel
()
Returns true
if the shared Font panel has been created, false
if it hasn’t.
public static boolean sharedFontPanelExists
()
Returns the receiver’s accessory view.
public NSView accessoryView
()
Returns true
if the receiver’s Set button is enabled, false
if it isn’t.
public boolean isEnabled
()
The receiver continues to reflect the font of the selection for cooperating text objects regardless of this setting.
Converts aFont using the settings in the receiver, with the aid of the shared NSFontManager if necessary, and returns the converted font.
public NSFont panelConvertFont
(NSFont aFont)
If aFont can’t be converted it’s returned unchanged.
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.
convertFont
(NSFontManager)Establishes aView as the receiver’s accessory view, allowing you to add custom controls to your application’s Font panel without having to create a subclass.
public void setAccessoryView
(NSView aView)
Controls whether the receiver’s Set button is enabled.
public void setEnabled
(boolean flag)
If flag is 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.
Sets the selected font in the receiver to aFont if flag is false
; otherwise selects no font and displays a message in the preview area indicating that multiple fonts are selected.
public void setPanelFont
(NSFont aFont, boolean flag)
You normally don’t use this method directly; instead, you send setSelectedFont
to the shared NSFontManager, which in turn invokes this method.
Returns true
, regardless of the setting established using the NSPanel method setWorksWhenModal
.
public boolean worksWhenModal
()
This method allows fonts to be changed in modal windows and panels.
worksWhenModal
(NSWindow)worksWhenModal
(NSPanel)The constants in the following table specify the available font panel mode masks. They are available only on Mac OS X v10.3 and later.
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)