1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGrid and related classes
4 // Author: wxWidgets team
6 // Licence: wxWindows license
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 wxGridCellBoolRenderer, wxGridCellFloatRenderer,
22 wxGridCellNumberRenderer, wxGridCellStringRenderer
24 class wxGridCellRenderer
28 This function must be implemented in derived classes to return a copy
31 virtual wxGridCellRenderer
* Clone() const = 0;
34 Draw the given cell on the provided DC inside the given rectangle using
35 the style specified by the attribute and the default or selected state
36 corresponding to the isSelected value.
38 This pure virtual function has a default implementation which will
39 prepare the DC using the given attribute: it will draw the rectangle
40 with the background colour from attr and set the text colour and font.
42 virtual void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
43 const wxRect
& rect
, int row
, int col
,
47 Get the preferred size of the cell for its contents.
49 virtual wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
50 int row
, int col
) = 0;
54 @class wxGridCellBoolRenderer
56 This class may be used to format boolean data in a cell.
61 @see wxGridCellRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer,
62 wxGridCellStringRenderer
64 class wxGridCellBoolRenderer
: public wxGridCellRenderer
70 wxGridCellBoolRenderer();
74 @class wxGridCellFloatRenderer
76 This class may be used to format floating point data in a cell.
81 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellNumberRenderer,
82 wxGridCellStringRenderer
84 class wxGridCellFloatRenderer
: public wxGridCellStringRenderer
89 Minimum number of characters to be shown.
91 Number of digits after the decimal dot.
93 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
96 Returns the precision.
98 int GetPrecision() const;
103 int GetWidth() const;
106 Parameters string format is "width[,precision]".
108 virtual void SetParameters(const wxString
& params
);
113 void SetPrecision(int precision
);
118 void SetWidth(int width
);
122 @class wxGridCellNumberRenderer
124 This class may be used to format integer data in a cell.
129 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer,
130 wxGridCellStringRenderer
132 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
138 wxGridCellNumberRenderer();
142 @class wxGridCellStringRenderer
144 This class may be used to format string data in a cell; it is the default
150 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer,
151 wxGridCellNumberRenderer
153 class wxGridCellStringRenderer
: public wxGridCellRenderer
159 wxGridCellStringRenderer();
165 @class wxGridCellEditor
167 This class is responsible for providing and manipulating the in-place edit
168 controls for the grid. Instances of wxGridCellEditor (actually, instances
169 of derived classes since it is an abstract class) can be associated with
170 the cell attributes for individual cells, rows, columns, or even for the
176 @see wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellFloatEditor,
177 wxGridCellNumberEditor, wxGridCellTextEditor
179 class wxGridCellEditor
188 Fetch the value from the table and prepare the edit control to begin
189 editing. Sets the focus to the edit control.
191 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
194 Create a new object which is the copy of this one.
196 virtual wxGridCellEditor
* Clone() const = 0;
199 Creates the actual edit control.
201 virtual void Create(wxWindow
* parent
, wxWindowID id
,
202 wxEvtHandler
* evtHandler
) = 0;
207 virtual void Destroy();
210 Complete the editing of the current cell. If necessary, the control may
213 @return @true if the value has changed.
215 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
) = 0;
218 Some types of controls on some platforms may need some help with the
221 virtual void HandleReturn(wxKeyEvent
& event
);
224 Returns @true if the edit control has been created.
229 Draws the part of the cell not occupied by the control: the base class
230 version just fills it with background colour from the attribute.
232 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
* attr
);
235 Reset the value in the control back to its starting value.
237 virtual void Reset() = 0;
240 Size and position the edit control.
242 virtual void SetSize(const wxRect
& rect
);
245 Show or hide the edit control, use the specified attributes to set
246 colours/fonts for it.
248 virtual void Show(bool show
, wxGridCellAttr
* attr
= NULL
);
251 If the editor is enabled by clicking on the cell, this method will be
254 virtual void StartingClick();
257 If the editor is enabled by pressing keys on the grid, this will be
258 called to let the editor do something about that first key if desired.
260 virtual void StartingKey(wxKeyEvent
& event
);
265 The destructor is private because only DecRef() can delete us.
267 virtual ~wxGridCellEditor();
271 @class wxGridCellBoolEditor
273 Grid cell editor for boolean data.
278 @see wxGridCellEditor, wxGridCellChoiceEditor, wxGridCellFloatEditor,
279 wxGridCellNumberEditor, wxGridCellTextEditor
281 class wxGridCellBoolEditor
: public wxGridCellEditor
287 wxGridCellBoolEditor();
290 Returns @true if the given @a value is equal to the string
291 representation of the truth value we currently use (see
294 static bool IsTrueValue(const wxString
& value
);
297 This method allows you to customize the values returned by GetValue()
298 for the cell using this editor. By default, the default values of the
299 arguments are used, i.e. @c "1" is returned if the cell is checked and
300 an empty string otherwise.
302 static void UseStringValues(const wxString
& valueTrue
= "1",
303 const wxString
& valueFalse
= wxEmptyString
) const;
307 @class wxGridCellChoiceEditor
309 Grid cell editor for string data providing the user a choice from a list of
315 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellFloatEditor,
316 wxGridCellNumberEditor, wxGridCellTextEditor
318 class wxGridCellChoiceEditor
: public wxGridCellEditor
323 Number of strings from which the user can choose.
325 An array of strings from which the user can choose.
327 If allowOthers is @true, the user can type a string not in choices
330 wxGridCellChoiceEditor(size_t count
= 0,
331 const wxString choices
[] = NULL
,
332 bool allowOthers
= false);
335 An array of strings from which the user can choose.
337 If allowOthers is @true, the user can type a string not in choices
340 wxGridCellChoiceEditor(const wxArrayString
& choices
,
341 bool allowOthers
= false);
344 Parameters string format is "item1[,item2[...,itemN]]"
346 virtual void SetParameters(const wxString
& params
);
350 @class wxGridCellTextEditor
352 Grid cell editor for string/text data.
357 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
358 wxGridCellFloatEditor, wxGridCellNumberEditor
360 class wxGridCellTextEditor
: public wxGridCellEditor
366 wxGridCellTextEditor();
369 The parameters string format is "n" where n is a number representing
372 virtual void SetParameters(const wxString
& params
);
376 @class wxGridCellFloatEditor
378 The editor for floating point numbers data.
383 @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
384 wxGridCellTextEditor, wxGridCellChoiceEditor
386 class wxGridCellFloatEditor
: public wxGridCellTextEditor
391 Minimum number of characters to be shown.
393 Number of digits after the decimal dot.
395 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
398 Parameters string format is "width,precision"
400 virtual void SetParameters(const wxString
& params
);
404 @class wxGridCellNumberEditor
406 Grid cell editor for numeric integer data.
411 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
412 wxGridCellFloatEditor, wxGridCellTextEditor
414 class wxGridCellNumberEditor
: public wxGridCellTextEditor
418 Allows you to specify the range for acceptable data. Values equal to
419 -1 for both @a min and @a max indicate that no range checking should be
422 wxGridCellNumberEditor(int min
= -1, int max
= -1);
426 Parameters string format is "min,max".
428 virtual void SetParameters(const wxString
& params
);
433 If the return value is @true, the editor uses a wxSpinCtrl to get user
434 input, otherwise it uses a wxTextCtrl.
436 bool HasRange() const;
439 String representation of the value.
441 wxString
GetString() const;
447 @class wxGridCellAttr
449 This class can be used to alter the cells' appearance in the grid by
450 changing their attributes from the defaults. An object of this class may be
451 returned by wxGridTableBase::GetAttr().
464 Constructor specifying some of the often used attributes.
466 wxGridCellAttr(const wxColour
& colText
, const wxColour
& colBack
,
467 const wxFont
& font
, int hAlign
, int vAlign
);
470 Creates a new copy of this object.
472 wxGridCellAttr
* Clone() const;
475 This class is reference counted: it is created with ref count of 1, so
476 calling DecRef() once will delete it. Calling IncRef() allows to lock
477 it until the matching DecRef() is called.
482 See SetAlignment() for the returned values.
484 void GetAlignment(int* hAlign
, int* vAlign
) const;
487 Returns the background colour.
489 const wxColour
& GetBackgroundColour() const;
492 Returns the cell editor.
494 wxGridCellEditor
* GetEditor(const wxGrid
* grid
, int row
, int col
) const;
499 const wxFont
& GetFont() const;
502 Returns the cell renderer.
504 wxGridCellRenderer
* GetRenderer(const wxGrid
* grid
, int row
, int col
) const;
507 Returns the text colour.
509 const wxColour
& GetTextColour() const;
512 Returns @true if this attribute has a valid alignment set.
514 bool HasAlignment() const;
517 Returns @true if this attribute has a valid background colour set.
519 bool HasBackgroundColour() const;
522 Returns @true if this attribute has a valid cell editor set.
524 bool HasEditor() const;
527 Returns @true if this attribute has a valid font set.
529 bool HasFont() const;
532 Returns @true if this attribute has a valid cell renderer set.
534 bool HasRenderer() const;
537 Returns @true if this attribute has a valid text colour set.
539 bool HasTextColour() const;
542 This class is reference counted: it is created with ref count of 1, so
543 calling DecRef() once will delete it. Calling IncRef() allows to lock
544 it until the matching DecRef() is called.
549 Returns @true if this cell is set as read-only.
551 bool IsReadOnly() const;
554 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
555 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of
556 @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
558 void SetAlignment(int hAlign
, int vAlign
);
561 Sets the background colour.
563 void SetBackgroundColour(const wxColour
& colBack
);
566 @todo Needs documentation.
568 void SetDefAttr(wxGridCellAttr
* defAttr
);
571 Sets the editor to be used with the cells with this attribute.
573 void SetEditor(wxGridCellEditor
* editor
);
578 void SetFont(const wxFont
& font
);
581 Sets the cell as read-only.
583 void SetReadOnly(bool isReadOnly
= true);
586 Sets the renderer to be used for cells with this attribute. Takes
587 ownership of the pointer.
589 void SetRenderer(wxGridCellRenderer
* renderer
);
592 Sets the text colour.
594 void SetTextColour(const wxColour
& colText
);
600 @class wxGridTableBase
602 The almost abstract base class for grid tables.
604 A grid table is responsible for storing the grid data and, indirectly, grid
605 cell attributes. The data can be stored in the way most convenient for the
606 application but has to be provided in string form to wxGrid. It is also
607 possible to provide cells values in other formats if appropriate, e.g. as
610 This base class is not quite abstract as it implements a trivial strategy
611 for storing the attributes by forwarding it to wxGridCellAttrProvider and
612 also provides stubs for some other functions. However it does have a number
613 of pure virtual methods which must be implemented in the derived classes.
615 @see wxGridStringTable
620 class wxGridTableBase
: public wxObject
629 Destructor frees the attribute provider if it was created.
631 virtual ~wxGridTableBase();
634 Must be overridden to return the number of rows in the table.
636 For backwards compatibility reasons, this method is not const.
637 Use GetRowsCount() instead of it in const methods of derived table
640 virtual int GetNumberRows() = 0;
643 Must be overridden to return the number of columns in the table.
645 For backwards compatibility reasons, this method is not const.
646 Use GetColsCount() instead of it in const methods of derived table
649 virtual int GetNumberCols() = 0;
652 Return the number of rows in the table.
654 This method is not virtual and is only provided as a convenience for
655 the derived classes which can't call GetNumberRows() without a
656 @c const_cast from their const methods.
658 int GetRowsCount() const;
661 Return the number of columns in the table.
663 This method is not virtual and is only provided as a convenience for
664 the derived classes which can't call GetNumberCols() without a
665 @c const_cast from their const methods.
667 int GetColsCount() const;
671 @name Table Cell Accessors
676 May be overridden to implement testing for empty cells.
678 This method is used by the grid to test if the given cell is not used
679 and so whether a neighbouring cell may overflow into it. By default it
680 only returns true if the value of the given cell, as returned by
681 GetValue(), is empty.
683 virtual bool IsEmptyCell(int row
, int col
);
686 Same as IsEmptyCell() but taking wxGridCellCoords.
688 Notice that this method is not virtual, only IsEmptyCell() should be
691 bool IsEmpty(const wxGridCellCoords
& coords
);
694 Must be overridden to implement accessing the table values as text.
696 virtual wxString
GetValue(int row
, int col
) = 0;
699 Must be overridden to implement setting the table values as text.
701 virtual void SetValue(int row
, int col
, const wxString
& value
) = 0;
704 Returns the type of the value in the given cell.
706 By default all cells are strings and this method returns
707 @c wxGRID_VALUE_STRING.
709 virtual wxString
GetTypeName(int row
, int col
);
712 Returns true if the value of the given cell can be accessed as if it
713 were of the specified type.
715 By default the cells can only be accessed as strings. Note that a cell
716 could be accessible in different ways, e.g. a numeric cell may return
717 @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
718 indicating that the value can be coerced to a string form.
720 virtual bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
723 Returns true if the value of the given cell can be set as if it were of
728 virtual bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
731 Returns the value of the given cell as a long.
733 This should only be called if CanGetValueAs() returns @true when called
734 with @c wxGRID_VALUE_NUMBER argument. Default implementation always
737 virtual long GetValueAsLong(int row
, int col
);
740 Returns the value of the given cell as a double.
742 This should only be called if CanGetValueAs() returns @true when called
743 with @c wxGRID_VALUE_FLOAT argument. Default implementation always
746 virtual double GetValueAsDouble(int row
, int col
);
749 Returns the value of the given cell as a boolean.
751 This should only be called if CanGetValueAs() returns @true when called
752 with @c wxGRID_VALUE_BOOL argument. Default implementation always
755 virtual bool GetValueAsBool(int row
, int col
);
758 Returns the value of the given cell as a user-defined type.
760 This should only be called if CanGetValueAs() returns @true when called
761 with @a typeName. Default implementation always return @NULL.
763 virtual void *GetValueAsCustom(int row
, int col
, const wxString
& typeName
);
766 Sets the value of the given cell as a long.
768 This should only be called if CanSetValueAs() returns @true when called
769 with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
772 virtual void SetValueAsLong(int row
, int col
, long value
);
775 Sets the value of the given cell as a double.
777 This should only be called if CanSetValueAs() returns @true when called
778 with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
781 virtual void SetValueAsDouble(int row
, int col
, double value
);
784 Sets the value of the given cell as a boolean.
786 This should only be called if CanSetValueAs() returns @true when called
787 with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
790 virtual void SetValueAsBool( int row
, int col
, bool value
);
793 Sets the value of the given cell as a user-defined type.
795 This should only be called if CanSetValueAs() returns @true when called
796 with @a typeName. Default implementation doesn't do anything.
798 virtual void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
805 Called by the grid when the table is associated with it.
807 The default implementation stores the pointer and returns it from its
808 GetView() and so only makes sense if the table cannot be associated
809 with more than one grid at a time.
811 virtual void SetView(wxGrid
*grid
);
814 Returns the last grid passed to SetView().
816 virtual wxGrid
*GetView() const;
820 @name Table Structure Modifiers
822 Notice that none of these functions are pure virtual as they don't have
823 to be implemented if the table structure is never modified after
824 creation, i.e. neither rows nor columns are never added or deleted but
825 that you do need to implement them if they are called, i.e. if your
826 code either calls them directly or uses the matching wxGrid methods, as
827 by default they simply do nothing which is definitely inappropriate.
832 Clear the table contents.
834 This method is used by wxGrid::ClearGrid().
836 virtual void Clear();
839 Insert additional rows into the table.
842 The position of the first new row.
844 The number of rows to insert.
846 virtual bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
849 Append additional rows at the end of the table.
851 This method is provided in addition to InsertRows() as some data models
852 may only support appending rows to them but not inserting them at
853 arbitrary locations. In such case you may implement this method only
854 and leave InsertRows() unimplemented.
857 The number of rows to add.
859 virtual bool AppendRows(size_t numRows
= 1);
862 Delete rows from the table.
865 The first row to delete.
867 The number of rows to delete.
869 virtual bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
872 Exactly the same as InsertRows() but for columns.
874 virtual bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
877 Exactly the same as AppendRows() but for columns.
879 virtual bool AppendCols(size_t numCols
= 1);
882 Exactly the same as DeleteRows() but for columns.
884 virtual bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
889 @name Table Row and Column Labels
891 By default the numbers are used for labeling rows and Latin letters for
892 labeling columns. If the table has more than 26 columns, the pairs of
893 letters are used starting from the 27-th one and so on, i.e. the
894 sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
900 Return the label of the specified row.
902 virtual wxString
GetRowLabelValue(int row
);
905 Return the label of the specified column.
907 virtual wxString
GetColLabelValue(int col
);
910 Set the given label for the specified row.
912 The default version does nothing, i.e. the label is not stored. You
913 must override this method in your derived class if you wish
914 wxGrid::SetRowLabelValue() to work.
916 virtual void SetRowLabelValue(int row
, const wxString
& label
);
919 Exactly the same as SetRowLabelValue() but for columns.
921 virtual void SetColLabelValue(int col
, const wxString
& label
);
927 @name Attributes Management
929 By default the attributes management is delegated to
930 wxGridCellAttrProvider class. You may override the methods in this
931 section to handle the attributes directly if, for example, they can be
932 computed from the cell values.
937 Associate this attributes provider with the table.
939 The table takes ownership of @a attrProvider pointer and will delete it
940 when it doesn't need it any more. The pointer can be @NULL, however
941 this won't disable attributes management in the table but will just
942 result in a default attributes being recreated the next time any of the
943 other functions in this section is called. To completely disable the
944 attributes support, should this be needed, you need to override
945 CanHaveAttributes() to return @false.
947 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
950 Returns the attribute provider currently being used.
952 This function may return @NULL if the attribute provider hasn't been
953 neither associated with this table by SetAttrProvider() nor created on
954 demand by any other methods.
956 wxGridCellAttrProvider
*GetAttrProvider() const;
959 Return the attribute for the given cell.
961 By default this function is simply forwarded to
962 wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
963 attributes directly in the table.
965 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
966 wxGridCellAttr::wxAttrKind kind
);
969 Set attribute of the specified cell.
971 By default this function is simply forwarded to
972 wxGridCellAttrProvider::SetAttr().
974 The table takes ownership of @a attr, i.e. will call DecRef() on it.
976 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
979 Set attribute of the specified row.
981 By default this function is simply forwarded to
982 wxGridCellAttrProvider::SetRowAttr().
984 The table takes ownership of @a attr, i.e. will call DecRef() on it.
986 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
989 Set attribute of the specified column.
991 By default this function is simply forwarded to
992 wxGridCellAttrProvider::SetColAttr().
994 The table takes ownership of @a attr, i.e. will call DecRef() on it.
996 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
1001 Returns true if this table supports attributes or false otherwise.
1003 By default, the table automatically creates a wxGridCellAttrProvider
1004 when this function is called if it had no attribute provider before and
1007 virtual bool CanHaveAttributes();
1015 wxGrid and its related classes are used for displaying and editing tabular
1016 data. They provide a rich set of features for display, editing, and
1017 interacting with a variety of data sources. For simple applications, and to
1018 help you get started, wxGrid is the only class you need to refer to
1019 directly. It will set up default instances of the other classes and manage
1020 them for you. For more complex applications you can derive your own classes
1021 for custom grid views, grid data tables, cell editors and renderers. The
1022 @ref overview_grid has examples of simple and more complex applications,
1023 explains the relationship between the various grid classes and has a
1024 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1026 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1027 class. One or more wxGrid classes may act as a view for one table class.
1028 The default table class is called wxGridStringTable and holds an array of
1029 strings. An instance of such a class is created by CreateGrid().
1031 wxGridCellRenderer is the abstract base class for rendereing contents in a
1032 cell. The following renderers are predefined:
1034 - wxGridCellBoolRenderer
1035 - wxGridCellFloatRenderer
1036 - wxGridCellNumberRenderer
1037 - wxGridCellStringRenderer
1039 The look of a cell can be further defined using wxGridCellAttr. An object
1040 of this type may be returned by wxGridTableBase::GetAttr().
1042 wxGridCellEditor is the abstract base class for editing the value of a
1043 cell. The following editors are predefined:
1045 - wxGridCellBoolEditor
1046 - wxGridCellChoiceEditor
1047 - wxGridCellFloatEditor
1048 - wxGridCellNumberEditor
1049 - wxGridCellTextEditor
1051 Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and
1052 wxGridEditorCreatedEvent for the documentation of all event types you can
1058 @see @ref overview_grid, wxGridUpdateLocker
1060 class wxGrid
: public wxScrolledWindow
1065 Different selection modes supported by the grid.
1067 enum wxGridSelectionModes
1070 The default selection mode allowing selection of the individual
1071 cells as well as of the entire rows and columns.
1076 The selection mode allowing the selection of the entire rows only.
1078 The user won't be able to select any cells or columns in this mode.
1083 The selection mode allowing the selection of the entire columns only.
1085 The user won't be able to select any cells or rows in this mode.
1092 @name Constructors and Initialization
1097 Default constructor.
1099 You must call Create() to really create the grid window and also call
1100 CreateGrid() or SetTable() to initialize the grid contents.
1104 Constructor creating the grid window.
1106 You must call either CreateGrid() or SetTable() to initialize the grid
1107 contents before using it.
1109 wxGrid(wxWindow
* parent
, wxWindowID id
,
1110 const wxPoint
& pos
= wxDefaultPosition
,
1111 const wxSize
& size
= wxDefaultSize
,
1112 long style
= wxWANTS_CHARS
,
1113 const wxString
& name
= wxGridNameStr
);
1118 This will also destroy the associated grid table unless you passed a
1119 table object to the grid and specified that the grid should not take
1120 ownership of the table (see SetTable()).
1125 Creates the grid window for an object initialized using the default
1128 You must call either CreateGrid() or SetTable() to initialize the grid
1129 contents before using it.
1131 bool Create(wxWindow
* parent
, wxWindowID id
,
1132 const wxPoint
& pos
= wxDefaultPosition
,
1133 const wxSize
& size
= wxDefaultSize
,
1134 long style
= wxWANTS_CHARS
,
1135 const wxString
& name
= wxGridNameStr
);
1138 Creates a grid with the specified initial number of rows and columns.
1140 Call this directly after the grid constructor. When you use this
1141 function wxGrid will create and manage a simple table of string values
1142 for you. All of the grid data will be stored in memory.
1144 For applications with more complex data types or relationships, or for
1145 dealing with very large datasets, you should derive your own grid table
1146 class and pass a table object to the grid with SetTable().
1148 bool CreateGrid(int numRows
, int numCols
,
1149 wxGridSelectionModes selmode
= wxGridSelectCells
);
1152 Passes a pointer to a custom grid table to be used by the grid.
1154 This should be called after the grid constructor and before using the
1155 grid object. If @a takeOwnership is set to @true then the table will be
1156 deleted by the wxGrid destructor.
1158 Use this function instead of CreateGrid() when your application
1159 involves complex or non-string data or data sets that are too large to
1160 fit wholly in memory.
1162 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= false,
1163 wxGridSelectionModes selmode
= wxGridSelectCells
);
1169 @name Grid Line Formatting
1174 Turns the drawing of grid lines on or off.
1176 void EnableGridLines(bool enable
= true);
1179 Returns the pen used for vertical grid lines.
1181 This virtual function may be overridden in derived classes in order to
1182 change the appearance of individual grid lines for the given column
1185 See GetRowGridLinePen() for an example.
1187 virtual wxPen
GetColGridLinePen(int col
);
1190 Returns the pen used for grid lines.
1192 This virtual function may be overridden in derived classes in order to
1193 change the appearance of grid lines. Note that currently the pen width
1196 @see GetColGridLinePen(), GetRowGridLinePen()
1198 virtual wxPen
GetDefaultGridLinePen();
1201 Returns the colour used for grid lines.
1203 @see GetDefaultGridLinePen()
1205 wxColour
GetGridLineColour() const;
1208 Returns the pen used for horizontal grid lines.
1210 This virtual function may be overridden in derived classes in order to
1211 change the appearance of individual grid line for the given @a row.
1215 // in a grid displaying music notation, use a solid black pen between
1216 // octaves (C0=row 127, C1=row 115 etc.)
1217 wxPen MidiGrid::GetRowGridLinePen(int row)
1219 if ( row % 12 == 7 )
1220 return wxPen(*wxBLACK, 1, wxSOLID);
1222 return GetDefaultGridLinePen();
1226 virtual wxPen
GetRowGridLinePen(int row
);
1229 Returns @true if drawing of grid lines is turned on, @false otherwise.
1231 bool GridLinesEnabled() const;
1234 Sets the colour used to draw grid lines.
1236 void SetGridLineColour(const wxColour
& colour
);
1242 @name Label Values and Formatting
1247 Sets the arguments to the current column label alignment values.
1249 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1250 or @c wxALIGN_RIGHT.
1252 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1255 void GetColLabelAlignment(int* horiz
, int* vert
) const;
1258 Returns the orientation of the column labels (either @c wxHORIZONTAL or
1261 int GetColLabelTextOrientation() const;
1264 Returns the specified column label.
1266 The default grid table class provides column labels of the form
1267 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1268 override wxGridTableBase::GetColLabelValue() to provide your own
1271 wxString
GetColLabelValue(int col
) const;
1274 Returns the colour used for the background of row and column labels.
1276 wxColour
GetLabelBackgroundColour() const;
1279 Returns the font used for row and column labels.
1281 wxFont
GetLabelFont() const;
1284 Returns the colour used for row and column label text.
1286 wxColour
GetLabelTextColour() const;
1289 Returns the alignment used for row labels.
1291 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1292 or @c wxALIGN_RIGHT.
1294 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1297 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
1300 Returns the specified row label.
1302 The default grid table class provides numeric row labels. If you are
1303 using a custom grid table you can override
1304 wxGridTableBase::GetRowLabelValue() to provide your own labels.
1306 wxString
GetRowLabelValue(int row
) const;
1309 Hides the column labels by calling SetColLabelSize() with a size of 0.
1310 Show labels again by calling that method with a width greater than 0.
1312 void HideColLabels();
1315 Hides the row labels by calling SetRowLabelSize() with a size of 0.
1317 The labels can be shown again by calling SetRowLabelSize() with a width
1320 void HideRowLabels();
1323 Sets the horizontal and vertical alignment of column label text.
1325 Horizontal alignment should be one of @c wxALIGN_LEFT,
1326 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
1327 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1329 void SetColLabelAlignment(int horiz
, int vert
);
1332 Sets the orientation of the column labels (either @c wxHORIZONTAL or
1335 void SetColLabelTextOrientation(int textOrientation
);
1338 Set the value for the given column label.
1340 If you are using a custom grid table you must override
1341 wxGridTableBase::SetColLabelValue() for this to have any effect.
1343 void SetColLabelValue(int col
, const wxString
& value
);
1346 Sets the background colour for row and column labels.
1348 void SetLabelBackgroundColour(const wxColour
& colour
);
1351 Sets the font for row and column labels.
1353 void SetLabelFont(const wxFont
& font
);
1356 Sets the colour for row and column label text.
1358 void SetLabelTextColour(const wxColour
& colour
);
1361 Sets the horizontal and vertical alignment of row label text.
1363 Horizontal alignment should be one of @c wxALIGN_LEFT,
1364 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
1365 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1367 void SetRowLabelAlignment(int horiz
, int vert
);
1370 Sets the value for the given row label.
1372 If you are using a derived grid table you must override
1373 wxGridTableBase::SetRowLabelValue() for this to have any effect.
1375 void SetRowLabelValue(int row
, const wxString
& value
);
1378 Call this in order to make the column labels use a native look by using
1379 wxRenderer::DrawHeaderButton() internally.
1381 There is no equivalent method for drawing row columns as there is not
1382 native look for that. This option is useful when using wxGrid for
1383 displaying tables and not as a spread-sheet.
1385 void SetUseNativeColLabels(bool native
= true);
1391 @name Cell Formatting
1393 Note that wxGridCellAttr can be used alternatively to most of these
1394 methods. See the "Attributes Management" of wxGridTableBase.
1399 Sets the arguments to the horizontal and vertical text alignment values
1400 for the grid cell at the specified location.
1402 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1403 or @c wxALIGN_RIGHT.
1405 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1408 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
1411 Returns the background colour of the cell at the specified location.
1413 wxColour
GetCellBackgroundColour(int row
, int col
) const;
1416 Returns the font for text in the grid cell at the specified location.
1418 wxFont
GetCellFont(int row
, int col
) const;
1421 Returns the text colour for the grid cell at the specified location.
1423 wxColour
GetCellTextColour(int row
, int col
) const;
1426 Returns the default cell alignment.
1428 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1429 or @c wxALIGN_RIGHT.
1431 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1434 @see SetDefaultCellAlignment()
1436 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
1439 Returns the current default background colour for grid cells.
1441 wxColour
GetDefaultCellBackgroundColour() const;
1444 Returns the current default font for grid cell text.
1446 wxFont
GetDefaultCellFont() const;
1449 Returns the current default colour for grid cell text.
1451 wxColour
GetDefaultCellTextColour() const;
1454 Sets the horizontal and vertical alignment for grid cell text at the
1457 Horizontal alignment should be one of @c wxALIGN_LEFT,
1458 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
1460 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
1461 or @c wxALIGN_BOTTOM.
1463 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
1465 Sets the horizontal and vertical alignment for grid cell text at the
1468 Horizontal alignment should be one of @c wxALIGN_LEFT,
1469 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
1471 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
1472 or @c wxALIGN_BOTTOM.
1474 void SetCellAlignment(int align
, int row
, int col
);
1477 Set the background colour for the given cell or all cells by default.
1479 void SetCellBackgroundColour(int row
, int col
, const wxColour
& colour
);
1482 Sets the font for text in the grid cell at the specified location.
1484 void SetCellFont(int row
, int col
, const wxFont
& font
);
1487 Sets the text colour for the given cell.
1489 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
1491 Sets the text colour for the given cell.
1493 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
1495 Sets the text colour for all cells by default.
1497 void SetCellTextColour(const wxColour
& colour
);
1500 Sets the default horizontal and vertical alignment for grid cell text.
1502 Horizontal alignment should be one of @c wxALIGN_LEFT,
1503 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
1504 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1506 void SetDefaultCellAlignment(int horiz
, int vert
);
1509 Sets the default background colour for grid cells.
1511 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
1514 Sets the default font to be used for grid cell text.
1516 void SetDefaultCellFont(const wxFont
& font
);
1519 Sets the current default colour for grid cell text.
1521 void SetDefaultCellTextColour(const wxColour
& colour
);
1527 @name Cell Values, Editors, and Renderers
1529 Note that wxGridCellAttr can be used alternatively to most of these
1530 methods. See the "Attributes Management" of wxGridTableBase.
1535 Returns @true if the in-place edit control for the current grid cell
1536 can be used and @false otherwise.
1538 This function always returns @false for the read-only cells.
1540 bool CanEnableCellControl() const;
1543 Disables in-place editing of grid cells.
1545 Equivalent to calling EnableCellEditControl(@false).
1547 void DisableCellEditControl();
1550 Enables or disables in-place editing of grid cell data.
1552 The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or
1553 @c wxEVT_GRID_EDITOR_HIDDEN event.
1555 void EnableCellEditControl(bool enable
= true);
1558 Makes the grid globally editable or read-only.
1560 If the edit argument is @false this function sets the whole grid as
1561 read-only. If the argument is @true the grid is set to the default
1562 state where cells may be editable. In the default state you can set
1563 single grid cells and whole rows and columns to be editable or
1564 read-only via wxGridCellAttr::SetReadOnly(). For single cells you
1565 can also use the shortcut function SetReadOnly().
1567 For more information about controlling grid cell attributes see the
1568 wxGridCellAttr class and the @ref overview_grid.
1570 void EnableEditing(bool edit
);
1573 Returns a pointer to the editor for the cell at the specified location.
1575 See wxGridCellEditor and the @ref overview_grid for more information
1576 about cell editors and renderers.
1578 The caller must call DecRef() on the returned pointer.
1580 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
1583 Returns a pointer to the renderer for the grid cell at the specified
1586 See wxGridCellRenderer and the @ref overview_grid for more information
1587 about cell editors and renderers.
1589 The caller must call DecRef() on the returned pointer.
1591 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
1594 Returns the string contained in the cell at the specified location.
1596 For simple applications where a grid object automatically uses a
1597 default grid table of string values you use this function together with
1598 SetCellValue() to access cell values. For more complex applications
1599 where you have derived your own grid table class that contains various
1600 data types (e.g. numeric, boolean or user-defined custom types) then
1601 you only use this function for those cells that contain string values.
1603 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
1606 wxString
GetCellValue(int row
, int col
) const;
1608 Returns the string contained in the cell at the specified location.
1610 For simple applications where a grid object automatically uses a
1611 default grid table of string values you use this function together with
1612 SetCellValue() to access cell values. For more complex applications
1613 where you have derived your own grid table class that contains various
1614 data types (e.g. numeric, boolean or user-defined custom types) then
1615 you only use this function for those cells that contain string values.
1617 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
1620 const wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
1623 Returns a pointer to the current default grid cell editor.
1625 See wxGridCellEditor and the @ref overview_grid for more information
1626 about cell editors and renderers.
1628 wxGridCellEditor
* GetDefaultEditor() const;
1631 Returns the default editor for the specified cell.
1633 The base class version returns the editor appropriate for the current
1634 cell type but this method may be overridden in the derived classes to
1635 use custom editors for some cells by default.
1637 Notice that the same may be achieved in a usually simpler way by
1638 associating a custom editor with the given cell or cells.
1640 The caller must call DecRef() on the returned pointer.
1642 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1644 Returns the default editor for the specified cell.
1646 The base class version returns the editor appropriate for the current
1647 cell type but this method may be overridden in the derived classes to
1648 use custom editors for some cells by default.
1650 Notice that the same may be achieved in a usually simpler way by
1651 associating a custom editor with the given cell or cells.
1653 The caller must call DecRef() on the returned pointer.
1655 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
1658 Returns the default editor for the cells containing values of the given
1661 The base class version returns the editor which was associated with the
1662 specified @a typeName when it was registered RegisterDataType() but
1663 this function may be overridden to return something different. This
1664 allows to override an editor used for one of the standard types.
1666 The caller must call DecRef() on the returned pointer.
1668 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1671 Returns a pointer to the current default grid cell renderer.
1673 See wxGridCellRenderer and the @ref overview_grid for more information
1674 about cell editors and renderers.
1676 The caller must call DecRef() on the returned pointer.
1678 wxGridCellRenderer
* GetDefaultRenderer() const;
1681 Returns the default renderer for the given cell.
1683 The base class version returns the renderer appropriate for the current
1684 cell type but this method may be overridden in the derived classes to
1685 use custom renderers for some cells by default.
1687 The caller must call DecRef() on the returned pointer.
1689 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1692 Returns the default renderer for the cell containing values of the
1695 @see GetDefaultEditorForType()
1697 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1700 Hides the in-place cell edit control.
1702 void HideCellEditControl();
1705 Returns @true if the in-place edit control is currently enabled.
1707 bool IsCellEditControlEnabled() const;
1710 Returns @true if the current cell is read-only.
1712 @see SetReadOnly(), IsReadOnly()
1714 bool IsCurrentCellReadOnly() const;
1717 Returns @false if the whole grid has been set as read-only or @true
1720 See EnableEditing() for more information about controlling the editing
1721 status of grid cells.
1723 bool IsEditable() const;
1726 Returns @true if the cell at the specified location can't be edited.
1728 @see SetReadOnly(), IsCurrentCellReadOnly()
1730 bool IsReadOnly(int row
, int col
) const;
1733 Register a new data type.
1735 The data types allow to naturally associate specific renderers and
1736 editors to the cells containing values of the given type. For example,
1737 the grid automatically registers a data type with the name
1738 @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
1739 wxGridCellTextEditor as its renderer and editor respectively -- this is
1740 the data type used by all the cells of the default wxGridStringTable,
1741 so this renderer and editor are used by default for all grid cells.
1743 However if a custom table returns @c wxGRID_VALUE_BOOL from its
1744 wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
1745 wxGridCellBoolEditor are used for it because the grid also registers a
1746 boolean data type with this name.
1748 And as this mechanism is completely generic, you may register your own
1749 data types using your own custom renderers and editors. Just remember
1750 that the table must identify a cell as being of the given type for them
1751 to be used for this cell.
1754 Name of the new type. May be any string, but if the type name is
1755 the same as the name of an already registered type, including one
1756 of the standard ones (which are @c wxGRID_VALUE_STRING, @c
1757 wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT
1758 and @c wxGRID_VALUE_CHOICE), then the new registration information
1759 replaces the previously used renderer and editor.
1761 The renderer to use for the cells of this type. Its ownership is
1762 taken by the grid, i.e. it will call DecRef() on this pointer when
1763 it doesn't need it any longer.
1765 The editor to use for the cells of this type. Its ownership is also
1768 void RegisterDataType(const wxString
& typeName
,
1769 wxGridCellRenderer
* renderer
,
1770 wxGridCellEditor
* editor
);
1773 Sets the value of the current grid cell to the current in-place edit
1776 This is called automatically when the grid cursor moves from the
1777 current cell to a new cell. It is also a good idea to call this
1778 function when closing a grid since any edits to the final cell location
1779 will not be saved otherwise.
1781 void SaveEditControlValue();
1784 Sets the editor for the grid cell at the specified location.
1786 The grid will take ownership of the pointer.
1788 See wxGridCellEditor and the @ref overview_grid for more information
1789 about cell editors and renderers.
1791 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
1794 Sets the renderer for the grid cell at the specified location.
1796 The grid will take ownership of the pointer.
1798 See wxGridCellRenderer and the @ref overview_grid for more information
1799 about cell editors and renderers.
1801 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
* renderer
);
1804 Sets the string value for the cell at the specified location.
1806 For simple applications where a grid object automatically uses a
1807 default grid table of string values you use this function together with
1808 GetCellValue() to access cell values. For more complex applications
1809 where you have derived your own grid table class that contains various
1810 data types (e.g. numeric, boolean or user-defined custom types) then
1811 you only use this function for those cells that contain string values.
1813 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
1816 void SetCellValue(int row
, int col
, const wxString
& s
);
1818 Sets the string value for the cell at the specified location.
1820 For simple applications where a grid object automatically uses a
1821 default grid table of string values you use this function together with
1822 GetCellValue() to access cell values. For more complex applications
1823 where you have derived your own grid table class that contains various
1824 data types (e.g. numeric, boolean or user-defined custom types) then
1825 you only use this function for those cells that contain string values.
1827 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
1830 void SetCellValue(const wxGridCellCoords
& coords
, const wxString
& s
);
1832 @deprecated Please use SetCellValue(int,int,const wxString&) or
1833 SetCellValue(const wxGridCellCoords&,const wxString&)
1836 Sets the string value for the cell at the specified location.
1838 For simple applications where a grid object automatically uses a
1839 default grid table of string values you use this function together with
1840 GetCellValue() to access cell values. For more complex applications
1841 where you have derived your own grid table class that contains various
1842 data types (e.g. numeric, boolean or user-defined custom types) then
1843 you only use this function for those cells that contain string values.
1845 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
1848 void SetCellValue(const wxString
& val
, int row
, int col
);
1851 Sets the specified column to display boolean values.
1853 @see SetColFormatCustom()
1855 void SetColFormatBool(int col
);
1858 Sets the specified column to display data in a custom format.
1860 This method provides an alternative to defining a custom grid table
1861 which would return @a typeName from its GetTypeName() method for the
1862 cells in this column: while it doesn't really change the type of the
1863 cells in this column, it does associate the renderer and editor used
1864 for the cells of the specified type with them.
1866 See the @ref overview_grid for more information on working with custom
1869 void SetColFormatCustom(int col
, const wxString
& typeName
);
1872 Sets the specified column to display floating point values with the
1873 given width and precision.
1875 @see SetColFormatCustom()
1877 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
1880 Sets the specified column to display integer values.
1882 @see SetColFormatCustom()
1884 void SetColFormatNumber(int col
);
1887 Sets the default editor for grid cells.
1889 The grid will take ownership of the pointer.
1891 See wxGridCellEditor and the @ref overview_grid for more information
1892 about cell editors and renderers.
1894 void SetDefaultEditor(wxGridCellEditor
* editor
);
1897 Sets the default renderer for grid cells.
1899 The grid will take ownership of the pointer.
1901 See wxGridCellRenderer and the @ref overview_grid for more information
1902 about cell editors and renderers.
1904 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
1907 Makes the cell at the specified location read-only or editable.
1911 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
1914 Displays the in-place cell edit control for the current cell.
1916 void ShowCellEditControl();
1922 @name Column and Row Sizes
1927 Automatically sets the height and width of all rows and columns to fit
1933 Automatically adjusts width of the column to fit its label.
1935 void AutoSizeColLabelSize(int col
);
1938 Automatically sizes the column to fit its contents. If @a setAsMin is
1939 @true the calculated width will also be set as the minimal width for
1942 void AutoSizeColumn(int col
, bool setAsMin
= true);
1945 Automatically sizes all columns to fit their contents. If @a setAsMin
1946 is @true the calculated widths will also be set as the minimal widths
1949 void AutoSizeColumns(bool setAsMin
= true);
1952 Automatically sizes the row to fit its contents. If @a setAsMin is
1953 @true the calculated height will also be set as the minimal height for
1956 void AutoSizeRow(int row
, bool setAsMin
= true);
1959 Automatically adjusts height of the row to fit its label.
1961 void AutoSizeRowLabelSize(int col
);
1964 Automatically sizes all rows to fit their contents. If @a setAsMin is
1965 @true the calculated heights will also be set as the minimal heights
1968 void AutoSizeRows(bool setAsMin
= true);
1971 Returns the current height of the column labels.
1973 int GetColLabelSize() const;
1976 Returns the minimal width to which a column may be resized.
1978 Use SetColMinimalAcceptableWidth() to change this value globally or
1979 SetColMinimalWidth() to do it for individual columns.
1981 @see GetRowMinimalAcceptableHeight()
1983 int GetColMinimalAcceptableWidth() const;
1986 Returns the width of the specified column.
1988 int GetColSize(int col
) const;
1991 Returns the default height for column labels.
1993 int GetDefaultColLabelSize() const;
1996 Returns the current default width for grid columns.
1998 int GetDefaultColSize() const;
2001 Returns the default width for the row labels.
2003 int GetDefaultRowLabelSize() const;
2006 Returns the current default height for grid rows.
2008 int GetDefaultRowSize() const;
2011 Returns the minimal size to which rows can be resized.
2013 Use SetRowMinimalAcceptableHeight() to change this value globally or
2014 SetRowMinimalHeight() to do it for individual cells.
2016 @see GetColMinimalAcceptableWidth()
2018 int GetRowMinimalAcceptableHeight() const;
2021 Returns the current width of the row labels.
2023 int GetRowLabelSize() const;
2026 Returns the height of the specified row.
2028 int GetRowSize(int row
) const;
2031 Sets the height of the column labels.
2033 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
2034 automatically so that no label is truncated. Note that this could be
2035 slow for a large table.
2037 void SetColLabelSize(int height
);
2040 Sets the minimal @a width to which the user can resize columns.
2042 @see GetColMinimalAcceptableWidth()
2044 void SetColMinimalAcceptableWidth(int width
);
2047 Sets the minimal @a width for the specified column @a col.
2049 It is usually best to call this method during grid creation as calling
2050 it later will not resize the column to the given minimal width even if
2051 it is currently narrower than it.
2053 @a width must be greater than the minimal acceptable column width as
2054 returned by GetColMinimalAcceptableWidth().
2056 void SetColMinimalWidth(int col
, int width
);
2059 Sets the width of the specified column.
2061 Notice that this function does not refresh the grid, you need to call
2062 ForceRefresh() to make the changes take effect immediately.
2067 The new column width in pixels or a negative value to fit the
2068 column width to its label width.
2070 void SetColSize(int col
, int width
);
2073 Sets the default width for columns in the grid.
2075 This will only affect columns subsequently added to the grid unless
2076 @a resizeExistingCols is @true.
2078 If @a width is less than GetColMinimalAcceptableWidth(), then the
2079 minimal acceptable width is used instead of it.
2081 void SetDefaultColSize(int width
, bool resizeExistingCols
= false);
2084 Sets the default height for rows in the grid.
2086 This will only affect rows subsequently added to the grid unless
2087 @a resizeExistingRows is @true.
2089 If @a height is less than GetRowMinimalAcceptableHeight(), then the
2090 minimal acceptable heihgt is used instead of it.
2092 void SetDefaultRowSize(int height
, bool resizeExistingRows
= false);
2095 Sets the width of the row labels.
2097 If @a width equals @c wxGRID_AUTOSIZE then width is calculated
2098 automatically so that no label is truncated. Note that this could be
2099 slow for a large table.
2101 void SetRowLabelSize(int width
);
2104 Sets the minimal row @a height used by default.
2106 See SetColMinimalAcceptableWidth() for more information.
2108 void SetRowMinimalAcceptableHeight(int height
);
2111 Sets the minimal @a height for the specified @a row.
2113 See SetColMinimalWidth() for more information.
2115 void SetRowMinimalHeight(int row
, int height
);
2118 Sets the height of the specified row.
2120 See SetColSize() for more information.
2122 void SetRowSize(int row
, int height
);
2128 @name User-Resizing and Dragging
2133 Return @true if the dragging of cells is enabled or @false otherwise.
2135 bool CanDragCell() const;
2138 Returns @true if columns can be moved by dragging with the mouse.
2140 Columns can be moved by dragging on their labels.
2142 bool CanDragColMove() const;
2145 Returns @true if columns can be resized by dragging with the mouse.
2147 Columns can be resized by dragging the edges of their labels. If grid
2148 line dragging is enabled they can also be resized by dragging the right
2149 edge of the column in the grid cell area (see EnableDragGridSize()).
2151 bool CanDragColSize() const;
2154 Return @true if the dragging of grid lines to resize rows and columns
2155 is enabled or @false otherwise.
2157 bool CanDragGridSize() const;
2160 Returns @true if rows can be resized by dragging with the mouse.
2162 Rows can be resized by dragging the edges of their labels. If grid line
2163 dragging is enabled they can also be resized by dragging the lower edge
2164 of the row in the grid cell area (see EnableDragGridSize()).
2166 bool CanDragRowSize() const;
2169 Disables column moving by dragging with the mouse.
2171 Equivalent to passing @false to EnableDragColMove().
2173 void DisableDragColMove();
2176 Disables column sizing by dragging with the mouse.
2178 Equivalent to passing @false to EnableDragColSize().
2180 void DisableDragColSize();
2183 Disable mouse dragging of grid lines to resize rows and columns.
2185 Equivalent to passing @false to EnableDragGridSize()
2187 void DisableDragGridSize();
2190 Disables row sizing by dragging with the mouse.
2192 Equivalent to passing @false to EnableDragRowSize().
2194 void DisableDragRowSize();
2197 Enables or disables cell dragging with the mouse.
2199 void EnableDragCell(bool enable
= true);
2202 Enables or disables column moving by dragging with the mouse.
2204 void EnableDragColMove(bool enable
= true);
2207 Enables or disables column sizing by dragging with the mouse.
2209 void EnableDragColSize(bool enable
= true);
2212 Enables or disables row and column resizing by dragging gridlines with
2215 void EnableDragGridSize(bool enable
= true);
2218 Enables or disables row sizing by dragging with the mouse.
2220 void EnableDragRowSize(bool enable
= true);
2223 Returns the column ID of the specified column position.
2225 int GetColAt(int colPos
) const;
2228 Returns the position of the specified column.
2230 int GetColPos(int colID
) const;
2233 Sets the position of the specified column.
2235 void SetColPos(int colID
, int newPos
);
2241 @name Cursor Movement
2246 Returns the current grid cell column position.
2248 int GetGridCursorCol() const;
2251 Returns the current grid cell row position.
2253 int GetGridCursorRow() const;
2256 Make the given cell current and ensure it is visible.
2258 This method is equivalent to calling MakeCellVisible() and
2259 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
2260 event is generated by it and the selected cell doesn't change if the
2263 void GoToCell(int row
, int col
);
2265 Make the given cell current and ensure it is visible.
2267 This method is equivalent to calling MakeCellVisible() and
2268 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
2269 event is generated by it and the selected cell doesn't change if the
2272 void GoToCell(const wxGridCellCoords
& coords
);
2275 Moves the grid cursor down by one row.
2277 If a block of cells was previously selected it will expand if the
2278 argument is @true or be cleared if the argument is @false.
2280 bool MoveCursorDown(bool expandSelection
);
2283 Moves the grid cursor down in the current column such that it skips to
2284 the beginning or end of a block of non-empty cells.
2286 If a block of cells was previously selected it will expand if the
2287 argument is @true or be cleared if the argument is @false.
2289 bool MoveCursorDownBlock(bool expandSelection
);
2292 Moves the grid cursor left by one column.
2294 If a block of cells was previously selected it will expand if the
2295 argument is @true or be cleared if the argument is @false.
2297 bool MoveCursorLeft(bool expandSelection
);
2300 Moves the grid cursor left in the current row such that it skips to the
2301 beginning or end of a block of non-empty cells.
2303 If a block of cells was previously selected it will expand if the
2304 argument is @true or be cleared if the argument is @false.
2306 bool MoveCursorLeftBlock(bool expandSelection
);
2309 Moves the grid cursor right by one column.
2311 If a block of cells was previously selected it will expand if the
2312 argument is @true or be cleared if the argument is @false.
2314 bool MoveCursorRight(bool expandSelection
);
2317 Moves the grid cursor right in the current row such that it skips to
2318 the beginning or end of a block of non-empty cells.
2320 If a block of cells was previously selected it will expand if the
2321 argument is @true or be cleared if the argument is @false.
2323 bool MoveCursorRightBlock(bool expandSelection
);
2326 Moves the grid cursor up by one row.
2328 If a block of cells was previously selected it will expand if the
2329 argument is @true or be cleared if the argument is @false.
2331 bool MoveCursorUp(bool expandSelection
);
2334 Moves the grid cursor up in the current column such that it skips to
2335 the beginning or end of a block of non-empty cells.
2337 If a block of cells was previously selected it will expand if the
2338 argument is @true or be cleared if the argument is @false.
2340 bool MoveCursorUpBlock(bool expandSelection
);
2343 Moves the grid cursor down by some number of rows so that the previous
2344 bottom visible row becomes the top visible row.
2346 bool MovePageDown();
2349 Moves the grid cursor up by some number of rows so that the previous
2350 top visible row becomes the bottom visible row.
2355 Set the grid cursor to the specified cell.
2357 The grid cursor indicates the current cell and can be moved by the user
2358 using the arrow keys or the mouse.
2360 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
2361 if the event handler vetoes this event, the cursor is not moved.
2363 This function doesn't make the target call visible, use GoToCell() to
2366 void SetGridCursor(int row
, int col
);
2368 Set the grid cursor to the specified cell.
2370 The grid cursor indicates the current cell and can be moved by the user
2371 using the arrow keys or the mouse.
2373 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
2374 if the event handler vetoes this event, the cursor is not moved.
2376 This function doesn't make the target call visible, use GoToCell() to
2379 void SetGridCursor(const wxGridCellCoords
& coords
);
2385 @name User Selection
2390 Deselects all cells that are currently selected.
2392 void ClearSelection();
2395 Returns an array of individually selected cells.
2397 Notice that this array does @em not contain all the selected cells in
2398 general as it doesn't include the cells selected as part of column, row
2399 or block selection. You must use this method, GetSelectedCols(),
2400 GetSelectedRows() and GetSelectionBlockTopLeft() and
2401 GetSelectionBlockBottomRight() methods to obtain the entire selection
2404 Please notice this behaviour is by design and is needed in order to
2405 support grids of arbitrary size (when an entire column is selected in
2406 a grid with a million of columns, we don't want to create an array with
2407 a million of entries in this function, instead it returns an empty
2408 array and GetSelectedCols() returns an array containing one element).
2410 wxGridCellCoordsArray
GetSelectedCells() const;
2413 Returns an array of selected columns.
2415 Please notice that this method alone is not sufficient to find all the
2416 selected columns as it contains only the columns which were
2417 individually selected but not those being part of the block selection
2418 or being selected in virtue of all of their cells being selected
2419 individually, please see GetSelectedCells() for more details.
2421 wxArrayInt
GetSelectedCols() const;
2424 Returns an array of selected rows.
2426 Please notice that this method alone is not sufficient to find all the
2427 selected rows as it contains only the rows which were individually
2428 selected but not those being part of the block selection or being
2429 selected in virtue of all of their cells being selected individually,
2430 please see GetSelectedCells() for more details.
2432 wxArrayInt
GetSelectedRows() const;
2435 Returns the colour used for drawing the selection background.
2437 wxColour
GetSelectionBackground() const;
2440 Returns an array of the bottom right corners of blocks of selected
2443 Please see GetSelectedCells() for more information about the selection
2444 representation in wxGrid.
2446 @see GetSelectionBlockTopLeft()
2448 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
2451 Returns an array of the top left corners of blocks of selected cells.
2453 Please see GetSelectedCells() for more information about the selection
2454 representation in wxGrid.
2456 @see GetSelectionBlockBottomRight()
2458 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
2461 Returns the colour used for drawing the selection foreground.
2463 wxColour
GetSelectionForeground() const;
2466 Returns the current selection mode.
2468 @see SetSelectionMode().
2470 wxGridSelectionModes
GetSelectionMode() const;
2473 Returns @true if the given cell is selected.
2475 bool IsInSelection(int row
, int col
) const;
2477 Returns @true if the given cell is selected.
2479 bool IsInSelection(const wxGridCellCoords
& coords
) const;
2482 Returns @true if there are currently any selected cells, rows, columns
2485 bool IsSelection() const;
2488 Selects all cells in the grid.
2493 Selects a rectangular block of cells.
2495 If @a addToSelected is @false then any existing selection will be
2496 deselected; if @true the column will be added to the existing
2499 void SelectBlock(int topRow
, int leftCol
, int bottomRow
, int rightCol
,
2500 bool addToSelected
= false);
2502 Selects a rectangular block of cells.
2504 If @a addToSelected is @false then any existing selection will be
2505 deselected; if @true the column will be added to the existing
2508 void SelectBlock(const wxGridCellCoords
& topLeft
,
2509 const wxGridCellCoords
& bottomRight
,
2510 bool addToSelected
= false);
2513 Selects the specified column.
2515 If @a addToSelected is @false then any existing selection will be
2516 deselected; if @true the column will be added to the existing
2519 This method won't select anything if the current selection mode is
2522 void SelectCol(int col
, bool addToSelected
= false);
2525 Selects the specified row.
2527 If @a addToSelected is @false then any existing selection will be
2528 deselected; if @true the row will be added to the existing selection.
2530 This method won't select anything if the current selection mode is
2531 wxGridSelectColumns.
2533 void SelectRow(int row
, bool addToSelected
= false);
2536 Set the colour to be used for drawing the selection background.
2538 void SetSelectionBackground(const wxColour
& c
);
2541 Set the colour to be used for drawing the selection foreground.
2543 void SetSelectionForeground(const wxColour
& c
);
2546 Set the selection behaviour of the grid.
2548 The existing selection is converted to conform to the new mode if
2549 possible and discarded otherwise (e.g. any individual selected cells
2550 are deselected if the new mode allows only the selection of the entire
2553 void SetSelectionMode(wxGridSelectionModes selmode
);
2564 Returns the number of pixels per horizontal scroll increment.
2568 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
2570 int GetScrollLineX() const;
2573 Returns the number of pixels per vertical scroll increment.
2577 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
2579 int GetScrollLineY() const;
2582 Returns @true if a cell is either entirely or at least partially
2583 visible in the grid window.
2585 By default, the cell must be entirely visible for this function to
2586 return @true but if @a wholeCellVisible is @false, the function returns
2587 @true even if the cell is only partially visible.
2589 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
2591 Returns @true if a cell is either entirely or at least partially
2592 visible in the grid window.
2594 By default, the cell must be entirely visible for this function to
2595 return @true but if @a wholeCellVisible is @false, the function returns
2596 @true even if the cell is only partially visible.
2598 bool IsVisible(const wxGridCellCoords
& coords
,
2599 bool wholeCellVisible
= true) const;
2602 Brings the specified cell into the visible grid cell area with minimal
2605 Does nothing if the cell is already visible.
2607 void MakeCellVisible(int row
, int col
);
2609 Brings the specified cell into the visible grid cell area with minimal
2612 Does nothing if the cell is already visible.
2614 void MakeCellVisible(const wxGridCellCoords
& coords
);
2617 Sets the number of pixels per horizontal scroll increment.
2621 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2623 void SetScrollLineX(int x
);
2626 Sets the number of pixels per vertical scroll increment.
2630 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2632 void SetScrollLineY(int y
);
2638 @name Cell and Device Coordinate Translation
2643 Convert grid cell coordinates to grid window pixel coordinates.
2645 This function returns the rectangle that encloses the block of cells
2646 limited by @a topLeft and @a bottomRight cell in device coords and
2647 clipped to the client size of the grid window.
2651 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
2652 const wxGridCellCoords
& bottomRight
) const;
2655 Return the rectangle corresponding to the grid cell's size and position
2656 in logical coordinates.
2658 @see BlockToDeviceRect()
2660 wxRect
CellToRect(int row
, int col
) const;
2662 Return the rectangle corresponding to the grid cell's size and position
2663 in logical coordinates.
2665 @see BlockToDeviceRect()
2667 const wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
2670 Returns the column at the given pixel position.
2673 The x position to evaluate.
2675 If @true, rather than returning @c wxNOT_FOUND, it returns either
2676 the first or last column depending on whether @a x is too far to
2677 the left or right respectively.
2679 The column index or @c wxNOT_FOUND.
2681 int XToCol(int x
, bool clipToMinMax
= false) const;
2684 Returns the column whose right hand edge is close to the given logical
2687 If no column edge is near to this position @c wxNOT_FOUND is returned.
2689 int XToEdgeOfCol(int x
) const;
2692 Translates logical pixel coordinates to the grid cell coordinates.
2694 Notice that this function expects logical coordinates on input so if
2695 you use this function in a mouse event handler you need to translate
2696 the mouse position, which is expressed in device coordinates, to
2699 @see XToCol(), YToRow()
2701 wxGridCellCoords
XYToCell(int x
, int y
) const;
2703 Translates logical pixel coordinates to the grid cell coordinates.
2705 Notice that this function expects logical coordinates on input so if
2706 you use this function in a mouse event handler you need to translate
2707 the mouse position, which is expressed in device coordinates, to
2710 @see XToCol(), YToRow()
2712 wxGridCellCoords
XYToCell(const wxPoint
& pos
) const;
2713 // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
2714 // undocumented, using it is ugly and non-const reference parameters are
2715 // not used in wxWidgets API
2718 Returns the row whose bottom edge is close to the given logical @a y
2721 If no row edge is near to this position @c wxNOT_FOUND is returned.
2723 int YToEdgeOfRow(int y
) const;
2726 Returns the grid row that corresponds to the logical @a y coordinate.
2728 Returns @c wxNOT_FOUND if there is no row at the @a y position.
2730 int YToRow(int y
, bool clipToMinMax
= false) const;
2736 @name Miscellaneous Functions
2741 Appends one or more new columns to the right of the grid.
2743 The @a updateLabels argument is not used at present. If you are using a
2744 derived grid table class you will need to override
2745 wxGridTableBase::AppendCols(). See InsertCols() for further
2748 @return @true on success or @false if appending columns failed.
2750 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
2753 Appends one or more new rows to the bottom of the grid.
2755 The @a updateLabels argument is not used at present. If you are using a
2756 derived grid table class you will need to override
2757 wxGridTableBase::AppendRows(). See InsertRows() for further
2760 @return @true on success or @false if appending rows failed.
2762 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
2765 Return @true if the horizontal grid lines stop at the last column
2766 boundary or @false if they continue to the end of the window.
2768 The default is to clip grid lines.
2770 @see ClipHorzGridLines(), AreVertGridLinesClipped()
2772 bool AreHorzGridLinesClipped() const;
2775 Return @true if the vertical grid lines stop at the last row
2776 boundary or @false if they continue to the end of the window.
2778 The default is to clip grid lines.
2780 @see ClipVertGridLines(), AreHorzGridLinesClipped()
2782 bool AreVertGridLinesClipped() const;
2785 Increments the grid's batch count.
2787 When the count is greater than zero repainting of the grid is
2788 suppressed. Each call to BeginBatch must be matched by a later call to
2789 EndBatch(). Code that does a lot of grid modification can be enclosed
2790 between BeginBatch() and EndBatch() calls to avoid screen flicker. The
2791 final EndBatch() call will cause the grid to be repainted.
2793 Notice that you should use wxGridUpdateLocker which ensures that there
2794 is always a matching EndBatch() call for this BeginBatch() if possible
2795 instead of calling this method directly.
2800 Clears all data in the underlying grid table and repaints the grid.
2802 The table is not deleted by this function. If you are using a derived
2803 table class then you need to override wxGridTableBase::Clear() for this
2804 function to have any effect.
2809 Change whether the horizontal grid lines are clipped by the end of the
2812 By default the grid lines are not drawn beyond the end of the last
2813 column but after calling this function with @a clip set to @false they
2814 will be drawn across the entire grid window.
2816 @see AreHorzGridLinesClipped(), ClipVertGridLines()
2818 void ClipHorzGridLines(bool clip
);
2821 Change whether the vertical grid lines are clipped by the end of the
2824 By default the grid lines are not drawn beyond the end of the last
2825 row but after calling this function with @a clip set to @false they
2826 will be drawn across the entire grid window.
2828 @see AreVertGridLinesClipped(), ClipHorzGridLines()
2830 void ClipVertGridLines(bool clip
);
2833 Deletes one or more columns from a grid starting at the specified
2836 The @a updateLabels argument is not used at present. If you are using a
2837 derived grid table class you will need to override
2838 wxGridTableBase::DeleteCols(). See InsertCols() for further
2841 @return @true on success or @false if deleting columns failed.
2843 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
2846 Deletes one or more rows from a grid starting at the specified
2849 The @a updateLabels argument is not used at present. If you are using a
2850 derived grid table class you will need to override
2851 wxGridTableBase::DeleteRows(). See InsertRows() for further
2854 @return @true on success or @false if appending rows failed.
2856 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
2859 Decrements the grid's batch count.
2861 When the count is greater than zero repainting of the grid is
2862 suppressed. Each previous call to BeginBatch() must be matched by a
2863 later call to EndBatch(). Code that does a lot of grid modification can
2864 be enclosed between BeginBatch() and EndBatch() calls to avoid screen
2865 flicker. The final EndBatch() will cause the grid to be repainted.
2867 @see wxGridUpdateLocker
2872 Overridden wxWindow method.
2877 Causes immediate repainting of the grid.
2879 Use this instead of the usual wxWindow::Refresh().
2881 void ForceRefresh();
2884 Returns the number of times that BeginBatch() has been called without
2885 (yet) matching calls to EndBatch(). While the grid's batch count is
2886 greater than zero the display will not be updated.
2888 int GetBatchCount();
2891 Returns the total number of grid columns.
2893 This is the same as the number of columns in the underlying grid table.
2895 int GetNumberCols() const;
2898 Returns the total number of grid rows.
2900 This is the same as the number of rows in the underlying grid table.
2902 int GetNumberRows() const;
2905 Returns the attribute for the given cell creating one if necessary.
2907 If the cell already has an attribute, it is returned. Otherwise a new
2908 attribute is created, associated with the cell and returned. In any
2909 case the caller must call DecRef() on the returned pointer.
2911 This function may only be called if CanHaveAttributes() returns @true.
2913 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
2916 Returns a base pointer to the current table object.
2918 The returned pointer is still owned by the grid.
2920 wxGridTableBase
*GetTable() const;
2923 Inserts one or more new columns into a grid with the first new column
2924 at the specified position.
2926 Notice that inserting the columns in the grid requires grid table
2927 cooperation: when this method is called, grid object begins by
2928 requesting the underlying grid table to insert new columns. If this is
2929 successful the table notifies the grid and the grid updates the
2930 display. For a default grid (one where you have called CreateGrid())
2931 this process is automatic. If you are using a custom grid table
2932 (specified with SetTable()) then you must override
2933 wxGridTableBase::InsertCols() in your derived table class.
2936 The position which the first newly inserted column will have.
2938 The number of columns to insert.
2942 @true if the columns were successfully inserted, @false if an error
2943 occurred (most likely the table couldn't be updated).
2945 bool InsertCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
2948 Inserts one or more new rows into a grid with the first new row at the
2951 Notice that you must implement wxGridTableBase::InsertRows() if you use
2952 a grid with a custom table, please see InsertCols() for more
2956 The position which the first newly inserted row will have.
2958 The number of rows to insert.
2962 @true if the rows were successfully inserted, @false if an error
2963 occurred (most likely the table couldn't be updated).
2965 bool InsertRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
2968 Sets the cell attributes for all cells in the specified column.
2970 For more information about controlling grid cell attributes see the
2971 wxGridCellAttr cell attribute class and the @ref overview_grid.
2973 void SetColAttr(int col
, wxGridCellAttr
* attr
);
2976 Sets the extra margins used around the grid area.
2978 A grid may occupy more space than needed for its data display and
2979 this function allows to set how big this extra space is
2981 void SetMargins(int extraWidth
, int extraHeight
);
2984 Sets the cell attributes for all cells in the specified row.
2986 The grid takes ownership of the attribute pointer.
2988 See the wxGridCellAttr class for more information about controlling
2991 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
2997 Returns @true if this grid has support for cell attributes.
2999 The grid supports attributes if it has the associated table which, in
3000 turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
3003 bool CanHaveAttributes() const;
3006 Get the minimal width of the given column/row.
3008 The value returned by this function may be different than that returned
3009 by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
3010 called for this column.
3012 int GetColMinimalWidth(int col
) const;
3015 Returns the coordinate of the right border specified column.
3017 int GetColRight(int col
) const;
3020 Returns the coordinate of the left border specified column.
3022 int GetColLeft(int col
) const;
3025 Returns the minimal size for the given column.
3027 The value returned by this function may be different than that returned
3028 by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
3029 called for this row.
3031 int GetRowMinimalHeight(int col
) const;
3037 @class wxGridUpdateLocker
3039 This small class can be used to prevent wxGrid from redrawing during its
3040 lifetime by calling wxGrid::BeginBatch() in its constructor and
3041 wxGrid::EndBatch() in its destructor. It is typically used in a function
3042 performing several operations with a grid which would otherwise result in
3043 flicker. For example:
3048 m_grid = new wxGrid(this, ...);
3050 wxGridUpdateLocker noUpdates(m_grid);
3051 m_grid-AppendColumn();
3052 // ... many other operations with m_grid ...
3055 // destructor called, grid refreshed
3059 Using this class is easier and safer than calling wxGrid::BeginBatch() and
3060 wxGrid::EndBatch() because you don't risk missing the call the latter (due
3061 to an exception for example).
3066 class wxGridUpdateLocker
3070 Creates an object preventing the updates of the specified @a grid. The
3071 parameter could be @NULL in which case nothing is done. If @a grid is
3072 non-@NULL then the grid must exist for longer than this
3073 wxGridUpdateLocker object itself.
3075 The default constructor could be followed by a call to Create() to set
3076 the grid object later.
3078 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
3081 Destructor reenables updates for the grid this object is associated
3084 ~wxGridUpdateLocker();
3087 This method can be called if the object had been constructed using the
3088 default constructor. It must not be called more than once.
3090 void Create(wxGrid
* grid
);
3098 This event class contains information about various grid events.
3100 @beginEventTable{wxGridEvent}
3101 @event{EVT_GRID_CELL_CHANGE(func)}
3102 The user changed the data in a cell. Processes a
3103 @c wxEVT_GRID_CELL_CHANGE event type.
3104 @event{EVT_GRID_CELL_LEFT_CLICK(func)}
3105 The user clicked a cell with the left mouse button. Processes a
3106 @c wxEVT_GRID_CELL_LEFT_CLICK event type.
3107 @event{EVT_GRID_CELL_LEFT_DCLICK(func)}
3108 The user double-clicked a cell with the left mouse button. Processes a
3109 @c wxEVT_GRID_CELL_LEFT_DCLICK event type.
3110 @event{EVT_GRID_CELL_RIGHT_CLICK(func)}
3111 The user clicked a cell with the right mouse button. Processes a
3112 @c wxEVT_GRID_CELL_RIGHT_CLICK event type.
3113 @event{EVT_GRID_CELL_RIGHT_DCLICK(func)}
3114 The user double-clicked a cell with the right mouse button. Processes a
3115 @c wxEVT_GRID_CELL_RIGHT_DCLICK event type.
3116 @event{EVT_GRID_EDITOR_HIDDEN(func)}
3117 The editor for a cell was hidden. Processes a
3118 @c wxEVT_GRID_EDITOR_HIDDEN event type.
3119 @event{EVT_GRID_EDITOR_SHOWN(func)}
3120 The editor for a cell was shown. Processes a
3121 @c wxEVT_GRID_EDITOR_SHOWN event type.
3122 @event{EVT_GRID_LABEL_LEFT_CLICK(func)}
3123 The user clicked a label with the left mouse button. Processes a
3124 @c wxEVT_GRID_LABEL_LEFT_CLICK event type.
3125 @event{EVT_GRID_LABEL_LEFT_DCLICK(func)}
3126 The user double-clicked a label with the left mouse button. Processes a
3127 @c wxEVT_GRID_LABEL_LEFT_DCLICK event type.
3128 @event{EVT_GRID_LABEL_RIGHT_CLICK(func)}
3129 The user clicked a label with the right mouse button. Processes a
3130 @c wxEVT_GRID_LABEL_RIGHT_CLICK event type.
3131 @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)}
3132 The user double-clicked a label with the right mouse button. Processes
3133 a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type.
3134 @event{EVT_GRID_SELECT_CELL(func)}
3135 The user moved to, and selected a cell. Processes a
3136 @c wxEVT_GRID_SELECT_CELL event type.
3137 @event{EVT_GRID_CMD_CELL_CHANGE(id, func)}
3138 The user changed the data in a cell; variant taking a window
3139 identifier. Processes a @c wxEVT_GRID_CELL_CHANGE event type.
3140 @event{EVT_GRID_CMD_CELL_LEFT_CLICK(id, func)}
3141 The user clicked a cell with the left mouse button; variant taking a
3142 window identifier. Processes a @c wxEVT_GRID_CELL_LEFT_CLICK event
3144 @event{EVT_GRID_CMD_CELL_LEFT_DCLICK(id, func)}
3145 The user double-clicked a cell with the left mouse button; variant
3146 taking a window identifier. Processes a @c wxEVT_GRID_CELL_LEFT_DCLICK
3148 @event{EVT_GRID_CMD_CELL_RIGHT_CLICK(id, func)}
3149 The user clicked a cell with the right mouse button; variant taking a
3150 window identifier. Processes a @c wxEVT_GRID_CELL_RIGHT_CLICK event
3152 @event{EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, func)}
3153 The user double-clicked a cell with the right mouse button; variant
3154 taking a window identifier. Processes a @c wxEVT_GRID_CELL_RIGHT_DCLICK
3156 @event{EVT_GRID_CMD_EDITOR_HIDDEN(id, func)}
3157 The editor for a cell was hidden; variant taking a window identifier.
3158 Processes a @c wxEVT_GRID_EDITOR_HIDDEN event type.
3159 @event{EVT_GRID_CMD_EDITOR_SHOWN(id, func)}
3160 The editor for a cell was shown; variant taking a window identifier.
3161 Processes a @c wxEVT_GRID_EDITOR_SHOWN event type.
3162 @event{EVT_GRID_CMD_LABEL_LEFT_CLICK(id, func)}
3163 The user clicked a label with the left mouse button; variant taking a
3164 window identifier. Processes a @c wxEVT_GRID_LABEL_LEFT_CLICK event
3166 @event{EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, func)}
3167 The user double-clicked a label with the left mouse button; variant
3168 taking a window identifier. Processes a @c wxEVT_GRID_LABEL_LEFT_DCLICK
3170 @event{EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, func)}
3171 The user clicked a label with the right mouse button; variant taking a
3172 window identifier. Processes a @c wxEVT_GRID_LABEL_RIGHT_CLICK event
3174 @event{EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, func)}
3175 The user double-clicked a label with the right mouse button; variant
3176 taking a window identifier. Processes a
3177 @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type.
3178 @event{EVT_GRID_CMD_SELECT_CELL(id, func)}
3179 The user moved to, and selected a cell; variant taking a window
3180 identifier. Processes a @c wxEVT_GRID_SELECT_CELL event type.
3186 class wxGridEvent
: public wxNotifyEvent
3190 Default constructor.
3194 Constructor for initializing all event attributes.
3196 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
3197 int row
= -1, int col
= -1, int x
= -1, int y
= -1,
3198 bool sel
= true, bool control
= false, bool shift
= false,
3199 bool alt
= false, bool meta
= false);
3202 Returns @true if the Alt key was down at the time of the event.
3204 bool AltDown() const;
3207 Returns @true if the Control key was down at the time of the event.
3209 bool ControlDown() const;
3212 Column at which the event occurred.
3214 virtual int GetCol();
3217 Position in pixels at which the event occurred.
3219 wxPoint
GetPosition();
3222 Row at which the event occurred.
3224 virtual int GetRow();
3227 Returns @true if the Meta key was down at the time of the event.
3229 bool MetaDown() const;
3232 Returns @true if the user is selecting grid cells, or @false if
3238 Returns @true if the Shift key was down at the time of the event.
3240 bool ShiftDown() const;
3246 @class wxGridSizeEvent
3248 This event class contains information about a row/column resize event.
3250 @beginEventTable{wxGridSizeEvent}
3251 @event{EVT_GRID_COL_SIZE(func)}
3252 The user resized a column by dragging it. Processes a
3253 @c wxEVT_GRID_COL_SIZE event type.
3254 @event{EVT_GRID_ROW_SIZE(func)}
3255 The user resized a row by dragging it. Processes a
3256 @c wxEVT_GRID_ROW_SIZE event type.
3257 @event{EVT_GRID_CMD_COL_SIZE(id, func)}
3258 The user resized a column by dragging it; variant taking a window
3259 identifier. Processes a @c wxEVT_GRID_COL_SIZE event type.
3260 @event{EVT_GRID_CMD_ROW_SIZE(id, func)}
3261 The user resized a row by dragging it; variant taking a window
3262 identifier. Processes a @c wxEVT_GRID_ROW_SIZE event type.
3268 class wxGridSizeEvent
: public wxNotifyEvent
3272 Default constructor.
3276 Constructor for initializing all event attributes.
3278 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
3279 int rowOrCol
= -1, int x
= -1, int y
= -1,
3280 bool control
= false, bool shift
= false,
3281 bool alt
= false, bool meta
= false);
3284 Returns @true if the Alt key was down at the time of the event.
3286 bool AltDown() const;
3289 Returns @true if the Control key was down at the time of the event.
3291 bool ControlDown() const;
3294 Position in pixels at which the event occurred.
3296 wxPoint
GetPosition();
3299 Row or column at that was resized.
3304 Returns @true if the Meta key was down at the time of the event.
3306 bool MetaDown() const;
3309 Returns @true if the Shift key was down at the time of the event.
3311 bool ShiftDown() const;
3317 @class wxGridRangeSelectEvent
3319 @beginEventTable{wxGridRangeSelectEvent}
3320 @event{EVT_GRID_RANGE_SELECT(func)}
3321 The user selected a group of contiguous cells. Processes a
3322 @c wxEVT_GRID_RANGE_SELECT event type.
3323 @event{EVT_GRID_CMD_RANGE_SELECT(id, func)}
3324 The user selected a group of contiguous cells; variant taking a window
3325 identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type.
3331 class wxGridRangeSelectEvent
: public wxNotifyEvent
3335 Default constructor.
3337 wxGridRangeSelectEvent();
3339 Constructor for initializing all event attributes.
3341 wxGridRangeSelectEvent(int id
, wxEventType type
,
3343 const wxGridCellCoords
& topLeft
,
3344 const wxGridCellCoords
& bottomRight
,
3345 bool sel
= true, bool control
= false,
3346 bool shift
= false, bool alt
= false,
3350 Returns @true if the Alt key was down at the time of the event.
3352 bool AltDown() const;
3355 Returns @true if the Control key was down at the time of the event.
3357 bool ControlDown() const;
3360 Top left corner of the rectangular area that was (de)selected.
3362 wxGridCellCoords
GetBottomRightCoords();
3365 Bottom row of the rectangular area that was (de)selected.
3370 Left column of the rectangular area that was (de)selected.
3375 Right column of the rectangular area that was (de)selected.
3380 Top left corner of the rectangular area that was (de)selected.
3382 wxGridCellCoords
GetTopLeftCoords();
3385 Top row of the rectangular area that was (de)selected.
3390 Returns @true if the Meta key was down at the time of the event.
3392 bool MetaDown() const;
3395 Returns @true if the area was selected, @false otherwise.
3400 Returns @true if the Shift key was down at the time of the event.
3402 bool ShiftDown() const;
3408 @class wxGridEditorCreatedEvent
3410 @beginEventTable{wxGridEditorCreatedEvent}
3411 @event{EVT_GRID_EDITOR_CREATED(func)}
3412 The editor for a cell was created. Processes a
3413 @c wxEVT_GRID_EDITOR_CREATED event type.
3414 @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)}
3415 The editor for a cell was created; variant taking a window identifier.
3416 Processes a @c wxEVT_GRID_EDITOR_CREATED event type.
3422 class wxGridEditorCreatedEvent
: public wxCommandEvent
3426 Default constructor.
3428 wxGridEditorCreatedEvent();
3430 Constructor for initializing all event attributes.
3432 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
3433 int row
, int col
, wxControl
* ctrl
);
3436 Returns the column at which the event occurred.
3441 Returns the edit control.
3443 wxControl
* GetControl();
3446 Returns the row at which the event occurred.
3451 Sets the column at which the event occurred.
3453 void SetCol(int col
);
3456 Sets the edit control.
3458 void SetControl(wxControl
* ctrl
);
3461 Sets the row at which the event occurred.
3463 void SetRow(int row
);