/**
Parameters string format is "width[,precision]".
*/
- void SetParameters(const wxString& params);
+ virtual void SetParameters(const wxString& params);
/**
Sets the precision.
/// 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.
/// 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;
/**
The dtor is private because only DecRef() can delete us.
*/
- ~wxGridCellEditor();
+ virtual ~wxGridCellEditor();
/**
Fetch the value from the table and prepare the edit control
/**
Final cleanup.
*/
- void Destroy();
+ virtual void Destroy();
/**
Complete the editing of the current cell. Returns @true if the value has
Some types of controls on some platforms may need some help
with the Return key.
*/
- void HandleReturn(wxKeyEvent& event);
+ virtual void HandleReturn(wxKeyEvent& event);
/**
/**
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);
};
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);
};
/**
Parameters string format is "item1[,item2[...,itemN]]"
*/
- void SetParameters(const wxString& params);
+ virtual void SetParameters(const wxString& params);
};
/**
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.
/**
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.
/**
Returns @true if the Shift key was down at the time of the event.
*/
- bool ShiftDown();
+ bool ShiftDown() const;
};
/**
Parameters string format is "min,max".
*/
- void SetParameters(const wxString& params);
+ virtual void SetParameters(const wxString& params);
};
/**
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.
/**
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;
};
/**
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.
/**
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
/**
Returns @true if the Shift key was down at the time of the event.
*/
- bool ShiftDown();
+ bool ShiftDown() const;
};
/**
Parameters string format is "width,precision"
*/
- void SetParameters(const wxString& params);
+ virtual void SetParameters(const wxString& params);
};
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.
@library{wxadv}
@category{grid}
- @see @ref overview_gridoverview "wxGrid overview"
+ @see @ref overview_grid "wxGrid overview"
*/
class wxGrid : public wxScrolledWindow
{
*/
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.
*/
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.
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);
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
/**
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.
*/
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.
*/
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;
See GetRowGridLinePen() for an example.
*/
- wxPen GetColGridLinePen(int col);
+ virtual wxPen GetColGridLinePen(int col);
/**
Sets the arguments to the current column label alignment values.
/**
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;
@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.
*/
}
@endcode
*/
- wxPen GetRowGridLinePen(int row);
+ virtual wxPen GetRowGridLinePen(int row);
/**
Returns the alignment used for row labels.
*/
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.
*/
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);
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);
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);
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);
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);
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);
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);
*/
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.
*/
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.