1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGrid and related classes
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxGridCellRenderer
12 This class is responsible for actually drawing the cell in the grid. You
13 may pass it to the wxGridCellAttr (below) to change the format of one given
14 cell or to wxGrid::SetDefaultRenderer() to change the view of all cells.
15 This is an abstract class, and you will normally use one of the predefined
16 derived classes or derive your own class from it.
21 @see wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer,
22 wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
23 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
24 wxGridCellStringRenderer
26 class wxGridCellRenderer
: public wxClientDataContainer
, public wxRefCounter
32 This function must be implemented in derived classes to return a copy
35 virtual wxGridCellRenderer
* Clone() const = 0;
38 Draw the given cell on the provided DC inside the given rectangle using
39 the style specified by the attribute and the default or selected state
40 corresponding to the isSelected value.
42 This pure virtual function has a default implementation which will
43 prepare the DC using the given attribute: it will draw the rectangle
44 with the background colour from attr and set the text colour and font.
46 virtual void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
47 const wxRect
& rect
, int row
, int col
,
51 Get the preferred size of the cell for its contents.
53 virtual wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
54 int row
, int col
) = 0;
58 The destructor is private because only DecRef() can delete us.
60 virtual ~wxGridCellRenderer();
64 @class wxGridCellAutoWrapStringRenderer
66 This class may be used to format string data in a cell. The too
67 long lines are wrapped to be shown entirely at word boundaries.
72 @see wxGridCellRenderer, wxGridCellBoolRenderer,
73 wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
74 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
75 wxGridCellStringRenderer
78 class wxGridCellAutoWrapStringRenderer
: public wxGridCellStringRenderer
84 wxGridCellAutoWrapStringRenderer();
89 @class wxGridCellBoolRenderer
91 This class may be used to format boolean data in a cell.
96 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
97 wxGridCellDateTimeRenderer, wxGridCellEnumRenderer,
98 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
99 wxGridCellStringRenderer
101 class wxGridCellBoolRenderer
: public wxGridCellRenderer
107 wxGridCellBoolRenderer();
111 @class wxGridCellDateTimeRenderer
113 This class may be used to format a date/time data in a cell.
114 The class wxDateTime is used internally to display the local date/time
115 or to parse the string date entered in the cell thanks to the defined format.
120 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
121 wxGridCellBoolRenderer, wxGridCellEnumRenderer,
122 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
123 wxGridCellStringRenderer
125 class wxGridCellDateTimeRenderer
: public wxGridCellStringRenderer
129 Date/time renderer constructor.
132 strptime()-like format string used the parse the output date/time.
134 strptime()-like format string used to parse the string entered in the cell.
136 wxGridCellDateTimeRenderer(const wxString
& outformat
= wxDefaultDateTimeFormat
,
137 const wxString
& informat
= wxDefaultDateTimeFormat
);
141 Sets the strptime()-like format string which will be used to parse
145 strptime()-like format string used to parse the date/time.
147 virtual void SetParameters(const wxString
& params
);
151 @class wxGridCellEnumRenderer
153 This class may be used to render in a cell a number as a textual
156 The corresponding text strings are specified as comma-separated items in
157 the string passed to this renderer ctor or SetParameters() method. For
158 example, if this string is @c "John,Fred,Bob" the cell will be rendered as
159 "John", "Fred" or "Bob" if its contents is 0, 1 or 2 respectively.
164 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
165 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
166 wxGridCellFloatRenderer, wxGridCellNumberRenderer,
167 wxGridCellStringRenderer
169 class wxGridCellEnumRenderer
: public wxGridCellStringRenderer
176 Comma separated string parameters "item1[,item2[...,itemN]]".
178 wxGridCellEnumRenderer( const wxString
& choices
= wxEmptyString
);
181 Sets the comma separated string content of the enum.
184 Comma separated string parameters "item1[,item2[...,itemN]]".
186 virtual void SetParameters(const wxString
& params
);
190 Specifier used to format the data to string for the numbers handled by
191 wxGridCellFloatRenderer and wxGridCellFloatEditor.
195 enum wxGridCellFloatFormat
197 /// Decimal floating point (%f).
198 wxGRID_FLOAT_FORMAT_FIXED
= 0x0010,
200 /// Scientific notation (mantise/exponent) using e character (%e).
201 wxGRID_FLOAT_FORMAT_SCIENTIFIC
= 0x0020,
203 /// Use the shorter of %e or %f (%g).
204 wxGRID_FLOAT_FORMAT_COMPACT
= 0x0040,
206 /// To use in combination with one of the above formats for the upper
207 /// case version (%F/%E/%G)
208 wxGRID_FLOAT_FORMAT_UPPER
= 0x0080,
210 /// The format used by default (wxGRID_FLOAT_FORMAT_FIXED).
211 wxGRID_FLOAT_FORMAT_DEFAULT
= wxGRID_FLOAT_FORMAT_FIXED
215 @class wxGridCellFloatRenderer
217 This class may be used to format floating point data in a cell.
222 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
223 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
224 wxGridCellEnumRenderer, wxGridCellNumberRenderer,
225 wxGridCellStringRenderer
227 class wxGridCellFloatRenderer
: public wxGridCellStringRenderer
231 Float cell renderer ctor.
234 Minimum number of characters to be shown.
236 Number of digits after the decimal dot.
238 The format used to display the string, must be a combination of
239 ::wxGridCellFloatFormat enum elements. This parameter is only
240 available since wxWidgets 2.9.3.
242 wxGridCellFloatRenderer(int width
= -1, int precision
= -1,
243 int format
= wxGRID_FLOAT_FORMAT_DEFAULT
);
246 Returns the specifier used to format the data to string.
248 The returned value is a combination of ::wxGridCellFloatFormat elements.
252 int GetFormat() const;
255 Returns the precision.
257 int GetPrecision() const;
262 int GetWidth() const;
265 Set the format to use for display the number.
268 Must be a combination of ::wxGridCellFloatFormat enum elements.
272 void SetFormat(int format
);
275 The parameters string format is "width[,precision[,format]]" where
276 @c format should be chosen between f|e|g|E|G (f is used by default)
278 virtual void SetParameters(const wxString
& params
);
283 void SetPrecision(int precision
);
288 void SetWidth(int width
);
292 @class wxGridCellNumberRenderer
294 This class may be used to format integer data in a cell.
299 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
300 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
301 wxGridCellEnumRenderer, wxGridCellFloatRenderer,
302 wxGridCellStringRenderer
304 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
310 wxGridCellNumberRenderer();
314 @class wxGridCellStringRenderer
316 This class may be used to format string data in a cell; it is the default
322 @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer,
323 wxGridCellBoolRenderer, wxGridCellDateTimeRenderer,
324 wxGridCellEnumRenderer, wxGridCellFloatRenderer,
325 wxGridCellNumberRenderer
327 class wxGridCellStringRenderer
: public wxGridCellRenderer
333 wxGridCellStringRenderer();
338 @class wxGridCellEditor
340 This class is responsible for providing and manipulating the in-place edit
341 controls for the grid. Instances of wxGridCellEditor (actually, instances
342 of derived classes since it is an abstract class) can be associated with
343 the cell attributes for individual cells, rows, columns, or even for the
349 @see wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor,
350 wxGridCellChoiceEditor, wxGridCellEnumEditor,
351 wxGridCellFloatEditor, wxGridCellNumberEditor,
354 class wxGridCellEditor
: public wxClientDataContainer
, public wxRefCounter
363 Fetch the value from the table and prepare the edit control to begin
366 This function should save the original value of the grid cell at the
367 given @a row and @a col and show the control allowing the user to
372 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
375 Create a new object which is the copy of this one.
377 virtual wxGridCellEditor
* Clone() const = 0;
380 Creates the actual edit control.
382 virtual void Create(wxWindow
* parent
, wxWindowID id
,
383 wxEvtHandler
* evtHandler
) = 0;
388 virtual void Destroy();
391 End editing the cell.
393 This function must check if the current value of the editing control is
394 valid and different from the original value (available as @a oldval in
395 its string form and possibly saved internally using its real type by
396 BeginEdit()). If it isn't, it just returns @false, otherwise it must do
398 - Save the new value internally so that ApplyEdit() could apply it.
399 - Fill @a newval (which is never @NULL) with the string
400 representation of the new value.
403 Notice that it must @em not modify the grid as the change could still
406 If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto
407 this change, ApplyEdit() will be called next.
409 virtual bool EndEdit(int row
, int col
, const wxGrid
* grid
,
410 const wxString
& oldval
, wxString
* newval
) = 0;
413 Effectively save the changes in the grid.
415 This function should save the value of the control in the grid. It is
416 called only after EndEdit() returns @true.
418 virtual void ApplyEdit(int row
, int col
, wxGrid
* grid
) = 0;
421 Some types of controls on some platforms may need some help with the
424 virtual void HandleReturn(wxKeyEvent
& event
);
427 Returns @true if the edit control has been created.
432 Draws the part of the cell not occupied by the control: the base class
433 version just fills it with background colour from the attribute.
435 virtual void PaintBackground(wxDC
& dc
, const wxRect
& rectCell
, wxGridCellAttr
& attr
);
438 Reset the value in the control back to its starting value.
440 virtual void Reset() = 0;
443 Size and position the edit control.
445 virtual void SetSize(const wxRect
& rect
);
448 Show or hide the edit control, use the specified attributes to set
449 colours/fonts for it.
451 virtual void Show(bool show
, wxGridCellAttr
* attr
= NULL
);
454 If the editor is enabled by clicking on the cell, this method will be
457 virtual void StartingClick();
460 If the editor is enabled by pressing keys on the grid, this will be
461 called to let the editor do something about that first key if desired.
463 virtual void StartingKey(wxKeyEvent
& event
);
466 Returns the value currently in the editor control.
468 virtual wxString
GetValue() const = 0;
473 The destructor is private because only DecRef() can delete us.
475 virtual ~wxGridCellEditor();
479 @class wxGridCellAutoWrapStringEditor
481 Grid cell editor for wrappable string/text data.
486 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
487 wxGridCellEnumEditor, wxGridCellFloatEditor,
488 wxGridCellNumberEditor, wxGridCellTextEditor
490 class wxGridCellAutoWrapStringEditor
: public wxGridCellTextEditor
493 wxGridCellAutoWrapStringEditor();
497 @class wxGridCellBoolEditor
499 Grid cell editor for boolean data.
504 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
505 wxGridCellChoiceEditor, wxGridCellEnumEditor,
506 wxGridCellFloatEditor, wxGridCellNumberEditor,
509 class wxGridCellBoolEditor
: public wxGridCellEditor
515 wxGridCellBoolEditor();
518 Returns @true if the given @a value is equal to the string
519 representation of the truth value we currently use (see
522 static bool IsTrueValue(const wxString
& value
);
525 This method allows you to customize the values returned by GetValue()
526 for the cell using this editor. By default, the default values of the
527 arguments are used, i.e. @c "1" is returned if the cell is checked and
528 an empty string otherwise.
530 static void UseStringValues(const wxString
& valueTrue
= "1",
531 const wxString
& valueFalse
= wxEmptyString
);
535 @class wxGridCellChoiceEditor
537 Grid cell editor for string data providing the user a choice from a list of
543 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
544 wxGridCellBoolEditor, wxGridCellEnumEditor,
545 wxGridCellFloatEditor, wxGridCellNumberEditor,
548 class wxGridCellChoiceEditor
: public wxGridCellEditor
552 Choice cell renderer ctor.
555 Number of strings from which the user can choose.
557 An array of strings from which the user can choose.
559 If allowOthers is @true, the user can type a string not in choices
562 wxGridCellChoiceEditor(size_t count
= 0,
563 const wxString choices
[] = NULL
,
564 bool allowOthers
= false);
567 Choice cell renderer ctor.
570 An array of strings from which the user can choose.
572 If allowOthers is @true, the user can type a string not in choices
575 wxGridCellChoiceEditor(const wxArrayString
& choices
,
576 bool allowOthers
= false);
579 Parameters string format is "item1[,item2[...,itemN]]"
581 virtual void SetParameters(const wxString
& params
);
585 @class wxGridCellEnumEditor
587 Grid cell editor which displays an enum number as a textual equivalent
588 (eg. data in cell is 0,1,2 ... n the cell could be displayed as
589 "John","Fred"..."Bob" in the combo choice box).
594 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
595 wxGridCellBoolEditor, wxGridCellChoiceEditor,
596 wxGridCellTextEditor, wxGridCellFloatEditor,
597 wxGridCellNumberEditor
599 class wxGridCellEnumEditor
: public wxGridCellChoiceEditor
603 Enum cell editor ctor.
606 Comma separated choice parameters "item1[,item2[...,itemN]]".
608 wxGridCellEnumEditor( const wxString
& choices
= wxEmptyString
);
612 @class wxGridCellTextEditor
614 Grid cell editor for string/text data.
619 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
620 wxGridCellBoolEditor, wxGridCellChoiceEditor,
621 wxGridCellEnumEditor, wxGridCellFloatEditor,
622 wxGridCellNumberEditor
624 class wxGridCellTextEditor
: public wxGridCellEditor
630 wxGridCellTextEditor();
633 The parameters string format is "n" where n is a number representing
636 virtual void SetParameters(const wxString
& params
);
640 @class wxGridCellFloatEditor
642 The editor for floating point numbers data.
647 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
648 wxGridCellBoolEditor, wxGridCellChoiceEditor,
649 wxGridCellEnumEditor, wxGridCellNumberEditor,
652 class wxGridCellFloatEditor
: public wxGridCellTextEditor
656 Float cell editor ctor.
659 Minimum number of characters to be shown.
661 Number of digits after the decimal dot.
663 The format to use for displaying the number, a combination of
664 ::wxGridCellFloatFormat enum elements. This parameter is only
665 available since wxWidgets 2.9.3.
667 wxGridCellFloatEditor(int width
= -1, int precision
= -1,
668 int format
= wxGRID_FLOAT_FORMAT_DEFAULT
);
671 The parameters string format is "width[,precision[,format]]" where
672 @c format should be chosen between f|e|g|E|G (f is used by default)
674 virtual void SetParameters(const wxString
& params
);
678 @class wxGridCellNumberEditor
680 Grid cell editor for numeric integer data.
685 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
686 wxGridCellBoolEditor, wxGridCellChoiceEditor,
687 wxGridCellEnumEditor, wxGridCellFloatEditor,
690 class wxGridCellNumberEditor
: public wxGridCellTextEditor
694 Allows you to specify the range for acceptable data. Values equal to
695 -1 for both @a min and @a max indicate that no range checking should be
698 wxGridCellNumberEditor(int min
= -1, int max
= -1);
702 Parameters string format is "min,max".
704 virtual void SetParameters(const wxString
& params
);
709 If the return value is @true, the editor uses a wxSpinCtrl to get user
710 input, otherwise it uses a wxTextCtrl.
712 bool HasRange() const;
715 String representation of the value.
717 wxString
GetString() const;
723 @class wxGridCellAttr
725 This class can be used to alter the cells' appearance in the grid by
726 changing their attributes from the defaults. An object of this class may be
727 returned by wxGridTableBase::GetAttr().
732 class wxGridCellAttr
: public wxClientDataContainer
, public wxRefCounter
736 Kind of the attribute to retrieve.
738 @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr()
742 /// Return the combined effective attribute for the cell.
745 /// Return the attribute explicitly set for this cell.
748 /// Return the attribute set for this cells row.
751 /// Return the attribute set for this cells column.
758 wxGridCellAttr(wxGridCellAttr
* attrDefault
= NULL
);
760 Constructor specifying some of the often used attributes.
762 wxGridCellAttr(const wxColour
& colText
, const wxColour
& colBack
,
763 const wxFont
& font
, int hAlign
, int vAlign
);
766 Creates a new copy of this object.
768 wxGridCellAttr
* Clone() const;
771 This class is reference counted: it is created with ref count of 1, so
772 calling DecRef() once will delete it. Calling IncRef() allows to lock
773 it until the matching DecRef() is called.
778 Get the alignment to use for the cell with the given attribute.
780 If this attribute doesn't specify any alignment, the default attribute
781 alignment is used (which can be changed using
782 wxGrid::SetDefaultCellAlignment() but is left and top by default).
784 Notice that @a hAlign and @a vAlign values are always overwritten by
785 this function, use GetNonDefaultAlignment() if this is not desirable.
788 Horizontal alignment is returned here if this argument is non-@NULL.
789 It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.
791 Vertical alignment is returned here if this argument is non-@NULL.
792 It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
794 void GetAlignment(int* hAlign
, int* vAlign
) const;
797 Returns the background colour.
799 const wxColour
& GetBackgroundColour() const;
802 Returns the cell editor.
804 wxGridCellEditor
* GetEditor(const wxGrid
* grid
, int row
, int col
) const;
809 const wxFont
& GetFont() const;
812 Get the alignment defined by this attribute.
814 Unlike GetAlignment() this function only modifies @a hAlign and @a
815 vAlign if this attribute does define a non-default alignment. This
816 means that they must be initialized before calling this function and
817 that their values will be preserved unchanged if they are different
818 from wxALIGN_INVALID.
820 For example, the following fragment can be used to use the cell
821 alignment if one is defined but right-align its contents by default
822 (instead of left-aligning it by default) while still using the default
825 int hAlign = wxALIGN_RIGHT,
826 vAlign = wxALIGN_INVALID;
827 attr.GetNonDefaultAlignment(&hAlign, &vAlign);
832 void GetNonDefaultAlignment(int *hAlign
, int *vAlign
) const;
835 Returns the cell renderer.
837 wxGridCellRenderer
* GetRenderer(const wxGrid
* grid
, int row
, int col
) const;
840 Returns the text colour.
842 const wxColour
& GetTextColour() const;
845 Returns @true if this attribute has a valid alignment set.
847 bool HasAlignment() const;
850 Returns @true if this attribute has a valid background colour set.
852 bool HasBackgroundColour() const;
855 Returns @true if this attribute has a valid cell editor set.
857 bool HasEditor() const;
860 Returns @true if this attribute has a valid font set.
862 bool HasFont() const;
865 Returns @true if this attribute has a valid cell renderer set.
867 bool HasRenderer() const;
870 Returns @true if this attribute has a valid text colour set.
872 bool HasTextColour() const;
875 This class is reference counted: it is created with ref count of 1, so
876 calling DecRef() once will delete it. Calling IncRef() allows to lock
877 it until the matching DecRef() is called.
882 Returns @true if this cell is set as read-only.
884 bool IsReadOnly() const;
887 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
888 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of
889 @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
891 void SetAlignment(int hAlign
, int vAlign
);
894 Sets the background colour.
896 void SetBackgroundColour(const wxColour
& colBack
);
899 @todo Needs documentation.
901 void SetDefAttr(wxGridCellAttr
* defAttr
);
904 Sets the editor to be used with the cells with this attribute.
906 void SetEditor(wxGridCellEditor
* editor
);
911 void SetFont(const wxFont
& font
);
914 Sets the cell as read-only.
916 void SetReadOnly(bool isReadOnly
= true);
919 Sets the renderer to be used for cells with this attribute. Takes
920 ownership of the pointer.
922 void SetRenderer(wxGridCellRenderer
* renderer
);
925 Sets the text colour.
927 void SetTextColour(const wxColour
& colText
);
932 The destructor is private because only DecRef() can delete us.
934 virtual ~wxGridCellAttr();
938 Base class for corner window renderer.
940 This is the simplest of all header renderers and only has a single
943 @see wxGridCellAttrProvider::GetCornerRenderer()
947 class wxGridCornerHeaderRenderer
951 Called by the grid to draw the corner window border.
953 This method is responsible for drawing the border inside the given @a
954 rect and adjusting the rectangle size to correspond to the area inside
955 the border, i.e. usually call wxRect::Deflate() to account for the
959 The grid whose corner window is being drawn.
961 The device context to use for drawing.
963 Input/output parameter which contains the border rectangle on input
964 and should be updated to contain the area inside the border on
967 virtual void DrawBorder(const wxGrid
& grid
,
969 wxRect
& rect
) const = 0;
973 Common base class for row and column headers renderers.
975 @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer
979 class wxGridHeaderLabelsRenderer
: public wxGridCornerHeaderRenderer
983 Called by the grid to draw the specified label.
985 Notice that the base class DrawBorder() method is called before this
988 The default implementation uses wxGrid::GetLabelTextColour() and
989 wxGrid::GetLabelFont() to draw the label.
991 virtual void DrawLabel(const wxGrid
& grid
,
993 const wxString
& value
,
997 int textOrientation
) const;
1001 Base class for row headers renderer.
1003 This is the same as wxGridHeaderLabelsRenderer currently but we still use a
1004 separate class for it to distinguish it from wxGridColumnHeaderRenderer.
1006 @see wxGridRowHeaderRendererDefault
1008 @see wxGridCellAttrProvider::GetRowHeaderRenderer()
1012 class wxGridRowHeaderRenderer
: public wxGridHeaderLabelsRenderer
1017 Base class for column headers renderer.
1019 This is the same as wxGridHeaderLabelsRenderer currently but we still use a
1020 separate class for it to distinguish it from wxGridRowHeaderRenderer.
1022 @see wxGridColumnHeaderRendererDefault
1024 @see wxGridCellAttrProvider::GetColumnHeaderRenderer()
1028 class wxGridColumnHeaderRenderer
: public wxGridHeaderLabelsRenderer
1033 Default row header renderer.
1035 You may derive from this class if you need to only override one of its
1036 methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the
1037 default implementation for the other one.
1039 @see wxGridColumnHeaderRendererDefault
1043 class wxGridRowHeaderRendererDefault
: public wxGridRowHeaderRenderer
1046 /// Implement border drawing for the row labels.
1047 virtual void DrawBorder(const wxGrid
& grid
,
1049 wxRect
& rect
) const;
1053 Default column header renderer.
1055 @see wxGridRowHeaderRendererDefault
1059 class wxGridColumnHeaderRendererDefault
: public wxGridColumnHeaderRenderer
1062 /// Implement border drawing for the column labels.
1063 virtual void DrawBorder(const wxGrid
& grid
,
1065 wxRect
& rect
) const;
1069 Default corner window renderer.
1071 @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault
1075 class wxGridCornerHeaderRendererDefault
: public wxGridCornerHeaderRenderer
1078 /// Implement border drawing for the corner window.
1079 virtual void DrawBorder(const wxGrid
& grid
,
1081 wxRect
& rect
) const;
1085 Class providing attributes to be used for the grid cells.
1087 This class both defines an interface which grid cell attributes providers
1088 should implement -- and which can be implemented differently in derived
1089 classes -- and a default implementation of this interface which is often
1090 good enough to be used without modification, especially with not very large
1091 grids for which the efficiency of attributes storage hardly matters (see
1092 the discussion below).
1094 An object of this class can be associated with a wxGrid using
1095 wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you
1096 intend to use the default provider as it is used by wxGridTableBase by
1099 Notice that while attributes provided by this class can be set for
1100 individual cells using SetAttr() or the entire rows or columns using
1101 SetRowAttr() and SetColAttr() they are always retrieved using GetAttr()
1105 The default implementation of this class stores the attributes passed to
1106 its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A
1107 derived class may use its knowledge about how the attributes are used in
1108 your program to implement it much more efficiently: for example, using a
1109 special background colour for all even-numbered rows can be implemented by
1110 simply returning the same attribute from GetAttr() if the row number is
1111 even instead of having to store N/2 row attributes where N is the total
1112 number of rows in the grid.
1114 Notice that objects of this class can't be copied.
1116 class wxGridCellAttrProvider
: public wxClientDataContainer
1119 /// Trivial default constructor.
1120 wxGridCellAttrProvider();
1122 /// Destructor releases any attributes held by this class.
1123 virtual ~wxGridCellAttrProvider();
1126 Get the attribute to use for the specified cell.
1128 If wxGridCellAttr::Any is used as @a kind value, this function combines
1129 the attributes set for this cell using SetAttr() and those for its row
1130 or column (set with SetRowAttr() or SetColAttr() respectively), with
1131 the cell attribute having the highest precedence.
1133 Notice that the caller must call DecRef() on the returned pointer if it
1137 The row of the cell.
1139 The column of the cell.
1141 The kind of the attribute to return.
1143 The attribute to use which should be DecRef()'d by caller or @NULL
1144 if no attributes are defined for this cell.
1146 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
1147 wxGridCellAttr::wxAttrKind kind
) const;
1152 All these functions take ownership of the attribute passed to them,
1153 i.e. will call DecRef() on it themselves later and so it should not be
1154 destroyed by the caller. And the attribute can be @NULL to reset a
1155 previously set value.
1159 /// Set attribute for the specified cell.
1160 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
1162 /// Set attribute for the specified row.
1163 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
1165 /// Set attribute for the specified column.
1166 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
1171 Getting header renderers.
1173 These functions return the renderers for the given row or column header
1174 label and the corner window. Unlike cell attributes, these objects are
1175 not reference counted and are never @NULL so they are returned by
1176 reference and not pointer and DecRef() shouldn't (and can't) be called
1179 All these functions were added in wxWidgets 2.9.1.
1184 Return the renderer used for drawing column headers.
1186 By default wxGridColumnHeaderRendererDefault is returned.
1188 @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader()
1192 virtual const wxGridColumnHeaderRenderer
& GetColumnHeaderRenderer(int col
);
1195 Return the renderer used for drawing row headers.
1197 By default wxGridRowHeaderRendererDefault is returned.
1201 virtual const wxGridRowHeaderRenderer
& GetRowHeaderRenderer(int row
);
1204 Return the renderer used for drawing the corner window.
1206 By default wxGridCornerHeaderRendererDefault is returned.
1210 virtual const wxGridCornerHeaderRenderer
& GetCornerRenderer();
1216 Represents coordinates of a grid cell.
1218 An object of this class is simply a (row, column) pair.
1220 class wxGridCellCoords
1224 Default constructor initializes the object to invalid state.
1226 Initially the row and column are both invalid (-1) and so operator!()
1227 for an uninitialized wxGridCellCoords returns false.
1232 Constructor taking a row and a column.
1234 wxGridCellCoords(int row
, int col
);
1237 Return the row of the coordinate.
1242 Set the row of the coordinate.
1247 Return the column of the coordinate.
1252 Set the column of the coordinate.
1257 Set the row and column of the coordinate.
1259 void Set(int row
, int col
);
1262 Assignment operator for coordinate types.
1264 wxGridCellCoords
& operator=(const wxGridCellCoords
& other
);
1269 bool operator==(const wxGridCellCoords
& other
) const;
1272 Inequality operator.
1274 bool operator!=(const wxGridCellCoords
& other
) const;
1277 Checks whether the coordinates are invalid.
1279 Returns false only if both row and column are -1. Notice that if either
1280 row or column (but not both) are -1, this method returns true even if
1281 the object is invalid. This is done because objects in such state
1282 should actually never exist, i.e. either both coordinates should be -1
1283 or none of them should be -1.
1285 bool operator!() const;
1289 @class wxGridTableBase
1291 The almost abstract base class for grid tables.
1293 A grid table is responsible for storing the grid data and, indirectly, grid
1294 cell attributes. The data can be stored in the way most convenient for the
1295 application but has to be provided in string form to wxGrid. It is also
1296 possible to provide cells values in other formats if appropriate, e.g. as
1299 This base class is not quite abstract as it implements a trivial strategy
1300 for storing the attributes by forwarding it to wxGridCellAttrProvider and
1301 also provides stubs for some other functions. However it does have a number
1302 of pure virtual methods which must be implemented in the derived classes.
1304 @see wxGridStringTable
1309 class wxGridTableBase
: public wxObject
1313 Default constructor.
1318 Destructor frees the attribute provider if it was created.
1320 virtual ~wxGridTableBase();
1323 Must be overridden to return the number of rows in the table.
1325 For backwards compatibility reasons, this method is not const.
1326 Use GetRowsCount() instead of it in const methods of derived table
1329 virtual int GetNumberRows() = 0;
1332 Must be overridden to return the number of columns in the table.
1334 For backwards compatibility reasons, this method is not const.
1335 Use GetColsCount() instead of it in const methods of derived table
1338 virtual int GetNumberCols() = 0;
1341 Return the number of rows in the table.
1343 This method is not virtual and is only provided as a convenience for
1344 the derived classes which can't call GetNumberRows() without a
1345 @c const_cast from their const methods.
1347 int GetRowsCount() const;
1350 Return the number of columns in the table.
1352 This method is not virtual and is only provided as a convenience for
1353 the derived classes which can't call GetNumberCols() without a
1354 @c const_cast from their const methods.
1356 int GetColsCount() const;
1360 @name Table Cell Accessors
1365 May be overridden to implement testing for empty cells.
1367 This method is used by the grid to test if the given cell is not used
1368 and so whether a neighbouring cell may overflow into it. By default it
1369 only returns true if the value of the given cell, as returned by
1370 GetValue(), is empty.
1372 virtual bool IsEmptyCell(int row
, int col
);
1375 Same as IsEmptyCell() but taking wxGridCellCoords.
1377 Notice that this method is not virtual, only IsEmptyCell() should be
1380 bool IsEmpty(const wxGridCellCoords
& coords
);
1383 Must be overridden to implement accessing the table values as text.
1385 virtual wxString
GetValue(int row
, int col
) = 0;
1388 Must be overridden to implement setting the table values as text.
1390 virtual void SetValue(int row
, int col
, const wxString
& value
) = 0;
1393 Returns the type of the value in the given cell.
1395 By default all cells are strings and this method returns
1396 @c wxGRID_VALUE_STRING.
1398 virtual wxString
GetTypeName(int row
, int col
);
1401 Returns true if the value of the given cell can be accessed as if it
1402 were of the specified type.
1404 By default the cells can only be accessed as strings. Note that a cell
1405 could be accessible in different ways, e.g. a numeric cell may return
1406 @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
1407 indicating that the value can be coerced to a string form.
1409 virtual bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
1412 Returns true if the value of the given cell can be set as if it were of
1415 @see CanGetValueAs()
1417 virtual bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
1420 Returns the value of the given cell as a long.
1422 This should only be called if CanGetValueAs() returns @true when called
1423 with @c wxGRID_VALUE_NUMBER argument. Default implementation always
1426 virtual long GetValueAsLong(int row
, int col
);
1429 Returns the value of the given cell as a double.
1431 This should only be called if CanGetValueAs() returns @true when called
1432 with @c wxGRID_VALUE_FLOAT argument. Default implementation always
1435 virtual double GetValueAsDouble(int row
, int col
);
1438 Returns the value of the given cell as a boolean.
1440 This should only be called if CanGetValueAs() returns @true when called
1441 with @c wxGRID_VALUE_BOOL argument. Default implementation always
1444 virtual bool GetValueAsBool(int row
, int col
);
1447 Returns the value of the given cell as a user-defined type.
1449 This should only be called if CanGetValueAs() returns @true when called
1450 with @a typeName. Default implementation always return @NULL.
1452 virtual void *GetValueAsCustom(int row
, int col
, const wxString
& typeName
);
1455 Sets the value of the given cell as a long.
1457 This should only be called if CanSetValueAs() returns @true when called
1458 with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
1461 virtual void SetValueAsLong(int row
, int col
, long value
);
1464 Sets the value of the given cell as a double.
1466 This should only be called if CanSetValueAs() returns @true when called
1467 with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
1470 virtual void SetValueAsDouble(int row
, int col
, double value
);
1473 Sets the value of the given cell as a boolean.
1475 This should only be called if CanSetValueAs() returns @true when called
1476 with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
1479 virtual void SetValueAsBool( int row
, int col
, bool value
);
1482 Sets the value of the given cell as a user-defined type.
1484 This should only be called if CanSetValueAs() returns @true when called
1485 with @a typeName. Default implementation doesn't do anything.
1487 virtual void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
1494 Called by the grid when the table is associated with it.
1496 The default implementation stores the pointer and returns it from its
1497 GetView() and so only makes sense if the table cannot be associated
1498 with more than one grid at a time.
1500 virtual void SetView(wxGrid
*grid
);
1503 Returns the last grid passed to SetView().
1505 virtual wxGrid
*GetView() const;
1509 @name Table Structure Modifiers
1511 Notice that none of these functions are pure virtual as they don't have
1512 to be implemented if the table structure is never modified after
1513 creation, i.e. neither rows nor columns are never added or deleted but
1514 that you do need to implement them if they are called, i.e. if your
1515 code either calls them directly or uses the matching wxGrid methods, as
1516 by default they simply do nothing which is definitely inappropriate.
1521 Clear the table contents.
1523 This method is used by wxGrid::ClearGrid().
1525 virtual void Clear();
1528 Insert additional rows into the table.
1531 The position of the first new row.
1533 The number of rows to insert.
1535 virtual bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
1538 Append additional rows at the end of the table.
1540 This method is provided in addition to InsertRows() as some data models
1541 may only support appending rows to them but not inserting them at
1542 arbitrary locations. In such case you may implement this method only
1543 and leave InsertRows() unimplemented.
1546 The number of rows to add.
1548 virtual bool AppendRows(size_t numRows
= 1);
1551 Delete rows from the table.
1553 Notice that currently deleting a row intersecting a multi-cell (see
1554 SetCellSize()) is not supported and will result in a crash.
1557 The first row to delete.
1559 The number of rows to delete.
1561 virtual bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
1564 Exactly the same as InsertRows() but for columns.
1566 virtual bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
1569 Exactly the same as AppendRows() but for columns.
1571 virtual bool AppendCols(size_t numCols
= 1);
1574 Exactly the same as DeleteRows() but for columns.
1576 virtual bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
1581 @name Table Row and Column Labels
1583 By default the numbers are used for labeling rows and Latin letters for
1584 labeling columns. If the table has more than 26 columns, the pairs of
1585 letters are used starting from the 27-th one and so on, i.e. the
1586 sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
1592 Return the label of the specified row.
1594 virtual wxString
GetRowLabelValue(int row
);
1597 Return the label of the specified column.
1599 virtual wxString
GetColLabelValue(int col
);
1602 Set the given label for the specified row.
1604 The default version does nothing, i.e. the label is not stored. You
1605 must override this method in your derived class if you wish
1606 wxGrid::SetRowLabelValue() to work.
1608 virtual void SetRowLabelValue(int row
, const wxString
& label
);
1611 Exactly the same as SetRowLabelValue() but for columns.
1613 virtual void SetColLabelValue(int col
, const wxString
& label
);
1619 @name Attributes Management
1621 By default the attributes management is delegated to
1622 wxGridCellAttrProvider class. You may override the methods in this
1623 section to handle the attributes directly if, for example, they can be
1624 computed from the cell values.
1629 Associate this attributes provider with the table.
1631 The table takes ownership of @a attrProvider pointer and will delete it
1632 when it doesn't need it any more. The pointer can be @NULL, however
1633 this won't disable attributes management in the table but will just
1634 result in a default attributes being recreated the next time any of the
1635 other functions in this section is called. To completely disable the
1636 attributes support, should this be needed, you need to override
1637 CanHaveAttributes() to return @false.
1639 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
1642 Returns the attribute provider currently being used.
1644 This function may return @NULL if the attribute provider hasn't been
1645 neither associated with this table by SetAttrProvider() nor created on
1646 demand by any other methods.
1648 wxGridCellAttrProvider
*GetAttrProvider() const;
1651 Return the attribute for the given cell.
1653 By default this function is simply forwarded to
1654 wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
1655 attributes directly in the table.
1657 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
1658 wxGridCellAttr::wxAttrKind kind
);
1661 Set attribute of the specified cell.
1663 By default this function is simply forwarded to
1664 wxGridCellAttrProvider::SetAttr().
1666 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1668 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
1671 Set attribute of the specified row.
1673 By default this function is simply forwarded to
1674 wxGridCellAttrProvider::SetRowAttr().
1676 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1678 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
1681 Set attribute of the specified column.
1683 By default this function is simply forwarded to
1684 wxGridCellAttrProvider::SetColAttr().
1686 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1688 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
1693 Returns true if this table supports attributes or false otherwise.
1695 By default, the table automatically creates a wxGridCellAttrProvider
1696 when this function is called if it had no attribute provider before and
1699 virtual bool CanHaveAttributes();
1704 enum wxGridTableRequest
1706 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
1707 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
1708 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
1709 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
1710 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
1711 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
1712 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
1713 wxGRIDTABLE_NOTIFY_COLS_DELETED
1718 @class wxGridTableMessage
1720 A simple class used to pass messages from the table to the grid.
1725 class wxGridTableMessage
1728 wxGridTableMessage();
1729 wxGridTableMessage( wxGridTableBase
*table
, int id
,
1733 void SetTableObject( wxGridTableBase
*table
);
1734 wxGridTableBase
* GetTableObject() const;
1735 void SetId( int id
);
1737 void SetCommandInt( int comInt1
);
1738 int GetCommandInt();
1739 void SetCommandInt2( int comInt2
);
1740 int GetCommandInt2();
1746 @class wxGridStringTable
1748 Simplest type of data table for a grid for small tables of strings
1749 that are stored in memory
1751 class wxGridStringTable
: public wxGridTableBase
1754 wxGridStringTable();
1755 wxGridStringTable( int numRows
, int numCols
);
1757 // these are pure virtual in wxGridTableBase
1758 virtual int GetNumberRows();
1759 virtual int GetNumberCols();
1760 virtual wxString
GetValue( int row
, int col
);
1761 virtual void SetValue( int row
, int col
, const wxString
& value
);
1763 // overridden functions from wxGridTableBase
1765 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
1766 bool AppendRows( size_t numRows
= 1 );
1767 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
1768 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
1769 bool AppendCols( size_t numCols
= 1 );
1770 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
1772 void SetRowLabelValue( int row
, const wxString
& );
1773 void SetColLabelValue( int col
, const wxString
& );
1774 wxString
GetRowLabelValue( int row
);
1775 wxString
GetColLabelValue( int col
);
1784 @class wxGridSizesInfo
1786 wxGridSizesInfo stores information about sizes of all wxGrid rows or
1789 It assumes that most of the rows or columns (which are both called elements
1790 here as the difference between them doesn't matter at this class level)
1791 have the default size and so stores it separately. And it uses a wxHashMap
1792 to store the sizes of all elements which have the non-default size.
1794 This structure is particularly useful for serializing the sizes of all
1795 wxGrid elements at once.
1800 struct wxGridSizesInfo
1803 Default constructor.
1805 m_sizeDefault and m_customSizes must be initialized later.
1812 This constructor is used by wxGrid::GetRowSizes() and GetColSizes()
1813 methods. User code will usually use the default constructor instead.
1816 The default element size.
1818 Array containing the sizes of @em all elements, including those
1819 which have the default size.
1821 wxGridSizesInfo(int defSize
, const wxArrayInt
& allSizes
);
1824 Get the element size.
1827 The index of the element.
1829 The size for this element, using m_customSizes if @a pos is in it
1830 or m_sizeDefault otherwise.
1832 int GetSize(unsigned pos
) const;
1839 Map with element indices as keys and their sizes as values.
1841 This map only contains the elements with non-default size.
1843 wxUnsignedToIntHashMap m_customSizes
;
1849 Rendering styles supported by wxGrid::Render() method.
1853 enum wxGridRenderStyle
1855 /// Draw grid row header labels.
1856 wxGRID_DRAW_ROWS_HEADER
= 0x001,
1858 /// Draw grid column header labels.
1859 wxGRID_DRAW_COLS_HEADER
= 0x002,
1861 /// Draw grid cell border lines.
1862 wxGRID_DRAW_CELL_LINES
= 0x004,
1865 Draw a bounding rectangle around the rendered cell area.
1867 Useful where row or column headers are not drawn or where there is
1868 multi row or column cell clipping and therefore no cell border at
1869 the rendered outer boundary.
1871 wxGRID_DRAW_BOX_RECT
= 0x008,
1874 Draw the grid cell selection highlight if a selection is present.
1876 At present the highlight colour drawn depends on whether the grid
1877 window loses focus before drawing begins.
1879 wxGRID_DRAW_SELECTION
= 0x010,
1882 The default render style.
1884 Includes all except wxGRID_DRAW_SELECTION.
1886 wxGRID_DRAW_DEFAULT
= wxGRID_DRAW_ROWS_HEADER
|
1887 wxGRID_DRAW_COLS_HEADER
|
1888 wxGRID_DRAW_CELL_LINES
|
1889 wxGRID_DRAW_BOX_RECT
1897 wxGrid and its related classes are used for displaying and editing tabular
1898 data. They provide a rich set of features for display, editing, and
1899 interacting with a variety of data sources. For simple applications, and to
1900 help you get started, wxGrid is the only class you need to refer to
1901 directly. It will set up default instances of the other classes and manage
1902 them for you. For more complex applications you can derive your own classes
1903 for custom grid views, grid data tables, cell editors and renderers. The
1904 @ref overview_grid has examples of simple and more complex applications,
1905 explains the relationship between the various grid classes and has a
1906 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1908 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1909 class. One or more wxGrid classes may act as a view for one table class.
1910 The default table class is called wxGridStringTable and holds an array of
1911 strings. An instance of such a class is created by CreateGrid().
1913 wxGridCellRenderer is the abstract base class for rendering contents in a
1914 cell. The following renderers are predefined:
1916 - wxGridCellBoolRenderer
1917 - wxGridCellFloatRenderer
1918 - wxGridCellNumberRenderer
1919 - wxGridCellStringRenderer
1921 The look of a cell can be further defined using wxGridCellAttr. An object
1922 of this type may be returned by wxGridTableBase::GetAttr().
1924 wxGridCellEditor is the abstract base class for editing the value of a
1925 cell. The following editors are predefined:
1927 - wxGridCellBoolEditor
1928 - wxGridCellChoiceEditor
1929 - wxGridCellFloatEditor
1930 - wxGridCellNumberEditor
1931 - wxGridCellTextEditor
1933 Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and
1934 wxGridEditorCreatedEvent for the documentation of all event types you can
1940 @see @ref overview_grid, wxGridUpdateLocker
1942 class wxGrid
: public wxScrolledWindow
1947 Different selection modes supported by the grid.
1949 enum wxGridSelectionModes
1952 The default selection mode allowing selection of the individual
1953 cells as well as of the entire rows and columns.
1958 The selection mode allowing the selection of the entire rows only.
1960 The user won't be able to select any cells or columns in this mode.
1965 The selection mode allowing the selection of the entire columns only.
1967 The user won't be able to select any cells or rows in this mode.
1969 wxGridSelectColumns
,
1972 The selection mode allowing the user to select either the entire
1973 columns or the entire rows but not individual cells nor blocks.
1975 Notice that while this constant is defined as @code
1976 wxGridSelectColumns | wxGridSelectRows @endcode this doesn't mean
1977 that all the other combinations are valid -- at least currently
1982 wxGridSelectRowsOrColumns
1986 Return values for GetCellSize().
1992 /// This cell is inside a span covered by another cell.
1993 CellSpan_Inside
= -1,
1995 /// This is a normal, non-spanning cell.
1998 /// This cell spans several physical wxGrid cells.
2003 Constants defining different support built-in TAB handling behaviours.
2005 The elements of this enum determine what happens when TAB is pressed
2006 when the cursor is in the rightmost column (or Shift-TAB is pressed
2007 when the cursor is in the leftmost one).
2009 @see SetTabBehaviour(), @c wxEVT_GRID_TABBING
2015 /// Do nothing, this is default.
2018 /// Move to the beginning of the next (or the end of the previous) row.
2021 /// Move to the next (or the previous) control after the grid.
2026 @name Constructors and Initialization
2031 Default constructor.
2033 You must call Create() to really create the grid window and also call
2034 CreateGrid() or SetTable() to initialize the grid contents.
2038 Constructor creating the grid window.
2040 You must call either CreateGrid() or SetTable() to initialize the grid
2041 contents before using it.
2043 wxGrid(wxWindow
* parent
, wxWindowID id
,
2044 const wxPoint
& pos
= wxDefaultPosition
,
2045 const wxSize
& size
= wxDefaultSize
,
2046 long style
= wxWANTS_CHARS
,
2047 const wxString
& name
= wxGridNameStr
);
2052 This will also destroy the associated grid table unless you passed a
2053 table object to the grid and specified that the grid should not take
2054 ownership of the table (see SetTable()).
2059 Creates the grid window for an object initialized using the default
2062 You must call either CreateGrid() or SetTable() to initialize the grid
2063 contents before using it.
2065 bool Create(wxWindow
* parent
, wxWindowID id
,
2066 const wxPoint
& pos
= wxDefaultPosition
,
2067 const wxSize
& size
= wxDefaultSize
,
2068 long style
= wxWANTS_CHARS
,
2069 const wxString
& name
= wxGridNameStr
);
2072 Creates a grid with the specified initial number of rows and columns.
2074 Call this directly after the grid constructor. When you use this
2075 function wxGrid will create and manage a simple table of string values
2076 for you. All of the grid data will be stored in memory.
2078 For applications with more complex data types or relationships, or for
2079 dealing with very large datasets, you should derive your own grid table
2080 class and pass a table object to the grid with SetTable().
2082 bool CreateGrid(int numRows
, int numCols
,
2083 wxGridSelectionModes selmode
= wxGridSelectCells
);
2086 Passes a pointer to a custom grid table to be used by the grid.
2088 This should be called after the grid constructor and before using the
2089 grid object. If @a takeOwnership is set to @true then the table will be
2090 deleted by the wxGrid destructor.
2092 Use this function instead of CreateGrid() when your application
2093 involves complex or non-string data or data sets that are too large to
2094 fit wholly in memory.
2096 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= false,
2097 wxGridSelectionModes selmode
= wxGridSelectCells
);
2100 Receive and handle a message from the table.
2102 bool ProcessTableMessage(wxGridTableMessage
& msg
);
2108 @name Grid Line Formatting
2113 Turns the drawing of grid lines on or off.
2115 void EnableGridLines(bool enable
= true);
2118 Returns the pen used for vertical grid lines.
2120 This virtual function may be overridden in derived classes in order to
2121 change the appearance of individual grid lines for the given column
2124 See GetRowGridLinePen() for an example.
2126 virtual wxPen
GetColGridLinePen(int col
);
2129 Returns the pen used for grid lines.
2131 This virtual function may be overridden in derived classes in order to
2132 change the appearance of grid lines. Note that currently the pen width
2135 @see GetColGridLinePen(), GetRowGridLinePen()
2137 virtual wxPen
GetDefaultGridLinePen();
2140 Returns the colour used for grid lines.
2142 @see GetDefaultGridLinePen()
2144 wxColour
GetGridLineColour() const;
2147 Returns the pen used for horizontal grid lines.
2149 This virtual function may be overridden in derived classes in order to
2150 change the appearance of individual grid line for the given @a row.
2154 // in a grid displaying music notation, use a solid black pen between
2155 // octaves (C0=row 127, C1=row 115 etc.)
2156 wxPen MidiGrid::GetRowGridLinePen(int row)
2158 if ( row % 12 == 7 )
2159 return wxPen(*wxBLACK, 1, wxSOLID);
2161 return GetDefaultGridLinePen();
2165 virtual wxPen
GetRowGridLinePen(int row
);
2168 Returns @true if drawing of grid lines is turned on, @false otherwise.
2170 bool GridLinesEnabled() const;
2173 Sets the colour used to draw grid lines.
2175 void SetGridLineColour(const wxColour
& colour
);
2181 @name Label Values and Formatting
2186 Sets the arguments to the current column label alignment values.
2188 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2189 or @c wxALIGN_RIGHT.
2191 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2194 void GetColLabelAlignment(int* horiz
, int* vert
) const;
2197 Returns the orientation of the column labels (either @c wxHORIZONTAL or
2200 int GetColLabelTextOrientation() const;
2203 Returns the specified column label.
2205 The default grid table class provides column labels of the form
2206 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
2207 override wxGridTableBase::GetColLabelValue() to provide your own
2210 wxString
GetColLabelValue(int col
) const;
2213 Returns the colour used for the background of row and column labels.
2215 wxColour
GetLabelBackgroundColour() const;
2218 Returns the font used for row and column labels.
2220 wxFont
GetLabelFont() const;
2223 Returns the colour used for row and column label text.
2225 wxColour
GetLabelTextColour() const;
2228 Returns the alignment used for row labels.
2230 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2231 or @c wxALIGN_RIGHT.
2233 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2236 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
2239 Returns the specified row label.
2241 The default grid table class provides numeric row labels. If you are
2242 using a custom grid table you can override
2243 wxGridTableBase::GetRowLabelValue() to provide your own labels.
2245 wxString
GetRowLabelValue(int row
) const;
2248 Hides the column labels by calling SetColLabelSize() with a size of 0.
2249 Show labels again by calling that method with a width greater than 0.
2251 void HideColLabels();
2254 Hides the row labels by calling SetRowLabelSize() with a size of 0.
2256 The labels can be shown again by calling SetRowLabelSize() with a width
2259 void HideRowLabels();
2262 Sets the horizontal and vertical alignment of column label text.
2264 Horizontal alignment should be one of @c wxALIGN_LEFT,
2265 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2266 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2268 void SetColLabelAlignment(int horiz
, int vert
);
2271 Sets the orientation of the column labels (either @c wxHORIZONTAL or
2274 void SetColLabelTextOrientation(int textOrientation
);
2277 Set the value for the given column label.
2279 If you are using a custom grid table you must override
2280 wxGridTableBase::SetColLabelValue() for this to have any effect.
2282 void SetColLabelValue(int col
, const wxString
& value
);
2285 Sets the background colour for row and column labels.
2287 void SetLabelBackgroundColour(const wxColour
& colour
);
2290 Sets the font for row and column labels.
2292 void SetLabelFont(const wxFont
& font
);
2295 Sets the colour for row and column label text.
2297 void SetLabelTextColour(const wxColour
& colour
);
2300 Sets the horizontal and vertical alignment of row label text.
2302 Horizontal alignment should be one of @c wxALIGN_LEFT,
2303 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2304 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2306 void SetRowLabelAlignment(int horiz
, int vert
);
2309 Sets the value for the given row label.
2311 If you are using a derived grid table you must override
2312 wxGridTableBase::SetRowLabelValue() for this to have any effect.
2314 void SetRowLabelValue(int row
, const wxString
& value
);
2317 Call this in order to make the column labels use a native look by using
2318 wxRendererNative::DrawHeaderButton() internally.
2320 There is no equivalent method for drawing row columns as there is not
2321 native look for that. This option is useful when using wxGrid for
2322 displaying tables and not as a spread-sheet.
2324 @see UseNativeColHeader()
2326 void SetUseNativeColLabels(bool native
= true);
2329 Enable the use of native header window for column labels.
2331 If this function is called with @true argument, a wxHeaderCtrl is used
2332 instead to display the column labels instead of drawing them in wxGrid
2333 code itself. This has the advantage of making the grid look and feel
2334 perfectly the same as native applications (using SetUseNativeColLabels()
2335 the grid can be made to look more natively but it still doesn't feel
2336 natively, notably the column resizing and dragging still works slightly
2337 differently as it is implemented in wxWidgets itself) but results in
2338 different behaviour for column and row headers, for which there is no
2339 equivalent function, and, most importantly, is unsuitable for grids
2340 with huge numbers of columns as wxHeaderCtrl doesn't support virtual
2341 mode. Because of this, by default the grid does not use the native
2342 header control but you should call this function to enable it if you
2343 are using the grid to display tabular data and don't have thousands of
2346 Another difference between the default behaviour and the native header
2347 behaviour is that the latter provides the user with a context menu
2348 (which appears on right clicking the header) allowing to rearrange the
2349 grid columns if CanDragColMove() returns @true. If you want to prevent
2350 this from happening for some reason, you need to define a handler for
2351 @c wxEVT_GRID_LABEL_RIGHT_CLICK event which simply does nothing (in
2352 particular doesn't skip the event) as this will prevent the default
2353 right click handling from working.
2355 Also note that currently @c wxEVT_GRID_LABEL_RIGHT_DCLICK event is not
2356 generated for the column labels if the native columns header is used
2357 (but this limitation could possibly be lifted in the future).
2359 void UseNativeColHeader(bool native
= true);
2365 @name Cell Formatting
2367 Note that wxGridCellAttr can be used alternatively to most of these
2368 methods. See the "Attributes Management" of wxGridTableBase.
2373 Sets the arguments to the horizontal and vertical text alignment values
2374 for the grid cell at the specified location.
2376 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2377 or @c wxALIGN_RIGHT.
2379 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2382 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
2385 Returns the background colour of the cell at the specified location.
2387 wxColour
GetCellBackgroundColour(int row
, int col
) const;
2390 Returns the font for text in the grid cell at the specified location.
2392 wxFont
GetCellFont(int row
, int col
) const;
2395 Returns the text colour for the grid cell at the specified location.
2397 wxColour
GetCellTextColour(int row
, int col
) const;
2400 Returns the default cell alignment.
2402 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2403 or @c wxALIGN_RIGHT.
2405 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2408 @see SetDefaultCellAlignment()
2410 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
2413 Returns the current default background colour for grid cells.
2415 wxColour
GetDefaultCellBackgroundColour() const;
2418 Returns the current default font for grid cell text.
2420 wxFont
GetDefaultCellFont() const;
2423 Returns the current default colour for grid cell text.
2425 wxColour
GetDefaultCellTextColour() const;
2428 Sets the horizontal and vertical alignment for grid cell text at the
2431 Horizontal alignment should be one of @c wxALIGN_LEFT,
2432 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2434 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2435 or @c wxALIGN_BOTTOM.
2437 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2439 Sets the horizontal and vertical alignment for grid cell text at the
2442 Horizontal alignment should be one of @c wxALIGN_LEFT,
2443 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2445 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2446 or @c wxALIGN_BOTTOM.
2448 void SetCellAlignment(int align
, int row
, int col
);
2451 Set the background colour for the given cell or all cells by default.
2453 void SetCellBackgroundColour(int row
, int col
, const wxColour
& colour
);
2456 Sets the font for text in the grid cell at the specified location.
2458 void SetCellFont(int row
, int col
, const wxFont
& font
);
2461 Sets the text colour for the given cell.
2463 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2465 Sets the text colour for the given cell.
2467 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2469 Sets the text colour for all cells by default.
2471 void SetCellTextColour(const wxColour
& colour
);
2474 Sets the default horizontal and vertical alignment for grid cell text.
2476 Horizontal alignment should be one of @c wxALIGN_LEFT,
2477 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2478 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2480 void SetDefaultCellAlignment(int horiz
, int vert
);
2483 Sets the default background colour for grid cells.
2485 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2488 Sets the default font to be used for grid cell text.
2490 void SetDefaultCellFont(const wxFont
& font
);
2493 Sets the current default colour for grid cell text.
2495 void SetDefaultCellTextColour(const wxColour
& colour
);
2501 @name Cell Values, Editors, and Renderers
2503 Note that wxGridCellAttr can be used alternatively to most of these
2504 methods. See the "Attributes Management" of wxGridTableBase.
2509 Returns @true if the in-place edit control for the current grid cell
2510 can be used and @false otherwise.
2512 This function always returns @false for the read-only cells.
2514 bool CanEnableCellControl() const;
2517 Disables in-place editing of grid cells.
2519 Equivalent to calling EnableCellEditControl(@false).
2521 void DisableCellEditControl();
2524 Enables or disables in-place editing of grid cell data.
2526 The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or
2527 @c wxEVT_GRID_EDITOR_HIDDEN event.
2529 void EnableCellEditControl(bool enable
= true);
2532 Makes the grid globally editable or read-only.
2534 If the edit argument is @false this function sets the whole grid as
2535 read-only. If the argument is @true the grid is set to the default
2536 state where cells may be editable. In the default state you can set
2537 single grid cells and whole rows and columns to be editable or
2538 read-only via wxGridCellAttr::SetReadOnly(). For single cells you
2539 can also use the shortcut function SetReadOnly().
2541 For more information about controlling grid cell attributes see the
2542 wxGridCellAttr class and the @ref overview_grid.
2544 void EnableEditing(bool edit
);
2547 Returns a pointer to the editor for the cell at the specified location.
2549 See wxGridCellEditor and the @ref overview_grid for more information
2550 about cell editors and renderers.
2552 The caller must call DecRef() on the returned pointer.
2554 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
2557 Returns a pointer to the renderer for the grid cell at the specified
2560 See wxGridCellRenderer and the @ref overview_grid for more information
2561 about cell editors and renderers.
2563 The caller must call DecRef() on the returned pointer.
2565 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
2568 Returns the string contained in the cell at the specified location.
2570 For simple applications where a grid object automatically uses a
2571 default grid table of string values you use this function together with
2572 SetCellValue() to access cell values. For more complex applications
2573 where you have derived your own grid table class that contains various
2574 data types (e.g. numeric, boolean or user-defined custom types) then
2575 you only use this function for those cells that contain string values.
2577 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
2580 wxString
GetCellValue(int row
, int col
) const;
2582 Returns the string contained in the cell at the specified location.
2584 For simple applications where a grid object automatically uses a
2585 default grid table of string values you use this function together with
2586 SetCellValue() to access cell values. For more complex applications
2587 where you have derived your own grid table class that contains various
2588 data types (e.g. numeric, boolean or user-defined custom types) then
2589 you only use this function for those cells that contain string values.
2591 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
2594 wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
2597 Returns a pointer to the current default grid cell editor.
2599 See wxGridCellEditor and the @ref overview_grid for more information
2600 about cell editors and renderers.
2602 wxGridCellEditor
* GetDefaultEditor() const;
2605 Returns the default editor for the specified cell.
2607 The base class version returns the editor appropriate for the current
2608 cell type but this method may be overridden in the derived classes to
2609 use custom editors for some cells by default.
2611 Notice that the same may be achieved in a usually simpler way by
2612 associating a custom editor with the given cell or cells.
2614 The caller must call DecRef() on the returned pointer.
2616 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
2618 Returns the default editor for the specified cell.
2620 The base class version returns the editor appropriate for the current
2621 cell type but this method may be overridden in the derived classes to
2622 use custom editors for some cells by default.
2624 Notice that the same may be achieved in a usually simpler way by
2625 associating a custom editor with the given cell or cells.
2627 The caller must call DecRef() on the returned pointer.
2629 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
2632 Returns the default editor for the cells containing values of the given
2635 The base class version returns the editor which was associated with the
2636 specified @a typeName when it was registered RegisterDataType() but
2637 this function may be overridden to return something different. This
2638 allows to override an editor used for one of the standard types.
2640 The caller must call DecRef() on the returned pointer.
2642 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
2645 Returns a pointer to the current default grid cell renderer.
2647 See wxGridCellRenderer and the @ref overview_grid for more information
2648 about cell editors and renderers.
2650 The caller must call DecRef() on the returned pointer.
2652 wxGridCellRenderer
* GetDefaultRenderer() const;
2655 Returns the default renderer for the given cell.
2657 The base class version returns the renderer appropriate for the current
2658 cell type but this method may be overridden in the derived classes to
2659 use custom renderers for some cells by default.
2661 The caller must call DecRef() on the returned pointer.
2663 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
2666 Returns the default renderer for the cell containing values of the
2669 @see GetDefaultEditorForType()
2671 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
2674 Hides the in-place cell edit control.
2676 void HideCellEditControl();
2679 Returns @true if the in-place edit control is currently enabled.
2681 bool IsCellEditControlEnabled() const;
2684 Returns @true if the current cell is read-only.
2686 @see SetReadOnly(), IsReadOnly()
2688 bool IsCurrentCellReadOnly() const;
2691 Returns @false if the whole grid has been set as read-only or @true
2694 See EnableEditing() for more information about controlling the editing
2695 status of grid cells.
2697 bool IsEditable() const;
2700 Returns @true if the cell at the specified location can't be edited.
2702 @see SetReadOnly(), IsCurrentCellReadOnly()
2704 bool IsReadOnly(int row
, int col
) const;
2707 Register a new data type.
2709 The data types allow to naturally associate specific renderers and
2710 editors to the cells containing values of the given type. For example,
2711 the grid automatically registers a data type with the name
2712 @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
2713 wxGridCellTextEditor as its renderer and editor respectively -- this is
2714 the data type used by all the cells of the default wxGridStringTable,
2715 so this renderer and editor are used by default for all grid cells.
2717 However if a custom table returns @c wxGRID_VALUE_BOOL from its
2718 wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
2719 wxGridCellBoolEditor are used for it because the grid also registers a
2720 boolean data type with this name.
2722 And as this mechanism is completely generic, you may register your own
2723 data types using your own custom renderers and editors. Just remember
2724 that the table must identify a cell as being of the given type for them
2725 to be used for this cell.
2728 Name of the new type. May be any string, but if the type name is
2729 the same as the name of an already registered type, including one
2730 of the standard ones (which are @c wxGRID_VALUE_STRING, @c
2731 wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT
2732 and @c wxGRID_VALUE_CHOICE), then the new registration information
2733 replaces the previously used renderer and editor.
2735 The renderer to use for the cells of this type. Its ownership is
2736 taken by the grid, i.e. it will call DecRef() on this pointer when
2737 it doesn't need it any longer.
2739 The editor to use for the cells of this type. Its ownership is also
2742 void RegisterDataType(const wxString
& typeName
,
2743 wxGridCellRenderer
* renderer
,
2744 wxGridCellEditor
* editor
);
2747 Sets the value of the current grid cell to the current in-place edit
2750 This is called automatically when the grid cursor moves from the
2751 current cell to a new cell. It is also a good idea to call this
2752 function when closing a grid since any edits to the final cell location
2753 will not be saved otherwise.
2755 void SaveEditControlValue();
2758 Sets the editor for the grid cell at the specified location.
2760 The grid will take ownership of the pointer.
2762 See wxGridCellEditor and the @ref overview_grid for more information
2763 about cell editors and renderers.
2765 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2768 Sets the renderer for the grid cell at the specified location.
2770 The grid will take ownership of the pointer.
2772 See wxGridCellRenderer and the @ref overview_grid for more information
2773 about cell editors and renderers.
2775 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
* renderer
);
2778 Sets the string value for the cell at the specified location.
2780 For simple applications where a grid object automatically uses a
2781 default grid table of string values you use this function together with
2782 GetCellValue() to access cell values. For more complex applications
2783 where you have derived your own grid table class that contains various
2784 data types (e.g. numeric, boolean or user-defined custom types) then
2785 you only use this function for those cells that contain string values.
2787 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2790 void SetCellValue(int row
, int col
, const wxString
& s
);
2792 Sets the string value for the cell at the specified location.
2794 For simple applications where a grid object automatically uses a
2795 default grid table of string values you use this function together with
2796 GetCellValue() to access cell values. For more complex applications
2797 where you have derived your own grid table class that contains various
2798 data types (e.g. numeric, boolean or user-defined custom types) then
2799 you only use this function for those cells that contain string values.
2801 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2804 void SetCellValue(const wxGridCellCoords
& coords
, const wxString
& s
);
2806 @deprecated Please use SetCellValue(int,int,const wxString&) or
2807 SetCellValue(const wxGridCellCoords&,const wxString&)
2810 Sets the string value for the cell at the specified location.
2812 For simple applications where a grid object automatically uses a
2813 default grid table of string values you use this function together with
2814 GetCellValue() to access cell values. For more complex applications
2815 where you have derived your own grid table class that contains various
2816 data types (e.g. numeric, boolean or user-defined custom types) then
2817 you only use this function for those cells that contain string values.
2819 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2822 void SetCellValue(const wxString
& val
, int row
, int col
);
2825 Sets the specified column to display boolean values.
2827 @see SetColFormatCustom()
2829 void SetColFormatBool(int col
);
2832 Sets the specified column to display data in a custom format.
2834 This method provides an alternative to defining a custom grid table
2835 which would return @a typeName from its GetTypeName() method for the
2836 cells in this column: while it doesn't really change the type of the
2837 cells in this column, it does associate the renderer and editor used
2838 for the cells of the specified type with them.
2840 See the @ref overview_grid for more information on working with custom
2843 void SetColFormatCustom(int col
, const wxString
& typeName
);
2846 Sets the specified column to display floating point values with the
2847 given width and precision.
2849 @see SetColFormatCustom()
2851 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
2854 Sets the specified column to display integer values.
2856 @see SetColFormatCustom()
2858 void SetColFormatNumber(int col
);
2861 Sets the default editor for grid cells.
2863 The grid will take ownership of the pointer.
2865 See wxGridCellEditor and the @ref overview_grid for more information
2866 about cell editors and renderers.
2868 void SetDefaultEditor(wxGridCellEditor
* editor
);
2871 Sets the default renderer for grid cells.
2873 The grid will take ownership of the pointer.
2875 See wxGridCellRenderer and the @ref overview_grid for more information
2876 about cell editors and renderers.
2878 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2881 Makes the cell at the specified location read-only or editable.
2885 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2888 Displays the in-place cell edit control for the current cell.
2890 void ShowCellEditControl();
2896 @name Column and Row Sizes
2898 @see @ref overview_grid_resizing
2903 Automatically sets the height and width of all rows and columns to fit
2909 Automatically adjusts width of the column to fit its label.
2911 void AutoSizeColLabelSize(int col
);
2914 Automatically sizes the column to fit its contents. If @a setAsMin is
2915 @true the calculated width will also be set as the minimal width for
2918 void AutoSizeColumn(int col
, bool setAsMin
= true);
2921 Automatically sizes all columns to fit their contents. If @a setAsMin
2922 is @true the calculated widths will also be set as the minimal widths
2925 void AutoSizeColumns(bool setAsMin
= true);
2928 Automatically sizes the row to fit its contents. If @a setAsMin is
2929 @true the calculated height will also be set as the minimal height for
2932 void AutoSizeRow(int row
, bool setAsMin
= true);
2935 Automatically adjusts height of the row to fit its label.
2937 void AutoSizeRowLabelSize(int col
);
2940 Automatically sizes all rows to fit their contents. If @a setAsMin is
2941 @true the calculated heights will also be set as the minimal heights
2944 void AutoSizeRows(bool setAsMin
= true);
2947 Returns @true if the cell value can overflow.
2949 A cell can overflow if the next cell in the row is empty.
2951 bool GetCellOverflow(int row
, int col
) const;
2954 Returns the current height of the column labels.
2956 int GetColLabelSize() const;
2959 Returns the minimal width to which a column may be resized.
2961 Use SetColMinimalAcceptableWidth() to change this value globally or
2962 SetColMinimalWidth() to do it for individual columns.
2964 @see GetRowMinimalAcceptableHeight()
2966 int GetColMinimalAcceptableWidth() const;
2969 Returns the width of the specified column.
2971 int GetColSize(int col
) const;
2974 Returns @true if the specified column is not currently hidden.
2976 bool IsColShown(int col
) const;
2979 Returns @true if the cells can overflow by default.
2981 bool GetDefaultCellOverflow() const;
2984 Returns the default height for column labels.
2986 int GetDefaultColLabelSize() const;
2989 Returns the current default width for grid columns.
2991 int GetDefaultColSize() const;
2994 Returns the default width for the row labels.
2996 int GetDefaultRowLabelSize() const;
2999 Returns the current default height for grid rows.
3001 int GetDefaultRowSize() const;
3004 Returns the minimal size to which rows can be resized.
3006 Use SetRowMinimalAcceptableHeight() to change this value globally or
3007 SetRowMinimalHeight() to do it for individual cells.
3009 @see GetColMinimalAcceptableWidth()
3011 int GetRowMinimalAcceptableHeight() const;
3014 Returns the current width of the row labels.
3016 int GetRowLabelSize() const;
3019 Returns the height of the specified row.
3021 int GetRowSize(int row
) const;
3024 Returns @true if the specified row is not currently hidden.
3026 bool IsRowShown(int row
) const;
3029 Sets the overflow permission of the cell.
3031 void SetCellOverflow(int row
, int col
, bool allow
);
3034 Sets the height of the column labels.
3036 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
3037 automatically so that no label is truncated. Note that this could be
3038 slow for a large table.
3040 void SetColLabelSize(int height
);
3043 Sets the minimal @a width to which the user can resize columns.
3045 @see GetColMinimalAcceptableWidth()
3047 void SetColMinimalAcceptableWidth(int width
);
3050 Sets the minimal @a width for the specified column @a col.
3052 It is usually best to call this method during grid creation as calling
3053 it later will not resize the column to the given minimal width even if
3054 it is currently narrower than it.
3056 @a width must be greater than the minimal acceptable column width as
3057 returned by GetColMinimalAcceptableWidth().
3059 void SetColMinimalWidth(int col
, int width
);
3062 Sets the width of the specified column.
3067 The new column width in pixels, 0 to hide the column or -1 to fit
3068 the column width to its label width.
3070 void SetColSize(int col
, int width
);
3073 Hides the specified column.
3075 To show the column later you need to call SetColSize() with non-0
3076 width or ShowCol() to restore the previous column width.
3078 If the column is already hidden, this method doesn't do anything.
3083 void HideCol(int col
);
3086 Shows the previously hidden column by resizing it to non-0 size.
3088 The column is shown again with the same width that it had before
3091 If the column is currently shown, this method doesn't do anything.
3093 @see HideCol(), SetColSize()
3095 void ShowCol(int col
);
3099 Sets the default overflow permission of the cells.
3101 void SetDefaultCellOverflow( bool allow
);
3104 Sets the default width for columns in the grid.
3106 This will only affect columns subsequently added to the grid unless
3107 @a resizeExistingCols is @true.
3109 If @a width is less than GetColMinimalAcceptableWidth(), then the
3110 minimal acceptable width is used instead of it.
3112 void SetDefaultColSize(int width
, bool resizeExistingCols
= false);
3115 Sets the default height for rows in the grid.
3117 This will only affect rows subsequently added to the grid unless
3118 @a resizeExistingRows is @true.
3120 If @a height is less than GetRowMinimalAcceptableHeight(), then the
3121 minimal acceptable height is used instead of it.
3123 void SetDefaultRowSize(int height
, bool resizeExistingRows
= false);
3126 Sets the width of the row labels.
3128 If @a width equals @c wxGRID_AUTOSIZE then width is calculated
3129 automatically so that no label is truncated. Note that this could be
3130 slow for a large table.
3132 void SetRowLabelSize(int width
);
3135 Sets the minimal row @a height used by default.
3137 See SetColMinimalAcceptableWidth() for more information.
3139 void SetRowMinimalAcceptableHeight(int height
);
3142 Sets the minimal @a height for the specified @a row.
3144 See SetColMinimalWidth() for more information.
3146 void SetRowMinimalHeight(int row
, int height
);
3149 Sets the height of the specified row.
3151 See SetColSize() for more information.
3153 void SetRowSize(int row
, int height
);
3156 Hides the specified row.
3158 To show the row later you need to call SetRowSize() with non-0
3159 width or ShowRow() to restore its original height.
3161 If the row is already hidden, this method doesn't do anything.
3166 void HideRow(int col
);
3169 Shows the previously hidden row.
3171 The row is shown again with the same height that it had before
3174 If the row is currently shown, this method doesn't do anything.
3176 @see HideRow(), SetRowSize()
3178 void ShowRow(int col
);
3181 Get size information for all columns at once.
3183 This method is useful when the information about all column widths
3184 needs to be saved. The widths can be later restored using
3187 @sa wxGridSizesInfo, GetRowSizes()
3189 wxGridSizesInfo
GetColSizes() const;
3192 Get size information for all row at once.
3194 @sa wxGridSizesInfo, GetColSizes()
3196 wxGridSizesInfo
GetRowSizes() const;
3199 Restore all columns sizes.
3201 This is usually called with wxGridSizesInfo object previously returned
3206 void SetColSizes(const wxGridSizesInfo
& sizeInfo
);
3209 Restore all rows sizes.
3213 void SetRowSizes(const wxGridSizesInfo
& sizeInfo
);
3216 Set the size of the cell.
3218 Specifying a value of more than 1 in @a num_rows or @a num_cols will
3219 make the cell at (@a row, @a col) span the block of the specified size,
3220 covering the other cells which would be normally shown in it. Passing 1
3221 for both arguments resets the cell to normal appearance.
3226 The row of the cell.
3228 The column of the cell.
3230 Number of rows to be occupied by this cell, must be >= 1.
3232 Number of columns to be occupied by this cell, must be >= 1.
3234 void SetCellSize(int row
, int col
, int num_rows
, int num_cols
);
3237 Get the size of the cell in number of cells covered by it.
3239 For normal cells, the function fills both @a num_rows and @a num_cols
3240 with 1 and returns CellSpan_None. For cells which span multiple cells, i.e.
3241 for which SetCellSize() had been called, the returned values are the
3242 same ones as were passed to SetCellSize() call and the function return
3243 value is CellSpan_Main.
3245 More unexpectedly, perhaps, the returned values may be @em negative for
3246 the cells which are inside a span covered by a cell occupying multiple
3247 rows or columns. They correspond to the offset of the main cell of the
3248 span from the cell passed to this functions and the function returns
3249 CellSpan_Inside value to indicate this.
3251 As an example, consider a 3*3 grid with the cell (1, 1) (the one in the
3252 middle) having a span of 2 rows and 2 columns, i.e. the grid looks like
3262 Then the function returns 2 and 2 in @a num_rows and @a num_cols for
3263 the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1
3264 and 0 for the cell (2, 1).
3267 The row of the cell.
3269 The column of the cell.
3271 Pointer to variable receiving the number of rows, must not be @NULL.
3273 Pointer to variable receiving the number of columns, must not be
3276 The kind of this cell span (the return value is new in wxWidgets
3277 2.9.1, this function was void in previous wxWidgets versions).
3279 CellSpan
GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
) const;
3282 Get the number of rows and columns allocated for this cell.
3284 This overload doesn't return a CellSpan value but the values returned
3285 may still be negative, see GetCellSize(int, int, int *, int *) for
3288 wxSize
GetCellSize(const wxGridCellCoords
& coords
);
3294 @name User-Resizing and Dragging
3296 Functions controlling various interactive mouse operations.
3298 By default, columns and rows can be resized by dragging the edges of
3299 their labels (this can be disabled using DisableDragColSize() and
3300 DisableDragRowSize() methods). And if grid line dragging is enabled with
3301 EnableDragGridSize() they can also be resized by dragging the right or
3302 bottom edge of the grid cells.
3304 Columns can also be moved to interactively change their order but this
3305 needs to be explicitly enabled with EnableDragColMove().
3310 Return @true if the dragging of cells is enabled or @false otherwise.
3312 bool CanDragCell() const;
3315 Returns @true if columns can be moved by dragging with the mouse.
3317 Columns can be moved by dragging on their labels.
3319 bool CanDragColMove() const;
3322 Returns @true if the given column can be resized by dragging with the
3325 This function returns @true if resizing the columns interactively is
3326 globally enabled, i.e. if DisableDragColSize() hadn't been called, and
3327 if this column wasn't explicitly marked as non-resizable with
3330 bool CanDragColSize(int col
) const;
3333 Return @true if the dragging of grid lines to resize rows and columns
3334 is enabled or @false otherwise.
3336 bool CanDragGridSize() const;
3339 Returns @true if the given row can be resized by dragging with the
3342 This is the same as CanDragColSize() but for rows.
3344 bool CanDragRowSize(int row
) const;
3347 Disable interactive resizing of the specified column.
3349 This method allows to disable resizing of an individual column in a
3350 grid where the columns are otherwise resizable (which is the case by
3353 Notice that currently there is no way to make some columns resizable in
3354 a grid where columns can't be resized by default as there doesn't seem
3355 to be any need for this in practice. There is also no way to make the
3356 column marked as fixed using this method resizable again because it is
3357 supposed that fixed columns are used for static parts of the grid and
3358 so should remain fixed during the entire grid lifetime.
3360 Also notice that disabling interactive column resizing will not prevent
3361 the program from changing the column size.
3363 @see EnableDragColSize()
3365 void DisableColResize(int col
);
3368 Disable interactive resizing of the specified row.
3370 This is the same as DisableColResize() but for rows.
3372 @see EnableDragRowSize()
3374 void DisableRowResize(int row
);
3377 Disables column moving by dragging with the mouse.
3379 Equivalent to passing @false to EnableDragColMove().
3381 void DisableDragColMove();
3384 Disables column sizing by dragging with the mouse.
3386 Equivalent to passing @false to EnableDragColSize().
3388 void DisableDragColSize();
3391 Disable mouse dragging of grid lines to resize rows and columns.
3393 Equivalent to passing @false to EnableDragGridSize()
3395 void DisableDragGridSize();
3398 Disables row sizing by dragging with the mouse.
3400 Equivalent to passing @false to EnableDragRowSize().
3402 void DisableDragRowSize();
3405 Enables or disables cell dragging with the mouse.
3407 void EnableDragCell(bool enable
= true);
3410 Enables or disables column moving by dragging with the mouse.
3412 void EnableDragColMove(bool enable
= true);
3415 Enables or disables column sizing by dragging with the mouse.
3417 @see DisableColResize()
3419 void EnableDragColSize(bool enable
= true);
3422 Enables or disables row and column resizing by dragging gridlines with
3425 void EnableDragGridSize(bool enable
= true);
3428 Enables or disables row sizing by dragging with the mouse.
3430 @see DisableRowResize()
3432 void EnableDragRowSize(bool enable
= true);
3435 Returns the column ID of the specified column position.
3437 int GetColAt(int colPos
) const;
3440 Returns the position of the specified column.
3442 int GetColPos(int colID
) const;
3445 Sets the position of the specified column.
3447 void SetColPos(int colID
, int newPos
);
3450 Sets the positions of all columns at once.
3452 This method takes an array containing the indices of the columns in
3453 their display order, i.e. uses the same convention as
3454 wxHeaderCtrl::SetColumnsOrder().
3456 void SetColumnsOrder(const wxArrayInt
& order
);
3459 Resets the position of the columns to the default.
3467 @name Cursor Movement
3472 Returns the current grid cell column position.
3474 int GetGridCursorCol() const;
3477 Returns the current grid cell row position.
3479 int GetGridCursorRow() const;
3482 Make the given cell current and ensure it is visible.
3484 This method is equivalent to calling MakeCellVisible() and
3485 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
3486 event is generated by it and the selected cell doesn't change if the
3489 void GoToCell(int row
, int col
);
3491 Make the given cell current and ensure it is visible.
3493 This method is equivalent to calling MakeCellVisible() and
3494 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
3495 event is generated by it and the selected cell doesn't change if the
3498 void GoToCell(const wxGridCellCoords
& coords
);
3501 Moves the grid cursor down by one row.
3503 If a block of cells was previously selected it will expand if the
3504 argument is @true or be cleared if the argument is @false.
3506 bool MoveCursorDown(bool expandSelection
);
3509 Moves the grid cursor down in the current column such that it skips to
3510 the beginning or end of a block of non-empty cells.
3512 If a block of cells was previously selected it will expand if the
3513 argument is @true or be cleared if the argument is @false.
3515 bool MoveCursorDownBlock(bool expandSelection
);
3518 Moves the grid cursor left by one column.
3520 If a block of cells was previously selected it will expand if the
3521 argument is @true or be cleared if the argument is @false.
3523 bool MoveCursorLeft(bool expandSelection
);
3526 Moves the grid cursor left in the current row such that it skips to the
3527 beginning or end of a block of non-empty cells.
3529 If a block of cells was previously selected it will expand if the
3530 argument is @true or be cleared if the argument is @false.
3532 bool MoveCursorLeftBlock(bool expandSelection
);
3535 Moves the grid cursor right by one column.
3537 If a block of cells was previously selected it will expand if the
3538 argument is @true or be cleared if the argument is @false.
3540 bool MoveCursorRight(bool expandSelection
);
3543 Moves the grid cursor right in the current row such that it skips to
3544 the beginning or end of a block of non-empty cells.
3546 If a block of cells was previously selected it will expand if the
3547 argument is @true or be cleared if the argument is @false.
3549 bool MoveCursorRightBlock(bool expandSelection
);
3552 Moves the grid cursor up by one row.
3554 If a block of cells was previously selected it will expand if the
3555 argument is @true or be cleared if the argument is @false.
3557 bool MoveCursorUp(bool expandSelection
);
3560 Moves the grid cursor up in the current column such that it skips to
3561 the beginning or end of a block of non-empty cells.
3563 If a block of cells was previously selected it will expand if the
3564 argument is @true or be cleared if the argument is @false.
3566 bool MoveCursorUpBlock(bool expandSelection
);
3569 Moves the grid cursor down by some number of rows so that the previous
3570 bottom visible row becomes the top visible row.
3572 bool MovePageDown();
3575 Moves the grid cursor up by some number of rows so that the previous
3576 top visible row becomes the bottom visible row.
3581 Set the grid cursor to the specified cell.
3583 The grid cursor indicates the current cell and can be moved by the user
3584 using the arrow keys or the mouse.
3586 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
3587 if the event handler vetoes this event, the cursor is not moved.
3589 This function doesn't make the target call visible, use GoToCell() to
3592 void SetGridCursor(int row
, int col
);
3594 Set the grid cursor to the specified cell.
3596 The grid cursor indicates the current cell and can be moved by the user
3597 using the arrow keys or the mouse.
3599 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
3600 if the event handler vetoes this event, the cursor is not moved.
3602 This function doesn't make the target call visible, use GoToCell() to
3605 void SetGridCursor(const wxGridCellCoords
& coords
);
3608 Set the grid's behaviour when the user presses the TAB key.
3610 Pressing the TAB key moves the grid cursor right in the current row, if
3611 there is a cell at the right and, similarly, Shift-TAB moves the cursor
3612 to the left in the current row if it's not in the first column.
3614 What happens if the cursor can't be moved because it it's already at
3615 the beginning or end of the row can be configured using this function,
3616 see wxGrid::TabBehaviour documentation for the detailed description.
3618 IF none of the standard behaviours is appropriate, you can always
3619 handle @c wxEVT_GRID_TABBING event directly to implement a custom
3624 void SetTabBehaviour(TabBehaviour behaviour
);
3630 @name User Selection
3635 Deselects all cells that are currently selected.
3637 void ClearSelection();
3640 Returns an array of individually selected cells.
3642 Notice that this array does @em not contain all the selected cells in
3643 general as it doesn't include the cells selected as part of column, row
3644 or block selection. You must use this method, GetSelectedCols(),
3645 GetSelectedRows() and GetSelectionBlockTopLeft() and
3646 GetSelectionBlockBottomRight() methods to obtain the entire selection
3649 Please notice this behaviour is by design and is needed in order to
3650 support grids of arbitrary size (when an entire column is selected in
3651 a grid with a million of columns, we don't want to create an array with
3652 a million of entries in this function, instead it returns an empty
3653 array and GetSelectedCols() returns an array containing one element).
3655 wxGridCellCoordsArray
GetSelectedCells() const;
3658 Returns an array of selected columns.
3660 Please notice that this method alone is not sufficient to find all the
3661 selected columns as it contains only the columns which were
3662 individually selected but not those being part of the block selection
3663 or being selected in virtue of all of their cells being selected
3664 individually, please see GetSelectedCells() for more details.
3666 wxArrayInt
GetSelectedCols() const;
3669 Returns an array of selected rows.
3671 Please notice that this method alone is not sufficient to find all the
3672 selected rows as it contains only the rows which were individually
3673 selected but not those being part of the block selection or being
3674 selected in virtue of all of their cells being selected individually,
3675 please see GetSelectedCells() for more details.
3677 wxArrayInt
GetSelectedRows() const;
3680 Returns the colour used for drawing the selection background.
3682 wxColour
GetSelectionBackground() const;
3685 Returns an array of the bottom right corners of blocks of selected
3688 Please see GetSelectedCells() for more information about the selection
3689 representation in wxGrid.
3691 @see GetSelectionBlockTopLeft()
3693 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
3696 Returns an array of the top left corners of blocks of selected cells.
3698 Please see GetSelectedCells() for more information about the selection
3699 representation in wxGrid.
3701 @see GetSelectionBlockBottomRight()
3703 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
3706 Returns the colour used for drawing the selection foreground.
3708 wxColour
GetSelectionForeground() const;
3711 Returns the current selection mode.
3713 @see SetSelectionMode().
3715 wxGridSelectionModes
GetSelectionMode() const;
3718 Returns @true if the given cell is selected.
3720 bool IsInSelection(int row
, int col
) const;
3722 Returns @true if the given cell is selected.
3724 bool IsInSelection(const wxGridCellCoords
& coords
) const;
3727 Returns @true if there are currently any selected cells, rows, columns
3730 bool IsSelection() const;
3733 Selects all cells in the grid.
3738 Selects a rectangular block of cells.
3740 If @a addToSelected is @false then any existing selection will be
3741 deselected; if @true the column will be added to the existing
3744 void SelectBlock(int topRow
, int leftCol
, int bottomRow
, int rightCol
,
3745 bool addToSelected
= false);
3747 Selects a rectangular block of cells.
3749 If @a addToSelected is @false then any existing selection will be
3750 deselected; if @true the column will be added to the existing
3753 void SelectBlock(const wxGridCellCoords
& topLeft
,
3754 const wxGridCellCoords
& bottomRight
,
3755 bool addToSelected
= false);
3758 Selects the specified column.
3760 If @a addToSelected is @false then any existing selection will be
3761 deselected; if @true the column will be added to the existing
3764 This method won't select anything if the current selection mode is
3767 void SelectCol(int col
, bool addToSelected
= false);
3770 Selects the specified row.
3772 If @a addToSelected is @false then any existing selection will be
3773 deselected; if @true the row will be added to the existing selection.
3775 This method won't select anything if the current selection mode is
3776 wxGridSelectColumns.
3778 void SelectRow(int row
, bool addToSelected
= false);
3781 Set the colour to be used for drawing the selection background.
3783 void SetSelectionBackground(const wxColour
& c
);
3786 Set the colour to be used for drawing the selection foreground.
3788 void SetSelectionForeground(const wxColour
& c
);
3791 Set the selection behaviour of the grid.
3793 The existing selection is converted to conform to the new mode if
3794 possible and discarded otherwise (e.g. any individual selected cells
3795 are deselected if the new mode allows only the selection of the entire
3798 void SetSelectionMode(wxGridSelectionModes selmode
);
3809 Returns the number of pixels per horizontal scroll increment.
3813 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
3815 int GetScrollLineX() const;
3818 Returns the number of pixels per vertical scroll increment.
3822 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
3824 int GetScrollLineY() const;
3827 Returns @true if a cell is either entirely or at least partially
3828 visible in the grid window.
3830 By default, the cell must be entirely visible for this function to
3831 return @true but if @a wholeCellVisible is @false, the function returns
3832 @true even if the cell is only partially visible.
3834 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
3836 Returns @true if a cell is either entirely or at least partially
3837 visible in the grid window.
3839 By default, the cell must be entirely visible for this function to
3840 return @true but if @a wholeCellVisible is @false, the function returns
3841 @true even if the cell is only partially visible.
3843 bool IsVisible(const wxGridCellCoords
& coords
,
3844 bool wholeCellVisible
= true) const;
3847 Brings the specified cell into the visible grid cell area with minimal
3850 Does nothing if the cell is already visible.
3852 void MakeCellVisible(int row
, int col
);
3854 Brings the specified cell into the visible grid cell area with minimal
3857 Does nothing if the cell is already visible.
3859 void MakeCellVisible(const wxGridCellCoords
& coords
);
3862 Sets the number of pixels per horizontal scroll increment.
3866 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
3868 void SetScrollLineX(int x
);
3871 Sets the number of pixels per vertical scroll increment.
3875 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
3877 void SetScrollLineY(int y
);
3883 @name Cell and Device Coordinate Translation
3888 Convert grid cell coordinates to grid window pixel coordinates.
3890 This function returns the rectangle that encloses the block of cells
3891 limited by @a topLeft and @a bottomRight cell in device coords and
3892 clipped to the client size of the grid window.
3896 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
3897 const wxGridCellCoords
& bottomRight
) const;
3900 Return the rectangle corresponding to the grid cell's size and position
3901 in logical coordinates.
3903 @see BlockToDeviceRect()
3905 wxRect
CellToRect(int row
, int col
) const;
3907 Return the rectangle corresponding to the grid cell's size and position
3908 in logical coordinates.
3910 @see BlockToDeviceRect()
3912 wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
3915 Returns the column at the given pixel position.
3918 The x position to evaluate.
3920 If @true, rather than returning @c wxNOT_FOUND, it returns either
3921 the first or last column depending on whether @a x is too far to
3922 the left or right respectively.
3924 The column index or @c wxNOT_FOUND.
3926 int XToCol(int x
, bool clipToMinMax
= false) const;
3929 Returns the column whose right hand edge is close to the given logical
3932 If no column edge is near to this position @c wxNOT_FOUND is returned.
3934 int XToEdgeOfCol(int x
) const;
3937 Translates logical pixel coordinates to the grid cell coordinates.
3939 Notice that this function expects logical coordinates on input so if
3940 you use this function in a mouse event handler you need to translate
3941 the mouse position, which is expressed in device coordinates, to
3944 @see XToCol(), YToRow()
3946 wxGridCellCoords
XYToCell(int x
, int y
) const;
3948 Translates logical pixel coordinates to the grid cell coordinates.
3950 Notice that this function expects logical coordinates on input so if
3951 you use this function in a mouse event handler you need to translate
3952 the mouse position, which is expressed in device coordinates, to
3955 @see XToCol(), YToRow()
3957 wxGridCellCoords
XYToCell(const wxPoint
& pos
) const;
3958 // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
3959 // undocumented, using it is ugly and non-const reference parameters are
3960 // not used in wxWidgets API
3963 Returns the row whose bottom edge is close to the given logical @a y
3966 If no row edge is near to this position @c wxNOT_FOUND is returned.
3968 int YToEdgeOfRow(int y
) const;
3971 Returns the grid row that corresponds to the logical @a y coordinate.
3973 Returns @c wxNOT_FOUND if there is no row at the @a y position.
3975 int YToRow(int y
, bool clipToMinMax
= false) const;
3981 @name Miscellaneous Functions
3986 Appends one or more new columns to the right of the grid.
3988 The @a updateLabels argument is not used at present. If you are using a
3989 derived grid table class you will need to override
3990 wxGridTableBase::AppendCols(). See InsertCols() for further
3993 @return @true on success or @false if appending columns failed.
3995 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
3998 Appends one or more new rows to the bottom of the grid.
4000 The @a updateLabels argument is not used at present. If you are using a
4001 derived grid table class you will need to override
4002 wxGridTableBase::AppendRows(). See InsertRows() for further
4005 @return @true on success or @false if appending rows failed.
4007 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
4010 Return @true if the horizontal grid lines stop at the last column
4011 boundary or @false if they continue to the end of the window.
4013 The default is to clip grid lines.
4015 @see ClipHorzGridLines(), AreVertGridLinesClipped()
4017 bool AreHorzGridLinesClipped() const;
4020 Return @true if the vertical grid lines stop at the last row
4021 boundary or @false if they continue to the end of the window.
4023 The default is to clip grid lines.
4025 @see ClipVertGridLines(), AreHorzGridLinesClipped()
4027 bool AreVertGridLinesClipped() const;
4030 Increments the grid's batch count.
4032 When the count is greater than zero repainting of the grid is
4033 suppressed. Each call to BeginBatch must be matched by a later call to
4034 EndBatch(). Code that does a lot of grid modification can be enclosed
4035 between BeginBatch() and EndBatch() calls to avoid screen flicker. The
4036 final EndBatch() call will cause the grid to be repainted.
4038 Notice that you should use wxGridUpdateLocker which ensures that there
4039 is always a matching EndBatch() call for this BeginBatch() if possible
4040 instead of calling this method directly.
4045 Clears all data in the underlying grid table and repaints the grid.
4047 The table is not deleted by this function. If you are using a derived
4048 table class then you need to override wxGridTableBase::Clear() for this
4049 function to have any effect.
4054 Change whether the horizontal grid lines are clipped by the end of the
4057 By default the grid lines are not drawn beyond the end of the last
4058 column but after calling this function with @a clip set to @false they
4059 will be drawn across the entire grid window.
4061 @see AreHorzGridLinesClipped(), ClipVertGridLines()
4063 void ClipHorzGridLines(bool clip
);
4066 Change whether the vertical grid lines are clipped by the end of the
4069 By default the grid lines are not drawn beyond the end of the last
4070 row but after calling this function with @a clip set to @false they
4071 will be drawn across the entire grid window.
4073 @see AreVertGridLinesClipped(), ClipHorzGridLines()
4075 void ClipVertGridLines(bool clip
);
4078 Deletes one or more columns from a grid starting at the specified
4081 The @a updateLabels argument is not used at present. If you are using a
4082 derived grid table class you will need to override
4083 wxGridTableBase::DeleteCols(). See InsertCols() for further
4086 @return @true on success or @false if deleting columns failed.
4088 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
4091 Deletes one or more rows from a grid starting at the specified
4094 The @a updateLabels argument is not used at present. If you are using a
4095 derived grid table class you will need to override
4096 wxGridTableBase::DeleteRows(). See InsertRows() for further
4099 @return @true on success or @false if appending rows failed.
4101 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
4104 Decrements the grid's batch count.
4106 When the count is greater than zero repainting of the grid is
4107 suppressed. Each previous call to BeginBatch() must be matched by a
4108 later call to EndBatch(). Code that does a lot of grid modification can
4109 be enclosed between BeginBatch() and EndBatch() calls to avoid screen
4110 flicker. The final EndBatch() will cause the grid to be repainted.
4112 @see wxGridUpdateLocker
4117 Overridden wxWindow method.
4122 Causes immediate repainting of the grid.
4124 Use this instead of the usual wxWindow::Refresh().
4126 void ForceRefresh();
4129 Returns the number of times that BeginBatch() has been called without
4130 (yet) matching calls to EndBatch(). While the grid's batch count is
4131 greater than zero the display will not be updated.
4133 int GetBatchCount();
4136 Returns the total number of grid columns.
4138 This is the same as the number of columns in the underlying grid table.
4140 int GetNumberCols() const;
4143 Returns the total number of grid rows.
4145 This is the same as the number of rows in the underlying grid table.
4147 int GetNumberRows() const;
4150 Returns the attribute for the given cell creating one if necessary.
4152 If the cell already has an attribute, it is returned. Otherwise a new
4153 attribute is created, associated with the cell and returned. In any
4154 case the caller must call DecRef() on the returned pointer.
4156 This function may only be called if CanHaveAttributes() returns @true.
4158 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
4161 Returns a base pointer to the current table object.
4163 The returned pointer is still owned by the grid.
4165 wxGridTableBase
*GetTable() const;
4168 Inserts one or more new columns into a grid with the first new column
4169 at the specified position.
4171 Notice that inserting the columns in the grid requires grid table
4172 cooperation: when this method is called, grid object begins by
4173 requesting the underlying grid table to insert new columns. If this is
4174 successful the table notifies the grid and the grid updates the
4175 display. For a default grid (one where you have called CreateGrid())
4176 this process is automatic. If you are using a custom grid table
4177 (specified with SetTable()) then you must override
4178 wxGridTableBase::InsertCols() in your derived table class.
4181 The position which the first newly inserted column will have.
4183 The number of columns to insert.
4187 @true if the columns were successfully inserted, @false if an error
4188 occurred (most likely the table couldn't be updated).
4190 bool InsertCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
4193 Inserts one or more new rows into a grid with the first new row at the
4196 Notice that you must implement wxGridTableBase::InsertRows() if you use
4197 a grid with a custom table, please see InsertCols() for more
4201 The position which the first newly inserted row will have.
4203 The number of rows to insert.
4207 @true if the rows were successfully inserted, @false if an error
4208 occurred (most likely the table couldn't be updated).
4210 bool InsertRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
4213 Invalidates the cached attribute for the given cell.
4215 For efficiency reasons, wxGrid may cache the recently used attributes
4216 (currently it caches only the single most recently used one, in fact)
4217 which can result in the cell appearance not being refreshed even when
4218 the attribute returned by your custom wxGridCellAttrProvider-derived
4219 class has changed. To force the grid to refresh the cell attribute,
4220 this function may be used. Notice that calling it will not result in
4221 actually redrawing the cell, you still need to call
4222 wxWindow::RefreshRect() to invalidate the area occupied by the cell in
4223 the window to do this. Also note that you don't need to call this
4224 function if you store the attributes in wxGrid itself, i.e. use its
4225 SetAttr() and similar methods, it is only useful when using a separate
4226 custom attributes provider.
4229 The row of the cell whose attribute needs to be queried again.
4231 The column of the cell whose attribute needs to be queried again.
4235 void RefreshAttr(int row
, int col
);
4238 Draws part or all of a wxGrid on a wxDC for printing or display.
4240 Pagination can be accomplished by using sequential Render() calls
4241 with appropriate values in wxGridCellCoords topLeft and bottomRight.
4244 The wxDC to be drawn on.
4246 The position on the wxDC where rendering should begin. If not
4247 specified drawing will begin at the wxDC MaxX() and MaxY().
4249 The size of the area on the wxDC that the rendered wxGrid should
4250 occupy. If not specified the drawing will be scaled to fit the
4251 available dc width or height. The wxGrid's aspect ratio is
4252 maintained whether or not size is specified.
4254 The top left cell of the block to be drawn. Defaults to ( 0, 0 ).
4256 The bottom right cell of the block to be drawn. Defaults to row and
4259 A combination of values from wxGridRenderStyle.
4263 void Render( wxDC
& dc
,
4264 const wxPoint
& pos
= wxDefaultPosition
,
4265 const wxSize
& size
= wxDefaultSize
,
4266 const wxGridCellCoords
& topLeft
= wxGridCellCoords( -1, -1 ),
4267 const wxGridCellCoords
& bottomRight
= wxGridCellCoords( -1, -1 ),
4268 int style
= wxGRID_DRAW_DEFAULT
);
4271 Sets the cell attributes for all cells in the specified column.
4273 For more information about controlling grid cell attributes see the
4274 wxGridCellAttr cell attribute class and the @ref overview_grid.
4276 void SetColAttr(int col
, wxGridCellAttr
* attr
);
4279 Sets the extra margins used around the grid area.
4281 A grid may occupy more space than needed for its data display and
4282 this function allows to set how big this extra space is
4284 void SetMargins(int extraWidth
, int extraHeight
);
4287 Sets the cell attributes for all cells in the specified row.
4289 The grid takes ownership of the attribute pointer.
4291 See the wxGridCellAttr class for more information about controlling
4294 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
4300 @name Sorting support.
4302 wxGrid doesn't provide any support for sorting the data but it does
4303 generate events allowing the user code to sort it and supports
4304 displaying the sort indicator in the column used for sorting.
4306 To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT
4307 event (and not veto it) and resort the data displayed in the grid. The
4308 grid will automatically update the sorting indicator on the column
4311 You can also call the functions in this section directly to update the
4312 sorting indicator. Once again, they don't do anything with the grid
4313 data, it remains your responsibility to actually sort it appropriately.
4318 Return the column in which the sorting indicator is currently
4321 Returns @c wxNOT_FOUND if sorting indicator is not currently displayed
4324 @see SetSortingColumn()
4326 int GetSortingColumn() const;
4329 Return @true if this column is currently used for sorting.
4331 @see GetSortingColumn()
4333 bool IsSortingBy(int col
) const;
4336 Return @true if the current sorting order is ascending or @false if it
4339 It only makes sense to call this function if GetSortingColumn() returns
4340 a valid column index and not @c wxNOT_FOUND.
4342 @see SetSortingColumn()
4344 bool IsSortOrderAscending() const;
4347 Set the column to display the sorting indicator in and its direction.
4350 The column to display the sorting indicator in or @c wxNOT_FOUND to
4351 remove any currently displayed sorting indicator.
4353 If @true, display the ascending sort indicator, otherwise display
4354 the descending sort indicator.
4356 @see GetSortingColumn(), IsSortOrderAscending()
4358 void SetSortingColumn(int col
, bool ascending
= true);
4361 Remove any currently shown sorting indicator.
4363 This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND
4366 void UnsetSortingColumn();
4371 @name Accessors for component windows.
4373 Return the various child windows of wxGrid.
4375 wxGrid is an empty parent window for 4 children representing the column
4376 labels window (top), the row labels window (left), the corner window
4377 (top left) and the main grid window. It may be necessary to use these
4378 individual windows and not the wxGrid window itself if you need to
4379 handle events for them (this can be done using wxEvtHandler::Connect()
4380 or wxWindow::PushEventHandler()) or do something else requiring the use
4381 of the correct window pointer. Notice that you should not, however,
4382 change these windows (e.g. reposition them or draw over them) because
4383 they are managed by wxGrid itself.
4388 Return the main grid window containing the grid cells.
4390 This window is always shown.
4392 wxWindow
*GetGridWindow() const;
4395 Return the row labels window.
4397 This window is not shown if the row labels were hidden using
4400 wxWindow
*GetGridRowLabelWindow() const;
4403 Return the column labels window.
4405 This window is not shown if the columns labels were hidden using
4408 Depending on whether UseNativeColHeader() was called or not this can be
4409 either a wxHeaderCtrl or a plain wxWindow. This function returns a valid
4410 window pointer in either case but in the former case you can also use
4411 GetGridColHeader() to access it if you need wxHeaderCtrl-specific
4414 wxWindow
*GetGridColLabelWindow() const;
4417 Return the window in the top left grid corner.
4419 This window is shown only of both columns and row labels are shown and
4420 normally doesn't contain anything. Clicking on it is handled by wxGrid
4421 however and can be used to select the entire grid.
4423 wxWindow
*GetGridCornerLabelWindow() const;
4426 Return the header control used for column labels display.
4428 This function can only be called if UseNativeColHeader() had been
4431 wxHeaderCtrl
*GetGridColHeader() const;
4437 Returns @true if this grid has support for cell attributes.
4439 The grid supports attributes if it has the associated table which, in
4440 turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
4443 bool CanHaveAttributes() const;
4446 Get the minimal width of the given column/row.
4448 The value returned by this function may be different than that returned
4449 by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
4450 called for this column.
4452 int GetColMinimalWidth(int col
) const;
4455 Returns the coordinate of the right border specified column.
4457 int GetColRight(int col
) const;
4460 Returns the coordinate of the left border specified column.
4462 int GetColLeft(int col
) const;
4465 Returns the minimal size for the given column.
4467 The value returned by this function may be different than that returned
4468 by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
4469 called for this row.
4471 int GetRowMinimalHeight(int col
) const;
4477 @class wxGridUpdateLocker
4479 This small class can be used to prevent wxGrid from redrawing during its
4480 lifetime by calling wxGrid::BeginBatch() in its constructor and
4481 wxGrid::EndBatch() in its destructor. It is typically used in a function
4482 performing several operations with a grid which would otherwise result in
4483 flicker. For example:
4488 m_grid = new wxGrid(this, ...);
4490 wxGridUpdateLocker noUpdates(m_grid);
4491 m_grid-AppendColumn();
4492 // ... many other operations with m_grid ...
4495 // destructor called, grid refreshed
4499 Using this class is easier and safer than calling wxGrid::BeginBatch() and
4500 wxGrid::EndBatch() because you don't risk missing the call the latter (due
4501 to an exception for example).
4506 class wxGridUpdateLocker
4510 Creates an object preventing the updates of the specified @a grid. The
4511 parameter could be @NULL in which case nothing is done. If @a grid is
4512 non-@NULL then the grid must exist for longer than this
4513 wxGridUpdateLocker object itself.
4515 The default constructor could be followed by a call to Create() to set
4516 the grid object later.
4518 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
4521 Destructor reenables updates for the grid this object is associated
4524 ~wxGridUpdateLocker();
4527 This method can be called if the object had been constructed using the
4528 default constructor. It must not be called more than once.
4530 void Create(wxGrid
* grid
);
4538 This event class contains information about various grid events.
4540 Notice that all grid event table macros are available in two versions:
4541 @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the
4542 two is that the former doesn't allow to specify the grid window identifier
4543 and so takes a single parameter, the event handler, but is not suitable if
4544 there is more than one grid control in the window where the event table is
4545 used (as it would catch the events from all the grids). The version with @c
4546 CMD takes the id as first argument and the event handler as the second one
4547 and so can be used with multiple grids as well. Otherwise there are no
4548 difference between the two and only the versions without the id are
4549 documented below for brevity.
4551 @beginEventTable{wxGridEvent}
4552 @event{EVT_GRID_CELL_CHANGING(func)}
4553 The user is about to change the data in a cell. The new cell value as
4554 string is available from GetString() event object method. This event
4555 can be vetoed if the change is not allowed.
4556 Processes a @c wxEVT_GRID_CELL_CHANGING event type.
4557 @event{EVT_GRID_CELL_CHANGED(func)}
4558 The user changed the data in a cell. The old cell value as string is
4559 available from GetString() event object method. Notice that vetoing
4560 this event still works for backwards compatibility reasons but any new
4561 code should only veto EVT_GRID_CELL_CHANGING event and not this one.
4562 Processes a @c wxEVT_GRID_CELL_CHANGED event type.
4563 @event{EVT_GRID_CELL_LEFT_CLICK(func)}
4564 The user clicked a cell with the left mouse button. Processes a
4565 @c wxEVT_GRID_CELL_LEFT_CLICK event type.
4566 @event{EVT_GRID_CELL_LEFT_DCLICK(func)}
4567 The user double-clicked a cell with the left mouse button. Processes a
4568 @c wxEVT_GRID_CELL_LEFT_DCLICK event type.
4569 @event{EVT_GRID_CELL_RIGHT_CLICK(func)}
4570 The user clicked a cell with the right mouse button. Processes a
4571 @c wxEVT_GRID_CELL_RIGHT_CLICK event type.
4572 @event{EVT_GRID_CELL_RIGHT_DCLICK(func)}
4573 The user double-clicked a cell with the right mouse button. Processes a
4574 @c wxEVT_GRID_CELL_RIGHT_DCLICK event type.
4575 @event{EVT_GRID_EDITOR_HIDDEN(func)}
4576 The editor for a cell was hidden. Processes a
4577 @c wxEVT_GRID_EDITOR_HIDDEN event type.
4578 @event{EVT_GRID_EDITOR_SHOWN(func)}
4579 The editor for a cell was shown. Processes a
4580 @c wxEVT_GRID_EDITOR_SHOWN event type.
4581 @event{EVT_GRID_LABEL_LEFT_CLICK(func)}
4582 The user clicked a label with the left mouse button. Processes a
4583 @c wxEVT_GRID_LABEL_LEFT_CLICK event type.
4584 @event{EVT_GRID_LABEL_LEFT_DCLICK(func)}
4585 The user double-clicked a label with the left mouse button. Processes a
4586 @c wxEVT_GRID_LABEL_LEFT_DCLICK event type.
4587 @event{EVT_GRID_LABEL_RIGHT_CLICK(func)}
4588 The user clicked a label with the right mouse button. Processes a
4589 @c wxEVT_GRID_LABEL_RIGHT_CLICK event type.
4590 @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)}
4591 The user double-clicked a label with the right mouse button. Processes
4592 a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type.
4593 @event{EVT_GRID_SELECT_CELL(func)}
4594 The given cell was made current, either by user or by the program via a
4595 call to SetGridCursor() or GoToCell(). Processes a
4596 @c wxEVT_GRID_SELECT_CELL event type.
4597 @event{EVT_GRID_COL_MOVE(func)}
4598 The user tries to change the order of the columns in the grid by
4599 dragging the column specified by GetCol(). This event can be vetoed to
4600 either prevent the user from reordering the column change completely
4601 (but notice that if you don't want to allow it at all, you simply
4602 shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed
4603 but handled in some way in the handler, e.g. by really moving the
4604 column to the new position at the associated table level, or allowed to
4605 proceed in which case wxGrid::SetColPos() is used to reorder the
4606 columns display order without affecting the use of the column indices
4608 This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type.
4609 @event{EVT_GRID_COL_SORT(func)}
4610 This event is generated when a column is clicked by the user and its
4611 name is explained by the fact that the custom reaction to a click on a
4612 column is to sort the grid contents by this column. However the grid
4613 itself has no special support for sorting and it's up to the handler of
4614 this event to update the associated table. But if the event is handled
4615 (and not vetoed) the grid supposes that the table was indeed resorted
4616 and updates the column to indicate the new sort order and refreshes
4618 This event macro corresponds to @c wxEVT_GRID_COL_SORT event type.
4619 @event{EVT_GRID_TABBING(func)}
4620 This event is generated when the user presses TAB or Shift-TAB in the
4621 grid. It can be used to customize the simple default TAB handling
4622 logic, e.g. to go to the next non-empty cell instead of just the next
4623 cell. See also wxGrid::SetTabBehaviour(). This event is new since
4628 @category{grid,events}
4630 class wxGridEvent
: public wxNotifyEvent
4634 Default constructor.
4638 Constructor for initializing all event attributes.
4640 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
4641 int row
= -1, int col
= -1, int x
= -1, int y
= -1,
4642 bool sel
= true, const wxKeyboardState
& kbd
= wxKeyboardState());
4645 Returns @true if the Alt key was down at the time of the event.
4647 bool AltDown() const;
4650 Returns @true if the Control key was down at the time of the event.
4652 bool ControlDown() const;
4655 Column at which the event occurred.
4657 Notice that for a @c wxEVT_GRID_SELECT_CELL event this column is the
4658 column of the newly selected cell while the previously selected cell
4659 can be retrieved using wxGrid::GetGridCursorCol().
4661 virtual int GetCol();
4664 Position in pixels at which the event occurred.
4666 wxPoint
GetPosition();
4669 Row at which the event occurred.
4671 Notice that for a @c wxEVT_GRID_SELECT_CELL event this row is the row
4672 of the newly selected cell while the previously selected cell can be
4673 retrieved using wxGrid::GetGridCursorRow().
4675 virtual int GetRow();
4678 Returns @true if the Meta key was down at the time of the event.
4680 bool MetaDown() const;
4683 Returns @true if the user is selecting grid cells, or @false if
4689 Returns @true if the Shift key was down at the time of the event.
4691 bool ShiftDown() const;
4697 @class wxGridSizeEvent
4699 This event class contains information about a row/column resize event.
4701 @beginEventTable{wxGridSizeEvent}
4702 @event{EVT_GRID_CMD_COL_SIZE(id, func)}
4703 The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event
4705 @event{EVT_GRID_CMD_ROW_SIZE(id, func)}
4706 The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event
4708 @event{EVT_GRID_COL_SIZE(func)}
4709 Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id.
4710 @event{EVT_GRID_COL_AUTO_SIZE(func)}
4711 This event is sent when a column must be resized to its best size, e.g.
4712 when the user double clicks the column divider. The default
4713 implementation simply resizes the column to fit the column label (but
4714 not its contents as this could be too slow for big grids). This macro
4715 corresponds to @c wxEVT_GRID_COL_AUTO_SIZE event type and is new since
4717 @event{EVT_GRID_ROW_SIZE(func)}
4718 Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id.
4722 @category{grid,events}
4724 class wxGridSizeEvent
: public wxNotifyEvent
4728 Default constructor.
4732 Constructor for initializing all event attributes.
4734 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
4735 int rowOrCol
= -1, int x
= -1, int y
= -1,
4736 const wxKeyboardState
& kbd
= wxKeyboardState());
4739 Returns @true if the Alt key was down at the time of the event.
4741 bool AltDown() const;
4744 Returns @true if the Control key was down at the time of the event.
4746 bool ControlDown() const;
4749 Position in pixels at which the event occurred.
4751 wxPoint
GetPosition();
4754 Row or column at that was resized.
4759 Returns @true if the Meta key was down at the time of the event.
4761 bool MetaDown() const;
4764 Returns @true if the Shift key was down at the time of the event.
4766 bool ShiftDown() const;
4772 @class wxGridRangeSelectEvent
4774 @beginEventTable{wxGridRangeSelectEvent}
4775 @event{EVT_GRID_RANGE_SELECT(func)}
4776 The user selected a group of contiguous cells. Processes a
4777 @c wxEVT_GRID_RANGE_SELECT event type.
4778 @event{EVT_GRID_CMD_RANGE_SELECT(id, func)}
4779 The user selected a group of contiguous cells; variant taking a window
4780 identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type.
4784 @category{grid,events}
4786 class wxGridRangeSelectEvent
: public wxNotifyEvent
4790 Default constructor.
4792 wxGridRangeSelectEvent();
4794 Constructor for initializing all event attributes.
4796 wxGridRangeSelectEvent(int id
, wxEventType type
,
4798 const wxGridCellCoords
& topLeft
,
4799 const wxGridCellCoords
& bottomRight
,
4800 bool sel
= true, const wxKeyboardState
& kbd
= wxKeyboardState());
4803 Returns @true if the Alt key was down at the time of the event.
4805 bool AltDown() const;
4808 Returns @true if the Control key was down at the time of the event.
4810 bool ControlDown() const;
4813 Top left corner of the rectangular area that was (de)selected.
4815 wxGridCellCoords
GetBottomRightCoords();
4818 Bottom row of the rectangular area that was (de)selected.
4823 Left column of the rectangular area that was (de)selected.
4828 Right column of the rectangular area that was (de)selected.
4833 Top left corner of the rectangular area that was (de)selected.
4835 wxGridCellCoords
GetTopLeftCoords();
4838 Top row of the rectangular area that was (de)selected.
4843 Returns @true if the Meta key was down at the time of the event.
4845 bool MetaDown() const;
4848 Returns @true if the area was selected, @false otherwise.
4853 Returns @true if the Shift key was down at the time of the event.
4855 bool ShiftDown() const;
4861 @class wxGridEditorCreatedEvent
4863 @beginEventTable{wxGridEditorCreatedEvent}
4864 @event{EVT_GRID_EDITOR_CREATED(func)}
4865 The editor for a cell was created. Processes a
4866 @c wxEVT_GRID_EDITOR_CREATED event type.
4867 @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)}
4868 The editor for a cell was created; variant taking a window identifier.
4869 Processes a @c wxEVT_GRID_EDITOR_CREATED event type.
4873 @category{grid,events}
4875 class wxGridEditorCreatedEvent
: public wxCommandEvent
4879 Default constructor.
4881 wxGridEditorCreatedEvent();
4883 Constructor for initializing all event attributes.
4885 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
4886 int row
, int col
, wxControl
* ctrl
);
4889 Returns the column at which the event occurred.
4894 Returns the edit control.
4896 wxControl
* GetControl();
4899 Returns the row at which the event occurred.
4904 Sets the column at which the event occurred.
4906 void SetCol(int col
);
4909 Sets the edit control.
4911 void SetControl(wxControl
* ctrl
);
4914 Sets the row at which the event occurred.
4916 void SetRow(int row
);
4920 wxEventType wxEVT_GRID_CELL_LEFT_CLICK
;
4921 wxEventType wxEVT_GRID_CELL_RIGHT_CLICK
;
4922 wxEventType wxEVT_GRID_CELL_LEFT_DCLICK
;
4923 wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK
;
4924 wxEventType wxEVT_GRID_LABEL_LEFT_CLICK
;
4925 wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK
;
4926 wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK
;
4927 wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK
;
4928 wxEventType wxEVT_GRID_ROW_SIZE
;
4929 wxEventType wxEVT_GRID_COL_SIZE
;
4930 wxEventType wxEVT_GRID_COL_AUTO_SIZE
;
4931 wxEventType wxEVT_GRID_RANGE_SELECT
;
4932 wxEventType wxEVT_GRID_CELL_CHANGING
;
4933 wxEventType wxEVT_GRID_CELL_CHANGED
;
4934 wxEventType wxEVT_GRID_SELECT_CELL
;
4935 wxEventType wxEVT_GRID_EDITOR_SHOWN
;
4936 wxEventType wxEVT_GRID_EDITOR_HIDDEN
;
4937 wxEventType wxEVT_GRID_EDITOR_CREATED
;
4938 wxEventType wxEVT_GRID_CELL_BEGIN_DRAG
;
4939 wxEventType wxEVT_GRID_COL_MOVE
;
4940 wxEventType wxEVT_GRID_COL_SORT
;
4941 wxEventType wxEVT_GRID_TABBING
;