X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8763842294e3945c327b81a6112d8679283d55bf..f1ddb476b1d90a1e24f904eb74462f5dc5165442:/interface/wx/grid.h?ds=sidebyside diff --git a/interface/wx/grid.h b/interface/wx/grid.h index ad7250a984..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(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. @@ -321,7 +328,7 @@ public: an empty string otherwise. */ static void UseStringValues(const wxString& valueTrue = "1", - const wxString& valueFalse = wxEmptyString) const; + const wxString& valueFalse = wxEmptyString); }; /** @@ -480,7 +487,7 @@ public: /** Default constructor. */ - wxGridCellAttr(); + wxGridCellAttr(wxGridCellAttr* attrDefault = NULL); /** Constructor specifying some of the often used attributes. */ @@ -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; +}; /** @@ -1068,7 +1137,7 @@ public: - wxGridCellFloatEditor - wxGridCellNumberEditor - wxGridCellTextEditor - + Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and wxGridEditorCreatedEvent for the documentation of all event types you can use with wxGrid. @@ -1397,13 +1466,13 @@ public: /** 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); @@ -1425,8 +1494,8 @@ public: 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). */ @@ -1665,7 +1734,7 @@ public: 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. @@ -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); + //@} @@ -2332,12 +2436,12 @@ public: 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(); //@} @@ -2345,7 +2449,7 @@ public: /** @name Cursor Movement - */ + */ //@{ /** @@ -2770,7 +2874,7 @@ public: @see BlockToDeviceRect() */ - const wxRect CellToRect(const wxGridCellCoords& coords) const; + wxRect CellToRect(const wxGridCellCoords& coords) const; /** Returns the column at the given pixel position. @@ -3098,44 +3202,6 @@ public: //@} -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. @@ -3207,6 +3273,7 @@ protected: void UnsetSortingColumn(); //@} + /** @name Accessors for component windows. @@ -3251,7 +3318,7 @@ protected: 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. @@ -3271,6 +3338,44 @@ protected: 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; }; @@ -3354,8 +3459,8 @@ public: @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 @@ -3406,7 +3511,6 @@ public: 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 @@ -3417,7 +3521,6 @@ public: (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 @@ -3436,8 +3539,7 @@ public: */ 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. @@ -3518,8 +3620,7 @@ public: */ 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. @@ -3583,9 +3684,7 @@ public: 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.