This function must check if the current value of the editing control is
valid and different from the original value (available as @a oldval in
its string form and possibly saved internally using its real type by
- BeginEdit()). If it isn't, it just returns @false, otherwise it fills
- @a newval with the representation of the new value in the string form,
- if necessary saves it using its real type internally, and returns @true.
+ BeginEdit()). If it isn't, it just returns @false, otherwise it must do
+ the following:
+ # Save the new value internally so that ApplyEdit() could apply it.
+ # Fill @a newval (which is never @NULL) with the string
+ representation of the new value.
+ # Return @true
+
+ Notice that it must @em not modify the grid as the change could still
+ be vetoed.
If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto
this change, ApplyEdit() will be called next.
*/
- virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
+ virtual bool EndEdit(int row, int col, const wxGrid* grid,
+ const wxString& oldval, wxString* newval) = 0;
/**
Effectively save the changes in the grid.
an empty string otherwise.
*/
static void UseStringValues(const wxString& valueTrue = "1",
- const wxString& valueFalse = wxEmptyString) const;
+ const wxString& valueFalse = wxEmptyString);
};
/**
/**
Default constructor.
*/
- wxGridCellAttr();
+ wxGridCellAttr(wxGridCellAttr* attrDefault = NULL);
/**
Constructor specifying some of the often used attributes.
*/
virtual bool CanHaveAttributes();
};
+/**
+ @class wxGridSizesInfo
+
+ wxGridSizesInfo stores information about sizes of all wxGrid rows or
+ columns.
+
+ It assumes that most of the rows or columns (which are both called elements
+ here as the difference between them doesn't matter at this class level)
+ have the default size and so stores it separately. And it uses a wxHashMap
+ to store the sizes of all elements which have the non-default size.
+
+ This structure is particularly useful for serializing the sizes of all
+ wxGrid elements at once.
+
+ @library{wxadv}
+ @category{grid}
+ */
+struct wxGridSizesInfo
+{
+ /**
+ Default constructor.
+
+ m_sizeDefault and m_customSizes must be initialized later.
+ */
+ wxGridSizesInfo();
+
+ /**
+ Constructor.
+
+ This constructor is used by wxGrid::GetRowSizes() and GetColSizes()
+ methods. User code will usually use the default constructor instead.
+
+ @param defSize
+ The default element size.
+ @param allSizes
+ Array containing the sizes of @em all elements, including those
+ which have the default size.
+ */
+ wxGridSizesInfo(int defSize, const wxArrayInt& allSizes);
+
+ /**
+ Get the element size.
+
+ @param pos
+ The index of the element.
+ @return
+ The size for this element, using m_customSizes if @a pos is in it
+ or m_sizeDefault otherwise.
+ */
+ int GetSize(unsigned pos) const;
+
+
+ /// Default size
+ int m_sizeDefault;
+
+ /**
+ Map with element indices as keys and their sizes as values.
+
+ This map only contains the elements with non-default size.
+ */
+ wxUnsignedToIntHashMap m_customSizes;
+};
/**
- wxGridCellFloatEditor
- wxGridCellNumberEditor
- wxGridCellTextEditor
-
+
Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and
wxGridEditorCreatedEvent for the documentation of all event types you can
use with wxGrid.
/**
Call this in order to make the column labels use a native look by using
- wxRenderer::DrawHeaderButton() internally.
+ wxRendererNative::DrawHeaderButton() internally.
There is no equivalent method for drawing row columns as there is not
native look for that. This option is useful when using wxGrid for
displaying tables and not as a spread-sheet.
- @see UseNativeHeader()
+ @see UseNativeColHeader()
*/
void SetUseNativeColLabels(bool native = true);
are using the grid to display tabular data and don't have thousands of
columns in it.
- Also note that currently @c wxEVT_GRID_LABEL_LEFT_DCLICK and @c
- wxEVT_GRID_LABEL_RIGHT_DCLICK events are not generated for the column
+ Also note that currently @c wxEVT_GRID_LABEL_LEFT_DCLICK and
+ @c wxEVT_GRID_LABEL_RIGHT_DCLICK events are not generated for the column
labels if the native columns header is used (but this limitation could
possibly be lifted in the future).
*/
See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
more information.
*/
- const wxString GetCellValue(const wxGridCellCoords& coords) const;
+ wxString GetCellValue(const wxGridCellCoords& coords) const;
/**
Returns a pointer to the current default grid cell editor.
*/
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);
+
//@}
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
- */
+ */
//@{
/**
@see BlockToDeviceRect()
*/
- const wxRect CellToRect(const wxGridCellCoords& coords) const;
+ wxRect CellToRect(const wxGridCellCoords& coords) const;
/**
Returns the column at the given pixel position.
//@}
-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;
-
/**
@name Sorting support.
void UnsetSortingColumn();
//@}
+
/**
@name Accessors for component windows.
GetGridColHeader() to access it if you need wxHeaderCtrl-specific
functionality.
*/
- wxWindow *GetGridWindow() const;
+ wxWindow *GetGridColLabelWindow() const;
/**
Return the window in the top left grid corner.
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.
+ */
+ 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;
};
@event{EVT_GRID_CELL_CHANGING(func)}
The user is about to change the data in a cell. The new cell value as
string is available from GetString() event object method. This event
- can be vetoed if the change is not allowed. Processes a @c
- wxEVT_GRID_CELL_CHANGING event type.
+ can be vetoed if the change is not allowed.
+ Processes a @c wxEVT_GRID_CELL_CHANGING event type.
@event{EVT_GRID_CELL_CHANGED(func)}
The user changed the data in a cell. The old cell value as string is
available from GetString() event object method. Notice that vetoing
proceed in which case wxGrid::SetColPos() is used to reorder the
columns display order without affecting the use of the column indices
otherwise.
-
This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type.
@event{EVT_GRID_COL_SORT(func)}
This event is generated when a column is clicked by the user and its
(and not vetoed) the grid supposes that the table was indeed resorted
and updates the column to indicate the new sort order and refreshes
itself.
-
This event macro corresponds to @c wxEVT_GRID_COL_SORT event type.
@endEventTable
@library{wxadv}
- @category{grid}
+ @category{grid,events}
*/
class wxGridEvent : public wxNotifyEvent
{
*/
wxGridEvent(int id, wxEventType type, wxObject* obj,
int row = -1, int col = -1, int x = -1, int y = -1,
- bool sel = true, bool control = false, bool shift = false,
- bool alt = false, bool meta = false);
+ bool sel = true, const wxKeyboardState& kbd = wxKeyboardState());
/**
Returns @true if the Alt key was down at the time of the event.
@endEventTable
@library{wxadv}
- @category{grid}
+ @category{grid,events}
*/
class wxGridSizeEvent : public wxNotifyEvent
{
*/
wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
int rowOrCol = -1, int x = -1, int y = -1,
- bool control = false, bool shift = false,
- bool alt = false, bool meta = false);
+ const wxKeyboardState& kbd = wxKeyboardState());
/**
Returns @true if the Alt key was down at the time of the event.
@endEventTable
@library{wxadv}
- @category{grid}
+ @category{grid,events}
*/
class wxGridRangeSelectEvent : public wxNotifyEvent
{
wxObject* obj,
const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
- bool sel = true, bool control = false,
- bool shift = false, bool alt = false,
- bool meta = false);
+ bool sel = true, const wxKeyboardState& kbd = wxKeyboardState());
/**
Returns @true if the Alt key was down at the time of the event.
@endEventTable
@library{wxadv}
- @category{grid}
+ @category{grid,events}
*/
class wxGridEditorCreatedEvent : public wxCommandEvent
{