1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGrid and related classes
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 @class wxGridCellRenderer
11 This class is responsible for actually drawing the cell in the grid. You
12 may pass it to the wxGridCellAttr (below) to change the format of one given
13 cell or to wxGrid::SetDefaultRenderer() to change the view of all cells.
14 This is an abstract class, and you will normally use one of the predefined
15 derived classes or derive your own class from it.
20 @see wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer,
21 wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
22 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
23 wxGridCellStringRenderer
25 class wxGridCellRenderer
: public wxClientDataContainer
, public wxRefCounter
31 This function must be implemented in derived classes to return a copy
34 virtual wxGridCellRenderer
* Clone() const = 0;
37 Draw the given cell on the provided DC inside the given rectangle using
38 the style specified by the attribute and the default or selected state
39 corresponding to the isSelected value.
41 This pure virtual function has a default implementation which will
42 prepare the DC using the given attribute: it will draw the rectangle
43 with the background colour from attr and set the text colour and font.
45 virtual void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
46 const wxRect
& rect
, int row
, int col
,
50 Get the preferred size of the cell for its contents.
52 virtual wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
53 int row
, int col
) = 0;
57 The destructor is private because only DecRef() can delete us.
59 virtual ~wxGridCellRenderer();
63 @class wxGridCellAutoWrapStringRenderer
65 This class may be used to format string data in a cell. The too
66 long lines are wrapped to be shown entirely at word boundaries.
71 @see wxGridCellRenderer, wxGridCellBoolRenderer,
72 wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
73 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
74 wxGridCellStringRenderer
77 class wxGridCellAutoWrapStringRenderer
: public wxGridCellStringRenderer
83 wxGridCellAutoWrapStringRenderer();
88 @class wxGridCellBoolRenderer
90 This class may be used to format boolean data in a cell.
95 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
96 wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
97 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
98 wxGridCellStringRenderer
100 class wxGridCellBoolRenderer
: public wxGridCellRenderer
106 wxGridCellBoolRenderer();
110 @class wxGridCellDateTimeRenderer
112 This class may be used to format a date/time data in a cell.
113 The class wxDateTime is used internally to display the local date/time
114 or to parse the string date entered in the cell thanks to the defined format.
119 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
120 wxGridCellBoolRenderer, wxGridCellEnumRenderer,
121 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
122 wxGridCellStringRenderer
124 class wxGridCellDateTimeRenderer
: public wxGridCellStringRenderer
128 Date/time renderer constructor.
131 strptime()-like format string used the parse the output date/time.
133 strptime()-like format string used to parse the string entered in the cell.
135 wxGridCellDateTimeRenderer(const wxString
& outformat
= wxDefaultDateTimeFormat
,
136 const wxString
& informat
= wxDefaultDateTimeFormat
);
140 Sets the strptime()-like format string which will be used to parse
144 strptime()-like format string used to parse the date/time.
146 virtual void SetParameters(const wxString
& params
);
150 @class wxGridCellEnumRenderer
152 This class may be used to render in a cell a number as a textual
155 The corresponding text strings are specified as comma-separated items in
156 the string passed to this renderer ctor or SetParameters() method. For
157 example, if this string is @c "John,Fred,Bob" the cell will be rendered as
158 "John", "Fred" or "Bob" if its contents is 0, 1 or 2 respectively.
163 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
164 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
165 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
166 wxGridCellStringRenderer
168 class wxGridCellEnumRenderer
: public wxGridCellStringRenderer
175 Comma separated string parameters "item1[,item2[...,itemN]]".
177 wxGridCellEnumRenderer( const wxString
& choices
= wxEmptyString
);
180 Sets the comma separated string content of the enum.
183 Comma separated string parameters "item1[,item2[...,itemN]]".
185 virtual void SetParameters(const wxString
& params
);
189 Specifier used to format the data to string for the numbers handled by
190 wxGridCellFloatRenderer and wxGridCellFloatEditor.
194 enum wxGridCellFloatFormat
196 /// Decimal floating point (%f).
197 wxGRID_FLOAT_FORMAT_FIXED
= 0x0010,
199 /// Scientific notation (mantise/exponent) using e character (%e).
200 wxGRID_FLOAT_FORMAT_SCIENTIFIC
= 0x0020,
202 /// Use the shorter of %e or %f (%g).
203 wxGRID_FLOAT_FORMAT_COMPACT
= 0x0040,
205 /// To use in combination with one of the above formats for the upper
206 /// case version (%F/%E/%G)
207 wxGRID_FLOAT_FORMAT_UPPER
= 0x0080,
209 /// The format used by default (wxGRID_FLOAT_FORMAT_FIXED).
210 wxGRID_FLOAT_FORMAT_DEFAULT
= wxGRID_FLOAT_FORMAT_FIXED
214 @class wxGridCellFloatRenderer
216 This class may be used to format floating point data in a cell.
221 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
222 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
223 wxGridCellEnumRenderer, wxGridCellNumberRenderer,
224 wxGridCellStringRenderer
226 class wxGridCellFloatRenderer
: public wxGridCellStringRenderer
230 Float cell renderer ctor.
233 Minimum number of characters to be shown.
235 Number of digits after the decimal dot.
237 The format used to display the string, must be a combination of
238 ::wxGridCellFloatFormat enum elements. This parameter is only
239 available since wxWidgets 2.9.3.
241 wxGridCellFloatRenderer(int width
= -1, int precision
= -1,
242 int format
= wxGRID_FLOAT_FORMAT_DEFAULT
);
245 Returns the specifier used to format the data to string.
247 The returned value is a combination of ::wxGridCellFloatFormat elements.
251 int GetFormat() const;
254 Returns the precision.
256 int GetPrecision() const;
261 int GetWidth() const;
264 Set the format to use for display the number.
267 Must be a combination of ::wxGridCellFloatFormat enum elements.
271 void SetFormat(int format
);
274 The parameters string format is "width[,precision[,format]]" where
275 @c format should be chosen between f|e|g|E|G (f is used by default)
277 virtual void SetParameters(const wxString
& params
);
282 void SetPrecision(int precision
);
287 void SetWidth(int width
);
291 @class wxGridCellNumberRenderer
293 This class may be used to format integer data in a cell.
298 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
299 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
300 wxGridCellEnumRenderer, wxGridCellFloatRenderer,
301 wxGridCellStringRenderer
303 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
309 wxGridCellNumberRenderer();
313 @class wxGridCellStringRenderer
315 This class may be used to format string data in a cell; it is the default
321 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
322 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
323 wxGridCellEnumRenderer, wxGridCellFloatRenderer,
324 wxGridCellNumberRenderer
326 class wxGridCellStringRenderer
: public wxGridCellRenderer
332 wxGridCellStringRenderer();
337 @class wxGridCellEditor
339 This class is responsible for providing and manipulating the in-place edit
340 controls for the grid. Instances of wxGridCellEditor (actually, instances
341 of derived classes since it is an abstract class) can be associated with
342 the cell attributes for individual cells, rows, columns, or even for the
348 @see wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor,
349 wxGridCellChoiceEditor, wxGridCellEnumEditor,
350 wxGridCellFloatEditor, wxGridCellNumberEditor,
353 class wxGridCellEditor
: public wxClientDataContainer
, public wxRefCounter
362 Fetch the value from the table and prepare the edit control to begin
365 This function should save the original value of the grid cell at the
366 given @a row and @a col and show the control allowing the user to
371 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
374 Create a new object which is the copy of this one.
376 virtual wxGridCellEditor
* Clone() const = 0;
379 Creates the actual edit control.
381 virtual void Create(wxWindow
* parent
, wxWindowID id
,
382 wxEvtHandler
* evtHandler
) = 0;
387 virtual void Destroy();
390 End editing the cell.
392 This function must check if the current value of the editing control is
393 valid and different from the original value (available as @a oldval in
394 its string form and possibly saved internally using its real type by
395 BeginEdit()). If it isn't, it just returns @false, otherwise it must do
397 - Save the new value internally so that ApplyEdit() could apply it.
398 - Fill @a newval (which is never @NULL) with the string
399 representation of the new value.
402 Notice that it must @em not modify the grid as the change could still
405 If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto
406 this change, ApplyEdit() will be called next.
408 virtual bool EndEdit(int row
, int col
, const wxGrid
* grid
,
409 const wxString
& oldval
, wxString
* newval
) = 0;
412 Effectively save the changes in the grid.
414 This function should save the value of the control in the grid. It is
415 called only after EndEdit() returns @true.
417 virtual void ApplyEdit(int row
, int col
, wxGrid
* grid
) = 0;
420 Some types of controls on some platforms may need some help with the
423 virtual void HandleReturn(wxKeyEvent
& event
);
426 Returns @true if the edit control has been created.
431 Draws the part of the cell not occupied by the control: the base class
432 version just fills it with background colour from the attribute.
434 virtual void PaintBackground(wxDC
& dc
, const wxRect
& rectCell
, wxGridCellAttr
& attr
);
437 Reset the value in the control back to its starting value.
439 virtual void Reset() = 0;
442 Size and position the edit control.
444 virtual void SetSize(const wxRect
& rect
);
447 Show or hide the edit control, use the specified attributes to set
448 colours/fonts for it.
450 virtual void Show(bool show
, wxGridCellAttr
* attr
= NULL
);
453 If the editor is enabled by clicking on the cell, this method will be
456 virtual void StartingClick();
459 If the editor is enabled by pressing keys on the grid, this will be
460 called to let the editor do something about that first key if desired.
462 virtual void StartingKey(wxKeyEvent
& event
);
465 Returns the value currently in the editor control.
467 virtual wxString
GetValue() const = 0;
472 The destructor is private because only DecRef() can delete us.
474 virtual ~wxGridCellEditor();
478 @class wxGridCellAutoWrapStringEditor
480 Grid cell editor for wrappable string/text data.
485 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
486 wxGridCellEnumEditor, wxGridCellFloatEditor,
487 wxGridCellNumberEditor, wxGridCellTextEditor
489 class wxGridCellAutoWrapStringEditor
: public wxGridCellTextEditor
492 wxGridCellAutoWrapStringEditor();
496 @class wxGridCellBoolEditor
498 Grid cell editor for boolean data.
503 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
504 wxGridCellChoiceEditor, wxGridCellEnumEditor,
505 wxGridCellFloatEditor, wxGridCellNumberEditor,
508 class wxGridCellBoolEditor
: public wxGridCellEditor
514 wxGridCellBoolEditor();
517 Returns @true if the given @a value is equal to the string
518 representation of the truth value we currently use (see
521 static bool IsTrueValue(const wxString
& value
);
524 This method allows you to customize the values returned by GetValue()
525 for the cell using this editor. By default, the default values of the
526 arguments are used, i.e. @c "1" is returned if the cell is checked and
527 an empty string otherwise.
529 static void UseStringValues(const wxString
& valueTrue
= "1",
530 const wxString
& valueFalse
= wxEmptyString
);
534 @class wxGridCellChoiceEditor
536 Grid cell editor for string data providing the user a choice from a list of
542 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
543 wxGridCellBoolEditor, wxGridCellEnumEditor,
544 wxGridCellFloatEditor, wxGridCellNumberEditor,
547 class wxGridCellChoiceEditor
: public wxGridCellEditor
551 Choice cell renderer ctor.
554 Number of strings from which the user can choose.
556 An array of strings from which the user can choose.
558 If allowOthers is @true, the user can type a string not in choices
561 wxGridCellChoiceEditor(size_t count
= 0,
562 const wxString choices
[] = NULL
,
563 bool allowOthers
= false);
566 Choice cell renderer ctor.
569 An array of strings from which the user can choose.
571 If allowOthers is @true, the user can type a string not in choices
574 wxGridCellChoiceEditor(const wxArrayString
& choices
,
575 bool allowOthers
= false);
578 Parameters string format is "item1[,item2[...,itemN]]"
580 virtual void SetParameters(const wxString
& params
);
584 @class wxGridCellEnumEditor
586 Grid cell editor which displays an enum number as a textual equivalent
587 (eg. data in cell is 0,1,2 ... n the cell could be displayed as
588 "John","Fred"..."Bob" in the combo choice box).
593 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
594 wxGridCellBoolEditor, wxGridCellChoiceEditor,
595 wxGridCellTextEditor, wxGridCellFloatEditor,
596 wxGridCellNumberEditor
598 class wxGridCellEnumEditor
: public wxGridCellChoiceEditor
602 Enum cell editor ctor.
605 Comma separated choice parameters "item1[,item2[...,itemN]]".
607 wxGridCellEnumEditor( const wxString
& choices
= wxEmptyString
);
611 @class wxGridCellTextEditor
613 Grid cell editor for string/text data.
618 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
619 wxGridCellBoolEditor, wxGridCellChoiceEditor,
620 wxGridCellEnumEditor, wxGridCellFloatEditor,
621 wxGridCellNumberEditor
623 class wxGridCellTextEditor
: public wxGridCellEditor
627 Text cell editor constructor.
630 Maximum width of text (this parameter is supported starting since
633 explicit wxGridCellTextEditor(size_t maxChars
= 0);
636 The parameters string format is "n" where n is a number representing
639 virtual void SetParameters(const wxString
& params
);
642 Set validator to validate user input.
646 virtual void SetValidator(const wxValidator
& validator
);
650 @class wxGridCellFloatEditor
652 The editor for floating point numbers data.
657 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
658 wxGridCellBoolEditor, wxGridCellChoiceEditor,
659 wxGridCellEnumEditor, wxGridCellNumberEditor,
662 class wxGridCellFloatEditor
: public wxGridCellTextEditor
666 Float cell editor ctor.
669 Minimum number of characters to be shown.
671 Number of digits after the decimal dot.
673 The format to use for displaying the number, a combination of
674 ::wxGridCellFloatFormat enum elements. This parameter is only
675 available since wxWidgets 2.9.3.
677 wxGridCellFloatEditor(int width
= -1, int precision
= -1,
678 int format
= wxGRID_FLOAT_FORMAT_DEFAULT
);
681 The parameters string format is "width[,precision[,format]]" where
682 @c format should be chosen between f|e|g|E|G (f is used by default)
684 virtual void SetParameters(const wxString
& params
);
688 @class wxGridCellNumberEditor
690 Grid cell editor for numeric integer data.
695 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
696 wxGridCellBoolEditor, wxGridCellChoiceEditor,
697 wxGridCellEnumEditor, wxGridCellFloatEditor,
700 class wxGridCellNumberEditor
: public wxGridCellTextEditor
704 Allows you to specify the range for acceptable data. Values equal to
705 -1 for both @a min and @a max indicate that no range checking should be
708 wxGridCellNumberEditor(int min
= -1, int max
= -1);
712 Parameters string format is "min,max".
714 virtual void SetParameters(const wxString
& params
);
719 If the return value is @true, the editor uses a wxSpinCtrl to get user
720 input, otherwise it uses a wxTextCtrl.
722 bool HasRange() const;
725 String representation of the value.
727 wxString
GetString() const;
733 @class wxGridCellAttr
735 This class can be used to alter the cells' appearance in the grid by
736 changing their attributes from the defaults. An object of this class may be
737 returned by wxGridTableBase::GetAttr().
742 class wxGridCellAttr
: public wxClientDataContainer
, public wxRefCounter
746 Kind of the attribute to retrieve.
748 @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr()
752 /// Return the combined effective attribute for the cell.
755 /// Return the attribute explicitly set for this cell.
758 /// Return the attribute set for this cells row.
761 /// Return the attribute set for this cells column.
768 wxGridCellAttr(wxGridCellAttr
* attrDefault
= NULL
);
770 Constructor specifying some of the often used attributes.
772 wxGridCellAttr(const wxColour
& colText
, const wxColour
& colBack
,
773 const wxFont
& font
, int hAlign
, int vAlign
);
776 Creates a new copy of this object.
778 wxGridCellAttr
* Clone() const;
781 This class is reference counted: it is created with ref count of 1, so
782 calling DecRef() once will delete it. Calling IncRef() allows to lock
783 it until the matching DecRef() is called.
788 Get the alignment to use for the cell with the given attribute.
790 If this attribute doesn't specify any alignment, the default attribute
791 alignment is used (which can be changed using
792 wxGrid::SetDefaultCellAlignment() but is left and top by default).
794 Notice that @a hAlign and @a vAlign values are always overwritten by
795 this function, use GetNonDefaultAlignment() if this is not desirable.
798 Horizontal alignment is returned here if this argument is non-@NULL.
799 It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.
801 Vertical alignment is returned here if this argument is non-@NULL.
802 It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
804 void GetAlignment(int* hAlign
, int* vAlign
) const;
807 Returns the background colour.
809 const wxColour
& GetBackgroundColour() const;
812 Returns the cell editor.
814 wxGridCellEditor
* GetEditor(const wxGrid
* grid
, int row
, int col
) const;
819 const wxFont
& GetFont() const;
822 Get the alignment defined by this attribute.
824 Unlike GetAlignment() this function only modifies @a hAlign and @a
825 vAlign if this attribute does define a non-default alignment. This
826 means that they must be initialized before calling this function and
827 that their values will be preserved unchanged if they are different
828 from wxALIGN_INVALID.
830 For example, the following fragment can be used to use the cell
831 alignment if one is defined but right-align its contents by default
832 (instead of left-aligning it by default) while still using the default
835 int hAlign = wxALIGN_RIGHT,
836 vAlign = wxALIGN_INVALID;
837 attr.GetNonDefaultAlignment(&hAlign, &vAlign);
842 void GetNonDefaultAlignment(int *hAlign
, int *vAlign
) const;
845 Returns the cell renderer.
847 wxGridCellRenderer
* GetRenderer(const wxGrid
* grid
, int row
, int col
) const;
850 Returns the text colour.
852 const wxColour
& GetTextColour() const;
855 Returns @true if this attribute has a valid alignment set.
857 bool HasAlignment() const;
860 Returns @true if this attribute has a valid background colour set.
862 bool HasBackgroundColour() const;
865 Returns @true if this attribute has a valid cell editor set.
867 bool HasEditor() const;
870 Returns @true if this attribute has a valid font set.
872 bool HasFont() const;
875 Returns @true if this attribute has a valid cell renderer set.
877 bool HasRenderer() const;
880 Returns @true if this attribute has a valid text colour set.
882 bool HasTextColour() const;
885 This class is reference counted: it is created with ref count of 1, so
886 calling DecRef() once will delete it. Calling IncRef() allows to lock
887 it until the matching DecRef() is called.
892 Returns @true if this cell is set as read-only.
894 bool IsReadOnly() const;
897 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
898 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of
899 @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
901 void SetAlignment(int hAlign
, int vAlign
);
904 Sets the background colour.
906 void SetBackgroundColour(const wxColour
& colBack
);
909 @todo Needs documentation.
911 void SetDefAttr(wxGridCellAttr
* defAttr
);
914 Sets the editor to be used with the cells with this attribute.
916 void SetEditor(wxGridCellEditor
* editor
);
921 void SetFont(const wxFont
& font
);
924 Sets the cell as read-only.
926 void SetReadOnly(bool isReadOnly
= true);
929 Sets the renderer to be used for cells with this attribute. Takes
930 ownership of the pointer.
932 void SetRenderer(wxGridCellRenderer
* renderer
);
935 Sets the text colour.
937 void SetTextColour(const wxColour
& colText
);
942 The destructor is private because only DecRef() can delete us.
944 virtual ~wxGridCellAttr();
948 Base class for corner window renderer.
950 This is the simplest of all header renderers and only has a single
953 @see wxGridCellAttrProvider::GetCornerRenderer()
957 class wxGridCornerHeaderRenderer
961 Called by the grid to draw the corner window border.
963 This method is responsible for drawing the border inside the given @a
964 rect and adjusting the rectangle size to correspond to the area inside
965 the border, i.e. usually call wxRect::Deflate() to account for the
969 The grid whose corner window is being drawn.
971 The device context to use for drawing.
973 Input/output parameter which contains the border rectangle on input
974 and should be updated to contain the area inside the border on
977 virtual void DrawBorder(const wxGrid
& grid
,
979 wxRect
& rect
) const = 0;
983 Common base class for row and column headers renderers.
985 @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer
989 class wxGridHeaderLabelsRenderer
: public wxGridCornerHeaderRenderer
993 Called by the grid to draw the specified label.
995 Notice that the base class DrawBorder() method is called before this
998 The default implementation uses wxGrid::GetLabelTextColour() and
999 wxGrid::GetLabelFont() to draw the label.
1001 virtual void DrawLabel(const wxGrid
& grid
,
1003 const wxString
& value
,
1007 int textOrientation
) const;
1011 Base class for row headers renderer.
1013 This is the same as wxGridHeaderLabelsRenderer currently but we still use a
1014 separate class for it to distinguish it from wxGridColumnHeaderRenderer.
1016 @see wxGridRowHeaderRendererDefault
1018 @see wxGridCellAttrProvider::GetRowHeaderRenderer()
1022 class wxGridRowHeaderRenderer
: public wxGridHeaderLabelsRenderer
1027 Base class for column headers renderer.
1029 This is the same as wxGridHeaderLabelsRenderer currently but we still use a
1030 separate class for it to distinguish it from wxGridRowHeaderRenderer.
1032 @see wxGridColumnHeaderRendererDefault
1034 @see wxGridCellAttrProvider::GetColumnHeaderRenderer()
1038 class wxGridColumnHeaderRenderer
: public wxGridHeaderLabelsRenderer
1043 Default row header renderer.
1045 You may derive from this class if you need to only override one of its
1046 methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the
1047 default implementation for the other one.
1049 @see wxGridColumnHeaderRendererDefault
1053 class wxGridRowHeaderRendererDefault
: public wxGridRowHeaderRenderer
1056 /// Implement border drawing for the row labels.
1057 virtual void DrawBorder(const wxGrid
& grid
,
1059 wxRect
& rect
) const;
1063 Default column header renderer.
1065 @see wxGridRowHeaderRendererDefault
1069 class wxGridColumnHeaderRendererDefault
: public wxGridColumnHeaderRenderer
1072 /// Implement border drawing for the column labels.
1073 virtual void DrawBorder(const wxGrid
& grid
,
1075 wxRect
& rect
) const;
1079 Default corner window renderer.
1081 @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault
1085 class wxGridCornerHeaderRendererDefault
: public wxGridCornerHeaderRenderer
1088 /// Implement border drawing for the corner window.
1089 virtual void DrawBorder(const wxGrid
& grid
,
1091 wxRect
& rect
) const;
1095 Class providing attributes to be used for the grid cells.
1097 This class both defines an interface which grid cell attributes providers
1098 should implement -- and which can be implemented differently in derived
1099 classes -- and a default implementation of this interface which is often
1100 good enough to be used without modification, especially with not very large
1101 grids for which the efficiency of attributes storage hardly matters (see
1102 the discussion below).
1104 An object of this class can be associated with a wxGrid using
1105 wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you
1106 intend to use the default provider as it is used by wxGridTableBase by
1109 Notice that while attributes provided by this class can be set for
1110 individual cells using SetAttr() or the entire rows or columns using
1111 SetRowAttr() and SetColAttr() they are always retrieved using GetAttr()
1115 The default implementation of this class stores the attributes passed to
1116 its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A
1117 derived class may use its knowledge about how the attributes are used in
1118 your program to implement it much more efficiently: for example, using a
1119 special background colour for all even-numbered rows can be implemented by
1120 simply returning the same attribute from GetAttr() if the row number is
1121 even instead of having to store N/2 row attributes where N is the total
1122 number of rows in the grid.
1124 Notice that objects of this class can't be copied.
1126 class wxGridCellAttrProvider
: public wxClientDataContainer
1129 /// Trivial default constructor.
1130 wxGridCellAttrProvider();
1132 /// Destructor releases any attributes held by this class.
1133 virtual ~wxGridCellAttrProvider();
1136 Get the attribute to use for the specified cell.
1138 If wxGridCellAttr::Any is used as @a kind value, this function combines
1139 the attributes set for this cell using SetAttr() and those for its row
1140 or column (set with SetRowAttr() or SetColAttr() respectively), with
1141 the cell attribute having the highest precedence.
1143 Notice that the caller must call DecRef() on the returned pointer if it
1147 The row of the cell.
1149 The column of the cell.
1151 The kind of the attribute to return.
1153 The attribute to use which should be DecRef()'d by caller or @NULL
1154 if no attributes are defined for this cell.
1156 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
1157 wxGridCellAttr::wxAttrKind kind
) const;
1162 All these functions take ownership of the attribute passed to them,
1163 i.e. will call DecRef() on it themselves later and so it should not be
1164 destroyed by the caller. And the attribute can be @NULL to reset a
1165 previously set value.
1169 /// Set attribute for the specified cell.
1170 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
1172 /// Set attribute for the specified row.
1173 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
1175 /// Set attribute for the specified column.
1176 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
1181 Getting header renderers.
1183 These functions return the renderers for the given row or column header
1184 label and the corner window. Unlike cell attributes, these objects are
1185 not reference counted and are never @NULL so they are returned by
1186 reference and not pointer and DecRef() shouldn't (and can't) be called
1189 All these functions were added in wxWidgets 2.9.1.
1194 Return the renderer used for drawing column headers.
1196 By default wxGridColumnHeaderRendererDefault is returned.
1198 @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader()
1202 virtual const wxGridColumnHeaderRenderer
& GetColumnHeaderRenderer(int col
);
1205 Return the renderer used for drawing row headers.
1207 By default wxGridRowHeaderRendererDefault is returned.
1211 virtual const wxGridRowHeaderRenderer
& GetRowHeaderRenderer(int row
);
1214 Return the renderer used for drawing the corner window.
1216 By default wxGridCornerHeaderRendererDefault is returned.
1220 virtual const wxGridCornerHeaderRenderer
& GetCornerRenderer();
1226 Represents coordinates of a grid cell.
1228 An object of this class is simply a (row, column) pair.
1230 class wxGridCellCoords
1234 Default constructor initializes the object to invalid state.
1236 Initially the row and column are both invalid (-1) and so operator!()
1237 for an uninitialized wxGridCellCoords returns false.
1242 Constructor taking a row and a column.
1244 wxGridCellCoords(int row
, int col
);
1247 Return the row of the coordinate.
1252 Set the row of the coordinate.
1257 Return the column of the coordinate.
1262 Set the column of the coordinate.
1267 Set the row and column of the coordinate.
1269 void Set(int row
, int col
);
1272 Assignment operator for coordinate types.
1274 wxGridCellCoords
& operator=(const wxGridCellCoords
& other
);
1279 bool operator==(const wxGridCellCoords
& other
) const;
1282 Inequality operator.
1284 bool operator!=(const wxGridCellCoords
& other
) const;
1287 Checks whether the coordinates are invalid.
1289 Returns false only if both row and column are -1. Notice that if either
1290 row or column (but not both) are -1, this method returns true even if
1291 the object is invalid. This is done because objects in such state
1292 should actually never exist, i.e. either both coordinates should be -1
1293 or none of them should be -1.
1295 bool operator!() const;
1299 @class wxGridTableBase
1301 The almost abstract base class for grid tables.
1303 A grid table is responsible for storing the grid data and, indirectly, grid
1304 cell attributes. The data can be stored in the way most convenient for the
1305 application but has to be provided in string form to wxGrid. It is also
1306 possible to provide cells values in other formats if appropriate, e.g. as
1309 This base class is not quite abstract as it implements a trivial strategy
1310 for storing the attributes by forwarding it to wxGridCellAttrProvider and
1311 also provides stubs for some other functions. However it does have a number
1312 of pure virtual methods which must be implemented in the derived classes.
1314 @see wxGridStringTable
1319 class wxGridTableBase
: public wxObject
1323 Default constructor.
1328 Destructor frees the attribute provider if it was created.
1330 virtual ~wxGridTableBase();
1333 Must be overridden to return the number of rows in the table.
1335 For backwards compatibility reasons, this method is not const.
1336 Use GetRowsCount() instead of it in const methods of derived table
1339 virtual int GetNumberRows() = 0;
1342 Must be overridden to return the number of columns in the table.
1344 For backwards compatibility reasons, this method is not const.
1345 Use GetColsCount() instead of it in const methods of derived table
1348 virtual int GetNumberCols() = 0;
1351 Return the number of rows in the table.
1353 This method is not virtual and is only provided as a convenience for
1354 the derived classes which can't call GetNumberRows() without a
1355 @c const_cast from their const methods.
1357 int GetRowsCount() const;
1360 Return the number of columns in the table.
1362 This method is not virtual and is only provided as a convenience for
1363 the derived classes which can't call GetNumberCols() without a
1364 @c const_cast from their const methods.
1366 int GetColsCount() const;
1370 @name Table Cell Accessors
1375 May be overridden to implement testing for empty cells.
1377 This method is used by the grid to test if the given cell is not used
1378 and so whether a neighbouring cell may overflow into it. By default it
1379 only returns true if the value of the given cell, as returned by
1380 GetValue(), is empty.
1382 virtual bool IsEmptyCell(int row
, int col
);
1385 Same as IsEmptyCell() but taking wxGridCellCoords.
1387 Notice that this method is not virtual, only IsEmptyCell() should be
1390 bool IsEmpty(const wxGridCellCoords
& coords
);
1393 Must be overridden to implement accessing the table values as text.
1395 virtual wxString
GetValue(int row
, int col
) = 0;
1398 Must be overridden to implement setting the table values as text.
1400 virtual void SetValue(int row
, int col
, const wxString
& value
) = 0;
1403 Returns the type of the value in the given cell.
1405 By default all cells are strings and this method returns
1406 @c wxGRID_VALUE_STRING.
1408 virtual wxString
GetTypeName(int row
, int col
);
1411 Returns true if the value of the given cell can be accessed as if it
1412 were of the specified type.
1414 By default the cells can only be accessed as strings. Note that a cell
1415 could be accessible in different ways, e.g. a numeric cell may return
1416 @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
1417 indicating that the value can be coerced to a string form.
1419 virtual bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
1422 Returns true if the value of the given cell can be set as if it were of
1425 @see CanGetValueAs()
1427 virtual bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
1430 Returns the value of the given cell as a long.
1432 This should only be called if CanGetValueAs() returns @true when called
1433 with @c wxGRID_VALUE_NUMBER argument. Default implementation always
1436 virtual long GetValueAsLong(int row
, int col
);
1439 Returns the value of the given cell as a double.
1441 This should only be called if CanGetValueAs() returns @true when called
1442 with @c wxGRID_VALUE_FLOAT argument. Default implementation always
1445 virtual double GetValueAsDouble(int row
, int col
);
1448 Returns the value of the given cell as a boolean.
1450 This should only be called if CanGetValueAs() returns @true when called
1451 with @c wxGRID_VALUE_BOOL argument. Default implementation always
1454 virtual bool GetValueAsBool(int row
, int col
);
1457 Returns the value of the given cell as a user-defined type.
1459 This should only be called if CanGetValueAs() returns @true when called
1460 with @a typeName. Default implementation always return @NULL.
1462 virtual void *GetValueAsCustom(int row
, int col
, const wxString
& typeName
);
1465 Sets the value of the given cell as a long.
1467 This should only be called if CanSetValueAs() returns @true when called
1468 with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
1471 virtual void SetValueAsLong(int row
, int col
, long value
);
1474 Sets the value of the given cell as a double.
1476 This should only be called if CanSetValueAs() returns @true when called
1477 with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
1480 virtual void SetValueAsDouble(int row
, int col
, double value
);
1483 Sets the value of the given cell as a boolean.
1485 This should only be called if CanSetValueAs() returns @true when called
1486 with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
1489 virtual void SetValueAsBool( int row
, int col
, bool value
);
1492 Sets the value of the given cell as a user-defined type.
1494 This should only be called if CanSetValueAs() returns @true when called
1495 with @a typeName. Default implementation doesn't do anything.
1497 virtual void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
1504 Called by the grid when the table is associated with it.
1506 The default implementation stores the pointer and returns it from its
1507 GetView() and so only makes sense if the table cannot be associated
1508 with more than one grid at a time.
1510 virtual void SetView(wxGrid
*grid
);
1513 Returns the last grid passed to SetView().
1515 virtual wxGrid
*GetView() const;
1519 @name Table Structure Modifiers
1521 Notice that none of these functions are pure virtual as they don't have
1522 to be implemented if the table structure is never modified after
1523 creation, i.e. neither rows nor columns are never added or deleted but
1524 that you do need to implement them if they are called, i.e. if your
1525 code either calls them directly or uses the matching wxGrid methods, as
1526 by default they simply do nothing which is definitely inappropriate.
1531 Clear the table contents.
1533 This method is used by wxGrid::ClearGrid().
1535 virtual void Clear();
1538 Insert additional rows into the table.
1541 The position of the first new row.
1543 The number of rows to insert.
1545 virtual bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
1548 Append additional rows at the end of the table.
1550 This method is provided in addition to InsertRows() as some data models
1551 may only support appending rows to them but not inserting them at
1552 arbitrary locations. In such case you may implement this method only
1553 and leave InsertRows() unimplemented.
1556 The number of rows to add.
1558 virtual bool AppendRows(size_t numRows
= 1);
1561 Delete rows from the table.
1563 Notice that currently deleting a row intersecting a multi-cell (see
1564 SetCellSize()) is not supported and will result in a crash.
1567 The first row to delete.
1569 The number of rows to delete.
1571 virtual bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
1574 Exactly the same as InsertRows() but for columns.
1576 virtual bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
1579 Exactly the same as AppendRows() but for columns.
1581 virtual bool AppendCols(size_t numCols
= 1);
1584 Exactly the same as DeleteRows() but for columns.
1586 virtual bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
1591 @name Table Row and Column Labels
1593 By default the numbers are used for labeling rows and Latin letters for
1594 labeling columns. If the table has more than 26 columns, the pairs of
1595 letters are used starting from the 27-th one and so on, i.e. the
1596 sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
1602 Return the label of the specified row.
1604 virtual wxString
GetRowLabelValue(int row
);
1607 Return the label of the specified column.
1609 virtual wxString
GetColLabelValue(int col
);
1612 Set the given label for the specified row.
1614 The default version does nothing, i.e. the label is not stored. You
1615 must override this method in your derived class if you wish
1616 wxGrid::SetRowLabelValue() to work.
1618 virtual void SetRowLabelValue(int row
, const wxString
& label
);
1621 Exactly the same as SetRowLabelValue() but for columns.
1623 virtual void SetColLabelValue(int col
, const wxString
& label
);
1629 @name Attributes Management
1631 By default the attributes management is delegated to
1632 wxGridCellAttrProvider class. You may override the methods in this
1633 section to handle the attributes directly if, for example, they can be
1634 computed from the cell values.
1639 Associate this attributes provider with the table.
1641 The table takes ownership of @a attrProvider pointer and will delete it
1642 when it doesn't need it any more. The pointer can be @NULL, however
1643 this won't disable attributes management in the table but will just
1644 result in a default attributes being recreated the next time any of the
1645 other functions in this section is called. To completely disable the
1646 attributes support, should this be needed, you need to override
1647 CanHaveAttributes() to return @false.
1649 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
1652 Returns the attribute provider currently being used.
1654 This function may return @NULL if the attribute provider hasn't been
1655 neither associated with this table by SetAttrProvider() nor created on
1656 demand by any other methods.
1658 wxGridCellAttrProvider
*GetAttrProvider() const;
1661 Return the attribute for the given cell.
1663 By default this function is simply forwarded to
1664 wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
1665 attributes directly in the table.
1667 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
1668 wxGridCellAttr::wxAttrKind kind
);
1671 Set attribute of the specified cell.
1673 By default this function is simply forwarded to
1674 wxGridCellAttrProvider::SetAttr().
1676 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1678 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
1681 Set attribute of the specified row.
1683 By default this function is simply forwarded to
1684 wxGridCellAttrProvider::SetRowAttr().
1686 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1688 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
1691 Set attribute of the specified column.
1693 By default this function is simply forwarded to
1694 wxGridCellAttrProvider::SetColAttr().
1696 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1698 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
1703 Returns true if this table supports attributes or false otherwise.
1705 By default, the table automatically creates a wxGridCellAttrProvider
1706 when this function is called if it had no attribute provider before and
1709 virtual bool CanHaveAttributes();
1714 enum wxGridTableRequest
1716 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
1717 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
1718 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
1719 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
1720 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
1721 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
1722 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
1723 wxGRIDTABLE_NOTIFY_COLS_DELETED
1728 @class wxGridTableMessage
1730 A simple class used to pass messages from the table to the grid.
1735 class wxGridTableMessage
1738 wxGridTableMessage();
1739 wxGridTableMessage( wxGridTableBase
*table
, int id
,
1743 void SetTableObject( wxGridTableBase
*table
);
1744 wxGridTableBase
* GetTableObject() const;
1745 void SetId( int id
);
1747 void SetCommandInt( int comInt1
);
1748 int GetCommandInt();
1749 void SetCommandInt2( int comInt2
);
1750 int GetCommandInt2();
1756 @class wxGridStringTable
1758 Simplest type of data table for a grid for small tables of strings
1759 that are stored in memory
1761 class wxGridStringTable
: public wxGridTableBase
1764 wxGridStringTable();
1765 wxGridStringTable( int numRows
, int numCols
);
1767 // these are pure virtual in wxGridTableBase
1768 virtual int GetNumberRows();
1769 virtual int GetNumberCols();
1770 virtual wxString
GetValue( int row
, int col
);
1771 virtual void SetValue( int row
, int col
, const wxString
& value
);
1773 // overridden functions from wxGridTableBase
1775 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
1776 bool AppendRows( size_t numRows
= 1 );
1777 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
1778 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
1779 bool AppendCols( size_t numCols
= 1 );
1780 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
1782 void SetRowLabelValue( int row
, const wxString
& );
1783 void SetColLabelValue( int col
, const wxString
& );
1784 wxString
GetRowLabelValue( int row
);
1785 wxString
GetColLabelValue( int col
);
1794 @class wxGridSizesInfo
1796 wxGridSizesInfo stores information about sizes of all wxGrid rows or
1799 It assumes that most of the rows or columns (which are both called elements
1800 here as the difference between them doesn't matter at this class level)
1801 have the default size and so stores it separately. And it uses a wxHashMap
1802 to store the sizes of all elements which have the non-default size.
1804 This structure is particularly useful for serializing the sizes of all
1805 wxGrid elements at once.
1810 struct wxGridSizesInfo
1813 Default constructor.
1815 m_sizeDefault and m_customSizes must be initialized later.
1822 This constructor is used by wxGrid::GetRowSizes() and GetColSizes()
1823 methods. User code will usually use the default constructor instead.
1826 The default element size.
1828 Array containing the sizes of @em all elements, including those
1829 which have the default size.
1831 wxGridSizesInfo(int defSize
, const wxArrayInt
& allSizes
);
1834 Get the element size.
1837 The index of the element.
1839 The size for this element, using m_customSizes if @a pos is in it
1840 or m_sizeDefault otherwise.
1842 int GetSize(unsigned pos
) const;
1849 Map with element indices as keys and their sizes as values.
1851 This map only contains the elements with non-default size.
1853 wxUnsignedToIntHashMap m_customSizes
;
1859 Rendering styles supported by wxGrid::Render() method.
1863 enum wxGridRenderStyle
1865 /// Draw grid row header labels.
1866 wxGRID_DRAW_ROWS_HEADER
= 0x001,
1868 /// Draw grid column header labels.
1869 wxGRID_DRAW_COLS_HEADER
= 0x002,
1871 /// Draw grid cell border lines.
1872 wxGRID_DRAW_CELL_LINES
= 0x004,
1875 Draw a bounding rectangle around the rendered cell area.
1877 Useful where row or column headers are not drawn or where there is
1878 multi row or column cell clipping and therefore no cell border at
1879 the rendered outer boundary.
1881 wxGRID_DRAW_BOX_RECT
= 0x008,
1884 Draw the grid cell selection highlight if a selection is present.
1886 At present the highlight colour drawn depends on whether the grid
1887 window loses focus before drawing begins.
1889 wxGRID_DRAW_SELECTION
= 0x010,
1892 The default render style.
1894 Includes all except wxGRID_DRAW_SELECTION.
1896 wxGRID_DRAW_DEFAULT
= wxGRID_DRAW_ROWS_HEADER
|
1897 wxGRID_DRAW_COLS_HEADER
|
1898 wxGRID_DRAW_CELL_LINES
|
1899 wxGRID_DRAW_BOX_RECT
1907 wxGrid and its related classes are used for displaying and editing tabular
1908 data. They provide a rich set of features for display, editing, and
1909 interacting with a variety of data sources. For simple applications, and to
1910 help you get started, wxGrid is the only class you need to refer to
1911 directly. It will set up default instances of the other classes and manage
1912 them for you. For more complex applications you can derive your own classes
1913 for custom grid views, grid data tables, cell editors and renderers. The
1914 @ref overview_grid has examples of simple and more complex applications,
1915 explains the relationship between the various grid classes and has a
1916 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1918 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1919 class. One or more wxGrid classes may act as a view for one table class.
1920 The default table class is called wxGridStringTable and holds an array of
1921 strings. An instance of such a class is created by CreateGrid().
1923 wxGridCellRenderer is the abstract base class for rendering contents in a
1924 cell. The following renderers are predefined:
1926 - wxGridCellBoolRenderer
1927 - wxGridCellFloatRenderer
1928 - wxGridCellNumberRenderer
1929 - wxGridCellStringRenderer
1931 The look of a cell can be further defined using wxGridCellAttr. An object
1932 of this type may be returned by wxGridTableBase::GetAttr().
1934 wxGridCellEditor is the abstract base class for editing the value of a
1935 cell. The following editors are predefined:
1937 - wxGridCellBoolEditor
1938 - wxGridCellChoiceEditor
1939 - wxGridCellFloatEditor
1940 - wxGridCellNumberEditor
1941 - wxGridCellTextEditor
1943 Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and
1944 wxGridEditorCreatedEvent for the documentation of all event types you can
1950 @see @ref overview_grid, wxGridUpdateLocker
1952 class wxGrid
: public wxScrolledWindow
1957 Different selection modes supported by the grid.
1959 enum wxGridSelectionModes
1962 The default selection mode allowing selection of the individual
1963 cells as well as of the entire rows and columns.
1968 The selection mode allowing the selection of the entire rows only.
1970 The user won't be able to select any cells or columns in this mode.
1975 The selection mode allowing the selection of the entire columns only.
1977 The user won't be able to select any cells or rows in this mode.
1979 wxGridSelectColumns
,
1982 The selection mode allowing the user to select either the entire
1983 columns or the entire rows but not individual cells nor blocks.
1985 Notice that while this constant is defined as @code
1986 wxGridSelectColumns | wxGridSelectRows @endcode this doesn't mean
1987 that all the other combinations are valid -- at least currently
1992 wxGridSelectRowsOrColumns
1996 Return values for GetCellSize().
2002 /// This cell is inside a span covered by another cell.
2003 CellSpan_Inside
= -1,
2005 /// This is a normal, non-spanning cell.
2008 /// This cell spans several physical wxGrid cells.
2013 Constants defining different support built-in TAB handling behaviours.
2015 The elements of this enum determine what happens when TAB is pressed
2016 when the cursor is in the rightmost column (or Shift-TAB is pressed
2017 when the cursor is in the leftmost one).
2019 @see SetTabBehaviour(), @c wxEVT_GRID_TABBING
2025 /// Do nothing, this is default.
2028 /// Move to the beginning of the next (or the end of the previous) row.
2031 /// Move to the next (or the previous) control after the grid.
2036 @name Constructors and Initialization
2041 Default constructor.
2043 You must call Create() to really create the grid window and also call
2044 CreateGrid() or SetTable() to initialize the grid contents.
2048 Constructor creating the grid window.
2050 You must call either CreateGrid() or SetTable() to initialize the grid
2051 contents before using it.
2053 wxGrid(wxWindow
* parent
, wxWindowID id
,
2054 const wxPoint
& pos
= wxDefaultPosition
,
2055 const wxSize
& size
= wxDefaultSize
,
2056 long style
= wxWANTS_CHARS
,
2057 const wxString
& name
= wxGridNameStr
);
2062 This will also destroy the associated grid table unless you passed a
2063 table object to the grid and specified that the grid should not take
2064 ownership of the table (see SetTable()).
2069 Creates the grid window for an object initialized using the default
2072 You must call either CreateGrid() or SetTable() to initialize the grid
2073 contents before using it.
2075 bool Create(wxWindow
* parent
, wxWindowID id
,
2076 const wxPoint
& pos
= wxDefaultPosition
,
2077 const wxSize
& size
= wxDefaultSize
,
2078 long style
= wxWANTS_CHARS
,
2079 const wxString
& name
= wxGridNameStr
);
2082 Creates a grid with the specified initial number of rows and columns.
2084 Call this directly after the grid constructor. When you use this
2085 function wxGrid will create and manage a simple table of string values
2086 for you. All of the grid data will be stored in memory.
2088 For applications with more complex data types or relationships, or for
2089 dealing with very large datasets, you should derive your own grid table
2090 class and pass a table object to the grid with SetTable().
2092 bool CreateGrid(int numRows
, int numCols
,
2093 wxGridSelectionModes selmode
= wxGridSelectCells
);
2096 Passes a pointer to a custom grid table to be used by the grid.
2098 This should be called after the grid constructor and before using the
2099 grid object. If @a takeOwnership is set to @true then the table will be
2100 deleted by the wxGrid destructor.
2102 Use this function instead of CreateGrid() when your application
2103 involves complex or non-string data or data sets that are too large to
2104 fit wholly in memory.
2106 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= false,
2107 wxGridSelectionModes selmode
= wxGridSelectCells
);
2110 Receive and handle a message from the table.
2112 bool ProcessTableMessage(wxGridTableMessage
& msg
);
2118 @name Grid Line Formatting
2123 Turns the drawing of grid lines on or off.
2125 void EnableGridLines(bool enable
= true);
2128 Returns the pen used for vertical grid lines.
2130 This virtual function may be overridden in derived classes in order to
2131 change the appearance of individual grid lines for the given column
2134 See GetRowGridLinePen() for an example.
2136 virtual wxPen
GetColGridLinePen(int col
);
2139 Returns the pen used for grid lines.
2141 This virtual function may be overridden in derived classes in order to
2142 change the appearance of grid lines. Note that currently the pen width
2145 @see GetColGridLinePen(), GetRowGridLinePen()
2147 virtual wxPen
GetDefaultGridLinePen();
2150 Returns the colour used for grid lines.
2152 @see GetDefaultGridLinePen()
2154 wxColour
GetGridLineColour() const;
2157 Returns the pen used for horizontal grid lines.
2159 This virtual function may be overridden in derived classes in order to
2160 change the appearance of individual grid line for the given @a row.
2164 // in a grid displaying music notation, use a solid black pen between
2165 // octaves (C0=row 127, C1=row 115 etc.)
2166 wxPen MidiGrid::GetRowGridLinePen(int row)
2168 if ( row % 12 == 7 )
2169 return wxPen(*wxBLACK, 1, wxSOLID);
2171 return GetDefaultGridLinePen();
2175 virtual wxPen
GetRowGridLinePen(int row
);
2178 Returns @true if drawing of grid lines is turned on, @false otherwise.
2180 bool GridLinesEnabled() const;
2183 Sets the colour used to draw grid lines.
2185 void SetGridLineColour(const wxColour
& colour
);
2191 @name Label Values and Formatting
2196 Sets the arguments to the current column label alignment values.
2198 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2199 or @c wxALIGN_RIGHT.
2201 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2204 void GetColLabelAlignment(int* horiz
, int* vert
) const;
2207 Returns the orientation of the column labels (either @c wxHORIZONTAL or
2210 int GetColLabelTextOrientation() const;
2213 Returns the specified column label.
2215 The default grid table class provides column labels of the form
2216 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
2217 override wxGridTableBase::GetColLabelValue() to provide your own
2220 wxString
GetColLabelValue(int col
) const;
2223 Returns the colour used for the background of row and column labels.
2225 wxColour
GetLabelBackgroundColour() const;
2228 Returns the font used for row and column labels.
2230 wxFont
GetLabelFont() const;
2233 Returns the colour used for row and column label text.
2235 wxColour
GetLabelTextColour() const;
2238 Returns the alignment used for row labels.
2240 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2241 or @c wxALIGN_RIGHT.
2243 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2246 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
2249 Returns the specified row label.
2251 The default grid table class provides numeric row labels. If you are
2252 using a custom grid table you can override
2253 wxGridTableBase::GetRowLabelValue() to provide your own labels.
2255 wxString
GetRowLabelValue(int row
) const;
2258 Hides the column labels by calling SetColLabelSize() with a size of 0.
2259 Show labels again by calling that method with a width greater than 0.
2261 void HideColLabels();
2264 Hides the row labels by calling SetRowLabelSize() with a size of 0.
2266 The labels can be shown again by calling SetRowLabelSize() with a width
2269 void HideRowLabels();
2272 Sets the horizontal and vertical alignment of column label text.
2274 Horizontal alignment should be one of @c wxALIGN_LEFT,
2275 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2276 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2278 void SetColLabelAlignment(int horiz
, int vert
);
2281 Sets the orientation of the column labels (either @c wxHORIZONTAL or
2284 void SetColLabelTextOrientation(int textOrientation
);
2287 Set the value for the given column label.
2289 If you are using a custom grid table you must override
2290 wxGridTableBase::SetColLabelValue() for this to have any effect.
2292 void SetColLabelValue(int col
, const wxString
& value
);
2295 Sets the background colour for row and column labels.
2297 void SetLabelBackgroundColour(const wxColour
& colour
);
2300 Sets the font for row and column labels.
2302 void SetLabelFont(const wxFont
& font
);
2305 Sets the colour for row and column label text.
2307 void SetLabelTextColour(const wxColour
& colour
);
2310 Sets the horizontal and vertical alignment of row label text.
2312 Horizontal alignment should be one of @c wxALIGN_LEFT,
2313 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2314 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2316 void SetRowLabelAlignment(int horiz
, int vert
);
2319 Sets the value for the given row label.
2321 If you are using a derived grid table you must override
2322 wxGridTableBase::SetRowLabelValue() for this to have any effect.
2324 void SetRowLabelValue(int row
, const wxString
& value
);
2327 Call this in order to make the column labels use a native look by using
2328 wxRendererNative::DrawHeaderButton() internally.
2330 There is no equivalent method for drawing row columns as there is not
2331 native look for that. This option is useful when using wxGrid for
2332 displaying tables and not as a spread-sheet.
2334 @see UseNativeColHeader()
2336 void SetUseNativeColLabels(bool native
= true);
2339 Enable the use of native header window for column labels.
2341 If this function is called with @true argument, a wxHeaderCtrl is used
2342 instead to display the column labels instead of drawing them in wxGrid
2343 code itself. This has the advantage of making the grid look and feel
2344 perfectly the same as native applications (using SetUseNativeColLabels()
2345 the grid can be made to look more natively but it still doesn't feel
2346 natively, notably the column resizing and dragging still works slightly
2347 differently as it is implemented in wxWidgets itself) but results in
2348 different behaviour for column and row headers, for which there is no
2349 equivalent function, and, most importantly, is unsuitable for grids
2350 with huge numbers of columns as wxHeaderCtrl doesn't support virtual
2351 mode. Because of this, by default the grid does not use the native
2352 header control but you should call this function to enable it if you
2353 are using the grid to display tabular data and don't have thousands of
2356 Another difference between the default behaviour and the native header
2357 behaviour is that the latter provides the user with a context menu
2358 (which appears on right clicking the header) allowing to rearrange the
2359 grid columns if CanDragColMove() returns @true. If you want to prevent
2360 this from happening for some reason, you need to define a handler for
2361 @c wxEVT_GRID_LABEL_RIGHT_CLICK event which simply does nothing (in
2362 particular doesn't skip the event) as this will prevent the default
2363 right click handling from working.
2365 Also note that currently @c wxEVT_GRID_LABEL_RIGHT_DCLICK event is not
2366 generated for the column labels if the native columns header is used
2367 (but this limitation could possibly be lifted in the future).
2369 void UseNativeColHeader(bool native
= true);
2375 @name Cell Formatting
2377 Note that wxGridCellAttr can be used alternatively to most of these
2378 methods. See the "Attributes Management" of wxGridTableBase.
2383 Sets the arguments to the horizontal and vertical text alignment values
2384 for the grid cell at the specified location.
2386 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2387 or @c wxALIGN_RIGHT.
2389 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2392 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
2395 Returns the background colour of the cell at the specified location.
2397 wxColour
GetCellBackgroundColour(int row
, int col
) const;
2400 Returns the font for text in the grid cell at the specified location.
2402 wxFont
GetCellFont(int row
, int col
) const;
2405 Returns the text colour for the grid cell at the specified location.
2407 wxColour
GetCellTextColour(int row
, int col
) const;
2410 Returns the default cell alignment.
2412 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2413 or @c wxALIGN_RIGHT.
2415 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2418 @see SetDefaultCellAlignment()
2420 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
2423 Returns the current default background colour for grid cells.
2425 wxColour
GetDefaultCellBackgroundColour() const;
2428 Returns the current default font for grid cell text.
2430 wxFont
GetDefaultCellFont() const;
2433 Returns the current default colour for grid cell text.
2435 wxColour
GetDefaultCellTextColour() const;
2438 Sets the horizontal and vertical alignment for grid cell text at the
2441 Horizontal alignment should be one of @c wxALIGN_LEFT,
2442 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2444 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2445 or @c wxALIGN_BOTTOM.
2447 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2449 Sets the horizontal and vertical alignment for grid cell text at the
2452 Horizontal alignment should be one of @c wxALIGN_LEFT,
2453 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2455 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2456 or @c wxALIGN_BOTTOM.
2458 void SetCellAlignment(int align
, int row
, int col
);
2461 Set the background colour for the given cell or all cells by default.
2463 void SetCellBackgroundColour(int row
, int col
, const wxColour
& colour
);
2466 Sets the font for text in the grid cell at the specified location.
2468 void SetCellFont(int row
, int col
, const wxFont
& font
);
2471 Sets the text colour for the given cell.
2473 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2475 Sets the text colour for the given cell.
2477 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2479 Sets the text colour for all cells by default.
2481 void SetCellTextColour(const wxColour
& colour
);
2484 Sets the default horizontal and vertical alignment for grid cell text.
2486 Horizontal alignment should be one of @c wxALIGN_LEFT,
2487 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2488 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2490 void SetDefaultCellAlignment(int horiz
, int vert
);
2493 Sets the default background colour for grid cells.
2495 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2498 Sets the default font to be used for grid cell text.
2500 void SetDefaultCellFont(const wxFont
& font
);
2503 Sets the current default colour for grid cell text.
2505 void SetDefaultCellTextColour(const wxColour
& colour
);
2511 @name Cell Values, Editors, and Renderers
2513 Note that wxGridCellAttr can be used alternatively to most of these
2514 methods. See the "Attributes Management" of wxGridTableBase.
2519 Returns @true if the in-place edit control for the current grid cell
2520 can be used and @false otherwise.
2522 This function always returns @false for the read-only cells.
2524 bool CanEnableCellControl() const;
2527 Disables in-place editing of grid cells.
2529 Equivalent to calling EnableCellEditControl(@false).
2531 void DisableCellEditControl();
2534 Enables or disables in-place editing of grid cell data.
2536 The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or
2537 @c wxEVT_GRID_EDITOR_HIDDEN event.
2539 void EnableCellEditControl(bool enable
= true);
2542 Makes the grid globally editable or read-only.
2544 If the edit argument is @false this function sets the whole grid as
2545 read-only. If the argument is @true the grid is set to the default
2546 state where cells may be editable. In the default state you can set
2547 single grid cells and whole rows and columns to be editable or
2548 read-only via wxGridCellAttr::SetReadOnly(). For single cells you
2549 can also use the shortcut function SetReadOnly().
2551 For more information about controlling grid cell attributes see the
2552 wxGridCellAttr class and the @ref overview_grid.
2554 void EnableEditing(bool edit
);
2557 Returns a pointer to the editor for the cell at the specified location.
2559 See wxGridCellEditor and the @ref overview_grid for more information
2560 about cell editors and renderers.
2562 The caller must call DecRef() on the returned pointer.
2564 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
2567 Returns a pointer to the renderer for the grid cell at the specified
2570 See wxGridCellRenderer and the @ref overview_grid for more information
2571 about cell editors and renderers.
2573 The caller must call DecRef() on the returned pointer.
2575 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
2578 Returns the string contained in the cell at the specified location.
2580 For simple applications where a grid object automatically uses a
2581 default grid table of string values you use this function together with
2582 SetCellValue() to access cell values. For more complex applications
2583 where you have derived your own grid table class that contains various
2584 data types (e.g. numeric, boolean or user-defined custom types) then
2585 you only use this function for those cells that contain string values.
2587 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
2590 wxString
GetCellValue(int row
, int col
) const;
2592 Returns the string contained in the cell at the specified location.
2594 For simple applications where a grid object automatically uses a
2595 default grid table of string values you use this function together with
2596 SetCellValue() to access cell values. For more complex applications
2597 where you have derived your own grid table class that contains various
2598 data types (e.g. numeric, boolean or user-defined custom types) then
2599 you only use this function for those cells that contain string values.
2601 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
2604 wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
2607 Returns a pointer to the current default grid cell editor.
2609 See wxGridCellEditor and the @ref overview_grid for more information
2610 about cell editors and renderers.
2612 wxGridCellEditor
* GetDefaultEditor() const;
2615 Returns the default editor for the specified cell.
2617 The base class version returns the editor appropriate for the current
2618 cell type but this method may be overridden in the derived classes to
2619 use custom editors for some cells by default.
2621 Notice that the same may be achieved in a usually simpler way by
2622 associating a custom editor with the given cell or cells.
2624 The caller must call DecRef() on the returned pointer.
2626 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
2628 Returns the default editor for the specified cell.
2630 The base class version returns the editor appropriate for the current
2631 cell type but this method may be overridden in the derived classes to
2632 use custom editors for some cells by default.
2634 Notice that the same may be achieved in a usually simpler way by
2635 associating a custom editor with the given cell or cells.
2637 The caller must call DecRef() on the returned pointer.
2639 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
2642 Returns the default editor for the cells containing values of the given
2645 The base class version returns the editor which was associated with the
2646 specified @a typeName when it was registered RegisterDataType() but
2647 this function may be overridden to return something different. This
2648 allows to override an editor used for one of the standard types.
2650 The caller must call DecRef() on the returned pointer.
2652 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
2655 Returns a pointer to the current default grid cell renderer.
2657 See wxGridCellRenderer and the @ref overview_grid for more information
2658 about cell editors and renderers.
2660 The caller must call DecRef() on the returned pointer.
2662 wxGridCellRenderer
* GetDefaultRenderer() const;
2665 Returns the default renderer for the given cell.
2667 The base class version returns the renderer appropriate for the current
2668 cell type but this method may be overridden in the derived classes to
2669 use custom renderers for some cells by default.
2671 The caller must call DecRef() on the returned pointer.
2673 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
2676 Returns the default renderer for the cell containing values of the
2679 @see GetDefaultEditorForType()
2681 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
2684 Hides the in-place cell edit control.
2686 void HideCellEditControl();
2689 Returns @true if the in-place edit control is currently enabled.
2691 bool IsCellEditControlEnabled() const;
2694 Returns @true if the current cell is read-only.
2696 @see SetReadOnly(), IsReadOnly()
2698 bool IsCurrentCellReadOnly() const;
2701 Returns @false if the whole grid has been set as read-only or @true
2704 See EnableEditing() for more information about controlling the editing
2705 status of grid cells.
2707 bool IsEditable() const;
2710 Returns @true if the cell at the specified location can't be edited.
2712 @see SetReadOnly(), IsCurrentCellReadOnly()
2714 bool IsReadOnly(int row
, int col
) const;
2717 Register a new data type.
2719 The data types allow to naturally associate specific renderers and
2720 editors to the cells containing values of the given type. For example,
2721 the grid automatically registers a data type with the name
2722 @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
2723 wxGridCellTextEditor as its renderer and editor respectively -- this is
2724 the data type used by all the cells of the default wxGridStringTable,
2725 so this renderer and editor are used by default for all grid cells.
2727 However if a custom table returns @c wxGRID_VALUE_BOOL from its
2728 wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
2729 wxGridCellBoolEditor are used for it because the grid also registers a
2730 boolean data type with this name.
2732 And as this mechanism is completely generic, you may register your own
2733 data types using your own custom renderers and editors. Just remember
2734 that the table must identify a cell as being of the given type for them
2735 to be used for this cell.
2738 Name of the new type. May be any string, but if the type name is
2739 the same as the name of an already registered type, including one
2740 of the standard ones (which are @c wxGRID_VALUE_STRING, @c
2741 wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT
2742 and @c wxGRID_VALUE_CHOICE), then the new registration information
2743 replaces the previously used renderer and editor.
2745 The renderer to use for the cells of this type. Its ownership is
2746 taken by the grid, i.e. it will call DecRef() on this pointer when
2747 it doesn't need it any longer.
2749 The editor to use for the cells of this type. Its ownership is also
2752 void RegisterDataType(const wxString
& typeName
,
2753 wxGridCellRenderer
* renderer
,
2754 wxGridCellEditor
* editor
);
2757 Sets the value of the current grid cell to the current in-place edit
2760 This is called automatically when the grid cursor moves from the
2761 current cell to a new cell. It is also a good idea to call this
2762 function when closing a grid since any edits to the final cell location
2763 will not be saved otherwise.
2765 void SaveEditControlValue();
2768 Sets the editor for the grid cell at the specified location.
2770 The grid will take ownership of the pointer.
2772 See wxGridCellEditor and the @ref overview_grid for more information
2773 about cell editors and renderers.
2775 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2778 Sets the renderer for the grid cell at the specified location.
2780 The grid will take ownership of the pointer.
2782 See wxGridCellRenderer and the @ref overview_grid for more information
2783 about cell editors and renderers.
2785 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
* renderer
);
2788 Sets the string value for the cell at the specified location.
2790 For simple applications where a grid object automatically uses a
2791 default grid table of string values you use this function together with
2792 GetCellValue() to access cell values. For more complex applications
2793 where you have derived your own grid table class that contains various
2794 data types (e.g. numeric, boolean or user-defined custom types) then
2795 you only use this function for those cells that contain string values.
2797 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2800 void SetCellValue(int row
, int col
, const wxString
& s
);
2802 Sets the string value for the cell at the specified location.
2804 For simple applications where a grid object automatically uses a
2805 default grid table of string values you use this function together with
2806 GetCellValue() to access cell values. For more complex applications
2807 where you have derived your own grid table class that contains various
2808 data types (e.g. numeric, boolean or user-defined custom types) then
2809 you only use this function for those cells that contain string values.
2811 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2814 void SetCellValue(const wxGridCellCoords
& coords
, const wxString
& s
);
2816 @deprecated Please use SetCellValue(int,int,const wxString&) or
2817 SetCellValue(const wxGridCellCoords&,const wxString&)
2820 Sets the string value for the cell at the specified location.
2822 For simple applications where a grid object automatically uses a
2823 default grid table of string values you use this function together with
2824 GetCellValue() to access cell values. For more complex applications
2825 where you have derived your own grid table class that contains various
2826 data types (e.g. numeric, boolean or user-defined custom types) then
2827 you only use this function for those cells that contain string values.
2829 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2832 void SetCellValue(const wxString
& val
, int row
, int col
);
2835 Sets the specified column to display boolean values.
2837 @see SetColFormatCustom()
2839 void SetColFormatBool(int col
);
2842 Sets the specified column to display data in a custom format.
2844 This method provides an alternative to defining a custom grid table
2845 which would return @a typeName from its GetTypeName() method for the
2846 cells in this column: while it doesn't really change the type of the
2847 cells in this column, it does associate the renderer and editor used
2848 for the cells of the specified type with them.
2850 See the @ref overview_grid for more information on working with custom
2853 void SetColFormatCustom(int col
, const wxString
& typeName
);
2856 Sets the specified column to display floating point values with the
2857 given width and precision.
2859 @see SetColFormatCustom()
2861 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
2864 Sets the specified column to display integer values.
2866 @see SetColFormatCustom()
2868 void SetColFormatNumber(int col
);
2871 Sets the default editor for grid cells.
2873 The grid will take ownership of the pointer.
2875 See wxGridCellEditor and the @ref overview_grid for more information
2876 about cell editors and renderers.
2878 void SetDefaultEditor(wxGridCellEditor
* editor
);
2881 Sets the default renderer for grid cells.
2883 The grid will take ownership of the pointer.
2885 See wxGridCellRenderer and the @ref overview_grid for more information
2886 about cell editors and renderers.
2888 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2891 Makes the cell at the specified location read-only or editable.
2895 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2898 Displays the in-place cell edit control for the current cell.
2900 void ShowCellEditControl();
2906 @name Column and Row Sizes
2908 @see @ref overview_grid_resizing
2913 Automatically sets the height and width of all rows and columns to fit
2919 Automatically adjusts width of the column to fit its label.
2921 void AutoSizeColLabelSize(int col
);
2924 Automatically sizes the column to fit its contents. If @a setAsMin is
2925 @true the calculated width will also be set as the minimal width for
2928 void AutoSizeColumn(int col
, bool setAsMin
= true);
2931 Automatically sizes all columns to fit their contents. If @a setAsMin
2932 is @true the calculated widths will also be set as the minimal widths
2935 void AutoSizeColumns(bool setAsMin
= true);
2938 Automatically sizes the row to fit its contents. If @a setAsMin is
2939 @true the calculated height will also be set as the minimal height for
2942 void AutoSizeRow(int row
, bool setAsMin
= true);
2945 Automatically adjusts height of the row to fit its label.
2947 void AutoSizeRowLabelSize(int col
);
2950 Automatically sizes all rows to fit their contents. If @a setAsMin is
2951 @true the calculated heights will also be set as the minimal heights
2954 void AutoSizeRows(bool setAsMin
= true);
2957 Returns @true if the cell value can overflow.
2959 A cell can overflow if the next cell in the row is empty.
2961 bool GetCellOverflow(int row
, int col
) const;
2964 Returns the current height of the column labels.
2966 int GetColLabelSize() const;
2969 Returns the minimal width to which a column may be resized.
2971 Use SetColMinimalAcceptableWidth() to change this value globally or
2972 SetColMinimalWidth() to do it for individual columns.
2974 @see GetRowMinimalAcceptableHeight()
2976 int GetColMinimalAcceptableWidth() const;
2979 Returns the width of the specified column.
2981 int GetColSize(int col
) const;
2984 Returns @true if the specified column is not currently hidden.
2986 bool IsColShown(int col
) const;
2989 Returns @true if the cells can overflow by default.
2991 bool GetDefaultCellOverflow() const;
2994 Returns the default height for column labels.
2996 int GetDefaultColLabelSize() const;
2999 Returns the current default width for grid columns.
3001 int GetDefaultColSize() const;
3004 Returns the default width for the row labels.
3006 int GetDefaultRowLabelSize() const;
3009 Returns the current default height for grid rows.
3011 int GetDefaultRowSize() const;
3014 Returns the minimal size to which rows can be resized.
3016 Use SetRowMinimalAcceptableHeight() to change this value globally or
3017 SetRowMinimalHeight() to do it for individual cells.
3019 @see GetColMinimalAcceptableWidth()
3021 int GetRowMinimalAcceptableHeight() const;
3024 Returns the current width of the row labels.
3026 int GetRowLabelSize() const;
3029 Returns the height of the specified row.
3031 int GetRowSize(int row
) const;
3034 Returns @true if the specified row is not currently hidden.
3036 bool IsRowShown(int row
) const;
3039 Sets the overflow permission of the cell.
3041 void SetCellOverflow(int row
, int col
, bool allow
);
3044 Sets the height of the column labels.
3046 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
3047 automatically so that no label is truncated. Note that this could be
3048 slow for a large table.
3050 void SetColLabelSize(int height
);
3053 Sets the minimal @a width to which the user can resize columns.
3055 @see GetColMinimalAcceptableWidth()
3057 void SetColMinimalAcceptableWidth(int width
);
3060 Sets the minimal @a width for the specified column @a col.
3062 It is usually best to call this method during grid creation as calling
3063 it later will not resize the column to the given minimal width even if
3064 it is currently narrower than it.
3066 @a width must be greater than the minimal acceptable column width as
3067 returned by GetColMinimalAcceptableWidth().
3069 void SetColMinimalWidth(int col
, int width
);
3072 Sets the width of the specified column.
3077 The new column width in pixels, 0 to hide the column or -1 to fit
3078 the column width to its label width.
3080 void SetColSize(int col
, int width
);
3083 Hides the specified column.
3085 To show the column later you need to call SetColSize() with non-0
3086 width or ShowCol() to restore the previous column width.
3088 If the column is already hidden, this method doesn't do anything.
3093 void HideCol(int col
);
3096 Shows the previously hidden column by resizing it to non-0 size.
3098 The column is shown again with the same width that it had before
3101 If the column is currently shown, this method doesn't do anything.
3103 @see HideCol(), SetColSize()
3105 void ShowCol(int col
);
3109 Sets the default overflow permission of the cells.
3111 void SetDefaultCellOverflow( bool allow
);
3114 Sets the default width for columns in the grid.
3116 This will only affect columns subsequently added to the grid unless
3117 @a resizeExistingCols is @true.
3119 If @a width is less than GetColMinimalAcceptableWidth(), then the
3120 minimal acceptable width is used instead of it.
3122 void SetDefaultColSize(int width
, bool resizeExistingCols
= false);
3125 Sets the default height for rows in the grid.
3127 This will only affect rows subsequently added to the grid unless
3128 @a resizeExistingRows is @true.
3130 If @a height is less than GetRowMinimalAcceptableHeight(), then the
3131 minimal acceptable height is used instead of it.
3133 void SetDefaultRowSize(int height
, bool resizeExistingRows
= false);
3136 Sets the width of the row labels.
3138 If @a width equals @c wxGRID_AUTOSIZE then width is calculated
3139 automatically so that no label is truncated. Note that this could be
3140 slow for a large table.
3142 void SetRowLabelSize(int width
);
3145 Sets the minimal row @a height used by default.
3147 See SetColMinimalAcceptableWidth() for more information.
3149 void SetRowMinimalAcceptableHeight(int height
);
3152 Sets the minimal @a height for the specified @a row.
3154 See SetColMinimalWidth() for more information.
3156 void SetRowMinimalHeight(int row
, int height
);
3159 Sets the height of the specified row.
3161 See SetColSize() for more information.
3163 void SetRowSize(int row
, int height
);
3166 Hides the specified row.
3168 To show the row later you need to call SetRowSize() with non-0
3169 width or ShowRow() to restore its original height.
3171 If the row is already hidden, this method doesn't do anything.
3176 void HideRow(int col
);
3179 Shows the previously hidden row.
3181 The row is shown again with the same height that it had before
3184 If the row is currently shown, this method doesn't do anything.
3186 @see HideRow(), SetRowSize()
3188 void ShowRow(int col
);
3191 Get size information for all columns at once.
3193 This method is useful when the information about all column widths
3194 needs to be saved. The widths can be later restored using
3197 @sa wxGridSizesInfo, GetRowSizes()
3199 wxGridSizesInfo
GetColSizes() const;
3202 Get size information for all row at once.
3204 @sa wxGridSizesInfo, GetColSizes()
3206 wxGridSizesInfo
GetRowSizes() const;
3209 Restore all columns sizes.
3211 This is usually called with wxGridSizesInfo object previously returned
3216 void SetColSizes(const wxGridSizesInfo
& sizeInfo
);
3219 Restore all rows sizes.
3223 void SetRowSizes(const wxGridSizesInfo
& sizeInfo
);
3226 Set the size of the cell.
3228 Specifying a value of more than 1 in @a num_rows or @a num_cols will
3229 make the cell at (@a row, @a col) span the block of the specified size,
3230 covering the other cells which would be normally shown in it. Passing 1
3231 for both arguments resets the cell to normal appearance.
3236 The row of the cell.
3238 The column of the cell.
3240 Number of rows to be occupied by this cell, must be >= 1.
3242 Number of columns to be occupied by this cell, must be >= 1.
3244 void SetCellSize(int row
, int col
, int num_rows
, int num_cols
);
3247 Get the size of the cell in number of cells covered by it.
3249 For normal cells, the function fills both @a num_rows and @a num_cols
3250 with 1 and returns CellSpan_None. For cells which span multiple cells, i.e.
3251 for which SetCellSize() had been called, the returned values are the
3252 same ones as were passed to SetCellSize() call and the function return
3253 value is CellSpan_Main.
3255 More unexpectedly, perhaps, the returned values may be @em negative for
3256 the cells which are inside a span covered by a cell occupying multiple
3257 rows or columns. They correspond to the offset of the main cell of the
3258 span from the cell passed to this functions and the function returns
3259 CellSpan_Inside value to indicate this.
3261 As an example, consider a 3*3 grid with the cell (1, 1) (the one in the
3262 middle) having a span of 2 rows and 2 columns, i.e. the grid looks like
3272 Then the function returns 2 and 2 in @a num_rows and @a num_cols for
3273 the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1
3274 and 0 for the cell (2, 1).
3277 The row of the cell.
3279 The column of the cell.
3281 Pointer to variable receiving the number of rows, must not be @NULL.
3283 Pointer to variable receiving the number of columns, must not be
3286 The kind of this cell span (the return value is new in wxWidgets
3287 2.9.1, this function was void in previous wxWidgets versions).
3289 CellSpan
GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
) const;
3292 Get the number of rows and columns allocated for this cell.
3294 This overload doesn't return a CellSpan value but the values returned
3295 may still be negative, see GetCellSize(int, int, int *, int *) for
3298 wxSize
GetCellSize(const wxGridCellCoords
& coords
);
3304 @name User-Resizing and Dragging
3306 Functions controlling various interactive mouse operations.
3308 By default, columns and rows can be resized by dragging the edges of
3309 their labels (this can be disabled using DisableDragColSize() and
3310 DisableDragRowSize() methods). And if grid line dragging is enabled with
3311 EnableDragGridSize() they can also be resized by dragging the right or
3312 bottom edge of the grid cells.
3314 Columns can also be moved to interactively change their order but this
3315 needs to be explicitly enabled with EnableDragColMove().
3320 Return @true if the dragging of cells is enabled or @false otherwise.
3322 bool CanDragCell() const;
3325 Returns @true if columns can be moved by dragging with the mouse.
3327 Columns can be moved by dragging on their labels.
3329 bool CanDragColMove() const;
3332 Returns @true if the given column can be resized by dragging with the
3335 This function returns @true if resizing the columns interactively is
3336 globally enabled, i.e. if DisableDragColSize() hadn't been called, and
3337 if this column wasn't explicitly marked as non-resizable with
3340 bool CanDragColSize(int col
) const;
3343 Return @true if the dragging of grid lines to resize rows and columns
3344 is enabled or @false otherwise.
3346 bool CanDragGridSize() const;
3349 Returns @true if the given row can be resized by dragging with the
3352 This is the same as CanDragColSize() but for rows.
3354 bool CanDragRowSize(int row
) const;
3357 Disable interactive resizing of the specified column.
3359 This method allows to disable resizing of an individual column in a
3360 grid where the columns are otherwise resizable (which is the case by
3363 Notice that currently there is no way to make some columns resizable in
3364 a grid where columns can't be resized by default as there doesn't seem
3365 to be any need for this in practice. There is also no way to make the
3366 column marked as fixed using this method resizable again because it is
3367 supposed that fixed columns are used for static parts of the grid and
3368 so should remain fixed during the entire grid lifetime.
3370 Also notice that disabling interactive column resizing will not prevent
3371 the program from changing the column size.
3373 @see EnableDragColSize()
3375 void DisableColResize(int col
);
3378 Disable interactive resizing of the specified row.
3380 This is the same as DisableColResize() but for rows.
3382 @see EnableDragRowSize()
3384 void DisableRowResize(int row
);
3387 Disables column moving by dragging with the mouse.
3389 Equivalent to passing @false to EnableDragColMove().
3391 void DisableDragColMove();
3394 Disables column sizing by dragging with the mouse.
3396 Equivalent to passing @false to EnableDragColSize().
3398 void DisableDragColSize();
3401 Disable mouse dragging of grid lines to resize rows and columns.
3403 Equivalent to passing @false to EnableDragGridSize()
3405 void DisableDragGridSize();
3408 Disables row sizing by dragging with the mouse.
3410 Equivalent to passing @false to EnableDragRowSize().
3412 void DisableDragRowSize();
3415 Enables or disables cell dragging with the mouse.
3417 void EnableDragCell(bool enable
= true);
3420 Enables or disables column moving by dragging with the mouse.
3422 void EnableDragColMove(bool enable
= true);
3425 Enables or disables column sizing by dragging with the mouse.
3427 @see DisableColResize()
3429 void EnableDragColSize(bool enable
= true);
3432 Enables or disables row and column resizing by dragging gridlines with
3435 void EnableDragGridSize(bool enable
= true);
3438 Enables or disables row sizing by dragging with the mouse.
3440 @see DisableRowResize()
3442 void EnableDragRowSize(bool enable
= true);
3445 Returns the column ID of the specified column position.
3447 int GetColAt(int colPos
) const;
3450 Returns the position of the specified column.
3452 int GetColPos(int colID
) const;
3455 Sets the position of the specified column.
3457 void SetColPos(int colID
, int newPos
);
3460 Sets the positions of all columns at once.
3462 This method takes an array containing the indices of the columns in
3463 their display order, i.e. uses the same convention as
3464 wxHeaderCtrl::SetColumnsOrder().
3466 void SetColumnsOrder(const wxArrayInt
& order
);
3469 Resets the position of the columns to the default.
3477 @name Cursor Movement
3482 Returns the current grid cell column position.
3484 int GetGridCursorCol() const;
3487 Returns the current grid cell row position.
3489 int GetGridCursorRow() const;
3492 Make the given cell current and ensure it is visible.
3494 This method is equivalent to calling MakeCellVisible() and
3495 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
3496 event is generated by it and the selected cell doesn't change if the
3499 void GoToCell(int row
, int col
);
3501 Make the given cell current and ensure it is visible.
3503 This method is equivalent to calling MakeCellVisible() and
3504 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
3505 event is generated by it and the selected cell doesn't change if the
3508 void GoToCell(const wxGridCellCoords
& coords
);
3511 Moves the grid cursor down by one row.
3513 If a block of cells was previously selected it will expand if the
3514 argument is @true or be cleared if the argument is @false.
3516 bool MoveCursorDown(bool expandSelection
);
3519 Moves the grid cursor down in the current column such that it skips to
3520 the beginning or end of a block of non-empty cells.
3522 If a block of cells was previously selected it will expand if the
3523 argument is @true or be cleared if the argument is @false.
3525 bool MoveCursorDownBlock(bool expandSelection
);
3528 Moves the grid cursor left by one column.
3530 If a block of cells was previously selected it will expand if the
3531 argument is @true or be cleared if the argument is @false.
3533 bool MoveCursorLeft(bool expandSelection
);
3536 Moves the grid cursor left in the current row such that it skips to the
3537 beginning or end of a block of non-empty cells.
3539 If a block of cells was previously selected it will expand if the
3540 argument is @true or be cleared if the argument is @false.
3542 bool MoveCursorLeftBlock(bool expandSelection
);
3545 Moves the grid cursor right by one column.
3547 If a block of cells was previously selected it will expand if the
3548 argument is @true or be cleared if the argument is @false.
3550 bool MoveCursorRight(bool expandSelection
);
3553 Moves the grid cursor right in the current row such that it skips to
3554 the beginning or end of a block of non-empty cells.
3556 If a block of cells was previously selected it will expand if the
3557 argument is @true or be cleared if the argument is @false.
3559 bool MoveCursorRightBlock(bool expandSelection
);
3562 Moves the grid cursor up by one row.
3564 If a block of cells was previously selected it will expand if the
3565 argument is @true or be cleared if the argument is @false.
3567 bool MoveCursorUp(bool expandSelection
);
3570 Moves the grid cursor up in the current column such that it skips to
3571 the beginning or end of a block of non-empty cells.
3573 If a block of cells was previously selected it will expand if the
3574 argument is @true or be cleared if the argument is @false.
3576 bool MoveCursorUpBlock(bool expandSelection
);
3579 Moves the grid cursor down by some number of rows so that the previous
3580 bottom visible row becomes the top visible row.
3582 bool MovePageDown();
3585 Moves the grid cursor up by some number of rows so that the previous
3586 top visible row becomes the bottom visible row.
3591 Set the grid cursor to the specified cell.
3593 The grid cursor indicates the current cell and can be moved by the user
3594 using the arrow keys or the mouse.
3596 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
3597 if the event handler vetoes this event, the cursor is not moved.
3599 This function doesn't make the target call visible, use GoToCell() to
3602 void SetGridCursor(int row
, int col
);
3604 Set the grid cursor to the specified cell.
3606 The grid cursor indicates the current cell and can be moved by the user
3607 using the arrow keys or the mouse.
3609 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
3610 if the event handler vetoes this event, the cursor is not moved.
3612 This function doesn't make the target call visible, use GoToCell() to
3615 void SetGridCursor(const wxGridCellCoords
& coords
);
3618 Set the grid's behaviour when the user presses the TAB key.
3620 Pressing the TAB key moves the grid cursor right in the current row, if
3621 there is a cell at the right and, similarly, Shift-TAB moves the cursor
3622 to the left in the current row if it's not in the first column.
3624 What happens if the cursor can't be moved because it it's already at
3625 the beginning or end of the row can be configured using this function,
3626 see wxGrid::TabBehaviour documentation for the detailed description.
3628 IF none of the standard behaviours is appropriate, you can always
3629 handle @c wxEVT_GRID_TABBING event directly to implement a custom
3634 void SetTabBehaviour(TabBehaviour behaviour
);
3640 @name User Selection
3645 Deselects all cells that are currently selected.
3647 void ClearSelection();
3650 Returns an array of individually selected cells.
3652 Notice that this array does @em not contain all the selected cells in
3653 general as it doesn't include the cells selected as part of column, row
3654 or block selection. You must use this method, GetSelectedCols(),
3655 GetSelectedRows() and GetSelectionBlockTopLeft() and
3656 GetSelectionBlockBottomRight() methods to obtain the entire selection
3659 Please notice this behaviour is by design and is needed in order to
3660 support grids of arbitrary size (when an entire column is selected in
3661 a grid with a million of columns, we don't want to create an array with
3662 a million of entries in this function, instead it returns an empty
3663 array and GetSelectedCols() returns an array containing one element).
3665 wxGridCellCoordsArray
GetSelectedCells() const;
3668 Returns an array of selected columns.
3670 Please notice that this method alone is not sufficient to find all the
3671 selected columns as it contains only the columns which were
3672 individually selected but not those being part of the block selection
3673 or being selected in virtue of all of their cells being selected
3674 individually, please see GetSelectedCells() for more details.
3676 wxArrayInt
GetSelectedCols() const;
3679 Returns an array of selected rows.
3681 Please notice that this method alone is not sufficient to find all the
3682 selected rows as it contains only the rows which were individually
3683 selected but not those being part of the block selection or being
3684 selected in virtue of all of their cells being selected individually,
3685 please see GetSelectedCells() for more details.
3687 wxArrayInt
GetSelectedRows() const;
3690 Returns the colour used for drawing the selection background.
3692 wxColour
GetSelectionBackground() const;
3695 Returns an array of the bottom right corners of blocks of selected
3698 Please see GetSelectedCells() for more information about the selection
3699 representation in wxGrid.
3701 @see GetSelectionBlockTopLeft()
3703 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
3706 Returns an array of the top left corners of blocks of selected cells.
3708 Please see GetSelectedCells() for more information about the selection
3709 representation in wxGrid.
3711 @see GetSelectionBlockBottomRight()
3713 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
3716 Returns the colour used for drawing the selection foreground.
3718 wxColour
GetSelectionForeground() const;
3721 Returns the current selection mode.
3723 @see SetSelectionMode().
3725 wxGridSelectionModes
GetSelectionMode() const;
3728 Returns @true if the given cell is selected.
3730 bool IsInSelection(int row
, int col
) const;
3732 Returns @true if the given cell is selected.
3734 bool IsInSelection(const wxGridCellCoords
& coords
) const;
3737 Returns @true if there are currently any selected cells, rows, columns
3740 bool IsSelection() const;
3743 Selects all cells in the grid.
3748 Selects a rectangular block of cells.
3750 If @a addToSelected is @false then any existing selection will be
3751 deselected; if @true the column will be added to the existing
3754 void SelectBlock(int topRow
, int leftCol
, int bottomRow
, int rightCol
,
3755 bool addToSelected
= false);
3757 Selects a rectangular block of cells.
3759 If @a addToSelected is @false then any existing selection will be
3760 deselected; if @true the column will be added to the existing
3763 void SelectBlock(const wxGridCellCoords
& topLeft
,
3764 const wxGridCellCoords
& bottomRight
,
3765 bool addToSelected
= false);
3768 Selects the specified column.
3770 If @a addToSelected is @false then any existing selection will be
3771 deselected; if @true the column will be added to the existing
3774 This method won't select anything if the current selection mode is
3777 void SelectCol(int col
, bool addToSelected
= false);
3780 Selects the specified row.
3782 If @a addToSelected is @false then any existing selection will be
3783 deselected; if @true the row will be added to the existing selection.
3785 This method won't select anything if the current selection mode is
3786 wxGridSelectColumns.
3788 void SelectRow(int row
, bool addToSelected
= false);
3791 Set the colour to be used for drawing the selection background.
3793 void SetSelectionBackground(const wxColour
& c
);
3796 Set the colour to be used for drawing the selection foreground.
3798 void SetSelectionForeground(const wxColour
& c
);
3801 Set the selection behaviour of the grid.
3803 The existing selection is converted to conform to the new mode if
3804 possible and discarded otherwise (e.g. any individual selected cells
3805 are deselected if the new mode allows only the selection of the entire
3808 void SetSelectionMode(wxGridSelectionModes selmode
);
3819 Returns the number of pixels per horizontal scroll increment.
3823 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
3825 int GetScrollLineX() const;
3828 Returns the number of pixels per vertical scroll increment.
3832 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
3834 int GetScrollLineY() const;
3837 Returns @true if a cell is either entirely or at least partially
3838 visible in the grid window.
3840 By default, the cell must be entirely visible for this function to
3841 return @true but if @a wholeCellVisible is @false, the function returns
3842 @true even if the cell is only partially visible.
3844 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
3846 Returns @true if a cell is either entirely or at least partially
3847 visible in the grid window.
3849 By default, the cell must be entirely visible for this function to
3850 return @true but if @a wholeCellVisible is @false, the function returns
3851 @true even if the cell is only partially visible.
3853 bool IsVisible(const wxGridCellCoords
& coords
,
3854 bool wholeCellVisible
= true) const;
3857 Brings the specified cell into the visible grid cell area with minimal
3860 Does nothing if the cell is already visible.
3862 void MakeCellVisible(int row
, int col
);
3864 Brings the specified cell into the visible grid cell area with minimal
3867 Does nothing if the cell is already visible.
3869 void MakeCellVisible(const wxGridCellCoords
& coords
);
3872 Sets the number of pixels per horizontal scroll increment.
3876 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
3878 void SetScrollLineX(int x
);
3881 Sets the number of pixels per vertical scroll increment.
3885 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
3887 void SetScrollLineY(int y
);
3893 @name Cell and Device Coordinate Translation
3898 Convert grid cell coordinates to grid window pixel coordinates.
3900 This function returns the rectangle that encloses the block of cells
3901 limited by @a topLeft and @a bottomRight cell in device coords and
3902 clipped to the client size of the grid window.
3906 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
3907 const wxGridCellCoords
& bottomRight
) const;
3910 Return the rectangle corresponding to the grid cell's size and position
3911 in logical coordinates.
3913 @see BlockToDeviceRect()
3915 wxRect
CellToRect(int row
, int col
) const;
3917 Return the rectangle corresponding to the grid cell's size and position
3918 in logical coordinates.
3920 @see BlockToDeviceRect()
3922 wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
3925 Returns the column at the given pixel position.
3928 The x position to evaluate.
3930 If @true, rather than returning @c wxNOT_FOUND, it returns either
3931 the first or last column depending on whether @a x is too far to
3932 the left or right respectively.
3934 The column index or @c wxNOT_FOUND.
3936 int XToCol(int x
, bool clipToMinMax
= false) const;
3939 Returns the column whose right hand edge is close to the given logical
3942 If no column edge is near to this position @c wxNOT_FOUND is returned.
3944 int XToEdgeOfCol(int x
) const;
3947 Translates logical pixel coordinates to the grid cell coordinates.
3949 Notice that this function expects logical coordinates on input so if
3950 you use this function in a mouse event handler you need to translate
3951 the mouse position, which is expressed in device coordinates, to
3954 @see XToCol(), YToRow()
3956 wxGridCellCoords
XYToCell(int x
, int y
) const;
3958 Translates logical pixel coordinates to the grid cell coordinates.
3960 Notice that this function expects logical coordinates on input so if
3961 you use this function in a mouse event handler you need to translate
3962 the mouse position, which is expressed in device coordinates, to
3965 @see XToCol(), YToRow()
3967 wxGridCellCoords
XYToCell(const wxPoint
& pos
) const;
3968 // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
3969 // undocumented, using it is ugly and non-const reference parameters are
3970 // not used in wxWidgets API
3973 Returns the row whose bottom edge is close to the given logical @a y
3976 If no row edge is near to this position @c wxNOT_FOUND is returned.
3978 int YToEdgeOfRow(int y
) const;
3981 Returns the grid row that corresponds to the logical @a y coordinate.
3983 Returns @c wxNOT_FOUND if there is no row at the @a y position.
3985 int YToRow(int y
, bool clipToMinMax
= false) const;
3991 @name Miscellaneous Functions
3996 Appends one or more new columns to the right of the grid.
3998 The @a updateLabels argument is not used at present. If you are using a
3999 derived grid table class you will need to override
4000 wxGridTableBase::AppendCols(). See InsertCols() for further
4003 @return @true on success or @false if appending columns failed.
4005 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
4008 Appends one or more new rows to the bottom of the grid.
4010 The @a updateLabels argument is not used at present. If you are using a
4011 derived grid table class you will need to override
4012 wxGridTableBase::AppendRows(). See InsertRows() for further
4015 @return @true on success or @false if appending rows failed.
4017 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
4020 Return @true if the horizontal grid lines stop at the last column
4021 boundary or @false if they continue to the end of the window.
4023 The default is to clip grid lines.
4025 @see ClipHorzGridLines(), AreVertGridLinesClipped()
4027 bool AreHorzGridLinesClipped() const;
4030 Return @true if the vertical grid lines stop at the last row
4031 boundary or @false if they continue to the end of the window.
4033 The default is to clip grid lines.
4035 @see ClipVertGridLines(), AreHorzGridLinesClipped()
4037 bool AreVertGridLinesClipped() const;
4040 Increments the grid's batch count.
4042 When the count is greater than zero repainting of the grid is
4043 suppressed. Each call to BeginBatch must be matched by a later call to
4044 EndBatch(). Code that does a lot of grid modification can be enclosed
4045 between BeginBatch() and EndBatch() calls to avoid screen flicker. The
4046 final EndBatch() call will cause the grid to be repainted.
4048 Notice that you should use wxGridUpdateLocker which ensures that there
4049 is always a matching EndBatch() call for this BeginBatch() if possible
4050 instead of calling this method directly.
4055 Clears all data in the underlying grid table and repaints the grid.
4057 The table is not deleted by this function. If you are using a derived
4058 table class then you need to override wxGridTableBase::Clear() for this
4059 function to have any effect.
4064 Change whether the horizontal grid lines are clipped by the end of the
4067 By default the grid lines are not drawn beyond the end of the last
4068 column but after calling this function with @a clip set to @false they
4069 will be drawn across the entire grid window.
4071 @see AreHorzGridLinesClipped(), ClipVertGridLines()
4073 void ClipHorzGridLines(bool clip
);
4076 Change whether the vertical grid lines are clipped by the end of the
4079 By default the grid lines are not drawn beyond the end of the last
4080 row but after calling this function with @a clip set to @false they
4081 will be drawn across the entire grid window.
4083 @see AreVertGridLinesClipped(), ClipHorzGridLines()
4085 void ClipVertGridLines(bool clip
);
4088 Deletes one or more columns from a grid starting at the specified
4091 The @a updateLabels argument is not used at present. If you are using a
4092 derived grid table class you will need to override
4093 wxGridTableBase::DeleteCols(). See InsertCols() for further
4096 @return @true on success or @false if deleting columns failed.
4098 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
4101 Deletes one or more rows from a grid starting at the specified
4104 The @a updateLabels argument is not used at present. If you are using a
4105 derived grid table class you will need to override
4106 wxGridTableBase::DeleteRows(). See InsertRows() for further
4109 @return @true on success or @false if appending rows failed.
4111 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
4114 Decrements the grid's batch count.
4116 When the count is greater than zero repainting of the grid is
4117 suppressed. Each previous call to BeginBatch() must be matched by a
4118 later call to EndBatch(). Code that does a lot of grid modification can
4119 be enclosed between BeginBatch() and EndBatch() calls to avoid screen
4120 flicker. The final EndBatch() will cause the grid to be repainted.
4122 @see wxGridUpdateLocker
4127 Overridden wxWindow method.
4132 Causes immediate repainting of the grid.
4134 Use this instead of the usual wxWindow::Refresh().
4136 void ForceRefresh();
4139 Returns the number of times that BeginBatch() has been called without
4140 (yet) matching calls to EndBatch(). While the grid's batch count is
4141 greater than zero the display will not be updated.
4143 int GetBatchCount();
4146 Returns the total number of grid columns.
4148 This is the same as the number of columns in the underlying grid table.
4150 int GetNumberCols() const;
4153 Returns the total number of grid rows.
4155 This is the same as the number of rows in the underlying grid table.
4157 int GetNumberRows() const;
4160 Returns the attribute for the given cell creating one if necessary.
4162 If the cell already has an attribute, it is returned. Otherwise a new
4163 attribute is created, associated with the cell and returned. In any
4164 case the caller must call DecRef() on the returned pointer.
4166 This function may only be called if CanHaveAttributes() returns @true.
4168 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
4171 Returns a base pointer to the current table object.
4173 The returned pointer is still owned by the grid.
4175 wxGridTableBase
*GetTable() const;
4178 Inserts one or more new columns into a grid with the first new column
4179 at the specified position.
4181 Notice that inserting the columns in the grid requires grid table
4182 cooperation: when this method is called, grid object begins by
4183 requesting the underlying grid table to insert new columns. If this is
4184 successful the table notifies the grid and the grid updates the
4185 display. For a default grid (one where you have called CreateGrid())
4186 this process is automatic. If you are using a custom grid table
4187 (specified with SetTable()) then you must override
4188 wxGridTableBase::InsertCols() in your derived table class.
4191 The position which the first newly inserted column will have.
4193 The number of columns to insert.
4197 @true if the columns were successfully inserted, @false if an error
4198 occurred (most likely the table couldn't be updated).
4200 bool InsertCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
4203 Inserts one or more new rows into a grid with the first new row at the
4206 Notice that you must implement wxGridTableBase::InsertRows() if you use
4207 a grid with a custom table, please see InsertCols() for more
4211 The position which the first newly inserted row will have.
4213 The number of rows to insert.
4217 @true if the rows were successfully inserted, @false if an error
4218 occurred (most likely the table couldn't be updated).
4220 bool InsertRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
4223 Invalidates the cached attribute for the given cell.
4225 For efficiency reasons, wxGrid may cache the recently used attributes
4226 (currently it caches only the single most recently used one, in fact)
4227 which can result in the cell appearance not being refreshed even when
4228 the attribute returned by your custom wxGridCellAttrProvider-derived
4229 class has changed. To force the grid to refresh the cell attribute,
4230 this function may be used. Notice that calling it will not result in
4231 actually redrawing the cell, you still need to call
4232 wxWindow::RefreshRect() to invalidate the area occupied by the cell in
4233 the window to do this. Also note that you don't need to call this
4234 function if you store the attributes in wxGrid itself, i.e. use its
4235 SetAttr() and similar methods, it is only useful when using a separate
4236 custom attributes provider.
4239 The row of the cell whose attribute needs to be queried again.
4241 The column of the cell whose attribute needs to be queried again.
4245 void RefreshAttr(int row
, int col
);
4248 Draws part or all of a wxGrid on a wxDC for printing or display.
4250 Pagination can be accomplished by using sequential Render() calls
4251 with appropriate values in wxGridCellCoords topLeft and bottomRight.
4254 The wxDC to be drawn on.
4256 The position on the wxDC where rendering should begin. If not
4257 specified drawing will begin at the wxDC MaxX() and MaxY().
4259 The size of the area on the wxDC that the rendered wxGrid should
4260 occupy. If not specified the drawing will be scaled to fit the
4261 available dc width or height. The wxGrid's aspect ratio is
4262 maintained whether or not size is specified.
4264 The top left cell of the block to be drawn. Defaults to ( 0, 0 ).
4266 The bottom right cell of the block to be drawn. Defaults to row and
4269 A combination of values from wxGridRenderStyle.
4273 void Render( wxDC
& dc
,
4274 const wxPoint
& pos
= wxDefaultPosition
,
4275 const wxSize
& size
= wxDefaultSize
,
4276 const wxGridCellCoords
& topLeft
= wxGridCellCoords( -1, -1 ),
4277 const wxGridCellCoords
& bottomRight
= wxGridCellCoords( -1, -1 ),
4278 int style
= wxGRID_DRAW_DEFAULT
);
4281 Sets the cell attributes for all cells in the specified column.
4283 For more information about controlling grid cell attributes see the
4284 wxGridCellAttr cell attribute class and the @ref overview_grid.
4286 void SetColAttr(int col
, wxGridCellAttr
* attr
);
4289 Sets the extra margins used around the grid area.
4291 A grid may occupy more space than needed for its data display and
4292 this function allows to set how big this extra space is
4294 void SetMargins(int extraWidth
, int extraHeight
);
4297 Sets the cell attributes for all cells in the specified row.
4299 The grid takes ownership of the attribute pointer.
4301 See the wxGridCellAttr class for more information about controlling
4304 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
4307 wxArrayInt
CalcRowLabelsExposed( const wxRegion
& reg
);
4308 wxArrayInt
CalcColLabelsExposed( const wxRegion
& reg
);
4309 wxGridCellCoordsArray
CalcCellsExposed( const wxRegion
& reg
);
4315 @name Sorting support.
4317 wxGrid doesn't provide any support for sorting the data but it does
4318 generate events allowing the user code to sort it and supports
4319 displaying the sort indicator in the column used for sorting.
4321 To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT
4322 event (and not veto it) and resort the data displayed in the grid. The
4323 grid will automatically update the sorting indicator on the column
4326 You can also call the functions in this section directly to update the
4327 sorting indicator. Once again, they don't do anything with the grid
4328 data, it remains your responsibility to actually sort it appropriately.
4333 Return the column in which the sorting indicator is currently
4336 Returns @c wxNOT_FOUND if sorting indicator is not currently displayed
4339 @see SetSortingColumn()
4341 int GetSortingColumn() const;
4344 Return @true if this column is currently used for sorting.
4346 @see GetSortingColumn()
4348 bool IsSortingBy(int col
) const;
4351 Return @true if the current sorting order is ascending or @false if it
4354 It only makes sense to call this function if GetSortingColumn() returns
4355 a valid column index and not @c wxNOT_FOUND.
4357 @see SetSortingColumn()
4359 bool IsSortOrderAscending() const;
4362 Set the column to display the sorting indicator in and its direction.
4365 The column to display the sorting indicator in or @c wxNOT_FOUND to
4366 remove any currently displayed sorting indicator.
4368 If @true, display the ascending sort indicator, otherwise display
4369 the descending sort indicator.
4371 @see GetSortingColumn(), IsSortOrderAscending()
4373 void SetSortingColumn(int col
, bool ascending
= true);
4376 Remove any currently shown sorting indicator.
4378 This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND
4381 void UnsetSortingColumn();
4386 @name Accessors for component windows.
4388 Return the various child windows of wxGrid.
4390 wxGrid is an empty parent window for 4 children representing the column
4391 labels window (top), the row labels window (left), the corner window
4392 (top left) and the main grid window. It may be necessary to use these
4393 individual windows and not the wxGrid window itself if you need to
4394 handle events for them (this can be done using wxEvtHandler::Connect()
4395 or wxWindow::PushEventHandler()) or do something else requiring the use
4396 of the correct window pointer. Notice that you should not, however,
4397 change these windows (e.g. reposition them or draw over them) because
4398 they are managed by wxGrid itself.
4403 Return the main grid window containing the grid cells.
4405 This window is always shown.
4407 wxWindow
*GetGridWindow() const;
4410 Return the row labels window.
4412 This window is not shown if the row labels were hidden using
4415 wxWindow
*GetGridRowLabelWindow() const;
4418 Return the column labels window.
4420 This window is not shown if the columns labels were hidden using
4423 Depending on whether UseNativeColHeader() was called or not this can be
4424 either a wxHeaderCtrl or a plain wxWindow. This function returns a valid
4425 window pointer in either case but in the former case you can also use
4426 GetGridColHeader() to access it if you need wxHeaderCtrl-specific
4429 wxWindow
*GetGridColLabelWindow() const;
4432 Return the window in the top left grid corner.
4434 This window is shown only of both columns and row labels are shown and
4435 normally doesn't contain anything. Clicking on it is handled by wxGrid
4436 however and can be used to select the entire grid.
4438 wxWindow
*GetGridCornerLabelWindow() const;
4441 Return the header control used for column labels display.
4443 This function can only be called if UseNativeColHeader() had been
4446 wxHeaderCtrl
*GetGridColHeader() const;
4452 Returns @true if this grid has support for cell attributes.
4454 The grid supports attributes if it has the associated table which, in
4455 turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
4458 bool CanHaveAttributes() const;
4461 Get the minimal width of the given column/row.
4463 The value returned by this function may be different than that returned
4464 by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
4465 called for this column.
4467 int GetColMinimalWidth(int col
) const;
4470 Returns the coordinate of the right border specified column.
4472 int GetColRight(int col
) const;
4475 Returns the coordinate of the left border specified column.
4477 int GetColLeft(int col
) const;
4480 Returns the minimal size for the given column.
4482 The value returned by this function may be different than that returned
4483 by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
4484 called for this row.
4486 int GetRowMinimalHeight(int col
) const;
4492 @class wxGridUpdateLocker
4494 This small class can be used to prevent wxGrid from redrawing during its
4495 lifetime by calling wxGrid::BeginBatch() in its constructor and
4496 wxGrid::EndBatch() in its destructor. It is typically used in a function
4497 performing several operations with a grid which would otherwise result in
4498 flicker. For example:
4503 m_grid = new wxGrid(this, ...);
4505 wxGridUpdateLocker noUpdates(m_grid);
4506 m_grid-AppendColumn();
4507 // ... many other operations with m_grid ...
4510 // destructor called, grid refreshed
4514 Using this class is easier and safer than calling wxGrid::BeginBatch() and
4515 wxGrid::EndBatch() because you don't risk missing the call the latter (due
4516 to an exception for example).
4521 class wxGridUpdateLocker
4525 Creates an object preventing the updates of the specified @a grid. The
4526 parameter could be @NULL in which case nothing is done. If @a grid is
4527 non-@NULL then the grid must exist for longer than this
4528 wxGridUpdateLocker object itself.
4530 The default constructor could be followed by a call to Create() to set
4531 the grid object later.
4533 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
4536 Destructor reenables updates for the grid this object is associated
4539 ~wxGridUpdateLocker();
4542 This method can be called if the object had been constructed using the
4543 default constructor. It must not be called more than once.
4545 void Create(wxGrid
* grid
);
4553 This event class contains information about various grid events.
4555 Notice that all grid event table macros are available in two versions:
4556 @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the
4557 two is that the former doesn't allow to specify the grid window identifier
4558 and so takes a single parameter, the event handler, but is not suitable if
4559 there is more than one grid control in the window where the event table is
4560 used (as it would catch the events from all the grids). The version with @c
4561 CMD takes the id as first argument and the event handler as the second one
4562 and so can be used with multiple grids as well. Otherwise there are no
4563 difference between the two and only the versions without the id are
4564 documented below for brevity.
4566 @beginEventTable{wxGridEvent}
4567 @event{EVT_GRID_CELL_CHANGING(func)}
4568 The user is about to change the data in a cell. The new cell value as
4569 string is available from GetString() event object method. This event
4570 can be vetoed if the change is not allowed.
4571 Processes a @c wxEVT_GRID_CELL_CHANGING event type.
4572 @event{EVT_GRID_CELL_CHANGED(func)}
4573 The user changed the data in a cell. The old cell value as string is
4574 available from GetString() event object method. Notice that vetoing
4575 this event still works for backwards compatibility reasons but any new
4576 code should only veto EVT_GRID_CELL_CHANGING event and not this one.
4577 Processes a @c wxEVT_GRID_CELL_CHANGED event type.
4578 @event{EVT_GRID_CELL_LEFT_CLICK(func)}
4579 The user clicked a cell with the left mouse button. Processes a
4580 @c wxEVT_GRID_CELL_LEFT_CLICK event type.
4581 @event{EVT_GRID_CELL_LEFT_DCLICK(func)}
4582 The user double-clicked a cell with the left mouse button. Processes a
4583 @c wxEVT_GRID_CELL_LEFT_DCLICK event type.
4584 @event{EVT_GRID_CELL_RIGHT_CLICK(func)}
4585 The user clicked a cell with the right mouse button. Processes a
4586 @c wxEVT_GRID_CELL_RIGHT_CLICK event type.
4587 @event{EVT_GRID_CELL_RIGHT_DCLICK(func)}
4588 The user double-clicked a cell with the right mouse button. Processes a
4589 @c wxEVT_GRID_CELL_RIGHT_DCLICK event type.
4590 @event{EVT_GRID_EDITOR_HIDDEN(func)}
4591 The editor for a cell was hidden. Processes a
4592 @c wxEVT_GRID_EDITOR_HIDDEN event type.
4593 @event{EVT_GRID_EDITOR_SHOWN(func)}
4594 The editor for a cell was shown. Processes a
4595 @c wxEVT_GRID_EDITOR_SHOWN event type.
4596 @event{EVT_GRID_LABEL_LEFT_CLICK(func)}
4597 The user clicked a label with the left mouse button. Processes a
4598 @c wxEVT_GRID_LABEL_LEFT_CLICK event type.
4599 @event{EVT_GRID_LABEL_LEFT_DCLICK(func)}
4600 The user double-clicked a label with the left mouse button. Processes a
4601 @c wxEVT_GRID_LABEL_LEFT_DCLICK event type.
4602 @event{EVT_GRID_LABEL_RIGHT_CLICK(func)}
4603 The user clicked a label with the right mouse button. Processes a
4604 @c wxEVT_GRID_LABEL_RIGHT_CLICK event type.
4605 @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)}
4606 The user double-clicked a label with the right mouse button. Processes
4607 a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type.
4608 @event{EVT_GRID_SELECT_CELL(func)}
4609 The given cell was made current, either by user or by the program via a
4610 call to SetGridCursor() or GoToCell(). Processes a
4611 @c wxEVT_GRID_SELECT_CELL event type.
4612 @event{EVT_GRID_COL_MOVE(func)}
4613 The user tries to change the order of the columns in the grid by
4614 dragging the column specified by GetCol(). This event can be vetoed to
4615 either prevent the user from reordering the column change completely
4616 (but notice that if you don't want to allow it at all, you simply
4617 shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed
4618 but handled in some way in the handler, e.g. by really moving the
4619 column to the new position at the associated table level, or allowed to
4620 proceed in which case wxGrid::SetColPos() is used to reorder the
4621 columns display order without affecting the use of the column indices
4623 This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type.
4624 @event{EVT_GRID_COL_SORT(func)}
4625 This event is generated when a column is clicked by the user and its
4626 name is explained by the fact that the custom reaction to a click on a
4627 column is to sort the grid contents by this column. However the grid
4628 itself has no special support for sorting and it's up to the handler of
4629 this event to update the associated table. But if the event is handled
4630 (and not vetoed) the grid supposes that the table was indeed resorted
4631 and updates the column to indicate the new sort order and refreshes
4633 This event macro corresponds to @c wxEVT_GRID_COL_SORT event type.
4634 @event{EVT_GRID_TABBING(func)}
4635 This event is generated when the user presses TAB or Shift-TAB in the
4636 grid. It can be used to customize the simple default TAB handling
4637 logic, e.g. to go to the next non-empty cell instead of just the next
4638 cell. See also wxGrid::SetTabBehaviour(). This event is new since
4643 @category{grid,events}
4645 class wxGridEvent
: public wxNotifyEvent
4649 Default constructor.
4653 Constructor for initializing all event attributes.
4655 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
4656 int row
= -1, int col
= -1, int x
= -1, int y
= -1,
4657 bool sel
= true, const wxKeyboardState
& kbd
= wxKeyboardState());
4660 Returns @true if the Alt key was down at the time of the event.
4662 bool AltDown() const;
4665 Returns @true if the Control key was down at the time of the event.
4667 bool ControlDown() const;
4670 Column at which the event occurred.
4672 Notice that for a @c wxEVT_GRID_SELECT_CELL event this column is the
4673 column of the newly selected cell while the previously selected cell
4674 can be retrieved using wxGrid::GetGridCursorCol().
4676 virtual int GetCol();
4679 Position in pixels at which the event occurred.
4681 wxPoint
GetPosition();
4684 Row at which the event occurred.
4686 Notice that for a @c wxEVT_GRID_SELECT_CELL event this row is the row
4687 of the newly selected cell while the previously selected cell can be
4688 retrieved using wxGrid::GetGridCursorRow().
4690 virtual int GetRow();
4693 Returns @true if the Meta key was down at the time of the event.
4695 bool MetaDown() const;
4698 Returns @true if the user is selecting grid cells, or @false if
4704 Returns @true if the Shift key was down at the time of the event.
4706 bool ShiftDown() const;
4712 @class wxGridSizeEvent
4714 This event class contains information about a row/column resize event.
4716 @beginEventTable{wxGridSizeEvent}
4717 @event{EVT_GRID_CMD_COL_SIZE(id, func)}
4718 The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event
4720 @event{EVT_GRID_CMD_ROW_SIZE(id, func)}
4721 The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event
4723 @event{EVT_GRID_COL_SIZE(func)}
4724 Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id.
4725 @event{EVT_GRID_COL_AUTO_SIZE(func)}
4726 This event is sent when a column must be resized to its best size, e.g.
4727 when the user double clicks the column divider. The default
4728 implementation simply resizes the column to fit the column label (but
4729 not its contents as this could be too slow for big grids). This macro
4730 corresponds to @c wxEVT_GRID_COL_AUTO_SIZE event type and is new since
4732 @event{EVT_GRID_ROW_SIZE(func)}
4733 Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id.
4737 @category{grid,events}
4739 class wxGridSizeEvent
: public wxNotifyEvent
4743 Default constructor.
4747 Constructor for initializing all event attributes.
4749 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
4750 int rowOrCol
= -1, int x
= -1, int y
= -1,
4751 const wxKeyboardState
& kbd
= wxKeyboardState());
4754 Returns @true if the Alt key was down at the time of the event.
4756 bool AltDown() const;
4759 Returns @true if the Control key was down at the time of the event.
4761 bool ControlDown() const;
4764 Position in pixels at which the event occurred.
4766 wxPoint
GetPosition();
4769 Row or column at that was resized.
4774 Returns @true if the Meta key was down at the time of the event.
4776 bool MetaDown() const;
4779 Returns @true if the Shift key was down at the time of the event.
4781 bool ShiftDown() const;
4787 @class wxGridRangeSelectEvent
4789 @beginEventTable{wxGridRangeSelectEvent}
4790 @event{EVT_GRID_RANGE_SELECT(func)}
4791 The user selected a group of contiguous cells. Processes a
4792 @c wxEVT_GRID_RANGE_SELECT event type.
4793 @event{EVT_GRID_CMD_RANGE_SELECT(id, func)}
4794 The user selected a group of contiguous cells; variant taking a window
4795 identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type.
4799 @category{grid,events}
4801 class wxGridRangeSelectEvent
: public wxNotifyEvent
4805 Default constructor.
4807 wxGridRangeSelectEvent();
4809 Constructor for initializing all event attributes.
4811 wxGridRangeSelectEvent(int id
, wxEventType type
,
4813 const wxGridCellCoords
& topLeft
,
4814 const wxGridCellCoords
& bottomRight
,
4815 bool sel
= true, const wxKeyboardState
& kbd
= wxKeyboardState());
4818 Returns @true if the Alt key was down at the time of the event.
4820 bool AltDown() const;
4823 Returns @true if the Control key was down at the time of the event.
4825 bool ControlDown() const;
4828 Top left corner of the rectangular area that was (de)selected.
4830 wxGridCellCoords
GetBottomRightCoords();
4833 Bottom row of the rectangular area that was (de)selected.
4838 Left column of the rectangular area that was (de)selected.
4843 Right column of the rectangular area that was (de)selected.
4848 Top left corner of the rectangular area that was (de)selected.
4850 wxGridCellCoords
GetTopLeftCoords();
4853 Top row of the rectangular area that was (de)selected.
4858 Returns @true if the Meta key was down at the time of the event.
4860 bool MetaDown() const;
4863 Returns @true if the area was selected, @false otherwise.
4868 Returns @true if the Shift key was down at the time of the event.
4870 bool ShiftDown() const;
4876 @class wxGridEditorCreatedEvent
4878 @beginEventTable{wxGridEditorCreatedEvent}
4879 @event{EVT_GRID_EDITOR_CREATED(func)}
4880 The editor for a cell was created. Processes a
4881 @c wxEVT_GRID_EDITOR_CREATED event type.
4882 @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)}
4883 The editor for a cell was created; variant taking a window identifier.
4884 Processes a @c wxEVT_GRID_EDITOR_CREATED event type.
4888 @category{grid,events}
4890 class wxGridEditorCreatedEvent
: public wxCommandEvent
4894 Default constructor.
4896 wxGridEditorCreatedEvent();
4898 Constructor for initializing all event attributes.
4900 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
4901 int row
, int col
, wxControl
* ctrl
);
4904 Returns the column at which the event occurred.
4909 Returns the edit control.
4911 wxControl
* GetControl();
4914 Returns the row at which the event occurred.
4919 Sets the column at which the event occurred.
4921 void SetCol(int col
);
4924 Sets the edit control.
4926 void SetControl(wxControl
* ctrl
);
4929 Sets the row at which the event occurred.
4931 void SetRow(int row
);
4935 wxEventType wxEVT_GRID_CELL_LEFT_CLICK
;
4936 wxEventType wxEVT_GRID_CELL_RIGHT_CLICK
;
4937 wxEventType wxEVT_GRID_CELL_LEFT_DCLICK
;
4938 wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK
;
4939 wxEventType wxEVT_GRID_LABEL_LEFT_CLICK
;
4940 wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK
;
4941 wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK
;
4942 wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK
;
4943 wxEventType wxEVT_GRID_ROW_SIZE
;
4944 wxEventType wxEVT_GRID_COL_SIZE
;
4945 wxEventType wxEVT_GRID_COL_AUTO_SIZE
;
4946 wxEventType wxEVT_GRID_RANGE_SELECT
;
4947 wxEventType wxEVT_GRID_CELL_CHANGING
;
4948 wxEventType wxEVT_GRID_CELL_CHANGED
;
4949 wxEventType wxEVT_GRID_SELECT_CELL
;
4950 wxEventType wxEVT_GRID_EDITOR_SHOWN
;
4951 wxEventType wxEVT_GRID_EDITOR_HIDDEN
;
4952 wxEventType wxEVT_GRID_EDITOR_CREATED
;
4953 wxEventType wxEVT_GRID_CELL_BEGIN_DRAG
;
4954 wxEventType wxEVT_GRID_COL_MOVE
;
4955 wxEventType wxEVT_GRID_COL_SORT
;
4956 wxEventType wxEVT_GRID_TABBING
;