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
628 Text cell editor constructor.
631 Maximum width of text (this parameter is supported starting since
634 explicit wxGridCellTextEditor(size_t maxChars
= 0);
637 The parameters string format is "n" where n is a number representing
640 virtual void SetParameters(const wxString
& params
);
643 Set validator to validate user input.
647 virtual void SetValidator(const wxValidator
& validator
);
651 @class wxGridCellFloatEditor
653 The editor for floating point numbers data.
658 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
659 wxGridCellBoolEditor, wxGridCellChoiceEditor,
660 wxGridCellEnumEditor, wxGridCellNumberEditor,
663 class wxGridCellFloatEditor
: public wxGridCellTextEditor
667 Float cell editor ctor.
670 Minimum number of characters to be shown.
672 Number of digits after the decimal dot.
674 The format to use for displaying the number, a combination of
675 ::wxGridCellFloatFormat enum elements. This parameter is only
676 available since wxWidgets 2.9.3.
678 wxGridCellFloatEditor(int width
= -1, int precision
= -1,
679 int format
= wxGRID_FLOAT_FORMAT_DEFAULT
);
682 The parameters string format is "width[,precision[,format]]" where
683 @c format should be chosen between f|e|g|E|G (f is used by default)
685 virtual void SetParameters(const wxString
& params
);
689 @class wxGridCellNumberEditor
691 Grid cell editor for numeric integer data.
696 @see wxGridCellEditor, wxGridCellAutoWrapStringEditor,
697 wxGridCellBoolEditor, wxGridCellChoiceEditor,
698 wxGridCellEnumEditor, wxGridCellFloatEditor,
701 class wxGridCellNumberEditor
: public wxGridCellTextEditor
705 Allows you to specify the range for acceptable data. Values equal to
706 -1 for both @a min and @a max indicate that no range checking should be
709 wxGridCellNumberEditor(int min
= -1, int max
= -1);
713 Parameters string format is "min,max".
715 virtual void SetParameters(const wxString
& params
);
720 If the return value is @true, the editor uses a wxSpinCtrl to get user
721 input, otherwise it uses a wxTextCtrl.
723 bool HasRange() const;
726 String representation of the value.
728 wxString
GetString() const;
734 @class wxGridCellAttr
736 This class can be used to alter the cells' appearance in the grid by
737 changing their attributes from the defaults. An object of this class may be
738 returned by wxGridTableBase::GetAttr().
743 class wxGridCellAttr
: public wxClientDataContainer
, public wxRefCounter
747 Kind of the attribute to retrieve.
749 @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr()
753 /// Return the combined effective attribute for the cell.
756 /// Return the attribute explicitly set for this cell.
759 /// Return the attribute set for this cells row.
762 /// Return the attribute set for this cells column.
769 wxGridCellAttr(wxGridCellAttr
* attrDefault
= NULL
);
771 Constructor specifying some of the often used attributes.
773 wxGridCellAttr(const wxColour
& colText
, const wxColour
& colBack
,
774 const wxFont
& font
, int hAlign
, int vAlign
);
777 Creates a new copy of this object.
779 wxGridCellAttr
* Clone() const;
782 This class is reference counted: it is created with ref count of 1, so
783 calling DecRef() once will delete it. Calling IncRef() allows to lock
784 it until the matching DecRef() is called.
789 Get the alignment to use for the cell with the given attribute.
791 If this attribute doesn't specify any alignment, the default attribute
792 alignment is used (which can be changed using
793 wxGrid::SetDefaultCellAlignment() but is left and top by default).
795 Notice that @a hAlign and @a vAlign values are always overwritten by
796 this function, use GetNonDefaultAlignment() if this is not desirable.
799 Horizontal alignment is returned here if this argument is non-@NULL.
800 It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.
802 Vertical alignment is returned here if this argument is non-@NULL.
803 It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
805 void GetAlignment(int* hAlign
, int* vAlign
) const;
808 Returns the background colour.
810 const wxColour
& GetBackgroundColour() const;
813 Returns the cell editor.
815 wxGridCellEditor
* GetEditor(const wxGrid
* grid
, int row
, int col
) const;
820 const wxFont
& GetFont() const;
823 Get the alignment defined by this attribute.
825 Unlike GetAlignment() this function only modifies @a hAlign and @a
826 vAlign if this attribute does define a non-default alignment. This
827 means that they must be initialized before calling this function and
828 that their values will be preserved unchanged if they are different
829 from wxALIGN_INVALID.
831 For example, the following fragment can be used to use the cell
832 alignment if one is defined but right-align its contents by default
833 (instead of left-aligning it by default) while still using the default
836 int hAlign = wxALIGN_RIGHT,
837 vAlign = wxALIGN_INVALID;
838 attr.GetNonDefaultAlignment(&hAlign, &vAlign);
843 void GetNonDefaultAlignment(int *hAlign
, int *vAlign
) const;
846 Returns the cell renderer.
848 wxGridCellRenderer
* GetRenderer(const wxGrid
* grid
, int row
, int col
) const;
851 Returns the text colour.
853 const wxColour
& GetTextColour() const;
856 Returns @true if this attribute has a valid alignment set.
858 bool HasAlignment() const;
861 Returns @true if this attribute has a valid background colour set.
863 bool HasBackgroundColour() const;
866 Returns @true if this attribute has a valid cell editor set.
868 bool HasEditor() const;
871 Returns @true if this attribute has a valid font set.
873 bool HasFont() const;
876 Returns @true if this attribute has a valid cell renderer set.
878 bool HasRenderer() const;
881 Returns @true if this attribute has a valid text colour set.
883 bool HasTextColour() const;
886 This class is reference counted: it is created with ref count of 1, so
887 calling DecRef() once will delete it. Calling IncRef() allows to lock
888 it until the matching DecRef() is called.
893 Returns @true if this cell is set as read-only.
895 bool IsReadOnly() const;
898 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
899 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of
900 @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
902 void SetAlignment(int hAlign
, int vAlign
);
905 Sets the background colour.
907 void SetBackgroundColour(const wxColour
& colBack
);
910 @todo Needs documentation.
912 void SetDefAttr(wxGridCellAttr
* defAttr
);
915 Sets the editor to be used with the cells with this attribute.
917 void SetEditor(wxGridCellEditor
* editor
);
922 void SetFont(const wxFont
& font
);
925 Sets the cell as read-only.
927 void SetReadOnly(bool isReadOnly
= true);
930 Sets the renderer to be used for cells with this attribute. Takes
931 ownership of the pointer.
933 void SetRenderer(wxGridCellRenderer
* renderer
);
936 Sets the text colour.
938 void SetTextColour(const wxColour
& colText
);
943 The destructor is private because only DecRef() can delete us.
945 virtual ~wxGridCellAttr();
949 Base class for corner window renderer.
951 This is the simplest of all header renderers and only has a single
954 @see wxGridCellAttrProvider::GetCornerRenderer()
958 class wxGridCornerHeaderRenderer
962 Called by the grid to draw the corner window border.
964 This method is responsible for drawing the border inside the given @a
965 rect and adjusting the rectangle size to correspond to the area inside
966 the border, i.e. usually call wxRect::Deflate() to account for the
970 The grid whose corner window is being drawn.
972 The device context to use for drawing.
974 Input/output parameter which contains the border rectangle on input
975 and should be updated to contain the area inside the border on
978 virtual void DrawBorder(const wxGrid
& grid
,
980 wxRect
& rect
) const = 0;
984 Common base class for row and column headers renderers.
986 @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer
990 class wxGridHeaderLabelsRenderer
: public wxGridCornerHeaderRenderer
994 Called by the grid to draw the specified label.
996 Notice that the base class DrawBorder() method is called before this
999 The default implementation uses wxGrid::GetLabelTextColour() and
1000 wxGrid::GetLabelFont() to draw the label.
1002 virtual void DrawLabel(const wxGrid
& grid
,
1004 const wxString
& value
,
1008 int textOrientation
) const;
1012 Base class for row headers renderer.
1014 This is the same as wxGridHeaderLabelsRenderer currently but we still use a
1015 separate class for it to distinguish it from wxGridColumnHeaderRenderer.
1017 @see wxGridRowHeaderRendererDefault
1019 @see wxGridCellAttrProvider::GetRowHeaderRenderer()
1023 class wxGridRowHeaderRenderer
: public wxGridHeaderLabelsRenderer
1028 Base class for column headers renderer.
1030 This is the same as wxGridHeaderLabelsRenderer currently but we still use a
1031 separate class for it to distinguish it from wxGridRowHeaderRenderer.
1033 @see wxGridColumnHeaderRendererDefault
1035 @see wxGridCellAttrProvider::GetColumnHeaderRenderer()
1039 class wxGridColumnHeaderRenderer
: public wxGridHeaderLabelsRenderer
1044 Default row header renderer.
1046 You may derive from this class if you need to only override one of its
1047 methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the
1048 default implementation for the other one.
1050 @see wxGridColumnHeaderRendererDefault
1054 class wxGridRowHeaderRendererDefault
: public wxGridRowHeaderRenderer
1057 /// Implement border drawing for the row labels.
1058 virtual void DrawBorder(const wxGrid
& grid
,
1060 wxRect
& rect
) const;
1064 Default column header renderer.
1066 @see wxGridRowHeaderRendererDefault
1070 class wxGridColumnHeaderRendererDefault
: public wxGridColumnHeaderRenderer
1073 /// Implement border drawing for the column labels.
1074 virtual void DrawBorder(const wxGrid
& grid
,
1076 wxRect
& rect
) const;
1080 Default corner window renderer.
1082 @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault
1086 class wxGridCornerHeaderRendererDefault
: public wxGridCornerHeaderRenderer
1089 /// Implement border drawing for the corner window.
1090 virtual void DrawBorder(const wxGrid
& grid
,
1092 wxRect
& rect
) const;
1096 Class providing attributes to be used for the grid cells.
1098 This class both defines an interface which grid cell attributes providers
1099 should implement -- and which can be implemented differently in derived
1100 classes -- and a default implementation of this interface which is often
1101 good enough to be used without modification, especially with not very large
1102 grids for which the efficiency of attributes storage hardly matters (see
1103 the discussion below).
1105 An object of this class can be associated with a wxGrid using
1106 wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you
1107 intend to use the default provider as it is used by wxGridTableBase by
1110 Notice that while attributes provided by this class can be set for
1111 individual cells using SetAttr() or the entire rows or columns using
1112 SetRowAttr() and SetColAttr() they are always retrieved using GetAttr()
1116 The default implementation of this class stores the attributes passed to
1117 its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A
1118 derived class may use its knowledge about how the attributes are used in
1119 your program to implement it much more efficiently: for example, using a
1120 special background colour for all even-numbered rows can be implemented by
1121 simply returning the same attribute from GetAttr() if the row number is
1122 even instead of having to store N/2 row attributes where N is the total
1123 number of rows in the grid.
1125 Notice that objects of this class can't be copied.
1127 class wxGridCellAttrProvider
: public wxClientDataContainer
1130 /// Trivial default constructor.
1131 wxGridCellAttrProvider();
1133 /// Destructor releases any attributes held by this class.
1134 virtual ~wxGridCellAttrProvider();
1137 Get the attribute to use for the specified cell.
1139 If wxGridCellAttr::Any is used as @a kind value, this function combines
1140 the attributes set for this cell using SetAttr() and those for its row
1141 or column (set with SetRowAttr() or SetColAttr() respectively), with
1142 the cell attribute having the highest precedence.
1144 Notice that the caller must call DecRef() on the returned pointer if it
1148 The row of the cell.
1150 The column of the cell.
1152 The kind of the attribute to return.
1154 The attribute to use which should be DecRef()'d by caller or @NULL
1155 if no attributes are defined for this cell.
1157 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
1158 wxGridCellAttr::wxAttrKind kind
) const;
1163 All these functions take ownership of the attribute passed to them,
1164 i.e. will call DecRef() on it themselves later and so it should not be
1165 destroyed by the caller. And the attribute can be @NULL to reset a
1166 previously set value.
1170 /// Set attribute for the specified cell.
1171 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
1173 /// Set attribute for the specified row.
1174 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
1176 /// Set attribute for the specified column.
1177 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
1182 Getting header renderers.
1184 These functions return the renderers for the given row or column header
1185 label and the corner window. Unlike cell attributes, these objects are
1186 not reference counted and are never @NULL so they are returned by
1187 reference and not pointer and DecRef() shouldn't (and can't) be called
1190 All these functions were added in wxWidgets 2.9.1.
1195 Return the renderer used for drawing column headers.
1197 By default wxGridColumnHeaderRendererDefault is returned.
1199 @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader()
1203 virtual const wxGridColumnHeaderRenderer
& GetColumnHeaderRenderer(int col
);
1206 Return the renderer used for drawing row headers.
1208 By default wxGridRowHeaderRendererDefault is returned.
1212 virtual const wxGridRowHeaderRenderer
& GetRowHeaderRenderer(int row
);
1215 Return the renderer used for drawing the corner window.
1217 By default wxGridCornerHeaderRendererDefault is returned.
1221 virtual const wxGridCornerHeaderRenderer
& GetCornerRenderer();
1227 Represents coordinates of a grid cell.
1229 An object of this class is simply a (row, column) pair.
1231 class wxGridCellCoords
1235 Default constructor initializes the object to invalid state.
1237 Initially the row and column are both invalid (-1) and so operator!()
1238 for an uninitialized wxGridCellCoords returns false.
1243 Constructor taking a row and a column.
1245 wxGridCellCoords(int row
, int col
);
1248 Return the row of the coordinate.
1253 Set the row of the coordinate.
1258 Return the column of the coordinate.
1263 Set the column of the coordinate.
1268 Set the row and column of the coordinate.
1270 void Set(int row
, int col
);
1273 Assignment operator for coordinate types.
1275 wxGridCellCoords
& operator=(const wxGridCellCoords
& other
);
1280 bool operator==(const wxGridCellCoords
& other
) const;
1283 Inequality operator.
1285 bool operator!=(const wxGridCellCoords
& other
) const;
1288 Checks whether the coordinates are invalid.
1290 Returns false only if both row and column are -1. Notice that if either
1291 row or column (but not both) are -1, this method returns true even if
1292 the object is invalid. This is done because objects in such state
1293 should actually never exist, i.e. either both coordinates should be -1
1294 or none of them should be -1.
1296 bool operator!() const;
1300 @class wxGridTableBase
1302 The almost abstract base class for grid tables.
1304 A grid table is responsible for storing the grid data and, indirectly, grid
1305 cell attributes. The data can be stored in the way most convenient for the
1306 application but has to be provided in string form to wxGrid. It is also
1307 possible to provide cells values in other formats if appropriate, e.g. as
1310 This base class is not quite abstract as it implements a trivial strategy
1311 for storing the attributes by forwarding it to wxGridCellAttrProvider and
1312 also provides stubs for some other functions. However it does have a number
1313 of pure virtual methods which must be implemented in the derived classes.
1315 @see wxGridStringTable
1320 class wxGridTableBase
: public wxObject
1324 Default constructor.
1329 Destructor frees the attribute provider if it was created.
1331 virtual ~wxGridTableBase();
1334 Must be overridden to return the number of rows in the table.
1336 For backwards compatibility reasons, this method is not const.
1337 Use GetRowsCount() instead of it in const methods of derived table
1340 virtual int GetNumberRows() = 0;
1343 Must be overridden to return the number of columns in the table.
1345 For backwards compatibility reasons, this method is not const.
1346 Use GetColsCount() instead of it in const methods of derived table
1349 virtual int GetNumberCols() = 0;
1352 Return the number of rows in the table.
1354 This method is not virtual and is only provided as a convenience for
1355 the derived classes which can't call GetNumberRows() without a
1356 @c const_cast from their const methods.
1358 int GetRowsCount() const;
1361 Return the number of columns in the table.
1363 This method is not virtual and is only provided as a convenience for
1364 the derived classes which can't call GetNumberCols() without a
1365 @c const_cast from their const methods.
1367 int GetColsCount() const;
1371 @name Table Cell Accessors
1376 May be overridden to implement testing for empty cells.
1378 This method is used by the grid to test if the given cell is not used
1379 and so whether a neighbouring cell may overflow into it. By default it
1380 only returns true if the value of the given cell, as returned by
1381 GetValue(), is empty.
1383 virtual bool IsEmptyCell(int row
, int col
);
1386 Same as IsEmptyCell() but taking wxGridCellCoords.
1388 Notice that this method is not virtual, only IsEmptyCell() should be
1391 bool IsEmpty(const wxGridCellCoords
& coords
);
1394 Must be overridden to implement accessing the table values as text.
1396 virtual wxString
GetValue(int row
, int col
) = 0;
1399 Must be overridden to implement setting the table values as text.
1401 virtual void SetValue(int row
, int col
, const wxString
& value
) = 0;
1404 Returns the type of the value in the given cell.
1406 By default all cells are strings and this method returns
1407 @c wxGRID_VALUE_STRING.
1409 virtual wxString
GetTypeName(int row
, int col
);
1412 Returns true if the value of the given cell can be accessed as if it
1413 were of the specified type.
1415 By default the cells can only be accessed as strings. Note that a cell
1416 could be accessible in different ways, e.g. a numeric cell may return
1417 @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
1418 indicating that the value can be coerced to a string form.
1420 virtual bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
1423 Returns true if the value of the given cell can be set as if it were of
1426 @see CanGetValueAs()
1428 virtual bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
1431 Returns the value of the given cell as a long.
1433 This should only be called if CanGetValueAs() returns @true when called
1434 with @c wxGRID_VALUE_NUMBER argument. Default implementation always
1437 virtual long GetValueAsLong(int row
, int col
);
1440 Returns the value of the given cell as a double.
1442 This should only be called if CanGetValueAs() returns @true when called
1443 with @c wxGRID_VALUE_FLOAT argument. Default implementation always
1446 virtual double GetValueAsDouble(int row
, int col
);
1449 Returns the value of the given cell as a boolean.
1451 This should only be called if CanGetValueAs() returns @true when called
1452 with @c wxGRID_VALUE_BOOL argument. Default implementation always
1455 virtual bool GetValueAsBool(int row
, int col
);
1458 Returns the value of the given cell as a user-defined type.
1460 This should only be called if CanGetValueAs() returns @true when called
1461 with @a typeName. Default implementation always return @NULL.
1463 virtual void *GetValueAsCustom(int row
, int col
, const wxString
& typeName
);
1466 Sets the value of the given cell as a long.
1468 This should only be called if CanSetValueAs() returns @true when called
1469 with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
1472 virtual void SetValueAsLong(int row
, int col
, long value
);
1475 Sets the value of the given cell as a double.
1477 This should only be called if CanSetValueAs() returns @true when called
1478 with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
1481 virtual void SetValueAsDouble(int row
, int col
, double value
);
1484 Sets the value of the given cell as a boolean.
1486 This should only be called if CanSetValueAs() returns @true when called
1487 with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
1490 virtual void SetValueAsBool( int row
, int col
, bool value
);
1493 Sets the value of the given cell as a user-defined type.
1495 This should only be called if CanSetValueAs() returns @true when called
1496 with @a typeName. Default implementation doesn't do anything.
1498 virtual void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
1505 Called by the grid when the table is associated with it.
1507 The default implementation stores the pointer and returns it from its
1508 GetView() and so only makes sense if the table cannot be associated
1509 with more than one grid at a time.
1511 virtual void SetView(wxGrid
*grid
);
1514 Returns the last grid passed to SetView().
1516 virtual wxGrid
*GetView() const;
1520 @name Table Structure Modifiers
1522 Notice that none of these functions are pure virtual as they don't have
1523 to be implemented if the table structure is never modified after
1524 creation, i.e. neither rows nor columns are never added or deleted but
1525 that you do need to implement them if they are called, i.e. if your
1526 code either calls them directly or uses the matching wxGrid methods, as
1527 by default they simply do nothing which is definitely inappropriate.
1532 Clear the table contents.
1534 This method is used by wxGrid::ClearGrid().
1536 virtual void Clear();
1539 Insert additional rows into the table.
1542 The position of the first new row.
1544 The number of rows to insert.
1546 virtual bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
1549 Append additional rows at the end of the table.
1551 This method is provided in addition to InsertRows() as some data models
1552 may only support appending rows to them but not inserting them at
1553 arbitrary locations. In such case you may implement this method only
1554 and leave InsertRows() unimplemented.
1557 The number of rows to add.
1559 virtual bool AppendRows(size_t numRows
= 1);
1562 Delete rows from the table.
1564 Notice that currently deleting a row intersecting a multi-cell (see
1565 SetCellSize()) is not supported and will result in a crash.
1568 The first row to delete.
1570 The number of rows to delete.
1572 virtual bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
1575 Exactly the same as InsertRows() but for columns.
1577 virtual bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
1580 Exactly the same as AppendRows() but for columns.
1582 virtual bool AppendCols(size_t numCols
= 1);
1585 Exactly the same as DeleteRows() but for columns.
1587 virtual bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
1592 @name Table Row and Column Labels
1594 By default the numbers are used for labeling rows and Latin letters for
1595 labeling columns. If the table has more than 26 columns, the pairs of
1596 letters are used starting from the 27-th one and so on, i.e. the
1597 sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
1603 Return the label of the specified row.
1605 virtual wxString
GetRowLabelValue(int row
);
1608 Return the label of the specified column.
1610 virtual wxString
GetColLabelValue(int col
);
1613 Set the given label for the specified row.
1615 The default version does nothing, i.e. the label is not stored. You
1616 must override this method in your derived class if you wish
1617 wxGrid::SetRowLabelValue() to work.
1619 virtual void SetRowLabelValue(int row
, const wxString
& label
);
1622 Exactly the same as SetRowLabelValue() but for columns.
1624 virtual void SetColLabelValue(int col
, const wxString
& label
);
1630 @name Attributes Management
1632 By default the attributes management is delegated to
1633 wxGridCellAttrProvider class. You may override the methods in this
1634 section to handle the attributes directly if, for example, they can be
1635 computed from the cell values.
1640 Associate this attributes provider with the table.
1642 The table takes ownership of @a attrProvider pointer and will delete it
1643 when it doesn't need it any more. The pointer can be @NULL, however
1644 this won't disable attributes management in the table but will just
1645 result in a default attributes being recreated the next time any of the
1646 other functions in this section is called. To completely disable the
1647 attributes support, should this be needed, you need to override
1648 CanHaveAttributes() to return @false.
1650 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
1653 Returns the attribute provider currently being used.
1655 This function may return @NULL if the attribute provider hasn't been
1656 neither associated with this table by SetAttrProvider() nor created on
1657 demand by any other methods.
1659 wxGridCellAttrProvider
*GetAttrProvider() const;
1662 Return the attribute for the given cell.
1664 By default this function is simply forwarded to
1665 wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
1666 attributes directly in the table.
1668 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
1669 wxGridCellAttr::wxAttrKind kind
);
1672 Set attribute of the specified cell.
1674 By default this function is simply forwarded to
1675 wxGridCellAttrProvider::SetAttr().
1677 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1679 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
1682 Set attribute of the specified row.
1684 By default this function is simply forwarded to
1685 wxGridCellAttrProvider::SetRowAttr().
1687 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1689 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
1692 Set attribute of the specified column.
1694 By default this function is simply forwarded to
1695 wxGridCellAttrProvider::SetColAttr().
1697 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1699 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
1704 Returns true if this table supports attributes or false otherwise.
1706 By default, the table automatically creates a wxGridCellAttrProvider
1707 when this function is called if it had no attribute provider before and
1710 virtual bool CanHaveAttributes();
1715 enum wxGridTableRequest
1717 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
1718 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
1719 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
1720 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
1721 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
1722 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
1723 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
1724 wxGRIDTABLE_NOTIFY_COLS_DELETED
1729 @class wxGridTableMessage
1731 A simple class used to pass messages from the table to the grid.
1736 class wxGridTableMessage
1739 wxGridTableMessage();
1740 wxGridTableMessage( wxGridTableBase
*table
, int id
,
1744 void SetTableObject( wxGridTableBase
*table
);
1745 wxGridTableBase
* GetTableObject() const;
1746 void SetId( int id
);
1748 void SetCommandInt( int comInt1
);
1749 int GetCommandInt();
1750 void SetCommandInt2( int comInt2
);
1751 int GetCommandInt2();
1757 @class wxGridStringTable
1759 Simplest type of data table for a grid for small tables of strings
1760 that are stored in memory
1762 class wxGridStringTable
: public wxGridTableBase
1765 wxGridStringTable();
1766 wxGridStringTable( int numRows
, int numCols
);
1768 // these are pure virtual in wxGridTableBase
1769 virtual int GetNumberRows();
1770 virtual int GetNumberCols();
1771 virtual wxString
GetValue( int row
, int col
);
1772 virtual void SetValue( int row
, int col
, const wxString
& value
);
1774 // overridden functions from wxGridTableBase
1776 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
1777 bool AppendRows( size_t numRows
= 1 );
1778 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
1779 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
1780 bool AppendCols( size_t numCols
= 1 );
1781 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
1783 void SetRowLabelValue( int row
, const wxString
& );
1784 void SetColLabelValue( int col
, const wxString
& );
1785 wxString
GetRowLabelValue( int row
);
1786 wxString
GetColLabelValue( int col
);
1795 @class wxGridSizesInfo
1797 wxGridSizesInfo stores information about sizes of all wxGrid rows or
1800 It assumes that most of the rows or columns (which are both called elements
1801 here as the difference between them doesn't matter at this class level)
1802 have the default size and so stores it separately. And it uses a wxHashMap
1803 to store the sizes of all elements which have the non-default size.
1805 This structure is particularly useful for serializing the sizes of all
1806 wxGrid elements at once.
1811 struct wxGridSizesInfo
1814 Default constructor.
1816 m_sizeDefault and m_customSizes must be initialized later.
1823 This constructor is used by wxGrid::GetRowSizes() and GetColSizes()
1824 methods. User code will usually use the default constructor instead.
1827 The default element size.
1829 Array containing the sizes of @em all elements, including those
1830 which have the default size.
1832 wxGridSizesInfo(int defSize
, const wxArrayInt
& allSizes
);
1835 Get the element size.
1838 The index of the element.
1840 The size for this element, using m_customSizes if @a pos is in it
1841 or m_sizeDefault otherwise.
1843 int GetSize(unsigned pos
) const;
1850 Map with element indices as keys and their sizes as values.
1852 This map only contains the elements with non-default size.
1854 wxUnsignedToIntHashMap m_customSizes
;
1860 Rendering styles supported by wxGrid::Render() method.
1864 enum wxGridRenderStyle
1866 /// Draw grid row header labels.
1867 wxGRID_DRAW_ROWS_HEADER
= 0x001,
1869 /// Draw grid column header labels.
1870 wxGRID_DRAW_COLS_HEADER
= 0x002,
1872 /// Draw grid cell border lines.
1873 wxGRID_DRAW_CELL_LINES
= 0x004,
1876 Draw a bounding rectangle around the rendered cell area.
1878 Useful where row or column headers are not drawn or where there is
1879 multi row or column cell clipping and therefore no cell border at
1880 the rendered outer boundary.
1882 wxGRID_DRAW_BOX_RECT
= 0x008,
1885 Draw the grid cell selection highlight if a selection is present.
1887 At present the highlight colour drawn depends on whether the grid
1888 window loses focus before drawing begins.
1890 wxGRID_DRAW_SELECTION
= 0x010,
1893 The default render style.
1895 Includes all except wxGRID_DRAW_SELECTION.
1897 wxGRID_DRAW_DEFAULT
= wxGRID_DRAW_ROWS_HEADER
|
1898 wxGRID_DRAW_COLS_HEADER
|
1899 wxGRID_DRAW_CELL_LINES
|
1900 wxGRID_DRAW_BOX_RECT
1908 wxGrid and its related classes are used for displaying and editing tabular
1909 data. They provide a rich set of features for display, editing, and
1910 interacting with a variety of data sources. For simple applications, and to
1911 help you get started, wxGrid is the only class you need to refer to
1912 directly. It will set up default instances of the other classes and manage
1913 them for you. For more complex applications you can derive your own classes
1914 for custom grid views, grid data tables, cell editors and renderers. The
1915 @ref overview_grid has examples of simple and more complex applications,
1916 explains the relationship between the various grid classes and has a
1917 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1919 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1920 class. One or more wxGrid classes may act as a view for one table class.
1921 The default table class is called wxGridStringTable and holds an array of
1922 strings. An instance of such a class is created by CreateGrid().
1924 wxGridCellRenderer is the abstract base class for rendering contents in a
1925 cell. The following renderers are predefined:
1927 - wxGridCellBoolRenderer
1928 - wxGridCellFloatRenderer
1929 - wxGridCellNumberRenderer
1930 - wxGridCellStringRenderer
1932 The look of a cell can be further defined using wxGridCellAttr. An object
1933 of this type may be returned by wxGridTableBase::GetAttr().
1935 wxGridCellEditor is the abstract base class for editing the value of a
1936 cell. The following editors are predefined:
1938 - wxGridCellBoolEditor
1939 - wxGridCellChoiceEditor
1940 - wxGridCellFloatEditor
1941 - wxGridCellNumberEditor
1942 - wxGridCellTextEditor
1944 Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and
1945 wxGridEditorCreatedEvent for the documentation of all event types you can
1951 @see @ref overview_grid, wxGridUpdateLocker
1953 class wxGrid
: public wxScrolledWindow
1958 Different selection modes supported by the grid.
1960 enum wxGridSelectionModes
1963 The default selection mode allowing selection of the individual
1964 cells as well as of the entire rows and columns.
1969 The selection mode allowing the selection of the entire rows only.
1971 The user won't be able to select any cells or columns in this mode.
1976 The selection mode allowing the selection of the entire columns only.
1978 The user won't be able to select any cells or rows in this mode.
1980 wxGridSelectColumns
,
1983 The selection mode allowing the user to select either the entire
1984 columns or the entire rows but not individual cells nor blocks.
1986 Notice that while this constant is defined as @code
1987 wxGridSelectColumns | wxGridSelectRows @endcode this doesn't mean
1988 that all the other combinations are valid -- at least currently
1993 wxGridSelectRowsOrColumns
1997 Return values for GetCellSize().
2003 /// This cell is inside a span covered by another cell.
2004 CellSpan_Inside
= -1,
2006 /// This is a normal, non-spanning cell.
2009 /// This cell spans several physical wxGrid cells.
2014 Constants defining different support built-in TAB handling behaviours.
2016 The elements of this enum determine what happens when TAB is pressed
2017 when the cursor is in the rightmost column (or Shift-TAB is pressed
2018 when the cursor is in the leftmost one).
2020 @see SetTabBehaviour(), @c wxEVT_GRID_TABBING
2026 /// Do nothing, this is default.
2029 /// Move to the beginning of the next (or the end of the previous) row.
2032 /// Move to the next (or the previous) control after the grid.
2037 @name Constructors and Initialization
2042 Default constructor.
2044 You must call Create() to really create the grid window and also call
2045 CreateGrid() or SetTable() to initialize the grid contents.
2049 Constructor creating the grid window.
2051 You must call either CreateGrid() or SetTable() to initialize the grid
2052 contents before using it.
2054 wxGrid(wxWindow
* parent
, wxWindowID id
,
2055 const wxPoint
& pos
= wxDefaultPosition
,
2056 const wxSize
& size
= wxDefaultSize
,
2057 long style
= wxWANTS_CHARS
,
2058 const wxString
& name
= wxGridNameStr
);
2063 This will also destroy the associated grid table unless you passed a
2064 table object to the grid and specified that the grid should not take
2065 ownership of the table (see SetTable()).
2070 Creates the grid window for an object initialized using the default
2073 You must call either CreateGrid() or SetTable() to initialize the grid
2074 contents before using it.
2076 bool Create(wxWindow
* parent
, wxWindowID id
,
2077 const wxPoint
& pos
= wxDefaultPosition
,
2078 const wxSize
& size
= wxDefaultSize
,
2079 long style
= wxWANTS_CHARS
,
2080 const wxString
& name
= wxGridNameStr
);
2083 Creates a grid with the specified initial number of rows and columns.
2085 Call this directly after the grid constructor. When you use this
2086 function wxGrid will create and manage a simple table of string values
2087 for you. All of the grid data will be stored in memory.
2089 For applications with more complex data types or relationships, or for
2090 dealing with very large datasets, you should derive your own grid table
2091 class and pass a table object to the grid with SetTable().
2093 bool CreateGrid(int numRows
, int numCols
,
2094 wxGridSelectionModes selmode
= wxGridSelectCells
);
2097 Passes a pointer to a custom grid table to be used by the grid.
2099 This should be called after the grid constructor and before using the
2100 grid object. If @a takeOwnership is set to @true then the table will be
2101 deleted by the wxGrid destructor.
2103 Use this function instead of CreateGrid() when your application
2104 involves complex or non-string data or data sets that are too large to
2105 fit wholly in memory.
2107 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= false,
2108 wxGridSelectionModes selmode
= wxGridSelectCells
);
2111 Receive and handle a message from the table.
2113 bool ProcessTableMessage(wxGridTableMessage
& msg
);
2119 @name Grid Line Formatting
2124 Turns the drawing of grid lines on or off.
2126 void EnableGridLines(bool enable
= true);
2129 Returns the pen used for vertical grid lines.
2131 This virtual function may be overridden in derived classes in order to
2132 change the appearance of individual grid lines for the given column
2135 See GetRowGridLinePen() for an example.
2137 virtual wxPen
GetColGridLinePen(int col
);
2140 Returns the pen used for grid lines.
2142 This virtual function may be overridden in derived classes in order to
2143 change the appearance of grid lines. Note that currently the pen width
2146 @see GetColGridLinePen(), GetRowGridLinePen()
2148 virtual wxPen
GetDefaultGridLinePen();
2151 Returns the colour used for grid lines.
2153 @see GetDefaultGridLinePen()
2155 wxColour
GetGridLineColour() const;
2158 Returns the pen used for horizontal grid lines.
2160 This virtual function may be overridden in derived classes in order to
2161 change the appearance of individual grid line for the given @a row.
2165 // in a grid displaying music notation, use a solid black pen between
2166 // octaves (C0=row 127, C1=row 115 etc.)
2167 wxPen MidiGrid::GetRowGridLinePen(int row)
2169 if ( row % 12 == 7 )
2170 return wxPen(*wxBLACK, 1, wxSOLID);
2172 return GetDefaultGridLinePen();
2176 virtual wxPen
GetRowGridLinePen(int row
);
2179 Returns @true if drawing of grid lines is turned on, @false otherwise.
2181 bool GridLinesEnabled() const;
2184 Sets the colour used to draw grid lines.
2186 void SetGridLineColour(const wxColour
& colour
);
2192 @name Label Values and Formatting
2197 Sets the arguments to the current column label alignment values.
2199 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2200 or @c wxALIGN_RIGHT.
2202 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2205 void GetColLabelAlignment(int* horiz
, int* vert
) const;
2208 Returns the orientation of the column labels (either @c wxHORIZONTAL or
2211 int GetColLabelTextOrientation() const;
2214 Returns the specified column label.
2216 The default grid table class provides column labels of the form
2217 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
2218 override wxGridTableBase::GetColLabelValue() to provide your own
2221 wxString
GetColLabelValue(int col
) const;
2224 Returns the colour used for the background of row and column labels.
2226 wxColour
GetLabelBackgroundColour() const;
2229 Returns the font used for row and column labels.
2231 wxFont
GetLabelFont() const;
2234 Returns the colour used for row and column label text.
2236 wxColour
GetLabelTextColour() const;
2239 Returns the alignment used for row labels.
2241 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2242 or @c wxALIGN_RIGHT.
2244 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2247 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
2250 Returns the specified row label.
2252 The default grid table class provides numeric row labels. If you are
2253 using a custom grid table you can override
2254 wxGridTableBase::GetRowLabelValue() to provide your own labels.
2256 wxString
GetRowLabelValue(int row
) const;
2259 Hides the column labels by calling SetColLabelSize() with a size of 0.
2260 Show labels again by calling that method with a width greater than 0.
2262 void HideColLabels();
2265 Hides the row labels by calling SetRowLabelSize() with a size of 0.
2267 The labels can be shown again by calling SetRowLabelSize() with a width
2270 void HideRowLabels();
2273 Sets the horizontal and vertical alignment of column label text.
2275 Horizontal alignment should be one of @c wxALIGN_LEFT,
2276 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2277 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2279 void SetColLabelAlignment(int horiz
, int vert
);
2282 Sets the orientation of the column labels (either @c wxHORIZONTAL or
2285 void SetColLabelTextOrientation(int textOrientation
);
2288 Set the value for the given column label.
2290 If you are using a custom grid table you must override
2291 wxGridTableBase::SetColLabelValue() for this to have any effect.
2293 void SetColLabelValue(int col
, const wxString
& value
);
2296 Sets the background colour for row and column labels.
2298 void SetLabelBackgroundColour(const wxColour
& colour
);
2301 Sets the font for row and column labels.
2303 void SetLabelFont(const wxFont
& font
);
2306 Sets the colour for row and column label text.
2308 void SetLabelTextColour(const wxColour
& colour
);
2311 Sets the horizontal and vertical alignment of row label text.
2313 Horizontal alignment should be one of @c wxALIGN_LEFT,
2314 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2315 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2317 void SetRowLabelAlignment(int horiz
, int vert
);
2320 Sets the value for the given row label.
2322 If you are using a derived grid table you must override
2323 wxGridTableBase::SetRowLabelValue() for this to have any effect.
2325 void SetRowLabelValue(int row
, const wxString
& value
);
2328 Call this in order to make the column labels use a native look by using
2329 wxRendererNative::DrawHeaderButton() internally.
2331 There is no equivalent method for drawing row columns as there is not
2332 native look for that. This option is useful when using wxGrid for
2333 displaying tables and not as a spread-sheet.
2335 @see UseNativeColHeader()
2337 void SetUseNativeColLabels(bool native
= true);
2340 Enable the use of native header window for column labels.
2342 If this function is called with @true argument, a wxHeaderCtrl is used
2343 instead to display the column labels instead of drawing them in wxGrid
2344 code itself. This has the advantage of making the grid look and feel
2345 perfectly the same as native applications (using SetUseNativeColLabels()
2346 the grid can be made to look more natively but it still doesn't feel
2347 natively, notably the column resizing and dragging still works slightly
2348 differently as it is implemented in wxWidgets itself) but results in
2349 different behaviour for column and row headers, for which there is no
2350 equivalent function, and, most importantly, is unsuitable for grids
2351 with huge numbers of columns as wxHeaderCtrl doesn't support virtual
2352 mode. Because of this, by default the grid does not use the native
2353 header control but you should call this function to enable it if you
2354 are using the grid to display tabular data and don't have thousands of
2357 Another difference between the default behaviour and the native header
2358 behaviour is that the latter provides the user with a context menu
2359 (which appears on right clicking the header) allowing to rearrange the
2360 grid columns if CanDragColMove() returns @true. If you want to prevent
2361 this from happening for some reason, you need to define a handler for
2362 @c wxEVT_GRID_LABEL_RIGHT_CLICK event which simply does nothing (in
2363 particular doesn't skip the event) as this will prevent the default
2364 right click handling from working.
2366 Also note that currently @c wxEVT_GRID_LABEL_RIGHT_DCLICK event is not
2367 generated for the column labels if the native columns header is used
2368 (but this limitation could possibly be lifted in the future).
2370 void UseNativeColHeader(bool native
= true);
2376 @name Cell Formatting
2378 Note that wxGridCellAttr can be used alternatively to most of these
2379 methods. See the "Attributes Management" of wxGridTableBase.
2384 Sets the arguments to the horizontal and vertical text alignment values
2385 for the grid cell at the specified location.
2387 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2388 or @c wxALIGN_RIGHT.
2390 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2393 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
2396 Returns the background colour of the cell at the specified location.
2398 wxColour
GetCellBackgroundColour(int row
, int col
) const;
2401 Returns the font for text in the grid cell at the specified location.
2403 wxFont
GetCellFont(int row
, int col
) const;
2406 Returns the text colour for the grid cell at the specified location.
2408 wxColour
GetCellTextColour(int row
, int col
) const;
2411 Returns the default cell alignment.
2413 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2414 or @c wxALIGN_RIGHT.
2416 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2419 @see SetDefaultCellAlignment()
2421 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
2424 Returns the current default background colour for grid cells.
2426 wxColour
GetDefaultCellBackgroundColour() const;
2429 Returns the current default font for grid cell text.
2431 wxFont
GetDefaultCellFont() const;
2434 Returns the current default colour for grid cell text.
2436 wxColour
GetDefaultCellTextColour() const;
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 row
, int col
, int horiz
, int vert
);
2450 Sets the horizontal and vertical alignment for grid cell text at the
2453 Horizontal alignment should be one of @c wxALIGN_LEFT,
2454 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2456 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2457 or @c wxALIGN_BOTTOM.
2459 void SetCellAlignment(int align
, int row
, int col
);
2462 Set the background colour for the given cell or all cells by default.
2464 void SetCellBackgroundColour(int row
, int col
, const wxColour
& colour
);
2467 Sets the font for text in the grid cell at the specified location.
2469 void SetCellFont(int row
, int col
, const wxFont
& font
);
2472 Sets the text colour for the given cell.
2474 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2476 Sets the text colour for the given cell.
2478 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2480 Sets the text colour for all cells by default.
2482 void SetCellTextColour(const wxColour
& colour
);
2485 Sets the default horizontal and vertical alignment for grid cell text.
2487 Horizontal alignment should be one of @c wxALIGN_LEFT,
2488 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
2489 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
2491 void SetDefaultCellAlignment(int horiz
, int vert
);
2494 Sets the default background colour for grid cells.
2496 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2499 Sets the default font to be used for grid cell text.
2501 void SetDefaultCellFont(const wxFont
& font
);
2504 Sets the current default colour for grid cell text.
2506 void SetDefaultCellTextColour(const wxColour
& colour
);
2512 @name Cell Values, Editors, and Renderers
2514 Note that wxGridCellAttr can be used alternatively to most of these
2515 methods. See the "Attributes Management" of wxGridTableBase.
2520 Returns @true if the in-place edit control for the current grid cell
2521 can be used and @false otherwise.
2523 This function always returns @false for the read-only cells.
2525 bool CanEnableCellControl() const;
2528 Disables in-place editing of grid cells.
2530 Equivalent to calling EnableCellEditControl(@false).
2532 void DisableCellEditControl();
2535 Enables or disables in-place editing of grid cell data.
2537 The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or
2538 @c wxEVT_GRID_EDITOR_HIDDEN event.
2540 void EnableCellEditControl(bool enable
= true);
2543 Makes the grid globally editable or read-only.
2545 If the edit argument is @false this function sets the whole grid as
2546 read-only. If the argument is @true the grid is set to the default
2547 state where cells may be editable. In the default state you can set
2548 single grid cells and whole rows and columns to be editable or
2549 read-only via wxGridCellAttr::SetReadOnly(). For single cells you
2550 can also use the shortcut function SetReadOnly().
2552 For more information about controlling grid cell attributes see the
2553 wxGridCellAttr class and the @ref overview_grid.
2555 void EnableEditing(bool edit
);
2558 Returns a pointer to the editor for the cell at the specified location.
2560 See wxGridCellEditor 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 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
2568 Returns a pointer to the renderer for the grid cell at the specified
2571 See wxGridCellRenderer and the @ref overview_grid for more information
2572 about cell editors and renderers.
2574 The caller must call DecRef() on the returned pointer.
2576 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
2579 Returns the string contained in the cell at the specified location.
2581 For simple applications where a grid object automatically uses a
2582 default grid table of string values you use this function together with
2583 SetCellValue() to access cell values. For more complex applications
2584 where you have derived your own grid table class that contains various
2585 data types (e.g. numeric, boolean or user-defined custom types) then
2586 you only use this function for those cells that contain string values.
2588 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
2591 wxString
GetCellValue(int row
, int col
) const;
2593 Returns the string contained in the cell at the specified location.
2595 For simple applications where a grid object automatically uses a
2596 default grid table of string values you use this function together with
2597 SetCellValue() to access cell values. For more complex applications
2598 where you have derived your own grid table class that contains various
2599 data types (e.g. numeric, boolean or user-defined custom types) then
2600 you only use this function for those cells that contain string values.
2602 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
2605 wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
2608 Returns a pointer to the current default grid cell editor.
2610 See wxGridCellEditor and the @ref overview_grid for more information
2611 about cell editors and renderers.
2613 wxGridCellEditor
* GetDefaultEditor() const;
2616 Returns the default editor for the specified cell.
2618 The base class version returns the editor appropriate for the current
2619 cell type but this method may be overridden in the derived classes to
2620 use custom editors for some cells by default.
2622 Notice that the same may be achieved in a usually simpler way by
2623 associating a custom editor with the given cell or cells.
2625 The caller must call DecRef() on the returned pointer.
2627 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
2629 Returns the default editor for the specified cell.
2631 The base class version returns the editor appropriate for the current
2632 cell type but this method may be overridden in the derived classes to
2633 use custom editors for some cells by default.
2635 Notice that the same may be achieved in a usually simpler way by
2636 associating a custom editor with the given cell or cells.
2638 The caller must call DecRef() on the returned pointer.
2640 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
2643 Returns the default editor for the cells containing values of the given
2646 The base class version returns the editor which was associated with the
2647 specified @a typeName when it was registered RegisterDataType() but
2648 this function may be overridden to return something different. This
2649 allows to override an editor used for one of the standard types.
2651 The caller must call DecRef() on the returned pointer.
2653 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
2656 Returns a pointer to the current default grid cell renderer.
2658 See wxGridCellRenderer and the @ref overview_grid for more information
2659 about cell editors and renderers.
2661 The caller must call DecRef() on the returned pointer.
2663 wxGridCellRenderer
* GetDefaultRenderer() const;
2666 Returns the default renderer for the given cell.
2668 The base class version returns the renderer appropriate for the current
2669 cell type but this method may be overridden in the derived classes to
2670 use custom renderers for some cells by default.
2672 The caller must call DecRef() on the returned pointer.
2674 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
2677 Returns the default renderer for the cell containing values of the
2680 @see GetDefaultEditorForType()
2682 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
2685 Hides the in-place cell edit control.
2687 void HideCellEditControl();
2690 Returns @true if the in-place edit control is currently enabled.
2692 bool IsCellEditControlEnabled() const;
2695 Returns @true if the current cell is read-only.
2697 @see SetReadOnly(), IsReadOnly()
2699 bool IsCurrentCellReadOnly() const;
2702 Returns @false if the whole grid has been set as read-only or @true
2705 See EnableEditing() for more information about controlling the editing
2706 status of grid cells.
2708 bool IsEditable() const;
2711 Returns @true if the cell at the specified location can't be edited.
2713 @see SetReadOnly(), IsCurrentCellReadOnly()
2715 bool IsReadOnly(int row
, int col
) const;
2718 Register a new data type.
2720 The data types allow to naturally associate specific renderers and
2721 editors to the cells containing values of the given type. For example,
2722 the grid automatically registers a data type with the name
2723 @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
2724 wxGridCellTextEditor as its renderer and editor respectively -- this is
2725 the data type used by all the cells of the default wxGridStringTable,
2726 so this renderer and editor are used by default for all grid cells.
2728 However if a custom table returns @c wxGRID_VALUE_BOOL from its
2729 wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
2730 wxGridCellBoolEditor are used for it because the grid also registers a
2731 boolean data type with this name.
2733 And as this mechanism is completely generic, you may register your own
2734 data types using your own custom renderers and editors. Just remember
2735 that the table must identify a cell as being of the given type for them
2736 to be used for this cell.
2739 Name of the new type. May be any string, but if the type name is
2740 the same as the name of an already registered type, including one
2741 of the standard ones (which are @c wxGRID_VALUE_STRING, @c
2742 wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT
2743 and @c wxGRID_VALUE_CHOICE), then the new registration information
2744 replaces the previously used renderer and editor.
2746 The renderer to use for the cells of this type. Its ownership is
2747 taken by the grid, i.e. it will call DecRef() on this pointer when
2748 it doesn't need it any longer.
2750 The editor to use for the cells of this type. Its ownership is also
2753 void RegisterDataType(const wxString
& typeName
,
2754 wxGridCellRenderer
* renderer
,
2755 wxGridCellEditor
* editor
);
2758 Sets the value of the current grid cell to the current in-place edit
2761 This is called automatically when the grid cursor moves from the
2762 current cell to a new cell. It is also a good idea to call this
2763 function when closing a grid since any edits to the final cell location
2764 will not be saved otherwise.
2766 void SaveEditControlValue();
2769 Sets the editor for the grid cell at the specified location.
2771 The grid will take ownership of the pointer.
2773 See wxGridCellEditor and the @ref overview_grid for more information
2774 about cell editors and renderers.
2776 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2779 Sets the renderer for the grid cell at the specified location.
2781 The grid will take ownership of the pointer.
2783 See wxGridCellRenderer and the @ref overview_grid for more information
2784 about cell editors and renderers.
2786 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
* renderer
);
2789 Sets the string value for the cell at the specified location.
2791 For simple applications where a grid object automatically uses a
2792 default grid table of string values you use this function together with
2793 GetCellValue() to access cell values. For more complex applications
2794 where you have derived your own grid table class that contains various
2795 data types (e.g. numeric, boolean or user-defined custom types) then
2796 you only use this function for those cells that contain string values.
2798 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2801 void SetCellValue(int row
, int col
, const wxString
& s
);
2803 Sets the string value for the cell at the specified location.
2805 For simple applications where a grid object automatically uses a
2806 default grid table of string values you use this function together with
2807 GetCellValue() to access cell values. For more complex applications
2808 where you have derived your own grid table class that contains various
2809 data types (e.g. numeric, boolean or user-defined custom types) then
2810 you only use this function for those cells that contain string values.
2812 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2815 void SetCellValue(const wxGridCellCoords
& coords
, const wxString
& s
);
2817 @deprecated Please use SetCellValue(int,int,const wxString&) or
2818 SetCellValue(const wxGridCellCoords&,const wxString&)
2821 Sets the string value for the cell at the specified location.
2823 For simple applications where a grid object automatically uses a
2824 default grid table of string values you use this function together with
2825 GetCellValue() to access cell values. For more complex applications
2826 where you have derived your own grid table class that contains various
2827 data types (e.g. numeric, boolean or user-defined custom types) then
2828 you only use this function for those cells that contain string values.
2830 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2833 void SetCellValue(const wxString
& val
, int row
, int col
);
2836 Sets the specified column to display boolean values.
2838 @see SetColFormatCustom()
2840 void SetColFormatBool(int col
);
2843 Sets the specified column to display data in a custom format.
2845 This method provides an alternative to defining a custom grid table
2846 which would return @a typeName from its GetTypeName() method for the
2847 cells in this column: while it doesn't really change the type of the
2848 cells in this column, it does associate the renderer and editor used
2849 for the cells of the specified type with them.
2851 See the @ref overview_grid for more information on working with custom
2854 void SetColFormatCustom(int col
, const wxString
& typeName
);
2857 Sets the specified column to display floating point values with the
2858 given width and precision.
2860 @see SetColFormatCustom()
2862 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
2865 Sets the specified column to display integer values.
2867 @see SetColFormatCustom()
2869 void SetColFormatNumber(int col
);
2872 Sets the default editor for grid cells.
2874 The grid will take ownership of the pointer.
2876 See wxGridCellEditor and the @ref overview_grid for more information
2877 about cell editors and renderers.
2879 void SetDefaultEditor(wxGridCellEditor
* editor
);
2882 Sets the default renderer for grid cells.
2884 The grid will take ownership of the pointer.
2886 See wxGridCellRenderer and the @ref overview_grid for more information
2887 about cell editors and renderers.
2889 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2892 Makes the cell at the specified location read-only or editable.
2896 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2899 Displays the in-place cell edit control for the current cell.
2901 void ShowCellEditControl();
2907 @name Column and Row Sizes
2909 @see @ref overview_grid_resizing
2914 Automatically sets the height and width of all rows and columns to fit
2920 Automatically adjusts width of the column to fit its label.
2922 void AutoSizeColLabelSize(int col
);
2925 Automatically sizes the column to fit its contents. If @a setAsMin is
2926 @true the calculated width will also be set as the minimal width for
2929 void AutoSizeColumn(int col
, bool setAsMin
= true);
2932 Automatically sizes all columns to fit their contents. If @a setAsMin
2933 is @true the calculated widths will also be set as the minimal widths
2936 void AutoSizeColumns(bool setAsMin
= true);
2939 Automatically sizes the row to fit its contents. If @a setAsMin is
2940 @true the calculated height will also be set as the minimal height for
2943 void AutoSizeRow(int row
, bool setAsMin
= true);
2946 Automatically adjusts height of the row to fit its label.
2948 void AutoSizeRowLabelSize(int col
);
2951 Automatically sizes all rows to fit their contents. If @a setAsMin is
2952 @true the calculated heights will also be set as the minimal heights
2955 void AutoSizeRows(bool setAsMin
= true);
2958 Returns @true if the cell value can overflow.
2960 A cell can overflow if the next cell in the row is empty.
2962 bool GetCellOverflow(int row
, int col
) const;
2965 Returns the current height of the column labels.
2967 int GetColLabelSize() const;
2970 Returns the minimal width to which a column may be resized.
2972 Use SetColMinimalAcceptableWidth() to change this value globally or
2973 SetColMinimalWidth() to do it for individual columns.
2975 @see GetRowMinimalAcceptableHeight()
2977 int GetColMinimalAcceptableWidth() const;
2980 Returns the width of the specified column.
2982 int GetColSize(int col
) const;
2985 Returns @true if the specified column is not currently hidden.
2987 bool IsColShown(int col
) const;
2990 Returns @true if the cells can overflow by default.
2992 bool GetDefaultCellOverflow() const;
2995 Returns the default height for column labels.
2997 int GetDefaultColLabelSize() const;
3000 Returns the current default width for grid columns.
3002 int GetDefaultColSize() const;
3005 Returns the default width for the row labels.
3007 int GetDefaultRowLabelSize() const;
3010 Returns the current default height for grid rows.
3012 int GetDefaultRowSize() const;
3015 Returns the minimal size to which rows can be resized.
3017 Use SetRowMinimalAcceptableHeight() to change this value globally or
3018 SetRowMinimalHeight() to do it for individual cells.
3020 @see GetColMinimalAcceptableWidth()
3022 int GetRowMinimalAcceptableHeight() const;
3025 Returns the current width of the row labels.
3027 int GetRowLabelSize() const;
3030 Returns the height of the specified row.
3032 int GetRowSize(int row
) const;
3035 Returns @true if the specified row is not currently hidden.
3037 bool IsRowShown(int row
) const;
3040 Sets the overflow permission of the cell.
3042 void SetCellOverflow(int row
, int col
, bool allow
);
3045 Sets the height of the column labels.
3047 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
3048 automatically so that no label is truncated. Note that this could be
3049 slow for a large table.
3051 void SetColLabelSize(int height
);
3054 Sets the minimal @a width to which the user can resize columns.
3056 @see GetColMinimalAcceptableWidth()
3058 void SetColMinimalAcceptableWidth(int width
);
3061 Sets the minimal @a width for the specified column @a col.
3063 It is usually best to call this method during grid creation as calling
3064 it later will not resize the column to the given minimal width even if
3065 it is currently narrower than it.
3067 @a width must be greater than the minimal acceptable column width as
3068 returned by GetColMinimalAcceptableWidth().
3070 void SetColMinimalWidth(int col
, int width
);
3073 Sets the width of the specified column.
3078 The new column width in pixels, 0 to hide the column or -1 to fit
3079 the column width to its label width.
3081 void SetColSize(int col
, int width
);
3084 Hides the specified column.
3086 To show the column later you need to call SetColSize() with non-0
3087 width or ShowCol() to restore the previous column width.
3089 If the column is already hidden, this method doesn't do anything.
3094 void HideCol(int col
);
3097 Shows the previously hidden column by resizing it to non-0 size.
3099 The column is shown again with the same width that it had before
3102 If the column is currently shown, this method doesn't do anything.
3104 @see HideCol(), SetColSize()
3106 void ShowCol(int col
);
3110 Sets the default overflow permission of the cells.
3112 void SetDefaultCellOverflow( bool allow
);
3115 Sets the default width for columns in the grid.
3117 This will only affect columns subsequently added to the grid unless
3118 @a resizeExistingCols is @true.
3120 If @a width is less than GetColMinimalAcceptableWidth(), then the
3121 minimal acceptable width is used instead of it.
3123 void SetDefaultColSize(int width
, bool resizeExistingCols
= false);
3126 Sets the default height for rows in the grid.
3128 This will only affect rows subsequently added to the grid unless
3129 @a resizeExistingRows is @true.
3131 If @a height is less than GetRowMinimalAcceptableHeight(), then the
3132 minimal acceptable height is used instead of it.
3134 void SetDefaultRowSize(int height
, bool resizeExistingRows
= false);
3137 Sets the width of the row labels.
3139 If @a width equals @c wxGRID_AUTOSIZE then width is calculated
3140 automatically so that no label is truncated. Note that this could be
3141 slow for a large table.
3143 void SetRowLabelSize(int width
);
3146 Sets the minimal row @a height used by default.
3148 See SetColMinimalAcceptableWidth() for more information.
3150 void SetRowMinimalAcceptableHeight(int height
);
3153 Sets the minimal @a height for the specified @a row.
3155 See SetColMinimalWidth() for more information.
3157 void SetRowMinimalHeight(int row
, int height
);
3160 Sets the height of the specified row.
3162 See SetColSize() for more information.
3164 void SetRowSize(int row
, int height
);
3167 Hides the specified row.
3169 To show the row later you need to call SetRowSize() with non-0
3170 width or ShowRow() to restore its original height.
3172 If the row is already hidden, this method doesn't do anything.
3177 void HideRow(int col
);
3180 Shows the previously hidden row.
3182 The row is shown again with the same height that it had before
3185 If the row is currently shown, this method doesn't do anything.
3187 @see HideRow(), SetRowSize()
3189 void ShowRow(int col
);
3192 Get size information for all columns at once.
3194 This method is useful when the information about all column widths
3195 needs to be saved. The widths can be later restored using
3198 @sa wxGridSizesInfo, GetRowSizes()
3200 wxGridSizesInfo
GetColSizes() const;
3203 Get size information for all row at once.
3205 @sa wxGridSizesInfo, GetColSizes()
3207 wxGridSizesInfo
GetRowSizes() const;
3210 Restore all columns sizes.
3212 This is usually called with wxGridSizesInfo object previously returned
3217 void SetColSizes(const wxGridSizesInfo
& sizeInfo
);
3220 Restore all rows sizes.
3224 void SetRowSizes(const wxGridSizesInfo
& sizeInfo
);
3227 Set the size of the cell.
3229 Specifying a value of more than 1 in @a num_rows or @a num_cols will
3230 make the cell at (@a row, @a col) span the block of the specified size,
3231 covering the other cells which would be normally shown in it. Passing 1
3232 for both arguments resets the cell to normal appearance.
3237 The row of the cell.
3239 The column of the cell.
3241 Number of rows to be occupied by this cell, must be >= 1.
3243 Number of columns to be occupied by this cell, must be >= 1.
3245 void SetCellSize(int row
, int col
, int num_rows
, int num_cols
);
3248 Get the size of the cell in number of cells covered by it.
3250 For normal cells, the function fills both @a num_rows and @a num_cols
3251 with 1 and returns CellSpan_None. For cells which span multiple cells, i.e.
3252 for which SetCellSize() had been called, the returned values are the
3253 same ones as were passed to SetCellSize() call and the function return
3254 value is CellSpan_Main.
3256 More unexpectedly, perhaps, the returned values may be @em negative for
3257 the cells which are inside a span covered by a cell occupying multiple
3258 rows or columns. They correspond to the offset of the main cell of the
3259 span from the cell passed to this functions and the function returns
3260 CellSpan_Inside value to indicate this.
3262 As an example, consider a 3*3 grid with the cell (1, 1) (the one in the
3263 middle) having a span of 2 rows and 2 columns, i.e. the grid looks like
3273 Then the function returns 2 and 2 in @a num_rows and @a num_cols for
3274 the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1
3275 and 0 for the cell (2, 1).
3278 The row of the cell.
3280 The column of the cell.
3282 Pointer to variable receiving the number of rows, must not be @NULL.
3284 Pointer to variable receiving the number of columns, must not be
3287 The kind of this cell span (the return value is new in wxWidgets
3288 2.9.1, this function was void in previous wxWidgets versions).
3290 CellSpan
GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
) const;
3293 Get the number of rows and columns allocated for this cell.
3295 This overload doesn't return a CellSpan value but the values returned
3296 may still be negative, see GetCellSize(int, int, int *, int *) for
3299 wxSize
GetCellSize(const wxGridCellCoords
& coords
);
3305 @name User-Resizing and Dragging
3307 Functions controlling various interactive mouse operations.
3309 By default, columns and rows can be resized by dragging the edges of
3310 their labels (this can be disabled using DisableDragColSize() and
3311 DisableDragRowSize() methods). And if grid line dragging is enabled with
3312 EnableDragGridSize() they can also be resized by dragging the right or
3313 bottom edge of the grid cells.
3315 Columns can also be moved to interactively change their order but this
3316 needs to be explicitly enabled with EnableDragColMove().
3321 Return @true if the dragging of cells is enabled or @false otherwise.
3323 bool CanDragCell() const;
3326 Returns @true if columns can be moved by dragging with the mouse.
3328 Columns can be moved by dragging on their labels.
3330 bool CanDragColMove() const;
3333 Returns @true if the given column can be resized by dragging with the
3336 This function returns @true if resizing the columns interactively is
3337 globally enabled, i.e. if DisableDragColSize() hadn't been called, and
3338 if this column wasn't explicitly marked as non-resizable with
3341 bool CanDragColSize(int col
) const;
3344 Return @true if the dragging of grid lines to resize rows and columns
3345 is enabled or @false otherwise.
3347 bool CanDragGridSize() const;
3350 Returns @true if the given row can be resized by dragging with the
3353 This is the same as CanDragColSize() but for rows.
3355 bool CanDragRowSize(int row
) const;
3358 Disable interactive resizing of the specified column.
3360 This method allows to disable resizing of an individual column in a
3361 grid where the columns are otherwise resizable (which is the case by
3364 Notice that currently there is no way to make some columns resizable in
3365 a grid where columns can't be resized by default as there doesn't seem
3366 to be any need for this in practice. There is also no way to make the
3367 column marked as fixed using this method resizable again because it is
3368 supposed that fixed columns are used for static parts of the grid and
3369 so should remain fixed during the entire grid lifetime.
3371 Also notice that disabling interactive column resizing will not prevent
3372 the program from changing the column size.
3374 @see EnableDragColSize()
3376 void DisableColResize(int col
);
3379 Disable interactive resizing of the specified row.
3381 This is the same as DisableColResize() but for rows.
3383 @see EnableDragRowSize()
3385 void DisableRowResize(int row
);
3388 Disables column moving by dragging with the mouse.
3390 Equivalent to passing @false to EnableDragColMove().
3392 void DisableDragColMove();
3395 Disables column sizing by dragging with the mouse.
3397 Equivalent to passing @false to EnableDragColSize().
3399 void DisableDragColSize();
3402 Disable mouse dragging of grid lines to resize rows and columns.
3404 Equivalent to passing @false to EnableDragGridSize()
3406 void DisableDragGridSize();
3409 Disables row sizing by dragging with the mouse.
3411 Equivalent to passing @false to EnableDragRowSize().
3413 void DisableDragRowSize();
3416 Enables or disables cell dragging with the mouse.
3418 void EnableDragCell(bool enable
= true);
3421 Enables or disables column moving by dragging with the mouse.
3423 void EnableDragColMove(bool enable
= true);
3426 Enables or disables column sizing by dragging with the mouse.
3428 @see DisableColResize()
3430 void EnableDragColSize(bool enable
= true);
3433 Enables or disables row and column resizing by dragging gridlines with
3436 void EnableDragGridSize(bool enable
= true);
3439 Enables or disables row sizing by dragging with the mouse.
3441 @see DisableRowResize()
3443 void EnableDragRowSize(bool enable
= true);
3446 Returns the column ID of the specified column position.
3448 int GetColAt(int colPos
) const;
3451 Returns the position of the specified column.
3453 int GetColPos(int colID
) const;
3456 Sets the position of the specified column.
3458 void SetColPos(int colID
, int newPos
);
3461 Sets the positions of all columns at once.
3463 This method takes an array containing the indices of the columns in
3464 their display order, i.e. uses the same convention as
3465 wxHeaderCtrl::SetColumnsOrder().
3467 void SetColumnsOrder(const wxArrayInt
& order
);
3470 Resets the position of the columns to the default.
3478 @name Cursor Movement
3483 Returns the current grid cell column position.
3485 int GetGridCursorCol() const;
3488 Returns the current grid cell row position.
3490 int GetGridCursorRow() const;
3493 Make the given cell current and ensure it is visible.
3495 This method is equivalent to calling MakeCellVisible() and
3496 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
3497 event is generated by it and the selected cell doesn't change if the
3500 void GoToCell(int row
, int col
);
3502 Make the given cell current and ensure it is visible.
3504 This method is equivalent to calling MakeCellVisible() and
3505 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
3506 event is generated by it and the selected cell doesn't change if the
3509 void GoToCell(const wxGridCellCoords
& coords
);
3512 Moves the grid cursor down by one row.
3514 If a block of cells was previously selected it will expand if the
3515 argument is @true or be cleared if the argument is @false.
3517 bool MoveCursorDown(bool expandSelection
);
3520 Moves the grid cursor down in the current column such that it skips to
3521 the beginning or end of a block of non-empty cells.
3523 If a block of cells was previously selected it will expand if the
3524 argument is @true or be cleared if the argument is @false.
3526 bool MoveCursorDownBlock(bool expandSelection
);
3529 Moves the grid cursor left by one column.
3531 If a block of cells was previously selected it will expand if the
3532 argument is @true or be cleared if the argument is @false.
3534 bool MoveCursorLeft(bool expandSelection
);
3537 Moves the grid cursor left in the current row such that it skips to the
3538 beginning or end of a block of non-empty cells.
3540 If a block of cells was previously selected it will expand if the
3541 argument is @true or be cleared if the argument is @false.
3543 bool MoveCursorLeftBlock(bool expandSelection
);
3546 Moves the grid cursor right by one column.
3548 If a block of cells was previously selected it will expand if the
3549 argument is @true or be cleared if the argument is @false.
3551 bool MoveCursorRight(bool expandSelection
);
3554 Moves the grid cursor right in the current row such that it skips to
3555 the beginning or end of a block of non-empty cells.
3557 If a block of cells was previously selected it will expand if the
3558 argument is @true or be cleared if the argument is @false.
3560 bool MoveCursorRightBlock(bool expandSelection
);
3563 Moves the grid cursor up by one row.
3565 If a block of cells was previously selected it will expand if the
3566 argument is @true or be cleared if the argument is @false.
3568 bool MoveCursorUp(bool expandSelection
);
3571 Moves the grid cursor up in the current column such that it skips to
3572 the beginning or end of a block of non-empty cells.
3574 If a block of cells was previously selected it will expand if the
3575 argument is @true or be cleared if the argument is @false.
3577 bool MoveCursorUpBlock(bool expandSelection
);
3580 Moves the grid cursor down by some number of rows so that the previous
3581 bottom visible row becomes the top visible row.
3583 bool MovePageDown();
3586 Moves the grid cursor up by some number of rows so that the previous
3587 top visible row becomes the bottom visible row.
3592 Set the grid cursor to the specified cell.
3594 The grid cursor indicates the current cell and can be moved by the user
3595 using the arrow keys or the mouse.
3597 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
3598 if the event handler vetoes this event, the cursor is not moved.
3600 This function doesn't make the target call visible, use GoToCell() to
3603 void SetGridCursor(int row
, int col
);
3605 Set the grid cursor to the specified cell.
3607 The grid cursor indicates the current cell and can be moved by the user
3608 using the arrow keys or the mouse.
3610 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
3611 if the event handler vetoes this event, the cursor is not moved.
3613 This function doesn't make the target call visible, use GoToCell() to
3616 void SetGridCursor(const wxGridCellCoords
& coords
);
3619 Set the grid's behaviour when the user presses the TAB key.
3621 Pressing the TAB key moves the grid cursor right in the current row, if
3622 there is a cell at the right and, similarly, Shift-TAB moves the cursor
3623 to the left in the current row if it's not in the first column.
3625 What happens if the cursor can't be moved because it it's already at
3626 the beginning or end of the row can be configured using this function,
3627 see wxGrid::TabBehaviour documentation for the detailed description.
3629 IF none of the standard behaviours is appropriate, you can always
3630 handle @c wxEVT_GRID_TABBING event directly to implement a custom
3635 void SetTabBehaviour(TabBehaviour behaviour
);
3641 @name User Selection
3646 Deselects all cells that are currently selected.
3648 void ClearSelection();
3651 Returns an array of individually selected cells.
3653 Notice that this array does @em not contain all the selected cells in
3654 general as it doesn't include the cells selected as part of column, row
3655 or block selection. You must use this method, GetSelectedCols(),
3656 GetSelectedRows() and GetSelectionBlockTopLeft() and
3657 GetSelectionBlockBottomRight() methods to obtain the entire selection
3660 Please notice this behaviour is by design and is needed in order to
3661 support grids of arbitrary size (when an entire column is selected in
3662 a grid with a million of columns, we don't want to create an array with
3663 a million of entries in this function, instead it returns an empty
3664 array and GetSelectedCols() returns an array containing one element).
3666 wxGridCellCoordsArray
GetSelectedCells() const;
3669 Returns an array of selected columns.
3671 Please notice that this method alone is not sufficient to find all the
3672 selected columns as it contains only the columns which were
3673 individually selected but not those being part of the block selection
3674 or being selected in virtue of all of their cells being selected
3675 individually, please see GetSelectedCells() for more details.
3677 wxArrayInt
GetSelectedCols() const;
3680 Returns an array of selected rows.
3682 Please notice that this method alone is not sufficient to find all the
3683 selected rows as it contains only the rows which were individually
3684 selected but not those being part of the block selection or being
3685 selected in virtue of all of their cells being selected individually,
3686 please see GetSelectedCells() for more details.
3688 wxArrayInt
GetSelectedRows() const;
3691 Returns the colour used for drawing the selection background.
3693 wxColour
GetSelectionBackground() const;
3696 Returns an array of the bottom right corners of blocks of selected
3699 Please see GetSelectedCells() for more information about the selection
3700 representation in wxGrid.
3702 @see GetSelectionBlockTopLeft()
3704 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
3707 Returns an array of the top left corners of blocks of selected cells.
3709 Please see GetSelectedCells() for more information about the selection
3710 representation in wxGrid.
3712 @see GetSelectionBlockBottomRight()
3714 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
3717 Returns the colour used for drawing the selection foreground.
3719 wxColour
GetSelectionForeground() const;
3722 Returns the current selection mode.
3724 @see SetSelectionMode().
3726 wxGridSelectionModes
GetSelectionMode() const;
3729 Returns @true if the given cell is selected.
3731 bool IsInSelection(int row
, int col
) const;
3733 Returns @true if the given cell is selected.
3735 bool IsInSelection(const wxGridCellCoords
& coords
) const;
3738 Returns @true if there are currently any selected cells, rows, columns
3741 bool IsSelection() const;
3744 Selects all cells in the grid.
3749 Selects a rectangular block of cells.
3751 If @a addToSelected is @false then any existing selection will be
3752 deselected; if @true the column will be added to the existing
3755 void SelectBlock(int topRow
, int leftCol
, int bottomRow
, int rightCol
,
3756 bool addToSelected
= false);
3758 Selects a rectangular block of cells.
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 void SelectBlock(const wxGridCellCoords
& topLeft
,
3765 const wxGridCellCoords
& bottomRight
,
3766 bool addToSelected
= false);
3769 Selects the specified column.
3771 If @a addToSelected is @false then any existing selection will be
3772 deselected; if @true the column will be added to the existing
3775 This method won't select anything if the current selection mode is
3778 void SelectCol(int col
, bool addToSelected
= false);
3781 Selects the specified row.
3783 If @a addToSelected is @false then any existing selection will be
3784 deselected; if @true the row will be added to the existing selection.
3786 This method won't select anything if the current selection mode is
3787 wxGridSelectColumns.
3789 void SelectRow(int row
, bool addToSelected
= false);
3792 Set the colour to be used for drawing the selection background.
3794 void SetSelectionBackground(const wxColour
& c
);
3797 Set the colour to be used for drawing the selection foreground.
3799 void SetSelectionForeground(const wxColour
& c
);
3802 Set the selection behaviour of the grid.
3804 The existing selection is converted to conform to the new mode if
3805 possible and discarded otherwise (e.g. any individual selected cells
3806 are deselected if the new mode allows only the selection of the entire
3809 void SetSelectionMode(wxGridSelectionModes selmode
);
3820 Returns the number of pixels per horizontal scroll increment.
3824 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
3826 int GetScrollLineX() const;
3829 Returns the number of pixels per vertical scroll increment.
3833 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
3835 int GetScrollLineY() const;
3838 Returns @true if a cell is either entirely or at least partially
3839 visible in the grid window.
3841 By default, the cell must be entirely visible for this function to
3842 return @true but if @a wholeCellVisible is @false, the function returns
3843 @true even if the cell is only partially visible.
3845 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
3847 Returns @true if a cell is either entirely or at least partially
3848 visible in the grid window.
3850 By default, the cell must be entirely visible for this function to
3851 return @true but if @a wholeCellVisible is @false, the function returns
3852 @true even if the cell is only partially visible.
3854 bool IsVisible(const wxGridCellCoords
& coords
,
3855 bool wholeCellVisible
= true) const;
3858 Brings the specified cell into the visible grid cell area with minimal
3861 Does nothing if the cell is already visible.
3863 void MakeCellVisible(int row
, int col
);
3865 Brings the specified cell into the visible grid cell area with minimal
3868 Does nothing if the cell is already visible.
3870 void MakeCellVisible(const wxGridCellCoords
& coords
);
3873 Sets the number of pixels per horizontal scroll increment.
3877 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
3879 void SetScrollLineX(int x
);
3882 Sets the number of pixels per vertical scroll increment.
3886 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
3888 void SetScrollLineY(int y
);
3894 @name Cell and Device Coordinate Translation
3899 Convert grid cell coordinates to grid window pixel coordinates.
3901 This function returns the rectangle that encloses the block of cells
3902 limited by @a topLeft and @a bottomRight cell in device coords and
3903 clipped to the client size of the grid window.
3907 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
3908 const wxGridCellCoords
& bottomRight
) const;
3911 Return the rectangle corresponding to the grid cell's size and position
3912 in logical coordinates.
3914 @see BlockToDeviceRect()
3916 wxRect
CellToRect(int row
, int col
) const;
3918 Return the rectangle corresponding to the grid cell's size and position
3919 in logical coordinates.
3921 @see BlockToDeviceRect()
3923 wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
3926 Returns the column at the given pixel position.
3929 The x position to evaluate.
3931 If @true, rather than returning @c wxNOT_FOUND, it returns either
3932 the first or last column depending on whether @a x is too far to
3933 the left or right respectively.
3935 The column index or @c wxNOT_FOUND.
3937 int XToCol(int x
, bool clipToMinMax
= false) const;
3940 Returns the column whose right hand edge is close to the given logical
3943 If no column edge is near to this position @c wxNOT_FOUND is returned.
3945 int XToEdgeOfCol(int x
) 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(int x
, int y
) const;
3959 Translates logical pixel coordinates to the grid cell coordinates.
3961 Notice that this function expects logical coordinates on input so if
3962 you use this function in a mouse event handler you need to translate
3963 the mouse position, which is expressed in device coordinates, to
3966 @see XToCol(), YToRow()
3968 wxGridCellCoords
XYToCell(const wxPoint
& pos
) const;
3969 // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
3970 // undocumented, using it is ugly and non-const reference parameters are
3971 // not used in wxWidgets API
3974 Returns the row whose bottom edge is close to the given logical @a y
3977 If no row edge is near to this position @c wxNOT_FOUND is returned.
3979 int YToEdgeOfRow(int y
) const;
3982 Returns the grid row that corresponds to the logical @a y coordinate.
3984 Returns @c wxNOT_FOUND if there is no row at the @a y position.
3986 int YToRow(int y
, bool clipToMinMax
= false) const;
3992 @name Miscellaneous Functions
3997 Appends one or more new columns to the right of the grid.
3999 The @a updateLabels argument is not used at present. If you are using a
4000 derived grid table class you will need to override
4001 wxGridTableBase::AppendCols(). See InsertCols() for further
4004 @return @true on success or @false if appending columns failed.
4006 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
4009 Appends one or more new rows to the bottom of the grid.
4011 The @a updateLabels argument is not used at present. If you are using a
4012 derived grid table class you will need to override
4013 wxGridTableBase::AppendRows(). See InsertRows() for further
4016 @return @true on success or @false if appending rows failed.
4018 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
4021 Return @true if the horizontal grid lines stop at the last column
4022 boundary or @false if they continue to the end of the window.
4024 The default is to clip grid lines.
4026 @see ClipHorzGridLines(), AreVertGridLinesClipped()
4028 bool AreHorzGridLinesClipped() const;
4031 Return @true if the vertical grid lines stop at the last row
4032 boundary or @false if they continue to the end of the window.
4034 The default is to clip grid lines.
4036 @see ClipVertGridLines(), AreHorzGridLinesClipped()
4038 bool AreVertGridLinesClipped() const;
4041 Increments the grid's batch count.
4043 When the count is greater than zero repainting of the grid is
4044 suppressed. Each call to BeginBatch must be matched by a later call to
4045 EndBatch(). Code that does a lot of grid modification can be enclosed
4046 between BeginBatch() and EndBatch() calls to avoid screen flicker. The
4047 final EndBatch() call will cause the grid to be repainted.
4049 Notice that you should use wxGridUpdateLocker which ensures that there
4050 is always a matching EndBatch() call for this BeginBatch() if possible
4051 instead of calling this method directly.
4056 Clears all data in the underlying grid table and repaints the grid.
4058 The table is not deleted by this function. If you are using a derived
4059 table class then you need to override wxGridTableBase::Clear() for this
4060 function to have any effect.
4065 Change whether the horizontal grid lines are clipped by the end of the
4068 By default the grid lines are not drawn beyond the end of the last
4069 column but after calling this function with @a clip set to @false they
4070 will be drawn across the entire grid window.
4072 @see AreHorzGridLinesClipped(), ClipVertGridLines()
4074 void ClipHorzGridLines(bool clip
);
4077 Change whether the vertical grid lines are clipped by the end of the
4080 By default the grid lines are not drawn beyond the end of the last
4081 row but after calling this function with @a clip set to @false they
4082 will be drawn across the entire grid window.
4084 @see AreVertGridLinesClipped(), ClipHorzGridLines()
4086 void ClipVertGridLines(bool clip
);
4089 Deletes one or more columns from a grid starting at the specified
4092 The @a updateLabels argument is not used at present. If you are using a
4093 derived grid table class you will need to override
4094 wxGridTableBase::DeleteCols(). See InsertCols() for further
4097 @return @true on success or @false if deleting columns failed.
4099 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
4102 Deletes one or more rows from a grid starting at the specified
4105 The @a updateLabels argument is not used at present. If you are using a
4106 derived grid table class you will need to override
4107 wxGridTableBase::DeleteRows(). See InsertRows() for further
4110 @return @true on success or @false if appending rows failed.
4112 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
4115 Decrements the grid's batch count.
4117 When the count is greater than zero repainting of the grid is
4118 suppressed. Each previous call to BeginBatch() must be matched by a
4119 later call to EndBatch(). Code that does a lot of grid modification can
4120 be enclosed between BeginBatch() and EndBatch() calls to avoid screen
4121 flicker. The final EndBatch() will cause the grid to be repainted.
4123 @see wxGridUpdateLocker
4128 Overridden wxWindow method.
4133 Causes immediate repainting of the grid.
4135 Use this instead of the usual wxWindow::Refresh().
4137 void ForceRefresh();
4140 Returns the number of times that BeginBatch() has been called without
4141 (yet) matching calls to EndBatch(). While the grid's batch count is
4142 greater than zero the display will not be updated.
4144 int GetBatchCount();
4147 Returns the total number of grid columns.
4149 This is the same as the number of columns in the underlying grid table.
4151 int GetNumberCols() const;
4154 Returns the total number of grid rows.
4156 This is the same as the number of rows in the underlying grid table.
4158 int GetNumberRows() const;
4161 Returns the attribute for the given cell creating one if necessary.
4163 If the cell already has an attribute, it is returned. Otherwise a new
4164 attribute is created, associated with the cell and returned. In any
4165 case the caller must call DecRef() on the returned pointer.
4167 This function may only be called if CanHaveAttributes() returns @true.
4169 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
4172 Returns a base pointer to the current table object.
4174 The returned pointer is still owned by the grid.
4176 wxGridTableBase
*GetTable() const;
4179 Inserts one or more new columns into a grid with the first new column
4180 at the specified position.
4182 Notice that inserting the columns in the grid requires grid table
4183 cooperation: when this method is called, grid object begins by
4184 requesting the underlying grid table to insert new columns. If this is
4185 successful the table notifies the grid and the grid updates the
4186 display. For a default grid (one where you have called CreateGrid())
4187 this process is automatic. If you are using a custom grid table
4188 (specified with SetTable()) then you must override
4189 wxGridTableBase::InsertCols() in your derived table class.
4192 The position which the first newly inserted column will have.
4194 The number of columns to insert.
4198 @true if the columns were successfully inserted, @false if an error
4199 occurred (most likely the table couldn't be updated).
4201 bool InsertCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
4204 Inserts one or more new rows into a grid with the first new row at the
4207 Notice that you must implement wxGridTableBase::InsertRows() if you use
4208 a grid with a custom table, please see InsertCols() for more
4212 The position which the first newly inserted row will have.
4214 The number of rows to insert.
4218 @true if the rows were successfully inserted, @false if an error
4219 occurred (most likely the table couldn't be updated).
4221 bool InsertRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
4224 Invalidates the cached attribute for the given cell.
4226 For efficiency reasons, wxGrid may cache the recently used attributes
4227 (currently it caches only the single most recently used one, in fact)
4228 which can result in the cell appearance not being refreshed even when
4229 the attribute returned by your custom wxGridCellAttrProvider-derived
4230 class has changed. To force the grid to refresh the cell attribute,
4231 this function may be used. Notice that calling it will not result in
4232 actually redrawing the cell, you still need to call
4233 wxWindow::RefreshRect() to invalidate the area occupied by the cell in
4234 the window to do this. Also note that you don't need to call this
4235 function if you store the attributes in wxGrid itself, i.e. use its
4236 SetAttr() and similar methods, it is only useful when using a separate
4237 custom attributes provider.
4240 The row of the cell whose attribute needs to be queried again.
4242 The column of the cell whose attribute needs to be queried again.
4246 void RefreshAttr(int row
, int col
);
4249 Draws part or all of a wxGrid on a wxDC for printing or display.
4251 Pagination can be accomplished by using sequential Render() calls
4252 with appropriate values in wxGridCellCoords topLeft and bottomRight.
4255 The wxDC to be drawn on.
4257 The position on the wxDC where rendering should begin. If not
4258 specified drawing will begin at the wxDC MaxX() and MaxY().
4260 The size of the area on the wxDC that the rendered wxGrid should
4261 occupy. If not specified the drawing will be scaled to fit the
4262 available dc width or height. The wxGrid's aspect ratio is
4263 maintained whether or not size is specified.
4265 The top left cell of the block to be drawn. Defaults to ( 0, 0 ).
4267 The bottom right cell of the block to be drawn. Defaults to row and
4270 A combination of values from wxGridRenderStyle.
4274 void Render( wxDC
& dc
,
4275 const wxPoint
& pos
= wxDefaultPosition
,
4276 const wxSize
& size
= wxDefaultSize
,
4277 const wxGridCellCoords
& topLeft
= wxGridCellCoords( -1, -1 ),
4278 const wxGridCellCoords
& bottomRight
= wxGridCellCoords( -1, -1 ),
4279 int style
= wxGRID_DRAW_DEFAULT
);
4282 Sets the cell attributes for all cells in the specified column.
4284 For more information about controlling grid cell attributes see the
4285 wxGridCellAttr cell attribute class and the @ref overview_grid.
4287 void SetColAttr(int col
, wxGridCellAttr
* attr
);
4290 Sets the extra margins used around the grid area.
4292 A grid may occupy more space than needed for its data display and
4293 this function allows to set how big this extra space is
4295 void SetMargins(int extraWidth
, int extraHeight
);
4298 Sets the cell attributes for all cells in the specified row.
4300 The grid takes ownership of the attribute pointer.
4302 See the wxGridCellAttr class for more information about controlling
4305 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
4311 @name Sorting support.
4313 wxGrid doesn't provide any support for sorting the data but it does
4314 generate events allowing the user code to sort it and supports
4315 displaying the sort indicator in the column used for sorting.
4317 To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT
4318 event (and not veto it) and resort the data displayed in the grid. The
4319 grid will automatically update the sorting indicator on the column
4322 You can also call the functions in this section directly to update the
4323 sorting indicator. Once again, they don't do anything with the grid
4324 data, it remains your responsibility to actually sort it appropriately.
4329 Return the column in which the sorting indicator is currently
4332 Returns @c wxNOT_FOUND if sorting indicator is not currently displayed
4335 @see SetSortingColumn()
4337 int GetSortingColumn() const;
4340 Return @true if this column is currently used for sorting.
4342 @see GetSortingColumn()
4344 bool IsSortingBy(int col
) const;
4347 Return @true if the current sorting order is ascending or @false if it
4350 It only makes sense to call this function if GetSortingColumn() returns
4351 a valid column index and not @c wxNOT_FOUND.
4353 @see SetSortingColumn()
4355 bool IsSortOrderAscending() const;
4358 Set the column to display the sorting indicator in and its direction.
4361 The column to display the sorting indicator in or @c wxNOT_FOUND to
4362 remove any currently displayed sorting indicator.
4364 If @true, display the ascending sort indicator, otherwise display
4365 the descending sort indicator.
4367 @see GetSortingColumn(), IsSortOrderAscending()
4369 void SetSortingColumn(int col
, bool ascending
= true);
4372 Remove any currently shown sorting indicator.
4374 This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND
4377 void UnsetSortingColumn();
4382 @name Accessors for component windows.
4384 Return the various child windows of wxGrid.
4386 wxGrid is an empty parent window for 4 children representing the column
4387 labels window (top), the row labels window (left), the corner window
4388 (top left) and the main grid window. It may be necessary to use these
4389 individual windows and not the wxGrid window itself if you need to
4390 handle events for them (this can be done using wxEvtHandler::Connect()
4391 or wxWindow::PushEventHandler()) or do something else requiring the use
4392 of the correct window pointer. Notice that you should not, however,
4393 change these windows (e.g. reposition them or draw over them) because
4394 they are managed by wxGrid itself.
4399 Return the main grid window containing the grid cells.
4401 This window is always shown.
4403 wxWindow
*GetGridWindow() const;
4406 Return the row labels window.
4408 This window is not shown if the row labels were hidden using
4411 wxWindow
*GetGridRowLabelWindow() const;
4414 Return the column labels window.
4416 This window is not shown if the columns labels were hidden using
4419 Depending on whether UseNativeColHeader() was called or not this can be
4420 either a wxHeaderCtrl or a plain wxWindow. This function returns a valid
4421 window pointer in either case but in the former case you can also use
4422 GetGridColHeader() to access it if you need wxHeaderCtrl-specific
4425 wxWindow
*GetGridColLabelWindow() const;
4428 Return the window in the top left grid corner.
4430 This window is shown only of both columns and row labels are shown and
4431 normally doesn't contain anything. Clicking on it is handled by wxGrid
4432 however and can be used to select the entire grid.
4434 wxWindow
*GetGridCornerLabelWindow() const;
4437 Return the header control used for column labels display.
4439 This function can only be called if UseNativeColHeader() had been
4442 wxHeaderCtrl
*GetGridColHeader() const;
4448 Returns @true if this grid has support for cell attributes.
4450 The grid supports attributes if it has the associated table which, in
4451 turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
4454 bool CanHaveAttributes() const;
4457 Get the minimal width of the given column/row.
4459 The value returned by this function may be different than that returned
4460 by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
4461 called for this column.
4463 int GetColMinimalWidth(int col
) const;
4466 Returns the coordinate of the right border specified column.
4468 int GetColRight(int col
) const;
4471 Returns the coordinate of the left border specified column.
4473 int GetColLeft(int col
) const;
4476 Returns the minimal size for the given column.
4478 The value returned by this function may be different than that returned
4479 by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
4480 called for this row.
4482 int GetRowMinimalHeight(int col
) const;
4488 @class wxGridUpdateLocker
4490 This small class can be used to prevent wxGrid from redrawing during its
4491 lifetime by calling wxGrid::BeginBatch() in its constructor and
4492 wxGrid::EndBatch() in its destructor. It is typically used in a function
4493 performing several operations with a grid which would otherwise result in
4494 flicker. For example:
4499 m_grid = new wxGrid(this, ...);
4501 wxGridUpdateLocker noUpdates(m_grid);
4502 m_grid-AppendColumn();
4503 // ... many other operations with m_grid ...
4506 // destructor called, grid refreshed
4510 Using this class is easier and safer than calling wxGrid::BeginBatch() and
4511 wxGrid::EndBatch() because you don't risk missing the call the latter (due
4512 to an exception for example).
4517 class wxGridUpdateLocker
4521 Creates an object preventing the updates of the specified @a grid. The
4522 parameter could be @NULL in which case nothing is done. If @a grid is
4523 non-@NULL then the grid must exist for longer than this
4524 wxGridUpdateLocker object itself.
4526 The default constructor could be followed by a call to Create() to set
4527 the grid object later.
4529 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
4532 Destructor reenables updates for the grid this object is associated
4535 ~wxGridUpdateLocker();
4538 This method can be called if the object had been constructed using the
4539 default constructor. It must not be called more than once.
4541 void Create(wxGrid
* grid
);
4549 This event class contains information about various grid events.
4551 Notice that all grid event table macros are available in two versions:
4552 @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the
4553 two is that the former doesn't allow to specify the grid window identifier
4554 and so takes a single parameter, the event handler, but is not suitable if
4555 there is more than one grid control in the window where the event table is
4556 used (as it would catch the events from all the grids). The version with @c
4557 CMD takes the id as first argument and the event handler as the second one
4558 and so can be used with multiple grids as well. Otherwise there are no
4559 difference between the two and only the versions without the id are
4560 documented below for brevity.
4562 @beginEventTable{wxGridEvent}
4563 @event{EVT_GRID_CELL_CHANGING(func)}
4564 The user is about to change the data in a cell. The new cell value as
4565 string is available from GetString() event object method. This event
4566 can be vetoed if the change is not allowed.
4567 Processes a @c wxEVT_GRID_CELL_CHANGING event type.
4568 @event{EVT_GRID_CELL_CHANGED(func)}
4569 The user changed the data in a cell. The old cell value as string is
4570 available from GetString() event object method. Notice that vetoing
4571 this event still works for backwards compatibility reasons but any new
4572 code should only veto EVT_GRID_CELL_CHANGING event and not this one.
4573 Processes a @c wxEVT_GRID_CELL_CHANGED event type.
4574 @event{EVT_GRID_CELL_LEFT_CLICK(func)}
4575 The user clicked a cell with the left mouse button. Processes a
4576 @c wxEVT_GRID_CELL_LEFT_CLICK event type.
4577 @event{EVT_GRID_CELL_LEFT_DCLICK(func)}
4578 The user double-clicked a cell with the left mouse button. Processes a
4579 @c wxEVT_GRID_CELL_LEFT_DCLICK event type.
4580 @event{EVT_GRID_CELL_RIGHT_CLICK(func)}
4581 The user clicked a cell with the right mouse button. Processes a
4582 @c wxEVT_GRID_CELL_RIGHT_CLICK event type.
4583 @event{EVT_GRID_CELL_RIGHT_DCLICK(func)}
4584 The user double-clicked a cell with the right mouse button. Processes a
4585 @c wxEVT_GRID_CELL_RIGHT_DCLICK event type.
4586 @event{EVT_GRID_EDITOR_HIDDEN(func)}
4587 The editor for a cell was hidden. Processes a
4588 @c wxEVT_GRID_EDITOR_HIDDEN event type.
4589 @event{EVT_GRID_EDITOR_SHOWN(func)}
4590 The editor for a cell was shown. Processes a
4591 @c wxEVT_GRID_EDITOR_SHOWN event type.
4592 @event{EVT_GRID_LABEL_LEFT_CLICK(func)}
4593 The user clicked a label with the left mouse button. Processes a
4594 @c wxEVT_GRID_LABEL_LEFT_CLICK event type.
4595 @event{EVT_GRID_LABEL_LEFT_DCLICK(func)}
4596 The user double-clicked a label with the left mouse button. Processes a
4597 @c wxEVT_GRID_LABEL_LEFT_DCLICK event type.
4598 @event{EVT_GRID_LABEL_RIGHT_CLICK(func)}
4599 The user clicked a label with the right mouse button. Processes a
4600 @c wxEVT_GRID_LABEL_RIGHT_CLICK event type.
4601 @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)}
4602 The user double-clicked a label with the right mouse button. Processes
4603 a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type.
4604 @event{EVT_GRID_SELECT_CELL(func)}
4605 The given cell was made current, either by user or by the program via a
4606 call to SetGridCursor() or GoToCell(). Processes a
4607 @c wxEVT_GRID_SELECT_CELL event type.
4608 @event{EVT_GRID_COL_MOVE(func)}
4609 The user tries to change the order of the columns in the grid by
4610 dragging the column specified by GetCol(). This event can be vetoed to
4611 either prevent the user from reordering the column change completely
4612 (but notice that if you don't want to allow it at all, you simply
4613 shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed
4614 but handled in some way in the handler, e.g. by really moving the
4615 column to the new position at the associated table level, or allowed to
4616 proceed in which case wxGrid::SetColPos() is used to reorder the
4617 columns display order without affecting the use of the column indices
4619 This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type.
4620 @event{EVT_GRID_COL_SORT(func)}
4621 This event is generated when a column is clicked by the user and its
4622 name is explained by the fact that the custom reaction to a click on a
4623 column is to sort the grid contents by this column. However the grid
4624 itself has no special support for sorting and it's up to the handler of
4625 this event to update the associated table. But if the event is handled
4626 (and not vetoed) the grid supposes that the table was indeed resorted
4627 and updates the column to indicate the new sort order and refreshes
4629 This event macro corresponds to @c wxEVT_GRID_COL_SORT event type.
4630 @event{EVT_GRID_TABBING(func)}
4631 This event is generated when the user presses TAB or Shift-TAB in the
4632 grid. It can be used to customize the simple default TAB handling
4633 logic, e.g. to go to the next non-empty cell instead of just the next
4634 cell. See also wxGrid::SetTabBehaviour(). This event is new since
4639 @category{grid,events}
4641 class wxGridEvent
: public wxNotifyEvent
4645 Default constructor.
4649 Constructor for initializing all event attributes.
4651 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
4652 int row
= -1, int col
= -1, int x
= -1, int y
= -1,
4653 bool sel
= true, const wxKeyboardState
& kbd
= wxKeyboardState());
4656 Returns @true if the Alt key was down at the time of the event.
4658 bool AltDown() const;
4661 Returns @true if the Control key was down at the time of the event.
4663 bool ControlDown() const;
4666 Column at which the event occurred.
4668 Notice that for a @c wxEVT_GRID_SELECT_CELL event this column is the
4669 column of the newly selected cell while the previously selected cell
4670 can be retrieved using wxGrid::GetGridCursorCol().
4672 virtual int GetCol();
4675 Position in pixels at which the event occurred.
4677 wxPoint
GetPosition();
4680 Row at which the event occurred.
4682 Notice that for a @c wxEVT_GRID_SELECT_CELL event this row is the row
4683 of the newly selected cell while the previously selected cell can be
4684 retrieved using wxGrid::GetGridCursorRow().
4686 virtual int GetRow();
4689 Returns @true if the Meta key was down at the time of the event.
4691 bool MetaDown() const;
4694 Returns @true if the user is selecting grid cells, or @false if
4700 Returns @true if the Shift key was down at the time of the event.
4702 bool ShiftDown() const;
4708 @class wxGridSizeEvent
4710 This event class contains information about a row/column resize event.
4712 @beginEventTable{wxGridSizeEvent}
4713 @event{EVT_GRID_CMD_COL_SIZE(id, func)}
4714 The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event
4716 @event{EVT_GRID_CMD_ROW_SIZE(id, func)}
4717 The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event
4719 @event{EVT_GRID_COL_SIZE(func)}
4720 Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id.
4721 @event{EVT_GRID_COL_AUTO_SIZE(func)}
4722 This event is sent when a column must be resized to its best size, e.g.
4723 when the user double clicks the column divider. The default
4724 implementation simply resizes the column to fit the column label (but
4725 not its contents as this could be too slow for big grids). This macro
4726 corresponds to @c wxEVT_GRID_COL_AUTO_SIZE event type and is new since
4728 @event{EVT_GRID_ROW_SIZE(func)}
4729 Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id.
4733 @category{grid,events}
4735 class wxGridSizeEvent
: public wxNotifyEvent
4739 Default constructor.
4743 Constructor for initializing all event attributes.
4745 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
4746 int rowOrCol
= -1, int x
= -1, int y
= -1,
4747 const wxKeyboardState
& kbd
= wxKeyboardState());
4750 Returns @true if the Alt key was down at the time of the event.
4752 bool AltDown() const;
4755 Returns @true if the Control key was down at the time of the event.
4757 bool ControlDown() const;
4760 Position in pixels at which the event occurred.
4762 wxPoint
GetPosition();
4765 Row or column at that was resized.
4770 Returns @true if the Meta key was down at the time of the event.
4772 bool MetaDown() const;
4775 Returns @true if the Shift key was down at the time of the event.
4777 bool ShiftDown() const;
4783 @class wxGridRangeSelectEvent
4785 @beginEventTable{wxGridRangeSelectEvent}
4786 @event{EVT_GRID_RANGE_SELECT(func)}
4787 The user selected a group of contiguous cells. Processes a
4788 @c wxEVT_GRID_RANGE_SELECT event type.
4789 @event{EVT_GRID_CMD_RANGE_SELECT(id, func)}
4790 The user selected a group of contiguous cells; variant taking a window
4791 identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type.
4795 @category{grid,events}
4797 class wxGridRangeSelectEvent
: public wxNotifyEvent
4801 Default constructor.
4803 wxGridRangeSelectEvent();
4805 Constructor for initializing all event attributes.
4807 wxGridRangeSelectEvent(int id
, wxEventType type
,
4809 const wxGridCellCoords
& topLeft
,
4810 const wxGridCellCoords
& bottomRight
,
4811 bool sel
= true, const wxKeyboardState
& kbd
= wxKeyboardState());
4814 Returns @true if the Alt key was down at the time of the event.
4816 bool AltDown() const;
4819 Returns @true if the Control key was down at the time of the event.
4821 bool ControlDown() const;
4824 Top left corner of the rectangular area that was (de)selected.
4826 wxGridCellCoords
GetBottomRightCoords();
4829 Bottom row of the rectangular area that was (de)selected.
4834 Left column of the rectangular area that was (de)selected.
4839 Right column of the rectangular area that was (de)selected.
4844 Top left corner of the rectangular area that was (de)selected.
4846 wxGridCellCoords
GetTopLeftCoords();
4849 Top row of the rectangular area that was (de)selected.
4854 Returns @true if the Meta key was down at the time of the event.
4856 bool MetaDown() const;
4859 Returns @true if the area was selected, @false otherwise.
4864 Returns @true if the Shift key was down at the time of the event.
4866 bool ShiftDown() const;
4872 @class wxGridEditorCreatedEvent
4874 @beginEventTable{wxGridEditorCreatedEvent}
4875 @event{EVT_GRID_EDITOR_CREATED(func)}
4876 The editor for a cell was created. Processes a
4877 @c wxEVT_GRID_EDITOR_CREATED event type.
4878 @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)}
4879 The editor for a cell was created; variant taking a window identifier.
4880 Processes a @c wxEVT_GRID_EDITOR_CREATED event type.
4884 @category{grid,events}
4886 class wxGridEditorCreatedEvent
: public wxCommandEvent
4890 Default constructor.
4892 wxGridEditorCreatedEvent();
4894 Constructor for initializing all event attributes.
4896 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
4897 int row
, int col
, wxControl
* ctrl
);
4900 Returns the column at which the event occurred.
4905 Returns the edit control.
4907 wxControl
* GetControl();
4910 Returns the row at which the event occurred.
4915 Sets the column at which the event occurred.
4917 void SetCol(int col
);
4920 Sets the edit control.
4922 void SetControl(wxControl
* ctrl
);
4925 Sets the row at which the event occurred.
4927 void SetRow(int row
);
4931 wxEventType wxEVT_GRID_CELL_LEFT_CLICK
;
4932 wxEventType wxEVT_GRID_CELL_RIGHT_CLICK
;
4933 wxEventType wxEVT_GRID_CELL_LEFT_DCLICK
;
4934 wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK
;
4935 wxEventType wxEVT_GRID_LABEL_LEFT_CLICK
;
4936 wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK
;
4937 wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK
;
4938 wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK
;
4939 wxEventType wxEVT_GRID_ROW_SIZE
;
4940 wxEventType wxEVT_GRID_COL_SIZE
;
4941 wxEventType wxEVT_GRID_COL_AUTO_SIZE
;
4942 wxEventType wxEVT_GRID_RANGE_SELECT
;
4943 wxEventType wxEVT_GRID_CELL_CHANGING
;
4944 wxEventType wxEVT_GRID_CELL_CHANGED
;
4945 wxEventType wxEVT_GRID_SELECT_CELL
;
4946 wxEventType wxEVT_GRID_EDITOR_SHOWN
;
4947 wxEventType wxEVT_GRID_EDITOR_HIDDEN
;
4948 wxEventType wxEVT_GRID_EDITOR_CREATED
;
4949 wxEventType wxEVT_GRID_CELL_BEGIN_DRAG
;
4950 wxEventType wxEVT_GRID_COL_MOVE
;
4951 wxEventType wxEVT_GRID_COL_SORT
;
4952 wxEventType wxEVT_GRID_TABBING
;