+
+ If @a width equals @c wxGRID_AUTOSIZE then width is calculated
+ automatically so that no label is truncated. Note that this could be
+ slow for a large table.
+ */
+ void SetRowLabelSize(int width);
+
+ /**
+ Sets the minimal row @a height used by default.
+
+ See SetColMinimalAcceptableWidth() for more information.
+ */
+ void SetRowMinimalAcceptableHeight(int height);
+
+ /**
+ Sets the minimal @a height for the specified @a row.
+
+ See SetColMinimalWidth() for more information.
+ */
+ void SetRowMinimalHeight(int row, int height);
+
+ /**
+ Sets the height of the specified row.
+
+ See SetColSize() for more information.
+ */
+ void SetRowSize(int row, int height);
+
+ /**
+ Hides the specified row.
+
+ To show the row later you need to call SetRowSize() with non-0
+ width or ShowRow().
+
+ @param col
+ The row index.
+ */
+ void HideRow(int col);
+
+ /**
+ Shows the previously hidden row by resizing it to non-0 size.
+
+ @see HideRow(), SetRowSize()
+ */
+ void ShowRow(int col);
+
+ /**
+ Get size information for all columns at once.
+
+ This method is useful when the information about all column widths
+ needs to be saved. The widths can be later restored using
+ SetColSizes().
+
+ @sa wxGridSizesInfo, GetRowSizes()
+ */
+ wxGridSizesInfo GetColSizes() const;
+
+ /**
+ Get size information for all row at once.
+
+ @sa wxGridSizesInfo, GetColSizes()
+ */
+ wxGridSizesInfo GetRowSizes() const;
+
+ /**
+ Restore all columns sizes.
+
+ This is usually called with wxGridSizesInfo object previously returned
+ by GetColSizes().
+
+ @sa SetRowSizes()
+ */
+ void SetColSizes(const wxGridSizesInfo& sizeInfo);
+
+ /**
+ Restore all rows sizes.
+
+ @sa SetColSizes()
+ */
+ void SetRowSizes(const wxGridSizesInfo& sizeInfo);
+
+ /**
+ Set the size of the cell.
+
+ Specifying a value of more than 1 in @a num_rows or @a num_cols will
+ make the cell at (@a row, @a col) span the block of the specified size,
+ covering the other cells which would be normally shown in it. Passing 1
+ for both arguments resets the cell to normal appearance.
+
+ @see GetCellSize()
+
+ @param row
+ The row of the cell.
+ @param col
+ The column of the cell.
+ @param num_rows
+ Number of rows to be occupied by this cell, must be >= 1.
+ @param num_cols
+ Number of columns to be occupied by this cell, must be >= 1.
+ */
+ void SetCellSize(int row, int col, int num_rows, int num_cols);
+
+ /**
+ Get the size of the cell in number of cells covered by it.
+
+ For normal cells, the function fills both @a num_rows and @a num_cols
+ with 1 and returns CellSpan_None. For cells which span multiple cells, i.e.
+ for which SetCellSize() had been called, the returned values are the
+ same ones as were passed to SetCellSize() call and the function return
+ value is CellSpan_Main.
+
+ More unexpectedly, perhaps, the returned values may be @em negative for
+ the cells which are inside a span covered by a cell occupying multiple
+ rows or columns. They correspond to the offset of the main cell of the
+ span from the cell passed to this functions and the function returns
+ CellSpan_Inside value to indicate this.
+
+ As an example, consider a 3*3 grid with the cell (1, 1) (the one in the
+ middle) having a span of 2 rows and 2 columns, i.e. the grid looks like
+ @code
+ +----+----+----+
+ | | | |
+ +----+----+----+
+ | | |
+ +----+ |
+ | | |
+ +----+----+----+
+ @endcode
+ Then the function returns 2 and 2 in @a num_rows and @a num_cols for
+ the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1
+ and 0 for the cell (2, 1).
+
+ @param row
+ The row of the cell.
+ @param col
+ The column of the cell.
+ @param num_rows
+ Pointer to variable receiving the number of rows, must not be @NULL.
+ @param num_cols
+ Pointer to variable receiving the number of columns, must not be
+ @NULL.
+ @return
+ The kind of this cell span (the return value is new in wxWidgets
+ 2.9.1, this function was void in previous wxWidgets versions).
+ */
+ CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const;
+
+ /**
+ Get the number of rows and columns allocated for this cell.
+
+ This overload doesn't return a CellSpan value but the values returned
+ may still be negative, see GetCellSize(int, int, int *, int *) for
+ details.
+ */
+ wxSize GetCellSize(const wxGridCellCoords& coords);
+
+ //@}
+
+
+ /**
+ @name User-Resizing and Dragging
+
+ Functions controlling various interactive mouse operations.
+
+ By default, columns and rows can be resized by dragging the edges of
+ their labels (this can be disabled using DisableDragColSize() and
+ DisableDragRowSize() methods). And if grid line dragging is enabled with
+ EnableDragGridSize() they can also be resized by dragging the right or
+ bottom edge of the grid cells.
+
+ Columns can also be moved to interactively change their order but this
+ needs to be explicitly enabled with EnableDragColMove().
+ */
+ //@{
+
+ /**
+ Return @true if the dragging of cells is enabled or @false otherwise.
+ */
+ bool CanDragCell() const;
+
+ /**
+ Returns @true if columns can be moved by dragging with the mouse.
+
+ Columns can be moved by dragging on their labels.
+ */
+ bool CanDragColMove() const;
+
+ /**
+ Returns @true if the given column can be resized by dragging with the
+ mouse.
+
+ This function returns @true if resizing the columns interactively is
+ globally enabled, i.e. if DisableDragColSize() hadn't been called, and
+ if this column wasn't explicitly marked as non-resizable with
+ DisableColResize().
+ */
+ bool CanDragColSize(int col) const;
+
+ /**
+ Return @true if the dragging of grid lines to resize rows and columns
+ is enabled or @false otherwise.
+ */
+ bool CanDragGridSize() const;
+
+ /**
+ Returns @true if the given row can be resized by dragging with the
+ mouse.
+
+ This is the same as CanDragColSize() but for rows.
+ */
+ bool CanDragRowSize(int row) const;
+
+ /**
+ Disable interactive resizing of the specified column.
+
+ This method allows to disable resizing of an individual column in a
+ grid where the columns are otherwise resizable (which is the case by
+ default).
+
+ Notice that currently there is no way to make some columns resizable in
+ a grid where columns can't be resized by default as there doesn't seem
+ to be any need for this in practice. There is also no way to make the
+ column marked as fixed using this method resizable again because it is
+ supposed that fixed columns are used for static parts of the grid and
+ so should remain fixed during the entire grid lifetime.
+
+ Also notice that disabling interactive column resizing will not prevent
+ the program from changing the column size.
+
+ @see EnableDragColSize()
+ */
+ void DisableColResize(int col);
+
+ /**
+ Disable interactive resizing of the specified row.
+
+ This is the same as DisableColResize() but for rows.
+
+ @see EnableDragRowSize()
+ */
+ void DisableRowResize(int row);
+
+ /**
+ Disables column moving by dragging with the mouse.
+
+ Equivalent to passing @false to EnableDragColMove().
+ */
+ void DisableDragColMove();
+
+ /**
+ Disables column sizing by dragging with the mouse.
+
+ Equivalent to passing @false to EnableDragColSize().
+ */
+ void DisableDragColSize();
+
+ /**
+ Disable mouse dragging of grid lines to resize rows and columns.
+
+ Equivalent to passing @false to EnableDragGridSize()
+ */
+ void DisableDragGridSize();
+
+ /**
+ Disables row sizing by dragging with the mouse.
+
+ Equivalent to passing @false to EnableDragRowSize().
+ */
+ void DisableDragRowSize();
+
+ /**
+ Enables or disables cell dragging with the mouse.
+ */
+ void EnableDragCell(bool enable = true);
+
+ /**
+ Enables or disables column moving by dragging with the mouse.
+ */
+ void EnableDragColMove(bool enable = true);
+
+ /**
+ Enables or disables column sizing by dragging with the mouse.
+
+ @see DisableColResize()
+ */
+ void EnableDragColSize(bool enable = true);
+
+ /**
+ Enables or disables row and column resizing by dragging gridlines with
+ the mouse.
+ */
+ void EnableDragGridSize(bool enable = true);
+
+ /**
+ Enables or disables row sizing by dragging with the mouse.
+
+ @see DisableRowResize()
+ */
+ void EnableDragRowSize(bool enable = true);
+
+ /**
+ Returns the column ID of the specified column position.
+ */
+ int GetColAt(int colPos) const;
+
+ /**
+ Returns the position of the specified column.
+ */
+ int GetColPos(int colID) const;
+
+ /**
+ Sets the position of the specified column.
+ */
+ void SetColPos(int colID, int newPos);
+
+ /**
+ Sets the positions of all columns at once.
+
+ This method takes an array containing the indices of the columns in
+ their display order, i.e. uses the same convention as
+ wxHeaderCtrl::SetColumnsOrder().
+ */
+ void SetColumnsOrder(const wxArrayInt& order);
+
+ /**
+ Resets the position of the columns to the default.
+ */
+ void ResetColPos();
+
+ //@}
+
+
+ /**
+ @name Cursor Movement
+ */
+ //@{
+
+ /**
+ Returns the current grid cell column position.
+ */
+ int GetGridCursorCol() const;
+
+ /**
+ Returns the current grid cell row position.
+ */
+ int GetGridCursorRow() const;
+
+ /**
+ Make the given cell current and ensure it is visible.
+
+ This method is equivalent to calling MakeCellVisible() and
+ SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
+ event is generated by it and the selected cell doesn't change if the
+ event is vetoed.
+ */
+ void GoToCell(int row, int col);
+ /**
+ Make the given cell current and ensure it is visible.
+
+ This method is equivalent to calling MakeCellVisible() and
+ SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
+ event is generated by it and the selected cell doesn't change if the
+ event is vetoed.
+ */
+ void GoToCell(const wxGridCellCoords& coords);
+
+ /**
+ Moves the grid cursor down by one row.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorDown(bool expandSelection);
+
+ /**
+ Moves the grid cursor down in the current column such that it skips to
+ the beginning or end of a block of non-empty cells.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorDownBlock(bool expandSelection);
+
+ /**
+ Moves the grid cursor left by one column.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorLeft(bool expandSelection);
+
+ /**
+ Moves the grid cursor left in the current row such that it skips to the
+ beginning or end of a block of non-empty cells.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorLeftBlock(bool expandSelection);
+
+ /**
+ Moves the grid cursor right by one column.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorRight(bool expandSelection);
+
+ /**
+ Moves the grid cursor right in the current row such that it skips to
+ the beginning or end of a block of non-empty cells.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorRightBlock(bool expandSelection);
+
+ /**
+ Moves the grid cursor up by one row.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorUp(bool expandSelection);
+
+ /**
+ Moves the grid cursor up in the current column such that it skips to
+ the beginning or end of a block of non-empty cells.
+
+ If a block of cells was previously selected it will expand if the
+ argument is @true or be cleared if the argument is @false.
+ */
+ bool MoveCursorUpBlock(bool expandSelection);
+
+ /**
+ Moves the grid cursor down by some number of rows so that the previous
+ bottom visible row becomes the top visible row.
+ */
+ bool MovePageDown();
+
+ /**
+ Moves the grid cursor up by some number of rows so that the previous
+ top visible row becomes the bottom visible row.
+ */
+ bool MovePageUp();
+
+ /**
+ Set the grid cursor to the specified cell.
+
+ The grid cursor indicates the current cell and can be moved by the user
+ using the arrow keys or the mouse.
+
+ Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
+ if the event handler vetoes this event, the cursor is not moved.
+
+ This function doesn't make the target call visible, use GoToCell() to
+ do this.
+ */
+ void SetGridCursor(int row, int col);
+ /**
+ Set the grid cursor to the specified cell.
+
+ The grid cursor indicates the current cell and can be moved by the user
+ using the arrow keys or the mouse.
+
+ Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
+ if the event handler vetoes this event, the cursor is not moved.
+
+ This function doesn't make the target call visible, use GoToCell() to
+ do this.
+ */
+ void SetGridCursor(const wxGridCellCoords& coords);
+
+ //@}
+
+
+ /**
+ @name User Selection
+ */
+ //@{
+
+ /**
+ Deselects all cells that are currently selected.
+ */
+ void ClearSelection();
+
+ /**
+ Returns an array of individually selected cells.
+
+ Notice that this array does @em not contain all the selected cells in
+ general as it doesn't include the cells selected as part of column, row
+ or block selection. You must use this method, GetSelectedCols(),
+ GetSelectedRows() and GetSelectionBlockTopLeft() and
+ GetSelectionBlockBottomRight() methods to obtain the entire selection
+ in general.
+
+ Please notice this behaviour is by design and is needed in order to
+ support grids of arbitrary size (when an entire column is selected in
+ a grid with a million of columns, we don't want to create an array with
+ a million of entries in this function, instead it returns an empty
+ array and GetSelectedCols() returns an array containing one element).
+ */
+ wxGridCellCoordsArray GetSelectedCells() const;
+
+ /**
+ Returns an array of selected columns.
+
+ Please notice that this method alone is not sufficient to find all the
+ selected columns as it contains only the columns which were
+ individually selected but not those being part of the block selection
+ or being selected in virtue of all of their cells being selected
+ individually, please see GetSelectedCells() for more details.
+ */
+ wxArrayInt GetSelectedCols() const;
+
+ /**
+ Returns an array of selected rows.
+
+ Please notice that this method alone is not sufficient to find all the
+ selected rows as it contains only the rows which were individually
+ selected but not those being part of the block selection or being
+ selected in virtue of all of their cells being selected individually,
+ please see GetSelectedCells() for more details.
+ */
+ wxArrayInt GetSelectedRows() const;
+
+ /**
+ Returns the colour used for drawing the selection background.
+ */
+ wxColour GetSelectionBackground() const;
+
+ /**
+ Returns an array of the bottom right corners of blocks of selected
+ cells.
+
+ Please see GetSelectedCells() for more information about the selection
+ representation in wxGrid.
+
+ @see GetSelectionBlockTopLeft()
+ */
+ wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
+
+ /**
+ Returns an array of the top left corners of blocks of selected cells.
+
+ Please see GetSelectedCells() for more information about the selection
+ representation in wxGrid.
+
+ @see GetSelectionBlockBottomRight()
+ */
+ wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
+
+ /**
+ Returns the colour used for drawing the selection foreground.
+ */
+ wxColour GetSelectionForeground() const;
+
+ /**
+ Returns the current selection mode.
+
+ @see SetSelectionMode().
+ */
+ wxGridSelectionModes GetSelectionMode() const;
+
+ /**
+ Returns @true if the given cell is selected.
+ */
+ bool IsInSelection(int row, int col) const;
+ /**
+ Returns @true if the given cell is selected.
+ */
+ bool IsInSelection(const wxGridCellCoords& coords) const;
+
+ /**
+ Returns @true if there are currently any selected cells, rows, columns
+ or blocks.
+ */
+ bool IsSelection() const;
+
+ /**
+ Selects all cells in the grid.
+ */
+ void SelectAll();
+
+ /**
+ Selects a rectangular block of cells.
+
+ If @a addToSelected is @false then any existing selection will be
+ deselected; if @true the column will be added to the existing
+ selection.
+ */
+ void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol,
+ bool addToSelected = false);
+ /**
+ Selects a rectangular block of cells.
+
+ If @a addToSelected is @false then any existing selection will be
+ deselected; if @true the column will be added to the existing
+ selection.
+ */
+ void SelectBlock(const wxGridCellCoords& topLeft,
+ const wxGridCellCoords& bottomRight,
+ bool addToSelected = false);
+
+ /**
+ Selects the specified column.
+
+ If @a addToSelected is @false then any existing selection will be
+ deselected; if @true the column will be added to the existing
+ selection.
+
+ This method won't select anything if the current selection mode is
+ wxGridSelectRows.
+ */
+ void SelectCol(int col, bool addToSelected = false);
+
+ /**
+ Selects the specified row.
+
+ If @a addToSelected is @false then any existing selection will be
+ deselected; if @true the row will be added to the existing selection.
+
+ This method won't select anything if the current selection mode is
+ wxGridSelectColumns.
+ */
+ void SelectRow(int row, bool addToSelected = false);
+
+ /**
+ Set the colour to be used for drawing the selection background.
+ */
+ void SetSelectionBackground(const wxColour& c);
+
+ /**
+ Set the colour to be used for drawing the selection foreground.
+ */
+ void SetSelectionForeground(const wxColour& c);
+
+ /**
+ Set the selection behaviour of the grid.
+
+ The existing selection is converted to conform to the new mode if
+ possible and discarded otherwise (e.g. any individual selected cells
+ are deselected if the new mode allows only the selection of the entire
+ rows or columns).
+ */
+ void SetSelectionMode(wxGridSelectionModes selmode);
+
+ //@}
+
+
+ /**
+ @name Scrolling
+ */
+ //@{
+
+ /**
+ Returns the number of pixels per horizontal scroll increment.
+
+ The default is 15.
+
+ @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
+ */
+ int GetScrollLineX() const;
+
+ /**
+ Returns the number of pixels per vertical scroll increment.
+
+ The default is 15.
+
+ @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
+ */
+ int GetScrollLineY() const;
+
+ /**
+ Returns @true if a cell is either entirely or at least partially
+ visible in the grid window.
+
+ By default, the cell must be entirely visible for this function to
+ return @true but if @a wholeCellVisible is @false, the function returns
+ @true even if the cell is only partially visible.
+ */
+ bool IsVisible(int row, int col, bool wholeCellVisible = true) const;
+ /**
+ Returns @true if a cell is either entirely or at least partially
+ visible in the grid window.
+
+ By default, the cell must be entirely visible for this function to
+ return @true but if @a wholeCellVisible is @false, the function returns
+ @true even if the cell is only partially visible.
+ */
+ bool IsVisible(const wxGridCellCoords& coords,
+ bool wholeCellVisible = true) const;
+
+ /**
+ Brings the specified cell into the visible grid cell area with minimal
+ scrolling.
+
+ Does nothing if the cell is already visible.
+ */
+ void MakeCellVisible(int row, int col);
+ /**
+ Brings the specified cell into the visible grid cell area with minimal
+ scrolling.
+
+ Does nothing if the cell is already visible.
+ */
+ void MakeCellVisible(const wxGridCellCoords& coords);
+
+ /**
+ Sets the number of pixels per horizontal scroll increment.
+
+ The default is 15.
+
+ @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
+ */
+ void SetScrollLineX(int x);
+
+ /**
+ Sets the number of pixels per vertical scroll increment.
+
+ The default is 15.
+
+ @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
+ */
+ void SetScrollLineY(int y);
+
+ //@}
+
+
+ /**
+ @name Cell and Device Coordinate Translation
+ */
+ //@{
+
+ /**
+ Convert grid cell coordinates to grid window pixel coordinates.
+
+ This function returns the rectangle that encloses the block of cells
+ limited by @a topLeft and @a bottomRight cell in device coords and
+ clipped to the client size of the grid window.
+
+ @see CellToRect()
+ */
+ wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft,
+ const wxGridCellCoords& bottomRight) const;
+
+ /**
+ Return the rectangle corresponding to the grid cell's size and position
+ in logical coordinates.
+
+ @see BlockToDeviceRect()
+ */
+ wxRect CellToRect(int row, int col) const;
+ /**
+ Return the rectangle corresponding to the grid cell's size and position
+ in logical coordinates.
+
+ @see BlockToDeviceRect()
+ */
+ wxRect CellToRect(const wxGridCellCoords& coords) const;
+
+ /**
+ Returns the column at the given pixel position.
+
+ @param x
+ The x position to evaluate.
+ @param clipToMinMax
+ If @true, rather than returning @c wxNOT_FOUND, it returns either
+ the first or last column depending on whether @a x is too far to
+ the left or right respectively.
+ @return
+ The column index or @c wxNOT_FOUND.
+ */
+ int XToCol(int x, bool clipToMinMax = false) const;
+
+ /**
+ Returns the column whose right hand edge is close to the given logical
+ @a x position.
+
+ If no column edge is near to this position @c wxNOT_FOUND is returned.
+ */
+ int XToEdgeOfCol(int x) const;
+
+ /**
+ Translates logical pixel coordinates to the grid cell coordinates.
+
+ Notice that this function expects logical coordinates on input so if
+ you use this function in a mouse event handler you need to translate
+ the mouse position, which is expressed in device coordinates, to
+ logical ones.
+
+ @see XToCol(), YToRow()
+ */
+ wxGridCellCoords XYToCell(int x, int y) const;
+ /**
+ Translates logical pixel coordinates to the grid cell coordinates.
+
+ Notice that this function expects logical coordinates on input so if
+ you use this function in a mouse event handler you need to translate
+ the mouse position, which is expressed in device coordinates, to
+ logical ones.
+
+ @see XToCol(), YToRow()
+ */
+ wxGridCellCoords XYToCell(const wxPoint& pos) const;
+ // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
+ // undocumented, using it is ugly and non-const reference parameters are
+ // not used in wxWidgets API
+
+ /**
+ Returns the row whose bottom edge is close to the given logical @a y
+ position.
+
+ If no row edge is near to this position @c wxNOT_FOUND is returned.
+ */
+ int YToEdgeOfRow(int y) const;
+
+ /**
+ Returns the grid row that corresponds to the logical @a y coordinate.
+
+ Returns @c wxNOT_FOUND if there is no row at the @a y position.
+ */
+ int YToRow(int y, bool clipToMinMax = false) const;
+
+ //@}
+
+
+ /**
+ @name Miscellaneous Functions
+ */
+ //@{
+
+ /**
+ Appends one or more new columns to the right of the grid.
+
+ The @a updateLabels argument is not used at present. If you are using a
+ derived grid table class you will need to override
+ wxGridTableBase::AppendCols(). See InsertCols() for further
+ information.
+
+ @return @true on success or @false if appending columns failed.
+ */
+ bool AppendCols(int numCols = 1, bool updateLabels = true);
+
+ /**
+ Appends one or more new rows to the bottom of the grid.
+
+ The @a updateLabels argument is not used at present. If you are using a
+ derived grid table class you will need to override
+ wxGridTableBase::AppendRows(). See InsertRows() for further
+ information.
+
+ @return @true on success or @false if appending rows failed.
+ */
+ bool AppendRows(int numRows = 1, bool updateLabels = true);
+
+ /**
+ Return @true if the horizontal grid lines stop at the last column
+ boundary or @false if they continue to the end of the window.
+
+ The default is to clip grid lines.
+
+ @see ClipHorzGridLines(), AreVertGridLinesClipped()
+ */
+ bool AreHorzGridLinesClipped() const;
+
+ /**
+ Return @true if the vertical grid lines stop at the last row
+ boundary or @false if they continue to the end of the window.
+
+ The default is to clip grid lines.
+
+ @see ClipVertGridLines(), AreHorzGridLinesClipped()
+ */
+ bool AreVertGridLinesClipped() const;
+
+ /**
+ Increments the grid's batch count.
+
+ When the count is greater than zero repainting of the grid is
+ suppressed. Each call to BeginBatch must be matched by a later call to
+ EndBatch(). Code that does a lot of grid modification can be enclosed
+ between BeginBatch() and EndBatch() calls to avoid screen flicker. The
+ final EndBatch() call will cause the grid to be repainted.
+
+ Notice that you should use wxGridUpdateLocker which ensures that there
+ is always a matching EndBatch() call for this BeginBatch() if possible
+ instead of calling this method directly.
+ */
+ void BeginBatch();
+
+ /**
+ Clears all data in the underlying grid table and repaints the grid.
+
+ The table is not deleted by this function. If you are using a derived
+ table class then you need to override wxGridTableBase::Clear() for this
+ function to have any effect.
+ */
+ void ClearGrid();
+
+ /**
+ Change whether the horizontal grid lines are clipped by the end of the
+ last column.
+
+ By default the grid lines are not drawn beyond the end of the last
+ column but after calling this function with @a clip set to @false they
+ will be drawn across the entire grid window.
+
+ @see AreHorzGridLinesClipped(), ClipVertGridLines()
+ */
+ void ClipHorzGridLines(bool clip);
+
+ /**
+ Change whether the vertical grid lines are clipped by the end of the
+ last row.
+
+ By default the grid lines are not drawn beyond the end of the last
+ row but after calling this function with @a clip set to @false they
+ will be drawn across the entire grid window.
+
+ @see AreVertGridLinesClipped(), ClipHorzGridLines()
+ */
+ void ClipVertGridLines(bool clip);
+
+ /**
+ Deletes one or more columns from a grid starting at the specified
+ position.
+
+ The @a updateLabels argument is not used at present. If you are using a
+ derived grid table class you will need to override
+ wxGridTableBase::DeleteCols(). See InsertCols() for further
+ information.
+
+ @return @true on success or @false if deleting columns failed.
+ */
+ bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true);
+
+ /**
+ Deletes one or more rows from a grid starting at the specified
+ position.
+
+ The @a updateLabels argument is not used at present. If you are using a
+ derived grid table class you will need to override
+ wxGridTableBase::DeleteRows(). See InsertRows() for further
+ information.
+
+ @return @true on success or @false if appending rows failed.
+ */
+ bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true);
+
+ /**
+ Decrements the grid's batch count.
+
+ When the count is greater than zero repainting of the grid is
+ suppressed. Each previous call to BeginBatch() must be matched by a
+ later call to EndBatch(). Code that does a lot of grid modification can
+ be enclosed between BeginBatch() and EndBatch() calls to avoid screen
+ flicker. The final EndBatch() will cause the grid to be repainted.
+
+ @see wxGridUpdateLocker
+ */
+ void EndBatch();
+
+ /**
+ Overridden wxWindow method.
+ */
+ virtual void Fit();
+
+ /**
+ Causes immediate repainting of the grid.
+
+ Use this instead of the usual wxWindow::Refresh().
+ */
+ void ForceRefresh();
+
+ /**
+ Returns the number of times that BeginBatch() has been called without
+ (yet) matching calls to EndBatch(). While the grid's batch count is
+ greater than zero the display will not be updated.
+ */
+ int GetBatchCount();
+
+ /**
+ Returns the total number of grid columns.
+
+ This is the same as the number of columns in the underlying grid table.
+ */
+ int GetNumberCols() const;
+
+ /**
+ Returns the total number of grid rows.
+
+ This is the same as the number of rows in the underlying grid table.
+ */
+ int GetNumberRows() const;
+
+ /**
+ Returns the attribute for the given cell creating one if necessary.
+
+ If the cell already has an attribute, it is returned. Otherwise a new
+ attribute is created, associated with the cell and returned. In any
+ case the caller must call DecRef() on the returned pointer.
+
+ This function may only be called if CanHaveAttributes() returns @true.
+ */
+ wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
+
+ /**
+ Returns a base pointer to the current table object.
+
+ The returned pointer is still owned by the grid.
+ */
+ wxGridTableBase *GetTable() const;
+
+ /**
+ Inserts one or more new columns into a grid with the first new column
+ at the specified position.
+
+ Notice that inserting the columns in the grid requires grid table
+ cooperation: when this method is called, grid object begins by
+ requesting the underlying grid table to insert new columns. If this is
+ successful the table notifies the grid and the grid updates the
+ display. For a default grid (one where you have called CreateGrid())
+ this process is automatic. If you are using a custom grid table
+ (specified with SetTable()) then you must override
+ wxGridTableBase::InsertCols() in your derived table class.
+
+ @param pos
+ The position which the first newly inserted column will have.
+ @param numCols
+ The number of columns to insert.
+ @param updateLabels
+ Currently not used.
+ @return
+ @true if the columns were successfully inserted, @false if an error
+ occurred (most likely the table couldn't be updated).
+ */
+ bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true);
+
+ /**
+ Inserts one or more new rows into a grid with the first new row at the
+ specified position.
+
+ Notice that you must implement wxGridTableBase::InsertRows() if you use
+ a grid with a custom table, please see InsertCols() for more
+ information.
+
+ @param pos
+ The position which the first newly inserted row will have.
+ @param numRows
+ The number of rows to insert.
+ @param updateLabels
+ Currently not used.
+ @return
+ @true if the rows were successfully inserted, @false if an error
+ occurred (most likely the table couldn't be updated).
+ */
+ bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true);
+
+ /**
+ Invalidates the cached attribute for the given cell.
+
+ For efficiency reasons, wxGrid may cache the recently used attributes
+ (currently it caches only the single most recently used one, in fact)
+ which can result in the cell appearance not being refreshed even when
+ the attribute returned by your custom wxGridCellAttrProvider-derived
+ class has changed. To force the grid to refresh the cell attribute,
+ this function may be used. Notice that calling it will not result in
+ actually redrawing the cell, you still need to call
+ wxWindow::RefreshRect() to invalidate the area occupied by the cell in
+ the window to do this. Also note that you don't need to call this
+ function if you store the attributes in wxGrid itself, i.e. use its
+ SetAttr() and similar methods, it is only useful when using a separate
+ custom attributes provider.
+
+ @param row
+ The row of the cell whose attribute needs to be queried again.
+ @param col
+ The column of the cell whose attribute needs to be queried again.
+
+ @since 2.9.2
+ */
+ void RefreshAttr(int row, int col);
+
+ /**
+ Sets the cell attributes for all cells in the specified column.
+
+ For more information about controlling grid cell attributes see the
+ wxGridCellAttr cell attribute class and the @ref overview_grid.
+ */
+ void SetColAttr(int col, wxGridCellAttr* attr);
+
+ /**
+ Sets the extra margins used around the grid area.
+
+ A grid may occupy more space than needed for its data display and
+ this function allows to set how big this extra space is
+ */
+ void SetMargins(int extraWidth, int extraHeight);
+
+ /**
+ Sets the cell attributes for all cells in the specified row.
+
+ The grid takes ownership of the attribute pointer.
+
+ See the wxGridCellAttr class for more information about controlling
+ cell attributes.
+ */
+ void SetRowAttr(int row, wxGridCellAttr* attr);
+
+ //@}
+
+
+ /**
+ @name Sorting support.
+
+ wxGrid doesn't provide any support for sorting the data but it does
+ generate events allowing the user code to sort it and supports
+ displaying the sort indicator in the column used for sorting.
+
+ To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT
+ event (and not veto it) and resort the data displayed in the grid. The
+ grid will automatically update the sorting indicator on the column
+ which was clicked.
+
+ You can also call the functions in this section directly to update the
+ sorting indicator. Once again, they don't do anything with the grid
+ data, it remains your responsibility to actually sort it appropriately.
+ */
+ //@{
+
+ /**
+ Return the column in which the sorting indicator is currently
+ displayed.
+
+ Returns @c wxNOT_FOUND if sorting indicator is not currently displayed
+ at all.
+
+ @see SetSortingColumn()
+ */
+ int GetSortingColumn() const;
+
+ /**
+ Return @true if this column is currently used for sorting.
+
+ @see GetSortingColumn()
+ */
+ bool IsSortingBy(int col) const;
+
+ /**
+ Return @true if the current sorting order is ascending or @false if it
+ is descending.
+
+ It only makes sense to call this function if GetSortingColumn() returns
+ a valid column index and not @c wxNOT_FOUND.
+
+ @see SetSortingColumn()
+ */
+ bool IsSortOrderAscending() const;
+
+ /**
+ Set the column to display the sorting indicator in and its direction.
+
+ @param col
+ The column to display the sorting indicator in or @c wxNOT_FOUND to
+ remove any currently displayed sorting indicator.
+ @param ascending
+ If @true, display the ascending sort indicator, otherwise display
+ the descending sort indicator.
+
+ @see GetSortingColumn(), IsSortOrderAscending()
+ */
+ void SetSortingColumn(int col, bool ascending = true);
+
+ /**
+ Remove any currently shown sorting indicator.
+
+ This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND
+ first argument.
+ */
+ void UnsetSortingColumn();
+ //@}
+
+
+ /**
+ @name Accessors for component windows.
+
+ Return the various child windows of wxGrid.
+
+ wxGrid is an empty parent window for 4 children representing the column
+ labels window (top), the row labels window (left), the corner window
+ (top left) and the main grid window. It may be necessary to use these
+ individual windows and not the wxGrid window itself if you need to
+ handle events for them (this can be done using wxEvtHandler::Connect()
+ or wxWindow::PushEventHandler()) or do something else requiring the use
+ of the correct window pointer. Notice that you should not, however,
+ change these windows (e.g. reposition them or draw over them) because
+ they are managed by wxGrid itself.
+ */
+ //@{
+
+ /**
+ Return the main grid window containing the grid cells.
+
+ This window is always shown.
+ */
+ wxWindow *GetGridWindow() const;
+
+ /**
+ Return the row labels window.
+
+ This window is not shown if the row labels were hidden using
+ HideRowLabels().
+ */
+ wxWindow *GetGridRowLabelWindow() const;
+
+ /**
+ Return the column labels window.
+
+ This window is not shown if the columns labels were hidden using
+ HideColLabels().
+
+ Depending on whether UseNativeColHeader() was called or not this can be
+ either a wxHeaderCtrl or a plain wxWindow. This function returns a valid
+ window pointer in either case but in the former case you can also use
+ GetGridColHeader() to access it if you need wxHeaderCtrl-specific
+ functionality.
+ */
+ wxWindow *GetGridColLabelWindow() const;
+
+ /**
+ Return the window in the top left grid corner.
+
+ This window is shown only of both columns and row labels are shown and
+ normally doesn't contain anything. Clicking on it is handled by wxGrid
+ however and can be used to select the entire grid.
+ */
+ wxWindow *GetGridCornerLabelWindow() const;
+
+ /**
+ Return the header control used for column labels display.
+
+ This function can only be called if UseNativeColHeader() had been
+ called.
+ */
+ wxHeaderCtrl *GetGridColHeader() const;
+
+ //@}
+
+protected:
+ /**
+ Returns @true if this grid has support for cell attributes.
+
+ The grid supports attributes if it has the associated table which, in
+ turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
+ returns @true.