\chapter{Alphabetical class reference}\label{classref}
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%

\overview{wxGrid classes overview}{gridoverview}


\section{\class{wxGrid}: wxPanel}\label{wxgrid}

\overview{wxGrid classes overview}{gridoverview}

\membersection{wxGrid::wxGrid}

\func{void}{wxGrid}{\param{wxWindow *}{parent}, \param{int}{ x}, \param{int}{ y}, \param{int}{ width}, \param{int}{ height},
 \param{long}{ style=0}, \param{char *}{name="grid"}}

Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.

\membersection{wxGrid::AdjustScrollbars}

\func{void}{AdjustScrollbars}{\void}

Call this function whenever a change has been made via the API that might alter the scrollbar characteristics:
particularly when adding or deleting rows, or changing row or column dimensions. For example,
removing rows might make it unnecessary to show the vertical scrollbar.

\membersection{wxGrid::AppendCols}

\func{Bool}{AppendCols}{\param{int}{ n=1}, \param{Bool}{ updateLabels=TRUE}}

Appends {\it n} columns to the grid. If {\it updateLabels} is TRUE,
the function OnChangeLabels is called to give the application the opportunity to relabel.

\membersection{wxGrid::AppendRows}

\func{Bool}{AppendRows}{\param{int}{ n=1}, \param{Bool}{ updateLabels=TRUE}}

Appends {\it n} rows to the grid. If {\it updateLabels} is TRUE,
the function OnChangeLabels is called to give the application the opportunity to relabel.

\membersection{wxGrid::BeginBatch}\label{beginbatch}

\func{void}{BeginBatch}{\void}

Start a BeginBatch/EndBatch pair between which, calls to SetCellValue or
SetCellBitmap will not cause a refresh. This allows you to speed up some operations
(for example, setting several hundred cell values). You can nest, but not overlap,
these two functions.

See also \helpref{EndBatch}{endbatch}, \helpref{GetBatchCount}{getbatchcount}.

\membersection{wxGrid::CellHitTest}

\func{Bool}{CellHitTest}{\param{int}{ x}, \param{int}{ y}, \param{int *}{row}, \param{int *}{col}}

Returns TRUE if the x, y panel position coincides with a cell. If so, {\it row} and {\it col} are
returned.

\membersection{wxGrid::CreateGrid}

\func{Bool}{CreateGrid}{\param{int}{ rows}, \param{int}{ cols}, \param{wxString **}{cellValues=NULL},
 \param{short *}{widths=NULL}, \param{short}{ defaultWidth=wxGRID\_DEFAULT\_CELL\_WIDTH},
 \param{short}{ defaultHeight=wxGRID\_DEFAULT\_CELL\_HEIGHT}}

Creates a grid {\it rows} high and {\it cols} wide. You can optionally specify an array of initial values
and widths, and/or default cell width and height.

Call this function after creating the wxGrid object.

\membersection{wxGrid::CurrentCellVisible}

\func{Bool}{CurrentCellVisible}{\void}

Returns TRUE if the currently selected cell is visible, FALSE otherwise.

\membersection{wxGrid::DeleteCols}

\func{Bool}{DeleteCols}{\param{int}{ pos=0}, \param{int}{ n=1}, \param{Bool}{ updateLabels=TRUE}}

Deletes {\it n} columns from the grid at position {\it pos}. If {\it updateLabels} is TRUE,
the function OnChangeLabels is called to give the application the opportunity to relabel.

\membersection{wxGrid::DeleteRows}

\func{Bool}{DeleteRows}{\param{int}{ pos=0}, \param{int}{ n=1}, \param{Bool}{ updateLabels=TRUE}}

Deletes {\it n} rows from the grid at position {\it pos}. If {\it updateLabels} is TRUE,
the function OnChangeLabels is called to give the application the opportunity to relabel.

\membersection{wxGrid::EndBatch}\label{endbatch}

\func{void}{EndBatch}{\void}

End a BeginBatch/EndBatch pair between which, calls to SetCellValue or
SetCellBitmap will not cause a refresh. This allows you to speed up some operations
(for example, setting several hundred cell values). You can nest, but not overlap,
these two functions.

See also \helpref{BeginBatch}{beginbatch}, \helpref{GetBatchCount}{getbatchcount}.

\membersection{wxGrid::GetBatchCount}\label{getbatchcount}

\func{void}{GetBatchCount}{\void}

Return the level of batch nesting. This is initially zero, and will be incremented
every time BeginBatch is called, and decremented when EndBatch is called. When the
batch count is more zero, some functions (such as SetCellValue and SetCellBitmap) will
not refresh the cell.

See also \helpref{BeginBatch}{beginbatch}, \helpref{EndBatch}{endbatch}.

\membersection{wxGrid::GetCell}

\func{wxGridCell *}{GetCell}{\param{int}{ row}, \param{int}{ col}}

Returns the grid cell object associated with this position.

wxGenericGrid implementation only.

\membersection{wxGrid::GetCellAlignment}

\func{int}{GetCellAlignment}{\param{int}{ row}, \param{int}{ col}}

\func{int}{GetCellAlignment}{\void}

Sets the text alignment for the cell at the given position, or the global alignment value.
The return value is wxLEFT, wxRIGHT or wxCENTRE.

\membersection{wxGrid::GetCellBackgroundColour}

\func{wxColour\&}{GetCellBackgroundColour}{\param{int}{ row}, \param{int}{ col}}

\func{wxColour\&}{GetCellBackgroundColour}{\void}

Gets the background colour for the cell at the given position, or the global background colour.

\membersection{wxGrid::GetCells}

\func{wxGridCell ***}{GetCells}{\void}

Returns the array of grid cell object associated with this wxGrid.

wxGenericGrid implementation only.

\membersection{wxGrid::GetCellTextColour}

\func{wxColour\&}{GetCellTextColour}{\param{int}{ row}, \param{int}{ col}}

\func{wxColour\&}{GetCellTextColour}{\void}

Gets the text colour for the cell at the given position, or the global text colour.

\membersection{wxGrid::GetCellTextFont}

\func{wxFont *}{GetCellTextFont}{\param{int}{ row}, \param{int}{ col}}

\func{wxFont *}{GetCellTextFont}{\void}

Gets the text font for the cell at the given position, or the global text font.

\membersection{wxGrid::GetCellValue}

\func{wxString\&}{GetCellValue}{\param{int}{ row}, \param{int}{ col}}

Returns the cell value at the given position.

\membersection{wxGrid::GetCols}

\func{int}{GetCols}{\void}

Returns the number of columns in the grid.

\membersection{wxGrid::GetColumnWidth}

\func{int}{GetColumnWidth}{\param{int}{ col}}

Gets the width in pixels for column {\it col}.

\membersection{wxGrid::GetCurrentRect}

\func{wxRectangle *}{GetCurrentRect}{\void}

Returns a pointer to the rectangle enclosing the currently selected cell.
Do not delete this pointer.

\membersection{wxGrid::GetCursorColumn}

\func{int}{GetCursorColumn}{\void}

Returns the column position of the currently selected cell.

\membersection{wxGrid::GetCursorRow}

\func{int}{GetCursorRow}{\void}

Returns the row position of the currently selected cell.

\membersection{wxGrid::GetEditable}

\func{Bool}{GetEditable}{\void}

Returns TRUE if the grid cells can be edited.

\membersection{wxGrid::GetHorizScrollBar}

\func{wxScrollBar *}{GetHorizScrollBar}{\void}

Returns a pointer to the horizontal scrollbar.

\membersection{wxGrid::GetLabelAlignment}

\func{int}{GetLabelAlignment}{\param{int}{ orientation}}

Gets the row or column label alignment. {\it orientation} should
be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.\rtfsp
{\it alignment} should be wxCENTRE, wxLEFT or wxRIGHT.

\membersection{wxGrid::GetLabelBackgroundColour}

\func{wxColour\&}{GetLabelBackgroundColour}{\void}

Gets a row and column label text colour.

\membersection{wxGrid::GetLabelSize}

\func{int}{GetLabelSize}{\param{int}{ orientation}}

Gets the row label height, or column label width, in pixels. {\it orientation} should
be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.

\membersection{wxGrid::GetLabelTextColour}

\func{wxColour\&}{GetLabelTextColour}{\void}

Gets a row and column label text colour.

\membersection{wxGrid::GetLabelTextFont}

\func{wxFont *}{GetLabelTextFont}{\void}

Gets the font to be used for the row and column labels.

\membersection{wxGrid::GetLabelValue}

\func{wxString\&}{GetLabelValue}{\param{int}{ orientation}, \param{int}{ pos}}

Gets a row or column label value. {\it orientation} should
be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.\rtfsp
{\it pos} is the label position.

\membersection{wxGrid::GetRowHeight}

\func{int}{GetRowHeight}{\param{int}{ row}}

Gets the height in pixels for row {\it row}.

\membersection{wxGrid::GetRows}

\func{int}{GetRows}{\void}

Returns the number of rows in the grid.

\membersection{wxGrid::GetScrollPosX}

\func{int}{GetScrollPosX}{\void}

Returns the column scroll position.

\membersection{wxGrid::GetScrollPosX}

\func{int}{GetScrollPosY}{\void}

Returns the row scroll position.

\membersection{wxGrid::GetTextItem}

\func{wxText *}{GetTextItem}{\void}

Returns a pointer to the text item used for entering text into a cell.

\membersection{wxGrid::GetVertScrollBar}

\func{wxScrollBar *}{GetVertScrollBar}{\void}

Returns a pointer to the vertical scrollbar.

\membersection{wxGrid::InsertCols}

\func{Bool}{InsertCols}{\param{int}{ pos=0}, \param{int}{ n=1}, \param{Bool}{ updateLabels=TRUE}}

Inserts {\it n} number of columns before position {\it pos}. If {\it updateLabels} is TRUE,
the function OnChangeLabels is called to give the application the opportunity to relabel.

\membersection{wxGrid::InsertRows}

\func{Bool}{InsertRows}{\param{int}{ pos=0}, \param{int}{ n=1}, \param{Bool}{ updateLabels=TRUE}}

Inserts {\it n} number of rows before position {\it pos}. If {\it updateLabels} is TRUE,
the function OnChangeLabels is called to give the application the opportunity to relabel.

\membersection{wxGrid::OnActivate}

\func{void}{OnActivate}{\param{Bool}{ active}}

Sets the text item to have the focus. Call this function when the wxGrid window should have the
focus, for example from wxFrame::OnActivate.

\membersection{wxGrid::OnChangeLabels}

\func{void}{OnChangeLabels}{\void}

Called when rows and columns are created or deleted, to allow the application an
opportunity to update the labels. By default, columns are labelled alphabetically,
and rows numerically.

\membersection{wxGrid::OnChangeSelectionLabel}

\func{void}{OnChangeSelectionLabel}{\void}

Called when a cell is selected, to allow the application an
opportunity to update the selection label (the label of the wxText item
used for entering cell text). By default, the cell column letter and row
number are concatenated to form the selection label.

\membersection{wxGrid::OnCreateCell}

\func{wxGridCell *}{OnCreateCell}{\void}

Override this virtual function if you want to replace the normal wxGridCell with a derived
class.

\membersection{wxGrid::OnCellLeftClick}

\func{void}{OnLeftClick}{\param{int}{ row}, \param{int}{ col}, \param{int}{ x}, \param{int}{ y}, \param{Bool}{ control}, \param{Bool}{ shift}}

Virtual function called when the left button is depressed within a cell, just after OnSelectCell is called.

\membersection{wxGrid::OnCellRightClick}

\func{void}{OnRightClick}{\param{int}{ row}, \param{int}{ col}, \param{int}{ x}, \param{int}{ y}, \param{Bool}{ control}, \param{Bool}{ shift}}

Virtual function called when the right button is depressed within a cell, just after OnSelectCell is called.

\membersection{wxGrid::OnLabelLeftClick}

\func{void}{OnLeftClick}{\param{int}{ row}, \param{int}{ col}, \param{int}{ x}, \param{int}{ y}, \param{Bool}{ control}, \param{Bool}{ shift}}

Virtual function called when the left button is depressed within a
label.  

{\it row} will be {\it -1} if the click is in the top labels.

{\it col} will be {\it -1} if the click is in the left labels.

{\it row} and {\it col} will be {\it -1} if the click is in the upper
left corner.

\membersection{wxGrid::OnLabelRightClick}

\func{void}{OnRightClick}{\param{int}{ row}, \param{int}{ col}, \param{int}{ x}, \param{int}{ y}, \param{Bool}{ control}, \param{Bool}{ shift}}

Virtual function called when the right button is depressed within a label.

{\it row} will be {\it -1} if the click is in the top labels.

{\it col} will be {\it -1} if the click is in the left labels.

{\it row} and {\it col} will be {\it -1} if the click is in the upper
left corner.

\membersection{wxGrid::OnSelectCell}

\func{void}{OnSelectCell}{\param{int}{ row}, \param{int}{ col}}

Virtual function called when the user left-clicks on a cell.

\membersection{wxGrid::OnSelectCellImplementation}

\func{void}{OnSelectCellImplementation}{\param{wxDC *}{dc}, \param{int}{ row}, \param{int}{ col}}

Virtual function called when the user left-clicks on a cell. If you override this function,
call wxGrid::OnSelectCell to apply the default behaviour.

\membersection{wxGrid::SetCellAlignment}

\func{void}{SetCellAlignment}{\param{int}{ alignment}, \param{int}{ row}, \param{int}{ col}}

\func{void}{SetCellAlignment}{\param{int}{ alignment}}

Sets the text alignment for the cell at the given position, or for the whole grid. {\it alignment} may be wxLEFT, wxRIGHT or wxCENTRE.

\membersection{wxGrid::SetCellBackgroundColour}

\func{void}{SetCellBackgroundColour}{\param{const wxColour\&}{ colour}, \param{int}{ row}, \param{int}{ col}}

\func{void}{SetCellBackgroundColour}{\param{const wxColour\&}{ colour}}

Sets the background colour for the cell at the given position, or for the whole grid.

\membersection{wxGrid::SetCellTextColour}

\func{void}{SetCellTextColour}{\param{const wxColour\&}{ colour}, \param{int}{ row}, \param{int}{ col}}

\func{void}{SetCellTextColour}{\param{const wxColour\&}{ colour}}

Sets the text colour for the cell at the given position, or for the whole grid.

\membersection{wxGrid::SetCellTextFont}

\func{void}{SetCellTextFont}{\param{wxFont *}{font}, \param{int}{ row}, \param{int}{ col}}

\func{void}{SetCellTextFont}{\param{wxFont *}{font}}

Sets the text font for the cell at the given position, or for the whole grid.

\membersection{wxGrid::SetCellValue}

\func{void}{SetCellValue}{\param{const wxString\&}{ val}, \param{int}{ row}, \param{int}{ col}}

Sets the cell value at the given position.

\membersection{wxGrid::SetColumnWidth}

\func{void}{SetColumnWidth}{\param{int}{ col}, \param{int}{ width}}

Sets the width in pixels for column {\it col}.

\membersection{wxGrid::SetDividerPen}

\func{void}{SetDividerPen}{\param{wxPen *}{pen}}

Specifies the pen to be used for drawing the divisions between cells. The default
is a light grey. If NULL is specified, the divisions will not be drawn.

\membersection{wxGrid::SetEditable}

\func{void}{SetEditable}{\param{Bool}{ editable}}

If {\it editable} is TRUE (the default), the grid cells will be editable by means of the
text edit control. If FALSE, the text edit control will be hidden and the user will not
be able to edit the cell contents.

\membersection{wxGrid::SetGridCursor}

\func{void}{SetGridCursor}{\param{int }{row}, \param{int}{ col}}

Sets the position of the selected cell.

\membersection{wxGrid::SetLabelAlignment}

\func{void}{SetLabelAlignment}{\param{int}{ orientation}, \param{int}{ alignment}}

Sets the row or column label alignment. {\it orientation} should
be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.\rtfsp
{\it alignment} should be wxCENTRE, wxLEFT or wxRIGHT.

\membersection{wxGrid::SetLabelBackgroundColour}

\func{void}{SetLabelBackgroundColour}{\param{const wxColour\&}{ value}}

Sets a row or column label background colour.

\membersection{wxGrid::SetLabelSize}

\func{void}{SetLabelSize}{\param{int}{ orientation}, \param{int}{ size}}

Sets the row label height, or column label width, in pixels. {\it orientation} should
be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.

If a dimension of zero is specified, the row or column labels will not be
shown.

\membersection{wxGrid::SetLabelTextColour}

\func{void}{SetLabelTextColour}{\param{const wxColour\&}{ value}}

Sets a row and column label text colour.

\membersection{wxGrid::SetLabelTextFont}

\func{void}{SetLabelTextFont}{\param{wxFont *}{font}}

Sets the font to be used for the row and column labels.

\membersection{wxGrid::SetLabelValue}

\func{void}{SetLabelValue}{\param{int}{ orientation}, \param{const wxString\&}{ value}, \param{int}{ pos}}

Sets a row or column label value. {\it orientation} should
be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.\rtfsp
{\it pos} is the label position.

\membersection{wxGrid::SetRowHeight}

\func{void}{SetRowHeight}{\param{int}{ row}, \param{int}{ height}}

Sets the height in pixels for row {\it row}.

\membersection{wxGrid::UpdateDimensions}

\func{void}{UpdateDimensions}{\void}

Call this function whenever a change has been made via the API that
might alter size characteristics. You may also need to follow it with
a call to AdjustScrollbars.


\chapter{Classes by category}\label{classesbycat}

A classification of grid classes by category.

\section{Grid classes}

\begin{itemize}\itemsep=0pt
\item \helpref{wxGrid}{wxgrid}
\end{itemize}

\chapter{Topic overviews}\label{overviews}

This chapter contains a selection of topic overviews.

\section{wxGrid classes overview}\label{gridoverview}

wxGrid is a class for displaying and editing tabular information.

On each platform, the implementation has a different class name: on Motif,
it is wxMotifGrid, and on Windows, the generic implementation wxGenericGrid
is used. The wxGrid class is derived from a suitable platform-specific
(or generic) implementation.

This separation of portable and platform-specific class names allows the
programmer to use different grid implementations in the same program.
For example, say the wxGenericGrid implementation is good at displaying
lists without divisions, such as seen in the Windows 95 print manager
window. But the wxMotifGrid implementation is better at displaying 1000
by 1000 grids, under Motif. In this case the programmer might choose to
use both classes in the same program, thus `optimizing' the Motif
version of the application. (The example assumes that wxGenericGrid has
been tested under Motif, which currently it has not).

To use wxGrid, include the wxgrid.h header file and link with the
wxGrid library. Create a wxGrid object, or, if you need to override
some default behaviour, create an object of a class derived from wxGrid.
You need to call CreateGrid before there are any cells in the grid.

All row and column positions start from zero, and dimensions are in pixels.

If you make changes to row or column dimensions, call UpdateDimensions and
then AdjustScrollbars. If you make changes to the grid appearance (such as
a change of cell background colour or font), call Refresh for the changes
to be shown.

\subsection{Example}

The following fragment is taken from the file test.cc. Note the
call to UpdateDimensions, which is required if the application
has changed any dimensions such as column width or row height.
You may also need to call AdjustScrollbars. In this case, AdjustScrollbars
isn't necessary because it will be called by wxGrid::OnSize which is invoked
when the window is first displayed.

\begin{verbatim}
  // Make a grid
  frame->grid = new wxGrid(frame, 0, 0, 400, 400);

  frame->grid->CreateGrid(10, 8);
  frame->grid->SetColumnWidth(3, 200);
  frame->grid->SetRowHeight(4, 45);
  frame->grid->SetCellValue("First cell", 0, 0);
  frame->grid->SetCellValue("Another cell", 1, 1);
  frame->grid->SetCellValue("Yet another cell", 2, 2);
  frame->grid->SetCellTextFont(wxTheFontList->FindOrCreateFont(12, wxROMAN, wxITALIC, wxNORMAL), 0, 0);
  frame->grid->SetCellTextColour(*wxRED, 1, 1);
  frame->grid->SetCellBackgroundColour(*wxCYAN, 2, 2);
  frame->grid->UpdateDimensions();
\end{verbatim}
