X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03faec761d423a9a4ea76edfc391dc8ba3676af2..b5fe7ca67bf3121959a0b5a59afd00c1708f2f03:/interface/wx/grid.h diff --git a/interface/wx/grid.h b/interface/wx/grid.h index 3c63d221c3..22f1ff4f59 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -218,14 +218,21 @@ public: 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(const wxString& oldval, wxString* newval) = 0; + virtual bool EndEdit(int row, int col, const wxGrid* grid, + const wxString& oldval, wxString* newval) = 0; /** Effectively save the changes in the grid. @@ -1028,6 +1035,68 @@ public: 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; +}; /** @@ -2213,6 +2282,41 @@ public: */ 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); + //@}