1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGrid and related classes
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxGridCellFloatRenderer
12 This class may be used to format floating point data in a cell.
17 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellNumberRenderer,
18 wxGridCellStringRenderer
20 class wxGridCellFloatRenderer
: public wxGridCellStringRenderer
25 Minimum number of characters to be shown.
27 Number of digits after the decimal dot.
29 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
32 Returns the precision.
34 int GetPrecision() const;
42 Parameters string format is "width[,precision]".
44 virtual void SetParameters(const wxString
& params
);
49 void SetPrecision(int precision
);
54 void SetWidth(int width
);
60 @class wxGridTableBase
62 The almost abstract base class for grid tables.
64 A grid table is responsible for storing the grid data and, indirectly, grid
65 cell attributes. The data can be stored in the way most convenient for the
66 application but has to be provided in string form to wxGrid. It is also
67 possible to provide cells values in other formats if appropriate, e.g. as
70 This base class is not quite abstract as it implements a trivial strategy
71 for storing the attributes by forwarding it to wxGridCellAttrProvider and
72 also provides stubs for some other functions. However it does have a number
73 of pure virtual methods which must be implemented in the derived classes.
75 @see wxGridStringTable
80 class wxGridTableBase
: public wxObject
89 Destructor frees the attribute provider if it was created.
91 virtual ~wxGridTableBase();
94 Must be overridden to return the number of rows in the table.
96 For backwards compatibility reasons, this method is not const.
97 Use GetRowsCount() instead of it in const methods of derived table
100 virtual int GetNumberRows() = 0;
103 Must be overridden to return the number of columns in the table.
105 For backwards compatibility reasons, this method is not const.
106 Use GetColsCount() instead of it in const methods of derived table
109 virtual int GetNumberCols() = 0;
112 Return the number of rows in the table.
114 This method is not virtual and is only provided as a convenience for
115 the derived classes which can't call GetNumberRows() without a
116 @c const_cast from their const methods.
118 int GetRowsCount() const;
121 Return the number of columns in the table.
123 This method is not virtual and is only provided as a convenience for
124 the derived classes which can't call GetNumberCols() without a
125 @c const_cast from their const methods.
127 int GetColsCount() const;
131 @name Table Cell Accessors
136 Must be overridden to implement testing for empty cells.
138 virtual bool IsEmptyCell(int row
, int col
) = 0;
141 Same as IsEmptyCell() but taking wxGridCellCoords.
143 Notice that this method is not virtual, only IsEmptyCell() should be
146 bool IsEmpty(const wxGridCellCoords
& coords
);
149 Must be overridden to implement accessing the table values as text.
151 virtual wxString
GetValue(int row
, int col
) = 0;
154 Must be overridden to implement setting the table values as text.
156 virtual void SetValue(int row
, int col
, const wxString
& value
) = 0;
159 Returns the type of the value in the given cell.
161 By default all cells are strings and this method returns
162 @c wxGRID_VALUE_STRING.
164 virtual wxString
GetTypeName(int row
, int col
);
167 Returns true if the value of the given cell can be accessed as if it
168 were of the specified type.
170 By default the cells can only be accessed as strings. Note that a cell
171 could be accessible in different ways, e.g. a numeric cell may return
172 @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
173 indicating that the value can be coerced to a string form.
175 virtual bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
178 Returns true if the value of the given cell can be set as if it were of
183 virtual bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
186 Returns the value of the given cell as a long.
188 This should only be called if CanGetValueAs() returns @true when called
189 with @c wxGRID_VALUE_NUMBER argument. Default implementation always
192 virtual long GetValueAsLong(int row
, int col
);
195 Returns the value of the given cell as a double.
197 This should only be called if CanGetValueAs() returns @true when called
198 with @c wxGRID_VALUE_FLOAT argument. Default implementation always
201 virtual double GetValueAsDouble(int row
, int col
);
204 Returns the value of the given cell as a boolean.
206 This should only be called if CanGetValueAs() returns @true when called
207 with @c wxGRID_VALUE_BOOL argument. Default implementation always
210 virtual bool GetValueAsBool(int row
, int col
);
213 Returns the value of the given cell as a user-defined type.
215 This should only be called if CanGetValueAs() returns @true when called
216 with @a typeName. Default implementation always return @NULL.
218 virtual void *GetValueAsCustom(int row
, int col
, const wxString
& typeName
);
221 Sets the value of the given cell as a long.
223 This should only be called if CanSetValueAs() returns @true when called
224 with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
227 virtual void SetValueAsLong(int row
, int col
, long value
);
230 Sets the value of the given cell as a double.
232 This should only be called if CanSetValueAs() returns @true when called
233 with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
236 virtual void SetValueAsDouble(int row
, int col
, double value
);
239 Sets the value of the given cell as a boolean.
241 This should only be called if CanSetValueAs() returns @true when called
242 with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
245 virtual void SetValueAsBool( int row
, int col
, bool value
);
248 Sets the value of the given cell as a user-defined type.
250 This should only be called if CanSetValueAs() returns @true when called
251 with @a typeName. Default implementation doesn't do anything.
253 virtual void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
260 Called by the grid when the table is associated with it.
262 The default implementation stores the pointer and returns it from its
263 GetView() and so only makes sense if the table cannot be associated
264 with more than one grid at a time.
266 virtual void SetView(wxGrid
*grid
);
269 Returns the last grid passed to SetView().
271 virtual wxGrid
*GetView() const;
275 @name Table Structure Modifiers
277 Notice that none of these functions are pure virtual as they don't have
278 to be implemented if the table structure is never modified after
279 creation, i.e. neither rows nor columns are never added or deleted but
280 that you do need to implement them if they are called, i.e. if your
281 code either calls them directly or uses the matching wxGrid methods, as
282 by default they simply do nothing which is definitely inappropriate.
287 Clear the table contents.
289 This method is used by wxGrid::ClearGrid().
291 virtual void Clear();
294 Insert additional rows into the table.
297 The position of the first new row.
299 The number of rows to insert.
301 virtual bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
304 Append additional rows at the end of the table.
306 This method is provided in addition to InsertRows() as some data models
307 may only support appending rows to them but not inserting them at
308 arbitrary locations. In such case you may implement this method only
309 and leave InsertRows() unimplemented.
312 The number of rows to add.
314 virtual bool AppendRows(size_t numRows
= 1);
317 Delete rows from the table.
320 The first row to delete.
322 The number of rows to delete.
324 virtual bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
327 Exactly the same as InsertRows() but for columns.
329 virtual bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
332 Exactly the same as AppendRows() but for columns.
334 virtual bool AppendCols(size_t numCols
= 1);
337 Exactly the same as DeleteRows() but for columns.
339 virtual bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
344 @name Table Row and Column Labels
346 By default the numbers are used for labeling rows and Latin letters for
347 labeling columns. If the table has more than 26 columns, the pairs of
348 letters are used starting from the 27-th one and so on, i.e. the
349 sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
355 Return the label of the specified row.
357 virtual wxString
GetRowLabelValue(int row
);
360 Return the label of the specified column.
362 virtual wxString
GetColLabelValue(int col
);
365 Set the given label for the specified row.
367 The default version does nothing, i.e. the label is not stored. You
368 must override this method in your derived class if you wish
369 wxGrid::SetRowLabelValue() to work.
371 virtual void SetRowLabelValue(int row
, const wxString
& label
);
374 Exactly the same as SetRowLabelValue() but for columns.
376 virtual void SetColLabelValue(int col
, const wxString
& label
);
382 @name Attributes Management
384 By default the attributes management is delegated to
385 wxGridCellAttrProvider class. You may override the methods in this
386 section to handle the attributes directly if, for example, they can be
387 computed from the cell values.
392 Associate this attributes provider with the table.
394 The table takes ownership of @a attrProvider pointer and will delete it
395 when it doesn't need it any more. The pointer can be @NULL, however
396 this won't disable attributes management in the table but will just
397 result in a default attributes being recreated the next time any of the
398 other functions in this section is called. To completely disable the
399 attributes support, should this be needed, you need to override
400 CanHaveAttributes() to return @false.
402 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
405 Returns the attribute provider currently being used.
407 This function may return @NULL if the attribute provider hasn't been
408 neither associated with this table by SetAttrProvider() nor created on
409 demand by any other methods.
411 wxGridCellAttrProvider
*GetAttrProvider() const;
414 Return the attribute for the given cell.
416 By default this function is simply forwarded to
417 wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
418 attributes directly in the table.
420 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
421 wxGridCellAttr::wxAttrKind kind
);
424 Set attribute of the specified cell.
426 By default this function is simply forwarded to
427 wxGridCellAttrProvider::SetAttr().
429 The table takes ownership of @a attr, i.e. will call DecRef() on it.
431 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
434 Set attribute of the specified row.
436 By default this function is simply forwarded to
437 wxGridCellAttrProvider::SetRowAttr().
439 The table takes ownership of @a attr, i.e. will call DecRef() on it.
441 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
444 Set attribute of the specified column.
446 By default this function is simply forwarded to
447 wxGridCellAttrProvider::SetColAttr().
449 The table takes ownership of @a attr, i.e. will call DecRef() on it.
451 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
456 Returns true if this table supports attributes or false otherwise.
458 By default, the table automatically creates a wxGridCellAttrProvider
459 when this function is called if it had no attribute provider before and
462 virtual bool CanHaveAttributes();
468 @class wxGridCellEditor
470 This class is responsible for providing and manipulating the in-place edit
471 controls for the grid. Instances of wxGridCellEditor (actually, instances
472 of derived classes since it is an abstract class) can be associated with
473 the cell attributes for individual cells, rows, columns, or even for the
479 @see wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellFloatEditor,
480 wxGridCellNumberEditor, wxGridCellTextEditor
482 class wxGridCellEditor
491 Fetch the value from the table and prepare the edit control to begin
492 editing. Sets the focus to the edit control.
494 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
497 Create a new object which is the copy of this one.
499 virtual wxGridCellEditor
* Clone() const = 0;
502 Creates the actual edit control.
504 virtual void Create(wxWindow
* parent
, wxWindowID id
,
505 wxEvtHandler
* evtHandler
) = 0;
510 virtual void Destroy();
513 Complete the editing of the current cell. If necessary, the control may
516 @return @true if the value has changed.
518 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
) = 0;
521 Some types of controls on some platforms may need some help with the
524 virtual void HandleReturn(wxKeyEvent
& event
);
527 Returns @true if the edit control has been created.
532 Draws the part of the cell not occupied by the control: the base class
533 version just fills it with background colour from the attribute.
535 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
* attr
);
538 Reset the value in the control back to its starting value.
540 virtual void Reset() = 0;
543 Size and position the edit control.
545 virtual void SetSize(const wxRect
& rect
);
548 Show or hide the edit control, use the specified attributes to set
549 colours/fonts for it.
551 virtual void Show(bool show
, wxGridCellAttr
* attr
= NULL
);
554 If the editor is enabled by clicking on the cell, this method will be
557 virtual void StartingClick();
560 If the editor is enabled by pressing keys on the grid, this will be
561 called to let the editor do something about that first key if desired.
563 virtual void StartingKey(wxKeyEvent
& event
);
568 The destructor is private because only DecRef() can delete us.
570 virtual ~wxGridCellEditor();
576 @class wxGridCellTextEditor
578 Grid cell editor for string/text data.
583 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
584 wxGridCellFloatEditor, wxGridCellNumberEditor
586 class wxGridCellTextEditor
: public wxGridCellEditor
592 wxGridCellTextEditor();
595 The parameters string format is "n" where n is a number representing
598 virtual void SetParameters(const wxString
& params
);
604 @class wxGridCellStringRenderer
606 This class may be used to format string data in a cell; it is the default
612 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer,
613 wxGridCellNumberRenderer
615 class wxGridCellStringRenderer
: public wxGridCellRenderer
621 wxGridCellStringRenderer();
627 @class wxGridCellChoiceEditor
629 The editor for string data allowing to choose from a list of strings.
634 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellFloatEditor,
635 wxGridCellNumberEditor, wxGridCellTextEditor
637 class wxGridCellChoiceEditor
: public wxGridCellEditor
642 Number of strings from which the user can choose.
644 An array of strings from which the user can choose.
646 If allowOthers is @true, the user can type a string not in choices
649 wxGridCellChoiceEditor(size_t count
= 0,
650 const wxString choices
[] = NULL
,
651 bool allowOthers
= false);
654 An array of strings from which the user can choose.
656 If allowOthers is @true, the user can type a string not in choices
659 wxGridCellChoiceEditor(const wxArrayString
& choices
,
660 bool allowOthers
= false);
663 Parameters string format is "item1[,item2[...,itemN]]"
665 virtual void SetParameters(const wxString
& params
);
671 @class wxGridEditorCreatedEvent
673 @beginEventTable{wxGridEditorCreatedEvent}
674 @event{EVT_GRID_EDITOR_CREATED(func)}
675 The editor for a cell was created. Processes a
676 @c wxEVT_GRID_EDITOR_CREATED event type.
677 @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)}
678 The editor for a cell was created; variant taking a window identifier.
679 Processes a @c wxEVT_GRID_EDITOR_CREATED event type.
685 class wxGridEditorCreatedEvent
: public wxCommandEvent
691 wxGridEditorCreatedEvent();
693 Constructor for initializing all event attributes.
695 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
696 int row
, int col
, wxControl
* ctrl
);
699 Returns the column at which the event occurred.
704 Returns the edit control.
706 wxControl
* GetControl();
709 Returns the row at which the event occurred.
714 Sets the column at which the event occurred.
716 void SetCol(int col
);
719 Sets the edit control.
721 void SetControl(wxControl
* ctrl
);
724 Sets the row at which the event occurred.
726 void SetRow(int row
);
732 @class wxGridRangeSelectEvent
734 @beginEventTable{wxGridRangeSelectEvent}
735 @event{EVT_GRID_RANGE_SELECT(func)}
736 The user selected a group of contiguous cells. Processes a
737 @c wxEVT_GRID_RANGE_SELECT event type.
738 @event{EVT_GRID_CMD_RANGE_SELECT(id, func)}
739 The user selected a group of contiguous cells; variant taking a window
740 identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type.
746 class wxGridRangeSelectEvent
: public wxNotifyEvent
752 wxGridRangeSelectEvent();
754 Constructor for initializing all event attributes.
756 wxGridRangeSelectEvent(int id
, wxEventType type
,
758 const wxGridCellCoords
& topLeft
,
759 const wxGridCellCoords
& bottomRight
,
760 bool sel
= true, bool control
= false,
761 bool shift
= false, bool alt
= false,
765 Returns @true if the Alt key was down at the time of the event.
767 bool AltDown() const;
770 Returns @true if the Control key was down at the time of the event.
772 bool ControlDown() const;
775 Top left corner of the rectangular area that was (de)selected.
777 wxGridCellCoords
GetBottomRightCoords();
780 Bottom row of the rectangular area that was (de)selected.
785 Left column of the rectangular area that was (de)selected.
790 Right column of the rectangular area that was (de)selected.
795 Top left corner of the rectangular area that was (de)selected.
797 wxGridCellCoords
GetTopLeftCoords();
800 Top row of the rectangular area that was (de)selected.
805 Returns @true if the Meta key was down at the time of the event.
807 bool MetaDown() const;
810 Returns @true if the area was selected, @false otherwise.
815 Returns @true if the Shift key was down at the time of the event.
817 bool ShiftDown() const;
823 @class wxGridCellRenderer
825 This class is responsible for actually drawing the cell in the grid. You
826 may pass it to the wxGridCellAttr (below) to change the format of one given
827 cell or to wxGrid::SetDefaultRenderer() to change the view of all cells.
828 This is an abstract class, and you will normally use one of the predefined
829 derived classes or derive your own class from it.
834 @see wxGridCellBoolRenderer, wxGridCellFloatRenderer,
835 wxGridCellNumberRenderer, wxGridCellStringRenderer
837 class wxGridCellRenderer
841 This function must be implemented in derived classes to return a copy
844 virtual wxGridCellRenderer
* Clone() const = 0;
847 Draw the given cell on the provided DC inside the given rectangle using
848 the style specified by the attribute and the default or selected state
849 corresponding to the isSelected value.
851 This pure virtual function has a default implementation which will
852 prepare the DC using the given attribute: it will draw the rectangle
853 with the background colour from attr and set the text colour and font.
855 virtual void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
856 const wxRect
& rect
, int row
, int col
,
857 bool isSelected
) = 0;
860 Get the preferred size of the cell for its contents.
862 virtual wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
863 int row
, int col
) = 0;
869 @class wxGridCellNumberEditor
871 Grid cell editor for numeric integer data.
876 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
877 wxGridCellFloatEditor, wxGridCellTextEditor
879 class wxGridCellNumberEditor
: public wxGridCellTextEditor
883 Allows you to specify the range for acceptable data. Values equal to
884 -1 for both @a min and @a max indicate that no range checking should be
887 wxGridCellNumberEditor(int min
= -1, int max
= -1);
891 Parameters string format is "min,max".
893 virtual void SetParameters(const wxString
& params
);
898 If the return value is @true, the editor uses a wxSpinCtrl to get user
899 input, otherwise it uses a wxTextCtrl.
901 bool HasRange() const;
904 String representation of the value.
906 wxString
GetString() const;
912 @class wxGridSizeEvent
914 This event class contains information about a row/column resize event.
916 @beginEventTable{wxGridSizeEvent}
917 @event{EVT_GRID_COL_SIZE(func)}
918 The user resized a column by dragging it. Processes a
919 @c wxEVT_GRID_COL_SIZE event type.
920 @event{EVT_GRID_ROW_SIZE(func)}
921 The user resized a row by dragging it. Processes a
922 @c wxEVT_GRID_ROW_SIZE event type.
923 @event{EVT_GRID_CMD_COL_SIZE(id, func)}
924 The user resized a column by dragging it; variant taking a window
925 identifier. Processes a @c wxEVT_GRID_COL_SIZE event type.
926 @event{EVT_GRID_CMD_ROW_SIZE(id, func)}
927 The user resized a row by dragging it; variant taking a window
928 identifier. Processes a @c wxEVT_GRID_ROW_SIZE event type.
934 class wxGridSizeEvent
: public wxNotifyEvent
942 Constructor for initializing all event attributes.
944 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
945 int rowOrCol
= -1, int x
= -1, int y
= -1,
946 bool control
= false, bool shift
= false,
947 bool alt
= false, bool meta
= false);
950 Returns @true if the Alt key was down at the time of the event.
952 bool AltDown() const;
955 Returns @true if the Control key was down at the time of the event.
957 bool ControlDown() const;
960 Position in pixels at which the event occurred.
962 wxPoint
GetPosition();
965 Row or column at that was resized.
970 Returns @true if the Meta key was down at the time of the event.
972 bool MetaDown() const;
975 Returns @true if the Shift key was down at the time of the event.
977 bool ShiftDown() const;
983 @class wxGridCellNumberRenderer
985 This class may be used to format integer data in a cell.
990 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer,
991 wxGridCellStringRenderer
993 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
999 wxGridCellNumberRenderer();
1005 @class wxGridCellAttr
1007 This class can be used to alter the cells' appearance in
1008 the grid by changing their colour/font/... from default. An object of this
1009 class may be returned by wxGridTableBase::GetAttr.
1014 class wxGridCellAttr
1019 Constructor specifying some of the often used attributes.
1022 wxGridCellAttr(const wxColour
& colText
,
1023 const wxColour
& colBack
,
1025 int hAlign
, int vAlign
);
1029 Creates a new copy of this object.
1031 wxGridCellAttr
* Clone() const;
1039 See SetAlignment() for the returned values.
1041 void GetAlignment(int* hAlign
, int* vAlign
) const;
1046 const wxColour
& GetBackgroundColour() const;
1051 wxGridCellEditor
* GetEditor(const wxGrid
* grid
, int row
, int col
) const;
1056 const wxFont
& GetFont() const;
1061 wxGridCellRenderer
* GetRenderer(const wxGrid
* grid
, int row
, int col
) const;
1066 const wxColour
& GetTextColour() const;
1071 bool HasAlignment() const;
1076 bool HasBackgroundColour() const;
1081 bool HasEditor() const;
1086 bool HasFont() const;
1091 bool HasRenderer() const;
1096 bool HasTextColour() const;
1099 This class is ref counted: it is created with ref count of 1, so
1100 calling DecRef() once will delete it. Calling IncRef() allows to lock
1101 it until the matching DecRef() is called
1108 bool IsReadOnly() const;
1111 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
1112 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one
1113 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1115 void SetAlignment(int hAlign
, int vAlign
);
1118 Sets the background colour.
1120 void SetBackgroundColour(const wxColour
& colBack
);
1125 void SetDefAttr(wxGridCellAttr
* defAttr
);
1130 void SetEditor(wxGridCellEditor
* editor
);
1135 void SetFont(const wxFont
& font
);
1140 void SetReadOnly(bool isReadOnly
= true);
1143 takes ownership of the pointer
1145 void SetRenderer(wxGridCellRenderer
* renderer
);
1148 Sets the text colour.
1150 void SetTextColour(const wxColour
& colText
);
1156 @class wxGridCellBoolRenderer
1158 This class may be used to format boolean data in a cell.
1164 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
1165 wxGridCellNumberRenderer
1167 class wxGridCellBoolRenderer
: public wxGridCellRenderer
1173 wxGridCellBoolRenderer();
1181 This event class contains information about various grid events.
1186 class wxGridEvent
: public wxNotifyEvent
1194 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
1195 int row
= -1, int col
= -1,
1196 int x
= -1, int y
= -1,
1198 bool control
= false,
1205 Returns @true if the Alt key was down at the time of the event.
1207 bool AltDown() const;
1210 Returns @true if the Control key was down at the time of the event.
1212 bool ControlDown() const;
1215 Column at which the event occurred.
1217 virtual int GetCol();
1220 Position in pixels at which the event occurred.
1222 wxPoint
GetPosition();
1225 Row at which the event occurred.
1227 virtual int GetRow();
1230 Returns @true if the Meta key was down at the time of the event.
1232 bool MetaDown() const;
1235 Returns @true if the user is selecting grid cells, @false -- if
1241 Returns @true if the Shift key was down at the time of the event.
1243 bool ShiftDown() const;
1249 @class wxGridCellFloatEditor
1251 The editor for floating point numbers data.
1256 @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
1257 wxGridCellTextEditor, wxGridCellChoiceEditor
1259 class wxGridCellFloatEditor
: public wxGridCellTextEditor
1264 Minimum number of characters to be shown.
1266 Number of digits after the decimal dot.
1268 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
1271 Parameters string format is "width,precision"
1273 virtual void SetParameters(const wxString
& params
);
1281 wxGrid and its related classes are used for displaying and editing tabular
1283 They provide a rich set of features for display, editing, and interacting
1284 with a variety of data sources. For simple applications, and to help you
1285 get started, wxGrid is the only class you need to refer to directly. It
1286 will set up default instances of the other classes and manage them for you.
1287 For more complex applications you can derive your own classes for custom
1288 grid views, grid data tables, cell editors and renderers. The @ref
1289 overview_grid "wxGrid overview" has examples of simple and more complex applications,
1290 explains the relationship between the various grid classes and has a
1291 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1293 wxGrid has been greatly expanded and redesigned for wxWidgets 2.2 onwards.
1294 The new grid classes are reasonably backward-compatible but there are some
1295 exceptions. There are also easier ways of doing many things compared to the
1296 previous implementation.
1298 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1299 class. One or more wxGrid classes may act as a view for one table class.
1300 The default table class is called wxGridStringTable and holds an array of
1301 strings. An instance of such a class is created by wxGrid::CreateGrid.
1303 wxGridCellRenderer is the abstract base class for rendereing contents in a
1304 cell. The following renderers are predefined:
1305 - wxGridCellStringRenderer,
1306 - wxGridCellBoolRenderer,
1307 - wxGridCellFloatRenderer,
1308 - wxGridCellNumberRenderer.
1309 The look of a cell can be further defined using wxGridCellAttr. An object
1310 of this type may be returned by wxGridTableBase::GetAttr.
1312 wxGridCellEditor is the abstract base class for editing the value of a
1313 cell. The following editors are predefined:
1314 - wxGridCellTextEditor
1315 - wxGridCellBoolEditor
1316 - wxGridCellChoiceEditor
1317 - wxGridCellNumberEditor.
1322 @see @ref overview_grid "wxGrid overview"
1324 class wxGrid
: public wxScrolledWindow
1328 Different selection modes supported by the grid.
1330 enum wxGridSelectionModes
1333 The default selection mode allowing selection of the individual
1334 cells as well as of the entire rows and columns.
1339 The selection mode allowing the selection of the entire rows only.
1341 The user won't be able to select any cells or columns in this mode.
1346 The selection mode allowing the selection of the entire columns only.
1348 The user won't be able to select any cells or rows in this mode.
1354 Default constructor.
1356 You must call Create() to really create the grid window and also call
1357 CreateGrid() or SetTable() to initialize the grid contents.
1362 Constructor creating the grid window.
1364 You must call either CreateGrid() or SetTable() to initialize the grid
1365 contents before using it.
1367 wxGrid(wxWindow
* parent
,
1369 const wxPoint
& pos
= wxDefaultPosition
,
1370 const wxSize
& size
= wxDefaultSize
,
1371 long style
= wxWANTS_CHARS
,
1372 const wxString
& name
= wxGridNameStr
);
1375 Creates the grid window for an object initialized using the default
1378 You must call either CreateGrid() or SetTable() to initialize the grid
1379 contents before using it.
1381 bool Create(wxWindow
* parent
,
1383 const wxPoint
& pos
= wxDefaultPosition
,
1384 const wxSize
& size
= wxDefaultSize
,
1385 long style
= wxWANTS_CHARS
,
1386 const wxString
& name
= wxGridNameStr
);
1391 This will also destroy the associated grid table unless you passed a
1392 table object to the grid and specified that the grid should not take
1393 ownership of the table (see wxGrid::SetTable).
1398 Appends one or more new columns to the right of the grid.
1400 The @a updateLabels argument is not used at present. If you are using a
1401 derived grid table class you will need to override
1402 wxGridTableBase::AppendCols. See InsertCols() for further information.
1404 @return @true on success or @false if appending columns failed.
1406 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
1409 Appends one or more new rows to the bottom of the grid.
1411 The @a updateLabels argument is not used at present. If you are using a
1412 derived grid table class you will need to override
1413 wxGridTableBase::AppendRows. See InsertRows() for further information.
1415 @return @true on success or @false if appending rows failed.
1417 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
1420 Return @true if the horizontal grid lines stop at the last column
1421 boundary or @false if they continue to the end of the window.
1423 The default is to clip grid lines.
1425 @see ClipHorzGridLines(), AreVertGridLinesClipped()
1427 bool AreHorzGridLinesClipped() const;
1430 Return @true if the vertical grid lines stop at the last row
1431 boundary or @false if they continue to the end of the window.
1433 The default is to clip grid lines.
1435 @see ClipVertGridLines(), AreHorzGridLinesClipped()
1437 bool AreVertGridLinesClipped() const;
1440 Automatically sets the height and width of all rows and columns to fit their
1446 Automatically adjusts width of the column to fit its label.
1448 void AutoSizeColLabelSize(int col
);
1451 Automatically sizes the column to fit its contents. If setAsMin is @true the
1452 calculated width will
1453 also be set as the minimal width for the column.
1455 void AutoSizeColumn(int col
, bool setAsMin
= true);
1458 Automatically sizes all columns to fit their contents. If setAsMin is @true the
1459 calculated widths will
1460 also be set as the minimal widths for the columns.
1462 void AutoSizeColumns(bool setAsMin
= true);
1465 Automatically sizes the row to fit its contents. If setAsMin is @true the
1466 calculated height will
1467 also be set as the minimal height for the row.
1469 void AutoSizeRow(int row
, bool setAsMin
= true);
1472 Automatically adjusts height of the row to fit its label.
1474 void AutoSizeRowLabelSize(int col
);
1477 Automatically sizes all rows to fit their contents. If setAsMin is @true the
1478 calculated heights will
1479 also be set as the minimal heights for the rows.
1481 void AutoSizeRows(bool setAsMin
= true);
1484 Increments the grid's batch count.
1486 When the count is greater than zero repainting of the grid is
1487 suppressed. Each call to BeginBatch must be matched by a later call to
1488 EndBatch(). Code that does a lot of grid modification can be enclosed
1489 between BeginBatch and EndBatch calls to avoid screen flicker. The
1490 final EndBatch will cause the grid to be repainted.
1492 Notice that you should use wxGridUpdateLocker which ensures that there
1493 is always a matching EndBatch() call for this BeginBatch() if possible
1494 instead of calling this method directly.
1499 Convert grid cell coordinates to grid window pixel coordinates.
1501 This function returns the rectangle that encloses the block of cells
1502 limited by @a topLeft and @a bottomRight cell in device coords and
1503 clipped to the client size of the grid window.
1507 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
1508 const wxGridCellCoords
& bottomRight
) const;
1511 Returns @true if columns can be moved by dragging with the mouse.
1513 Columns can be moved by dragging on their labels.
1515 bool CanDragColMove() const;
1518 Returns @true if columns can be resized by dragging with the mouse.
1520 Columns can be resized by dragging the edges of their labels. If grid
1521 line dragging is enabled they can also be resized by dragging the right
1522 edge of the column in the grid cell area (see
1523 wxGrid::EnableDragGridSize).
1525 bool CanDragColSize() const;
1528 Return @true if the dragging of grid lines to resize rows and columns
1529 is enabled or @false otherwise.
1531 bool CanDragGridSize() const;
1534 Returns @true if rows can be resized by dragging with the mouse.
1536 Rows can be resized by dragging the edges of their labels. If grid line
1537 dragging is enabled they can also be resized by dragging the lower edge
1538 of the row in the grid cell area (see wxGrid::EnableDragGridSize).
1540 bool CanDragRowSize() const;
1543 Returns @true if the in-place edit control for the current grid cell
1544 can be used and @false otherwise.
1546 This function always returns @false for the read-only cells.
1548 bool CanEnableCellControl() const;
1552 Return the rectangle corresponding to the grid cell's size and position
1553 in logical coordinates.
1555 @see BlockToDeviceRect()
1557 wxRect
CellToRect(int row
, int col
) const;
1558 const wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
1563 Clears all data in the underlying grid table and repaints the grid.
1565 The table is not deleted by this function. If you are using a derived
1566 table class then you need to override wxGridTableBase::Clear() for this
1567 function to have any effect.
1572 Deselects all cells that are currently selected.
1574 void ClearSelection();
1577 Change whether the horizontal grid lines are clipped by the end of the
1580 By default the grid lines are not drawn beyond the end of the last
1581 column but after calling this function with @a clip set to @false they
1582 will be drawn across the entire grid window.
1584 @see AreHorzGridLinesClipped(), ClipVertGridLines()
1586 void ClipHorzGridLines(bool clip
);
1589 Change whether the vertical grid lines are clipped by the end of the
1592 By default the grid lines are not drawn beyond the end of the last
1593 row but after calling this function with @a clip set to @false they
1594 will be drawn across the entire grid window.
1596 @see AreVertzGridLinesClipped(), ClipHorzGridLines()
1598 void ClipVertzGridLines(bool clip
);
1601 Creates a grid with the specified initial number of rows and columns.
1603 Call this directly after the grid constructor. When you use this
1604 function wxGrid will create and manage a simple table of string values
1605 for you. All of the grid data will be stored in memory.
1606 For applications with more complex data types or relationships, or for
1607 dealing with very large datasets, you should derive your own grid table
1608 class and pass a table object to the grid with SetTable().
1610 bool CreateGrid(int numRows
, int numCols
,
1611 wxGridSelectionModes selmode
= wxGridSelectCells
);
1614 Deletes one or more columns from a grid starting at the specified
1617 The @a updateLabels argument is not used at present. If you are using a
1618 derived grid table class you will need to override
1619 wxGridTableBase::DeleteCols. See InsertCols() for further information.
1621 @return @true on success or @false if deleting columns failed.
1623 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
1626 Deletes one or more rows from a grid starting at the specified position.
1628 The @a updateLabels argument is not used at present. If you are using a
1629 derived grid table class you will need to override
1630 wxGridTableBase::DeleteRows. See InsertRows() for further information.
1632 @return @true on success or @false if appending rows failed.
1634 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
1637 Disables in-place editing of grid cells.
1639 Equivalent to calling EnableCellEditControl(@false).
1641 void DisableCellEditControl();
1644 Disables column moving by dragging with the mouse.
1646 Equivalent to passing @false to EnableDragColMove().
1648 void DisableDragColMove();
1651 Disables column sizing by dragging with the mouse.
1653 Equivalent to passing @false to EnableDragColSize().
1655 void DisableDragColSize();
1658 Disable mouse dragging of grid lines to resize rows and columns.
1660 Equivalent to passing @false to EnableDragGridSize()
1662 void DisableDragGridSize();
1665 Disables row sizing by dragging with the mouse.
1667 Equivalent to passing @false to EnableDragRowSize().
1669 void DisableDragRowSize();
1672 Enables or disables in-place editing of grid cell data.
1674 The grid will issue either a wxEVT_GRID_EDITOR_SHOWN or
1675 wxEVT_GRID_EDITOR_HIDDEN event.
1677 void EnableCellEditControl(bool enable
= true);
1680 Enables or disables column moving by dragging with the mouse.
1682 void EnableDragColMove(bool enable
= true);
1685 Enables or disables column sizing by dragging with the mouse.
1687 void EnableDragColSize(bool enable
= true);
1690 Enables or disables row and column resizing by dragging gridlines with the
1693 void EnableDragGridSize(bool enable
= true);
1696 Enables or disables row sizing by dragging with the mouse.
1698 void EnableDragRowSize(bool enable
= true);
1701 Makes the grid globally editable or read-only.
1703 If the edit argument is @false this function sets the whole grid as
1704 read-only. If the argument is @true the grid is set to the default
1705 state where cells may be editable. In the default state you can set
1706 single grid cells and whole rows and columns to be editable or
1707 read-only via wxGridCellAttribute::SetReadOnly. For single cells you
1708 can also use the shortcut function SetReadOnly().
1710 For more information about controlling grid cell attributes see the
1711 wxGridCellAttr cell attribute class and the
1712 @ref overview_grid "wxGrid overview".
1714 void EnableEditing(bool edit
);
1717 Turns the drawing of grid lines on or off.
1719 void EnableGridLines(bool enable
= true);
1722 Decrements the grid's batch count.
1724 When the count is greater than zero repainting of the grid is
1725 suppressed. Each previous call to BeginBatch() must be matched by a
1726 later call to EndBatch. Code that does a lot of grid modification can
1727 be enclosed between BeginBatch and EndBatch calls to avoid screen
1728 flicker. The final EndBatch will cause the grid to be repainted.
1730 @see wxGridUpdateLocker
1735 Overridden wxWindow method.
1740 Causes immediate repainting of the grid.
1742 Use this instead of the usual wxWindow::Refresh.
1744 void ForceRefresh();
1747 Returns the number of times that BeginBatch() has been called
1748 without (yet) matching calls to EndBatch(). While
1749 the grid's batch count is greater than zero the display will not be updated.
1751 int GetBatchCount();
1754 Sets the arguments to the horizontal and vertical text alignment values
1755 for the grid cell at the specified location.
1757 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1758 or @c wxALIGN_RIGHT.
1760 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1763 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
1766 Returns the background colour of the cell at the specified location.
1768 wxColour
GetCellBackgroundColour(int row
, int col
) const;
1771 Returns a pointer to the editor for the cell at the specified location.
1773 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
1774 for more information about cell editors and renderers.
1776 The caller must call DecRef() on the returned pointer.
1778 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
1781 Returns the font for text in the grid cell at the specified location.
1783 wxFont
GetCellFont(int row
, int col
) const;
1786 Returns a pointer to the renderer for the grid cell at the specified
1789 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
1790 for more information about cell editors and renderers.
1792 The caller must call DecRef() on the returned pointer.
1794 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
1797 Returns the text colour for the grid cell at the specified location.
1799 wxColour
GetCellTextColour(int row
, int col
) const;
1803 Returns the string contained in the cell at the specified location.
1805 For simple applications where a grid object automatically uses a
1806 default grid table of string values you use this function together with
1807 SetCellValue() to access cell values. For more complex applications
1808 where you have derived your own grid table class that contains various
1809 data types (e.g. numeric, boolean or user-defined custom types) then
1810 you only use this function for those cells that contain string values.
1812 See wxGridTableBase::CanGetValueAs and the @ref overview_grid "wxGrid overview"
1813 for more information.
1815 wxString
GetCellValue(int row
, int col
) const;
1816 const wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
1820 Returns the column ID of the specified column position.
1822 int GetColAt(int colPos
) const;
1825 Returns the pen used for vertical grid lines.
1827 This virtual function may be overridden in derived classes in order to
1828 change the appearance of individual grid lines for the given column @e
1831 See GetRowGridLinePen() for an example.
1833 virtual wxPen
GetColGridLinePen(int col
);
1836 Sets the arguments to the current column label alignment values.
1838 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1839 or @c wxALIGN_RIGHT.
1841 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1844 void GetColLabelAlignment(int* horiz
, int* vert
) const;
1847 Returns the current height of the column labels.
1849 int GetColLabelSize() const;
1852 Returns the specified column label.
1854 The default grid table class provides column labels of the form
1855 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1856 override wxGridTableBase::GetColLabelValue to provide your own labels.
1858 wxString
GetColLabelValue(int col
) const;
1861 Returns the minimal width to which a column may be resized.
1863 Use SetColMinimalAcceptableWidth() to change this value globally or
1864 SetColMinimalWidth() to do it for individual columns.
1866 int GetColMinimalAcceptableWidth() const;
1869 Returns the position of the specified column.
1871 int GetColPos(int colID
) const;
1874 Returns the width of the specified column.
1876 int GetColSize(int col
) const;
1879 Returns the default cell alignment.
1881 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1882 or @c wxALIGN_RIGHT.
1884 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1887 @see SetDefaultCellAlignment()
1889 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
1892 Returns the current default background colour for grid cells.
1894 wxColour
GetDefaultCellBackgroundColour() const;
1897 Returns the current default font for grid cell text.
1899 wxFont
GetDefaultCellFont() const;
1902 Returns the current default colour for grid cell text.
1904 wxColour
GetDefaultCellTextColour() const;
1907 Returns the default height for column labels.
1909 int GetDefaultColLabelSize() const;
1912 Returns the current default width for grid columns.
1914 int GetDefaultColSize() const;
1917 Returns a pointer to the current default grid cell editor.
1919 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
1920 for more information about cell editors and renderers.
1922 wxGridCellEditor
* GetDefaultEditor() const;
1926 Returns the default editor for the specified cell.
1928 The base class version returns the editor appropriate for the current
1929 cell type but this method may be overridden in the derived classes to
1930 use custom editors for some cells by default.
1932 Notice that the same may be usually achieved in simpler way by
1933 associating a custom editor with the given cell or cells.
1935 The caller must call DecRef() on the returned pointer.
1937 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1938 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
1942 Returns the default editor for the cells containing values of the given
1945 The base class version returns the editor which was associated with the
1946 specified @a typeName when it was registered RegisterDataType() but
1947 this function may be overridden to return something different. This
1948 allows to override an editor used for one of the standard types.
1950 The caller must call DecRef() on the returned pointer.
1952 virtual wxGridCellEditor
*
1953 GetDefaultEditorForType(const wxString
& typeName
) const;
1956 Returns the pen used for grid lines.
1958 This virtual function may be overridden in derived classes in order to
1959 change the appearance of grid lines. Note that currently the pen width
1962 @see GetColGridLinePen(), GetRowGridLinePen()
1964 virtual wxPen
GetDefaultGridLinePen();
1967 Returns a pointer to the current default grid cell renderer.
1969 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
1970 for more information about cell editors and renderers.
1972 The caller must call DecRef() on the returned pointer.
1974 wxGridCellRenderer
* GetDefaultRenderer() const;
1977 Returns the default renderer for the given cell.
1979 The base class version returns the renderer appropriate for the current
1980 cell type but this method may be overridden in the derived classes to
1981 use custom renderers for some cells by default.
1983 The caller must call DecRef() on the returned pointer.
1985 virtual wxGridCellRenderer
*GetDefaultRendererForCell(int row
, int col
) const;
1988 Returns the default renderer for the cell containing values of the
1991 @see GetDefaultEditorForType()
1993 virtual wxGridCellRenderer
*
1994 GetDefaultRendererForType(const wxString
& typeName
) const;
1997 Returns the default width for the row labels.
1999 int GetDefaultRowLabelSize() const;
2002 Returns the current default height for grid rows.
2004 int GetDefaultRowSize() const;
2007 Returns the current grid cell column position.
2009 int GetGridCursorCol() const;
2012 Returns the current grid cell row position.
2014 int GetGridCursorRow() const;
2017 Returns the colour used for grid lines.
2019 @see GetDefaultGridLinePen()
2021 wxColour
GetGridLineColour() const;
2024 Returns the colour used for the background of row and column labels.
2026 wxColour
GetLabelBackgroundColour() const;
2029 Returns the font used for row and column labels.
2031 wxFont
GetLabelFont() const;
2034 Returns the colour used for row and column label text.
2036 wxColour
GetLabelTextColour() const;
2039 Returns the total number of grid columns.
2041 This is the same as the number of columns in the underlying grid
2044 int GetNumberCols() const;
2047 Returns the total number of grid rows.
2049 This is the same as the number of rows in the underlying grid table.
2051 int GetNumberRows() const;
2054 Returns the attribute for the given cell creating one if necessary.
2056 If the cell already has an attribute, it is returned. Otherwise a new
2057 attribute is created, associated with the cell and returned. In any
2058 case the caller must call DecRef() on the returned pointer.
2060 This function may only be called if CanHaveAttributes() returns @true.
2062 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
2065 Returns the pen used for horizontal grid lines.
2067 This virtual function may be overridden in derived classes in order to
2068 change the appearance of individual grid line for the given row @e row.
2072 // in a grid displaying music notation, use a solid black pen between
2073 // octaves (C0=row 127, C1=row 115 etc.)
2074 wxPen MidiGrid::GetRowGridLinePen(int row)
2076 if ( row % 12 == 7 )
2077 return wxPen(*wxBLACK, 1, wxSOLID);
2079 return GetDefaultGridLinePen();
2083 virtual wxPen
GetRowGridLinePen(int row
);
2086 Returns the alignment used for row labels.
2088 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2089 or @c wxALIGN_RIGHT.
2091 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2094 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
2097 Returns the current width of the row labels.
2099 int GetRowLabelSize() const;
2102 Returns the specified row label.
2104 The default grid table class provides numeric row labels. If you are
2105 using a custom grid table you can override
2106 wxGridTableBase::GetRowLabelValue to provide your own labels.
2108 wxString
GetRowLabelValue(int row
) const;
2111 Returns the minimal size to which rows can be resized.
2113 Use SetRowMinimalAcceptableHeight() to change this value globally or
2114 SetRowMinimalHeight() to do it for individual cells.
2116 @see GetColMinimalAcceptableWidth()
2118 int GetRowMinimalAcceptableHeight() const;
2121 Returns the height of the specified row.
2123 int GetRowSize(int row
) const;
2126 Returns the number of pixels per horizontal scroll increment.
2130 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
2132 int GetScrollLineX() const;
2135 Returns the number of pixels per vertical scroll increment.
2139 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
2141 int GetScrollLineY() const;
2144 Returns an array of individually selected cells.
2146 Notice that this array does @em not contain all the selected cells in
2147 general as it doesn't include the cells selected as part of column, row
2148 or block selection. You must use this method, GetSelectedCols(),
2149 GetSelectedRows() and GetSelectionBlockTopLeft() and
2150 GetSelectionBlockBottomRight() methods to obtain the entire selection
2153 Please notice this behaviour is by design and is needed in order to
2154 support grids of arbitrary size (when an entire column is selected in
2155 a grid with a million of columns, we don't want to create an array with
2156 a million of entries in this function, instead it returns an empty
2157 array and GetSelectedCols() returns an array containing one element).
2159 wxGridCellCoordsArray
GetSelectedCells() const;
2162 Returns an array of selected columns.
2164 Please notice that this method alone is not sufficient to find all the
2165 selected columns as it contains only the columns which were
2166 individually selected but not those being part of the block selection
2167 or being selected in virtue of all of their cells being selected
2168 individually, please see GetSelectedCells() for more details.
2170 wxArrayInt
GetSelectedCols() const;
2173 Returns an array of selected rows.
2175 Please notice that this method alone is not sufficient to find all the
2176 selected rows as it contains only the rows which were individually
2177 selected but not those being part of the block selection or being
2178 selected in virtue of all of their cells being selected individually,
2179 please see GetSelectedCells() for more details.
2181 wxArrayInt
GetSelectedRows() const;
2184 Access or update the selection fore/back colours
2186 wxColour
GetSelectionBackground() const;
2189 Returns an array of the bottom right corners of blocks of selected
2192 Please see GetSelectedCells() for more information about the selection
2193 representation in wxGrid.
2195 @see GetSelectionBlockTopLeft()
2197 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
2200 Returns an array of the top left corners of blocks of selected cells.
2202 Please see GetSelectedCells() for more information about the selection
2203 representation in wxGrid.
2205 @see GetSelectionBlockBottomRight()
2207 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
2210 Returns the colour used for drawing the selection foreground.
2212 wxColour
GetSelectionForeground() const;
2215 Returns the current selection mode.
2217 @see SetSelectionMode().
2219 wxGridSelectionModes
GetSelectionMode() const;
2222 Returns a base pointer to the current table object.
2224 The returned pointer is still owned by the grid.
2226 wxGridTableBase
*GetTable() const;
2230 Make the given cell current and ensure it is visible.
2232 This method is equivalent to calling MakeCellVisible() and
2233 SetGridCursor() and so, as with the latter, a wxEVT_GRID_SELECT_CELL
2234 event is generated by it and the selected cell doesn't change if the
2237 void GoToCell(int row
, int col
);
2238 void GoToCell(const wxGridCellCoords
& coords
);
2242 Returns @true if drawing of grid lines is turned on, @false otherwise.
2244 bool GridLinesEnabled() const;
2247 Hides the in-place cell edit control.
2249 void HideCellEditControl();
2252 Hides the column labels by calling SetColLabelSize()
2253 with a size of 0. Show labels again by calling that method with
2254 a width greater than 0.
2256 void HideColLabels();
2259 Hides the row labels by calling SetRowLabelSize() with a size of 0.
2261 The labels can be shown again by calling SetRowLabelSize() with a width
2264 void HideRowLabels();
2267 Inserts one or more new columns into a grid with the first new column
2268 at the specified position.
2270 Notice that inserting the columns in the grid requires grid table
2271 cooperation: when this method is called, grid object begins by
2272 requesting the underlying grid table to insert new columns. If this is
2273 successful the table notifies the grid and the grid updates the
2274 display. For a default grid (one where you have called
2275 wxGrid::CreateGrid) this process is automatic. If you are using a
2276 custom grid table (specified with wxGrid::SetTable) then you must
2277 override wxGridTableBase::InsertCols() in your derived table class.
2280 The position which the first newly inserted column will have.
2282 The number of columns to insert.
2286 @true if the columns were successfully inserted, @false if an error
2287 occurred (most likely the table couldn't be updated).
2289 bool InsertCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
2292 Inserts one or more new rows into a grid with the first new row at the
2295 Notice that you must implement wxGridTableBase::InsertRows() if you use
2296 a grid with a custom table, please see InsertCols() for more
2300 The position which the first newly inserted row will have.
2302 The number of rows to insert.
2306 @true if the rows were successfully inserted, @false if an error
2307 occurred (most likely the table couldn't be updated).
2309 bool InsertRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
2312 Returns @true if the in-place edit control is currently enabled.
2314 bool IsCellEditControlEnabled() const;
2317 Returns @true if the current cell is read-only.
2319 @see SetReadOnly(), IsReadOnly()
2321 bool IsCurrentCellReadOnly() const;
2324 Returns @false if the whole grid has been set as read-only or @true
2327 See EnableEditing() for more information about controlling the editing
2328 status of grid cells.
2330 bool IsEditable() const;
2334 Is this cell currently selected?
2336 bool IsInSelection(int row
, int col
) const;
2337 bool IsInSelection(const wxGridCellCoords
& coords
) const;
2341 Returns @true if the cell at the specified location can't be edited.
2343 @see SetReadOnly(), IsCurrentCellReadOnly()
2345 bool IsReadOnly(int row
, int col
) const;
2348 Returns @true if there are currently any selected cells, rows, columns
2351 bool IsSelection() const;
2355 Returns @true if a cell is either wholly or at least partially visible
2358 By default, the cell must be entirely visible for this function to
2359 return true but if @a wholeCellVisible is @false, the function returns
2360 @true even if the cell is only partially visible.
2362 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
2363 bool IsVisible(const wxGridCellCoords
& coords
,
2364 bool wholeCellVisible
= true) const;
2369 Brings the specified cell into the visible grid cell area with minimal
2372 Does nothing if the cell is already visible.
2374 void MakeCellVisible(int row
, int col
);
2375 void MakeCellVisible(const wxGridCellCoords
& coords
);
2379 Moves the grid cursor down by one row.
2381 If a block of cells was previously selected it will expand if the
2382 argument is @true or be cleared if the argument is @false.
2384 bool MoveCursorDown(bool expandSelection
);
2387 Moves the grid cursor down in the current column such that it skips to
2388 the beginning or end of a block of non-empty cells.
2390 If a block of cells was previously selected it will expand if the
2391 argument is @true or be cleared if the argument is @false.
2393 bool MoveCursorDownBlock(bool expandSelection
);
2396 Moves the grid cursor left by one column.
2398 If a block of cells was previously selected it will expand if the
2399 argument is @true or be cleared if the argument is @false.
2401 bool MoveCursorLeft(bool expandSelection
);
2404 Moves the grid cursor left in the current row such that it skips to the
2405 beginning or end of a block of non-empty cells.
2407 If a block of cells was previously selected it will expand if the
2408 argument is @true or be cleared if the argument is @false.
2410 bool MoveCursorLeftBlock(bool expandSelection
);
2413 Moves the grid cursor right by one column.
2415 If a block of cells was previously selected it will expand if the
2416 argument is @true or be cleared if the argument is @false.
2418 bool MoveCursorRight(bool expandSelection
);
2421 Moves the grid cursor right in the current row such that it skips to
2422 the beginning or end of a block of non-empty cells.
2424 If a block of cells was previously selected it will expand if the
2425 argument is @true or be cleared if the argument is @false.
2427 bool MoveCursorRightBlock(bool expandSelection
);
2430 Moves the grid cursor up by one row.
2432 If a block of cells was previously selected it will expand if the
2433 argument is @true or be cleared if the argument is @false.
2435 bool MoveCursorUp(bool expandSelection
);
2438 Moves the grid cursor up in the current column such that it skips to
2439 the beginning or end of a block of non-empty cells.
2441 If a block of cells was previously selected it will expand if the
2442 argument is @true or be cleared if the argument is @false.
2444 bool MoveCursorUpBlock(bool expandSelection
);
2447 Moves the grid cursor down by some number of rows so that the previous
2448 bottom visible row becomes the top visible row.
2450 bool MovePageDown();
2453 Moves the grid cursor up by some number of rows so that the previous
2454 top visible row becomes the bottom visible row.
2459 Register a new data type.
2461 The data types allow to naturally associate specific renderers and
2462 editors to the cells containing values of the given type. For example,
2463 the grid automatically registers a data type with the name @c
2464 wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
2465 wxGridCellTextEditor as its renderer and editor respectively -- this is
2466 the data type used by all the cells of the default wxGridStringTable,
2467 so this renderer and editor are used by default for all grid cells.
2469 However if a custom table returns @c wxGRID_VALUE_BOOL from its
2470 wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
2471 wxGridCellBoolEditor are used for it because the grid also registers a
2472 boolean data type with this name.
2474 And as this mechanism is completely generic, you may register your own
2475 data types using your own custom renderers and editors. Just remember
2476 that the table must identify a cell as being of the given type for them
2477 to be used for this cell.
2480 Name of the new type. May be any string, but if the type name is
2481 the same as the name of an already registered type, including one
2482 of the standard ones (which are @c wxGRID_VALUE_STRING, @c
2483 wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT
2484 and @c wxGRID_VALUE_CHOICE), then the new registration information
2485 replaces the previously used renderer and editor.
2487 The renderer to use for the cells of this type. Its ownership is
2488 taken by the grid, i.e. it will call DecRef() on this pointer when
2489 it doesn't need it any longer.
2491 The editor to use for the cells of this type. Its ownership is also
2494 void RegisterDataType(const wxString
& typeName
,
2495 wxGridCellRenderer
* renderer
,
2496 wxGridCellEditor
* editor
);
2499 Sets the value of the current grid cell to the current in-place edit
2502 This is called automatically when the grid cursor moves from the
2503 current cell to a new cell. It is also a good idea to call this
2504 function when closing a grid since any edits to the final cell location
2505 will not be saved otherwise.
2507 void SaveEditControlValue();
2510 Selects all cells in the grid.
2516 Selects a rectangular block of cells.
2518 If @a addToSelected is @false then any existing selection will be
2519 deselected; if @true the column will be added to the existing
2522 void SelectBlock(int topRow
, int leftCol
, int bottomRow
, int rightCol
,
2523 bool addToSelected
= false);
2524 void SelectBlock(const wxGridCellCoords
& topLeft
,
2525 const wxGridCellCoords
& bottomRight
,
2526 bool addToSelected
= false);
2530 Selects the specified column.
2532 If @a addToSelected is @false then any existing selection will be
2533 deselected; if @true the column will be added to the existing
2536 This method won't select anything if the current selection mode is
2539 void SelectCol(int col
, bool addToSelected
= false);
2542 Selects the specified row.
2544 If @a addToSelected is @false then any existing selection will be
2545 deselected; if @true the row will be added to the existing selection.
2547 This method won't select anything if the current selection mode is
2548 wxGridSelectColumns.
2550 void SelectRow(int row
, bool addToSelected
= false);
2554 Sets the horizontal and vertical alignment for grid cell text at the
2557 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2558 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2560 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2561 or @c wxALIGN_BOTTOM.
2563 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2564 void SetCellAlignment(int align
, int row
, int col
);
2569 Set the background colour for the given cell or all cells by default.
2571 void SetCellBackgroundColour(int row
, int col
, const wxColour
& colour
);
2575 Sets the editor for the grid cell at the specified location.
2577 The grid will take ownership of the pointer.
2579 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
2580 for more information about cell editors and renderers.
2582 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2585 Sets the font for text in the grid cell at the specified location.
2587 void SetCellFont(int row
, int col
, const wxFont
& font
);
2590 Sets the renderer for the grid cell at the specified location.
2592 The grid will take ownership of the pointer.
2594 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
2595 for more information about cell editors and renderers.
2597 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
* renderer
);
2601 Sets the text colour for the given cell or all cells by default.
2603 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2604 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2605 void SetCellTextColour(const wxColour
& colour
);
2610 Sets the string value for the cell at the specified location.
2612 For simple applications where a grid object automatically uses a
2613 default grid table of string values you use this function together with
2614 GetCellValue() to access cell values. For more complex applications
2615 where you have derived your own grid table class that contains various
2616 data types (e.g. numeric, boolean or user-defined custom types) then
2617 you only use this function for those cells that contain string values.
2618 The last form is for backward compatibility only.
2620 See wxGridTableBase::CanSetValueAs and the @ref overview_grid
2621 "wxGrid overview" for more information.
2623 void SetCellValue(int row
, int col
, const wxString
& s
);
2624 void SetCellValue(const wxGridCellCoords
& coords
, const wxString
& s
);
2625 void SetCellValue(const wxString
& val
, int row
, int col
);
2629 Sets the cell attributes for all cells in the specified column.
2631 For more information about controlling grid cell attributes see the
2632 wxGridCellAttr cell attribute class and the @ref overview_grid "wxGrid overview".
2634 void SetColAttr(int col
, wxGridCellAttr
* attr
);
2637 Sets the specified column to display boolean values.
2639 @see SetColFormatCustom()
2641 void SetColFormatBool(int col
);
2644 Sets the specified column to display data in a custom format.
2646 This method provides an alternative to defining a custom grid table
2647 which would return @a typeName from its GetTypeName() method for the
2648 cells in this column: while it doesn't really change the type of the
2649 cells in this column, it does associate the renderer and editor used
2650 for the cells of the specified type with them.
2652 See the @ref overview_grid "wxGrid overview" for more
2653 information on working with custom data types.
2655 void SetColFormatCustom(int col
, const wxString
& typeName
);
2658 Sets the specified column to display floating point values with the
2659 given width and precision.
2661 @see SetColFormatCustom()
2663 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
2666 Sets the specified column to display integer values.
2668 @see SetColFormatCustom()
2670 void SetColFormatNumber(int col
);
2673 Sets the horizontal and vertical alignment of column label text.
2675 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2676 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2677 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2678 or @c wxALIGN_BOTTOM.
2680 void SetColLabelAlignment(int horiz
, int vert
);
2683 Sets the height of the column labels.
2685 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
2686 automatically so that no label is truncated. Note that this could be
2687 slow for a large table.
2689 void SetColLabelSize(int height
);
2692 Set the value for the given column label.
2694 If you are using a custom grid table you must override
2695 wxGridTableBase::SetColLabelValue for this to have any effect.
2697 void SetColLabelValue(int col
, const wxString
& value
);
2700 Sets the minimal width to which the user can resize columns.
2702 @see GetColMinimalAcceptableWidth()
2704 void SetColMinimalAcceptableWidth(int width
);
2707 Sets the minimal width for the specified column.
2709 It is usually best to call this method during grid creation as calling
2710 it later will not resize the column to the given minimal width even if
2711 it is currently narrower than it.
2713 @a width must be greater than the minimal acceptable column width as
2714 returned by GetColMinimalAcceptableWidth().
2716 void SetColMinimalWidth(int col
, int width
);
2719 Sets the position of the specified column.
2721 void SetColPos(int colID
, int newPos
);
2724 Sets the width of the specified column.
2726 Notice that this function does not refresh the grid, you need to call
2727 ForceRefresh() to make the changes take effect immediately.
2732 The new column width in pixels or a negative value to fit the
2733 column width to its label width.
2735 void SetColSize(int col
, int width
);
2738 Sets the default horizontal and vertical alignment for grid cell text.
2740 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2741 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2742 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2743 or @c wxALIGN_BOTTOM.
2745 void SetDefaultCellAlignment(int horiz
, int vert
);
2748 Sets the default background colour for grid cells.
2750 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2753 Sets the default font to be used for grid cell text.
2755 void SetDefaultCellFont(const wxFont
& font
);
2758 Sets the current default colour for grid cell text.
2760 void SetDefaultCellTextColour(const wxColour
& colour
);
2763 Sets the default width for columns in the grid.
2765 This will only affect columns subsequently added to the grid unless
2766 @a resizeExistingCols is @true.
2768 If @a width is less than GetColMinimalAcceptableWidth(), then the
2769 minimal acceptable width is used instead of it.
2771 void SetDefaultColSize(int width
, bool resizeExistingCols
= false);
2774 Sets the default editor for grid cells.
2776 The grid will take ownership of the pointer.
2778 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
2779 for more information about cell editors and renderers.
2781 void SetDefaultEditor(wxGridCellEditor
* editor
);
2784 Sets the default renderer for grid cells.
2786 The grid will take ownership of the pointer.
2788 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
2789 for more information about cell editors and renderers.
2791 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2794 Sets the default height for rows in the grid.
2796 This will only affect rows subsequently added to the grid unless
2797 @a resizeExistingRows is @true.
2799 If @a height is less than GetRowMinimalAcceptableHeight(), then the
2800 minimal acceptable heihgt is used instead of it.
2802 void SetDefaultRowSize(int height
, bool resizeExistingRows
= false);
2806 Set the grid cursor to the specified cell.
2808 The grid cursor indicates the current cell and can be moved by the user
2809 using the arrow keys or the mouse.
2811 Calling this function generates a wxEVT_GRID_SELECT_CELL event and if
2812 the event handler vetoes this event, the cursor is not moved.
2814 This function doesn't make the target call visible, use GoToCell() to
2817 void SetGridCursor(int row
, int col
);
2818 void SetGridCursor(const wxGridCellCoords
& coords
);
2822 Sets the colour used to draw grid lines.
2824 void SetGridLineColour(const wxColour
& colour
);
2827 Sets the background colour for row and column labels.
2829 void SetLabelBackgroundColour(const wxColour
& colour
);
2832 Sets the font for row and column labels.
2834 void SetLabelFont(const wxFont
& font
);
2837 Sets the colour for row and column label text.
2839 void SetLabelTextColour(const wxColour
& colour
);
2842 Sets the extra margins used around the grid area.
2844 A grid may occupy more space than needed for its data display and
2845 this function allows to set how big this extra space is
2847 void SetMargins(int extraWidth
, int extraHeight
);
2850 Makes the cell at the specified location read-only or editable.
2854 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2857 Sets the cell attributes for all cells in the specified row.
2859 The grid takes ownership of the attribute pointer.
2861 See the wxGridCellAttr class for more information about controlling
2864 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
2867 Sets the horizontal and vertical alignment of row label text.
2869 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2870 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2871 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2872 or @c wxALIGN_BOTTOM.
2874 void SetRowLabelAlignment(int horiz
, int vert
);
2877 Sets the width of the row labels.
2879 If @a width equals @c wxGRID_AUTOSIZE then width is calculated
2880 automatically so that no label is truncated. Note that this could be
2881 slow for a large table.
2883 void SetRowLabelSize(int width
);
2886 Sets the value for the given row label.
2888 If you are using a derived grid table you must override
2889 wxGridTableBase::SetRowLabelValue for this to have any effect.
2891 void SetRowLabelValue(int row
, const wxString
& value
);
2894 Sets the minimal row height used by default.
2896 See SetColMinimalAcceptableWidth() for more information.
2898 void SetRowMinimalAcceptableHeight(int height
);
2901 Sets the minimal height for the specified row.
2903 See SetColMinimalWidth() for more information.
2905 void SetRowMinimalHeight(int row
, int height
);
2908 Sets the height of the specified row.
2910 See SetColSize() for more information.
2912 void SetRowSize(int row
, int height
);
2915 Sets the number of pixels per horizontal scroll increment.
2919 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2921 void SetScrollLineX(int x
);
2924 Sets the number of pixels per vertical scroll increment.
2928 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2930 void SetScrollLineY(int y
);
2933 Set the colour to be used for drawing the selection background.
2935 void SetSelectionBackground(const wxColour
& c
);
2938 Set the colour to be used for drawing the selection foreground.
2940 void SetSelectionForeground(const wxColour
& c
);
2943 Set the selection behaviour of the grid.
2945 The existing selection is converted to conform to the new mode if
2946 possible and discarded otherwise (e.g. any individual selected cells
2947 are deselected if the new mode allows only the selection of the entire
2950 void SetSelectionMode(wxGridSelectionModes selmode
);
2953 Passes a pointer to a custom grid table to be used by the grid.
2955 This should be called after the grid constructor and before using the
2956 grid object. If @a takeOwnership is set to @true then the table will be
2957 deleted by the wxGrid destructor.
2959 Use this function instead of CreateGrid() when your application
2960 involves complex or non-string data or data sets that are too large to
2961 fit wholly in memory.
2963 bool SetTable(wxGridTableBase
* table
,
2964 bool takeOwnership
= false,
2965 wxGridSelectionModes selmode
= wxGridSelectCells
);
2968 Call this in order to make the column labels use a native look by using
2969 wxRenderer::DrawHeaderButton internally.
2971 There is no equivalent method for drawing row columns as there is not
2972 native look for that. This option is useful when using wxGrid for
2973 displaying tables and not as a spread-sheet.
2975 void SetUseNativeColLabels(bool native
= true);
2978 Displays the in-place cell edit control for the current cell.
2980 void ShowCellEditControl();
2983 Returns the column at the given pixel position.
2986 The x position to evaluate.
2988 If @true, rather than returning wxNOT_FOUND, it returns either the
2989 first or last column depending on whether x is too far to the left
2990 or right respectively.
2992 The column index or wxNOT_FOUND.
2994 int XToCol(int x
, bool clipToMinMax
= false) const;
2997 Returns the column whose right hand edge is close to the given logical
3000 If no column edge is near to this position @c wxNOT_FOUND is returned.
3002 int XToEdgeOfCol(int x
) const;
3006 Translates logical pixel coordinates to the grid cell coordinates.
3008 Notice that this function expects logical coordinates on input so if
3009 you use this function in a mouse event handler you need to translate
3010 the mouse position, which is expressed in device coordinates, to
3013 @see XToCol(), YToRow()
3016 // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
3017 // undocumented, using it is ugly and non-const reference parameters are
3018 // not used in wxWidgets API
3020 wxGridCellCoords
XYToCell(int x
, int y
) const;
3021 wxGridCellCoords
XYToCell(const wxPoint
& pos
) const;
3026 Returns the row whose bottom edge is close to the given logical y
3029 If no row edge is near to this position @c wxNOT_FOUND is returned.
3031 int YToEdgeOfRow(int y
) const;
3034 Returns the grid row that corresponds to the logical y coordinate.
3036 Returns @c wxNOT_FOUND if there is no row at the y position.
3038 int YToRow(int y
, bool clipToMinMax
= false) const;
3042 Returns @true if this grid has support for cell attributes.
3044 The grid supports attributes if it has the associated table which, in
3045 turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
3048 bool CanHaveAttributes() const;
3051 Get the minimal width of the given column/row.
3053 The value returned by this function may be different than that returned
3054 by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
3055 called for this column.
3057 int GetColMinimalWidth(int col
) const;
3060 Returns the coordinate of the right border specified column.
3062 int GetColRight(int col
) const;
3065 Returns the coordinate of the left border specified column.
3067 int GetColLeft(int col
) const;
3070 Returns the minimal size for the given column.
3072 The value returned by this function may be different than that returned
3073 by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
3074 called for this row.
3076 int GetRowMinimalHeight(int col
) const;
3082 @class wxGridCellBoolEditor
3084 The editor for boolean data.
3089 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor,
3090 wxGridCellTextEditor, wxGridCellChoiceEditor
3092 class wxGridCellBoolEditor
: public wxGridCellEditor
3096 Default constructor.
3098 wxGridCellBoolEditor();
3101 Returns @true if the given @a value is equal to the string representation of
3102 the truth value we currently use (see
3103 wxGridCellBoolEditor::UseStringValues).
3105 static bool IsTrueValue(const wxString
& value
);
3108 , wxString&@e valueFalse = _T(""))
3109 This method allows to customize the values returned by GetValue() method for
3110 the cell using this editor. By default, the default values of the arguments are
3111 used, i.e. @c "1" is returned if the cell is checked and an empty string
3112 otherwise, using this method allows to change this.
3114 static void UseStringValues() const;
3120 @class wxGridUpdateLocker
3122 This small class can be used to prevent wxGrid from redrawing
3123 during its lifetime by calling wxGrid::BeginBatch
3124 in its constructor and wxGrid::EndBatch in its
3125 destructor. It is typically used in a function performing several operations
3126 with a grid which would otherwise result in flicker. For example:
3131 m_grid = new wxGrid(this, ...);
3133 wxGridUpdateLocker noUpdates(m_grid);
3134 m_grid-AppendColumn();
3135 ... many other operations with m_grid...
3138 // destructor called, grid refreshed
3142 Using this class is easier and safer than calling
3143 wxGrid::BeginBatch and wxGrid::EndBatch
3144 because you don't risk not to call the latter (due to an exception for example).
3149 class wxGridUpdateLocker
3153 Creates an object preventing the updates of the specified @e grid. The
3154 parameter could be @NULL in which case nothing is done. If @a grid is
3155 non-@NULL then the grid must exist for longer than wxGridUpdateLocker object
3157 The default constructor could be followed by a call to
3161 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
3164 Destructor reenables updates for the grid this object is associated with.
3166 ~wxGridUpdateLocker();
3169 This method can be called if the object had been constructed using the default
3170 constructor. It must not be called more than once.
3172 void Create(wxGrid
* grid
);