]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/grid.h
Fixed Connect() use sample case in CreateControls() docs
[wxWidgets.git] / interface / wx / grid.h
index fdd1ee05b61ceef5af79d04f02dc975073fe90ca..18a50d7c210748b6389ac776286c00f770294b69 100644 (file)
@@ -41,7 +41,7 @@ public:
     /**
         Parameters string format is "width[,precision]".
     */
-    void SetParameters(const wxString& params);
+    virtual void SetParameters(const wxString& params);
 
     /**
         Sets the precision.
@@ -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.
@@ -462,7 +492,7 @@ public:
     /**
         Final cleanup.
     */
-    void Destroy();
+    virtual void Destroy();
 
     /**
         Complete the editing of the current cell. Returns @true if the value has
@@ -474,7 +504,7 @@ public:
         Some types of controls on some platforms may need some help
         with the Return key.
     */
-    void HandleReturn(wxKeyEvent& event);
+    virtual void HandleReturn(wxKeyEvent& event);
 
     /**
 
@@ -496,26 +526,26 @@ public:
     /**
         Size and position the edit control.
     */
-    void SetSize(const wxRect& rect);
+    virtual void SetSize(const wxRect& rect);
 
     /**
         Show or hide the edit control, use the specified attributes to set
         colours/fonts for it.
     */
-    void Show(bool show, wxGridCellAttr* attr = NULL);
+    virtual void Show(bool show, wxGridCellAttr* attr = NULL);
 
     /**
         If the editor is enabled by clicking on the cell, this method will be
         called.
     */
-    void StartingClick();
+    virtual void StartingClick();
 
     /**
         If the editor is enabled by pressing keys on the grid,
         this will be called to let the editor do something about
         that first key if desired.
     */
-    void StartingKey(wxKeyEvent& event);
+    virtual void StartingKey(wxKeyEvent& event);
 };
 
 
@@ -543,7 +573,7 @@ public:
         The parameters string format is "n" where n is a number representing the
         maximum width.
     */
-    void SetParameters(const wxString& params);
+    virtual void SetParameters(const wxString& params);
 };
 
 
@@ -604,7 +634,7 @@ public:
     /**
         Parameters string format is "item1[,item2[...,itemN]]"
     */
-    void SetParameters(const wxString& params);
+    virtual void SetParameters(const wxString& params);
 };
 
 
@@ -827,7 +857,7 @@ public:
     /**
         Parameters string format is "min,max".
     */
-    void SetParameters(const wxString& params);
+    virtual void SetParameters(const wxString& params);
 };
 
 
@@ -1126,7 +1156,7 @@ public:
     /**
         Column at which the event occurred.
     */
-    int GetCol();
+    virtual int GetCol();
 
     /**
         Position in pixels at which the event occurred.
@@ -1136,7 +1166,7 @@ public:
     /**
         Row at which the event occurred.
     */
-    int GetRow();
+    virtual int GetRow();
 
     /**
         Returns @true if the Meta key was down at the time of the event.
@@ -1182,7 +1212,7 @@ public:
     /**
         Parameters string format is "width,precision"
     */
-    void SetParameters(const wxString& params);
+    virtual void SetParameters(const wxString& params);
 };
 
 
@@ -1625,7 +1655,7 @@ public:
         without (yet) matching calls to EndBatch(). While
         the grid's batch count is greater than zero the display will not be updated.
     */
-    int GetBatchCount() const;
+    int GetBatchCount();
 
     /**
         Sets the arguments to the horizontal and vertical text alignment values
@@ -1707,7 +1737,7 @@ public:
 
         See GetRowGridLinePen() for an example.
     */
-    wxPen GetColGridLinePen(int col);
+    virtual wxPen GetColGridLinePen(int col);
 
     /**
         Sets the arguments to the current column label alignment values.
@@ -1857,7 +1887,7 @@ public:
 
         @see GetColGridLinePen(), GetRowGridLinePen()
     */
-    wxPen GetDefaultGridLinePen();
+    virtual wxPen GetDefaultGridLinePen();
 
     /**
         Returns a pointer to the current default grid cell renderer.
@@ -1976,7 +2006,7 @@ public:
            }
         @endcode
     */
-    wxPen GetRowGridLinePen(int row);
+    virtual wxPen GetRowGridLinePen(int row);
 
     /**
         Returns the alignment used for row labels.
@@ -2130,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.
     */
@@ -2693,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.
@@ -2883,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.