Copyright ©1995 by NeXT Computer, Inc.  All Rights Reserved.

FontPanel



Inherits From: Panel : Window : Responder : Object
Declared In: appkit/FontPanel.h



Class Description

The FontPanel is 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 FontManager.  There is only one FontPanel object for each application.

In general, you add the facilities of the FontPanel (and of the other components of the font conversion system:  the FontManager and the Font menu) to your application through Interface Builder.  You do this by dragging a Font menu into one of your application's menus.  At runtime, when the user chooses the Font Panel command for the first time, the FontPanel object will be created and hooked into the font conversion system.  You can also create (or access) the FontPanel through either of the new... methods.

A FontPanel can be customized by adding an additional View object or hierarchy of View objects (see setAccessoryView:).  If you want the FontManager to instantiate a panel object from some class other than FontPanel, use the FontManager's setFontPanelFactory: method.



Instance Variables

id faces;

id families;

id preview;

id current;

id size;

id sizes;

id manager;

id selFont;

NXFontMetrics *selMetrics;

int curTag;

id accessoryView;

id setButton;

id separator;

id sizeTitle;

char *lastPreview;

struct _fpFlags {
unsigned int  multipleFont:1;
unsigned int  dirty:1;

} fpFlags;


faces The Typeface browser.
families The Family browser.
preview The preview field.
current The current font field.
size The Size field.
sizes The Size browser.
manager The FontManager object.
selFont The font of the current selection.
selMetrics The metrics of selFont.
curTag The tag of the currently displayed font.
accessoryView The application-customized area.
currentBox The box displaying the current font.
setButton The Set button.
separator The line separating buttons from upper part of panel.
sizeTitle The title over the Size field and Size browser.
lastPreview The last font previewed.
fpFlags.multipleFont True if selection has multiple fonts.
fpFlags.dirty True if panel was updated while not visible.



Method Types

Creating a FontPanel + new
+ newContent:style:backing:buttonMask:defer:
Setting the font panelConvertFont:
setPanelFont:isMultiple:
Configuring the FontPanel accessoryView
setAccessoryView:
setEnabled:
isEnabled
worksWhenModal
Editing the FontPanel's fields textDidGetKeys:isEmpty:
textDidEnd:endChar:
Displaying the FontPanel orderWindow:relativeTo:
Resizing the FontPanel windowWillResize:toSize:



Class Methods

alloc

Disables the inherited alloc method to prevent multiple FontPanels from being created.  There's only one FontPanel object for each application; you access it through either of the new... methods.  Returns an error message.

See also:  + new, + newContent:style:backing:buttonMask:defer:



allocFromZone:

Disables the inherited allocFromZone method to prevent multiple FontPanels from being created.  There's only one FontPanel object for each application; you access it through either of the new... methods.  Returns an error message.

See also:  + new, + newContent:style:backing:buttonMask:defer:



new
+ new

Returns a FontPanel object by invoking the newContent:style:backing:buttonMask:defer: method.  An application has no more than one Font panel, so this method either returns the previously created object (if it exists) or creates a new one.

See also:  + new



newContent:style:backing:buttonMask:defer:
+ newContent:(const NXRect *)contentRect
style:(int)aStyle
backing:(int)bufferingType
buttonMask:(int)mask
defer:(BOOL)flag

Returns a FontPanel object.  An application has no more than one Font panel, so this method either returns the previously created object (if it exists) or creates a new one.  The arguments are ignored.  This is the designated new... method of the FontPanel class.

See also:  + new



Instance Methods

accessoryView
accessoryView

Returns the application-customized View set by setAccessoryView:.

See also:  setAccessoryView:



isEnabled
(BOOL)isEnabled

Reports whether the Font panel's Set button is enabled.

See also:  setEnabled:



orderWindow:relativeTo:
orderWindow:(int)place relativeTo:(int)otherWin

Repositions the panel in the screen list and updates the panel if it was changed while not visible.  place can be one of:

NX_ABOVE
NX_BELOW
NX_OUT

If it's NX_OUT, the panel is removed from the screen list and otherWin is ignored.  If it's NX_ABOVE or NX_BELOW, otherWin is the window number of the window that the Font Panel is to be placed above or below.  If otherWin is 0, the panel will be placed above or below all other windows.

See also:  orderWindow:relativeTo: (Window), makeKeyAndOrderFront: (Window)



panelConvertFont:
panelConvertFont:fontObj

Returns a Font object whose traits are the same as those of fontObj except as specified by the users choices in the Font Panel. If the conversion can't be made, the method returns fontObj itself.  The FontPanel makes the conversion by using the FontManager's methods that convert fonts.  A panelConvertFont: message is sent by the FontManager whenever it needs to convert a font as a result of user actions in the Font panel.



setAccessoryView:
setAccessoryView:aView

Customizes the Font panel by adding aView above the action buttons at the bottom of the panel.  The FontPanel is automatically resized to accommodate aView.

aView should be the top View in a view hierarchy.  If aView is nil, any existing accessory view is removed.  If aView is the same as the current accessory view, this method does nothing.  Returns the previous accessory view or nil if no accessory view was previously set.

See also:  accessoryView



setEnabled:
setEnabled:(BOOL)flag

Sets whether the Font panel's Set button is enabled (the default state).  Even when disabled, the Font panel allows the user to preview fonts.  However, when the Font panel is disabled, the user can't apply the selected font to text in the application's main window.

You can use this method to disable the user interface to the font selection system when its actions would be inappropriate.  For example, you might disable the font selection system when your application has no document window.

See also:  isEnabled



setPanelFont:isMultiple:
setPanelFont:fontObj isMultiple:(BOOL)flag

Sets the font that the FontPanel is currently manipulating.  This message should only be sent by the FontManager.  Do not send a setPanelFont:isMultiple: message directly.



textDidEnd:endChar:
textDidEnd:textObject endChar:(unsigned short)endChar

A textDidEnd:endChar: message is sent to the FontPanel object when editing is completed in the Size field.  This method updates the Size browser and the preview field.

See also:  textDidGetKeys:isEmpty:, textDidEnd:endChar: (Text)



textDidGetKeys:isEmpty:
textDidGetKeys:textObject isEmpty:(BOOL)flag

A textDidGetKeys:isEmpty: message is sent to the FontPanel object whenever the Size field is typed in or emptied.

See also:  textDidEnd:endChar:, textDidGetKeys:isEmpty: (Text)



windowWillResize:toSize:
windowWillResize:sender toSize:(NXSize *)frameSize

Keeps the FontPanel from being sized too small to accommodate the browser columns and accessory view.

See also:  windowWillResize:toSize: (Window)



worksWhenModal
(BOOL)worksWhenModal

Returns whether the FontPanel will operate while a modal panel is displayed within the application.  By default, this method returns YES.

See also:  worksWhenModal (Panel)