X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5039f140c4d1ea413991e95477cdc6f755ab4b73..e25cd7750c571191ce69438de5f7c0293d1b5270:/interface/wx/grid.h diff --git a/interface/wx/grid.h b/interface/wx/grid.h index 10d96fc530..facc29034b 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -86,12 +86,42 @@ public: /// Destructor frees the attribute provider if it was created. virtual ~wxGridTableBase(); - /// Must be overridden to return the number of rows in the table. + /** + Must be overridden to return the number of rows in the table. + + For backwards compatibility reasons, this method is not const. + Use GetRowsCount() instead of it in const methods of derived table + classes. + */ virtual int GetNumberRows() = 0; - /// Must be overridden to return the number of columns in the table. + /** + Must be overridden to return the number of columns in the table. + + For backwards compatibility reasons, this method is not const. + Use GetColsCount() instead of it in const methods of derived table + classes, + */ virtual int GetNumberCols() = 0; + /** + Return the number of rows in the table. + + This method is not virtual and is only provided as a convenience for + the derived classes which can't call GetNumberRows() without a @c + const_cast from their const methods. + */ + int GetRowsCount() const; + + /** + Return the number of columns in the table. + + This method is not virtual and is only provided as a convenience for + the derived classes which can't call GetNumberCols() without a @c + const_cast from their const methods. + */ + int GetColsCount() const; + /** Accessing table cells. @@ -101,6 +131,14 @@ public: /// Must be overridden to implement testing for empty cells. virtual bool IsEmptyCell(int row, int col) = 0; + /** + Same as IsEmptyCell() but taking wxGridCellCoords. + + Notice that this method is not virtual, only IsEmptyCell() should be + overridden. + */ + bool IsEmpty(const wxGridCellCoords& coords); + /// Must be overridden to implement accessing the table values as text. virtual wxString GetValue(int row, int col) = 0; @@ -2122,6 +2160,19 @@ public: */ wxGridTableBase *GetTable() 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 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); + void GoToCell(const wxGridCellCoords& coords); + //@} + /** Returns @true if drawing of grid lines is turned on, @false otherwise. */ @@ -2685,12 +2736,22 @@ public: */ void SetDefaultRowSize(int height, bool resizeExistingRows = false); + //@{ /** Set the grid cursor to the specified cell. - This function calls MakeCellVisible(). + 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 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); + void SetGridCursor(const wxGridCellCoords& coords); + //@} /** Sets the colour used to draw grid lines. @@ -2875,6 +2936,27 @@ public: */ 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() + */ + + // XYToCell(int, int, wxGridCellCoords&) overload is intentionally + // undocumented, using it is ugly and non-const reference parameters are + // not used in wxWidgets API + + wxGridCellCoords XYToCell(int x, int y) const; + wxGridCellCoords XYToCell(const wxPoint& pos) const; + + //@} + /** Returns the row whose bottom edge is close to the given logical y position.