]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/grid.h
no changes, just reformat, remove extraneous semicolons and inline keywords
[wxWidgets.git] / interface / wx / grid.h
index 1dace1eee9099bdba4c80873257750f22a9a5f80..c10743259d3294a34fc05ab84a230b80ebe93cbe 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.
@@ -59,7 +59,20 @@ public:
 /**
     @class wxGridTableBase
 
-    Grid table classes.
+    The almost abstract base class for grid tables.
+
+    A grid table is responsible for storing the grid data and, indirectly, grid
+    cell attributes. The data can be stored in the way most convenient for the
+    application but has to be provided in string form to wxGrid. It is also
+    possible to provide cells values in other formats if appropriate, e.g. as
+    numbers.
+
+    This base class is not quite abstract as it implements a trivial strategy
+    for storing the attributes by forwarding it to wxGridCellAttrProvider and
+    also provides stubs for some other functions. However it does have a number
+    of pure virtual methods which must be implemented in the derived classes.
+
+    @see wxGridStringTable
 
     @library{wxadv}
     @category{grid}
@@ -67,210 +80,364 @@ public:
 class wxGridTableBase : public wxObject
 {
 public:
-    /**
-
-    */
+    /// Default constructor.
     wxGridTableBase();
 
+    /// Destructor frees the attribute provider if it was created.
+    virtual ~wxGridTableBase();
+
     /**
+        Must be overridden to return the number of rows in the table.
 
-    */
-    ~wxGridTableBase();
+        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.
 
-    */
-    bool AppendCols(size_t numCols = 1);
+        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.
 
-    */
-    bool AppendRows(size_t numRows = 1);
+        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.
 
-    */
-    bool CanGetValueAs(int row, int col, const wxString& typeName);
+        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;
 
-    /**
-        Does this table allow attributes?  Default implementation creates
-        a wxGridCellAttrProvider if necessary.
-    */
-    bool CanHaveAttributes();
 
     /**
+        Accessing table cells.
+     */
+    //@{
 
-    */
-    bool CanSetValueAs(int row, int col, const wxString& typeName);
+    /// Must be overridden to implement testing for empty cells.
+    virtual bool IsEmptyCell(int row, int col) = 0;
 
     /**
+        Same as IsEmptyCell() but taking wxGridCellCoords.
 
-    */
-    void Clear();
+        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;
 
-    */
-    bool DeleteCols(size_t pos = 0, size_t numCols = 1);
+    /// Must be overridden to implement setting the table values as text.
+    virtual void SetValue(int row, int col, const wxString& value) = 0;
 
     /**
+        Returns the type of the value in the given cell.
 
-    */
-    bool DeleteRows(size_t pos = 0, size_t numRows = 1);
+        By default all cells are strings and this method returns @c
+        wxGRID_VALUE_STRING.
+     */
+    virtual wxString GetTypeName(int row, int col);
 
     /**
-        by default forwarded to wxGridCellAttrProvider if any. May be
-        overridden to handle attributes directly in the table.
-    */
-    wxGridCellAttr* GetAttr(int row, int col);
+        Returns true if the value of the given cell can be accessed as if it
+        were of the specified type.
 
-    /**
-        get the currently used attr provider (may be @NULL)
-    */
-    wxGridCellAttrProvider* GetAttrProvider() const;
+        By default the cells can only be accessed as strings. Note that a cell
+        could be accessible in different ways, e.g. a numeric cell may return
+        @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
+        indicating that the value can be coerced to a string form.
+     */
+    virtual bool CanGetValueAs(int row, int col, const wxString& typeName);
 
     /**
+        Returns true if the value of the given cell can be set as if it were of
+        the specified type.
 
-    */
-    wxString GetColLabelValue(int col);
+        @see CanGetValueAs()
+     */
+    virtual bool CanSetValueAs(int row, int col, const wxString& typeName);
 
     /**
+        Returns the value of the given cell as a long.
 
-    */
-    int GetNumberCols();
+        This should only be called if CanGetValueAs() returns @true when called
+        with @c wxGRID_VALUE_NUMBER argument. Default implementation always
+        return 0.
+     */
+    virtual long GetValueAsLong(int row, int col);
 
     /**
-        You must override these functions in a derived table class.
-    */
-    int GetNumberRows();
+        Returns the value of the given cell as a double.
+
+        This should only be called if CanGetValueAs() returns @true when called
+        with @c wxGRID_VALUE_FLOAT argument. Default implementation always
+        return 0.0.
+     */
+    virtual double GetValueAsDouble(int row, int col);
 
     /**
+        Returns the value of the given cell as a boolean.
 
-    */
-    wxString GetRowLabelValue(int row);
+        This should only be called if CanGetValueAs() returns @true when called
+        with @c wxGRID_VALUE_BOOL argument. Default implementation always
+        return false.
+     */
+    virtual bool GetValueAsBool(int row, int col);
 
     /**
-        Data type determination and value access.
-    */
-    wxString GetTypeName(int row, int col);
+        Returns the value of the given cell as a user-defined type.
 
-    /**
+        This should only be called if CanGetValueAs() returns @true when called
+        with @a typeName. Default implementation always return @NULL.
+     */
+    virtual void *GetValueAsCustom(int row, int col, const wxString& typeName);
 
-    */
-    wxString GetValue(int row, int col);
 
     /**
+        Sets the value of the given cell as a long.
 
-    */
-    bool GetValueAsBool(int row, int col);
+        This should only be called if CanSetValueAs() returns @true when called
+        with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
+        anything.
+     */
+    virtual void SetValueAsLong(int row, int col, long value);
 
     /**
-        For user defined types
-    */
-    void* GetValueAsCustom(int row, int col,
-                           const wxString& typeName);
+        Sets the value of the given cell as a double.
+
+        This should only be called if CanSetValueAs() returns @true when called
+        with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
+        anything.
+     */
+    virtual void SetValueAsDouble(int row, int col, double value);
 
     /**
+        Sets the value of the given cell as a boolean.
 
-    */
-    double GetValueAsDouble(int row, int col);
+        This should only be called if CanSetValueAs() returns @true when called
+        with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
+        anything.
+     */
+    virtual void SetValueAsBool( int row, int col, bool value );
 
     /**
+        Sets the value of the given cell as a user-defined type.
 
-    */
-    long GetValueAsLong(int row, int col);
+        This should only be called if CanSetValueAs() returns @true when called
+        with @a typeName. Default implementation doesn't do anything.
+     */
+    virtual void SetValueAsCustom(int row, int col, const wxString& typeName,
+                                  void *value);
+
+    //@}
 
     /**
+        Called by the grid when the table is associated with it.
 
-    */
-    wxGrid* GetView() const;
+        The default implementation stores the pointer and returns it from its
+        GetView() and so only makes sense if the table cannot be associated
+        with more than one grid at a time.
+     */
+    virtual void SetView(wxGrid *grid);
 
     /**
+        Returns the last grid passed to SetView().
+     */
+    virtual wxGrid *GetView() const;
 
-    */
-    bool InsertCols(size_t pos = 0, size_t numCols = 1);
 
     /**
+        Modifying the table structure.
 
-    */
-    bool InsertRows(size_t pos = 0, size_t numRows = 1);
+        Notice that none of these functions are pure virtual as they don't have
+        to be implemented if the table structure is never modified after
+        creation, i.e. neither rows nor columns are never added or deleted but
+        that you do need to implement them if they are called, i.e. if your
+        code either calls them directly or uses the matching wxGrid methods, as
+        by default they simply do nothing which is definitely inappropriate.
+     */
+    //@{
 
     /**
+        Clear the table contents.
 
-    */
-    bool IsEmptyCell(int row, int col);
+        This method is used by wxGrid::ClearGrid().
+     */
+    virtual void Clear();
 
     /**
-        these functions take ownership of the pointer
-    */
-    void SetAttr(wxGridCellAttr* attr, int row, int col);
+        Insert additional rows into the table.
 
-    /**
-        Attribute handling
-        give us the attr provider to use - we take ownership of the pointer
-    */
-    void SetAttrProvider(wxGridCellAttrProvider* attrProvider);
+        @param pos
+            The position of the first new row.
+        @param numRows
+            The number of rows to insert.
+     */
+    virtual bool InsertRows(size_t pos = 0, size_t numRows = 1);
 
     /**
+        Append additional rows at the end of the table.
 
-    */
-    void SetColAttr(wxGridCellAttr* attr, int col);
+        This method is provided in addition to InsertRows() as some data models
+        may only support appending rows to them but not inserting them at
+        arbitrary locations. In such case you may implement this method only
+        and leave InsertRows() unimplemented.
+
+        @param numRows
+            The number of rows to add.
+     */
+    virtual bool AppendRows(size_t numRows = 1);
 
     /**
-        , @e wxString)
-    */
-    void SetColLabelValue() const;
+        Delete rows from the table.
+
+        @param pos
+            The first row to delete.
+        @param numRows
+            The number of rows to delete.
+     */
+    virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1);
+
+    /// Exactly the same as InsertRows() but for columns.
+    virtual bool InsertCols(size_t pos = 0, size_t numCols = 1);
+
+    /// Exactly the same as AppendRows() but for columns.
+    virtual bool AppendCols(size_t numCols = 1);
+
+    /// Exactly the same as DeleteRows() but for columns.
+    virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1);
+
+    //@}
 
     /**
+        Table rows and columns labels.
 
-    */
-    void SetRowAttr(wxGridCellAttr* attr, int row);
+        By default the numbers are used for labeling rows and Latin letters for
+        labeling columns. If the table has more than 26 columns, the pairs of
+        letters are used starting from the 27-th one and so on, i.e. the
+        sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
+        AAA, ...
+     */
+    //@{
+
+    /// Return the label of the specified row.
+    virtual wxString GetRowLabelValue(int row);
+
+    /// Return the label of the specified column.
+    virtual wxString GetColLabelValue(int col);
 
     /**
-        , @e wxString)
-    */
-    void SetRowLabelValue() const;
+        Set the given label for the specified row.
+
+        The default version does nothing, i.e. the label is not stored. You
+        must override this method in your derived class if you wish
+        wxGrid::SetRowLabelValue() to work.
+     */
+    virtual void SetRowLabelValue(int row, const wxString& label);
+
+    /// Exactly the same as SetRowLabelValue() but for columns.
+    virtual void SetColLabelValue(int col, const wxString& label);
+
+    //@}
+
 
     /**
+        Attributes management.
 
-    */
-    void SetValue(int row, int col, const wxString& value);
+        By default the attributes management is delegated to
+        wxGridCellAttrProvider class. You may override the methods in this
+        section to handle the attributes directly if, for example, they can be
+        computed from the cell values.
+     */
+    //@{
 
     /**
+        Associate this attributes provider with the table.
 
-    */
-    void SetValueAsBool(int row, int col, bool value);
+        The table takes ownership of @a attrProvider pointer and will delete it
+        when it doesn't need it any more. The pointer can be @NULL, however
+        this won't disable attributes management in the table but will just
+        result in a default attributes being recreated the next time any of the
+        other functions in this section is called. To completely disable the
+        attributes support, should this be needed, you need to override
+        CanHaveAttributes() to return @false.
+     */
+    void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
 
     /**
+        Returns the attribute provider currently being used.
 
-    */
-    void SetValueAsCustom(int row, int col, const wxString& typeName,
-                          void* value);
+        This function may return @NULL if the attribute provider hasn't been
+        neither associated with this table by SetAttrProvider() nor created on
+        demand by any other methods.
+     */
+    wxGridCellAttrProvider *GetAttrProvider() const;
 
     /**
+        Return the attribute for the given cell.
 
-    */
-    void SetValueAsDouble(int row, int col, double value);
+        By default this function is simply forwarded to
+        wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
+        attributes directly in the table.
+     */
+    virtual wxGridCellAttr *GetAttr(int row, int col,
+                                    wxGridCellAttr::wxAttrKind kind);
 
     /**
+        Set attribute of the specified cell.
 
-    */
-    void SetValueAsLong(int row, int col, long value);
+        By default this function is simply forwarded to
+        wxGridCellAttrProvider::SetAttr().
+
+        The table takes ownership of @a attr, i.e. will call DecRef() on it.
+     */
+    virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
 
     /**
-        Overriding these is optional
-    */
-    void SetView(wxGrid* grid);
+        Set attribute of the specified row.
+
+        By default this function is simply forwarded to
+        wxGridCellAttrProvider::SetRowAttr().
+
+        The table takes ownership of @a attr, i.e. will call DecRef() on it.
+     */
+    virtual void SetRowAttr(wxGridCellAttr *attr, int row);
 
     /**
+        Set attribute of the specified column.
 
-    */
-    void UpdateAttrCols(size_t pos, int numCols);
+        By default this function is simply forwarded to
+        wxGridCellAttrProvider::SetColAttr().
+
+        The table takes ownership of @a attr, i.e. will call DecRef() on it.
+     */
+    virtual void SetColAttr(wxGridCellAttr *attr, int col);
+
+    //@}
 
     /**
-        change row/col number in attribute if needed
-    */
-    void UpdateAttrRows(size_t pos, int numRows);
+        Returns true if this table supports attributes or false otherwise.
+
+        By default, the table automatically creates a wxGridCellAttrProvider
+        when this function is called if it had no attribute provider before and
+        returns @true.
+     */
+    virtual bool CanHaveAttributes();
 };
 
 
@@ -298,44 +465,39 @@ public:
     */
     wxGridCellEditor();
 
-    /**
-        The dtor is private because only DecRef() can delete us.
-    */
-    ~wxGridCellEditor();
-
     /**
         Fetch the value from the table and prepare the edit control
         to begin editing. Set the focus to the edit control.
     */
-    void BeginEdit(int row, int col, wxGrid* grid);
+    virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
 
     /**
         Create a new object which is the copy of this one.
     */
-    wxGridCellEditor* Clone() const;
+    virtual wxGridCellEditor* Clone() const = 0;
 
     /**
         Creates the actual edit control.
     */
-    void Create(wxWindow* parent, wxWindowID id,
-                wxEvtHandler* evtHandler);
+    virtual void Create(wxWindow* parent, wxWindowID id,
+                        wxEvtHandler* evtHandler) = 0;
 
     /**
         Final cleanup.
     */
-    void Destroy();
+    virtual void Destroy();
 
     /**
         Complete the editing of the current cell. Returns @true if the value has
         changed. If necessary, the control may be destroyed.
     */
-    bool EndEdit(int row, int col, wxGrid* grid);
+    virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
 
     /**
         Some types of controls on some platforms may need some help
         with the Return key.
     */
-    void HandleReturn(wxKeyEvent& event);
+    virtual void HandleReturn(wxKeyEvent& event);
 
     /**
 
@@ -346,37 +508,43 @@ public:
         Draws the part of the cell not occupied by the control: the base class
         version just fills it with background colour from the attribute.
     */
-    void PaintBackground(const wxRect& rectCell,
-                         wxGridCellAttr* attr);
+    virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr* attr);
 
     /**
         Reset the value in the control back to its starting value.
     */
-    void Reset();
+    virtual void Reset() = 0;
 
     /**
         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);
+
+protected:
+
+    /**
+        The dtor is private because only DecRef() can delete us.
+    */
+    virtual ~wxGridCellEditor();
 };
 
 
@@ -404,7 +572,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);
 };
 
 
@@ -458,6 +626,12 @@ public:
     wxGridCellChoiceEditor(size_t count = 0,
                            const wxString choices[] = NULL,
                            bool allowOthers = false);
+    /**
+        @param choices
+            An array of strings from which the user can choose.
+        @param allowOthers
+            If allowOthers is @true, the user can type a string not in choices array.
+    */
     wxGridCellChoiceEditor(const wxArrayString& choices,
                            bool allowOthers = false);
     //@}
@@ -465,7 +639,7 @@ public:
     /**
         Parameters string format is "item1[,item2[...,itemN]]"
     */
-    void SetParameters(const wxString& params);
+    virtual void SetParameters(const wxString& params);
 };
 
 
@@ -554,12 +728,12 @@ public:
     /**
         Returns @true if the Alt key was down at the time of the event.
     */
-    bool AltDown();
+    bool AltDown() const;
 
     /**
         Returns @true if the Control key was down at the time of the event.
     */
-    bool ControlDown();
+    bool ControlDown() const;
 
     /**
         Top left corner of the rectangular area that was (de)selected.
@@ -594,7 +768,7 @@ public:
     /**
         Returns @true if the Meta key was down at the time of the event.
     */
-    bool MetaDown();
+    bool MetaDown() const;
 
     /**
         Returns @true if the area was selected, @false otherwise.
@@ -604,7 +778,7 @@ public:
     /**
         Returns @true if the Shift key was down at the time of the event.
     */
-    bool ShiftDown();
+    bool ShiftDown() const;
 };
 
 
@@ -631,7 +805,7 @@ public:
     /**
 
     */
-    wxGridCellRenderer* Clone() const;
+    virtual wxGridCellRenderer* Clone() const = 0;
 
     /**
         Draw the given cell on the provided DC inside the given rectangle
@@ -641,15 +815,15 @@ public:
         prepare the DC using the given attribute: it will draw the rectangle
         with the background colour from attr and set the text colour and font.
     */
-    void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
-              const wxRect& rect, int row, int col,
-              bool isSelected);
+    virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
+                      const wxRect& rect, int row, int col,
+                      bool isSelected) = 0;
 
     /**
         Get the preferred size of the cell for its contents.
     */
-    wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
-                       int row, int col);
+    virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
+                               int row, int col) = 0;
 };
 
 
@@ -674,10 +848,13 @@ public:
     */
     wxGridCellNumberEditor(int min = -1, int max = -1);
 
+
     /**
-        String representation of the value.
+        Parameters string format is "min,max".
     */
-    wxString GetString() const;
+    virtual void SetParameters(const wxString& params);
+
+protected:
 
     /**
         If the return value is @true, the editor uses a wxSpinCtrl to get user input,
@@ -686,9 +863,9 @@ public:
     bool HasRange() const;
 
     /**
-        Parameters string format is "min,max".
+        String representation of the value.
     */
-    void SetParameters(const wxString& params);
+    wxString GetString() const;
 };
 
 
@@ -722,12 +899,12 @@ public:
     /**
         Returns @true if the Alt key was down at the time of the event.
     */
-    bool AltDown();
+    bool AltDown() const;
 
     /**
         Returns @true if the Control key was down at the time of the event.
     */
-    bool ControlDown();
+    bool ControlDown() const;
 
     /**
         Position in pixels at which the event occurred.
@@ -742,12 +919,12 @@ public:
     /**
         Returns @true if the Meta key was down at the time of the event.
     */
-    bool MetaDown();
+    bool MetaDown() const;
 
     /**
         Returns @true if the Shift key was down at the time of the event.
     */
-    bool ShiftDown();
+    bool ShiftDown() const;
 };
 
 
@@ -816,27 +993,27 @@ public:
     /**
 
     */
-    const wxColour GetBackgroundColour() const;
+    const wxColour& GetBackgroundColour() const;
 
     /**
 
     */
-    wxGridCellEditor* GetEditor(wxGrid* grid, int row, int col) const;
+    wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const;
 
     /**
 
     */
-    const wxFont GetFont() const;
+    const wxFont& GetFont() const;
 
     /**
 
     */
-    wxGridCellRenderer* GetRenderer(wxGrid* grid, int row, int col) const;
+    wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const;
 
     /**
 
     */
-    const wxColour GetTextColour() const;
+    const wxColour& GetTextColour() const;
 
     /**
 
@@ -977,17 +1154,17 @@ public:
     /**
         Returns @true if the Alt key was down at the time of the event.
     */
-    bool AltDown();
+    bool AltDown() const;
 
     /**
         Returns @true if the Control key was down at the time of the event.
     */
-    bool ControlDown();
+    bool ControlDown() const;
 
     /**
         Column at which the event occurred.
     */
-    int GetCol();
+    virtual int GetCol();
 
     /**
         Position in pixels at which the event occurred.
@@ -997,12 +1174,12 @@ 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.
     */
-    bool MetaDown();
+    bool MetaDown() const;
 
     /**
         Returns @true if the user is selecting grid cells, @false -- if
@@ -1013,7 +1190,7 @@ public:
     /**
         Returns @true if the Shift key was down at the time of the event.
     */
-    bool ShiftDown();
+    bool ShiftDown() const;
 };
 
 
@@ -1043,7 +1220,7 @@ public:
     /**
         Parameters string format is "width,precision"
     */
-    void SetParameters(const wxString& params);
+    virtual void SetParameters(const wxString& params);
 };
 
 
@@ -1059,7 +1236,7 @@ public:
     will set up default instances of the other classes and manage them for you.
     For more complex applications you can derive your own classes for custom
     grid views, grid data tables, cell editors and renderers. The @ref
-    overview_gridoverview has examples of simple and more complex applications,
+    overview_grid "wxGrid overview" has examples of simple and more complex applications,
     explains the relationship between the various grid classes and has a
     summary of the keyboard shortcuts and mouse functions provided by wxGrid.
 
@@ -1092,7 +1269,7 @@ public:
     @library{wxadv}
     @category{grid}
 
-    @see @ref overview_gridoverview "wxGrid overview"
+    @see @ref overview_grid "wxGrid overview"
 */
 class wxGrid : public wxScrolledWindow
 {
@@ -1189,6 +1366,26 @@ public:
     */
     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;
+
     /**
         Automatically sets the height and width of all rows and columns to fit their
         contents.
@@ -1300,15 +1497,6 @@ public:
     */
     bool CanEnableCellControl() const;
 
-    /**
-        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.
-    */
-    bool CanHaveAttributes() const;
-
     //@{
     /**
         Return the rectangle corresponding to the grid cell's size and position
@@ -1335,6 +1523,30 @@ public:
     */
     void ClearSelection();
 
+    /**
+        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 AreVertzGridLinesClipped(), ClipHorzGridLines()
+     */
+    void ClipVertzGridLines(bool clip);
+
     /**
         Creates a grid with the specified initial number of rows and columns.
 
@@ -1447,7 +1659,7 @@ public:
 
         For more information about controlling grid cell attributes see the
         wxGridCellAttr cell attribute class and the
-        @ref overview_gridoverview.
+        @ref overview_grid "wxGrid overview".
     */
     void EnableEditing(bool edit);
 
@@ -1472,7 +1684,7 @@ public:
     /**
         Overridden wxWindow method.
     */
-    void Fit();
+    virtual void Fit();
 
     /**
         Causes immediate repainting of the grid.
@@ -1486,7 +1698,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
@@ -1508,8 +1720,8 @@ public:
     /**
         Returns a pointer to the editor for the cell at the specified location.
 
-        See wxGridCellEditor and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
 
         The caller must call DecRef() on the returned pointer.
     */
@@ -1524,8 +1736,8 @@ public:
         Returns a pointer to the renderer for the grid cell at the specified
         location.
 
-        See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
 
         The caller must call DecRef() on the returned pointer.
     */
@@ -1547,8 +1759,8 @@ public:
         data types (e.g. numeric, boolean or user-defined custom types) then
         you only use this function for those cells that contain string values.
 
-        See wxGridTableBase::CanGetValueAs and the @ref overview_gridoverview
-        "wxGrid overview" for more information.
+        See wxGridTableBase::CanGetValueAs and the @ref overview_grid "wxGrid overview"
+        for more information.
     */
     wxString GetCellValue(int row, int col) const;
     const wxString  GetCellValue(const wxGridCellCoords& coords) const;
@@ -1568,7 +1780,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.
@@ -1595,11 +1807,6 @@ public:
     */
     wxString GetColLabelValue(int col) const;
 
-    /**
-        Returns the coordinate of the left border specified column.
-    */
-    int GetColLeft(int col) const;
-
     /**
         Returns the minimal width to which a column may be resized.
 
@@ -1608,25 +1815,11 @@ public:
     */
     int GetColMinimalAcceptableWidth() const;
 
-    /**
-        Get the minimal width of the given column/row.
-
-        The value returned by this function may be different than that returned
-        by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
-        called for this column.
-    */
-    int GetColMinimalWidth(int col) const;
-
     /**
         Returns the position of the specified column.
     */
     int GetColPos(int colID) const;
 
-    /**
-        Returns the coordinate of the right border specified column.
-    */
-    int GetColRight(int col) const;
-
     /**
         Returns the width of the specified column.
     */
@@ -1673,8 +1866,8 @@ public:
     /**
         Returns a pointer to the current default grid cell editor.
 
-        See wxGridCellEditor and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
     */
     wxGridCellEditor* GetDefaultEditor() const;
 
@@ -1718,13 +1911,13 @@ public:
 
         @see GetColGridLinePen(), GetRowGridLinePen()
     */
-    wxPen GetDefaultGridLinePen();
+    virtual wxPen GetDefaultGridLinePen();
 
     /**
         Returns a pointer to the current default grid cell renderer.
 
-        See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
 
         The caller must call DecRef() on the returned pointer.
     */
@@ -1837,7 +2030,7 @@ public:
            }
         @endcode
     */
-    wxPen GetRowGridLinePen(int row);
+    virtual wxPen GetRowGridLinePen(int row);
 
     /**
         Returns the alignment used for row labels.
@@ -1874,15 +2067,6 @@ public:
     */
     int GetRowMinimalAcceptableHeight() const;
 
-    /**
-        Returns the minimal size for the given column.
-
-        The value returned by this function may be different than that returned
-        by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
-        called for this row.
-    */
-    int GetRowMinimalHeight(int col) const;
-
     /**
         Returns the height of the specified row.
     */
@@ -1991,6 +2175,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.
     */
@@ -2113,8 +2310,8 @@ public:
         @true even if the cell is only partially visible.
     */
     bool IsVisible(int row, int col, bool wholeCellVisible = true) const;
-    const bool IsVisible(const wxGridCellCoords& coords,
-                         bool wholeCellVisible = true) const;
+    bool IsVisible(const wxGridCellCoords& coords,
+                   bool wholeCellVisible = true) const;
     //@}
 
     //@{
@@ -2329,8 +2526,8 @@ public:
 
         The grid will take ownership of the pointer.
 
-        See wxGridCellEditor and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
     */
     void SetCellEditor(int row, int col, wxGridCellEditor* editor);
 
@@ -2344,8 +2541,8 @@ public:
 
         The grid will take ownership of the pointer.
 
-        See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
     */
     void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer);
 
@@ -2370,7 +2567,7 @@ public:
         you only use this function for those cells that contain string values.
         The last form is for backward compatibility only.
 
-        See wxGridTableBase::CanSetValueAs and the @ref overview_gridoverview
+        See wxGridTableBase::CanSetValueAs and the @ref overview_grid
         "wxGrid overview" for more information.
     */
     void SetCellValue(int row, int col, const wxString& s);
@@ -2382,7 +2579,7 @@ public:
         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_gridoverview.
+        wxGridCellAttr cell attribute class and the @ref overview_grid "wxGrid overview".
     */
     void SetColAttr(int col, wxGridCellAttr* attr);
 
@@ -2402,7 +2599,7 @@ public:
         cells in this column, it does associate the renderer and editor used
         for the cells of the specified type with them.
 
-        See the @ref overview_gridoverview "wxGrid overview" for more
+        See the @ref overview_grid "wxGrid overview" for more
         information on working with custom data types.
     */
     void SetColFormatCustom(int col, const wxString& typeName);
@@ -2528,8 +2725,8 @@ public:
 
         The grid will take ownership of the pointer.
 
-        See wxGridCellEditor and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
     */
     void SetDefaultEditor(wxGridCellEditor* editor);
 
@@ -2538,8 +2735,8 @@ public:
 
         The grid will take ownership of the pointer.
 
-        See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid
-        overview" for more information about cell editors and renderers.
+        See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
+        for more information about cell editors and renderers.
     */
     void SetDefaultRenderer(wxGridCellRenderer* renderer);
 
@@ -2554,12 +2751,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.
@@ -2744,6 +2951,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.
@@ -2757,7 +2985,45 @@ public:
 
         Returns @c wxNOT_FOUND if there is no row at the y position.
     */
-    int YToRow(int y) const;
+    int YToRow(int y, bool clipToMinMax = false) 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.
+    */
+    bool CanHaveAttributes() const;
+
+    /**
+        Get the minimal width of the given column/row.
+
+        The value returned by this function may be different than that returned
+        by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
+        called for this column.
+    */
+    int GetColMinimalWidth(int col) const;
+
+    /**
+        Returns the coordinate of the right border specified column.
+    */
+    int GetColRight(int col) const;
+
+    /**
+        Returns the coordinate of the left border specified column.
+    */
+    int GetColLeft(int col) const;
+
+    /**
+        Returns the minimal size for the given column.
+
+        The value returned by this function may be different than that returned
+        by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
+        called for this row.
+    */
+    int GetRowMinimalHeight(int col) const;
 };