1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGridCellFloatRenderer
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, wxGridCellNumberRenderer, wxGridCellStringRenderer,
18 wxGridCellBoolRenderer
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 ( see @ref constr() wxGridCellFloatRenderer ).
34 int GetPrecision() const;
37 Returns the width ( see @ref constr() wxGridCellFloatRenderer ).
42 Parameters string format is "width[,precision]".
44 void SetParameters(const wxString
& params
);
47 Sets the precision ( see @ref constr() wxGridCellFloatRenderer ).
49 void SetPrecision(int precision
);
52 Sets the width ( see @ref constr() wxGridCellFloatRenderer )
54 void SetWidth(int width
);
60 @class wxGridTableBase
67 class wxGridTableBase
: public wxObject
83 bool AppendCols(size_t numCols
= 1);
88 bool AppendRows(size_t numRows
= 1);
93 bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
96 Does this table allow attributes? Default implementation creates
97 a wxGridCellAttrProvider if necessary.
99 bool CanHaveAttributes();
104 bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
114 bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
119 bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
122 by default forwarded to wxGridCellAttrProvider if any. May be
123 overridden to handle attributes directly in the table.
125 wxGridCellAttr
* GetAttr(int row
, int col
);
128 get the currently used attr provider (may be @NULL)
130 wxGridCellAttrProvider
* GetAttrProvider() const;
135 wxString
GetColLabelValue(int col
);
143 You must override these functions in a derived table class.
150 wxString
GetRowLabelValue(int row
);
153 Data type determination and value access.
155 wxString
GetTypeName(int row
, int col
);
160 wxString
GetValue(int row
, int col
);
165 bool GetValueAsBool(int row
, int col
);
168 For user defined types
170 void* GetValueAsCustom(int row
, int col
,
171 const wxString
& typeName
);
176 double GetValueAsDouble(int row
, int col
);
181 long GetValueAsLong(int row
, int col
);
186 wxGrid
* GetView() const;
191 bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
196 bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
201 bool IsEmptyCell(int row
, int col
);
204 these functions take ownership of the pointer
206 void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
210 give us the attr provider to use - we take ownership of the pointer
212 void SetAttrProvider(wxGridCellAttrProvider
* attrProvider
);
217 void SetColAttr(wxGridCellAttr
* attr
, int col
);
222 void SetColLabelValue() const;
227 void SetRowAttr(wxGridCellAttr
* attr
, int row
);
232 void SetRowLabelValue() const;
237 void SetValue(int row
, int col
, const wxString
& value
);
242 void SetValueAsBool(int row
, int col
, bool value
);
247 void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
253 void SetValueAsDouble(int row
, int col
, double value
);
258 void SetValueAsLong(int row
, int col
, long value
);
261 Overriding these is optional
263 void SetView(wxGrid
* grid
);
268 void UpdateAttrCols(size_t pos
, int numCols
);
271 change row/col number in attribute if needed
273 void UpdateAttrRows(size_t pos
, int numRows
);
279 @class wxGridCellEditor
281 This class is responsible for providing and manipulating
282 the in-place edit controls for the grid. Instances of wxGridCellEditor
283 (actually, instances of derived classes since it is an abstract class) can be
284 associated with the cell attributes for individual cells, rows, columns, or
285 even for the entire grid.
290 @see wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
291 wxGridCellNumberEditor, wxGridCellChoiceEditor
293 class wxGridCellEditor
302 The dtor is private because only DecRef() can delete us.
307 Fetch the value from the table and prepare the edit control
308 to begin editing. Set the focus to the edit control.
310 void BeginEdit(int row
, int col
, wxGrid
* grid
);
313 Create a new object which is the copy of this one.
315 wxGridCellEditor
* Clone() const;
318 Creates the actual edit control.
320 void Create(wxWindow
* parent
, wxWindowID id
,
321 wxEvtHandler
* evtHandler
);
329 Complete the editing of the current cell. Returns @true if the value has
330 changed. If necessary, the control may be destroyed.
332 bool EndEdit(int row
, int col
, wxGrid
* grid
);
335 Some types of controls on some platforms may need some help
338 void HandleReturn(wxKeyEvent
& event
);
346 Draws the part of the cell not occupied by the control: the base class
347 version just fills it with background colour from the attribute.
349 void PaintBackground(const wxRect
& rectCell
,
350 wxGridCellAttr
* attr
);
353 Reset the value in the control back to its starting value.
358 Size and position the edit control.
360 void SetSize(const wxRect
& rect
);
363 Show or hide the edit control, use the specified attributes to set
364 colours/fonts for it.
366 void Show(bool show
, wxGridCellAttr
* attr
= NULL
);
369 If the editor is enabled by clicking on the cell, this method will be
372 void StartingClick();
375 If the editor is enabled by pressing keys on the grid,
376 this will be called to let the editor do something about
377 that first key if desired.
379 void StartingKey(wxKeyEvent
& event
);
385 @class wxGridCellTextEditor
387 The editor for string/text data.
392 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
393 wxGridCellNumberEditor, wxGridCellChoiceEditor
395 class wxGridCellTextEditor
: public wxGridCellEditor
401 wxGridCellTextEditor();
404 The parameters string format is "n" where n is a number representing the
407 void SetParameters(const wxString
& params
);
413 @class wxGridCellStringRenderer
415 This class may be used to format string data in a cell; it is the default
421 @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
422 wxGridCellBoolRenderer
424 class wxGridCellStringRenderer
: public wxGridCellRenderer
430 wxGridCellStringRenderer();
436 @class wxGridCellChoiceEditor
438 The editor for string data allowing to choose from a list of strings.
443 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
444 wxGridCellTextEditor, wxGridCellNumberEditor
446 class wxGridCellChoiceEditor
: public wxGridCellEditor
452 Number of strings from which the user can choose.
454 An array of strings from which the user can choose.
456 If allowOthers is @true, the user can type a string not in choices array.
458 wxGridCellChoiceEditor(size_t count
= 0,
459 const wxString choices
[] = NULL
,
460 bool allowOthers
= false);
461 wxGridCellChoiceEditor(const wxArrayString
& choices
,
462 bool allowOthers
= false);
466 Parameters string format is "item1[,item2[...,itemN]]"
468 void SetParameters(const wxString
& params
);
474 @class wxGridEditorCreatedEvent
480 class wxGridEditorCreatedEvent
: public wxCommandEvent
487 wxGridEditorCreatedEvent();
488 wxGridEditorCreatedEvent(int id
, wxEventType type
,
496 Returns the column at which the event occurred.
501 Returns the edit control.
503 wxControl
* GetControl();
506 Returns the row at which the event occurred.
511 Sets the column at which the event occurred.
513 void SetCol(int col
);
516 Sets the edit control.
518 void SetControl(wxControl
* ctrl
);
521 Sets the row at which the event occurred.
523 void SetRow(int row
);
529 @class wxGridRangeSelectEvent
535 class wxGridRangeSelectEvent
: public wxNotifyEvent
542 wxGridRangeSelectEvent();
543 wxGridRangeSelectEvent(int id
, wxEventType type
,
545 const wxGridCellCoords
& topLeft
,
546 const wxGridCellCoords
& bottomRight
,
548 bool control
= false,
555 Returns @true if the Alt key was down at the time of the event.
560 Returns @true if the Control key was down at the time of the event.
565 Top left corner of the rectangular area that was (de)selected.
567 wxGridCellCoords
GetBottomRightCoords();
570 Bottom row of the rectangular area that was (de)selected.
575 Left column of the rectangular area that was (de)selected.
580 Right column of the rectangular area that was (de)selected.
585 Top left corner of the rectangular area that was (de)selected.
587 wxGridCellCoords
GetTopLeftCoords();
590 Top row of the rectangular area that was (de)selected.
595 Returns @true if the Meta key was down at the time of the event.
600 Returns @true if the area was selected, @false otherwise.
605 Returns @true if the Shift key was down at the time of the event.
613 @class wxGridCellRenderer
615 This class is responsible for actually drawing the cell
616 in the grid. You may pass it to the wxGridCellAttr (below) to change the
617 format of one given cell or to wxGrid::SetDefaultRenderer() to change the
618 view of all cells. This is an abstract class, and you will normally use one of
620 predefined derived classes or derive your own class from it.
625 @see wxGridCellStringRenderer, wxGridCellNumberRenderer,
626 wxGridCellFloatRenderer, wxGridCellBoolRenderer
628 class wxGridCellRenderer
634 wxGridCellRenderer
* Clone() const;
637 Draw the given cell on the provided DC inside the given rectangle
638 using the style specified by the attribute and the default or selected
639 state corresponding to the isSelected value.
640 This pure virtual function has a default implementation which will
641 prepare the DC using the given attribute: it will draw the rectangle
642 with the background colour from attr and set the text colour and font.
644 void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
645 const wxRect
& rect
, int row
, int col
,
649 Get the preferred size of the cell for its contents.
651 wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
658 @class wxGridCellNumberEditor
660 The editor for numeric integer data.
665 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
666 wxGridCellTextEditor, wxGridCellChoiceEditor
668 class wxGridCellNumberEditor
: public wxGridCellTextEditor
672 Allows to specify the range for acceptable data;
673 if min == max == -1, no range checking is done
675 wxGridCellNumberEditor(int min
= -1, int max
= -1);
678 String representation of the value.
680 wxString
GetString() const;
683 If the return value is @true, the editor uses a wxSpinCtrl to get user input,
684 otherwise it uses a wxTextCtrl.
686 bool HasRange() const;
689 Parameters string format is "min,max".
691 void SetParameters(const wxString
& params
);
697 @class wxGridSizeEvent
699 This event class contains information about a row/column resize event.
704 class wxGridSizeEvent
: public wxNotifyEvent
712 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
716 bool control
= false,
723 Returns @true if the Alt key was down at the time of the event.
728 Returns @true if the Control key was down at the time of the event.
733 Position in pixels at which the event occurred.
735 wxPoint
GetPosition();
738 Row or column at that was resized.
743 Returns @true if the Meta key was down at the time of the event.
748 Returns @true if the Shift key was down at the time of the event.
756 @class wxGridCellNumberRenderer
758 This class may be used to format integer data in a cell.
763 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
764 wxGridCellBoolRenderer
766 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
772 wxGridCellNumberRenderer();
778 @class wxGridCellAttr
780 This class can be used to alter the cells' appearance in
781 the grid by changing their colour/font/... from default. An object of this
782 class may be returned by wxGridTableBase::GetAttr.
792 Constructor specifying some of the often used attributes.
795 wxGridCellAttr(const wxColour
& colText
,
796 const wxColour
& colBack
,
798 int hAlign
, int vAlign
);
802 Creates a new copy of this object.
804 wxGridCellAttr
* Clone() const;
812 See SetAlignment() for the returned values.
814 void GetAlignment(int* hAlign
, int* vAlign
) const;
819 const wxColour
GetBackgroundColour() const;
824 wxGridCellEditor
* GetEditor(wxGrid
* grid
, int row
, int col
) const;
829 const wxFont
GetFont() const;
834 wxGridCellRenderer
* GetRenderer(wxGrid
* grid
, int row
, int col
) const;
839 const wxColour
GetTextColour() const;
844 bool HasAlignment() const;
849 bool HasBackgroundColour() const;
854 bool HasEditor() const;
859 bool HasFont() const;
864 bool HasRenderer() const;
869 bool HasTextColour() const;
872 This class is ref counted: it is created with ref count of 1, so
873 calling DecRef() once will delete it. Calling IncRef() allows to lock
874 it until the matching DecRef() is called
881 bool IsReadOnly() const;
884 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
885 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one
886 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
888 void SetAlignment(int hAlign
, int vAlign
);
891 Sets the background colour.
893 void SetBackgroundColour(const wxColour
& colBack
);
898 void SetDefAttr(wxGridCellAttr
* defAttr
);
903 void SetEditor(wxGridCellEditor
* editor
);
908 void SetFont(const wxFont
& font
);
913 void SetReadOnly(bool isReadOnly
= true);
916 takes ownership of the pointer
918 void SetRenderer(wxGridCellRenderer
* renderer
);
921 Sets the text colour.
923 void SetTextColour(const wxColour
& colText
);
929 @class wxGridCellBoolRenderer
931 This class may be used to format boolean data in a cell.
937 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
938 wxGridCellNumberRenderer
940 class wxGridCellBoolRenderer
: public wxGridCellRenderer
946 wxGridCellBoolRenderer();
954 This event class contains information about various grid events.
959 class wxGridEvent
: public wxNotifyEvent
967 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
968 int row
= -1, int col
= -1,
969 int x
= -1, int y
= -1,
971 bool control
= false,
978 Returns @true if the Alt key was down at the time of the event.
983 Returns @true if the Control key was down at the time of the event.
988 Column at which the event occurred.
993 Position in pixels at which the event occurred.
995 wxPoint
GetPosition();
998 Row at which the event occurred.
1003 Returns @true if the Meta key was down at the time of the event.
1008 Returns @true if the user is selecting grid cells, @false -- if
1014 Returns @true if the Shift key was down at the time of the event.
1022 @class wxGridCellFloatEditor
1024 The editor for floating point numbers data.
1029 @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
1030 wxGridCellTextEditor, wxGridCellChoiceEditor
1032 class wxGridCellFloatEditor
: public wxGridCellTextEditor
1037 Minimum number of characters to be shown.
1039 Number of digits after the decimal dot.
1041 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
1044 Parameters string format is "width,precision"
1046 void SetParameters(const wxString
& params
);
1054 wxGrid and its related classes are used for displaying and editing tabular
1055 data. They provide a rich set of features for display, editing, and
1056 interacting with a variety of data sources. For simple applications, and to
1057 help you get started, wxGrid is the only class you need to refer to
1058 directly. It will set up default instances of the other classes and manage
1059 them for you. For more complex applications you can derive your own
1060 classes for custom grid views, grid data tables, cell editors and
1061 renderers. The @ref overview_gridoverview has
1062 examples of simple and more complex applications, explains the
1063 relationship between the various grid classes and has a summary of the
1064 keyboard shortcuts and mouse functions provided by wxGrid.
1066 wxGrid has been greatly expanded and redesigned for wxWidgets 2.2
1067 onwards. The new grid classes are reasonably backward-compatible
1068 but there are some exceptions. There are also easier ways of doing many things
1070 the previous implementation.
1072 A wxGridTableBase class holds the actual
1073 data to be displayed by a wxGrid class. One or more wxGrid classes
1074 may act as a view for one table class.
1075 The default table class is called wxGridStringTable and
1076 holds an array of strings. An instance of such a class is created
1077 by wxGrid::CreateGrid.
1079 wxGridCellRenderer is the abstract base
1080 class for rendereing contents in a cell. The following renderers are
1082 wxGridCellStringRenderer,
1083 wxGridCellBoolRenderer,
1084 wxGridCellFloatRenderer,
1085 wxGridCellNumberRenderer. The
1086 look of a cell can be further defined using wxGridCellAttr.
1087 An object of this type may be returned by wxGridTableBase::GetAttr.
1089 wxGridCellEditor is the abstract base
1090 class for editing the value of a cell. The following editors are
1092 wxGridCellTextEditor
1093 wxGridCellBoolEditor
1094 wxGridCellChoiceEditor
1095 wxGridCellNumberEditor.
1100 @see @ref overview_gridoverview "wxGrid overview"
1102 class wxGrid
: public wxScrolledWindow
1107 Constructor to create a grid object. Call either CreateGrid() or
1108 SetTable() directly after this to initialize the grid before using
1112 wxGrid(wxWindow
* parent
, wxWindowID id
,
1113 const wxPoint
& pos
= wxDefaultPosition
,
1114 const wxSize
& size
= wxDefaultSize
,
1115 long style
= wxWANTS_CHARS
,
1116 const wxString
& name
= wxPanelNameStr
);
1120 Destructor. This will also destroy the associated grid table unless you passed
1122 object to the grid and specified that the grid should not take ownership of the
1123 table (see wxGrid::SetTable).
1128 Appends one or more new columns to the right of the grid and returns @true if
1129 successful. The updateLabels argument is not used at present.
1130 If you are using a derived grid table class you will need to override
1131 wxGridTableBase::AppendCols. See
1132 InsertCols() for further information.
1134 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
1137 Appends one or more new rows to the bottom of the grid and returns @true if
1138 successful. The updateLabels argument is not used at present.
1139 If you are using a derived grid table class you will need to override
1140 wxGridTableBase::AppendRows. See
1141 InsertRows() for further information.
1143 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
1146 Automatically sets the height and width of all rows and columns to fit their
1152 Automatically adjusts width of the column to fit its label.
1154 void AutoSizeColLabelSize(int col
);
1157 Automatically sizes the column to fit its contents. If setAsMin is @true the
1158 calculated width will
1159 also be set as the minimal width for the column.
1161 void AutoSizeColumn(int col
, bool setAsMin
= true);
1164 Automatically sizes all columns to fit their contents. If setAsMin is @true the
1165 calculated widths will
1166 also be set as the minimal widths for the columns.
1168 void AutoSizeColumns(bool setAsMin
= true);
1171 Automatically sizes the row to fit its contents. If setAsMin is @true the
1172 calculated height will
1173 also be set as the minimal height for the row.
1175 void AutoSizeRow(int row
, bool setAsMin
= true);
1178 Automatically adjusts height of the row to fit its label.
1180 void AutoSizeRowLabelSize(int col
);
1183 Automatically sizes all rows to fit their contents. If setAsMin is @true the
1184 calculated heights will
1185 also be set as the minimal heights for the rows.
1187 void AutoSizeRows(bool setAsMin
= true);
1200 SetColMinimalWidth()
1202 SetRowMinimalHeight()
1204 SetColMinimalAcceptableWidth()
1206 SetRowMinimalAcceptableHeight()
1208 GetColMinimalAcceptableWidth()
1210 GetRowMinimalAcceptableHeight()
1215 Increments the grid's batch count. When the count is greater than zero
1217 the grid is suppressed. Each call to BeginBatch must be matched by a later call
1219 EndBatch(). Code that does a lot of grid
1220 modification can be enclosed between BeginBatch and EndBatch calls to avoid
1221 screen flicker. The final EndBatch will cause the grid to be repainted.
1223 @see wxGridUpdateLocker
1228 This function returns the rectangle that encloses the block of cells
1229 limited by TopLeft and BottomRight cell in device coords and clipped
1230 to the client size of the grid window.
1232 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
1233 const wxGridCellCoords
& bottomRight
) const;
1236 Returns @true if columns can be moved by dragging with the mouse. Columns can be
1238 by dragging on their labels.
1240 bool CanDragColMove() const;
1243 Returns @true if columns can be resized by dragging with the mouse. Columns can
1245 by dragging the edges of their labels. If grid line dragging is enabled they
1247 resized by dragging the right edge of the column in the grid cell area
1248 (see wxGrid::EnableDragGridSize).
1250 bool CanDragColSize() const;
1253 Return @true if the dragging of grid lines to resize rows and columns is enabled
1254 or @false otherwise.
1256 bool CanDragGridSize() const;
1259 Returns @true if rows can be resized by dragging with the mouse. Rows can be
1261 by dragging the edges of their labels. If grid line dragging is enabled they
1263 resized by dragging the lower edge of the row in the grid cell area
1264 (see wxGrid::EnableDragGridSize).
1266 bool CanDragRowSize() const;
1269 Returns @true if the in-place edit control for the current grid cell can be used
1271 @false otherwise (e.g. if the current cell is read-only).
1273 bool CanEnableCellControl() const;
1276 Do we have some place to store attributes in?
1278 bool CanHaveAttributes() const;
1293 EnableDragGridSize()
1311 Return the rectangle corresponding to the grid cell's size and position in
1315 wxRect
CellToRect(int row
, int col
) const;
1316 const wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
1320 Clears all data in the underlying grid table and repaints the grid. The table
1322 this function. If you are using a derived table class then you need to override
1323 wxGridTableBase::Clear for this function to have any effect.
1328 Deselects all cells that are currently selected.
1330 void ClearSelection();
1344 Creates a grid with the specified initial number of rows and columns.
1345 Call this directly after the grid constructor. When you use this
1346 function wxGrid will create and manage a simple table of string values
1347 for you. All of the grid data will be stored in memory.
1348 For applications with more complex data types or relationships, or for
1349 dealing with very large datasets, you should derive your own grid table
1350 class and pass a table object to the grid with SetTable().
1352 bool CreateGrid(int numRows
, int numCols
,
1353 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
1366 MoveCursorPageDown()
1370 MoveCursorDownBlock()
1372 MoveCursorLeftBlock()
1374 MoveCursorRightBlock()
1379 Deletes one or more columns from a grid starting at the specified position and
1381 @true if successful. The updateLabels argument is not used at present.
1382 If you are using a derived grid table class you will need to override
1383 wxGridTableBase::DeleteCols. See
1384 InsertCols() for further information.
1386 bool DeleteCols(int pos
= 0, int numCols
= 1,
1387 bool updateLabels
= true);
1390 Deletes one or more rows from a grid starting at the specified position and
1392 @true if successful. The updateLabels argument is not used at present.
1393 If you are using a derived grid table class you will need to override
1394 wxGridTableBase::DeleteRows. See
1395 InsertRows() for further information.
1397 bool DeleteRows(int pos
= 0, int numRows
= 1,
1398 bool updateLabels
= true);
1401 Disables in-place editing of grid cells.
1402 Equivalent to calling EnableCellEditControl(@false).
1404 void DisableCellEditControl();
1407 Disables column moving by dragging with the mouse. Equivalent to passing @false
1409 EnableDragColMove().
1411 void DisableDragColMove();
1414 Disables column sizing by dragging with the mouse. Equivalent to passing @false
1416 EnableDragColSize().
1418 void DisableDragColSize();
1421 Disable mouse dragging of grid lines to resize rows and columns. Equivalent to
1423 @false to EnableDragGridSize()
1425 void DisableDragGridSize();
1428 Disables row sizing by dragging with the mouse. Equivalent to passing @false to
1429 EnableDragRowSize().
1431 void DisableDragRowSize();
1434 Enables or disables in-place editing of grid cell data. The grid will issue
1436 wxEVT_GRID_EDITOR_SHOWN or wxEVT_GRID_EDITOR_HIDDEN event.
1438 void EnableCellEditControl(bool enable
= true);
1441 Enables or disables column moving by dragging with the mouse.
1443 void EnableDragColMove(bool enable
= true);
1446 Enables or disables column sizing by dragging with the mouse.
1448 void EnableDragColSize(bool enable
= true);
1451 Enables or disables row and column resizing by dragging gridlines with the
1454 void EnableDragGridSize(bool enable
= true);
1457 Enables or disables row sizing by dragging with the mouse.
1459 void EnableDragRowSize(bool enable
= true);
1462 If the edit argument is @false this function sets the whole grid as read-only.
1464 argument is @true the grid is set to the default state where cells may be
1466 default state you can set single grid cells and whole rows and columns to be
1469 wxGridCellAttribute::SetReadOnly. For single
1470 cells you can also use the shortcut function
1472 For more information about controlling grid cell attributes see the
1473 wxGridCellAttr cell attribute class and the
1474 @ref overview_gridoverview.
1476 void EnableEditing(bool edit
);
1479 Turns the drawing of grid lines on or off.
1481 void EnableGridLines(bool enable
= true);
1484 Decrements the grid's batch count. When the count is greater than zero
1486 the grid is suppressed. Each previous call to
1487 BeginBatch() must be matched by a later call to
1488 EndBatch. Code that does a lot of grid modification can be enclosed between
1489 BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will
1490 cause the grid to be repainted.
1492 @see wxGridUpdateLocker
1497 Overridden wxWindow method.
1502 Causes immediate repainting of the grid. Use this instead of the usual
1505 void ForceRefresh();
1508 Returns the number of times that BeginBatch() has been called
1509 without (yet) matching calls to EndBatch(). While
1510 the grid's batch count is greater than zero the display will not be updated.
1512 int GetBatchCount() const;
1515 Sets the arguments to the horizontal and vertical text alignment values for the
1516 grid cell at the specified location.
1517 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1520 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1522 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
1525 Returns the background colour of the cell at the specified location.
1527 wxColour
GetCellBackgroundColour(int row
, int col
) const;
1530 Returns a pointer to the editor for the cell at the specified location.
1531 See wxGridCellEditor and
1532 the @ref overview_gridoverview "wxGrid overview" for more information about
1533 cell editors and renderers.
1535 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
1538 Returns the font for text in the grid cell at the specified location.
1540 wxFont
GetCellFont(int row
, int col
) const;
1543 Returns a pointer to the renderer for the grid cell at the specified location.
1544 See wxGridCellRenderer and
1545 the @ref overview_gridoverview "wxGrid overview" for more information about
1546 cell editors and renderers.
1548 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
1551 Returns the text colour for the grid cell at the specified location.
1553 wxColour
GetCellTextColour(int row
, int col
) const;
1557 Returns the string contained in the cell at the specified location. For simple
1558 applications where a
1559 grid object automatically uses a default grid table of string values you use
1560 this function together
1561 with SetCellValue() to access cell values.
1562 For more complex applications where you have derived your own grid table class
1564 various data types (e.g. numeric, boolean or user-defined custom types) then
1566 function for those cells that contain string values.
1567 See wxGridTableBase::CanGetValueAs
1568 and the @ref overview_gridoverview "wxGrid overview" for more information.
1570 wxString
GetCellValue(int row
, int col
) const;
1571 const wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
1575 Returns the column ID of the specified column position.
1577 int GetColAt(int colPos
) const;
1580 Returns the pen used for vertical grid lines. This virtual function may be
1581 overridden in derived classes in order to change the appearance of individual
1582 grid lines for the given column @e col.
1583 See GetRowGridLinePen() for an example.
1585 wxPen
GetColGridLinePen(int col
);
1588 Sets the arguments to the current column label alignment values.
1589 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1592 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1594 void GetColLabelAlignment(int* horiz
, int* vert
) const;
1597 Returns the current height of the column labels.
1599 int GetColLabelSize() const;
1602 Returns the specified column label. The default grid table class provides
1604 the form A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1606 wxGridTableBase::GetColLabelValue to provide
1609 wxString
GetColLabelValue(int col
) const;
1614 int GetColLeft(int col
) const;
1617 This returns the value of the lowest column width that can be handled
1619 member SetColMinimalAcceptableWidth() for details.
1621 int GetColMinimalAcceptableWidth() const;
1624 Get the minimal width of the given column/row.
1626 int GetColMinimalWidth(int col
) const;
1629 Returns the position of the specified column.
1631 int GetColPos(int colID
) const;
1636 int GetColRight(int col
) const;
1639 Returns the width of the specified column.
1641 int GetColSize(int col
) const;
1644 Sets the arguments to the current default horizontal and vertical text alignment
1646 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1649 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1651 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
1654 Returns the current default background colour for grid cells.
1656 wxColour
GetDefaultCellBackgroundColour() const;
1659 Returns the current default font for grid cell text.
1661 wxFont
GetDefaultCellFont() const;
1664 Returns the current default colour for grid cell text.
1666 wxColour
GetDefaultCellTextColour() const;
1669 Returns the default height for column labels.
1671 int GetDefaultColLabelSize() const;
1674 Returns the current default width for grid columns.
1676 int GetDefaultColSize() const;
1679 Returns a pointer to the current default grid cell editor.
1680 See wxGridCellEditor and
1681 the @ref overview_gridoverview "wxGrid overview" for more information about
1682 cell editors and renderers.
1684 wxGridCellEditor
* GetDefaultEditor() const;
1690 wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1691 const wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
1697 wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1700 Returns the pen used for grid lines. This virtual function may be overridden in
1701 derived classes in order to change the appearance of grid lines. Note that
1702 currently the pen width must be 1.
1704 @see GetColGridLinePen(), GetRowGridLinePen()
1706 wxPen
GetDefaultGridLinePen();
1709 Returns a pointer to the current default grid cell renderer.
1710 See wxGridCellRenderer and
1711 the @ref overview_gridoverview "wxGrid overview" for more information about
1712 cell editors and renderers.
1714 wxGridCellRenderer
* GetDefaultRenderer() const;
1719 wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1724 wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1727 Returns the default width for the row labels.
1729 int GetDefaultRowLabelSize() const;
1732 Returns the current default height for grid rows.
1734 int GetDefaultRowSize() const;
1737 Returns the current grid cell column position.
1739 int GetGridCursorCol() const;
1742 Returns the current grid cell row position.
1744 int GetGridCursorRow() const;
1747 Returns the colour used for grid lines.
1749 @see GetDefaultGridLinePen()
1751 wxColour
GetGridLineColour() const;
1754 Returns the colour used for the background of row and column labels.
1756 wxColour
GetLabelBackgroundColour() const;
1759 Returns the font used for row and column labels.
1761 wxFont
GetLabelFont() const;
1764 Returns the colour used for row and column label text.
1766 wxColour
GetLabelTextColour() const;
1769 Returns the total number of grid columns (actually the number of columns in the
1773 int GetNumberCols() const;
1776 Returns the total number of grid rows (actually the number of rows in the
1777 underlying grid table).
1779 int GetNumberRows() const;
1784 wxGridCellAttr
* GetOrCreateCellAttr(int row
, int col
) const;
1787 Returns the pen used for horizontal grid lines. This virtual function may be
1788 overridden in derived classes in order to change the appearance of individual
1789 grid line for the given row @e row.
1792 wxPen
GetRowGridLinePen(int row
);
1795 Sets the arguments to the current row label alignment values.
1796 Horizontal alignment will be one of wxLEFT, wxCENTRE or wxRIGHT.
1798 Vertical alignment will be one of wxTOP, wxCENTRE or wxBOTTOM.
1800 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
1803 Returns the current width of the row labels.
1805 int GetRowLabelSize() const;
1808 Returns the specified row label. The default grid table class provides numeric
1810 If you are using a custom grid table you can override
1811 wxGridTableBase::GetRowLabelValue to provide
1814 wxString
GetRowLabelValue(int row
) const;
1817 This returns the value of the lowest row width that can be handled correctly.
1819 member SetRowMinimalAcceptableHeight() for details.
1821 int GetRowMinimalAcceptableHeight() const;
1826 int GetRowMinimalHeight(int col
) const;
1829 Returns the height of the specified row.
1831 int GetRowSize(int row
) const;
1834 Returns the number of pixels per horizontal scroll increment. The default is 15.
1836 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
1838 int GetScrollLineX() const;
1841 Returns the number of pixels per vertical scroll increment. The default is 15.
1843 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
1845 int GetScrollLineY() const;
1848 Returns an array of singly selected cells.
1850 wxGridCellCoordsArray
GetSelectedCells() const;
1853 Returns an array of selected cols.
1855 Please notice that this method alone is not sufficient to find all the
1856 selected columns, see the explanation in GetSelectedRows()
1857 documentation for more details.
1859 wxArrayInt
GetSelectedCols() const;
1862 Returns an array of selected rows.
1864 Note that this array contains only the rows which were individually
1865 selected (using the mouse with the row header or combinations involving
1866 @c Ctrl key for selecting individual rows). In particular if the user
1867 selects many rows at once (e.g. by pressing @c Shift key) this array is
1868 @b not updated because this could mean storing a very large number of
1869 elements in it. So in general to find the current selection you need to
1870 use both this method and GetSelectionBlockTopLeft() and
1871 GetSelectionBlockBottomRight() ones.
1873 wxArrayInt
GetSelectedRows() const;
1876 Access or update the selection fore/back colours
1878 wxColour
GetSelectionBackground() const;
1881 Returns an array of the bottom right corners of blocks of selected cells,
1882 see GetSelectionBlockTopLeft().
1884 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1887 Returns an array of the top left corners of blocks of selected cells,
1888 see GetSelectionBlockBottomRight().
1890 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1895 wxColour
GetSelectionForeground() const;
1898 Returns the current selection mode, see SetSelectionMode().
1900 wxGrid::wxGridSelectionModes
GetSelectionMode() const;
1903 Returns a base pointer to the current table object.
1905 wxGridTableBase
* GetTable() const;
1908 Returned number of whole cols visible.
1910 int GetViewWidth() const;
1921 GetDefaultGridLinePen()
1930 Returns @true if drawing of grid lines is turned on, @false otherwise.
1932 bool GridLinesEnabled() const;
1935 Hides the in-place cell edit control.
1937 void HideCellEditControl();
1940 Hides the column labels by calling SetColLabelSize()
1941 with a size of 0. Show labels again by calling that method with
1942 a width greater than 0.
1944 void HideColLabels();
1947 Hides the row labels by calling SetRowLabelSize()
1948 with a size of 0. Show labels again by calling that method with
1949 a width greater than 0.
1951 void HideRowLabels();
1954 Init the m_colWidths/Rights arrays
1956 void InitColWidths();
1959 @note @e never access m_row/col arrays directly because they are created
1960 on demand, @e always use accessor functions instead!
1961 Init the m_rowHeights/Bottoms arrays with default values.
1963 void InitRowHeights();
1966 Inserts one or more new columns into a grid with the first new column at the
1967 specified position and returns @true if successful. The updateLabels argument is
1970 The sequence of actions begins with the grid object requesting the underlying
1972 table to insert new columns. If this is successful the table notifies the grid
1974 grid updates the display. For a default grid (one where you have called
1975 wxGrid::CreateGrid) this process is automatic. If you are
1976 using a custom grid table (specified with wxGrid::SetTable)
1977 then you must override
1978 wxGridTableBase::InsertCols in your derived
1981 bool InsertCols(int pos
= 0, int numCols
= 1,
1982 bool updateLabels
= true);
1985 Inserts one or more new rows into a grid with the first new row at the specified
1986 position and returns @true if successful. The updateLabels argument is not used
1989 The sequence of actions begins with the grid object requesting the underlying
1991 table to insert new rows. If this is successful the table notifies the grid and
1993 grid updates the display. For a default grid (one where you have called
1994 wxGrid::CreateGrid) this process is automatic. If you are
1995 using a custom grid table (specified with wxGrid::SetTable)
1996 then you must override
1997 wxGridTableBase::InsertRows in your derived
2000 bool InsertRows(int pos
= 0, int numRows
= 1,
2001 bool updateLabels
= true);
2004 Returns @true if the in-place edit control is currently enabled.
2006 bool IsCellEditControlEnabled() const;
2009 Returns @true if the current cell has been set to read-only
2010 (see wxGrid::SetReadOnly).
2012 bool IsCurrentCellReadOnly() const;
2015 Returns @false if the whole grid has been set as read-only or @true otherwise.
2016 See EnableEditing() for more information about
2017 controlling the editing status of grid cells.
2019 bool IsEditable() const;
2023 Is this cell currently selected.
2025 bool IsInSelection(int row
, int col
) const;
2026 const bool IsInSelection(const wxGridCellCoords
& coords
) const;
2030 Returns @true if the cell at the specified location can't be edited.
2031 See also IsReadOnly().
2033 bool IsReadOnly(int row
, int col
) const;
2036 Returns @true if there are currently rows, columns or blocks of cells selected.
2038 bool IsSelection() const;
2042 Returns @true if a cell is either wholly visible (the default) or at least
2044 visible in the grid window.
2046 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
2047 const bool IsVisible(const wxGridCellCoords
& coords
,
2048 bool wholeCellVisible
= true) const;
2053 Brings the specified cell into the visible grid cell area with minimal
2055 nothing if the cell is already visible.
2057 void MakeCellVisible(int row
, int col
);
2058 void MakeCellVisible(const wxGridCellCoords
& coords
);
2062 Moves the grid cursor down by one row. If a block of cells was previously
2064 will expand if the argument is @true or be cleared if the argument is @false.
2066 bool MoveCursorDown(bool expandSelection
);
2069 Moves the grid cursor down in the current column such that it skips to the
2071 end of a block of non-empty cells. If a block of cells was previously selected
2073 will expand if the argument is @true or be cleared if the argument is @false.
2075 bool MoveCursorDownBlock(bool expandSelection
);
2078 Moves the grid cursor left by one column. If a block of cells was previously
2080 will expand if the argument is @true or be cleared if the argument is @false.
2082 bool MoveCursorLeft(bool expandSelection
);
2085 Moves the grid cursor left in the current row such that it skips to the
2087 end of a block of non-empty cells. If a block of cells was previously selected
2089 will expand if the argument is @true or be cleared if the argument is @false.
2091 bool MoveCursorLeftBlock(bool expandSelection
);
2094 Moves the grid cursor right by one column. If a block of cells was previously
2096 will expand if the argument is @true or be cleared if the argument is @false.
2098 bool MoveCursorRight(bool expandSelection
);
2101 Moves the grid cursor right in the current row such that it skips to the
2103 end of a block of non-empty cells. If a block of cells was previously selected
2105 will expand if the argument is @true or be cleared if the argument is @false.
2107 bool MoveCursorRightBlock(bool expandSelection
);
2110 Moves the grid cursor up by one row. If a block of cells was previously
2112 will expand if the argument is @true or be cleared if the argument is @false.
2114 bool MoveCursorUp(bool expandSelection
);
2117 Moves the grid cursor up in the current column such that it skips to the
2119 end of a block of non-empty cells. If a block of cells was previously selected
2121 will expand if the argument is @true or be cleared if the argument is @false.
2123 bool MoveCursorUpBlock(bool expandSelection
);
2126 Moves the grid cursor down by some number of rows so that the previous bottom
2128 becomes the top visible row.
2130 bool MovePageDown();
2133 Moves the grid cursor up by some number of rows so that the previous top
2135 becomes the bottom visible row.
2140 Methods for a registry for mapping data types to Renderers/Editors
2142 void RegisterDataType(const wxString
& typeName
,
2143 wxGridCellRenderer
* renderer
,
2144 wxGridCellEditor
* editor
);
2155 SetUseNativeColLabels()
2169 AutoSizeRowLabelSize()
2171 AutoSizeColLabelSize()
2173 GetDefaultRowLabelSize()
2175 GetDefaultColLabelSize()
2177 SetRowLabelAlignment()
2179 SetColLabelAlignment()
2181 GetRowLabelAlignment()
2183 GetColLabelAlignment()
2187 SetLabelTextColour()
2189 SetLabelBackgroundColour()
2193 GetLabelBackgroundColour()
2195 GetLabelTextColour()
2197 SetColLabelTextOrientation()
2199 GetColLabelTextOrientation()
2204 Sets the value of the current grid cell to the current in-place edit control
2206 This is called automatically when the grid cursor moves from the current cell
2208 new cell. It is also a good idea to call this function when closing a grid since
2209 any edits to the final cell location will not be saved otherwise.
2211 void SaveEditControlValue();
2214 Selects all cells in the grid.
2220 Selects a rectangular block of cells. If addToSelected is @false then any
2221 existing selection will be
2222 deselected; if @true the column will be added to the existing selection.
2224 void SelectBlock(int topRow
, int leftCol
, int bottomRow
,
2226 bool addToSelected
= false);
2227 void SelectBlock(const wxGridCellCoords
& topLeft
,
2228 const wxGridCellCoords
& bottomRight
,
2229 bool addToSelected
= false);
2233 Selects the specified column. If addToSelected is @false then any existing
2235 deselected; if @true the column will be added to the existing selection.
2237 void SelectCol(int col
, bool addToSelected
= false);
2240 Selects the specified row. If addToSelected is @false then any existing
2242 deselected; if @true the row will be added to the existing selection.
2244 void SelectRow(int row
, bool addToSelected
= false);
2262 This function returns the rectangle that encloses the selected cells
2263 in device coords and clipped to the client size of the grid window.
2265 wxRect
SelectionToDeviceRect() const;
2269 Sets the horizontal and vertical alignment for grid cell text at the specified
2271 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2274 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2277 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2278 void SetCellAlignment(int align
, int row
, int col
);
2284 void SetCellBackgroundColour(int row
, int col
,
2285 const wxColour
& colour
);
2288 Sets the editor for the grid cell at the specified location.
2289 The grid will take ownership of the pointer.
2290 See wxGridCellEditor and
2291 the @ref overview_gridoverview "wxGrid overview" for more information about
2292 cell editors and renderers.
2294 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2297 Sets the font for text in the grid cell at the specified location.
2299 void SetCellFont(int row
, int col
, const wxFont
& font
);
2302 Sets the renderer for the grid cell at the specified location.
2303 The grid will take ownership of the pointer.
2304 See wxGridCellRenderer and
2305 the @ref overview_gridoverview "wxGrid overview" for more information about
2306 cell editors and renderers.
2308 void SetCellRenderer(int row
, int col
,
2309 wxGridCellRenderer
* renderer
);
2313 Sets the text colour for the grid cell at the specified location.
2315 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2316 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2317 void SetCellTextColour(const wxColour
& colour
);
2322 Sets the string value for the cell at the specified location. For simple
2323 applications where a
2324 grid object automatically uses a default grid table of string values you use
2325 this function together
2326 with GetCellValue() to access cell values.
2327 For more complex applications where you have derived your own grid table class
2329 various data types (e.g. numeric, boolean or user-defined custom types) then
2331 function for those cells that contain string values.
2332 The last form is for backward compatibility only.
2333 See wxGridTableBase::CanSetValueAs
2334 and the @ref overview_gridoverview "wxGrid overview" for more information.
2336 void SetCellValue(int row
, int col
, const wxString
& s
);
2337 void SetCellValue(const wxGridCellCoords
& coords
,
2339 void SetCellValue(const wxString
& val
, int row
, int col
);
2343 Sets the cell attributes for all cells in the specified column.
2344 For more information about controlling grid cell attributes see the
2345 wxGridCellAttr cell attribute class and the
2346 @ref overview_gridoverview.
2348 void SetColAttr(int col
, wxGridCellAttr
* attr
);
2351 Sets the specified column to display boolean values. wxGrid displays boolean
2352 values with a checkbox.
2354 void SetColFormatBool(int col
);
2357 Sets the specified column to display data in a custom format.
2358 See the @ref overview_gridoverview "wxGrid overview" for more information on
2360 with custom data types.
2362 void SetColFormatCustom(int col
, const wxString
& typeName
);
2365 Sets the specified column to display floating point values with the given width
2368 void SetColFormatFloat(int col
, int width
= -1,
2369 int precision
= -1);
2372 Sets the specified column to display integer values.
2374 void SetColFormatNumber(int col
);
2377 Sets the horizontal and vertical alignment of column label text.
2378 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2380 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2383 void SetColLabelAlignment(int horiz
, int vert
);
2386 Sets the height of the column labels.
2387 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
2389 so that no label is truncated. Note that this could be slow for a large table.
2391 void SetColLabelSize(int height
);
2394 Set the value for the given column label. If you are using a derived grid table
2396 override wxGridTableBase::SetColLabelValue
2397 for this to have any effect.
2399 void SetColLabelValue(int col
, const wxString
& value
);
2402 This modifies the minimum column width that can be handled correctly.
2403 Specifying a low value here
2404 allows smaller grid cells to be dealt with correctly. Specifying a value here
2405 which is much smaller
2406 than the actual minimum size will incur a performance penalty in the functions
2408 grid cell index lookup on the basis of screen coordinates.
2409 This should normally be called when creating the grid because it will not
2410 resize existing columns
2411 with sizes smaller than the value specified here.
2413 void SetColMinimalAcceptableWidth(int width
);
2416 Sets the minimal width for the specified column. This should normally be called
2417 when creating the grid
2418 because it will not resize a column that is already narrower than the minimal
2420 The width argument must be higher than the minimimal acceptable column width,
2422 GetColMinimalAcceptableWidth().
2424 void SetColMinimalWidth(int col
, int width
);
2427 Sets the position of the specified column.
2429 void SetColPos(int colID
, int newPos
);
2432 Sets the width of the specified column.
2433 This function does not refresh the grid. If you are calling it outside of a
2434 BeginBatch / EndBatch
2435 block you can use ForceRefresh() to see the changes.
2436 Automatically sizes the column to fit its contents. If setAsMin is @true the
2437 calculated width will
2438 also be set as the minimal width for the column.
2440 void SetColSize(int col
, int width
);
2443 Sets the default horizontal and vertical alignment for grid cell text.
2444 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2446 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2449 void SetDefaultCellAlignment(int horiz
, int vert
);
2452 Sets the default background colour for grid cells.
2454 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2457 Sets the default font to be used for grid cell text.
2459 void SetDefaultCellFont(const wxFont
& font
);
2462 Sets the current default colour for grid cell text.
2464 void SetDefaultCellTextColour(const wxColour
& colour
);
2467 Sets the default width for columns in the grid. This will only affect columns
2468 subsequently added to
2469 the grid unless resizeExistingCols is @true.
2471 void SetDefaultColSize(int width
,
2472 bool resizeExistingCols
= false);
2475 Sets the default editor for grid cells. The grid will take ownership of the
2477 See wxGridCellEditor and
2478 the @ref overview_gridoverview "wxGrid overview" for more information about
2479 cell editors and renderers.
2481 void SetDefaultEditor(wxGridCellEditor
* editor
);
2484 Sets the default renderer for grid cells. The grid will take ownership of the
2486 See wxGridCellRenderer and
2487 the @ref overview_gridoverview "wxGrid overview" for more information about
2488 cell editors and renderers.
2490 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2493 Sets the default height for rows in the grid. This will only affect rows
2495 to the grid unless resizeExistingRows is @true.
2497 void SetDefaultRowSize(int height
,
2498 bool resizeExistingRows
= false);
2501 Set the grid cursor to the specified cell.
2502 This function calls MakeCellVisible().
2504 void SetGridCursor(int row
, int col
);
2507 Sets the colour used to draw grid lines.
2509 void SetGridLineColour(const wxColour
& colour
);
2512 Sets the background colour for row and column labels.
2514 void SetLabelBackgroundColour(const wxColour
& colour
);
2517 Sets the font for row and column labels.
2519 void SetLabelFont(const wxFont
& font
);
2522 Sets the colour for row and column label text.
2524 void SetLabelTextColour(const wxColour
& colour
);
2527 A grid may occupy more space than needed for its rows/columns. This
2528 function allows to set how big this extra space is
2530 void SetMargins(int extraWidth
, int extraHeight
);
2533 Common part of AutoSizeColumn/Row() and GetBestSize()
2535 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= true);
2540 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= true);
2543 Makes the cell at the specified location read-only or editable.
2544 See also IsReadOnly().
2546 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2549 Sets the cell attributes for all cells in the specified row.
2550 See the wxGridCellAttr class for more information
2551 about controlling cell attributes.
2553 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
2556 Sets the horizontal and vertical alignment of row label text.
2557 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2559 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2562 void SetRowLabelAlignment(int horiz
, int vert
);
2565 Sets the width of the row labels.
2566 If @a width equals @c wxGRID_AUTOSIZE then width is calculated automatically
2567 so that no label is truncated. Note that this could be slow for a large table.
2569 void SetRowLabelSize(int width
);
2572 Set the value for the given row label. If you are using a derived grid table
2574 override wxGridTableBase::SetRowLabelValue
2575 for this to have any effect.
2577 void SetRowLabelValue(int row
, const wxString
& value
);
2580 This modifies the minimum row width that can be handled correctly. Specifying a
2582 allows smaller grid cells to be dealt with correctly. Specifying a value here
2583 which is much smaller
2584 than the actual minimum size will incur a performance penalty in the functions
2586 grid cell index lookup on the basis of screen coordinates.
2587 This should normally be called when creating the grid because it will not
2588 resize existing rows
2589 with sizes smaller than the value specified here.
2591 void SetRowMinimalAcceptableHeight(int height
);
2594 Sets the minimal height for the specified row. This should normally be called
2595 when creating the grid
2596 because it will not resize a row that is already shorter than the minimal
2598 The height argument must be higher than the minimimal acceptable row height, see
2599 GetRowMinimalAcceptableHeight().
2601 void SetRowMinimalHeight(int row
, int height
);
2604 Sets the height of the specified row.
2605 This function does not refresh the grid. If you are calling it outside of a
2606 BeginBatch / EndBatch
2607 block you can use ForceRefresh() to see the changes.
2608 Automatically sizes the column to fit its contents. If setAsMin is @true the
2609 calculated width will
2610 also be set as the minimal width for the column.
2612 void SetRowSize(int row
, int height
);
2615 Sets the number of pixels per horizontal scroll increment. The default is 15.
2616 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2617 errors: setting this to 1 can help.
2619 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2621 void SetScrollLineX(int x
);
2624 Sets the number of pixels per vertical scroll increment. The default is 15.
2625 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2626 errors: setting this to 1 can help.
2628 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2630 void SetScrollLineY(int y
);
2635 void SetSelectionBackground(const wxColour
& c
);
2640 void SetSelectionForeground(const wxColour
& c
);
2643 Set the selection behaviour of the grid.
2645 @param wxGridSelectCells()
2646 The default mode where individual cells are selected.
2647 @param wxGridSelectRows()
2648 Selections will consist of whole rows.
2649 @param wxGridSelectColumns()
2650 Selections will consist of whole columns.
2652 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
2655 Passes a pointer to a custom grid table to be used by the grid. This should be
2657 after the grid constructor and before using the grid object. If takeOwnership
2659 @true then the table will be deleted by the wxGrid destructor.
2660 Use this function instead of CreateGrid() when your
2661 application involves complex or non-string data or data sets that are too large
2665 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= false,
2666 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
2669 Call this in order to make the column labels use a native look by using
2670 wxRenderer::DrawHeaderButton
2671 internally. There is no equivalent method for drawing row columns as
2672 there is not native look for that. This option is useful when using
2673 wxGrid for displaying tables and not as a spread-sheet.
2675 void SetUseNativeColLabels(bool native
= true);
2678 Displays the in-place cell edit control for the current cell.
2680 void ShowCellEditControl();
2684 The x position to evaluate.
2686 If @true, rather than returning wxNOT_FOUND, it returns either the first or
2687 last column depending on whether x is too far to the left or right respectively.
2689 int XToCol(int x
, bool clipToMinMax
= false) const;
2692 Returns the column whose right hand edge is close to the given logical x
2694 If no column edge is near to this position @c wxNOT_FOUND is returned.
2696 int XToEdgeOfCol(int x
) const;
2699 Returns the row whose bottom edge is close to the given logical y position.
2700 If no row edge is near to this position @c wxNOT_FOUND is returned.
2702 int YToEdgeOfRow(int y
) const;
2705 Returns the grid row that corresponds to the logical y coordinate. Returns
2706 @c wxNOT_FOUND if there is no row at the y position.
2708 int YToRow(int y
) const;
2714 @class wxGridCellBoolEditor
2716 The editor for boolean data.
2721 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor,
2722 wxGridCellTextEditor, wxGridCellChoiceEditor
2724 class wxGridCellBoolEditor
: public wxGridCellEditor
2728 Default constructor.
2730 wxGridCellBoolEditor();
2733 Returns @true if the given @a value is equal to the string representation of
2734 the truth value we currently use (see
2735 wxGridCellBoolEditor::UseStringValues).
2737 static bool IsTrueValue(const wxString
& value
);
2740 , wxString&@e valueFalse = _T(""))
2741 This method allows to customize the values returned by GetValue() method for
2742 the cell using this editor. By default, the default values of the arguments are
2743 used, i.e. @c "1" is returned if the cell is checked and an empty string
2744 otherwise, using this method allows to change this.
2746 static void UseStringValues() const;
2752 @class wxGridUpdateLocker
2754 This small class can be used to prevent wxGrid from redrawing
2755 during its lifetime by calling wxGrid::BeginBatch
2756 in its constructor and wxGrid::EndBatch in its
2757 destructor. It is typically used in a function performing several operations
2758 with a grid which would otherwise result in flicker. For example:
2763 m_grid = new wxGrid(this, ...);
2765 wxGridUpdateLocker noUpdates(m_grid);
2766 m_grid-AppendColumn();
2767 ... many other operations with m_grid...
2770 // destructor called, grid refreshed
2774 Using this class is easier and safer than calling
2775 wxGrid::BeginBatch and wxGrid::EndBatch
2776 because you don't risk not to call the latter (due to an exception for example).
2781 class wxGridUpdateLocker
2785 Creates an object preventing the updates of the specified @e grid. The
2786 parameter could be @NULL in which case nothing is done. If @a grid is
2787 non-@NULL then the grid must exist for longer than wxGridUpdateLocker object
2789 The default constructor could be followed by a call to
2793 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
2796 Destructor reenables updates for the grid this object is associated with.
2798 ~wxGridUpdateLocker();
2801 This method can be called if the object had been constructed using the default
2802 constructor. It must not be called more than once.
2804 void Create(wxGrid
* grid
);