1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxGridCellFloatRenderer class
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.
19 wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer,
20 wxGridCellBoolRenderer
22 class wxGridCellFloatRenderer
: public wxGridCellStringRenderer
27 Minimum number of characters to be shown.
30 Number of digits after the decimal dot.
32 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
35 Returns the precision ( see @ref constr() wxGridCellFloatRenderer ).
40 Returns the width ( see @ref constr() wxGridCellFloatRenderer ).
45 Parameters string format is "width[,precision]".
47 void SetParameters(const wxString
& params
);
50 Sets the precision ( see @ref constr() wxGridCellFloatRenderer ).
52 void SetPrecision(int precision
);
55 Sets the width ( see @ref constr() wxGridCellFloatRenderer )
57 void SetWidth(int width
);
62 @class wxGridTableBase
70 class wxGridTableBase
: public wxObject
86 bool AppendCols(size_t numCols
= 1);
91 bool AppendRows(size_t numRows
= 1);
96 bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
99 Does this table allow attributes? Default implementation creates
100 a wxGridCellAttrProvider if necessary.
102 bool CanHaveAttributes();
107 bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
117 bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
122 bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
125 by default forwarded to wxGridCellAttrProvider if any. May be
126 overridden to handle attributes directly in the table.
128 wxGridCellAttr
* GetAttr(int row
, int col
);
131 get the currently used attr provider (may be @NULL)
133 wxGridCellAttrProvider
* GetAttrProvider();
138 wxString
GetColLabelValue(int col
);
146 You must override these functions in a derived table class.
153 wxString
GetRowLabelValue(int row
);
156 Data type determination and value access.
158 wxString
GetTypeName(int row
, int col
);
163 wxString
GetValue(int row
, int col
);
168 bool GetValueAsBool(int row
, int col
);
171 For user defined types
173 void* GetValueAsCustom(int row
, int col
,
174 const wxString
& typeName
);
179 double GetValueAsDouble(int row
, int col
);
184 long GetValueAsLong(int row
, int col
);
194 bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
199 bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
204 bool IsEmptyCell(int row
, int col
);
207 these functions take ownership of the pointer
209 void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
213 give us the attr provider to use - we take ownership of the pointer
215 void SetAttrProvider(wxGridCellAttrProvider
* attrProvider
);
220 void SetColAttr(wxGridCellAttr
* attr
, int col
);
223 , @b const@e wxString)
225 void SetColLabelValue();
230 void SetRowAttr(wxGridCellAttr
* attr
, int row
);
233 , @b const@e wxString)
235 void SetRowLabelValue();
240 void SetValue(int row
, int col
, const wxString
& value
);
245 void SetValueAsBool(int row
, int col
, bool value
);
250 void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
256 void SetValueAsDouble(int row
, int col
, double value
);
261 void SetValueAsLong(int row
, int col
, long value
);
264 Overriding these is optional
266 void SetView(wxGrid
* grid
);
271 void UpdateAttrCols(size_t pos
, int numCols
);
274 change row/col number in attribute if needed
276 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.
294 wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
295 wxGridCellNumberEditor, wxGridCellChoiceEditor
297 class wxGridCellEditor
306 The dtor is private because only DecRef() can delete us.
311 Fetch the value from the table and prepare the edit control
312 to begin editing. Set the focus to the edit control.
314 void BeginEdit(int row
, int col
, wxGrid
* grid
);
317 Create a new object which is the copy of this one.
319 wxGridCellEditor
* Clone();
322 Creates the actual edit control.
324 void Create(wxWindow
* parent
, wxWindowID id
,
325 wxEvtHandler
* evtHandler
);
333 Complete the editing of the current cell. Returns @true if the value has
334 changed. If necessary, the control may be destroyed.
336 bool EndEdit(int row
, int col
, wxGrid
* grid
);
339 Some types of controls on some platforms may need some help
342 void HandleReturn(wxKeyEvent
& event
);
350 Draws the part of the cell not occupied by the control: the base class
351 version just fills it with background colour from the attribute.
353 void PaintBackground(const wxRect
& rectCell
,
354 wxGridCellAttr
* attr
);
357 Reset the value in the control back to its starting value.
362 Size and position the edit control.
364 void SetSize(const wxRect
& rect
);
367 Show or hide the edit control, use the specified attributes to set
368 colours/fonts for it.
370 void Show(bool show
, wxGridCellAttr
* attr
= @NULL
);
373 If the editor is enabled by clicking on the cell, this method will be
376 void StartingClick();
379 If the editor is enabled by pressing keys on the grid,
380 this will be called to let the editor do something about
381 that first key if desired.
383 void StartingKey(wxKeyEvent
& event
);
388 @class wxGridCellTextEditor
391 The editor for string/text data.
397 wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
398 wxGridCellNumberEditor, wxGridCellChoiceEditor
400 class wxGridCellTextEditor
: public wxGridCellEditor
406 wxGridCellTextEditor();
409 The parameters string format is "n" where n is a number representing the
412 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
427 wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
428 wxGridCellBoolRenderer
430 class wxGridCellStringRenderer
: public wxGridCellRenderer
436 wxGridCellStringRenderer();
441 @class wxGridCellChoiceEditor
444 The editor for string data allowing to choose from a list of strings.
450 wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
451 wxGridCellTextEditor, wxGridCellNumberEditor
453 class wxGridCellChoiceEditor
: public wxGridCellEditor
459 Number of strings from which the user can choose.
462 An array of strings from which the user can choose.
465 If allowOthers is @true, the user can type a string not in choices array.
467 wxGridCellChoiceEditor(size_t count
= 0,
468 const wxString choices
[] = @NULL
,
469 bool allowOthers
= @
false);
470 wxGridCellChoiceEditor(const wxArrayString
& choices
,
471 bool allowOthers
= @
false);
475 Parameters string format is "item1[,item2[...,itemN]]"
477 void SetParameters(const wxString
& params
);
482 @class wxGridEditorCreatedEvent
489 class wxGridEditorCreatedEvent
: public wxCommandEvent
496 wxGridEditorCreatedEvent();
497 wxGridEditorCreatedEvent(int id
, wxEventType type
,
505 Returns the column at which the event occurred.
510 Returns the edit control.
512 wxControl
* GetControl();
515 Returns the row at which the event occurred.
520 Sets the column at which the event occurred.
522 void SetCol(int col
);
525 Sets the edit control.
527 void SetControl(wxControl
* ctrl
);
530 Sets the row at which the event occurred.
532 void SetRow(int row
);
537 @class wxGridRangeSelectEvent
544 class wxGridRangeSelectEvent
: public wxNotifyEvent
551 wxGridRangeSelectEvent();
552 wxGridRangeSelectEvent(int id
, wxEventType type
,
554 const wxGridCellCoords
& topLeft
,
555 const wxGridCellCoords
& bottomRight
,
557 bool control
= @
false,
564 Returns @true if the Alt key was down at the time of the event.
569 Returns @true if the Control key was down at the time of the event.
574 Top left corner of the rectangular area that was (de)selected.
576 wxGridCellCoords
GetBottomRightCoords();
579 Bottom row of the rectangular area that was (de)selected.
584 Left column of the rectangular area that was (de)selected.
589 Right column of the rectangular area that was (de)selected.
594 Top left corner of the rectangular area that was (de)selected.
596 wxGridCellCoords
GetTopLeftCoords();
599 Top row of the rectangular area that was (de)selected.
604 Returns @true if the Meta key was down at the time of the event.
609 Returns @true if the area was selected, @false otherwise.
614 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.
635 wxGridCellStringRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
636 wxGridCellBoolRenderer
638 class wxGridCellRenderer
644 wxGridCellRenderer
* Clone();
647 Draw the given cell on the provided DC inside the given rectangle
648 using the style specified by the attribute and the default or selected
649 state corresponding to the isSelected value.
651 This pure virtual function has a default implementation which will
652 prepare the DC using the given attribute: it will draw the rectangle
653 with the background colour from attr and set the text colour and font.
655 void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
656 const wxRect
& rect
, int row
, int col
,
660 Get the preferred size of the cell for its contents.
662 wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
668 @class wxGridCellNumberEditor
671 The editor for numeric integer data.
677 wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
678 wxGridCellTextEditor, wxGridCellChoiceEditor
680 class wxGridCellNumberEditor
: public wxGridCellTextEditor
684 Allows to specify the range for acceptable data;
685 if min == max == -1, no range checking is done
687 wxGridCellNumberEditor(int min
= -1, int max
= -1);
690 String representation of the value.
692 wxString
GetString();
695 If the return value is @true, the editor uses a wxSpinCtrl to get user input,
696 otherwise it uses a wxTextCtrl.
701 Parameters string format is "min,max".
703 void SetParameters(const wxString
& params
);
708 @class wxGridSizeEvent
711 This event class contains information about a row/column resize event.
716 class wxGridSizeEvent
: public wxNotifyEvent
724 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
728 bool control
= @
false,
735 Returns @true if the Alt key was down at the time of the event.
740 Returns @true if the Control key was down at the time of the event.
745 Position in pixels at which the event occurred.
747 wxPoint
GetPosition();
750 Row or column at that was resized.
755 Returns @true if the Meta key was down at the time of the event.
760 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.
776 wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
777 wxGridCellBoolRenderer
779 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
785 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();
825 See SetAlignment() for the returned values.
827 void GetAlignment(int* hAlign
, int* vAlign
);
832 const wxColour
GetBackgroundColour();
837 wxGridCellEditor
* GetEditor(wxGrid
* grid
, int row
, int col
);
842 const wxFont
GetFont();
847 wxGridCellRenderer
* GetRenderer(wxGrid
* grid
, int row
, int col
);
852 const wxColour
GetTextColour();
862 bool HasBackgroundColour();
882 bool HasTextColour();
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
897 Sets the alignment. @e hAlign can be one of @c wxALIGN_LEFT,
898 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @e 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
);
941 @class wxGridCellBoolRenderer
944 This class may be used to format boolean data in a cell.
951 wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
952 wxGridCellNumberRenderer
954 class wxGridCellBoolRenderer
: public wxGridCellRenderer
960 wxGridCellBoolRenderer();
968 This event class contains information about various grid events.
973 class wxGridEvent
: public wxNotifyEvent
981 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
982 int row
= -1, int col
= -1,
983 int x
= -1, int y
= -1,
985 bool control
= @
false,
992 Returns @true if the Alt key was down at the time of the event.
997 Returns @true if the Control key was down at the time of the event.
1002 Column at which the event occurred.
1007 Position in pixels at which the event occurred.
1009 wxPoint
GetPosition();
1012 Row at which the event occurred.
1017 Returns @true if the Meta key was down at the time of the event.
1022 Returns @true if the user is selecting grid cells, @false -- if
1028 Returns @true if the Shift key was down at the time of the event.
1035 @class wxGridCellFloatEditor
1038 The editor for floating point numbers data.
1044 wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
1045 wxGridCellTextEditor, wxGridCellChoiceEditor
1047 class wxGridCellFloatEditor
: public wxGridCellTextEditor
1052 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
);
1070 wxGrid and its related classes are used for displaying and editing tabular
1071 data. They provide a rich set of features for display, editing, and
1072 interacting with a variety of data sources. For simple applications, and to
1073 help you get started, wxGrid is the only class you need to refer to
1074 directly. It will set up default instances of the other classes and manage
1075 them for you. For more complex applications you can derive your own
1076 classes for custom grid views, grid data tables, cell editors and
1077 renderers. The @ref overview_gridoverview "wxGrid classes overview" has
1078 examples of simple and more complex applications, explains the
1079 relationship between the various grid classes and has a summary of the
1080 keyboard shortcuts and mouse functions provided by wxGrid.
1082 wxGrid has been greatly expanded and redesigned for wxWidgets 2.2
1083 onwards. The new grid classes are reasonably backward-compatible
1084 but there are some exceptions. There are also easier ways of doing many things
1086 the previous implementation.
1088 A wxGridTableBase class holds the actual
1089 data to be displayed by a wxGrid class. One or more wxGrid classes
1090 may act as a view for one table class.
1091 The default table class is called wxGridStringTable and
1092 holds an array of strings. An instance of such a class is created
1093 by wxGrid::CreateGrid.
1095 wxGridCellRenderer is the abstract base
1096 class for rendereing contents in a cell. The following renderers are
1098 wxGridCellStringRenderer,
1099 wxGridCellBoolRenderer,
1100 wxGridCellFloatRenderer,
1101 wxGridCellNumberRenderer. The
1102 look of a cell can be further defined using wxGridCellAttr.
1103 An object of this type may be returned by wxGridTableBase::GetAttr.
1105 wxGridCellEditor is the abstract base
1106 class for editing the value of a cell. The following editors are
1108 wxGridCellTextEditor
1109 wxGridCellBoolEditor
1110 wxGridCellChoiceEditor
1111 wxGridCellNumberEditor.
1117 @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.
1148 If you are using a derived grid table class you will need to override
1149 wxGridTableBase::AppendCols. See
1150 InsertCols() for further information.
1152 bool AppendCols(int numCols
= 1, bool updateLabels
= @
true);
1155 Appends one or more new rows to the bottom of the grid and returns @true if
1156 successful. The updateLabels argument is not used at present.
1158 If you are using a derived grid table class you will need to override
1159 wxGridTableBase::AppendRows. See
1160 InsertRows() for further information.
1162 bool AppendRows(int numRows
= 1, bool updateLabels
= @
true);
1165 Automatically sets the height and width of all rows and columns to fit their
1171 Automatically adjusts width of the column to fit its label.
1173 void AutoSizeColLabelSize(int col
);
1176 Automatically sizes the column to fit its contents. If setAsMin is @true the
1177 calculated width will
1178 also be set as the minimal width for the column.
1180 void AutoSizeColumn(int col
, bool setAsMin
= @
true);
1183 Automatically sizes all columns to fit their contents. If setAsMin is @true the
1184 calculated widths will
1185 also be set as the minimal widths for the columns.
1187 void AutoSizeColumns(bool setAsMin
= @
true);
1190 Automatically sizes the row to fit its contents. If setAsMin is @true the
1191 calculated height will
1192 also be set as the minimal height for the row.
1194 void AutoSizeRow(int row
, bool setAsMin
= @
true);
1197 Automatically adjusts height of the row to fit its label.
1199 void AutoSizeRowLabelSize(int col
);
1202 Automatically sizes all rows to fit their contents. If setAsMin is @true the
1203 calculated heights will
1204 also be set as the minimal heights for the rows.
1206 void AutoSizeRows(bool setAsMin
= @
true);
1219 SetColMinimalWidth()
1221 SetRowMinimalHeight()
1223 SetColMinimalAcceptableWidth()
1225 SetRowMinimalAcceptableHeight()
1227 GetColMinimalAcceptableWidth()
1229 GetRowMinimalAcceptableHeight()
1234 Increments the grid's batch count. When the count is greater than zero
1236 the grid is suppressed. Each call to BeginBatch must be matched by a later call
1238 EndBatch(). Code that does a lot of grid
1239 modification can be enclosed between BeginBatch and EndBatch calls to avoid
1240 screen flicker. The final EndBatch will cause the grid to be repainted.
1242 @sa wxGridUpdateLocker
1247 This function returns the rectangle that encloses the block of cells
1248 limited by TopLeft and BottomRight cell in device coords and clipped
1249 to the client size of the grid window.
1251 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
1252 const wxGridCellCoords
& bottomRight
);
1255 Returns @true if columns can be moved by dragging with the mouse. Columns can be
1257 by dragging on their labels.
1259 bool CanDragColMove();
1262 Returns @true if columns can be resized by dragging with the mouse. Columns can
1264 by dragging the edges of their labels. If grid line dragging is enabled they
1266 resized by dragging the right edge of the column in the grid cell area
1267 (see wxGrid::EnableDragGridSize).
1269 bool CanDragColSize();
1272 Return @true if the dragging of grid lines to resize rows and columns is enabled
1273 or @false otherwise.
1275 bool CanDragGridSize();
1278 Returns @true if rows can be resized by dragging with the mouse. Rows can be
1280 by dragging the edges of their labels. If grid line dragging is enabled they
1282 resized by dragging the lower edge of the row in the grid cell area
1283 (see wxGrid::EnableDragGridSize).
1285 bool CanDragRowSize();
1288 Returns @true if the in-place edit control for the current grid cell can be used
1290 @false otherwise (e.g. if the current cell is read-only).
1292 bool CanEnableCellControl();
1295 Do we have some place to store attributes in?
1297 bool CanHaveAttributes();
1312 EnableDragGridSize()
1330 Return the rectangle corresponding to the grid cell's size and position in
1334 wxRect
CellToRect(int row
, int col
);
1335 wxRect
CellToRect(const wxGridCellCoords
& coords
);
1339 Clears all data in the underlying grid table and repaints the grid. The table
1341 this function. If you are using a derived table class then you need to override
1342 wxGridTableBase::Clear for this function to have any effect.
1347 Deselects all cells that are currently selected.
1349 void ClearSelection();
1363 Creates a grid with the specified initial number of rows and columns.
1364 Call this directly after the grid constructor. When you use this
1365 function wxGrid will create and manage a simple table of string values
1366 for you. All of the grid data will be stored in memory.
1368 For applications with more complex data types or relationships, or for
1369 dealing with very large datasets, you should derive your own grid table
1370 class and pass a table object to the grid with SetTable().
1372 bool CreateGrid(int numRows
, int numCols
,
1373 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
1386 MoveCursorPageDown()
1390 MoveCursorDownBlock()
1392 MoveCursorLeftBlock()
1394 MoveCursorRightBlock()
1399 Deletes one or more columns from a grid starting at the specified position and
1401 @true if successful. The updateLabels argument is not used at present.
1403 If you are using a derived grid table class you will need to override
1404 wxGridTableBase::DeleteCols. See
1405 InsertCols() for further information.
1407 bool DeleteCols(int pos
= 0, int numCols
= 1,
1408 bool updateLabels
= @
true);
1411 Deletes one or more rows from a grid starting at the specified position and
1413 @true if successful. The updateLabels argument is not used at present.
1415 If you are using a derived grid table class you will need to override
1416 wxGridTableBase::DeleteRows. See
1417 InsertRows() for further information.
1419 bool DeleteRows(int pos
= 0, int numRows
= 1,
1420 bool updateLabels
= @
true);
1423 Disables in-place editing of grid cells.
1424 Equivalent to calling EnableCellEditControl(@false).
1426 void DisableCellEditControl();
1429 Disables column moving by dragging with the mouse. Equivalent to passing @false
1431 EnableDragColMove().
1433 void DisableDragColMove();
1436 Disables column sizing by dragging with the mouse. Equivalent to passing @false
1438 EnableDragColSize().
1440 void DisableDragColSize();
1443 Disable mouse dragging of grid lines to resize rows and columns. Equivalent to
1445 @false to EnableDragGridSize()
1447 void DisableDragGridSize();
1450 Disables row sizing by dragging with the mouse. Equivalent to passing @false to
1451 EnableDragRowSize().
1453 void DisableDragRowSize();
1456 Enables or disables in-place editing of grid cell data. The grid will issue
1458 wxEVT_GRID_EDITOR_SHOWN or wxEVT_GRID_EDITOR_HIDDEN event.
1460 void EnableCellEditControl(bool enable
= @
true);
1463 Enables or disables column moving by dragging with the mouse.
1465 void EnableDragColMove(bool enable
= @
true);
1468 Enables or disables column sizing by dragging with the mouse.
1470 void EnableDragColSize(bool enable
= @
true);
1473 Enables or disables row and column resizing by dragging gridlines with the
1476 void EnableDragGridSize(bool enable
= @
true);
1479 Enables or disables row sizing by dragging with the mouse.
1481 void EnableDragRowSize(bool enable
= @
true);
1484 If the edit argument is @false this function sets the whole grid as read-only.
1486 argument is @true the grid is set to the default state where cells may be
1488 default state you can set single grid cells and whole rows and columns to be
1491 wxGridCellAttribute::SetReadOnly. For single
1492 cells you can also use the shortcut function
1495 For more information about controlling grid cell attributes see the
1496 wxGridCellAttr cell attribute class and the
1497 @ref overview_gridoverview "wxGrid classes overview".
1499 void EnableEditing(bool edit
);
1502 Turns the drawing of grid lines on or off.
1504 void EnableGridLines(bool enable
= @
true);
1507 Decrements the grid's batch count. When the count is greater than zero
1509 the grid is suppressed. Each previous call to
1510 BeginBatch() must be matched by a later call to
1511 EndBatch. Code that does a lot of grid modification can be enclosed between
1512 BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will
1513 cause the grid to be repainted.
1515 @sa wxGridUpdateLocker
1520 Overridden wxWindow method.
1522 #define void Fit() /* implementation is private */
1525 Causes immediate repainting of the grid. Use this instead of the usual
1528 void ForceRefresh();
1531 Returns the number of times that BeginBatch() has been called
1532 without (yet) matching calls to EndBatch(). While
1533 the grid's batch count is greater than zero the display will not be updated.
1535 int GetBatchCount();
1538 Sets the arguments to the horizontal and vertical text alignment values for the
1539 grid cell at the specified location.
1541 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1544 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1546 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
);
1549 Returns the background colour of the cell at the specified location.
1551 wxColour
GetCellBackgroundColour(int row
, int col
);
1554 Returns a pointer to the editor for the cell at the specified location.
1556 See wxGridCellEditor and
1557 the @ref overview_gridoverview "wxGrid overview" for more information about
1558 cell editors and renderers.
1560 wxGridCellEditor
* GetCellEditor(int row
, int col
);
1563 Returns the font for text in the grid cell at the specified location.
1565 wxFont
GetCellFont(int row
, int col
);
1568 Returns a pointer to the renderer for the grid cell at the specified location.
1570 See wxGridCellRenderer and
1571 the @ref overview_gridoverview "wxGrid overview" for more information about
1572 cell editors and renderers.
1574 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
1577 Returns the text colour for the grid cell at the specified location.
1579 wxColour
GetCellTextColour(int row
, int col
);
1583 Returns the string contained in the cell at the specified location. For simple
1584 applications where a
1585 grid object automatically uses a default grid table of string values you use
1586 this function together
1587 with SetCellValue() to access cell values.
1589 For more complex applications where you have derived your own grid table class
1591 various data types (e.g. numeric, boolean or user-defined custom types) then
1593 function for those cells that contain string values.
1595 See wxGridTableBase::CanGetValueAs
1596 and the @ref overview_gridoverview "wxGrid overview" for more information.
1598 wxString
GetCellValue(int row
, int col
);
1599 wxString
GetCellValue(const wxGridCellCoords
& coords
);
1603 Returns the column ID of the specified column position.
1605 int GetColAt(int colPos
);
1608 Returns the pen used for vertical grid lines. This virtual function may be
1609 overridden in derived classes in order to change the appearance of individual
1610 grid lines for the given column @e col.
1612 See GetRowGridLinePen() for an example.
1614 wxPen
GetColGridLinePen(int col
);
1617 Sets the arguments to the current column label alignment values.
1619 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1622 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1624 void GetColLabelAlignment(int* horiz
, int* vert
);
1627 Returns the current height of the column labels.
1629 int GetColLabelSize();
1632 Returns the specified column label. The default grid table class provides
1634 the form A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1636 wxGridTableBase::GetColLabelValue to provide
1639 wxString
GetColLabelValue(int col
);
1644 int GetColLeft(int col
);
1647 This returns the value of the lowest column width that can be handled
1649 member SetColMinimalAcceptableWidth() for details.
1651 int GetColMinimalAcceptableWidth();
1654 Get the minimal width of the given column/row.
1656 int GetColMinimalWidth(int col
);
1659 Returns the position of the specified column.
1661 int GetColPos(int colID
);
1666 int GetColRight(int col
);
1669 Returns the width of the specified column.
1671 int GetColSize(int col
);
1674 Sets the arguments to the current default horizontal and vertical text alignment
1677 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1680 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1682 void GetDefaultCellAlignment(int* horiz
, int* vert
);
1685 Returns the current default background colour for grid cells.
1687 wxColour
GetDefaultCellBackgroundColour();
1690 Returns the current default font for grid cell text.
1692 wxFont
GetDefaultCellFont();
1695 Returns the current default colour for grid cell text.
1697 wxColour
GetDefaultCellTextColour();
1700 Returns the default height for column labels.
1702 int GetDefaultColLabelSize();
1705 Returns the current default width for grid columns.
1707 int GetDefaultColSize();
1710 Returns a pointer to the current default grid cell editor.
1712 See wxGridCellEditor and
1713 the @ref overview_gridoverview "wxGrid overview" for more information about
1714 cell editors and renderers.
1716 wxGridCellEditor
* GetDefaultEditor();
1722 wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
);
1723 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
);
1729 wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
);
1732 Returns the pen used for grid lines. This virtual function may be overridden in
1733 derived classes in order to change the appearance of grid lines. Note that
1734 currently the pen width must be 1.
1736 @sa GetColGridLinePen(), GetRowGridLinePen()
1738 wxPen
GetDefaultGridLinePen();
1741 Returns a pointer to the current default grid cell renderer.
1743 See wxGridCellRenderer and
1744 the @ref overview_gridoverview "wxGrid overview" for more information about
1745 cell editors and renderers.
1747 wxGridCellRenderer
* GetDefaultRenderer();
1752 wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
);
1757 wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
);
1760 Returns the default width for the row labels.
1762 int GetDefaultRowLabelSize();
1765 Returns the current default height for grid rows.
1767 int GetDefaultRowSize();
1770 Returns the current grid cell column position.
1772 int GetGridCursorCol();
1775 Returns the current grid cell row position.
1777 int GetGridCursorRow();
1780 Returns the colour used for grid lines.
1782 @sa GetDefaultGridLinePen()
1784 wxColour
GetGridLineColour();
1787 Returns the colour used for the background of row and column labels.
1789 wxColour
GetLabelBackgroundColour();
1792 Returns the font used for row and column labels.
1794 wxFont
GetLabelFont();
1797 Returns the colour used for row and column label text.
1799 wxColour
GetLabelTextColour();
1802 Returns the total number of grid columns (actually the number of columns in the
1806 int GetNumberCols();
1809 Returns the total number of grid rows (actually the number of rows in the
1810 underlying grid table).
1812 int GetNumberRows();
1817 wxGridCellAttr
* GetOrCreateCellAttr(int row
, int col
);
1820 Returns the pen used for horizontal grid lines. This virtual function may be
1821 overridden in derived classes in order to change the appearance of individual
1822 grid line for the given row @e row.
1826 wxPen
GetRowGridLinePen(int row
);
1829 Sets the arguments to the current row label alignment values.
1831 Horizontal alignment will be one of wxLEFT, wxCENTRE or wxRIGHT.
1833 Vertical alignment will be one of wxTOP, wxCENTRE or wxBOTTOM.
1835 void GetRowLabelAlignment(int* horiz
, int* vert
);
1838 Returns the current width of the row labels.
1840 int GetRowLabelSize();
1843 Returns the specified row label. The default grid table class provides numeric
1845 If you are using a custom grid table you can override
1846 wxGridTableBase::GetRowLabelValue to provide
1849 wxString
GetRowLabelValue(int row
);
1852 This returns the value of the lowest row width that can be handled correctly.
1854 member SetRowMinimalAcceptableHeight() for details.
1856 int GetRowMinimalAcceptableHeight();
1861 int GetRowMinimalHeight(int col
);
1864 Returns the height of the specified row.
1866 int GetRowSize(int row
);
1869 Returns the number of pixels per horizontal scroll increment. The default is 15.
1871 @sa GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
1873 int GetScrollLineX();
1876 Returns the number of pixels per vertical scroll increment. The default is 15.
1878 @sa GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
1880 int GetScrollLineY();
1883 Returns an array of singly selected cells.
1885 wxGridCellCoordsArray
GetSelectedCells();
1888 Returns an array of selected cols.
1890 wxArrayInt
GetSelectedCols();
1893 Returns an array of selected rows.
1895 wxArrayInt
GetSelectedRows();
1898 Access or update the selection fore/back colours
1900 wxColour
GetSelectionBackground();
1903 Returns an array of the bottom right corners of blocks of selected cells,
1904 see GetSelectionBlockTopLeft().
1906 wxGridCellCoordsArray
GetSelectionBlockBottomRight();
1909 Returns an array of the top left corners of blocks of selected cells,
1910 see GetSelectionBlockBottomRight().
1912 wxGridCellCoordsArray
GetSelectionBlockTopLeft();
1917 wxColour
GetSelectionForeground();
1920 Returns the current selection mode, see SetSelectionMode().
1922 wxGrid::wxGridSelectionModes
GetSelectionMode();
1925 Returns a base pointer to the current table object.
1927 wxGridTableBase
* GetTable();
1930 Returned number of whole cols visible.
1943 GetDefaultGridLinePen()
1952 Returns @true if drawing of grid lines is turned on, @false otherwise.
1954 bool GridLinesEnabled();
1957 Hides the in-place cell edit control.
1959 void HideCellEditControl();
1962 Hides the column labels by calling SetColLabelSize()
1963 with a size of 0. Show labels again by calling that method with
1964 a width greater than 0.
1966 void HideColLabels();
1969 Hides the row labels by calling SetRowLabelSize()
1970 with a size of 0. Show labels again by calling that method with
1971 a width greater than 0.
1973 void HideRowLabels();
1976 Init the m_colWidths/Rights arrays
1978 void InitColWidths();
1981 NB: @e never access m_row/col arrays directly because they are created
1982 on demand, @e always use accessor functions instead!
1984 Init the m_rowHeights/Bottoms arrays with default values.
1986 void InitRowHeights();
1989 Inserts one or more new columns into a grid with the first new column at the
1990 specified position and returns @true if successful. The updateLabels argument is
1994 The sequence of actions begins with the grid object requesting the underlying
1996 table to insert new columns. If this is successful the table notifies the grid
1998 grid updates the display. For a default grid (one where you have called
1999 wxGrid::CreateGrid) this process is automatic. If you are
2000 using a custom grid table (specified with wxGrid::SetTable)
2001 then you must override
2002 wxGridTableBase::InsertCols in your derived
2005 bool InsertCols(int pos
= 0, int numCols
= 1,
2006 bool updateLabels
= @
true);
2009 Inserts one or more new rows into a grid with the first new row at the specified
2010 position and returns @true if successful. The updateLabels argument is not used
2014 The sequence of actions begins with the grid object requesting the underlying
2016 table to insert new rows. If this is successful the table notifies the grid and
2018 grid updates the display. For a default grid (one where you have called
2019 wxGrid::CreateGrid) this process is automatic. If you are
2020 using a custom grid table (specified with wxGrid::SetTable)
2021 then you must override
2022 wxGridTableBase::InsertRows in your derived
2025 bool InsertRows(int pos
= 0, int numRows
= 1,
2026 bool updateLabels
= @
true);
2029 Returns @true if the in-place edit control is currently enabled.
2031 bool IsCellEditControlEnabled();
2034 Returns @true if the current cell has been set to read-only
2035 (see wxGrid::SetReadOnly).
2037 bool IsCurrentCellReadOnly();
2040 Returns @false if the whole grid has been set as read-only or @true otherwise.
2041 See EnableEditing() for more information about
2042 controlling the editing status of grid cells.
2048 Is this cell currently selected.
2050 bool IsInSelection(int row
, int col
);
2051 bool IsInSelection(const wxGridCellCoords
& coords
);
2055 Returns @true if the cell at the specified location can't be edited.
2056 See also IsReadOnly().
2058 bool IsReadOnly(int row
, int col
);
2061 Returns @true if there are currently rows, columns or blocks of cells selected.
2067 Returns @true if a cell is either wholly visible (the default) or at least
2069 visible in the grid window.
2071 bool IsVisible(int row
, int col
, bool wholeCellVisible
= @
true);
2072 bool IsVisible(const wxGridCellCoords
& coords
,
2073 bool wholeCellVisible
= @
true);
2078 Brings the specified cell into the visible grid cell area with minimal
2080 nothing if the cell is already visible.
2082 void MakeCellVisible(int row
, int col
);
2083 void MakeCellVisible(const wxGridCellCoords
& coords
);
2087 Moves the grid cursor down by one row. If a block of cells was previously
2089 will expand if the argument is @true or be cleared if the argument is @false.
2091 bool MoveCursorDown(bool expandSelection
);
2094 Moves the grid cursor down in the current column such that it skips to the
2096 end of a block of non-empty cells. If a block of cells was previously selected
2098 will expand if the argument is @true or be cleared if the argument is @false.
2100 bool MoveCursorDownBlock(bool expandSelection
);
2103 Moves the grid cursor left by one column. If a block of cells was previously
2105 will expand if the argument is @true or be cleared if the argument is @false.
2107 bool MoveCursorLeft(bool expandSelection
);
2110 Moves the grid cursor left in the current row such that it skips to the
2112 end of a block of non-empty cells. If a block of cells was previously selected
2114 will expand if the argument is @true or be cleared if the argument is @false.
2116 bool MoveCursorLeftBlock(bool expandSelection
);
2119 Moves the grid cursor right by one column. If a block of cells was previously
2121 will expand if the argument is @true or be cleared if the argument is @false.
2123 bool MoveCursorRight(bool expandSelection
);
2126 Moves the grid cursor right in the current row such that it skips to the
2128 end of a block of non-empty cells. If a block of cells was previously selected
2130 will expand if the argument is @true or be cleared if the argument is @false.
2132 bool MoveCursorRightBlock(bool expandSelection
);
2135 Moves the grid cursor up by one row. If a block of cells was previously
2137 will expand if the argument is @true or be cleared if the argument is @false.
2139 bool MoveCursorUp(bool expandSelection
);
2142 Moves the grid cursor up in the current column such that it skips to the
2144 end of a block of non-empty cells. If a block of cells was previously selected
2146 will expand if the argument is @true or be cleared if the argument is @false.
2148 bool MoveCursorUpBlock(bool expandSelection
);
2151 Moves the grid cursor down by some number of rows so that the previous bottom
2153 becomes the top visible row.
2155 bool MovePageDown();
2158 Moves the grid cursor up by some number of rows so that the previous top
2160 becomes the bottom visible row.
2165 Methods for a registry for mapping data types to Renderers/Editors
2167 void RegisterDataType(const wxString
& typeName
,
2168 wxGridCellRenderer
* renderer
,
2169 wxGridCellEditor
* editor
);
2180 SetUseNativeColLabels()
2194 AutoSizeRowLabelSize()
2196 AutoSizeColLabelSize()
2198 GetDefaultRowLabelSize()
2200 GetDefaultColLabelSize()
2202 SetRowLabelAlignment()
2204 SetColLabelAlignment()
2206 GetRowLabelAlignment()
2208 GetColLabelAlignment()
2212 SetLabelTextColour()
2214 SetLabelBackgroundColour()
2218 GetLabelBackgroundColour()
2220 GetLabelTextColour()
2222 SetColLabelTextOrientation()
2224 GetColLabelTextOrientation()
2229 Sets the value of the current grid cell to the current in-place edit control
2231 This is called automatically when the grid cursor moves from the current cell
2233 new cell. It is also a good idea to call this function when closing a grid since
2234 any edits to the final cell location will not be saved otherwise.
2236 void SaveEditControlValue();
2239 Selects all cells in the grid.
2245 Selects a rectangular block of cells. If addToSelected is @false then any
2246 existing selection will be
2247 deselected; if @true the column will be added to the existing selection.
2249 void SelectBlock(int topRow
, int leftCol
, int bottomRow
,
2251 bool addToSelected
= @
false);
2252 void SelectBlock(const wxGridCellCoords
& topLeft
,
2253 const wxGridCellCoords
& bottomRight
,
2254 bool addToSelected
= @
false);
2258 Selects the specified column. If addToSelected is @false then any existing
2260 deselected; if @true the column will be added to the existing selection.
2262 void SelectCol(int col
, bool addToSelected
= @
false);
2265 Selects the specified row. If addToSelected is @false then any existing
2267 deselected; if @true the row will be added to the existing selection.
2269 void SelectRow(int row
, bool addToSelected
= @
false);
2287 This function returns the rectangle that encloses the selected cells
2288 in device coords and clipped to the client size of the grid window.
2290 wxRect
SelectionToDeviceRect();
2294 Sets the horizontal and vertical alignment for grid cell text at the specified
2297 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2300 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2303 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2304 void SetCellAlignment(int align
, int row
, int col
);
2310 void SetCellBackgroundColour(int row
, int col
,
2311 const wxColour
& colour
);
2314 Sets the editor for the grid cell at the specified location.
2315 The grid will take ownership of the pointer.
2317 See wxGridCellEditor and
2318 the @ref overview_gridoverview "wxGrid overview" for more information about
2319 cell editors and renderers.
2321 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2324 Sets the font for text in the grid cell at the specified location.
2326 void SetCellFont(int row
, int col
, const wxFont
& font
);
2329 Sets the renderer for the grid cell at the specified location.
2330 The grid will take ownership of the pointer.
2332 See wxGridCellRenderer and
2333 the @ref overview_gridoverview "wxGrid overview" for more information about
2334 cell editors and renderers.
2336 void SetCellRenderer(int row
, int col
,
2337 wxGridCellRenderer
* renderer
);
2341 Sets the text colour for the grid cell at the specified location.
2343 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2344 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2345 void SetCellTextColour(const wxColour
& colour
);
2350 Sets the string value for the cell at the specified location. For simple
2351 applications where a
2352 grid object automatically uses a default grid table of string values you use
2353 this function together
2354 with GetCellValue() to access cell values.
2356 For more complex applications where you have derived your own grid table class
2358 various data types (e.g. numeric, boolean or user-defined custom types) then
2360 function for those cells that contain string values.
2362 The last form is for backward compatibility only.
2364 See wxGridTableBase::CanSetValueAs
2365 and the @ref overview_gridoverview "wxGrid overview" for more information.
2367 void SetCellValue(int row
, int col
, const wxString
& s
);
2368 void SetCellValue(const wxGridCellCoords
& coords
,
2370 void SetCellValue(const wxString
& val
, int row
, int col
);
2374 Sets the cell attributes for all cells in the specified column.
2376 For more information about controlling grid cell attributes see the
2377 wxGridCellAttr cell attribute class and the
2378 @ref overview_gridoverview "wxGrid classes overview".
2380 void SetColAttr(int col
, wxGridCellAttr
* attr
);
2383 Sets the specified column to display boolean values. wxGrid displays boolean
2384 values with a checkbox.
2386 void SetColFormatBool(int col
);
2389 Sets the specified column to display data in a custom format.
2390 See the @ref overview_gridoverview "wxGrid overview" for more information on
2392 with custom data types.
2394 void SetColFormatCustom(int col
, const wxString
& typeName
);
2397 Sets the specified column to display floating point values with the given width
2400 void SetColFormatFloat(int col
, int width
= -1,
2401 int precision
= -1);
2404 Sets the specified column to display integer values.
2406 void SetColFormatNumber(int col
);
2409 Sets the horizontal and vertical alignment of column label text.
2411 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2414 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2417 void SetColLabelAlignment(int horiz
, int vert
);
2420 Sets the height of the column labels.
2422 If @e height equals to @c wxGRID_AUTOSIZE then height is calculated
2424 so that no label is truncated. Note that this could be slow for a large table.
2426 void SetColLabelSize(int height
);
2429 Set the value for the given column label. If you are using a derived grid table
2431 override wxGridTableBase::SetColLabelValue
2432 for this to have any effect.
2434 void SetColLabelValue(int col
, const wxString
& value
);
2437 This modifies the minimum column width that can be handled correctly.
2438 Specifying a low value here
2439 allows smaller grid cells to be dealt with correctly. Specifying a value here
2440 which is much smaller
2441 than the actual minimum size will incur a performance penalty in the functions
2443 grid cell index lookup on the basis of screen coordinates.
2444 This should normally be called when creating the grid because it will not
2445 resize existing columns
2446 with sizes smaller than the value specified here.
2448 void SetColMinimalAcceptableWidth(int width
);
2451 Sets the minimal width for the specified column. This should normally be called
2452 when creating the grid
2453 because it will not resize a column that is already narrower than the minimal
2455 The width argument must be higher than the minimimal acceptable column width,
2457 GetColMinimalAcceptableWidth().
2459 void SetColMinimalWidth(int col
, int width
);
2462 Sets the position of the specified column.
2464 void SetColPos(int colID
, int newPos
);
2467 Sets the width of the specified column.
2469 This function does not refresh the grid. If you are calling it outside of a
2470 BeginBatch / EndBatch
2471 block you can use ForceRefresh() to see the changes.
2473 Automatically sizes the column to fit its contents. If setAsMin is @true the
2474 calculated width will
2475 also be set as the minimal width for the column.
2477 void SetColSize(int col
, int width
);
2480 Sets the default horizontal and vertical alignment for grid cell text.
2482 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2485 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2488 void SetDefaultCellAlignment(int horiz
, int vert
);
2491 Sets the default background colour for grid cells.
2493 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2496 Sets the default font to be used for grid cell text.
2498 void SetDefaultCellFont(const wxFont
& font
);
2501 Sets the current default colour for grid cell text.
2503 void SetDefaultCellTextColour(const wxColour
& colour
);
2506 Sets the default width for columns in the grid. This will only affect columns
2507 subsequently added to
2508 the grid unless resizeExistingCols is @true.
2510 void SetDefaultColSize(int width
,
2511 bool resizeExistingCols
= @
false);
2514 Sets the default editor for grid cells. The grid will take ownership of the
2517 See wxGridCellEditor and
2518 the @ref overview_gridoverview "wxGrid overview" for more information about
2519 cell editors and renderers.
2521 void SetDefaultEditor(wxGridCellEditor
* editor
);
2524 Sets the default renderer for grid cells. The grid will take ownership of the
2527 See wxGridCellRenderer and
2528 the @ref overview_gridoverview "wxGrid overview" for more information about
2529 cell editors and renderers.
2531 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2534 Sets the default height for rows in the grid. This will only affect rows
2536 to the grid unless resizeExistingRows is @true.
2538 void SetDefaultRowSize(int height
,
2539 bool resizeExistingRows
= @
false);
2542 Set the grid cursor to the specified cell.
2543 This function calls MakeCellVisible().
2545 void SetGridCursor(int row
, int col
);
2548 Sets the colour used to draw grid lines.
2550 void SetGridLineColour(const wxColour
& colour
);
2553 Sets the background colour for row and column labels.
2555 void SetLabelBackgroundColour(const wxColour
& colour
);
2558 Sets the font for row and column labels.
2560 void SetLabelFont(const wxFont
& font
);
2563 Sets the colour for row and column label text.
2565 void SetLabelTextColour(const wxColour
& colour
);
2568 A grid may occupy more space than needed for its rows/columns. This
2569 function allows to set how big this extra space is
2571 void SetMargins(int extraWidth
, int extraHeight
);
2574 Common part of AutoSizeColumn/Row() and GetBestSize()
2576 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= @
true);
2581 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= @
true);
2584 Makes the cell at the specified location read-only or editable.
2585 See also IsReadOnly().
2587 void SetReadOnly(int row
, int col
, bool isReadOnly
= @
true);
2590 Sets the cell attributes for all cells in the specified row.
2591 See the wxGridCellAttr class for more information
2592 about controlling cell attributes.
2594 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
2597 Sets the horizontal and vertical alignment of row label text.
2599 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2602 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2605 void SetRowLabelAlignment(int horiz
, int vert
);
2608 Sets the width of the row labels.
2610 If @e width equals @c wxGRID_AUTOSIZE then width is calculated automatically
2611 so that no label is truncated. Note that this could be slow for a large table.
2613 void SetRowLabelSize(int width
);
2616 Set the value for the given row label. If you are using a derived grid table
2618 override wxGridTableBase::SetRowLabelValue
2619 for this to have any effect.
2621 void SetRowLabelValue(int row
, const wxString
& value
);
2624 This modifies the minimum row width that can be handled correctly. Specifying a
2626 allows smaller grid cells to be dealt with correctly. Specifying a value here
2627 which is much smaller
2628 than the actual minimum size will incur a performance penalty in the functions
2630 grid cell index lookup on the basis of screen coordinates.
2631 This should normally be called when creating the grid because it will not
2632 resize existing rows
2633 with sizes smaller than the value specified here.
2635 void SetRowMinimalAcceptableHeight(int height
);
2638 Sets the minimal height for the specified row. This should normally be called
2639 when creating the grid
2640 because it will not resize a row that is already shorter than the minimal
2642 The height argument must be higher than the minimimal acceptable row height, see
2643 GetRowMinimalAcceptableHeight().
2645 void SetRowMinimalHeight(int row
, int height
);
2648 Sets the height of the specified row.
2650 This function does not refresh the grid. If you are calling it outside of a
2651 BeginBatch / EndBatch
2652 block you can use ForceRefresh() to see the changes.
2654 Automatically sizes the column to fit its contents. If setAsMin is @true the
2655 calculated width will
2656 also be set as the minimal width for the column.
2658 void SetRowSize(int row
, int height
);
2661 Sets the number of pixels per horizontal scroll increment. The default is 15.
2662 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2663 errors: setting this to 1 can help.
2665 @sa GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2667 void SetScrollLineX(int x
);
2670 Sets the number of pixels per vertical scroll increment. The default is 15.
2671 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2672 errors: setting this to 1 can help.
2674 @sa GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2676 void SetScrollLineY(int y
);
2681 void SetSelectionBackground(const wxColour
& c
);
2686 void SetSelectionForeground(const wxColour
& c
);
2689 Set the selection behaviour of the grid.
2691 @param wxGridSelectCells()
2692 The default mode where individual cells are selected.
2694 @param wxGridSelectRows()
2695 Selections will consist of whole rows.
2697 @param wxGridSelectColumns()
2698 Selections will consist of whole columns.
2700 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
2703 Passes a pointer to a custom grid table to be used by the grid. This should be
2705 after the grid constructor and before using the grid object. If takeOwnership
2707 @true then the table will be deleted by the wxGrid destructor.
2709 Use this function instead of CreateGrid() when your
2710 application involves complex or non-string data or data sets that are too large
2714 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= @
false,
2715 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
2718 Call this in order to make the column labels use a native look by using
2719 wxRenderer::DrawHeaderButton
2720 internally. There is no equivalent method for drawing row columns as
2721 there is not native look for that. This option is useful when using
2722 wxGrid for displaying tables and not as a spread-sheet.
2724 void SetUseNativeColLabels(bool native
= @
true);
2727 Displays the in-place cell edit control for the current cell.
2729 void ShowCellEditControl();
2733 The x position to evaluate.
2736 If @true, rather than returning wxNOT_FOUND, it returns either the first or last
2737 column depending on whether x is too far to the left or right respectively.
2739 int XToCol(int x
, bool clipToMinMax
= @
false);
2742 Returns the column whose right hand edge is close to the given logical x
2744 If no column edge is near to this position @c wxNOT_FOUND is returned.
2746 int XToEdgeOfCol(int x
);
2749 Returns the row whose bottom edge is close to the given logical y position.
2750 If no row edge is near to this position @c wxNOT_FOUND is returned.
2752 int YToEdgeOfRow(int y
);
2755 Returns the grid row that corresponds to the logical y coordinate. Returns
2756 @c wxNOT_FOUND if there is no row at the y position.
2763 @class wxGridCellBoolEditor
2766 The editor for boolean data.
2772 wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor,
2773 wxGridCellTextEditor, wxGridCellChoiceEditor
2775 class wxGridCellBoolEditor
: public wxGridCellEditor
2779 Default constructor.
2781 wxGridCellBoolEditor();
2784 Returns @true if the given @e value is equal to the string representation of
2785 the truth value we currently use (see
2786 wxGridCellBoolEditor::UseStringValues).
2788 static bool IsTrueValue(const wxString
& value
);
2791 , @b const wxString&@e valueFalse = _T(""))
2793 This method allows to customize the values returned by GetValue() method for
2794 the cell using this editor. By default, the default values of the arguments are
2795 used, i.e. @c "1" is returned if the cell is checked and an empty string
2796 otherwise, using this method allows to change this.
2798 static void UseStringValues();
2803 @class wxGridUpdateLocker
2806 This small class can be used to prevent wxGrid from redrawing
2807 during its lifetime by calling wxGrid::BeginBatch
2808 in its constructor and wxGrid::EndBatch in its
2809 destructor. It is typically used in a function performing several operations
2810 with a grid which would otherwise result in flicker. For example:
2815 m_grid = new wxGrid(this, ...);
2817 wxGridUpdateLocker noUpdates(m_grid);
2818 m_grid-AppendColumn();
2819 ... many other operations with m_grid...
2822 // destructor called, grid refreshed
2826 Using this class is easier and safer than calling
2827 wxGrid::BeginBatch and wxGrid::EndBatch
2828 because you don't risk not to call the latter (due to an exception for example).
2833 class wxGridUpdateLocker
2837 Creates an object preventing the updates of the specified @e grid. The
2838 parameter could be @NULL in which case nothing is done. If @e grid is
2839 non-@NULL then the grid must exist for longer than wxGridUpdateLocker object
2842 The default constructor could be followed by a call to
2846 wxGridUpdateLocker(wxGrid
* grid
= @NULL
);
2849 Destructor reenables updates for the grid this object is associated with.
2851 ~wxGridUpdateLocker();
2854 This method can be called if the object had been constructed using the default
2855 constructor. It must not be called more than once.
2857 void Create(wxGrid
* grid
);