MPxUITableControl Class Reference

#include <MPxUITableControl.h>

Class 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( ... ).

+ Inheritance diagram for MPxUITableControl:

Public Types

enum  MLabelType { kNoLabel, kRowLabel, kColumnLabel, kAllLabels }
 Types of labels available in the control. More...
 

Public Member Functions

 MPxUITableControl (MPxControlCommand &)
 Class constructor. More...
 
virtual ~MPxUITableControl ()
 Class destructor.
 
MStatus redrawLabels (MLabelType lt=kAllLabels)
 Tells the table control to redraw the label entries. More...
 
MStatus redrawCells ()
 Tells the UI control to redraw the cells of the table. More...
 
MStatus addToSelection (unsigned int row, unsigned int col)
 Add the follow cell to the selection data structure. More...
 
MStatus removeFromSelection (unsigned int row, unsigned int column)
 Removes the specified cell entry from the internal selection list. More...
 
MStatus clearSelection ()
 Clears the selection table. More...
 
MStatus setSelection (unsigned int row, unsigned int column)
 Sets the table selection list based on the row & column entry. More...
 
MStatus setSelection (unsigned int firstRow, unsigned int lastRow, unsigned int firstCol, unsigned int lastCol)
 Sets the selection to be the range of cells specified. More...
 
MStatus setNumberOfRows (unsigned int count)
 Specifies the number of rows for the table. More...
 
unsigned int numberOfRows (MStatus *ReturnStatus=NULL)
 Returns the number of rows in the table. More...
 
MStatus setNumberOfColumns (unsigned int count)
 Specifies the number of columns for the table. More...
 
unsigned int numberOfColumns (MStatus *ReturnStatus=NULL) const
 Returns the number of columns in the table. More...
 
bool suspendUpdates (bool update, MStatus *ReturnStatue=NULL)
 When set to true, it prevents the UI from updating the table. More...
 
bool isSelected (unsigned int row, unsigned int col, MStatus *status=NULL)
 Returns true if the specified cell is selected. More...
 
virtual bool collapseOrExpandRow (unsigned int row)
 This is called when a row should be collapsed or expanded (depending on its current state). More...
 
- Public Member Functions inherited from MPxUIControl
virtual ~MPxUIControl ()
 Class destructor.
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 
- Static Public Member Functions inherited from MPxUIControl
static const char * className ()
 Returns the name of this class. More...
 

Protected Member Functions

virtual MString cellString (unsigned int r, unsigned int c, bool &ValidCell)
 Returns the contents of a cell. More...
 
virtual MString labelString (MLabelType labelType, unsigned int n)
 Returns the text of the label for the given row or column. More...
 
virtual bool getCell (unsigned int r, unsigned int c, MString &value)
 NO SCRIPT SUPPORT. More...
 
virtual void getLabel (MLabelType labelType, unsigned int n, MString &value)
 NO SCRIPT SUPPORT. More...
 
virtual bool allowEdit () const
 Tells the base UI table control class if this control is editable. More...
 
virtual bool allowSelection (int top, int left, int bottom, int right)
 This method is called when a selection occurs. More...
 
virtual bool getCellColor (unsigned int r, unsigned int c, int &red, int &green, int &blue)
 Returns the background color of a cell. More...
 

Friends

class MPxControlCommand
 

Member Enumeration Documentation

enum MLabelType

Types of labels available in the control.

Enumerator
kNoLabel 

 

kRowLabel 

 

kColumnLabel 

 

kAllLabels 

 

Constructor & Destructor Documentation

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)

Tells the table control to redraw the label entries.

Parameters
[in]labelTypeSpecifies which labels to redraw.
Returns
MStatus redrawCells ( )

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
MStatus addToSelection ( unsigned int  row,
unsigned int  col 
)

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]rowtable row entry.
[in]coltable col entry.
Returns
MStatus removeFromSelection ( unsigned int  row,
unsigned int  column 
)

Removes the specified cell entry from the internal selection list.

Parameters
[in]rowcell row entry
[in]columncell column entry
Returns
MStatus clearSelection ( )

Clears the selection table.

This will remove all highlighted cells from the table.

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

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

This replaces the current selection list with the new entry.

Parameters
[in]rowcell row entry
[in]columncell column entry
Returns
MStatus setSelection ( unsigned int  firstRow,
unsigned int  lastRow,
unsigned int  firstCol,
unsigned int  lastCol 
)

Sets the selection to be the range of cells specified.

This replaces the current selection with the specified selection range.

Parameters
[in]firstRowfirst row of the selection
[in]lastRowlast row of the selection
[in]firstColfirst column of the selection
[in]lastCollast column of the selection
Returns
MStatus setNumberOfRows ( unsigned int  count)

Specifies the number of rows for the table.

Parameters
[in]countnumber of rows desired.
Returns
unsigned int numberOfRows ( MStatus ReturnStatus = NULL)

Returns the number of rows in the table.

Parameters
[out]ReturnStatusStatus of the call.
Returns
Number of rows in the table or zero on failure.
Status Codes:
MStatus setNumberOfColumns ( unsigned int  count)

Specifies the number of columns for the table.

Parameters
[in]countnumber of columns desired.
Returns
unsigned int numberOfColumns ( MStatus ReturnStatus = NULL) const

Returns the number of columns in the table.

Parameters
[out]ReturnStatusstatus of the call.
Returns
bool suspendUpdates ( bool  update,
MStatus ReturnStatus = NULL 
)

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

The old suspend status is returned.

Parameters
[in]updatestate the new suspend status.
[out]ReturnStatusstatus of the call.
Returns
bool isSelected ( unsigned int  row,
unsigned int  col,
MStatus ReturnStatus = NULL 
)

Returns true if the specified cell is selected.

Parameters
[in]rowcell row position.
[in]colcell col position.
[out]ReturnStatusStatus code.
Returns
bool collapseOrExpandRow ( unsigned int  row)
virtual

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

Parameters
[in]rowthe row to collapse.
Returns
  • true the action was handled.
  • false the action was not handled.
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.
MString cellString ( unsigned int  r,
unsigned int  c,
bool &  isValidCell 
)
protectedvirtual

Returns the contents of a cell.

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

Parameters
[in]rRow index of the cell.
[in]cColumn index of the cell.
[out]isValidCellTrue 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 
)
protectedvirtual

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]labelTypeSpecifies whether a row or column label is requested.
[in]nRow 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 
)
protectedvirtual

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]rowRow index of cell.
[in]columnColumn index of cell.
[out]valueContents 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 
)
protectedvirtual

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]labelTypeSpecifies whether a row or column label is requested.
[in]nRow or column index.
[out]valueText of the requested label or an empty string if 'index' is invalid.
bool allowEdit ( ) const
protectedvirtual

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 
)
protectedvirtual

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]toptop cell coordinate
[in]leftleft cell coordinate
[in]bottombottom cell coordinate
[in]rightright 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 
)
protectedvirtual

Returns the background color of a cell.

Parameters
[in]rowRow index of cell.
[in]columnColumn index of cell.
[out]redThe Red component of the colour
[out]greenThe Green component of the colour
[out]blueThe Blue component of the colour
Returns
True state if 'row' and 'column' specify a valid cell, false otherwise.

The documentation for this class was generated from the following files:
  • MPxUITableControl.h
  • MPxUITableControl.cpp