- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends

# MPxUITableControl Class Reference
OpenMayaUI - API module for user interface | Proxy classes

Search for all occurrences

## Detailed Description

Base class for creating new spreadsheet controls.

MPxUITableControl is the base class for creating new spreadsheet like interfaces. Every UI control has an associated command that is 'in-charge' of that control. Therefore, when creating a new table control, you will need to create an associated MPxControlCommand. Please refer to the MPxControlCommand documentation for details on how to use these class together.

At a minimum, when creating a new table control, you must overload getCell( ... ). Other methods available for overloading are getLabel(...), allowEdit( ... ), allowSelection( ... ), and collapseOrExpandRow( ... ).

`#include <MPxUITableControl.h>`

Inheritance diagram for MPxUITableControl:
[legend]

List of all members.

## Public Types
enum | MLabelType { kNoLabel, kRowLabel, kColumnLabel, kAllLabels }
| Types of labels available in the control. More...
## Public Member Functions
| MPxUITableControl (MPxControlCommand &)
| Class constructor.
virtual | ~MPxUITableControl ()
| Class destructor.
MStatus | redrawLabels (MLabelType lt=kAllLabels)
| Tells the table control to redraw the label entries.
MStatus | redrawCells ()
| Tells the UI control to redraw the cells of the table.
MStatus | addToSelection (unsigned int row, unsigned int col)
| Add the follow cell to the selection data structure.
MStatus | removeFromSelection (unsigned int row, unsigned int column)
| Removes the specified cell entry from the internal selection list.
MStatus | clearSelection ()
| Clears the selection table.
MStatus | setSelection (unsigned int row, unsigned int column)
| Sets the table selection list based on the row & column entry.
MStatus | setSelection (unsigned int firstRow, unsigned int lastRow, unsigned int firstCol, unsigned int lastCol)
| Sets the selection to be the range of cells specified.
MStatus | setNumberOfRows (unsigned int count)
| Specifies the number of rows for the table.
unsigned int | numberOfRows (MStatus *ReturnStatus=NULL)
| Returns the number of rows in the table.
MStatus | setNumberOfColumns (unsigned int count)
| Specifies the number of columns for the table.
unsigned int | numberOfColumns (MStatus *ReturnStatus=NULL) const
| Returns the number of columns in the table.
bool | suspendUpdates (bool update, MStatus *ReturnStatue=NULL)
| When set to true, it prevents the UI from updating the table.
bool | isSelected (unsigned int row, unsigned int col, MStatus *status=NULL)
| Returns true if the specified cell is selected.
virtual bool | collapseOrExpandRow (unsigned int row)
| This is called when a row should be collapsed or expanded (depending on its current state).
## Static Public Member Functions
static const char * | className ()
| Returns the name of this class.
## Protected Member Functions
virtual MString | cellString (unsigned int r, unsigned int c, bool &ValidCell)
| Returns the contents of a cell.
virtual MString | labelString (MLabelType labelType, unsigned int n)
| Returns the text of the label for the given row or column.
virtual bool | getCell (unsigned int r, unsigned int c, MString &value)
| NO SCRIPT SUPPORT.
virtual void | getLabel (MLabelType labelType, unsigned int n, MString &value)
| NO SCRIPT SUPPORT.
virtual bool | allowEdit () const
| Tells the base UI table control class if this control is editable.
virtual bool | allowSelection (int top, int left, int bottom, int right)
| This method is called when a selection occurs.
virtual bool | getCellColor (unsigned int r, unsigned int c, int &red, int &green, int &blue)
| Returns the background color of a cell.
## Friends
class | MPxControlCommand Search for all occurrences

## Member Enumeration Documentation

enum MLabelType

Search for all occurrences

Types of labels available in the control.

Enumerator:

  kNoLabel | Search for all occurrences
  kRowLabel | Search for all occurrences
  kColumnLabel | Search for all occurrences
  kAllLabels | Search for all occurrences

## Constructor & Destructor Documentation

MPxUITableControl | ( | MPxControlCommand & | command | ) |

Class constructor.

You will always need to provide a constructor that takes a control command instance as an argument, and it is illegal to define your standard constructors.

## Member Function Documentation

MStatus redrawLabels | ( | MPxUITableControl::MLabelType | labelType = `kAllLabels` | ) |

Search for all occurrences

Tells the table control to redraw the label entries.

Parameters:

  [in] | labelType | Specifies which labels to redraw.

Returns:
  - MS::kSuccess Call was successful.
  - MS::kFailure Internal error.

MStatus redrawCells | ( |  | ) |

Search for all occurrences

Tells the UI control to redraw the cells of the table.

The table control maintains a database of cell entries and it will populate these entries using getCell interface.

Returns:
  - MS::kSuccess Call was successful.
  - MS::kFailure Internal error.

MStatus addToSelection | ( | unsigned int | row,
|  | unsigned int | col
| ) |  |

Search for all occurrences

Add the follow cell to the selection data structure.

To keep track of which entries that should be highlighted, an internal table is maintained.

Parameters:

  [in] | row | table row entry.
  [in] | col | table col entry.

Returns:
  - MS::kSuccess successfully added the selection.
  - MS::kFailure invalid row, col entry.

MStatus removeFromSelection | ( | unsigned int | row,
|  | unsigned int | column
| ) |  |

Search for all occurrences

Removes the specified cell entry from the internal selection list.

Parameters:

  [in] | row | cell row entry
  [in] | column | cell column entry

Returns:
  - MS::kFailure invalid row / col entry.
  - MS::kSuccess successfully removed entry from selection list.

MStatus clearSelection | ( |  | ) |

Search for all occurrences

Clears the selection table.

This will remove all highlighted cells from the table.

Returns:
  - MS::kSuccess successfully removed entry from selection list.
  - MS::kFailure Internal error.

MStatus setSelection | ( | unsigned int | row,
|  | unsigned int | column
| ) |  |

Search for all occurrences

Sets the table selection list based on the row & column entry.

This replaces the current selection list with the new entry.

Parameters:

  [in] | row | cell row entry
  [in] | column | cell column entry

Returns:
  - MS::kSuccess Successfully removed entry from selection list.
  - MS::kFailure Invalid row / col entry.

MStatus setSelection | ( | unsigned int | firstRow,
|  | unsigned int | lastRow,
|  | unsigned int | firstCol,
|  | unsigned int | lastCol
| ) |  |

Search for all occurrences

Sets the selection to be the range of cells specified.

This replaces the current selection with the specified selection range.

Parameters:

  [in] | firstRow | first row of the selection
  [in] | lastRow | last row of the selection
  [in] | firstCol | first column of the selection
  [in] | lastCol | last column of the selection

Returns:
  - MS::kSuccess Successfully edited the selection list.
  - MS::kFailure Invalid range.

MStatus setNumberOfRows | ( | unsigned int | count | ) |

Search for all occurrences

Specifies the number of rows for the table.

Parameters:

  [in] | count | number of rows desired.

Returns:
  - MS::kSuccess Successfully changed the number of rows.
  - MS::kFailure Internal error.

unsigned int numberOfRows | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Returns the number of rows in the table.

Parameters:

  [out] | ReturnStatus | Status of the call.

Returns:
  Number of rows in the table or zero on failure.

Status Codes:
  - MS::kSuccess Successfully returned the number of rows..
  - MS::kFailure Internal error.

MStatus setNumberOfColumns | ( | unsigned int | count | ) |

Search for all occurrences

Specifies the number of columns for the table.

Parameters:

  [in] | count | number of columns desired.

Returns:
  - MS::kSuccess Successfully changed the number of columns.
  - MS::kFailure Internal error.

unsigned int numberOfColumns | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Returns the number of columns in the table.

Parameters:

  [out] | ReturnStatus | status of the call.

Returns:
  - MS::kSuccess Successfully returned the number of rows.
  - MS::kFailure Internal error.

bool suspendUpdates | ( | bool | update,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Search for all occurrences

When set to true, it prevents the UI from updating the table.

The old suspend status is returned.

Parameters:

  [in] | update | state the new suspend status.
  [out] | ReturnStatus | status of the call.

Returns:
  - MS::kSuccess Suspend status updated.
  - MS::kFailure Internal error.

bool isSelected | ( | unsigned int | row,
|  | unsigned int | col,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Search for all occurrences

Returns true if the specified cell is selected.

Parameters:

  [in] | row | cell row position.
  [in] | col | cell col position.
  [out] | ReturnStatus | Status code.

Returns:
  - MS::kSuccess Successfully returned the selected state.
  - MS::kFailure Internal error.

bool collapseOrExpandRow | ( | unsigned int | row | ) | `[virtual]`

Search for all occurrences

This is called when a row should be collapsed or expanded (depending on its current state).

Parameters:

  [in] | row | the row to collapse.

Returns:
  - true the action was handled.
  - false the action was not handled.

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  Name of this class.

Reimplemented from MPxUIControl.

MString cellString | ( | unsigned int | r,
|  | unsigned int | c,
|  | bool & | isValidCell
| ) |  | `[protected, virtual]`

Search for all occurrences

Returns the contents of a cell.

Derived classes MUST override either this method or getCell().

Parameters:

  [in] | r | Row index of the cell.
  [in] | c | Column index of the cell.
  [out] | isValidCell | True if the row and column specify a valid cell, false otherwise.

Returns:
  Contents of the specified cell, as a string, or an empty string if an invalid cell was specified.

MString labelString | ( | MLabelType | labelType,
|  | unsigned int | n
| ) |  | `[protected, virtual]`

Search for all occurrences

Returns the text of the label for the given row or column.

The base implementation of the method always returns an empty string.

Parameters:

  [in] | labelType | Specifies whether a row or column label is requested.
  [in] | n | Row or column index.

Returns:
  Text of the requested label or an empty string if 'index' is invalid.

bool getCell | ( | unsigned int | row,
|  | unsigned int | column,
|  | MString & | value
| ) |  | `[protected, virtual]`

Search for all occurrences

NO SCRIPT SUPPORT.

Returns the contents of a cell.

Derived classes MUST override either this method or cellString().

Python Notes

This method is not supported in Python. Use cellString() instead.

Parameters:

  [in] | row | Row index of cell.
  [in] | column | Column index of cell.
  [out] | value | Contents of the specified cell, as a string, or an empty string if an invalid cell was specified.

Returns:
  True state if 'row' and 'column' specify a valid cell, false otherwise.

void getLabel | ( | MLabelType | labelType,
|  | unsigned int | n,
|  | MString & | value
| ) |  | `[protected, virtual]`

Search for all occurrences

NO SCRIPT SUPPORT.

Returns the text of the label for the given row or column.

The base implementation of the method always returns an empty string.

Python Notes

This method is not supported in Python. Use labelString() instead.

Parameters:

  [in] | labelType | Specifies whether a row or column label is requested.
  [in] | n | Row or column index.
  [out] | value | Text of the requested label or an empty string if 'index' is invalid.

bool allowEdit | ( |  | ) | const`[protected, virtual]`

Search for all occurrences

Tells the base UI table control class if this control is editable.

It is possible to implement tables that simple display information and do not allow the user to edit them.

Returns:
  - true the table can be edited.
  - false the table should not be edited.

bool allowSelection | ( | int | top,
|  | int | left,
|  | int | bottom,
|  | int | right
| ) |  | `[protected, virtual]`

Search for all occurrences

This method is called when a selection occurs.

In this base implementation it always returns true. However, this method can be overridden to allow or disallow a selection.

Parameters:

  [in] | top | top cell coordinate
  [in] | left | left cell coordinate
  [in] | bottom | bottom cell coordinate
  [in] | right | right cell coordinate

Returns:
  - true the table can be edited.
  - false the table should not be edited.

bool getCellColor | ( | unsigned int | row,
|  | unsigned int | column,
|  | int & | red,
|  | int & | green,
|  | int & | blue
| ) |  | `[protected, virtual]`

Search for all occurrences

Returns the background color of a cell.

Parameters:

  [in] | row | Row index of cell.
  [in] | column | Column index of cell.
  [out] | red | The Red component of the colour
  [out] | green | The Green component of the colour
  [out] | blue | The Blue component of the colour

Returns:
  True state if 'row' and 'column' specify a valid cell, false otherwise.

MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl
MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl MPxUITableControl