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

Cell



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



Class Description

The Cell class provides a mechanism for displaying text or icons (that is, named NXImages) in a View without the overhead of a full View subclass.  In particular, it provides much of the functionality of the Text class by providing access to a shared Text object used by all instances of Cell in an Application.  Cells are also extremely useful for placing titles or icons at various locations in a custom subclass of View.

Cell is used heavily by the Control classes to implement their internal workings.  Some subclasses of Control (notably Matrix) allow multiple Cells to be grouped and to act together in some cooperative manner.  Thus, with a Matrix, a group of radio buttons can be implemented without needing a View for each button (and without needing a Text object for the text on each button).

The Cell class provides primitives for displaying text or an icon, editing text, formatting floating point numbers, maintaining state, highlighting, and tracking the mouse.  It has several subclasses:  SelectionCell, NXBrowserCell, and ActionCell (which in turn has the subclasses ButtonCell, SliderCell, TextFieldCell, and FormCell).  Cell's trackMouse:inRect:ofView: method supports the target object and action method used to implement controls.  However, Cell implements target/action features abstractly, deferring the details of implementation to subclasses of ActionCell.

The initIconCell: method is the designated initializer for Cells that display icons.  The initTextCell: method is the designated initializer for Cells that display text.  Override one or both of these methods if you implement a subclass of Cell that performs its own initialization.  If you need to use target and action behavior, you may prefer to override ActionCell, which provides the default implementation of this behavior.

For more information on how Cell is used, see the Control class specification.



Instance Variables

char *contents;

id support;

struct _cFlags1 {
unsigned int state:1;
unsigned int highlighted:1;
unsigned int disabled:1;
unsigned int editable:1;
unsigned int type:2;
unsigned int freeText:1;
unsigned int alignment:2;
unsigned int bordered:1;
unsigned int bezeled:1;
unsigned int selectable:1;
unsigned int scrollable:1;
unsigned int entryType:3;

} cFlags1;

struct _cFlags2 {
unsigned int continuous:1;
unsigned int actOnMouseDown:1; unsigned int floatLeft:4;
unsigned int floatRight:4;
unsigned int autoRange:1;
unsigned int actOnMouseDragged:1; unsigned int noWrap:1;
unsigned int dontActOnMouseUp:1;

} cFlags2;


contents The string for a text Cell; the image name for an icon Cell.
support The Font for a text Cell; the NXImage for an icon Cell.
cFlags1.state The state of the Cell (0 or 1).
cFlags1.highlighted True if the Cell is highlighted.
cFlags1.disabled True if the Cell is disabled.
cFlags1.editable True if the text in the Cell is editable.
cFlags1.type The type of the Cell.
cFlags1.freeText True if the Cell should free contents when freeing the Cell.
cFlags1.alignment The text alignment of the Cell.
cFlags1.bordered True if the Cell has a solid border.
cFlags1.bezeled True if the Cell has a bezeled border.
cFlags1.selectable True if the text is selectable.
cFlags1.scrollable True if the text is scrollable.
cFlags1.entryType Data type accepted when the user types in a text Cell.
cFlags2.continuous True if the Cell sends its action continuously to target while control is active.
cFlags2.actOnMouseDown True if the Cell sends its action on a mouse-down.
cFlags2.floatLeft Digits to left of decimal when text is floating-point number.
cFlags2.floatRight Digits to right of decimal when text is floating-point number.
cFlags2.autoRange True if the Cell autoranges decimal places when text is floating point number.
cFlags2.actOnMouseDragged True if the Cell sends its action every time the mouse changes position.
cFlags2.noWrap True if the Cell wraps text by character, false if by word.
cFlags2.dontActOnMouseUp True if the Cell does not send its action on a mouse-up event.



Method Types

Initializing, copying, and freeing a Cell
init
initIconCell:
initTextCell:
copyFromZone:
free
Determining component sizes calcCellSize:
calcCellSize:inRect:
calcDrawInfo:
getDrawRect:
getIconRect:
getTitleRect:
Setting the Cell's type setType:
type
Setting the Cell's state setState:
incrementState
state
Enabling and disabling the Cell setEnabled:
isEnabled
Setting the icon setIcon:
icon
Setting the Cell's value setDoubleValue:
doubleValue
setFloatValue:
floatValue
setIntValue:
intValue
setStringValue:
setStringValueNoCopy:
setStringValueNoCopy:shouldFree:
stringValue
Interacting with other Cells takeDoubleValueFrom:
takeFloatValueFrom:
takeIntValueFrom:
takeStringValueFrom:
Modifying text attributes setAlignment:
alignment
setFont:
font
setEditable:
isEditable
setSelectable:
isSelectable
setScrollable:
isScrollable
setTextAttributes:
setWrap:
Editing text edit:inView:editor:delegate:event:
endEditing:
select:inView:editor:delegate:start:length:
Validating input setEntryType:
entryType
isEntryAcceptable:
Formatting data setFloatingPointFormat:left:right:
Modifying graphic attributes setBezeled:
isBezeled
setBordered:
isBordered
isOpaque
Setting parameters setParameter:to:
getParameter:
Displaying controlView
drawInside:inView:
drawSelf:inView:
highlight:inView:lit:
isHighlighted
Target and action setAction:
action
setTarget:
target
setContinuous:
isContinuous
sendActionOn:
Assigning a tag setTag:
tag
Handling keyboard alternatives keyEquivalent
Tracking the mouse + prefersTrackingUntilMouseUp
mouseDownFlags
getPeriodicDelay:andInterval:
trackMouse:inRect:ofView:
startTrackingAt:inView:
continueTracking:at:inView:
stopTracking:at:inView:mouseIsUp:
Managing the cursor resetCursorRect:inView:
Archiving read:
write:
awake



Class Methods

prefersTrackingUntilMouseUp
+ (BOOL)prefersTrackingUntilMouseUp

Returns NO by default.  Override this method to return YES if the Cell's View should allow it, after a mouse-down event, to track mouse-dragged and mouse-up events even if they occur outside the Cell's frame.  For example, this method is overridden by SliderCell to ensure that a SliderCell in a Matrix doesn't stop responding to user input (and its neighbor start responding) just because its knob isn't dragged in a perfectly straight line.

See also:  trackMouse:inRect:ofView:



Instance Methods

action
(SEL)action

Returns a null selector.  This method is overridden by Action Cell and subclasses that actually implement a target object and action method.

See also:  setAction:, target



alignment
(int)alignment

Returns the alignment of text in the Cell.  The return value can be one of three constants:  NX_LEFTALIGNED, NX_CENTERED, or NX_RIGHTALIGNED.

See also:  setAlignment:



awake
awake

Used during unarchiving to initialize static variables for the Cell class.  Returns self.

See also:  read:



calcCellSize:
calcCellSize:(NXSize *)theSize

Returns by reference the minimum width and height required for displaying the Cell.  This method invokes calcCellSize:inRect: with the rectangle argument set to a rectangle with very large width and height.  Override this method if that isn't the proper way to calculate the minimum width and height required for displaying the Cell.  Returns self.

See also:  calcCellSize:inRect:



calcCellSize:inRect:
calcCellSize:(NXSize *)theSize inRect:(const NXRect *)aRect

Returns by reference the minimum width and height required for displaying the Cell in the given rectangle.  If it's not possible to fit, the width and/or height could be bigger than the ones of the provided rectangle.  The computation is done by trying to size the Cell so that it fits in the rectangle argument (for example, by wrapping the text).  If a choice must be made between extending the width or height of aRect to fit text, the height will be extended.  Returns self.

See also:  calcCellSize:



calcDrawInfo:
calcDrawInfo:(const NXRect *)aRect

Does nothing and returns self.  Objects using Cells generally maintain a flag that informs them if any of their Cells has been modified in such a way that the location or size of the Cell should be recomputed.  If so, calcSize is automatically invoked before displaying the Cell; that method invokes Cell's calcDrawInfo: for each Cell.

See also:  calcSize (Matrix)



continueTracking:at:inView:
(BOOL)continueTracking:(const NXPoint *)lastPoint
at:(const NXPoint *)currentPoint
inView:aView

Determines whether or not the Cell should keep tracking the mouse based on the positions provided.  Returns YES if it can keep tracking, NO if should not.  This method is invoked by trackMouse:inRect:ofView: as the mouse is dragged around inside the Cell.  lastPoint and currentPoint should be in aView's coordinate system.  By default, this method returns YES when the Cell is continuous (that is, when it should continually send action messages while the mouse is pressed or dragged).  This method is often overridden to provide more sophisticated tracking behavior.

See also:  trackMouse:inRect:ofView:, startTrackingAt:inView:, stopTracking:at:inView:mouseIsUp:



controlView
controlView

Returns nil.  This method is implemented abstractly, since Cell doesn't record the View in which it's drawn.  This method is overridden by ActionCell and its subclasses, which use the control View as the only argument in the action message when it's sent to the target.

See also:  controlView (ActionCell), drawSelf:inView:, drawInside:inView:



copyFromZone:
copyFromZone:(NXZone *)zone

Allocates, initializes, and returns a copy of the receiving Cell.  The copy is allocated from zone and is assigned the same contents as the receiver.  When you subclass Cell, override this method to send the message

[super copyFromZone:zone];

then copy each of the subclass's unique instance variables separately in that same zone.

See also:  copy (Object)



doubleValue
(double)doubleValue

Returns the receiving text Cell's value as a double-precision floating point number, by converting its string contents to a double using the standard C function atof().  Returns 0.0 if the Cell isn't a text Cell.

See also:  setDoubleValue:, floatValue, intValue, stringValue, type



drawInside:inView:
drawInside:(const NXRect *)cellFrame inView:aView

Draws the "inside" of the Cell.  For the base Cell class, it's the same as drawSelf:inView: except that it doesn't draw the bezel or border if there is one.  cellFrame should be the frame of the Cell (that is, the same as the cellFrame passed to drawSelf:inView:), not the rectangle returned by getDrawRect:.  The PostScript focus must be locked on aView when this method is invoked.  If the Cell's highlight flag is YES, then the Cell is highlighted (by swapping light gray and white throughout cellFrame; see the description of the Display PostScript operator compositerect for a description of highlighting).  Returns self.

drawInside:inView: is usually invoked from the Control class's drawCellInside: method and is used to cause minimal drawing to be done in order to update the value displayed by the Cell when the contents is changed.  This becomes more important in more complex Cells such as ButtonCell and SliderCell.

All subclasses of Cell which override drawSelf:inView: must override drawInside:inView:drawInside:inView: should never invoke drawSelf:inView:, but drawSelf:inView: can--and often does--invoke drawInside:inView:.

See also:  drawSelf:inView:, lockFocus (View), highlight:inView:lit:, isHighlighted, compositerect (Display PostScript operator)



drawSelf:inView:
drawSelf:(const NXRect *)cellFrame inView:aView

Displays the contents of a Cell in a given rectangle of a given view.  Your code must lock the focus on aView before invoking this method.  It draws the border or bezel (if any), then invokes drawInside:inView:.  A text Cell displays its text in the rectangle by using a global Text object.  An icon Cell displays its icon centered in the rectangle if it fits in the rectangle, or by setting the icon origin on the rectangle origin if it doesn't fit.  Nothing is displayed for a Cell of type NX_NULLCELL.  Override this method if you want a display that is specific to your own subclass of Cell.  Returns self.

See also:  drawInside:inView:, lockFocus (View)



edit:inView:editor:delegate:event:
edit:(const NXRect *)aRect
inView:aView
editor:textObject
delegate:anObject
event:(NXEvent *)theEvent

Begins editing of a Cell's text by using the Text object textObject in response to an NX_MOUSEDOWN event.  aRect must be the one you have used when displaying the Cell.  theEvent is the NX_MOUSEDOWN event.  anObject is made the delegate of the Text object textObject used for the editing:  it will receive messages such as textDidEnd:endChar:, textWillEnd, textDidResize, textWillResize, and others sent by the Text object while editing.  If the receiver isn't a text Cell, no editing is performed, otherwise the Text object is sized to aRect and its superview is set to aView, so that it exactly covers the Cell.  Then it's activated and editing begins.  It's the responsibility of the delegate to end the editing, remove any data from textObject and invoke endEditing: on the Cell in the textDidEnd:endChar: method.  Returns self.

See also:  endEditing:, select:inView:editor:delegate:start:length:, Text class (Methods Implemented by the Delegate)



endEditing:
endEditing:textObject

Ends editing begun with edit:inView:editor:delegate:event: or select:inView:editor:delegate:start:length:.  Usually this method is invoked by the textDidEnd:endChar: method of the object you are using as the delegate for the Text object (most often a Matrix or TextField).  This method should remove the Text object from the view hierarchy and sets its delegate to nil. Returns self.

See also:  edit:inView:editor:delegate:event:, select:inView:editor:delegate:start:length:,  textDidEnd:endChar: (Text class delegate method)



entryType
(int)entryType

Returns the type of data allowed in the Cell.  See setEntryType: for the list of valid types.

See also:  setEntryType:



floatValue
(float)floatValue

Returns the receiving text Cell's value as a single-precision floating point number, by converting its string contents to a double using the C function atof() and then casting the result to a float.  Returns 0.0 if the receiver isn't a text Cell.

See also:  setFloatValue:, doubleValue, intValue, stringValue, type



font
font

Returns the Font used to display text in the Cell.  Returns nil if the receiver isn't a text Cell.

See also:  setFont:, type



free
free

Frees the memory used by the Cell and returns nil.  If the Cell's contents was set by copy (the default), then the contents is also freed.



getDrawRect:
getDrawRect:(NXRect *)theRect

Given the bounds of the Cell in theRect, this method changes it to be the rectangle into which the Cell would draw its "insides" (everything but a bezel or border), and returns it by reference.  In other words, this method calculates the rectangle which is touched by drawInside:inView:.  However, your code should not use the rectangle returned by this method as the argument to drawInside:inView:.  Returns self.

See also:  getIconRect:, getTitleRect:, drawInside:inView:



getIconRect:
getIconRect:(NXRect *)theRect

Given the bounds of the Cell in theRect, this method changes it to be the rectangle into which the Cell would draw its icon, and returns it by reference.  If the Cell doesn't draw an icon, theRect is untouched.   Your code should not use the rectangle returned by this method as the argument to drawInside:inView:.  Returns self.

See also:  getDrawRect:, getTitleRect:, drawInside:inView:



getParameter:
(int)getParameter:(int)aParameter

Returns the value of one of the frequently accessed flags for a Cell.  See setParameter:to: for a list of the parameters and corresponding methods.  Since the parameters are also accessible through methods such as isEnabled and isHighlighted, you shouldn't need to use this method often.

See also:  setParameter:to:



getPeriodicDelay:andInterval:
getPeriodicDelay:(float*)delay andInterval:(float*)interval

Returns by reference two values:  the amount of time (in seconds) that a continuous button will pause before starting to periodically send action messages to the target object, and the interval (also in seconds) at which those messages are sent. Periodic messaging behavior is controlled by Cell's sendActionOn: and setContinuous: methods.  (By default, Cell sends the action message only on mouse up events.)  Override this method to return your own values.  Returns self.

See also:  setContinuous:, sendActionOn:



getTitleRect:
getTitleRect:(NXRect *)theRect

Returns self, and, by reference in theRect, the rectangle into which the text will be drawn.  If this Cell doesn't draw any text, theRect is untouched.  Your code should not use the rectangle returned by this method as the argument to drawInside:inView:. Returns self.

See also:  getDrawRect:, getIconRect:, drawInside:inView:



highlight:inView:lit:
highlight:(const NXRect *)cellFrame
inView:aView
lit:(BOOL)flag

If the Cell's highlight status is different from flag, sets the Cell's highlight status to flag and, if flag is YES, highlights the rectangle cellFrame in aView.  Your code must lock focus on aView before invoking this method.  This method composites with NX_HIGHLIGHT inside the bounds of cellFrame.  Override this method if you want more sophisticated highlighting behavior in a Cell subclass.  Returns self.

Note that the highlighting that the base Cell class does will not appear when printed (although subclasses like TextFieldCell, SelectionCell, and ButtonCell can print themselves highlighted).  This is because the base Cell class is transparent, and there is no concept of transparency in printed output.

See also:  isHighlighted, drawSelf:inView:, drawInside:inView:



icon
(const char *)icon

Returns the name of the icon currently used by the Cell, if any, or NULL if the receiver isn't an icon Cell.

See also:  setIcon:, title



incrementState
incrementState

Adds 1 to the state of the Cell, wrapping around to 0 from the maximum value (which, for the Cell class, is 1).  Returns self.

Subclasses may want to change the meaning of this method (to create multistate Cells, for example).  Remember that if you want the visual appearance of the Cell to reflect a change in state, you must invoke drawSelf:inView: after altering the state. Your drawSelf:inView: implementation must draw the different states in different ways, since the default implementation doesn't do so.

See also:  setState:, drawSelf:inView:



init
init

Initializes and returns the receiver, a new Cell instance, as type NX_NULLCELL.  This method is the designated initializer for cells without either text or an icon.

See also:  initIconCell:, initTextCell:, setIcon:, setText:



initIconCell:
initIconCell:(const char *)iconName

Initializes and returns the receiver, a new icon Cell instance (that is, its type is NX_ICONCELL).  The icon is set to an NXImage with the name iconName.  If iconName is NULL or an image for iconName is not found, the Cell will be initialized with a default icon, "NXsquare16".  This method is the designated initializer for Cells that display an icon.  If the Cell later has text assigned, its type will automatically change.

See also:  icon, setIcon:, initTextCell:,  setText:, init, findImageFor: (NXImage), name (NXImage)



initTextCell:
initTextCell:(const char *)aString

Initializes and returns the receiver, a new text Cell instance, (that is, its type is NX_TEXTCELL).  The string value is set to aString, or "Cell" if aString is NULL.  This method is the designated initializer for text Cells.

See also:  title, setTitle:, initIconCell:, setIcon:, init



intValue
(int)intValue

Returns the receiving text Cell's value as an integer, by converting its string contents to an int using the C function atoi(). Returns 0 if the receiver isn't a text Cell.

See also:  setIntValue:, doubleValue, floatValue, stringValue, type:



isBezeled
(BOOL)isBezeled

Returns YES if the Cell draws itself with a bezeled border, NO otherwise.  The default is NO.

See also:  setBezeled:, isBordered



isBordered
(BOOL)isBordered

Returns YES if the Cell draws itself surrounded by a 1-pixel black frame, NO otherwise.  The default is NO.

See also:  setBordered:, isBezeled



isContinuous
(BOOL)isContinuous

Returns YES if the Cell continuously sends its action message to the target object when tracking.  This usually has meaning only for subclasses of Cell that implement instance variables and methods for target/action functionality, such as ActionCell; certain Control subclasses, specifically Matrix, send a default action to a default target even if the Cell doesn't have a target and action.

See also:  setContinuous:, target, action



isEditable
(BOOL)isEditable

Returns YES if text in the Cell is editable (and therefore also selectable), NO otherwise.  The default is NO.

See also:  setEditable:, isSelectable



isEnabled
(BOOL)isEnabled

Returns YES if the Cell is enabled, NO otherwise.  The default is YES.  A Cell's enabled status is used primarily in event handling and display:  It affects the behavior of methods for mouse tracking and text editing, by allowing or disallowing changes to the Cell within those methods, and only allows the Cell to highlight or set a cursor rectangle if it's enabled.  You can still affect many Cell attributes programmatically (setState:, for example, will still work).

See also:  setEnabled:, trackMouse:inRect:ofView:



isEntryAcceptable:
(BOOL)isEntryAcceptable:(const char *)aString

Tests whether aString matches the Cell's entry type, as set by the setEntryType: method.  Returns YES if aString is acceptable by the receiving Cell, NO otherwise.  For example, a text Cell of type NX_INTTYPE accepts strings that represent integers, but not floating point numbers or words.  If aString is NULL or empty, this method returns YES.

This method is invoked by Form, Matrix, and other Controls to see if a new text string is acceptable for this Cell.  This method doesn't check for overflow.  It can be overridden to enforce specific restrictions on what the user can type into the Cell.

See also:  setEntryType:



isHighlighted
(BOOL)isHighlighted

Returns YES if the Cell is highlighted, NO otherwise.

See also:  highlight:inView:lit:



isOpaque
(BOOL)isOpaque

Returns YES if the Cell is opaque (that is, if it draws over every pixel in its frame), NO otherwise.  The base Cell class is opaque if and only if it draws a bezel.  Subclasses that draw differently should override this based on how they perform their drawing.

See also:  setBezeled:



isScrollable
(BOOL)isScrollable

Returns YES if typing past an end of the text in the Cell will cause the Cell to scroll to follow the typing.  The default return value is NO.

See also:  setScrollable:



isSelectable
(BOOL)isSelectable

Returns YES if the text in the Cell is selectable, NO otherwise.  The default is NO.

See also:  setSelectable:, isEditable



keyEquivalent
(unsigned short)keyEquivalent

Returns 0, as Cell provides no support for key equivalents.  Subclasses can implement key equivalents, and can override this method to return the key equivalent for the receiver.

See also:  setKeyEquivalent: (ButtonCell), keyEquivalent (ButtonCell)



mouseDownFlags
(int)mouseDownFlags

Returns the flags (for example, NX_SHIFTMASK) that were set when the mouse went down to start the current tracking session.  This method is only valid during tracking.  It doesn't work if the target of the Cell initiates another Cell tracking loop as part of its action method (as does PopUpList).

See also:  sendActionOn:



read:
read:(NXTypedStream *)stream

Reads the Cell from the typed stream stream.

See also:  write:, awake



resetCursorRect:inView:
resetCursorRect:(const NXRect *)cellFrame inView:aView

If the receiver is a textCell, then a cursor rectangle is added to aView (with addCursorRect:cursor:).  This allows the cursor to change to an I-beam when it passes over the Cell.  Override this method to change the cursor for an icon Cell, or to provide a different cursor for a text Cell.

See also:  addCursorRect:cursor: (View, Control)



select:inView:editor:delegate:start:length:
select:(const NXRect *)aRect
inView:aView
editor:aTextObject
delegate:anObject
start:(int)selStart
length:(int)selLength

Uses aTextObj to select text in the Cell identified by selStart and selLength, which will be highlighted and selected as though the user had dragged the cursor over it.  This method is similar to edit:inView:editor:delegate:event:, except that it can be invoked in any situation, not only on a mouse-down event.

See also:  edit:inView:editor:delegate:event:



sendActionOn:
(int)sendActionOn:(int)mask

Resets flags to determine when the action is sent to the target while tracking.  Can be any logical combination of:

NX_MOUSEUPMASK
NX_MOUSEDOWNMASK
NX_MOUSEDRAGGEDMASK
NX_PERIODICMASK

The default is NX_MOUSEUPMASK.  You can also use the setContinuous: method to turn on the flag corresponding to NX_PERIODICMASK (cflags2.continuous) or NX_MOUSEDRAGGEDMASK (cflags2.actOnMouseDragged), whichever is appropriate to the given subclass of Cell.

This method returns an event mask built from the old flags.

See also:  setContinuous:



setAction:
setAction:(SEL)aSelector

Does nothing.  This method is overridden by Action Cell and its subclasses, which actually implement the target object and action method.  It is also overriden by NXBrowserCell to provide access to its NXBrowser's action method.  Returns self.

See also:  action, setTarget:



setAlignment:
setAlignment:(int)mode

Sets the alignment of text in the Cell.  mode should be one of three constants:  NX_LEFTALIGNED, NX_CENTERED, or NX_RIGHTALIGNED.  Returns self.

See also:  alignment, setWrap:



setBezeled:
setBezeled:(BOOL)flag

If flag is YES, then the Cell draws itself surrounded by a bezel; if NO, it doesn't.  setBordered: and setBezeled: are mutually exclusive.  Returns self.

See also:  isBezeled, setBordered:



setBordered:
setBordered:(BOOL)flag

If flag is YES, then the Cell draws itself surrounded by a 1-pixel black frame; if NO, it doesn't.  setBordered: and setBezeled: are mutually exclusive.  Returns self.

See also:  isBordered, setBezeled:



setContinuous:
setContinuous:(BOOL)flag

Sets whether a Cell continuously sends its action message to the target object when tracking.  Normally, this method will set the continuous (cflags2.continuous) or the mouse-dragged flag (cflags2.actOnMouseDragged), depending on which setting is appropriate to the subclass implementing it.  In the base Cell class, this method sets the continuous flag.  These settings usually have meaning only for ActionCell and its subclasses which implement the instance variables and methods that provide target/action functionality.  Some Control subclasses, specifically Matrix, send a default action to a default target when a Cell doesn't provide a target or action.

See also:  isContinuous, sendActionOn:



setDoubleValue:
setDoubleValue:(double)aDouble

Sets the contents of the Cell to the string value representing the double-precision floating point number aDouble, ignoring the entry type of the Cell.  Does nothing if the receiver isn't a text Cell.  Returns self.

See also:  doubleValue, setFloatValue:, setIntValue:, setStringValue:, entryType, type



setEditable:
setEditable:(BOOL)flag

If flag is YES, then the text is made both editable and selectable.  If flag is NO, and the text was not selectable before editing was last enabled (that is, before this message was last sent with an argument of YES), then the text is returned to not being selectable.  Returns self.

See also:  isEditable, setSelectable:, edit:inView:editor:delegate:event:



setEnabled:
setEnabled:(BOOL)flag

Sets the enabled status of the Cell.  A Cell's enabled status is used primarily in event handling and display:  It affects the behavior of methods for mouse tracking and text editing, by allowing or disallowing changes to the Cell within those methods, and only allows the Cell to highlight or set a cursor rectangle if it's enabled.  Many Cell attributes can still be altered programmatically (setState:, for example, will still work).  Returns self.

See also:  isEnabled



setEntryType:
setEntryType:(int)aType

This method sets the data format allowed in the Cell.  aType is one of these seven constants, allowing only the corresponding numeric string values to be entered:

NX_ANYTYPE No restrictions
NX_INTTYPE Integer values
NX_FLOATTYPE Single-precision floating point values
NX_DOUBLETYPE Double-precision floating point values
NX_POSINTTYPE Positive integer values
NX_POSFLOATTYPE Positive single-precision floating point values
NX_POSDOUBLETYPE Positive double-precision floating point values

If the receiver isn't a text Cell, it's converted to type NX_TEXTCELL, in which case its font is set to the user's system font at 12.0 point, and its string value is set to "Cell" (even for text Cells that display numbers).

The entry type is checked by the isEntryAcceptable: method.  That method is used by Controls that contain editable text (such as Matrix and TextField) to validate that what the user has typed is correct.  If you want to have a custom Cell accept some specific type of data (other than those listed above), override the isEntryAcceptable: method to check for the validity of the data the user has entered.

See also:  entryType, isEntryAcceptable:, setFloatingPointFormat:left:right:



setFloatingPointFormat:left:right:
setFloatingPointFormat:(BOOL)autoRange
left:(unsigned int)leftDigits
right:(unsigned int)rightDigits

Sets whether floating-point numbers are autoranged, and sets the sizes of the fields to the left and right of the decimal point. leftDigits specifies the maximum number of digits to the left of the decimal point, and rightDigits specifies the number of digits to the right (the fractional digit places will be padded with zeros to fill this width).  However, if a number is too large to fit its integer part in leftDigits digits, as many places as are needed on the left are effectively removed from rightDigits when the number is displayed.

If autoRange is YES, leftDigits and rightDigits are simply added to form a maximum total field width for the Cell (plus 1 for the decimal point).  The fractional part will be padded with zeros on the right to fill this width, or truncated as much as possible (up to removing the decimal point and displaying the number as an integer).  The integer portion of a number is never truncated--that is, it is displayed in full no matter what the field width limit is.

leftDigits must be between 0 and 10.  rightDigits must be between 0 and 14.  If leftDigits is 0, then the default printf() formatting applies.  If rightDigits is 0, then the decimal and the fractional part of the floating-point number are truncated (that is, the floating-point number is printed as if it were an integer).  If the entry type of the Cell isn't already NX_FLOATTYPE, NX_POSFLOATTYPE, NX_DOUBLETYPE, or NX_POSDOUBLETYPE, it's set to NX_FLOATTYPE.  Returns self.

See also:  setEntryType:



setFloatValue:
setFloatValue:(float)aFloat

Sets the contents of the Cell to the string value representing the single-precision floating point number aFloat, ignoring the entry type of the Cell.  Does nothing if the receiver isn't a text Cell.  Returns self.

See also:  floatValue, setDoubleValue:, setIntValue:, setStringValue:, entryType, type



setFont:
setFont:fontObject

Sets the Font to be used when displaying text in the Cell.  Does nothing if the receiver isn't a text Cell.  Returns self.

See also:  font



setIcon:
setIcon:(const char *)iconName

Sets the Cell's icon to iconName (an NXImage object with that name).  iconName is stored as the Cell's contents, and the NXImage is stored as its support.  If the Cell isn't an icon cell, it's converted; if the Cell was a text Cell, the text string is freed if necessary.  If iconName is NULL or an empty string, or if an image can't be found for iconName, the Cell has its icon set to the standard system bitmap "NXsquare16".

If you specify a name for which an image can't be found, no change is made.  Your code can verify that the icon was properly changed by comparing the values returned by the type or icon methods before and after invoking setIcon:.  Returns self.

See also:  icon, findImageNamed (NXImage), initIconCell:



setIntValue:
setIntValue:(int)anInt

Sets the contents of the Cell to the string value representing the integer anInt.  Does nothing if the receiver isn't a text Cell. This method ignores the entry type of the Cell.  Returns self.

See also:  intValue, setDoubleValue:, setFloatValue:, setStringValue:, type, entryType



setParameter:to:
setParameter:(int)aParameter to:(int)value

Sets the value of one of the Cell's parameters to value, and returns self.  You don't normally use this method, since these parameters can be set using specific methods such as setEditable:.  In this method, the parameters is identified by aParameter, a symbolic constant defined in the header file appkit/Cell.h.  The following table lists these constants with the corresponding methods for setting and getting the value of the related parameters:

Parameter Constant Equivalent Methods
NX_CELLDISABLED setEnabled:, isEnabled
NX_CELLHIGHLIGHTED highlightInView:lit:, isHighlighted
NX_CELLSTATE setState:, incrementState, state
NX_CELLEDITABLE setEditable:, isEditable

Use of this method is discouraged as it could produce unpredictable results in subclasses.  It's much safer to invoke the appropriate parameters-specific method.

See also:  getParameter:



setScrollable:
setScrollable:(BOOL)flag

Sets whether the Cell will scroll to follow typing while being edited.  Returns self.

See also:  isScrollable, edit:inView:editor:delegate:event:



setSelectable:
setSelectable:(BOOL)flag

If flag is YES, then the text is made selectable but not editable.  If NO, then the text is static (neither editable nor selectable). To make text in a Cell both selectable and editable, send it a setEditable: message.  Returns self.

See also:   isSelectable:, isEditable, edit:inView:editor:delegate:event:



setState:
setState:(int)value

Sets the state of the Cell to 0 if value is 0, to 1 otherwise.  Returns self.

See also:  state, incrementState



setStringValue:
setStringValue:(const char *)aString

Copies aString as the receiver's contents.  If the receiver isn't a text Cell, this method converts it to that type, setting its font to the user's system font at 12 points.  Returns self.

If the receiver was an icon Cell, the NXImage for that icon is not freed; your code should retrieve it beforehand and free it after sending this message.

If floating point formatting has been set (with setFloatingPointParameters:left:right:) and the entry type of the Cell is a floating point number type, then the string is tested to determine whether it represents a floating point number; if so, the string is displayed according to that floating point format.

See also:  setStringValueNoCopy:, setStringValueNoCopy:shouldFree:, stringValue, setDoubleValue:, setFloatValue:, setIntValue:,  setFloatingPointFormat:left:right:



setStringValueNoCopy:
setStringValueNoCopy:(const char *)aString

Similar to setStringValue: but doesn't make a copy of aString.  The Cell records that it doesn't have to dispose of its contents when it receives a free message.  Note that if a string is set this way, floating-point formatting can't be applied (since a shared string can't be altered).  Returns self.

See also:  setStringValue:, setStringValueNoCopy:shouldFree:, stringValue



setStringValueNoCopy:shouldFree:
setStringValueNoCopy:(char *)aString shouldFree:(BOOL)flag

Similar to setStringValueNoCopy:, but the sender can specify in flag if the contents should be freed when the Cell receives a free message.  Note that if a string is set this way, floating-point formatting isn't applied.  Returns self.

If the contents was already the same string as aString (the same pointer, not the same string value), the free-contents flag can't be set set to YES.  That is, you can't set a string as non-freeable and later change it to be freeable by reinvoking this method with that same string; you can, however, change it from freeable to nonfreeable.

See also:  setStringValue:, setStringValueNoCopy:, stringValue



setTag:
setTag:(int)anInt

Does nothing.  This method is overridden by ActionCell and its subclasses to support Controls with multiple Cells (Matrix and Form).  Override this method to provide a way to identify Cells.  Returns self.

See also:  tag, findCellWithTag: (Matrix, Menu classes)



setTarget:
setTarget:anObject

Does nothing.  This method is one of several overridden by ActionCell and subclasses to implement target/action functionality. Returns self.

See also:  setAction:, target, action, ActionCell



setTextAttributes:
setTextAttributes:textObject

Invoked just before any drawing or editing occurs in the Cell.  This method is intended to be overridden.  If you do override this method you must include this line first:

[super setTextAttributes:textObject];

If you don't, you risk inheriting drawing attributes from the last Cell which drew any text.  You should invoke only the setBackgroundGray: and setTextGray: Text instance methods.  Don't set any other parameters in the Text object.

This method normally returns textObject.  If you want to substitute some other Text object to draw with (but not edit, since editing always uses the window's field editor), you can return that object instead of textObject and it will be used for the draw that caused setTextAttributes: to be invoked.

TextFieldCell, a subclass of ActionCell, allows you to set the grays without creating your own subclass of Cell.  You only need to subclass Cell to control the gray values if you don't want all the functionality (and instance variable usage) of an ActionCell.

The default values for text attributes are as follows.  If the Cell is enabled, its text gray will be NX_BLACK, otherwise it will be NX_DKGRAY.  If the Cell has a bezel, then its background gray will be NX_WHITE, otherwise it will be NX_LTGRAY. The Text object does not paint the background gray before drawing; it only uses the background gray to erase characters while editing.  The Cell class does paint the NX_WHITE background when it draws a bezeled Cell, but doesn't paint any background otherwise (that is, it's transparent).

Note that most of the other text object attributes can be set with Cell methods (setFont:, setAlignment:, setWrap:) so you need only override this method if you need to set the gray values.  Returns self.



setType:
setType:(int)aType

Sets the type of the Cell.  aType should be NX_TEXTCELL, NX_ICONCELL, or NX_NULLCELL.  If  aType is NX_TEXTCELL and the receiver isn't currently a text Cell, then the font is set to the user's system font in 12.0 point; its string value is set to "Cell".  If aType is NX_ICONCELL and the receiver isn't an icon Cell, then the icon set to the default, "NXsquare16".

See also:  type, init, initIconCell:, initTextCell:, setIcon:, setText:



setWrap:
setWrap:(BOOL)flag

If flag is YES, text will be wrapped to word breaks.  If flag is NO, it will be truncated.  The default is YES.  This setting has effect only when displaying text, not when editing, and only applies to Cells whose alignment is NX_LEFTALIGNED (centered and right-aligned text always wraps to word breaks).

See also:  setAlignment:



startTrackingAt:inView:
(BOOL)startTrackingAt:(const NXPoint *)startPoint inView:aView

This method is invoked from trackMouse:inRect:ofView: the first time the mouse appears in the Cell needing to be tracked. Override to provide implementation-specific tracking behavior.  This method should return YES if it's OK to track based on this starting point, and only if the Cell is continuous; otherwise it should return NO.

See also:  trackMouse:inRect:ofView:, continueTracking:at:inView:, stopTracking:at:inView:mouseIsUp:, isContinuous, mouseDownFlags



state
(int)state

Returns the state of the Cell (0 or 1).  The default is 0.

See also:  setState:, incrementState



stopTracking:at:inView:mouseIsUp:
stopTracking:(const NXPoint *)lastPoint
at:(const NXPoint *)stopPoint
inView:aView
mouseIsUp:(BOOL)flag

Invoked from trackMouse:inRect:ofView: when the mouse has left the bounds of the Cell, or the mouse button has gone up. flag is YES if the mouse button went up to cause this method to be invoked.  The default behavior is to do nothing and return self.  This method is often overridden to provide more sophisticated tracking behavior.

See also:  trackMouse:inRect:ofView:, startTrackingAt:inView:, continueTracking:at:inView:



stringValue
(const char *)stringValue

Returns the contents of the Cell as a string.

See also:  setStringValue:, doubleValue, floatValue, intValue



tag
(int)tag

Returns 1.  This method is overridden by ActionCell and its subclasses to support multiple-Cell controls (Matrix and Form). Override this method if you want to use tags to identifiy Cells.  Returns self.

See also:  setTag:, findCellWithTag: (Matrix, Menu classes)



takeDoubleValueFrom:
takeDoubleValueFrom:sender

Sets the Cell's double-precision floating point value to the value returned by sender's doubleValue method.  sender must be of a class that implements the doubleValue method.  Returns self.

This method can be used in action messages between Cells.  It permits one Cell (the sender) to affect the value of another Cell (the receiver).  For example, a TextFieldCell can be made the target of a SliderCell, which will send it a takeDoubleValueFrom: action message.  The TextFieldCell will get the return value of the SliderCell's doubleValue method, turn it into a text string, and display it.

See also:  takeDoubleValueFrom: (Control), setDoubleValue:



takeFloatValueFrom:
takeFloatValueFrom:sender

Sets the Cell's single-precision floating-point value to the value returned by sender's floatValue method.  sender must be of a class that implements the floatValue method.  Returns self.

This method is similar to takeDoubleValueFrom: except it works with floats rather than doubles.

See also:  takeFloatValueFrom: (Control), setFloatValue:



takeIntValueFrom:
takeIntValueFrom:sender

Sets the Cell's integer value to the value returned by sender's intValue method.  sender must be of a class that implements the intValue method.  Returns self.

This method is similar to takeDoubleValueFrom: except it works with ints rather than doubles.

See also:  takeIntValueFrom: (Control), setIntValue:



takeStringValueFrom:
takeStringValueFrom:sender

Sets the  Cell's string value to the value returned by sender's stringValue method.  sender must be of a class that implements the stringValue method.  Returns self.

This method is similar to takeDoubleValueFrom: except it works with strings rather than doubles.

See also:  takeStringValueFrom: (Control),   setStringValue:



target
target

Returns nil.  This method is one of those overridden by ActionCell and subclasses to implement target/action functionality.

See also:  setTarget:, action, ActionCell



trackMouse:inRect:ofView:
(BOOL)trackMouse:(NXEvent *)theEvent
inRect:(const NXRect *)cellFrame
ofView:aView

Invoked by a Control to initiate the tracking behavior of a Cell.  It's generally not overridden since the default implementation invokes other Cell methods that can be overridden to handle specific events in a dragging session.  Returns YES if the mouse goes up in cellFrame, NO otherwise.

This method first invokes startTrackingAt:inView:.  If that method returns YES, then as mouse-dragged events are intercepted, continueTracking:at:inView: is invoked, and, finally, when the mouse leaves the bounds or if the mouse button goes up, stopTracking:at:inView:mouseIsUp: is invoked (if cellFrame is NULL, then the bounds are considered infinitely large).  You usually override one or more of these methods to respond to specific mouse events.

If the other tracking methods are insufficient for your needs, override this method directly.  It's this method's responsibility to invoke aView's sendAction:to: method when appropriate (before, during, or after tracking) and to return YES if and only if the mouse goes up within the Cell during tracking.  If the Cell's action is sent on a mouse down event, then startTrackingAt:inView: is invoked before the action is sent and the mouse is tracked until it goes up or out of bounds.  If the Cell sends its action periodically, then the action is sent periodically to the target even if the mouse isn't moving (although continueTracking:at:inView: is only invoked when the mouse changes position).  If the Cell's action is sent on a mouse dragged event, then continueTracking:at:inView: is invoked before the action is sent.  The state of the Cell is incremented (with incrementState) before the action is sent and after stopTracking:at:inView: is invoked when the mouse goes up.

See also:  startTrackingAt:inView:, continueTracking:at:inView:, stopTracking:at::inView:mouseIsUp:



type
(int)type

Returns the type of the Cell, which can be either NX_NULLCELL, NX_ICONCELL or NX_TEXTCELL.

See also:  setType:



write:
write:(NXTypedStream *)stream

Writes the Cell to the typed stream stream.  Returns self.

See also:  read: