1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGridCellFloatRenderer
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxGridCellFloatRenderer
13 This class may be used to format floating point data in a cell.
18 @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer,
19 wxGridCellBoolRenderer
21 class wxGridCellFloatRenderer
: public wxGridCellStringRenderer
26 Minimum number of characters to be shown.
28 Number of digits after the decimal dot.
30 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
33 Returns the precision ( see @ref constr() wxGridCellFloatRenderer ).
35 int GetPrecision() const;
38 Returns the width ( see @ref constr() wxGridCellFloatRenderer ).
43 Parameters string format is "width[,precision]".
45 void SetParameters(const wxString
& params
);
48 Sets the precision ( see @ref constr() wxGridCellFloatRenderer ).
50 void SetPrecision(int precision
);
53 Sets the width ( see @ref constr() wxGridCellFloatRenderer )
55 void SetWidth(int width
);
61 @class wxGridTableBase
69 class wxGridTableBase
: public wxObject
85 bool AppendCols(size_t numCols
= 1);
90 bool AppendRows(size_t numRows
= 1);
95 bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
98 Does this table allow attributes? Default implementation creates
99 a wxGridCellAttrProvider if necessary.
101 bool CanHaveAttributes();
106 bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
116 bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
121 bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
124 by default forwarded to wxGridCellAttrProvider if any. May be
125 overridden to handle attributes directly in the table.
127 wxGridCellAttr
* GetAttr(int row
, int col
);
130 get the currently used attr provider (may be @NULL)
132 wxGridCellAttrProvider
* GetAttrProvider() const;
137 wxString
GetColLabelValue(int col
);
145 You must override these functions in a derived table class.
152 wxString
GetRowLabelValue(int row
);
155 Data type determination and value access.
157 wxString
GetTypeName(int row
, int col
);
162 wxString
GetValue(int row
, int col
);
167 bool GetValueAsBool(int row
, int col
);
170 For user defined types
172 void* GetValueAsCustom(int row
, int col
,
173 const wxString
& typeName
);
178 double GetValueAsDouble(int row
, int col
);
183 long GetValueAsLong(int row
, int col
);
188 wxGrid
* GetView() const;
193 bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
198 bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
203 bool IsEmptyCell(int row
, int col
);
206 these functions take ownership of the pointer
208 void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
212 give us the attr provider to use - we take ownership of the pointer
214 void SetAttrProvider(wxGridCellAttrProvider
* attrProvider
);
219 void SetColAttr(wxGridCellAttr
* attr
, int col
);
224 void SetColLabelValue() const;
229 void SetRowAttr(wxGridCellAttr
* attr
, int row
);
234 void SetRowLabelValue() const;
239 void SetValue(int row
, int col
, const wxString
& value
);
244 void SetValueAsBool(int row
, int col
, bool value
);
249 void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
255 void SetValueAsDouble(int row
, int col
, double value
);
260 void SetValueAsLong(int row
, int col
, long value
);
263 Overriding these is optional
265 void SetView(wxGrid
* grid
);
270 void UpdateAttrCols(size_t pos
, int numCols
);
273 change row/col number in attribute if needed
275 void UpdateAttrRows(size_t pos
, int numRows
);
281 @class wxGridCellEditor
284 This class is responsible for providing and manipulating
285 the in-place edit controls for the grid. Instances of wxGridCellEditor
286 (actually, instances of derived classes since it is an abstract class) can be
287 associated with the cell attributes for individual cells, rows, columns, or
288 even for the entire grid.
293 @see wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
294 wxGridCellNumberEditor, wxGridCellChoiceEditor
296 class wxGridCellEditor
305 The dtor is private because only DecRef() can delete us.
310 Fetch the value from the table and prepare the edit control
311 to begin editing. Set the focus to the edit control.
313 void BeginEdit(int row
, int col
, wxGrid
* grid
);
316 Create a new object which is the copy of this one.
318 wxGridCellEditor
* Clone() const;
321 Creates the actual edit control.
323 void Create(wxWindow
* parent
, wxWindowID id
,
324 wxEvtHandler
* evtHandler
);
332 Complete the editing of the current cell. Returns @true if the value has
333 changed. If necessary, the control may be destroyed.
335 bool EndEdit(int row
, int col
, wxGrid
* grid
);
338 Some types of controls on some platforms may need some help
341 void HandleReturn(wxKeyEvent
& event
);
349 Draws the part of the cell not occupied by the control: the base class
350 version just fills it with background colour from the attribute.
352 void PaintBackground(const wxRect
& rectCell
,
353 wxGridCellAttr
* attr
);
356 Reset the value in the control back to its starting value.
361 Size and position the edit control.
363 void SetSize(const wxRect
& rect
);
366 Show or hide the edit control, use the specified attributes to set
367 colours/fonts for it.
369 void Show(bool show
, wxGridCellAttr
* attr
= NULL
);
372 If the editor is enabled by clicking on the cell, this method will be
375 void StartingClick();
378 If the editor is enabled by pressing keys on the grid,
379 this will be called to let the editor do something about
380 that first key if desired.
382 void StartingKey(wxKeyEvent
& event
);
388 @class wxGridCellTextEditor
391 The editor for string/text data.
396 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
397 wxGridCellNumberEditor, wxGridCellChoiceEditor
399 class wxGridCellTextEditor
: public wxGridCellEditor
405 wxGridCellTextEditor();
408 The parameters string format is "n" where n is a number representing the
411 void SetParameters(const wxString
& params
);
417 @class wxGridCellStringRenderer
420 This class may be used to format string data in a cell; it is the default
426 @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
427 wxGridCellBoolRenderer
429 class wxGridCellStringRenderer
: public wxGridCellRenderer
435 wxGridCellStringRenderer();
441 @class wxGridCellChoiceEditor
444 The editor for string data allowing to choose from a list of strings.
449 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
450 wxGridCellTextEditor, wxGridCellNumberEditor
452 class wxGridCellChoiceEditor
: public wxGridCellEditor
458 Number of strings from which the user can choose.
460 An array of strings from which the user can choose.
462 If allowOthers is @true, the user can type a string not in choices array.
464 wxGridCellChoiceEditor(size_t count
= 0,
465 const wxString choices
[] = NULL
,
466 bool allowOthers
= false);
467 wxGridCellChoiceEditor(const wxArrayString
& choices
,
468 bool allowOthers
= false);
472 Parameters string format is "item1[,item2[...,itemN]]"
474 void SetParameters(const wxString
& params
);
480 @class wxGridEditorCreatedEvent
487 class wxGridEditorCreatedEvent
: public wxCommandEvent
494 wxGridEditorCreatedEvent();
495 wxGridEditorCreatedEvent(int id
, wxEventType type
,
503 Returns the column at which the event occurred.
508 Returns the edit control.
510 wxControl
* GetControl();
513 Returns the row at which the event occurred.
518 Sets the column at which the event occurred.
520 void SetCol(int col
);
523 Sets the edit control.
525 void SetControl(wxControl
* ctrl
);
528 Sets the row at which the event occurred.
530 void SetRow(int row
);
536 @class wxGridRangeSelectEvent
543 class wxGridRangeSelectEvent
: public wxNotifyEvent
550 wxGridRangeSelectEvent();
551 wxGridRangeSelectEvent(int id
, wxEventType type
,
553 const wxGridCellCoords
& topLeft
,
554 const wxGridCellCoords
& bottomRight
,
556 bool control
= false,
563 Returns @true if the Alt key was down at the time of the event.
568 Returns @true if the Control key was down at the time of the event.
573 Top left corner of the rectangular area that was (de)selected.
575 wxGridCellCoords
GetBottomRightCoords();
578 Bottom row of the rectangular area that was (de)selected.
583 Left column of the rectangular area that was (de)selected.
588 Right column of the rectangular area that was (de)selected.
593 Top left corner of the rectangular area that was (de)selected.
595 wxGridCellCoords
GetTopLeftCoords();
598 Top row of the rectangular area that was (de)selected.
603 Returns @true if the Meta key was down at the time of the event.
608 Returns @true if the area was selected, @false otherwise.
613 Returns @true if the Shift key was down at the time of the event.
621 @class wxGridCellRenderer
624 This class is responsible for actually drawing the cell
625 in the grid. You may pass it to the wxGridCellAttr (below) to change the
626 format of one given cell or to wxGrid::SetDefaultRenderer() to change the
627 view of all cells. This is an abstract class, and you will normally use one of
629 predefined derived classes or derive your own class from it.
634 @see wxGridCellStringRenderer, wxGridCellNumberRenderer,
635 wxGridCellFloatRenderer, wxGridCellBoolRenderer
637 class wxGridCellRenderer
643 wxGridCellRenderer
* Clone() const;
646 Draw the given cell on the provided DC inside the given rectangle
647 using the style specified by the attribute and the default or selected
648 state corresponding to the isSelected value.
649 This pure virtual function has a default implementation which will
650 prepare the DC using the given attribute: it will draw the rectangle
651 with the background colour from attr and set the text colour and font.
653 void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
654 const wxRect
& rect
, int row
, int col
,
658 Get the preferred size of the cell for its contents.
660 wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
667 @class wxGridCellNumberEditor
670 The editor for numeric integer data.
675 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
676 wxGridCellTextEditor, wxGridCellChoiceEditor
678 class wxGridCellNumberEditor
: public wxGridCellTextEditor
682 Allows to specify the range for acceptable data;
683 if min == max == -1, no range checking is done
685 wxGridCellNumberEditor(int min
= -1, int max
= -1);
688 String representation of the value.
690 wxString
GetString() const;
693 If the return value is @true, the editor uses a wxSpinCtrl to get user input,
694 otherwise it uses a wxTextCtrl.
696 bool HasRange() const;
699 Parameters string format is "min,max".
701 void SetParameters(const wxString
& params
);
707 @class wxGridSizeEvent
710 This event class contains information about a row/column resize event.
715 class wxGridSizeEvent
: public wxNotifyEvent
723 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
727 bool control
= false,
734 Returns @true if the Alt key was down at the time of the event.
739 Returns @true if the Control key was down at the time of the event.
744 Position in pixels at which the event occurred.
746 wxPoint
GetPosition();
749 Row or column at that was resized.
754 Returns @true if the Meta key was down at the time of the event.
759 Returns @true if the Shift key was down at the time of the event.
767 @class wxGridCellNumberRenderer
770 This class may be used to format integer data in a cell.
775 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
776 wxGridCellBoolRenderer
778 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
784 wxGridCellNumberRenderer();
790 @class wxGridCellAttr
793 This class can be used to alter the cells' appearance in
794 the grid by changing their colour/font/... from default. An object of this
795 class may be returned by wxGridTableBase::GetAttr.
805 Constructor specifying some of the often used attributes.
808 wxGridCellAttr(const wxColour
& colText
,
809 const wxColour
& colBack
,
811 int hAlign
, int vAlign
);
815 Creates a new copy of this object.
817 wxGridCellAttr
* Clone() const;
825 See SetAlignment() for the returned values.
827 void GetAlignment(int* hAlign
, int* vAlign
) const;
832 const wxColour
GetBackgroundColour() const;
837 wxGridCellEditor
* GetEditor(wxGrid
* grid
, int row
, int col
) const;
842 const wxFont
GetFont() const;
847 wxGridCellRenderer
* GetRenderer(wxGrid
* grid
, int row
, int col
) const;
852 const wxColour
GetTextColour() const;
857 bool HasAlignment() const;
862 bool HasBackgroundColour() const;
867 bool HasEditor() const;
872 bool HasFont() const;
877 bool HasRenderer() const;
882 bool HasTextColour() const;
885 This class is ref counted: it is created with ref count of 1, so
886 calling DecRef() once will delete it. Calling IncRef() allows to lock
887 it until the matching DecRef() is called
894 bool IsReadOnly() const;
897 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
898 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one
899 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
901 void SetAlignment(int hAlign
, int vAlign
);
904 Sets the background colour.
906 void SetBackgroundColour(const wxColour
& colBack
);
911 void SetDefAttr(wxGridCellAttr
* defAttr
);
916 void SetEditor(wxGridCellEditor
* editor
);
921 void SetFont(const wxFont
& font
);
926 void SetReadOnly(bool isReadOnly
= true);
929 takes ownership of the pointer
931 void SetRenderer(wxGridCellRenderer
* renderer
);
934 Sets the text colour.
936 void SetTextColour(const wxColour
& colText
);
942 @class wxGridCellBoolRenderer
945 This class may be used to format boolean data in a cell.
951 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
952 wxGridCellNumberRenderer
954 class wxGridCellBoolRenderer
: public wxGridCellRenderer
960 wxGridCellBoolRenderer();
969 This event class contains information about various grid events.
974 class wxGridEvent
: public wxNotifyEvent
982 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
983 int row
= -1, int col
= -1,
984 int x
= -1, int y
= -1,
986 bool control
= false,
993 Returns @true if the Alt key was down at the time of the event.
998 Returns @true if the Control key was down at the time of the event.
1003 Column at which the event occurred.
1008 Position in pixels at which the event occurred.
1010 wxPoint
GetPosition();
1013 Row at which the event occurred.
1018 Returns @true if the Meta key was down at the time of the event.
1023 Returns @true if the user is selecting grid cells, @false -- if
1029 Returns @true if the Shift key was down at the time of the event.
1037 @class wxGridCellFloatEditor
1040 The editor for floating point numbers data.
1045 @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
1046 wxGridCellTextEditor, wxGridCellChoiceEditor
1048 class wxGridCellFloatEditor
: public wxGridCellTextEditor
1053 Minimum number of characters to be shown.
1055 Number of digits after the decimal dot.
1057 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
1060 Parameters string format is "width,precision"
1062 void SetParameters(const wxString
& params
);
1071 wxGrid and its related classes are used for displaying and editing tabular
1072 data. They provide a rich set of features for display, editing, and
1073 interacting with a variety of data sources. For simple applications, and to
1074 help you get started, wxGrid is the only class you need to refer to
1075 directly. It will set up default instances of the other classes and manage
1076 them for you. For more complex applications you can derive your own
1077 classes for custom grid views, grid data tables, cell editors and
1078 renderers. The @ref overview_gridoverview has
1079 examples of simple and more complex applications, explains the
1080 relationship between the various grid classes and has a summary of the
1081 keyboard shortcuts and mouse functions provided by wxGrid.
1083 wxGrid has been greatly expanded and redesigned for wxWidgets 2.2
1084 onwards. The new grid classes are reasonably backward-compatible
1085 but there are some exceptions. There are also easier ways of doing many things
1087 the previous implementation.
1089 A wxGridTableBase class holds the actual
1090 data to be displayed by a wxGrid class. One or more wxGrid classes
1091 may act as a view for one table class.
1092 The default table class is called wxGridStringTable and
1093 holds an array of strings. An instance of such a class is created
1094 by wxGrid::CreateGrid.
1096 wxGridCellRenderer is the abstract base
1097 class for rendereing contents in a cell. The following renderers are
1099 wxGridCellStringRenderer,
1100 wxGridCellBoolRenderer,
1101 wxGridCellFloatRenderer,
1102 wxGridCellNumberRenderer. The
1103 look of a cell can be further defined using wxGridCellAttr.
1104 An object of this type may be returned by wxGridTableBase::GetAttr.
1106 wxGridCellEditor is the abstract base
1107 class for editing the value of a cell. The following editors are
1109 wxGridCellTextEditor
1110 wxGridCellBoolEditor
1111 wxGridCellChoiceEditor
1112 wxGridCellNumberEditor.
1117 @see @ref overview_gridoverview "wxGrid overview"
1119 class wxGrid
: public wxScrolledWindow
1124 Constructor to create a grid object. Call either CreateGrid() or
1125 SetTable() directly after this to initialize the grid before using
1129 wxGrid(wxWindow
* parent
, wxWindowID id
,
1130 const wxPoint
& pos
= wxDefaultPosition
,
1131 const wxSize
& size
= wxDefaultSize
,
1132 long style
= wxWANTS_CHARS
,
1133 const wxString
& name
= wxPanelNameStr
);
1137 Destructor. This will also destroy the associated grid table unless you passed
1139 object to the grid and specified that the grid should not take ownership of the
1140 table (see wxGrid::SetTable).
1145 Appends one or more new columns to the right of the grid and returns @true if
1146 successful. The updateLabels argument is not used at present.
1147 If you are using a derived grid table class you will need to override
1148 wxGridTableBase::AppendCols. See
1149 InsertCols() for further information.
1151 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
1154 Appends one or more new rows to the bottom of the grid and returns @true if
1155 successful. The updateLabels argument is not used at present.
1156 If you are using a derived grid table class you will need to override
1157 wxGridTableBase::AppendRows. See
1158 InsertRows() for further information.
1160 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
1163 Automatically sets the height and width of all rows and columns to fit their
1169 Automatically adjusts width of the column to fit its label.
1171 void AutoSizeColLabelSize(int col
);
1174 Automatically sizes the column to fit its contents. If setAsMin is @true the
1175 calculated width will
1176 also be set as the minimal width for the column.
1178 void AutoSizeColumn(int col
, bool setAsMin
= true);
1181 Automatically sizes all columns to fit their contents. If setAsMin is @true the
1182 calculated widths will
1183 also be set as the minimal widths for the columns.
1185 void AutoSizeColumns(bool setAsMin
= true);
1188 Automatically sizes the row to fit its contents. If setAsMin is @true the
1189 calculated height will
1190 also be set as the minimal height for the row.
1192 void AutoSizeRow(int row
, bool setAsMin
= true);
1195 Automatically adjusts height of the row to fit its label.
1197 void AutoSizeRowLabelSize(int col
);
1200 Automatically sizes all rows to fit their contents. If setAsMin is @true the
1201 calculated heights will
1202 also be set as the minimal heights for the rows.
1204 void AutoSizeRows(bool setAsMin
= true);
1217 SetColMinimalWidth()
1219 SetRowMinimalHeight()
1221 SetColMinimalAcceptableWidth()
1223 SetRowMinimalAcceptableHeight()
1225 GetColMinimalAcceptableWidth()
1227 GetRowMinimalAcceptableHeight()
1232 Increments the grid's batch count. When the count is greater than zero
1234 the grid is suppressed. Each call to BeginBatch must be matched by a later call
1236 EndBatch(). Code that does a lot of grid
1237 modification can be enclosed between BeginBatch and EndBatch calls to avoid
1238 screen flicker. The final EndBatch will cause the grid to be repainted.
1240 @see wxGridUpdateLocker
1245 This function returns the rectangle that encloses the block of cells
1246 limited by TopLeft and BottomRight cell in device coords and clipped
1247 to the client size of the grid window.
1249 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
1250 const wxGridCellCoords
& bottomRight
) const;
1253 Returns @true if columns can be moved by dragging with the mouse. Columns can be
1255 by dragging on their labels.
1257 bool CanDragColMove() const;
1260 Returns @true if columns can be resized by dragging with the mouse. Columns can
1262 by dragging the edges of their labels. If grid line dragging is enabled they
1264 resized by dragging the right edge of the column in the grid cell area
1265 (see wxGrid::EnableDragGridSize).
1267 bool CanDragColSize() const;
1270 Return @true if the dragging of grid lines to resize rows and columns is enabled
1271 or @false otherwise.
1273 bool CanDragGridSize() const;
1276 Returns @true if rows can be resized by dragging with the mouse. Rows can be
1278 by dragging the edges of their labels. If grid line dragging is enabled they
1280 resized by dragging the lower edge of the row in the grid cell area
1281 (see wxGrid::EnableDragGridSize).
1283 bool CanDragRowSize() const;
1286 Returns @true if the in-place edit control for the current grid cell can be used
1288 @false otherwise (e.g. if the current cell is read-only).
1290 bool CanEnableCellControl() const;
1293 Do we have some place to store attributes in?
1295 bool CanHaveAttributes() const;
1310 EnableDragGridSize()
1328 Return the rectangle corresponding to the grid cell's size and position in
1332 wxRect
CellToRect(int row
, int col
) const;
1333 const wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
1337 Clears all data in the underlying grid table and repaints the grid. The table
1339 this function. If you are using a derived table class then you need to override
1340 wxGridTableBase::Clear for this function to have any effect.
1345 Deselects all cells that are currently selected.
1347 void ClearSelection();
1361 Creates a grid with the specified initial number of rows and columns.
1362 Call this directly after the grid constructor. When you use this
1363 function wxGrid will create and manage a simple table of string values
1364 for you. All of the grid data will be stored in memory.
1365 For applications with more complex data types or relationships, or for
1366 dealing with very large datasets, you should derive your own grid table
1367 class and pass a table object to the grid with SetTable().
1369 bool CreateGrid(int numRows
, int numCols
,
1370 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
1383 MoveCursorPageDown()
1387 MoveCursorDownBlock()
1389 MoveCursorLeftBlock()
1391 MoveCursorRightBlock()
1396 Deletes one or more columns from a grid starting at the specified position and
1398 @true if successful. The updateLabels argument is not used at present.
1399 If you are using a derived grid table class you will need to override
1400 wxGridTableBase::DeleteCols. See
1401 InsertCols() for further information.
1403 bool DeleteCols(int pos
= 0, int numCols
= 1,
1404 bool updateLabels
= true);
1407 Deletes one or more rows from a grid starting at the specified position and
1409 @true if successful. The updateLabels argument is not used at present.
1410 If you are using a derived grid table class you will need to override
1411 wxGridTableBase::DeleteRows. See
1412 InsertRows() for further information.
1414 bool DeleteRows(int pos
= 0, int numRows
= 1,
1415 bool updateLabels
= true);
1418 Disables in-place editing of grid cells.
1419 Equivalent to calling EnableCellEditControl(@false).
1421 void DisableCellEditControl();
1424 Disables column moving by dragging with the mouse. Equivalent to passing @false
1426 EnableDragColMove().
1428 void DisableDragColMove();
1431 Disables column sizing by dragging with the mouse. Equivalent to passing @false
1433 EnableDragColSize().
1435 void DisableDragColSize();
1438 Disable mouse dragging of grid lines to resize rows and columns. Equivalent to
1440 @false to EnableDragGridSize()
1442 void DisableDragGridSize();
1445 Disables row sizing by dragging with the mouse. Equivalent to passing @false to
1446 EnableDragRowSize().
1448 void DisableDragRowSize();
1451 Enables or disables in-place editing of grid cell data. The grid will issue
1453 wxEVT_GRID_EDITOR_SHOWN or wxEVT_GRID_EDITOR_HIDDEN event.
1455 void EnableCellEditControl(bool enable
= true);
1458 Enables or disables column moving by dragging with the mouse.
1460 void EnableDragColMove(bool enable
= true);
1463 Enables or disables column sizing by dragging with the mouse.
1465 void EnableDragColSize(bool enable
= true);
1468 Enables or disables row and column resizing by dragging gridlines with the
1471 void EnableDragGridSize(bool enable
= true);
1474 Enables or disables row sizing by dragging with the mouse.
1476 void EnableDragRowSize(bool enable
= true);
1479 If the edit argument is @false this function sets the whole grid as read-only.
1481 argument is @true the grid is set to the default state where cells may be
1483 default state you can set single grid cells and whole rows and columns to be
1486 wxGridCellAttribute::SetReadOnly. For single
1487 cells you can also use the shortcut function
1489 For more information about controlling grid cell attributes see the
1490 wxGridCellAttr cell attribute class and the
1491 @ref overview_gridoverview.
1493 void EnableEditing(bool edit
);
1496 Turns the drawing of grid lines on or off.
1498 void EnableGridLines(bool enable
= true);
1501 Decrements the grid's batch count. When the count is greater than zero
1503 the grid is suppressed. Each previous call to
1504 BeginBatch() must be matched by a later call to
1505 EndBatch. Code that does a lot of grid modification can be enclosed between
1506 BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will
1507 cause the grid to be repainted.
1509 @see wxGridUpdateLocker
1514 Overridden wxWindow method.
1519 Causes immediate repainting of the grid. Use this instead of the usual
1522 void ForceRefresh();
1525 Returns the number of times that BeginBatch() has been called
1526 without (yet) matching calls to EndBatch(). While
1527 the grid's batch count is greater than zero the display will not be updated.
1529 int GetBatchCount() const;
1532 Sets the arguments to the horizontal and vertical text alignment values for the
1533 grid cell at the specified location.
1534 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1537 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1539 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
1542 Returns the background colour of the cell at the specified location.
1544 wxColour
GetCellBackgroundColour(int row
, int col
) const;
1547 Returns a pointer to the editor for the cell at the specified location.
1548 See wxGridCellEditor and
1549 the @ref overview_gridoverview "wxGrid overview" for more information about
1550 cell editors and renderers.
1552 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
1555 Returns the font for text in the grid cell at the specified location.
1557 wxFont
GetCellFont(int row
, int col
) const;
1560 Returns a pointer to the renderer for the grid cell at the specified location.
1561 See wxGridCellRenderer and
1562 the @ref overview_gridoverview "wxGrid overview" for more information about
1563 cell editors and renderers.
1565 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
1568 Returns the text colour for the grid cell at the specified location.
1570 wxColour
GetCellTextColour(int row
, int col
) const;
1574 Returns the string contained in the cell at the specified location. For simple
1575 applications where a
1576 grid object automatically uses a default grid table of string values you use
1577 this function together
1578 with SetCellValue() to access cell values.
1579 For more complex applications where you have derived your own grid table class
1581 various data types (e.g. numeric, boolean or user-defined custom types) then
1583 function for those cells that contain string values.
1584 See wxGridTableBase::CanGetValueAs
1585 and the @ref overview_gridoverview "wxGrid overview" for more information.
1587 wxString
GetCellValue(int row
, int col
) const;
1588 const wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
1592 Returns the column ID of the specified column position.
1594 int GetColAt(int colPos
) const;
1597 Returns the pen used for vertical grid lines. This virtual function may be
1598 overridden in derived classes in order to change the appearance of individual
1599 grid lines for the given column @e col.
1600 See GetRowGridLinePen() for an example.
1602 wxPen
GetColGridLinePen(int col
);
1605 Sets the arguments to the current column label alignment values.
1606 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1609 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1611 void GetColLabelAlignment(int* horiz
, int* vert
) const;
1614 Returns the current height of the column labels.
1616 int GetColLabelSize() const;
1619 Returns the specified column label. The default grid table class provides
1621 the form A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1623 wxGridTableBase::GetColLabelValue to provide
1626 wxString
GetColLabelValue(int col
) const;
1631 int GetColLeft(int col
) const;
1634 This returns the value of the lowest column width that can be handled
1636 member SetColMinimalAcceptableWidth() for details.
1638 int GetColMinimalAcceptableWidth() const;
1641 Get the minimal width of the given column/row.
1643 int GetColMinimalWidth(int col
) const;
1646 Returns the position of the specified column.
1648 int GetColPos(int colID
) const;
1653 int GetColRight(int col
) const;
1656 Returns the width of the specified column.
1658 int GetColSize(int col
) const;
1661 Sets the arguments to the current default horizontal and vertical text alignment
1663 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1666 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1668 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
1671 Returns the current default background colour for grid cells.
1673 wxColour
GetDefaultCellBackgroundColour() const;
1676 Returns the current default font for grid cell text.
1678 wxFont
GetDefaultCellFont() const;
1681 Returns the current default colour for grid cell text.
1683 wxColour
GetDefaultCellTextColour() const;
1686 Returns the default height for column labels.
1688 int GetDefaultColLabelSize() const;
1691 Returns the current default width for grid columns.
1693 int GetDefaultColSize() const;
1696 Returns a pointer to the current default grid cell editor.
1697 See wxGridCellEditor and
1698 the @ref overview_gridoverview "wxGrid overview" for more information about
1699 cell editors and renderers.
1701 wxGridCellEditor
* GetDefaultEditor() const;
1707 wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1708 const wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
1714 wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1717 Returns the pen used for grid lines. This virtual function may be overridden in
1718 derived classes in order to change the appearance of grid lines. Note that
1719 currently the pen width must be 1.
1721 @see GetColGridLinePen(), GetRowGridLinePen()
1723 wxPen
GetDefaultGridLinePen();
1726 Returns a pointer to the current default grid cell renderer.
1727 See wxGridCellRenderer and
1728 the @ref overview_gridoverview "wxGrid overview" for more information about
1729 cell editors and renderers.
1731 wxGridCellRenderer
* GetDefaultRenderer() const;
1736 wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1741 wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1744 Returns the default width for the row labels.
1746 int GetDefaultRowLabelSize() const;
1749 Returns the current default height for grid rows.
1751 int GetDefaultRowSize() const;
1754 Returns the current grid cell column position.
1756 int GetGridCursorCol() const;
1759 Returns the current grid cell row position.
1761 int GetGridCursorRow() const;
1764 Returns the colour used for grid lines.
1766 @see GetDefaultGridLinePen()
1768 wxColour
GetGridLineColour() const;
1771 Returns the colour used for the background of row and column labels.
1773 wxColour
GetLabelBackgroundColour() const;
1776 Returns the font used for row and column labels.
1778 wxFont
GetLabelFont() const;
1781 Returns the colour used for row and column label text.
1783 wxColour
GetLabelTextColour() const;
1786 Returns the total number of grid columns (actually the number of columns in the
1790 int GetNumberCols() const;
1793 Returns the total number of grid rows (actually the number of rows in the
1794 underlying grid table).
1796 int GetNumberRows() const;
1801 wxGridCellAttr
* GetOrCreateCellAttr(int row
, int col
) const;
1804 Returns the pen used for horizontal grid lines. This virtual function may be
1805 overridden in derived classes in order to change the appearance of individual
1806 grid line for the given row @e row.
1809 wxPen
GetRowGridLinePen(int row
);
1812 Sets the arguments to the current row label alignment values.
1813 Horizontal alignment will be one of wxLEFT, wxCENTRE or wxRIGHT.
1815 Vertical alignment will be one of wxTOP, wxCENTRE or wxBOTTOM.
1817 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
1820 Returns the current width of the row labels.
1822 int GetRowLabelSize() const;
1825 Returns the specified row label. The default grid table class provides numeric
1827 If you are using a custom grid table you can override
1828 wxGridTableBase::GetRowLabelValue to provide
1831 wxString
GetRowLabelValue(int row
) const;
1834 This returns the value of the lowest row width that can be handled correctly.
1836 member SetRowMinimalAcceptableHeight() for details.
1838 int GetRowMinimalAcceptableHeight() const;
1843 int GetRowMinimalHeight(int col
) const;
1846 Returns the height of the specified row.
1848 int GetRowSize(int row
) const;
1851 Returns the number of pixels per horizontal scroll increment. The default is 15.
1853 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
1855 int GetScrollLineX() const;
1858 Returns the number of pixels per vertical scroll increment. The default is 15.
1860 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
1862 int GetScrollLineY() const;
1865 Returns an array of singly selected cells.
1867 wxGridCellCoordsArray
GetSelectedCells() const;
1870 Returns an array of selected cols.
1872 wxArrayInt
GetSelectedCols() const;
1875 Returns an array of selected rows.
1877 wxArrayInt
GetSelectedRows() const;
1880 Access or update the selection fore/back colours
1882 wxColour
GetSelectionBackground() const;
1885 Returns an array of the bottom right corners of blocks of selected cells,
1886 see GetSelectionBlockTopLeft().
1888 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1891 Returns an array of the top left corners of blocks of selected cells,
1892 see GetSelectionBlockBottomRight().
1894 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1899 wxColour
GetSelectionForeground() const;
1902 Returns the current selection mode, see SetSelectionMode().
1904 wxGrid::wxGridSelectionModes
GetSelectionMode() const;
1907 Returns a base pointer to the current table object.
1909 wxGridTableBase
* GetTable() const;
1912 Returned number of whole cols visible.
1914 int GetViewWidth() const;
1925 GetDefaultGridLinePen()
1934 Returns @true if drawing of grid lines is turned on, @false otherwise.
1936 bool GridLinesEnabled() const;
1939 Hides the in-place cell edit control.
1941 void HideCellEditControl();
1944 Hides the column labels by calling SetColLabelSize()
1945 with a size of 0. Show labels again by calling that method with
1946 a width greater than 0.
1948 void HideColLabels();
1951 Hides the row labels by calling SetRowLabelSize()
1952 with a size of 0. Show labels again by calling that method with
1953 a width greater than 0.
1955 void HideRowLabels();
1958 Init the m_colWidths/Rights arrays
1960 void InitColWidths();
1963 @note @e never access m_row/col arrays directly because they are created
1964 on demand, @e always use accessor functions instead!
1965 Init the m_rowHeights/Bottoms arrays with default values.
1967 void InitRowHeights();
1970 Inserts one or more new columns into a grid with the first new column at the
1971 specified position and returns @true if successful. The updateLabels argument is
1974 The sequence of actions begins with the grid object requesting the underlying
1976 table to insert new columns. If this is successful the table notifies the grid
1978 grid updates the display. For a default grid (one where you have called
1979 wxGrid::CreateGrid) this process is automatic. If you are
1980 using a custom grid table (specified with wxGrid::SetTable)
1981 then you must override
1982 wxGridTableBase::InsertCols in your derived
1985 bool InsertCols(int pos
= 0, int numCols
= 1,
1986 bool updateLabels
= true);
1989 Inserts one or more new rows into a grid with the first new row at the specified
1990 position and returns @true if successful. The updateLabels argument is not used
1993 The sequence of actions begins with the grid object requesting the underlying
1995 table to insert new rows. If this is successful the table notifies the grid and
1997 grid updates the display. For a default grid (one where you have called
1998 wxGrid::CreateGrid) this process is automatic. If you are
1999 using a custom grid table (specified with wxGrid::SetTable)
2000 then you must override
2001 wxGridTableBase::InsertRows in your derived
2004 bool InsertRows(int pos
= 0, int numRows
= 1,
2005 bool updateLabels
= true);
2008 Returns @true if the in-place edit control is currently enabled.
2010 bool IsCellEditControlEnabled() const;
2013 Returns @true if the current cell has been set to read-only
2014 (see wxGrid::SetReadOnly).
2016 bool IsCurrentCellReadOnly() const;
2019 Returns @false if the whole grid has been set as read-only or @true otherwise.
2020 See EnableEditing() for more information about
2021 controlling the editing status of grid cells.
2023 bool IsEditable() const;
2027 Is this cell currently selected.
2029 bool IsInSelection(int row
, int col
) const;
2030 const bool IsInSelection(const wxGridCellCoords
& coords
) const;
2034 Returns @true if the cell at the specified location can't be edited.
2035 See also IsReadOnly().
2037 bool IsReadOnly(int row
, int col
) const;
2040 Returns @true if there are currently rows, columns or blocks of cells selected.
2042 bool IsSelection() const;
2046 Returns @true if a cell is either wholly visible (the default) or at least
2048 visible in the grid window.
2050 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
2051 const bool IsVisible(const wxGridCellCoords
& coords
,
2052 bool wholeCellVisible
= true) const;
2057 Brings the specified cell into the visible grid cell area with minimal
2059 nothing if the cell is already visible.
2061 void MakeCellVisible(int row
, int col
);
2062 void MakeCellVisible(const wxGridCellCoords
& coords
);
2066 Moves the grid cursor down by one row. If a block of cells was previously
2068 will expand if the argument is @true or be cleared if the argument is @false.
2070 bool MoveCursorDown(bool expandSelection
);
2073 Moves the grid cursor down in the current column such that it skips to the
2075 end of a block of non-empty cells. If a block of cells was previously selected
2077 will expand if the argument is @true or be cleared if the argument is @false.
2079 bool MoveCursorDownBlock(bool expandSelection
);
2082 Moves the grid cursor left by one column. If a block of cells was previously
2084 will expand if the argument is @true or be cleared if the argument is @false.
2086 bool MoveCursorLeft(bool expandSelection
);
2089 Moves the grid cursor left in the current row such that it skips to the
2091 end of a block of non-empty cells. If a block of cells was previously selected
2093 will expand if the argument is @true or be cleared if the argument is @false.
2095 bool MoveCursorLeftBlock(bool expandSelection
);
2098 Moves the grid cursor right by one column. If a block of cells was previously
2100 will expand if the argument is @true or be cleared if the argument is @false.
2102 bool MoveCursorRight(bool expandSelection
);
2105 Moves the grid cursor right in the current row such that it skips to the
2107 end of a block of non-empty cells. If a block of cells was previously selected
2109 will expand if the argument is @true or be cleared if the argument is @false.
2111 bool MoveCursorRightBlock(bool expandSelection
);
2114 Moves the grid cursor up by one row. If a block of cells was previously
2116 will expand if the argument is @true or be cleared if the argument is @false.
2118 bool MoveCursorUp(bool expandSelection
);
2121 Moves the grid cursor up in the current column such that it skips to the
2123 end of a block of non-empty cells. If a block of cells was previously selected
2125 will expand if the argument is @true or be cleared if the argument is @false.
2127 bool MoveCursorUpBlock(bool expandSelection
);
2130 Moves the grid cursor down by some number of rows so that the previous bottom
2132 becomes the top visible row.
2134 bool MovePageDown();
2137 Moves the grid cursor up by some number of rows so that the previous top
2139 becomes the bottom visible row.
2144 Methods for a registry for mapping data types to Renderers/Editors
2146 void RegisterDataType(const wxString
& typeName
,
2147 wxGridCellRenderer
* renderer
,
2148 wxGridCellEditor
* editor
);
2159 SetUseNativeColLabels()
2173 AutoSizeRowLabelSize()
2175 AutoSizeColLabelSize()
2177 GetDefaultRowLabelSize()
2179 GetDefaultColLabelSize()
2181 SetRowLabelAlignment()
2183 SetColLabelAlignment()
2185 GetRowLabelAlignment()
2187 GetColLabelAlignment()
2191 SetLabelTextColour()
2193 SetLabelBackgroundColour()
2197 GetLabelBackgroundColour()
2199 GetLabelTextColour()
2201 SetColLabelTextOrientation()
2203 GetColLabelTextOrientation()
2208 Sets the value of the current grid cell to the current in-place edit control
2210 This is called automatically when the grid cursor moves from the current cell
2212 new cell. It is also a good idea to call this function when closing a grid since
2213 any edits to the final cell location will not be saved otherwise.
2215 void SaveEditControlValue();
2218 Selects all cells in the grid.
2224 Selects a rectangular block of cells. If addToSelected is @false then any
2225 existing selection will be
2226 deselected; if @true the column will be added to the existing selection.
2228 void SelectBlock(int topRow
, int leftCol
, int bottomRow
,
2230 bool addToSelected
= false);
2231 void SelectBlock(const wxGridCellCoords
& topLeft
,
2232 const wxGridCellCoords
& bottomRight
,
2233 bool addToSelected
= false);
2237 Selects the specified column. If addToSelected is @false then any existing
2239 deselected; if @true the column will be added to the existing selection.
2241 void SelectCol(int col
, bool addToSelected
= false);
2244 Selects the specified row. If addToSelected is @false then any existing
2246 deselected; if @true the row will be added to the existing selection.
2248 void SelectRow(int row
, bool addToSelected
= false);
2266 This function returns the rectangle that encloses the selected cells
2267 in device coords and clipped to the client size of the grid window.
2269 wxRect
SelectionToDeviceRect() const;
2273 Sets the horizontal and vertical alignment for grid cell text at the specified
2275 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2278 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2281 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2282 void SetCellAlignment(int align
, int row
, int col
);
2288 void SetCellBackgroundColour(int row
, int col
,
2289 const wxColour
& colour
);
2292 Sets the editor for the grid cell at the specified location.
2293 The grid will take ownership of the pointer.
2294 See wxGridCellEditor and
2295 the @ref overview_gridoverview "wxGrid overview" for more information about
2296 cell editors and renderers.
2298 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2301 Sets the font for text in the grid cell at the specified location.
2303 void SetCellFont(int row
, int col
, const wxFont
& font
);
2306 Sets the renderer for the grid cell at the specified location.
2307 The grid will take ownership of the pointer.
2308 See wxGridCellRenderer and
2309 the @ref overview_gridoverview "wxGrid overview" for more information about
2310 cell editors and renderers.
2312 void SetCellRenderer(int row
, int col
,
2313 wxGridCellRenderer
* renderer
);
2317 Sets the text colour for the grid cell at the specified location.
2319 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2320 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2321 void SetCellTextColour(const wxColour
& colour
);
2326 Sets the string value for the cell at the specified location. For simple
2327 applications where a
2328 grid object automatically uses a default grid table of string values you use
2329 this function together
2330 with GetCellValue() to access cell values.
2331 For more complex applications where you have derived your own grid table class
2333 various data types (e.g. numeric, boolean or user-defined custom types) then
2335 function for those cells that contain string values.
2336 The last form is for backward compatibility only.
2337 See wxGridTableBase::CanSetValueAs
2338 and the @ref overview_gridoverview "wxGrid overview" for more information.
2340 void SetCellValue(int row
, int col
, const wxString
& s
);
2341 void SetCellValue(const wxGridCellCoords
& coords
,
2343 void SetCellValue(const wxString
& val
, int row
, int col
);
2347 Sets the cell attributes for all cells in the specified column.
2348 For more information about controlling grid cell attributes see the
2349 wxGridCellAttr cell attribute class and the
2350 @ref overview_gridoverview.
2352 void SetColAttr(int col
, wxGridCellAttr
* attr
);
2355 Sets the specified column to display boolean values. wxGrid displays boolean
2356 values with a checkbox.
2358 void SetColFormatBool(int col
);
2361 Sets the specified column to display data in a custom format.
2362 See the @ref overview_gridoverview "wxGrid overview" for more information on
2364 with custom data types.
2366 void SetColFormatCustom(int col
, const wxString
& typeName
);
2369 Sets the specified column to display floating point values with the given width
2372 void SetColFormatFloat(int col
, int width
= -1,
2373 int precision
= -1);
2376 Sets the specified column to display integer values.
2378 void SetColFormatNumber(int col
);
2381 Sets the horizontal and vertical alignment of column label text.
2382 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2384 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2387 void SetColLabelAlignment(int horiz
, int vert
);
2390 Sets the height of the column labels.
2391 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
2393 so that no label is truncated. Note that this could be slow for a large table.
2395 void SetColLabelSize(int height
);
2398 Set the value for the given column label. If you are using a derived grid table
2400 override wxGridTableBase::SetColLabelValue
2401 for this to have any effect.
2403 void SetColLabelValue(int col
, const wxString
& value
);
2406 This modifies the minimum column width that can be handled correctly.
2407 Specifying a low value here
2408 allows smaller grid cells to be dealt with correctly. Specifying a value here
2409 which is much smaller
2410 than the actual minimum size will incur a performance penalty in the functions
2412 grid cell index lookup on the basis of screen coordinates.
2413 This should normally be called when creating the grid because it will not
2414 resize existing columns
2415 with sizes smaller than the value specified here.
2417 void SetColMinimalAcceptableWidth(int width
);
2420 Sets the minimal width for the specified column. This should normally be called
2421 when creating the grid
2422 because it will not resize a column that is already narrower than the minimal
2424 The width argument must be higher than the minimimal acceptable column width,
2426 GetColMinimalAcceptableWidth().
2428 void SetColMinimalWidth(int col
, int width
);
2431 Sets the position of the specified column.
2433 void SetColPos(int colID
, int newPos
);
2436 Sets the width of the specified column.
2437 This function does not refresh the grid. If you are calling it outside of a
2438 BeginBatch / EndBatch
2439 block you can use ForceRefresh() to see the changes.
2440 Automatically sizes the column to fit its contents. If setAsMin is @true the
2441 calculated width will
2442 also be set as the minimal width for the column.
2444 void SetColSize(int col
, int width
);
2447 Sets the default horizontal and vertical alignment for grid cell text.
2448 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2450 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2453 void SetDefaultCellAlignment(int horiz
, int vert
);
2456 Sets the default background colour for grid cells.
2458 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2461 Sets the default font to be used for grid cell text.
2463 void SetDefaultCellFont(const wxFont
& font
);
2466 Sets the current default colour for grid cell text.
2468 void SetDefaultCellTextColour(const wxColour
& colour
);
2471 Sets the default width for columns in the grid. This will only affect columns
2472 subsequently added to
2473 the grid unless resizeExistingCols is @true.
2475 void SetDefaultColSize(int width
,
2476 bool resizeExistingCols
= false);
2479 Sets the default editor for grid cells. The grid will take ownership of the
2481 See wxGridCellEditor and
2482 the @ref overview_gridoverview "wxGrid overview" for more information about
2483 cell editors and renderers.
2485 void SetDefaultEditor(wxGridCellEditor
* editor
);
2488 Sets the default renderer for grid cells. The grid will take ownership of the
2490 See wxGridCellRenderer and
2491 the @ref overview_gridoverview "wxGrid overview" for more information about
2492 cell editors and renderers.
2494 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2497 Sets the default height for rows in the grid. This will only affect rows
2499 to the grid unless resizeExistingRows is @true.
2501 void SetDefaultRowSize(int height
,
2502 bool resizeExistingRows
= false);
2505 Set the grid cursor to the specified cell.
2506 This function calls MakeCellVisible().
2508 void SetGridCursor(int row
, int col
);
2511 Sets the colour used to draw grid lines.
2513 void SetGridLineColour(const wxColour
& colour
);
2516 Sets the background colour for row and column labels.
2518 void SetLabelBackgroundColour(const wxColour
& colour
);
2521 Sets the font for row and column labels.
2523 void SetLabelFont(const wxFont
& font
);
2526 Sets the colour for row and column label text.
2528 void SetLabelTextColour(const wxColour
& colour
);
2531 A grid may occupy more space than needed for its rows/columns. This
2532 function allows to set how big this extra space is
2534 void SetMargins(int extraWidth
, int extraHeight
);
2537 Common part of AutoSizeColumn/Row() and GetBestSize()
2539 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= true);
2544 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= true);
2547 Makes the cell at the specified location read-only or editable.
2548 See also IsReadOnly().
2550 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2553 Sets the cell attributes for all cells in the specified row.
2554 See the wxGridCellAttr class for more information
2555 about controlling cell attributes.
2557 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
2560 Sets the horizontal and vertical alignment of row label text.
2561 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2563 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2566 void SetRowLabelAlignment(int horiz
, int vert
);
2569 Sets the width of the row labels.
2570 If @a width equals @c wxGRID_AUTOSIZE then width is calculated automatically
2571 so that no label is truncated. Note that this could be slow for a large table.
2573 void SetRowLabelSize(int width
);
2576 Set the value for the given row label. If you are using a derived grid table
2578 override wxGridTableBase::SetRowLabelValue
2579 for this to have any effect.
2581 void SetRowLabelValue(int row
, const wxString
& value
);
2584 This modifies the minimum row width that can be handled correctly. Specifying a
2586 allows smaller grid cells to be dealt with correctly. Specifying a value here
2587 which is much smaller
2588 than the actual minimum size will incur a performance penalty in the functions
2590 grid cell index lookup on the basis of screen coordinates.
2591 This should normally be called when creating the grid because it will not
2592 resize existing rows
2593 with sizes smaller than the value specified here.
2595 void SetRowMinimalAcceptableHeight(int height
);
2598 Sets the minimal height for the specified row. This should normally be called
2599 when creating the grid
2600 because it will not resize a row that is already shorter than the minimal
2602 The height argument must be higher than the minimimal acceptable row height, see
2603 GetRowMinimalAcceptableHeight().
2605 void SetRowMinimalHeight(int row
, int height
);
2608 Sets the height of the specified row.
2609 This function does not refresh the grid. If you are calling it outside of a
2610 BeginBatch / EndBatch
2611 block you can use ForceRefresh() to see the changes.
2612 Automatically sizes the column to fit its contents. If setAsMin is @true the
2613 calculated width will
2614 also be set as the minimal width for the column.
2616 void SetRowSize(int row
, int height
);
2619 Sets the number of pixels per horizontal scroll increment. The default is 15.
2620 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2621 errors: setting this to 1 can help.
2623 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2625 void SetScrollLineX(int x
);
2628 Sets the number of pixels per vertical scroll increment. The default is 15.
2629 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2630 errors: setting this to 1 can help.
2632 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2634 void SetScrollLineY(int y
);
2639 void SetSelectionBackground(const wxColour
& c
);
2644 void SetSelectionForeground(const wxColour
& c
);
2647 Set the selection behaviour of the grid.
2649 @param wxGridSelectCells()
2650 The default mode where individual cells are selected.
2651 @param wxGridSelectRows()
2652 Selections will consist of whole rows.
2653 @param wxGridSelectColumns()
2654 Selections will consist of whole columns.
2656 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
2659 Passes a pointer to a custom grid table to be used by the grid. This should be
2661 after the grid constructor and before using the grid object. If takeOwnership
2663 @true then the table will be deleted by the wxGrid destructor.
2664 Use this function instead of CreateGrid() when your
2665 application involves complex or non-string data or data sets that are too large
2669 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= false,
2670 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
2673 Call this in order to make the column labels use a native look by using
2674 wxRenderer::DrawHeaderButton
2675 internally. There is no equivalent method for drawing row columns as
2676 there is not native look for that. This option is useful when using
2677 wxGrid for displaying tables and not as a spread-sheet.
2679 void SetUseNativeColLabels(bool native
= true);
2682 Displays the in-place cell edit control for the current cell.
2684 void ShowCellEditControl();
2688 The x position to evaluate.
2690 If @true, rather than returning wxNOT_FOUND, it returns either the first or
2691 last column depending on whether x is too far to the left or right respectively.
2693 int XToCol(int x
, bool clipToMinMax
= false) const;
2696 Returns the column whose right hand edge is close to the given logical x
2698 If no column edge is near to this position @c wxNOT_FOUND is returned.
2700 int XToEdgeOfCol(int x
) const;
2703 Returns the row whose bottom edge is close to the given logical y position.
2704 If no row edge is near to this position @c wxNOT_FOUND is returned.
2706 int YToEdgeOfRow(int y
) const;
2709 Returns the grid row that corresponds to the logical y coordinate. Returns
2710 @c wxNOT_FOUND if there is no row at the y position.
2712 int YToRow(int y
) const;
2718 @class wxGridCellBoolEditor
2721 The editor for boolean data.
2726 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor,
2727 wxGridCellTextEditor, wxGridCellChoiceEditor
2729 class wxGridCellBoolEditor
: public wxGridCellEditor
2733 Default constructor.
2735 wxGridCellBoolEditor();
2738 Returns @true if the given @a value is equal to the string representation of
2739 the truth value we currently use (see
2740 wxGridCellBoolEditor::UseStringValues).
2742 static bool IsTrueValue(const wxString
& value
);
2745 , wxString&@e valueFalse = _T(""))
2746 This method allows to customize the values returned by GetValue() method for
2747 the cell using this editor. By default, the default values of the arguments are
2748 used, i.e. @c "1" is returned if the cell is checked and an empty string
2749 otherwise, using this method allows to change this.
2751 static void UseStringValues() const;
2757 @class wxGridUpdateLocker
2760 This small class can be used to prevent wxGrid from redrawing
2761 during its lifetime by calling wxGrid::BeginBatch
2762 in its constructor and wxGrid::EndBatch in its
2763 destructor. It is typically used in a function performing several operations
2764 with a grid which would otherwise result in flicker. For example:
2769 m_grid = new wxGrid(this, ...);
2771 wxGridUpdateLocker noUpdates(m_grid);
2772 m_grid-AppendColumn();
2773 ... many other operations with m_grid...
2776 // destructor called, grid refreshed
2780 Using this class is easier and safer than calling
2781 wxGrid::BeginBatch and wxGrid::EndBatch
2782 because you don't risk not to call the latter (due to an exception for example).
2787 class wxGridUpdateLocker
2791 Creates an object preventing the updates of the specified @e grid. The
2792 parameter could be @NULL in which case nothing is done. If @a grid is
2793 non-@NULL then the grid must exist for longer than wxGridUpdateLocker object
2795 The default constructor could be followed by a call to
2799 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
2802 Destructor reenables updates for the grid this object is associated with.
2804 ~wxGridUpdateLocker();
2807 This method can be called if the object had been constructed using the default
2808 constructor. It must not be called more than once.
2810 void Create(wxGrid
* grid
);