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


Inherits From: ActionCell : Cell : Object
Declared In: appkit/TextFieldCell.h

Class Description

A TextFieldCell is simply a text Cell that keeps track of it background and text colors.  Normally, the Cell class assumes white as the background when bezeled, and light gray otherwise, and black text is always used.  With TextFieldCell, you can specify those colors.

Instance Variables

float backgroundGray;

float textGray;

backgroundGray The background gray level.
textGray The text gray level.

Method Types

Initializing a new TextFieldCell
Copying a TextFieldCell copyFromZone:
Setting the TextFieldCell's value
setFloatValue: (Cell)
floatValue (Cell)
setDoubleValue: (Cell)
doubleValue (Cell)
setIntValue: (Cell)
intValue (Cell)
setStringValue: (Cell)
setStringValueNoCopy: (Cell)
setStringValueNoCopy:shouldFree: (Cell)
stringValue (Cell)
Modifying Graphic Attributes setTextColor:
Displaying drawSelf:inView:
Tracking the Mouse trackMouse:inRect:ofView:
Archiving read:

Instance Methods


Returns the color used to draw the background on color displays.

See also:  setBackgroundColor:, backgroundGray


Returns the gray level used to draw the background on monochrome displays.  If the gray level is less than 0, then the background is transparent.

See also:  setBackgroundGray:, backgroundColor

copyFromZone:(NXZone *)zone

Creates and returns a new TextFieldCell as a copy of the receiver, allocated from zone.

drawInside:(const NXRect *)cellFrame inView:controlView

Draws the inside of the TextFieldCell (the background and text, but not the bezel or border).  This method is invoked from drawSelf:inView: and also from Control and its subclasses' drawCellInside: method.  If you subclass TextFieldCell, and you override drawSelf:inView:, then you should override this method as well.  Returns self.

See also:  drawSelf:inView:

drawSelf:(const NXRect *)cellFrame inView:controlView

Draws the TextFieldCell's background, text, and border or bezel.  Returns self.

See also:  drawInside:inView:


Initializes and returns the receiver, a new instance of TextFieldCell, with the default title, "Field".  Other defaults are set as described in initTextCell: below.

See also:  initTextCell:

initTextCell:(const char *)aString

Initializes and returns the receiver, a new instance of TextFieldCell, with aString as its text. The default text gray is NX_BLACK, and the default background gray is transparent (1.0).  Its font is set to the user's system font, and the font size is 12.0 point.

This method is the designated initializer for TextFieldCell.  Override this method if you create a subclass of TextFieldCell that performs its own initialization.  Note that TextFieldCell doesn't override Cell's initIconCell: designated initializer; your code shouldn't use that method to initialize an instance of TextFieldCell.

See also:  init


Returns YES if the background of the TextFieldCell is transparent (that is, if the background gray is less than 0).

See also:  setBackgroundTransparent:, setBackgroundGray:


Returns YES if the TextFieldCell draws over every pixel in its frame.  This will be true if the cell is bezeled, or if its background gray is not transparent.

See also:  setBezeled:, setBackgroundGray:

read:(NXTypedStream *)stream

Reads the TextFieldCell from the typed stream stream.  Returns self.

See also:  write:


Sets the background color for the TextFieldCell to aColor.  The background color is used only on color displays; on monochrome displays, the background gray is used.  Returns self.

See also:  backgroundColor, setBackgroundGray:


Sets the gray level that will be used to draw the background on monochrome displays.  If value is less than 0.0, no background will be drawn.  If the cell is editable, it should have a background gray greater than or equal to 0.0.  Returns self.

See also:  backgroundGray, setBackgroundColor:


If flag is YES, sets the background gray of the TextFieldCell to transparent (a negative value); if NO, sets the background gray to NX_WHITE.  Returns self.

See also:  setBackgroundGray:


If flag is YES, the TextFieldCell is drawn with a bezel around the edge; if NO, nothing is drawn around the text.  If the current background gray is transparent, it's changed to NX_WHITE.  Bezeled transparent TextFieldCells look rather strange, but if you want to have one, invoke setBackgroundGray: with 1.0 after invoking setBezeled:.

See also:  isBezeled (Cell), setBackgroundGray:


Used to set the attributes of the field editor when editing the TextFieldCell (see the TextFieldCell class description).  Sets the background and text colors or gray levels of textObject to those of the TextFieldCell, and returns textObjecttextObject should respond to the messages setBackgroundGray:, setBackgroundColor:, setTextGray:, and setTextColor:.  You rarely need to override this method; you never need to invoke it.

If the TextFieldCell is disabled, then 0.333 is added or subtracted to textObject's brightness level so that the brightness is brought toward the background gray level (if the background is transparent, the text is always made darker).  The gray level is never brought below 0.0 or above 1.0 by this adjustment; this can cause brightly colored text on a white background to look no different when the cell is disabled.

Note that if the TextFieldCell has a transparent background, textObject's background gray isn't changed.  Since a TextFieldCell's background is transparent by default, and the field editor's background could be any gray level or color (depending on where it was last used), this can cause ugly side effects.  Editable TextFieldCells should use an opaque background whenever possible in order to avoid this.

See also:  setTextGray:, setBackgroundGray:, setTextAttributes: (Cell)


Sets the color used to draw the text.  On monochrome displays this can result in unsightly dithering of text, so this method should only be used if the drawing view responds YES to a shouldDrawColor message.  setTextColor: doesn't cause the text to be redrawn.  Returns self.

See also:  textColor, setTextGray:, shouldDrawColor (View)


Sets the gray level used to draw the text, regardless of the color capability of the display.  value should lie in the range 0.0 (indicating black) to 1.0 (indicating white).  To specify one of the four pure shades of gray, use one of these constants:

Constant Shade
NX_LTGRAY Light gray
NX_DKGRAY Dark gray

A setTextGray: message doesn't cause the text to be redrawn.  Returns self.

See also:  textGray, setTextColor:


Returns the color used to draw the text.  Returns self.

See also:  setTextColor:, textGray


Returns the gray level used to draw the text.  Returns self.

See also:  setTextGray:, textColor

inRect:(const NXRect*)aRect

Causes editing to occur, and increments the state of the TextFieldCell if its enabled and the mouse goes up in its frame.  Returns YES if the mouse goes up in the TextFieldCell, NO otherwise.

See also:  trackMouse:inRect:ofView: (Cell)

write:(NXTypedStream *)stream

Writes the receiving TextFieldCell to the typed stream stream.  Returns self.

See also:  read: