Copyright ©1995 by NeXT Computer, Inc. All Rights Reserved.
Matrix |
Inherits From: | Control : View : Responder : Object | |
Declared In: | appkit/Matrix.h |
Class Description |
Matrix is a class used for creating groups of Cells that work together in various ways. It includes methods for arranging its Cells in rows and columns, either with or without space between them. The only restriction is that all Cells must be the same size. Cells in the Matrix are numbered by row and columns, each starting with 0; for example, the top left Cell would be at (0, 0), and the Cell that's second down and third across would be at (1, 2). A Matrix can have many Cells of different classes, but usually uses only one type of Cell. A Matrix can be set up to create new Cells by copying a prototype Cell, or by allocating and initializing instances of a specific Cell class.
A Matrix adds to Control's target/action paradigm by allowing a separate target and action for each of its Cells in addition to its own, and also by having an action that gets sent when the user double-clicks a Cell, and which is sent in addition to the single-click action. If a Cell doesn't have an action, the Matrix sends its own action to its own target. If a Cell doesn't have a target, the Matrix sends the Cell's action to its own target. The double-click action of a Matrix is always sent to the target of the Matrix. Since the user might press the mouse button anywhere in the Matrix, and then drag the mouse around, Matrix offers four "selection modes" which determine how Cells behave when the Matrix is tracking the mouse: NX_TRACKMODE is the most basic mode of operation. All that happens in this mode is that the Cells are asked to track the mouse with trackMouse:inRect:ofView: whenever the mouse is inside their bounds. No highlighting is performed. An example of this mode might be a "graphic equalizer" Matrix of sliders. Moving the mouse around causes the sliders to move under the mouse. NX_HIGHLIGHTMODE is a modification of TRACKMODE. In this mode, a Cell is highlighted before it is asked to track the mouse, then unhighlighted when it is done tracking. This is useful for multiple unconnected Cells which use highlighting to inform the user that they are being tracked (like push-buttons and switches). NX_RADIOMODE is used when you want no more than one Cell to be selected at a time. It can be used to create a set of buttons of which one and only one is selected (there is the option of allowing no button to be selected). Any time a Cell is selected, the previously selected Cell is unselected. The canonical example of this mode is a set of radio buttons. NX_LISTMODE is the opposite of NX_TRACKMODE. Cells are highlighted, but don't track the mouse. This mode can be used to select a range of text values, for example. Matrix supports the standard multiple-selection paradigms of dragging to select, using the shift key to make disjoint selections, and using the alternate key to extend selections. The best way to learn about selection modes is to play with a Matrix in Interface Builder, testing the Matrix interface with various options and Cell types. You can also create minimal connections to Buttons that play sounds, setting the action to be performClick:, which will cause the sounds to be played when you use the Matrix in Interface Builder's test mode. |
Instance Variables |
id cellList;
id target; SEL action; id selectedCell; int selectedRow; int selectedCol; int numRows; int numCols; NXSize cellSize; NXSize intercell; float backgroundGray; float cellBackgroundGray; id font; id protoCell; id cellClass; id nextText; id previousText; SEL doubleAction; SEL errorAction; id textDelegate; struct _mFlags { |
cellList | List of the Cells in the Matrix. | |
target | The object that is sent an action if a Cell doesn't have its own action or its own target. | |
action | The message sent to the target of the Matrix if a Cell doesn't have its own. | |
selectedCell | The selected Cell (if there's only one). | |
selectedRow | The row number of selected Cell. | |
selectedCol | The column number of selected Cell. | |
numRows | Number of rows in the Matrix. | |
numCols | Number of columns in the Matrix. | |
cellSize | The size of each Cell in the Matrix (they're all the same size). | |
intercell | Vertical and horizontal spacing between Cells. | |
backgroundGray | The gray level drawn between Cell in the Matrix. | |
cellBackgroundGray | The gray level drawn as the background of each Cell. | |
font | The Font of text in the Cells of the Matrix. | |
protoCell | A Cell instance copied to make new Cells. | |
cellClass | The class of Cell used by the Matrix; not used if a prototype is used. | |
nextText | The object whose text is selected when Tab is pressed. | |
previousText | The object whose text is selected when Shift-Tab is pressed. | |
doubleAction | Action sent to the target of the Matrix on a double-click in a Cell. | |
errorAction | Message sent to the target when a bad value is entered in a text field. | |
textDelegate | Delegate for Text object delegate methods. | |
mFlags.highlightMode | True if selection mode is NX_HIGHLIGHTMODE. | |
mFlags.radioMode | True if selection mode is NX_RADIOMODE. | |
mFlags.listMode | True if selection mode is NX_LISTMODE. | |
mFlags.allowEmptySel | True if no selection is allowed in NX_RADIOMODE. | |
mFlags.autoscroll | True if the Matrix auto-scrolls when in a ScrollView. | |
mFlags.reaction | True if an action message caused the Cell that triggered the action message to change. | |
mFlags.selectionByRect | True if a rectangle of Cells in the Matrix can be selected by dragging the cursor. |
Method Types |
Initializing the Matrix class | + initialize |
+ setCellClass: |
Initializing and freeing a Matrix | initFrame: |
initFrame:mode:cellClass:numRows:numCols: initFrame:mode:prototype:numRows:numCols: free |
Setting the selection mode | setMode: |
mode |
Configuring the Matrix | setEnabled: |
setEmptySelectionEnabled: isEmptySelectionEnabled setSelectionByRect: isSelectionByRect |
Setting the Cell class | setCellClass: |
setPrototype: prototype |
Laying out the Matrix | addCol |
addRow insertColAt: insertRowAt: removeColAt:andFree: removeRowAt:andFree: makeCellAt:: putCell:at:: renewRows:cols: setCellSize: getCellSize: getCellFrame:at:: setIntercell: getIntercell: cellCount getNumRows:numCols: |
Finding Matrix coordinates | getRow:andCol:ofCell: |
getRow:andCol:forPoint: |
Modifying individual Cells | setIcon:at:: |
setState:at:: setTitle:at:: setTag:at:: setTag:target:action:at:: |
Selecting Cells | selectCell: |
selectCellAt:: selectCellWithTag: setSelectionFrom:to:anchor:lit: selectAll: selectedCell getSelectedCells: selectedCol selectedRow clearSelectedCell |
Finding Cells | findCellWithTag: |
cellAt:: cellList |
Modifying graphic attributes | setBackgroundColor: |
backgroundColor setBackgroundGray: backgroundGray setCellBackgroundColor: cellBackgroundColor setCellBackgroundGray: cellBackgroundGray setBackgroundTransparent: isBackgroundTransparent setCellBackgroundTransparent: isCellBackgroundTransparent setFont: font |
Editing text in Cells | selectText: |
selectTextAt:: |
Setting Tab key behavior | setNextText: |
setPreviousText: |
Assigning a Text delegate | setTextDelegate: |
textDelegate |
Text object delegate methods | textWillChange: |
textDidChange: textDidGetKeys:isEmpty: textWillEnd: textDidEnd:endChar: |
Resizing the Matrix and Cells | setAutosizeCells: |
doesAutosizeCells calcSize sizeTo:: sizeToCells sizeToFit validateSize: |
Scrolling | setAutoscroll: |
setScrollable: scrollCellToVisible:: |
Displaying | display |
drawSelf:: drawCell: drawCellAt:: drawCellInside: highlightCellAt::lit: |
Target and action | setTarget: |
target setAction: action setDoubleAction: doubleAction setErrorAction: errorAction setTarget:at:: setAction:at:: sendAction sendAction:to: sendAction:to:forAllCells: sendDoubleAction setReaction: |
Handling event and action messages |
acceptsFirstMouse |
mouseDown: mouseDownFlags performKeyEquivalent: |
Managing the cursor | resetCursorRects | |
Archiving | read: |
write: |
Class Methods |
initialize |
+ initialize |
Initializes data for the Matrix class object. |
setCellClass: |
+ setCellClass:classId |
Configures the Matrix class to use instances of classId for its Cells. classId should be the id of a subclass of Cell (usually ActionCell), obtained by sending the class message to either the Cell subclass object or to an instance of that subclass. The default Cell class is ActionCell. Returns self.
Your code should rarely need to invoke this method, since each instance of Matrix can be configured to use its own Cell class (or a prototype that gets copied). The Cell class set with this method is simply a fallback for Matrices initialized with initFrame:. "Creating New Controls" in the Control class specification has more information on how to safely set the Cell class used by a subclass of Control. See also: initFrame:... |
Instance Methods |
acceptsFirstMouse |
(BOOL)acceptsFirstMouse |
Returns NO if the selection mode of the Matrix is NX_LISTMODE, YES if the Matrix is in any other selection mode. The Matrix does not accept first mouse in NX_LISTMODE to prevent the loss of multiple selections.
See also: mode |
action |
(SEL)action |
Returns the default action of the Matrix. The returned method is used when a Cell with no action receives an event which would ordinarily cause its action to be sent--normally a mouse-up in the Cell. In such cases, the Matrix sends its action to its own target.
See also: setAction:, target, action (ActionCell), target (ActionCell) |
addCol |
addCol |
Adds a new column of Cells to the right of the existing columns, creating new Cells if needed with makeCellAt::. Does not redraw even if autodisplay is on. Returns self.
If the number of rows or columns in the Matrix has been changed with renewRows:cols:, then makeCellAt: is invoked only if new Cells are needed (since renewRows:cols: doesn't free Cells, it just rearranges them). This allows you to grow and shrink a Matrix without repeatedly creating and freeing the Cells. See also: insertColAt:, makeCellAt::, renewRows:cols:, isAutodisplay (View) |
addRow |
addRow |
Adds a new row of Cells to the bottom of the existing rows, creating new Cells if needed with makeCellAt::. Does not redraw even if autodisplay is on. Returns self.
If the number of rows or columns in the Matrix has been changed with renewRows:cols:, then makeCellAt: is invoked only if new Cells are needed (since renewRows:cols: doesn't free Cells, it just rearranges them). This allows you to grow and shrink a Matrix without repeatedly creating and freeing the Cells. See also: insertRowAt:, makeCellAt::, renewRows:cols:, isAutodisplay (View) |
backgroundColor |
(NXColor)backgroundColor |
Returns the color used to draw the background (the space between the Cells).
See also: setBackgroundColor:, backgroundGray, cellBackgroundColor |
backgroundGray |
(float)backgroundGray |
Returns the gray level used to draw the background (the space between the Cells). If the gray level is less than 0, then the background is transparent.
See also: setBackgroundGray:, backgroundColor, cellBackgroundGray |
calcSize |
calcSize |
Your code should never invoke this method. It is invoked automatically by the system if it has to recompute some size information about the Cells. It invokes calcDrawInfo: on each Cell in the Matrix. Can be overridden to do more if necessary (Form overrides calcSize, for example). Returns self.
See also: calcSize (Control, Form), validateSize: |
cellAt:: |
cellAt:(int)row :(int)col |
Returns the Cell at row row and column col, or nil if no such Cell exists.
See also: getRow:andCol:ofCell: |
cellBackgroundColor |
(NXColor)cellBackgroundColor |
Returns the color used to fill the background of a Cell.
See also: setCellBackgroundColor:, cellBackgroundGray, backgroundColor |
cellBackgroundGray |
(float)cellBackgroundGray |
Returns the gray value used to fill the background of a Cell before the Cell is drawn. If the gray level is 1.0, then the Cell is transparent.
See also: setCellBackgroundGray:, cellBackgroundColor, backgroundGray |
cellCount |
(int)cellCount |
Returns the number of Cell positions in the Matrix (that is, the number of rows times the number of columns).
See also: cellList |
cellList |
cellList |
Returns a List object that contains the Cells of the Matrix. The Cells in the list are row-ordered; that is, the first row of Cells appear first in the List, then the next row, and so on. |
clearSelectedCell |
clearSelectedCell |
Deselects the selected Cell or Cells, and returns the previously selected Cell (the last of the selected Cells if there were more than one). If the selection mode is NX_RADIOMODE and empty selection is not allowed, this method won't deselect the selected Cell. Doesn't redisplay the Matrix. It's often more convenient to use selectCellAt:: with a row and column of (1, 1), since this will clear the selected Cell and redisplay the Matrix.
See also: selectCellAt::, mode, setEmptySelectionEnabled: |
display |
display |
Draws the Matrix. This method invokes displayFromOpaqueAncestor::: if any part of the Matrix (either the space between Cells, or any Cell) is transparent, or display::: if the entire Matrix is opaque. Returns self.
See also: display::: (View), displayFromOpaqueAncestor::: (View) |
doesAutosizeCells |
(BOOL)doesAutosizeCells |
Returns YES if Cells are resized proportionally to the Matrix when its size changes; the inter-Cell spacing is kept constant. Returns NO if the inter-Cell spacing changes when the Matrix is resized; the Cell size remains constant.
See also: setAutosizeCells: |
doubleAction |
(SEL)doubleAction |
Returns the action sent by the Matrix to its target when the user double-clicks an entry. Unlike NXBrowser, this method returns NULL if there is no double-click action. The double-click action of a Matrix is sent after the appropriate single-click action (for the Cell clicked or for the Matrix if the Cell doesn't have its own action). If there is no double-click action and the Matrix doesn't ignore multiple clicks, the single-click action is sent twice.
See also: setDoubleAction:, action, target, sendDoubleAction, ignoreMultiClick: (Control) |
drawCell: |
drawCell:aCell |
If aCell is in the Matrix, then it's drawn. Does nothing otherwise. Returns self. This method is useful for constructs like: |
[aMatrix drawCell:[[aMatrix cellAt:aRow :aCol] setSomething:anArg]]];
See also: drawCellAt::, drawCellInside: |
drawCellAt:: |
drawCellAt:(int)row :(int)col |
Displays the Cell at (row, col) if it's in the Matrix. Does nothing otherwise. Returns self.
See also: drawCell:, drawCellInside: |
drawCellInside: |
drawCellInside:aCell |
If aCell is in the Matrix, then its inside (usually all but a bezel or border) is drawn.
See also: drawCell:, drawCellAt::, drawInside:inView: (Cell) |
drawSelf:: |
drawSelf:(const NXRect *)rects :(int)rectCount |
Displays the Cells in the Matrix which intersect any of the rects. |
errorAction |
(SEL)errorAction |
Returns the action sent to the target of the Matrix when the user enters an illegal value for a Cell's type (as set by Cell's setEntryType: method and checked by Cell's isEntryAcceptable: method).
See also: setErrorAction:, setEntryType: (Cell), isEntryAccectable: (Cell) |
findCellWithTag: |
findCellWithTag:(int)anInt |
Returns the Cell which has a tag matching anInt, or nil if no such Cell exists in the Matrix.
See also: setTag:at::, setTag: (ActionCell), setTag:target:action:at::, |
font |
font |
Returns the Font used to display text in the Cells of the Matrix, or nil if the Cells don't contain text.
See also: setFont: |
free |
free |
Deallocates the storage for the Matrix and all its Cells, and returns nil. |
getCellFrame:at:: |
getCellFrame:(NXRect *)theRect |
at:(int)row :(int)col |
Returns self, and by reference in theRect the frame of the Cell that would be drawn at the specified row and col (whether or not it actually exists).
See also: getCellSize: |
getCellSize: |
getCellSize:(NXSize *)theSize |
Returns self, and by reference in theSize the width and the height of each Cell in the Matrix (all Cells are the same size).
See also: getCellFrame:at::, getIntercell: |
getIntercell: |
getIntercell:(NXSize *)theSize |
Returns self, and by reference in theSize the vertical and horizontal spacing between Cells.
See also: getCellSize: |
getNumRows:numCols: |
getNumRows:(int *)rowCount numCols:(int *)colCount |
Returns self, and, by reference in rowCount and colCount, the number of rows and columns in the Matrix. |
getRow:andCol:forPoint: |
getRow:(int *)row |
andCol:(int *)col forPoint:(const NXPoint *)aPoint |
Returns the Cell at aPoint in the Matrix. aPoint must be in the coordinate system of the Matrix. If aPoint is outside the bounds of the Matrix or in an intercell spacing, getRow:andCol:forPoint: returns nil. Also returns by reference in row and col the row and column position of the Cell.
See also: getRow:andCol:ofCell: |
getRow:andCol:ofCell: |
getRow:(int *)row |
andCol:(int *)col ofCell:aCell |
Returns by reference in row and col the row and column indices for the position of aCell within the Matrix. Returns aCell if it's in the Matrix, nil otherwise.
See also: getRow:andCol:forPoint: |
getSelectedCells: |
getSelectedCells:(List *)aList |
Adds to aList the Cells of the Matrix that are selected. If aList is nil, a new List object is created and filled with the selected Cells. Your code may free the List object, but not the Cells in the List. Returns the List containing the Cells.
See also: selectedCell |
highlightCellAt::lit: |
highlightCellAt:(int)row |
:(int)col lit:(BOOL)flag |
Highlights or unhighlights the Cell at (row, col) in the Matrix by sending highlight:inView:lit: to the Cell. The PostScript focus must be locked on the Matrix when this message is sent. Returns self.
See also: highlight:inView:lit: (Cell) |
initFrame: |
initFrame:(const NXRect *)frameRect |
Initializes and returns the receiver, a new instance of Matrix, with default parameters in the given frame. The default font is the user's chosen system font in 12.0 point, the default Cell size is 100.0 by 17.0 points, the default inter-Cell spacing is 1.0 point by 1.0 point, the default background gray is 1 (transparent), and the default Cell background gray is also 1. The new Matrix contains no rows or columns. The default mode is NX_RADIOMODE.
See also: initFrame:mode:... |
initFrame:mode:cellClass:numRows:numCols: |
initFrame:(const NXRect *)frameRect |
mode:(int)aMode cellClass:classId numRows:(int)numRows numCols:(int)numCols |
Initializes and returns the receiver, a new instance of Matrix, in frameRect with numRows rows and numCols columns. aMode is set as the tracking mode for the Matrix, and can be one of four constants: |
NX_TRACKMODE | Just track the mouse inside the Cells | |
NX_HIGHLIGHTMODE | Highlight the Cell, then track, then unhighlight | |
NX_RADIOMODE | Allow no more than one selected Cell | |
NX_LISTMODE | Allow multiple selected Cells |
The behavior for these constants is more fully described in the class description. The new Matrix creates and uses Cells of class classId, which should be the return value of a class message sent to a subclass of Cell.
This method is the designated initializer for Matrices that add Cells by creating instances of a Cell subclass. See also: initFrame:, initFrame:mode:prototype:numRows:numCols: |
initFrame:mode:prototype:numRows:numCols: |
initFrame:(const NXRect *)frameRect |
mode:(int)aMode prototype:aCell numRows:(int)numRows numCols:(int)numCols |
Initializes and returns the receiver, a new instance of Matrix, in frameRect with numRows rows and numCols columns. aMode is set as the tracking mode for the Matrix, and can be one of four constants: |
NX_TRACKMODE | Just track the mouse inside the Cells | |
NX_HIGHLIGHTMODE | Highlight the Cell, then track, then unhighlight | |
NX_RADIOMODE | Allow no more than one selected Cell | |
NX_LISTMODE | Allow multiple selected Cells |
The behavior for these constants is more fully described in the class description. The new Matrix creates Cells by copying aCell, which should be an instance of a subclass of Cell.
This method is the designated initializer for Matrices that add Cells by copying an instance of a Cell subclass. See also: initFrame:, initFrame:mode:cellClass:numRows:numCols: |
insertColAt: |
insertColAt:(int)col |
Inserts a new column of Cells before col, creating new Cells with makeCellAt::. If col is greater than the number of columns in the Matrix, enough columns are created to expand Matrix to be col columns wide. This method doesn't redraw even if autodisplay is on. Your code may need to use sizeToCells after sending this method to resize the Matrix to fit the newly added Cells. Returns self.
If the number of rows or columns in the Matrix has been changed with renewRows:cols:, then makeCellAt: is invoked only if new Cells are needed (since renewRows:cols: doesn't free Cells, it just rearranges them). This allows you to grow and shrink a Matrix without repeatedly creating and freeing the Cells. See also: addCol, insertRowAt:, sizeToCells, makeCellAt:: |
insertRowAt: |
insertRowAt:(int)row |
Inserts a new row of Cells before row, creating new Cells with makeCellAt::. If row is greater than the number of rows in the Matrix, enough rows are created to expand Matrix to be row rows high. This method doesn't redraw even if autodisplay is on. Your code may need to use sizeToCells after sending this method to resize the Matrix to fit the newly added Cells. Returns self.
If the number of rows or columns in the Matrix has been changed with renewRows:cols:, then makeCellAt: is invoked only if new Cells are needed (since renewRows:cols: doesn't free Cells, it just rearranges them). This allows you to grow and shrink a Matrix without repeatedly creating and freeing the Cells. See also: addRow, insertColAt:, sizeToCells, makeCellAt:: |
isBackgroundTransparent |
(BOOL)isBackgroundTransparent |
Returns YES if the Matrix background is transparent, NO otherwise.
See also: setBackgroundTransparent:, backgroundGray |
isCellBackgroundTransparent |
(BOOL)isCellBackgroundTransparent |
Returns YES if Cells in the Matrix have transparent backgrounds, NO otherwise.
See also: setCellBackgroundTransparent:, cellBackgroundGray |
isEmptySelectionEnabled |
(BOOL)isEmptySelectionEnabled |
Returns YES if it is possible to have no Cells selected in a radio-mode Matrix, NO otherwise.
See also: setEmptySelectionEnabled: |
isSelectionByRect |
(BOOL)isSelectionByRect |
Returns YES if a rectangle of Cells in the Matrix can be selected by dragging the cursor, NO otherwise.
See also: setSelectionFrom:to:anchor:lit: |
makeCellAt:: |
makeCellAt:(int)row :(int)col |
Creates a new Cell at the specified location in the Matrix. If the Matrix has a prototype Cell, it's copied to create the new Cell; if the Matrix has a Cell class set, it allocates and initializes (with init) an instance of that class; if the Matrix has not had a Cell class set, the default class, ActionCell, is used. The new Cell's font is set to the font of the Matrix Returns the newly created Cell.
Your code should never invoke this method directly; it's used by addRow and other methods when a Cell must be created. It may be overridden to provide more specific initialization of Cells. See also: addCol, addRow, insertColAt:, insertRowAt: |
mode |
(int)mode |
Returns the selection mode of the Matrix. These modes are explained in the class description.
See also: setMode:, initFrame:mode:... |
mouseDown: |
mouseDown:(NXEvent *)theEvent |
Your code should never invoke this method, but you may override it to implement different mouse tracking than Matrix does. The response of the Matrix depends on its selection mode, as explained in the class description.
In any selection mode, a mouse-down in an editable text Cell immediately enters text editing mode. A double-click in any other kind of Cell sends the double-click action of the Matrix (if there is one) in addition to the single-click action. See also: sendAction, sendDoubleAction |
mouseDownFlags |
(int)mouseDownFlags |
Returns the flags (for example, NX_SHIFTMASK) that were in effect at the mouse-down event that started the current tracking session. Use this method if you want to access these flags, but don't want the overhead of having to use sendActionOn: to add NX_MOUSEDOWNMASK to every Cell to get them. This method is valid only during tracking; it's not useful if the target of the Matrix initiates another tracking loop as part of its action method (as a Cell that pops up a PopUpList does, for example).
See also: sendActionOn: (Cell) |
performKeyEquivalent: |
(BOOL)performKeyEquivalent:(NXEvent *)theEvent |
If there is a Cell in the Matrix that has a key equivalent equal to the character in theEvent->data.key.charCode, that Cell is made to react as if the user had clicked it by highlighting, changing its state as appropriate, sending its action if it has one, and then unhighlighting. Returns YES if a Cell in the Matrix responds to the key equivalent in theEvent, NO if no Cell responds.
Your code should never send this message; it is sent when the Matrix or one of its superviews is the first responder and the user presses a key. You may want to override this method to change the way key equivalents are performed or displayed, or to disable them in your subclass. |
prototype |
prototype |
Returns the prototype Cell that is copied whenever a new Cell needs to be made, or nil if there is none.
See also: setPrototype:, initFrame:mode:prototype:numRows:numCols:, makeCellAt:: |
putCell:at:: |
putCell:newCell |
at:(int)row :(int)col |
Replaces the Cell at (row, col) by newCell, and returns the old Cell at that position. Draws the new Cell if autodisplay is on. |
read: |
read:(NXTypedStream *)stream |
Reads the Matrix from the typed stream stream. Returns self.
See also: write: |
removeColAt:andFree: |
removeColAt:(int)col andFree:(BOOL)flag |
Removes the column at position col. If flag is YES then the Cells from that column are freed. Doesn't redraw even if autodisplay is on. Your code should normally send sizeToCells after invoking this method to resize the Matrix so it fits the reduced Cell count. Returns self.
See also: removeRowAt:andFree:, addCol, insertColAt: |
removeRowAt:andFree: |
removeRowAt:(int)row andFree:(BOOL)flag |
Removes the row at position row. If flag is YES then the Cells from that row are freed. Doesn't redraw even if autodisplay is on. Your code should normally send sizeToCells after invoking this method to resize the Matrix so it fits the reduced Cell count. Returns self.
See also: removeColAt:andFree:, addRow, insertRowAt: |
renewRows:cols: |
renewRows:(int)newRows cols:(int)newCols |
Changes the number of rows and columns in the Matrix. This method uses the same Cells as before, creating new Cells only if the new size is larger; it never frees Cells. Doesn't display the Matrix even if autodisplay is on. Your code should normally send sizeToCells after invoking this method to resize the Matrix so it fits the changed Cell arrangement. This method deselects all Cells in the Matrix. Returns self.
See also: addRow, addCol |
resetCursorRects |
resetCursorRects |
Sends resetCursorRect:inView: to each Cell in the Matrix. Any Cell that has a cursor rectangle to set up should send the message addCursorRect:cursor: back to the Matrix. Returns self.
See also: resetCursorRect:inView: (Cell), addCursorRect:cursor: (View) |
scrollCellToVisible:: |
scrollCellToVisible:(int)row :(int)col |
If the Matrix is in a scrolling View, then the Matrix will scroll to make the Cell at (row, col) visible. Returns self.
See also: scrollRectToVisible: (View) |
selectAll: |
selectAll:sender |
If the mode of the Matrix is not NX_RADIOMODE, then all the Cells in the Matrix are selected and highlighted, and the Matrix is redisplayed. The currently selected Cell is unaffected. Editable text Cells are not affected. Returns self.
See also: selectCell:, selectCellAt::, selectCellWithTag:, selectText: |
selectCell: |
selectCell:aCell |
If aCell is in the Matrix, then the Cell is selected, the Matrix is redrawn, and the selected Cell is returned. An editable text Cell's text is selected. Returns nil if the Cell is not in the Matrix.
See also: selectCellAt::, selectCellWithTag:, selectAll:, selectText: |
selectCellAt:: |
selectCellAt:(int)row :(int)col |
Selects the Cell at the position in the Matrix denoted by (row, col). An editable text Cell's text is selected. If either row or col is 1, then the current selection is cleared (unless the Matrix is in NX_RADIOMODE and does not allow empty selection). Redraws the affected Cells and returns self.
See also: selectCell:, selectCellWithTag:, selectAll:, selectText: |
selectCellWithTag: |
selectCellWithTag:(int)anInt |
If the Matrix has a Cell whose tag is equal to anInt, that Cell is selected. An editable text Cell's text is selected. Returns self, or nil if there is no such Cell.
See also: selectCell:, selectCellAt::, selectAll:, selectText: |
selectedCell |
selectedCell |
Returns the currently selected Cell, or nil if no Cell is selected. If more than one Cell is selected, returns the last selected Cell; that is, the Cell that is lowest and furthest to the right in the Matrix.
See also: getSelectedCells: |
selectedCol |
(int)selectedCol |
Returns the column number of the selected Cell, or 1 if no Cells are selected. If Cells in multiple columns are selected, this method returns the number of the last column containing a selected Cell.
See also: selectedRow |
selectedRow |
(int)selectedRow |
Returns the row number of the selected Cell, or 1 if no Cells are selected. If Cells in multiple rows are selected, this method returns the number of the last row containing a selected Cell.
See also: selectedCol |
selectText: |
selectText:sender |
If sender is the next Text object of the Matrix (as set with setNextText:), the text in the last selectable text Cell (the one lowest and furthest to the right) is selected; otherwise, the text of the first selectable text Cell is selected. Returns the Cell whose text was selected, the Matrix if such a Cell wasn't found, and nil if the Cell was bound but wasn't enabled or wasn't selectable.
See also: selectTextAt::, selectText: (TextField) |
selectTextAt:: |
selectTextAt:(int)row :(int)col |
Select the text of the Cell at (row, col) in the Matrix, if there is such a Cell and its text is selectable. Returns the Cell whose text was selected, the Matrix if such a Cell wasn't found, and nil if the Cell was found but wasn't enabled or wasn't selectable.
See also: selectText:, selectText: (TextField) |
sendAction |
sendAction |
If the selected Cell has both an action and a target, its action is sent to its target. If the Cell has an action but no target, its action is sent to the target of the Matrix. If the Cell doesn't have an action, or if there is no selected Cell, the Matrix sends its action to its target.
See also: sendDoubleAction, sendAction:to:, action, target |
sendAction:to: |
sendAction:(SEL)theAction to:theTarget |
If both theAction and theTarget are non-null, sends theAction to theTarget. If theAction is null, sends the action of the Matrix to its target. If theAction is nil, sends theAction to the target of the Matrix. Returns nil if no target that responds to theAction could be found; otherwise returns self.
Your code shouldn't normally invoke this method. It is used by event handling methods such as Cell's trackMouse:inRect:ofView: to send an action to a target in response to an event within the Matrix. See also: sendAction, sendAction:to: (Control) |
sendAction:to:forAllCells: |
sendAction:(SEL)aSelector |
to:anObject forAllCells:(BOOL)flag |
Iterates through the Cells in the Matrix, sending aSelector to anObject for each. aSelector must represent a method that takes a single argument: the id of the current Cell in the iteration. aSelector's return value must be a BOOL. Iteration begins with the Cell in the upper-left corner of the Matrix, proceeding through all entries in the first row, then on to the next. Returns self.
If aSelector returns NO for any Cell, this method terminates immediately and return self, without sending the message for other Cells. If it returns YES, this method keeps sending the message. This method is not invoked to send action messages to target objects in response to mouse-down events in the Matrix. Instead, you can invoke it if you want to have multiple Cells in a Matrix interact with an object. For example you could use it to verify the titles in a list of items, or to enable a series of radio buttons based on their purpose in relation to anObject. See also: sendAction:to: |
sendDoubleAction |
sendDoubleAction |
If the Matrix has a double-click action, sends that message to the target of the Matrix. If not, then if the selected Cell (as returned by selectedCell) has an action, that message is sent to the selected Cell's target. If the selected Cell also has no action, then the action of the Matrix is sent to the target of the Matrix. This method only sends an action if the selected Cell is enabled. Returns self.
Your code shouldn't invoke this method; it's sent in response to a double-click event in the Matrix. You may want to override it to change the search order for an action to send. See also: sendAction, sendAction:to:, ignoreMultiClick: (Control) |
setAction: |
setAction:(SEL)aSelector |
Sets the default action of the Matrix, the message sent for a Cell which has no action of its own. The action of the Matrix is always sent to its target, never to the Cell's target. Returns self.
See also: action, setDoubleAction, setTarget:, setAction:at::, setTarget:at:: |
setAction:at:: |
setAction:(SEL)aSelector |
at:(int)row :(int)col |
Sets the action of the Cell at (row, col) to aSelector. Returns self.
See also: setAction: (ActionCell) |
setAutoscroll: |
setAutoscroll:(BOOL)flag |
If flag is YES and the Matrix is in a scrolling View, it will be automatically scrolled whenever a the mouse is dragged outside the Matrix after a mouse-down event within its bounds. Returns self. |
setAutosizeCells: |
setAutosizeCells:(BOOL)flag |
If flag is YES, then whenever the Matrix is resized, the sizes of the Cells changes in proportion, keeping the inter-Cell space constant; further, this method verifies that the Cell sizes and inter-Cell spacing add up to the exact size of the Matrix, adjusting the size of the Cells and updating the Matrix if they don't. If flag is NO, then the inter-Cell space changes when the Matrix is resized, with the Cell size remaining constant. Returns self.
See also: doesAutosizeCells, update (Control) |
setBackgroundColor: |
setBackgroundColor:(NXColor)aColor |
Sets the background color for the Matrix to aColor. This color is used to fill the space between Cells or the space behind any non-opaque Cells. Doesn't redraw the Matrix even if autodisplay is on. Returns self.
See also: backgroundColor, setBackgroundGray:, setCellBackgroundColor:, isAutodisplay (View) |
setBackgroundGray: |
setBackgroundGray:(float)value |
Sets the background gray level for the Matrix to value. This gray level is used to draw the inter-Cell space, or the space behind any non-opaque Cells. If the gray level is 1, the background is transparent (that is, doesn't get drawn). Updates the Matrix if the background gray level changes. Returns self.
See also: backgroundGray, setBackgroundColor:, setCellBackgroundGray:, update (Control) |
setBackgroundTransparent: |
setBackgroundTransparent:(BOOL)flag |
If flag is YES, sets the background gray level of the Matrix to 1 (transparent). If flag is NO, set the background gray level to NX_WHITE.
See also: isBackgroundTransparent, setBackgroundGray: |
setCellBackgroundColor: |
setCellBackgroundColor:(NXColor)aColor |
Sets the background color for the Cells in the Matrix to aColor. This color is used to fill the space behind non-opaque Cells. Doesn't redraw the Matrix even if autodisplay is on. Returns self.
See also: cellBackgroundColor, setCellBackgroundGray:, setBackgroundColor:, isAutodisplay (View) |
setCellBackgroundGray: |
setCellBackgroundGray:(float)value |
Sets the background gray level for the Cells in the Matrix to value. This gray level is used to draw the space behind non-opaque Cells. If the gray level is 1, the Cell background is transparent (that is, doesn't get drawn). Updates the Matrix if the Cell background gray level changes. Returns self.
See also: cellBackgroundGray, setCellBackgroundColor:, setBackgroundGray:, isAutodisplay (View) |
setCellBackgroundTransparent: |
setCellBackgroundTransparent:(BOOL)flag |
If flag is YES, sets the background gray level of Cells in the Matrix to 1 (transparent). If flag is NO, set their background gray level to NX_WHITE.
See also: isCellBackgroundTransparent, setCellBackgroundGray: |
setCellClass: |
setCellClass:classId |
Configures a single Matrix to use instances of classId when creating new Cells. classId should be the id of a subclass of Cell, obtained by sending the class message to either the Cell subclass object or to an instance of that subclass. The Cell class is that set with the class method setCellClass:; the default Cell class is ActionCell. Returns self.
You only need to use this method with Matrices initialized with initFrame:, since the other initializers allow you to specify an instance-specific Cell class or Cell prototype. See also: + setCellClass:, setPrototype:, initFrame: |
setCellSize: |
setCellSize:(const NXSize *)aSize |
Sets the width and the height of each of the Cells in the Matrix to those in aSize. This may change the size of the Matrix. Does not redraw the Matrix, even if autodisplay is on.
See also: getCellSize:, calcSize, isAutodisplay (View) |
setDoubleAction: |
setDoubleAction:(SEL)aSelector |
Make aSelector the action sent to the target of the Matrix when the user double-clicks a Cell. A double-click action is always sent after the appropriate single-click action; the Cell's if it has one, otherwise the single-click action of the Matrix. Returns self.
If a Matrix has no double-click action set, then by default a double-click is treated as a single-click. Setting a double-click action also sets allowMultiClick: to YES; be sure to set the Matrix to ignore multiple-clicks if you later remove the double-click action. See also: doubleAction, setAction:, setTarget:, ignoreMultiClick: (Control) |
setEmptySelectionEnabled: |
setEmptySelectionEnabled:(BOOL)flag |
If flag is YES, then the Matrix will allow one or zero Cells to be selected. If flag is NO, then the Matrix will allow one and only one Cell (not zero Cells) to be selected. This setting has effect only in NX_RADIOMODE.
This method replaces the allowEmptySel: method of NEXTSTEP Release 2. See also: isEmptySelectionEnabled |
setEnabled: |
setEnabled:(BOOL)flag |
If flag is YES, enables all Cells in the Matrix; if NO, disables all Cells. If autodisplay is on, this redraws the entire Matrix. Returns self.
See also: isEnabled, setEnabled: (ActionCell), isAutodisplay (View) |
setErrorAction: |
setErrorAction:(SEL)aSelector |
Sets the action sent to the target of the Matrix when the user enters an illegal value in a text Cell for that Cell's entry type (as set by Cell's setEntryType: method and checked by Cell's isEntryAcceptable: method). Returns self.
See also: errorAction, setEntryType: (Cell), isEntryAccectable: (Cell) |
setFont: |
setFont:fontObject |
Sets the Font for the Matrix to fontObject. This will cause all current Cells to have their Font changed to fontObject as well as cause all future Cells to have that Font. If autodisplay is on, this redraws the entire Matrix. Returns self.
See also: font, isAutodisplay (View) |
setIcon:at:: |
setIcon:(const char *)iconName |
at:(int)row :(int)col |
Sets the icon of the Cell at (row, col) to the NXImage with the name iconName. If autodisplay is on, then the Cell is redrawn. Returns self.
See also: setIcon: (ButtonCell, Cell), isAutodisplay (View) |
setIntercell: |
setIntercell:(const NXSize *)aSize |
Sets the width and the height of the space between Cells to those in aSize. Doesn't redraw the Matrix, even if autodisplay is on. Returns self.
See also: getIntercell:, isAutodisplay (View) |
setMode: |
setMode:(int)aMode |
Sets the selection mode of the Matrix. aMode can be one of four constants: |
NX_TRACKMODE | Just track the mouse inside the Cells | |
NX_HIGHLIGHTMODE | Highlight the Cell, then track, then unhighlight | |
NX_RADIOMODE | Allow no more than one selected Cell | |
NX_LISTMODE | Allow multiple selected Cells |
The behaviors associated with these constants are explained in the class description.
See also: mode |
setNextText: |
setNextText:anObject |
Sets anObject as the object whose text is selected when the user presses Tab while editing the last editable text Cell. anObject should respond to the selectText: message. If anObject also responds to both selectText: and setPreviousText:, it's sent setPrevious: with the receiving Matrix as the argument; this builds a two-way connection, so that pressing Tab in the last text Cell selects anObject's text, and pressing Shift-Tab in anObject selects the last text Cell of the Matrix. Returns self.
See also: setPreviousText:, selectText: |
setPreviousText: |
setPreviousText:anObject |
Sets anObject as the object whose text is selected when the user presses Shift-Tab while editing the first editable text Cell. anObject should respond to the selectText: message. Your code shouldn't need to use this method directly, since it's invoked automatically by setNextText:. In deference to setNextText:, this method doesn't build a two-way connection. Returns self.
See also: setNextText:, selectText: |
setPrototype: |
setPrototype:aCell |
Sets the prototype Cell that is copied whenever a new Cell needs to be made. aCell should be an instance of a subclass of Cell. If a Matrix has a prototype Cell, it doesn't use its Cell class object to create new Cells; if you want your Matrix to use its Cell class, invoke this method with nil as the argument. The Matrix is considered to own the prototype, and will free it when the Matrix is itself freed; be sure to make a copy of an instance that your code may use elsewhere. Returns the old prototype Cell, or nil if there wasn't one.
If you implement your own Cell subclass for use as a prototype with a Matrix, make sure your Cell does the right thing when it receives a copy message. For example, Object's copy copies only pointers, not what they point to--sometimes this is what it should do, sometimes not. The best way to implement copy when you subclass Cell is send copy to super, then copy instance variable values (for example, title strings) into your subclass instance individually. Also, be careful that freeing the prototype will not damage any of the copies that were made and put into the Matrix (due to shared pointers that are freed, for example). See also: prototype, initFrame:mode:prototype:numRows:numCols: |
setReaction: |
setReaction:(BOOL)flag |
Sent to the Matrix by the target of an action message. If flag is NO, prevents the selected Cell from changing back to its previous state; if YES, allows it to revert to its previous state (to reflect unhighlighting, for example). Invoke this from an action method if the action causes the Cell to change in such a way that trying to unhighlight it would be incorrect; for example, if the Cell is deleted or its visual appearance completely changed by the action method. Returns self. |
setScrollable: |
setScrollable:(BOOL)flag |
Sets all the Cells to be scrollable, so that the text they contain scrolls to remain in view if the user types past the edge of the Cell. Returns self.
See also: setScrollable: (Cell) |
setSelectionByRect: |
setSelectionByRect:(BOOL)flag |
If flag is YES, a rectangle of Cells in the Matrix can be selected by dragging the cursor; if flag is NO, such selection isn't possible.
See also: isSelectionByRect, setSelectionFrom:to:anchor:lit: |
setSelectionFrom:to:anchor:lit: |
setSelectionFrom:(int)startPos |
to:(int)endPos anchor:(int)anchorPos lit:(BOOL)flag |
Programmatically selects a range of Cells. startPos, endPos, and anchorPos are Cell positions, counting from 0 at the upper left Cell of the Matrix, rows before columns. For example, the third Cell in the top row would be number 2.
startPos and endPos are used to mark where the user would have pressed the mouse button and released it, respectively. anchorPos locates the "last selected Cell" with regard to extending the selection by Shift- or Alternate-clicking. Finally, lit determines whether Cells selected by this method are highlighted. See also: isSelectionByRect, getSelectedCells:, cellList |
setState:at:: |
setState:(int)value |
at:(int)row :(int)col |
Sets the state of the Cell at row row and column col to value. For radio-mode Matrices, this is identical to selectCellAt:: except that the state can be set to any arbitrary value. If autodisplay is on, redraws the affected Cell; if the Matrix is in radio mode, the Cell is redrawn regardless of the setting of autodisplay. Returns self.
See also: setState: (Cell), selectCellAt::, isAutodisplay (View) |
setTag:at:: |
setTag:(int)anInt |
at:(int)row :(int)col |
If there's a Cell at (row, col), sets that Cell's tag to anInt and returns self.
See also: setTag:target:action:at::, setTag: (ActionCell) |
setTag:target:action:at:: |
setTag:(int)anInt |
target:anObject action:(SEL)aSelector at:(int)row :(int)col |
If there's a Cell at (row, col), sets that Cell's tag, target, and action to anInt, anObject, and aSelector, respectively. Returns self.
See also: setTag:at::, setTarget:at::, setAction:at:: |
setTarget: |
setTarget:anObject |
Sets the target object of the Matrix. This is the object to which actions will be sent for Cells that don't have their own target. Returns self.
See also: target, action |
setTarget:at:: |
setTarget:anObject |
at:(int)row :(int)col |
If there's a Cell at (row, col), sets that Cell's target to anObject and returns self.
See also: setTag:target:action:at::, setTarget:, setTarget: (ActionCell) |
setTextDelegate: |
setTextDelegate:anObject |
Sets the object to which the Matrix will forward messages from the field editor. These messages include text:isEmpty:, textWillEnd:, textDidEnd:endChar:, textWillChange:, and textDidChange:. Returns self.
See also: textDelegate, Text class delegate methods |
setTitle:at:: |
setTitle:(const char *)aString |
at:(int)row :(int)col |
If there's a Cell at (row, col), sets that Cell's title to aString and returns self.
Note: Use this method only with Matrices that have Cells that respond to setTitle:. Not all subclasses of Cell implement this method. See also: setTitle: (ButtonCell, FormCell) |
sizeTo:: |
sizeTo:(float)width :(float)height |
Resizes the Matrix to width and height, but doesn't redraw it. If the Matrix has been set to autosize its Cells, each Cell is resized proportionally to the change in size of the Matrix, keeping the inter-Cell spacing constant; if the Matrix doesn't autosize, then the inter-Cell spacing is adjusted, and the Cells remain the same size. If editing is going on in the Matrix, it's aborted; after the Matrix is redrawn, the text is reselected to allow editing to continue. Returns self.
See also: sizeToCells, sizeToFit, setAutosizeCells:, selectText: |
sizeToCells |
sizeToCells |
Changes the width and the height of the Matrix frame so that it exactly contains the Cells. Does not redraw the Matrix. Returns self.
See also: sizeTo::, sizeToFit |
sizeToFit |
sizeToFit |
Changes the Cell size to accommodate the Cell with the largest contents in the Matrix, then changes the width and the height of the Matrix frame so that it exactly contains the Cells. Doesn't redraw the Matrix. Returns self.
See also: sizeTo::, sizeToCells, calcCellSize: (Cell) |
target |
target |
Returns the target of the Matrix. This object receives action messages for Cells that don't have their own target or action, and receives all double-click action messages.
See also: setTarget:, setTarget:at::, action |
textDelegate |
textDelegate |
Returns the object that receives messages passed on by the Matrix from the field editor. The field editor, as mentioned in the TextField class specification, is the Text object used to draw text in all Cells in a Window.
See also: setTextDelegate: |
textDidChange: |
textDidChange:textObject |
Passes this message on, with the same argument, to the Text delegate of the Matrix. Override this method if you want your subclass of Matrix to act as the field editor's delegate. Returns self.
See also: textDidChange: (Text class delegate method) |
textDidEnd:endChar: |
textDidEnd:textObject endChar:(unsigned short)whyEnd |
Invoked by textObject (the field editor) when text editing ends. Passes this message on, with the same argument, to the Text delegate of the Matrix, then ends editing for the field editor and checks whyEnd to see if an action key (Return or Tab) was pressed. If Return was pressed, an action message is sent as explained in the sendAction method description. If Tab was pressed, the next editable text Cell is selected, or if the current Cell is the last one, selectText: is sent to the next text if there is one and it responds; failing that, the first selectable text field in the Matrix is selected (that is, the selection cycles within a Matrix with no next text). If Shift-Tab was pressed, a similar sequence is performed in reverse. Returns the object sent the selectText: message.
You may want to override this method to interpret more characters (such as the Enter or Escape keys) in ending editing. See also: sendAction, setNextText:, setPreviousText:, textDidEnd:endChar: (Text class delegate method) |
textDidGetKeys:isEmpty: |
textDidGetKeys:textObject isEmpty:(BOOL)flag |
Passes this message on, with the same argument, to the Text delegate of the Matrix. Override this method if you want your subclass of Matrix to act as the field editor's delegate. Returns self.
See also: textDidGetKeys:isEmpty: (Text class delegate method) |
textWillChange: |
(BOOL)textWillChange:textObject |
Invoked automatically during editing to determine if it is OK to edit the selected text. This method checks whether the Cell is editable and sends textWillChange: to the TextField's Text delegate to allow it to respond. Returns YES if the text isn't editable; NO if the text is editable but the Text delegate doesn't respond to textWillChange:; the text delegate's return value for textWillChange: if the Text delegate responds to it.
See also: setEditable: (Cell), setTextDelegate:, textWillChange: (Text class delegate method) |
textWillEnd: |
(BOOL)textWillEnd:textObject |
Invoked automatically before text editing ends. Checks the text by sending isEntryAcceptable: to the Cell being edited. If the entry isn't acceptable, sends the error action to the target. This method is then passed on to the Text delegate with the same argument. The return value is based on whether the entry is acceptable and on the return value from the Text delegate. If the delegate responds to textWillEnd:, then the return value is NO only if the entry is acceptable and the delegate returns NO. Otherwise the return value is YES to indicate that editing shouldn't end, and this method generates a beep (to indicate an error in the entry).
See also: isEntryAcceptable: (Cell), setTextDelegate:, textWillEnd: (Text class delegate method) |
validateSize: |
validateSize:(BOOL)flag |
If flag is YES, then the size information in the Matrix is assumed correct. If flag is NO, then calcSize will be invoked before any further drawing is done. Returns self.
See also: calcSize |
write: |
write:(NXTypedStream *)stream |
Writes the receiving Matrix to the typed stream stream. Returns self.
See also: read: |