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.
29 Number of digits after the decimal dot.
31 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
34 Returns the precision ( see @ref constr() wxGridCellFloatRenderer ).
39 Returns the width ( see @ref constr() wxGridCellFloatRenderer ).
44 Parameters string format is "width[,precision]".
46 void SetParameters(const wxString
& params
);
49 Sets the precision ( see @ref constr() wxGridCellFloatRenderer ).
51 void SetPrecision(int precision
);
54 Sets the width ( see @ref constr() wxGridCellFloatRenderer )
56 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();
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
);
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
);
222 , @b const@e wxString)
224 void SetColLabelValue();
229 void SetRowAttr(wxGridCellAttr
* attr
, int row
);
232 , @b const@e wxString)
234 void SetRowLabelValue();
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
);
280 @class wxGridCellEditor
283 This class is responsible for providing and manipulating
284 the in-place edit controls for the grid. Instances of wxGridCellEditor
285 (actually, instances of derived classes since it is an abstract class) can be
286 associated with the cell attributes for individual cells, rows, columns, or
287 even for the entire grid.
293 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();
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
);
387 @class wxGridCellTextEditor
390 The editor for string/text data.
396 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
);
416 @class wxGridCellStringRenderer
419 This class may be used to format string data in a cell; it is the default
426 wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
427 wxGridCellBoolRenderer
429 class wxGridCellStringRenderer
: public wxGridCellRenderer
435 wxGridCellStringRenderer();
440 @class wxGridCellChoiceEditor
443 The editor for string data allowing to choose from a list of strings.
449 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
);
479 @class wxGridEditorCreatedEvent
486 class wxGridEditorCreatedEvent
: public wxCommandEvent
493 wxGridEditorCreatedEvent();
494 wxGridEditorCreatedEvent(int id
, wxEventType type
,
502 Returns the column at which the event occurred.
507 Returns the edit control.
509 wxControl
* GetControl();
512 Returns the row at which the event occurred.
517 Sets the column at which the event occurred.
519 void SetCol(int col
);
522 Sets the edit control.
524 void SetControl(wxControl
* ctrl
);
527 Sets the row at which the event occurred.
529 void SetRow(int row
);
534 @class wxGridRangeSelectEvent
541 class wxGridRangeSelectEvent
: public wxNotifyEvent
548 wxGridRangeSelectEvent();
549 wxGridRangeSelectEvent(int id
, wxEventType type
,
551 const wxGridCellCoords
& topLeft
,
552 const wxGridCellCoords
& bottomRight
,
554 bool control
= false,
561 Returns @true if the Alt key was down at the time of the event.
566 Returns @true if the Control key was down at the time of the event.
571 Top left corner of the rectangular area that was (de)selected.
573 wxGridCellCoords
GetBottomRightCoords();
576 Bottom row of the rectangular area that was (de)selected.
581 Left column of the rectangular area that was (de)selected.
586 Right column of the rectangular area that was (de)selected.
591 Top left corner of the rectangular area that was (de)selected.
593 wxGridCellCoords
GetTopLeftCoords();
596 Top row of the rectangular area that was (de)selected.
601 Returns @true if the Meta key was down at the time of the event.
606 Returns @true if the area was selected, @false otherwise.
611 Returns @true if the Shift key was down at the time of the event.
618 @class wxGridCellRenderer
621 This class is responsible for actually drawing the cell
622 in the grid. You may pass it to the wxGridCellAttr (below) to change the
623 format of one given cell or to wxGrid::SetDefaultRenderer() to change the
624 view of all cells. This is an abstract class, and you will normally use one of
626 predefined derived classes or derive your own class from it.
632 wxGridCellStringRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
633 wxGridCellBoolRenderer
635 class wxGridCellRenderer
641 wxGridCellRenderer
* Clone();
644 Draw the given cell on the provided DC inside the given rectangle
645 using the style specified by the attribute and the default or selected
646 state corresponding to the isSelected value.
647 This pure virtual function has a default implementation which will
648 prepare the DC using the given attribute: it will draw the rectangle
649 with the background colour from attr and set the text colour and font.
651 void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
652 const wxRect
& rect
, int row
, int col
,
656 Get the preferred size of the cell for its contents.
658 wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
664 @class wxGridCellNumberEditor
667 The editor for numeric integer data.
673 wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
674 wxGridCellTextEditor, wxGridCellChoiceEditor
676 class wxGridCellNumberEditor
: public wxGridCellTextEditor
680 Allows to specify the range for acceptable data;
681 if min == max == -1, no range checking is done
683 wxGridCellNumberEditor(int min
= -1, int max
= -1);
686 String representation of the value.
688 wxString
GetString();
691 If the return value is @true, the editor uses a wxSpinCtrl to get user input,
692 otherwise it uses a wxTextCtrl.
697 Parameters string format is "min,max".
699 void SetParameters(const wxString
& params
);
704 @class wxGridSizeEvent
707 This event class contains information about a row/column resize event.
712 class wxGridSizeEvent
: public wxNotifyEvent
720 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
724 bool control
= false,
731 Returns @true if the Alt key was down at the time of the event.
736 Returns @true if the Control key was down at the time of the event.
741 Position in pixels at which the event occurred.
743 wxPoint
GetPosition();
746 Row or column at that was resized.
751 Returns @true if the Meta key was down at the time of the event.
756 Returns @true if the Shift key was down at the time of the event.
763 @class wxGridCellNumberRenderer
766 This class may be used to format integer data in a cell.
772 wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
773 wxGridCellBoolRenderer
775 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
781 wxGridCellNumberRenderer();
786 @class wxGridCellAttr
789 This class can be used to alter the cells' appearance in
790 the grid by changing their colour/font/... from default. An object of this
791 class may be returned by wxGridTableBase::GetAttr.
801 Constructor specifying some of the often used attributes.
804 wxGridCellAttr(const wxColour
& colText
,
805 const wxColour
& colBack
,
807 int hAlign
, int vAlign
);
811 Creates a new copy of this object.
813 wxGridCellAttr
* Clone();
821 See SetAlignment() for the returned values.
823 void GetAlignment(int* hAlign
, int* vAlign
);
828 const wxColour
GetBackgroundColour();
833 wxGridCellEditor
* GetEditor(wxGrid
* grid
, int row
, int col
);
838 const wxFont
GetFont();
843 wxGridCellRenderer
* GetRenderer(wxGrid
* grid
, int row
, int col
);
848 const wxColour
GetTextColour();
858 bool HasBackgroundColour();
878 bool HasTextColour();
881 This class is ref counted: it is created with ref count of 1, so
882 calling DecRef() once will delete it. Calling IncRef() allows to lock
883 it until the matching DecRef() is called
893 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
894 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one
895 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
897 void SetAlignment(int hAlign
, int vAlign
);
900 Sets the background colour.
902 void SetBackgroundColour(const wxColour
& colBack
);
907 void SetDefAttr(wxGridCellAttr
* defAttr
);
912 void SetEditor(wxGridCellEditor
* editor
);
917 void SetFont(const wxFont
& font
);
922 void SetReadOnly(bool isReadOnly
= true);
925 takes ownership of the pointer
927 void SetRenderer(wxGridCellRenderer
* renderer
);
930 Sets the text colour.
932 void SetTextColour(const wxColour
& colText
);
937 @class wxGridCellBoolRenderer
940 This class may be used to format boolean data in a cell.
947 wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
948 wxGridCellNumberRenderer
950 class wxGridCellBoolRenderer
: public wxGridCellRenderer
956 wxGridCellBoolRenderer();
964 This event class contains information about various grid events.
969 class wxGridEvent
: public wxNotifyEvent
977 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
978 int row
= -1, int col
= -1,
979 int x
= -1, int y
= -1,
981 bool control
= false,
988 Returns @true if the Alt key was down at the time of the event.
993 Returns @true if the Control key was down at the time of the event.
998 Column at which the event occurred.
1003 Position in pixels at which the event occurred.
1005 wxPoint
GetPosition();
1008 Row at which the event occurred.
1013 Returns @true if the Meta key was down at the time of the event.
1018 Returns @true if the user is selecting grid cells, @false -- if
1024 Returns @true if the Shift key was down at the time of the event.
1031 @class wxGridCellFloatEditor
1034 The editor for floating point numbers data.
1040 wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
1041 wxGridCellTextEditor, wxGridCellChoiceEditor
1043 class wxGridCellFloatEditor
: public wxGridCellTextEditor
1048 Minimum number of characters to be shown.
1050 Number of digits after the decimal dot.
1052 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
1055 Parameters string format is "width,precision"
1057 void SetParameters(const wxString
& params
);
1065 wxGrid and its related classes are used for displaying and editing tabular
1066 data. They provide a rich set of features for display, editing, and
1067 interacting with a variety of data sources. For simple applications, and to
1068 help you get started, wxGrid is the only class you need to refer to
1069 directly. It will set up default instances of the other classes and manage
1070 them for you. For more complex applications you can derive your own
1071 classes for custom grid views, grid data tables, cell editors and
1072 renderers. The @ref overview_gridoverview has
1073 examples of simple and more complex applications, explains the
1074 relationship between the various grid classes and has a summary of the
1075 keyboard shortcuts and mouse functions provided by wxGrid.
1077 wxGrid has been greatly expanded and redesigned for wxWidgets 2.2
1078 onwards. The new grid classes are reasonably backward-compatible
1079 but there are some exceptions. There are also easier ways of doing many things
1081 the previous implementation.
1083 A wxGridTableBase class holds the actual
1084 data to be displayed by a wxGrid class. One or more wxGrid classes
1085 may act as a view for one table class.
1086 The default table class is called wxGridStringTable and
1087 holds an array of strings. An instance of such a class is created
1088 by wxGrid::CreateGrid.
1090 wxGridCellRenderer is the abstract base
1091 class for rendereing contents in a cell. The following renderers are
1093 wxGridCellStringRenderer,
1094 wxGridCellBoolRenderer,
1095 wxGridCellFloatRenderer,
1096 wxGridCellNumberRenderer. The
1097 look of a cell can be further defined using wxGridCellAttr.
1098 An object of this type may be returned by wxGridTableBase::GetAttr.
1100 wxGridCellEditor is the abstract base
1101 class for editing the value of a cell. The following editors are
1103 wxGridCellTextEditor
1104 wxGridCellBoolEditor
1105 wxGridCellChoiceEditor
1106 wxGridCellNumberEditor.
1112 @ref overview_gridoverview "wxGrid overview"
1114 class wxGrid
: public wxScrolledWindow
1119 Constructor to create a grid object. Call either CreateGrid() or
1120 SetTable() directly after this to initialize the grid before using
1124 wxGrid(wxWindow
* parent
, wxWindowID id
,
1125 const wxPoint
& pos
= wxDefaultPosition
,
1126 const wxSize
& size
= wxDefaultSize
,
1127 long style
= wxWANTS_CHARS
,
1128 const wxString
& name
= wxPanelNameStr
);
1132 Destructor. This will also destroy the associated grid table unless you passed
1134 object to the grid and specified that the grid should not take ownership of the
1135 table (see wxGrid::SetTable).
1140 Appends one or more new columns to the right of the grid and returns @true if
1141 successful. The updateLabels argument is not used at present.
1142 If you are using a derived grid table class you will need to override
1143 wxGridTableBase::AppendCols. See
1144 InsertCols() for further information.
1146 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
1149 Appends one or more new rows to the bottom of the grid and returns @true if
1150 successful. The updateLabels argument is not used at present.
1151 If you are using a derived grid table class you will need to override
1152 wxGridTableBase::AppendRows. See
1153 InsertRows() for further information.
1155 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
1158 Automatically sets the height and width of all rows and columns to fit their
1164 Automatically adjusts width of the column to fit its label.
1166 void AutoSizeColLabelSize(int col
);
1169 Automatically sizes the column to fit its contents. If setAsMin is @true the
1170 calculated width will
1171 also be set as the minimal width for the column.
1173 void AutoSizeColumn(int col
, bool setAsMin
= true);
1176 Automatically sizes all columns to fit their contents. If setAsMin is @true the
1177 calculated widths will
1178 also be set as the minimal widths for the columns.
1180 void AutoSizeColumns(bool setAsMin
= true);
1183 Automatically sizes the row to fit its contents. If setAsMin is @true the
1184 calculated height will
1185 also be set as the minimal height for the row.
1187 void AutoSizeRow(int row
, bool setAsMin
= true);
1190 Automatically adjusts height of the row to fit its label.
1192 void AutoSizeRowLabelSize(int col
);
1195 Automatically sizes all rows to fit their contents. If setAsMin is @true the
1196 calculated heights will
1197 also be set as the minimal heights for the rows.
1199 void AutoSizeRows(bool setAsMin
= true);
1212 SetColMinimalWidth()
1214 SetRowMinimalHeight()
1216 SetColMinimalAcceptableWidth()
1218 SetRowMinimalAcceptableHeight()
1220 GetColMinimalAcceptableWidth()
1222 GetRowMinimalAcceptableHeight()
1227 Increments the grid's batch count. When the count is greater than zero
1229 the grid is suppressed. Each call to BeginBatch must be matched by a later call
1231 EndBatch(). Code that does a lot of grid
1232 modification can be enclosed between BeginBatch and EndBatch calls to avoid
1233 screen flicker. The final EndBatch will cause the grid to be repainted.
1235 @see wxGridUpdateLocker
1240 This function returns the rectangle that encloses the block of cells
1241 limited by TopLeft and BottomRight cell in device coords and clipped
1242 to the client size of the grid window.
1244 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
1245 const wxGridCellCoords
& bottomRight
);
1248 Returns @true if columns can be moved by dragging with the mouse. Columns can be
1250 by dragging on their labels.
1252 bool CanDragColMove();
1255 Returns @true if columns can be resized by dragging with the mouse. Columns can
1257 by dragging the edges of their labels. If grid line dragging is enabled they
1259 resized by dragging the right edge of the column in the grid cell area
1260 (see wxGrid::EnableDragGridSize).
1262 bool CanDragColSize();
1265 Return @true if the dragging of grid lines to resize rows and columns is enabled
1266 or @false otherwise.
1268 bool CanDragGridSize();
1271 Returns @true if rows can be resized by dragging with the mouse. Rows can be
1273 by dragging the edges of their labels. If grid line dragging is enabled they
1275 resized by dragging the lower edge of the row in the grid cell area
1276 (see wxGrid::EnableDragGridSize).
1278 bool CanDragRowSize();
1281 Returns @true if the in-place edit control for the current grid cell can be used
1283 @false otherwise (e.g. if the current cell is read-only).
1285 bool CanEnableCellControl();
1288 Do we have some place to store attributes in?
1290 bool CanHaveAttributes();
1305 EnableDragGridSize()
1323 Return the rectangle corresponding to the grid cell's size and position in
1327 wxRect
CellToRect(int row
, int col
);
1328 wxRect
CellToRect(const wxGridCellCoords
& coords
);
1332 Clears all data in the underlying grid table and repaints the grid. The table
1334 this function. If you are using a derived table class then you need to override
1335 wxGridTableBase::Clear for this function to have any effect.
1340 Deselects all cells that are currently selected.
1342 void ClearSelection();
1356 Creates a grid with the specified initial number of rows and columns.
1357 Call this directly after the grid constructor. When you use this
1358 function wxGrid will create and manage a simple table of string values
1359 for you. All of the grid data will be stored in memory.
1360 For applications with more complex data types or relationships, or for
1361 dealing with very large datasets, you should derive your own grid table
1362 class and pass a table object to the grid with SetTable().
1364 bool CreateGrid(int numRows
, int numCols
,
1365 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
1378 MoveCursorPageDown()
1382 MoveCursorDownBlock()
1384 MoveCursorLeftBlock()
1386 MoveCursorRightBlock()
1391 Deletes one or more columns from a grid starting at the specified position and
1393 @true if successful. The updateLabels argument is not used at present.
1394 If you are using a derived grid table class you will need to override
1395 wxGridTableBase::DeleteCols. See
1396 InsertCols() for further information.
1398 bool DeleteCols(int pos
= 0, int numCols
= 1,
1399 bool updateLabels
= true);
1402 Deletes one or more rows from a grid starting at the specified position and
1404 @true if successful. The updateLabels argument is not used at present.
1405 If you are using a derived grid table class you will need to override
1406 wxGridTableBase::DeleteRows. See
1407 InsertRows() for further information.
1409 bool DeleteRows(int pos
= 0, int numRows
= 1,
1410 bool updateLabels
= true);
1413 Disables in-place editing of grid cells.
1414 Equivalent to calling EnableCellEditControl(@false).
1416 void DisableCellEditControl();
1419 Disables column moving by dragging with the mouse. Equivalent to passing @false
1421 EnableDragColMove().
1423 void DisableDragColMove();
1426 Disables column sizing by dragging with the mouse. Equivalent to passing @false
1428 EnableDragColSize().
1430 void DisableDragColSize();
1433 Disable mouse dragging of grid lines to resize rows and columns. Equivalent to
1435 @false to EnableDragGridSize()
1437 void DisableDragGridSize();
1440 Disables row sizing by dragging with the mouse. Equivalent to passing @false to
1441 EnableDragRowSize().
1443 void DisableDragRowSize();
1446 Enables or disables in-place editing of grid cell data. The grid will issue
1448 wxEVT_GRID_EDITOR_SHOWN or wxEVT_GRID_EDITOR_HIDDEN event.
1450 void EnableCellEditControl(bool enable
= true);
1453 Enables or disables column moving by dragging with the mouse.
1455 void EnableDragColMove(bool enable
= true);
1458 Enables or disables column sizing by dragging with the mouse.
1460 void EnableDragColSize(bool enable
= true);
1463 Enables or disables row and column resizing by dragging gridlines with the
1466 void EnableDragGridSize(bool enable
= true);
1469 Enables or disables row sizing by dragging with the mouse.
1471 void EnableDragRowSize(bool enable
= true);
1474 If the edit argument is @false this function sets the whole grid as read-only.
1476 argument is @true the grid is set to the default state where cells may be
1478 default state you can set single grid cells and whole rows and columns to be
1481 wxGridCellAttribute::SetReadOnly. For single
1482 cells you can also use the shortcut function
1484 For more information about controlling grid cell attributes see the
1485 wxGridCellAttr cell attribute class and the
1486 @ref overview_gridoverview.
1488 void EnableEditing(bool edit
);
1491 Turns the drawing of grid lines on or off.
1493 void EnableGridLines(bool enable
= true);
1496 Decrements the grid's batch count. When the count is greater than zero
1498 the grid is suppressed. Each previous call to
1499 BeginBatch() must be matched by a later call to
1500 EndBatch. Code that does a lot of grid modification can be enclosed between
1501 BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will
1502 cause the grid to be repainted.
1504 @see wxGridUpdateLocker
1509 Overridden wxWindow method.
1514 Causes immediate repainting of the grid. Use this instead of the usual
1517 void ForceRefresh();
1520 Returns the number of times that BeginBatch() has been called
1521 without (yet) matching calls to EndBatch(). While
1522 the grid's batch count is greater than zero the display will not be updated.
1524 int GetBatchCount();
1527 Sets the arguments to the horizontal and vertical text alignment values for the
1528 grid cell at the specified location.
1529 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1532 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1534 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
);
1537 Returns the background colour of the cell at the specified location.
1539 wxColour
GetCellBackgroundColour(int row
, int col
);
1542 Returns a pointer to the editor for the cell at the specified location.
1543 See wxGridCellEditor and
1544 the @ref overview_gridoverview "wxGrid overview" for more information about
1545 cell editors and renderers.
1547 wxGridCellEditor
* GetCellEditor(int row
, int col
);
1550 Returns the font for text in the grid cell at the specified location.
1552 wxFont
GetCellFont(int row
, int col
);
1555 Returns a pointer to the renderer for the grid cell at the specified location.
1556 See wxGridCellRenderer and
1557 the @ref overview_gridoverview "wxGrid overview" for more information about
1558 cell editors and renderers.
1560 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
1563 Returns the text colour for the grid cell at the specified location.
1565 wxColour
GetCellTextColour(int row
, int col
);
1569 Returns the string contained in the cell at the specified location. For simple
1570 applications where a
1571 grid object automatically uses a default grid table of string values you use
1572 this function together
1573 with SetCellValue() to access cell values.
1574 For more complex applications where you have derived your own grid table class
1576 various data types (e.g. numeric, boolean or user-defined custom types) then
1578 function for those cells that contain string values.
1579 See wxGridTableBase::CanGetValueAs
1580 and the @ref overview_gridoverview "wxGrid overview" for more information.
1582 wxString
GetCellValue(int row
, int col
);
1583 wxString
GetCellValue(const wxGridCellCoords
& coords
);
1587 Returns the column ID of the specified column position.
1589 int GetColAt(int colPos
);
1592 Returns the pen used for vertical grid lines. This virtual function may be
1593 overridden in derived classes in order to change the appearance of individual
1594 grid lines for the given column @e col.
1595 See GetRowGridLinePen() for an example.
1597 wxPen
GetColGridLinePen(int col
);
1600 Sets the arguments to the current column label alignment values.
1601 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1604 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1606 void GetColLabelAlignment(int* horiz
, int* vert
);
1609 Returns the current height of the column labels.
1611 int GetColLabelSize();
1614 Returns the specified column label. The default grid table class provides
1616 the form A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1618 wxGridTableBase::GetColLabelValue to provide
1621 wxString
GetColLabelValue(int col
);
1626 int GetColLeft(int col
);
1629 This returns the value of the lowest column width that can be handled
1631 member SetColMinimalAcceptableWidth() for details.
1633 int GetColMinimalAcceptableWidth();
1636 Get the minimal width of the given column/row.
1638 int GetColMinimalWidth(int col
);
1641 Returns the position of the specified column.
1643 int GetColPos(int colID
);
1648 int GetColRight(int col
);
1651 Returns the width of the specified column.
1653 int GetColSize(int col
);
1656 Sets the arguments to the current default horizontal and vertical text alignment
1658 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1661 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1663 void GetDefaultCellAlignment(int* horiz
, int* vert
);
1666 Returns the current default background colour for grid cells.
1668 wxColour
GetDefaultCellBackgroundColour();
1671 Returns the current default font for grid cell text.
1673 wxFont
GetDefaultCellFont();
1676 Returns the current default colour for grid cell text.
1678 wxColour
GetDefaultCellTextColour();
1681 Returns the default height for column labels.
1683 int GetDefaultColLabelSize();
1686 Returns the current default width for grid columns.
1688 int GetDefaultColSize();
1691 Returns a pointer to the current default grid cell editor.
1692 See wxGridCellEditor and
1693 the @ref overview_gridoverview "wxGrid overview" for more information about
1694 cell editors and renderers.
1696 wxGridCellEditor
* GetDefaultEditor();
1702 wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
);
1703 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
);
1709 wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
);
1712 Returns the pen used for grid lines. This virtual function may be overridden in
1713 derived classes in order to change the appearance of grid lines. Note that
1714 currently the pen width must be 1.
1716 @see GetColGridLinePen(), GetRowGridLinePen()
1718 wxPen
GetDefaultGridLinePen();
1721 Returns a pointer to the current default grid cell renderer.
1722 See wxGridCellRenderer and
1723 the @ref overview_gridoverview "wxGrid overview" for more information about
1724 cell editors and renderers.
1726 wxGridCellRenderer
* GetDefaultRenderer();
1731 wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
);
1736 wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
);
1739 Returns the default width for the row labels.
1741 int GetDefaultRowLabelSize();
1744 Returns the current default height for grid rows.
1746 int GetDefaultRowSize();
1749 Returns the current grid cell column position.
1751 int GetGridCursorCol();
1754 Returns the current grid cell row position.
1756 int GetGridCursorRow();
1759 Returns the colour used for grid lines.
1761 @see GetDefaultGridLinePen()
1763 wxColour
GetGridLineColour();
1766 Returns the colour used for the background of row and column labels.
1768 wxColour
GetLabelBackgroundColour();
1771 Returns the font used for row and column labels.
1773 wxFont
GetLabelFont();
1776 Returns the colour used for row and column label text.
1778 wxColour
GetLabelTextColour();
1781 Returns the total number of grid columns (actually the number of columns in the
1785 int GetNumberCols();
1788 Returns the total number of grid rows (actually the number of rows in the
1789 underlying grid table).
1791 int GetNumberRows();
1796 wxGridCellAttr
* GetOrCreateCellAttr(int row
, int col
);
1799 Returns the pen used for horizontal grid lines. This virtual function may be
1800 overridden in derived classes in order to change the appearance of individual
1801 grid line for the given row @e row.
1804 wxPen
GetRowGridLinePen(int row
);
1807 Sets the arguments to the current row label alignment values.
1808 Horizontal alignment will be one of wxLEFT, wxCENTRE or wxRIGHT.
1810 Vertical alignment will be one of wxTOP, wxCENTRE or wxBOTTOM.
1812 void GetRowLabelAlignment(int* horiz
, int* vert
);
1815 Returns the current width of the row labels.
1817 int GetRowLabelSize();
1820 Returns the specified row label. The default grid table class provides numeric
1822 If you are using a custom grid table you can override
1823 wxGridTableBase::GetRowLabelValue to provide
1826 wxString
GetRowLabelValue(int row
);
1829 This returns the value of the lowest row width that can be handled correctly.
1831 member SetRowMinimalAcceptableHeight() for details.
1833 int GetRowMinimalAcceptableHeight();
1838 int GetRowMinimalHeight(int col
);
1841 Returns the height of the specified row.
1843 int GetRowSize(int row
);
1846 Returns the number of pixels per horizontal scroll increment. The default is 15.
1848 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
1850 int GetScrollLineX();
1853 Returns the number of pixels per vertical scroll increment. The default is 15.
1855 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
1857 int GetScrollLineY();
1860 Returns an array of singly selected cells.
1862 wxGridCellCoordsArray
GetSelectedCells();
1865 Returns an array of selected cols.
1867 wxArrayInt
GetSelectedCols();
1870 Returns an array of selected rows.
1872 wxArrayInt
GetSelectedRows();
1875 Access or update the selection fore/back colours
1877 wxColour
GetSelectionBackground();
1880 Returns an array of the bottom right corners of blocks of selected cells,
1881 see GetSelectionBlockTopLeft().
1883 wxGridCellCoordsArray
GetSelectionBlockBottomRight();
1886 Returns an array of the top left corners of blocks of selected cells,
1887 see GetSelectionBlockBottomRight().
1889 wxGridCellCoordsArray
GetSelectionBlockTopLeft();
1894 wxColour
GetSelectionForeground();
1897 Returns the current selection mode, see SetSelectionMode().
1899 wxGrid::wxGridSelectionModes
GetSelectionMode();
1902 Returns a base pointer to the current table object.
1904 wxGridTableBase
* GetTable();
1907 Returned number of whole cols visible.
1920 GetDefaultGridLinePen()
1929 Returns @true if drawing of grid lines is turned on, @false otherwise.
1931 bool GridLinesEnabled();
1934 Hides the in-place cell edit control.
1936 void HideCellEditControl();
1939 Hides the column labels by calling SetColLabelSize()
1940 with a size of 0. Show labels again by calling that method with
1941 a width greater than 0.
1943 void HideColLabels();
1946 Hides the row labels by calling SetRowLabelSize()
1947 with a size of 0. Show labels again by calling that method with
1948 a width greater than 0.
1950 void HideRowLabels();
1953 Init the m_colWidths/Rights arrays
1955 void InitColWidths();
1958 NB: @e never access m_row/col arrays directly because they are created
1959 on demand, @e always use accessor functions instead!
1960 Init the m_rowHeights/Bottoms arrays with default values.
1962 void InitRowHeights();
1965 Inserts one or more new columns into a grid with the first new column at the
1966 specified position and returns @true if successful. The updateLabels argument is
1969 The sequence of actions begins with the grid object requesting the underlying
1971 table to insert new columns. If this is successful the table notifies the grid
1973 grid updates the display. For a default grid (one where you have called
1974 wxGrid::CreateGrid) this process is automatic. If you are
1975 using a custom grid table (specified with wxGrid::SetTable)
1976 then you must override
1977 wxGridTableBase::InsertCols in your derived
1980 bool InsertCols(int pos
= 0, int numCols
= 1,
1981 bool updateLabels
= true);
1984 Inserts one or more new rows into a grid with the first new row at the specified
1985 position and returns @true if successful. The updateLabels argument is not used
1988 The sequence of actions begins with the grid object requesting the underlying
1990 table to insert new rows. If this is successful the table notifies the grid and
1992 grid updates the display. For a default grid (one where you have called
1993 wxGrid::CreateGrid) this process is automatic. If you are
1994 using a custom grid table (specified with wxGrid::SetTable)
1995 then you must override
1996 wxGridTableBase::InsertRows in your derived
1999 bool InsertRows(int pos
= 0, int numRows
= 1,
2000 bool updateLabels
= true);
2003 Returns @true if the in-place edit control is currently enabled.
2005 bool IsCellEditControlEnabled();
2008 Returns @true if the current cell has been set to read-only
2009 (see wxGrid::SetReadOnly).
2011 bool IsCurrentCellReadOnly();
2014 Returns @false if the whole grid has been set as read-only or @true otherwise.
2015 See EnableEditing() for more information about
2016 controlling the editing status of grid cells.
2022 Is this cell currently selected.
2024 bool IsInSelection(int row
, int col
);
2025 bool IsInSelection(const wxGridCellCoords
& coords
);
2029 Returns @true if the cell at the specified location can't be edited.
2030 See also IsReadOnly().
2032 bool IsReadOnly(int row
, int col
);
2035 Returns @true if there are currently rows, columns or blocks of cells selected.
2041 Returns @true if a cell is either wholly visible (the default) or at least
2043 visible in the grid window.
2045 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true);
2046 bool IsVisible(const wxGridCellCoords
& coords
,
2047 bool wholeCellVisible
= true);
2052 Brings the specified cell into the visible grid cell area with minimal
2054 nothing if the cell is already visible.
2056 void MakeCellVisible(int row
, int col
);
2057 void MakeCellVisible(const wxGridCellCoords
& coords
);
2061 Moves the grid cursor down by one row. If a block of cells was previously
2063 will expand if the argument is @true or be cleared if the argument is @false.
2065 bool MoveCursorDown(bool expandSelection
);
2068 Moves the grid cursor down in the current column such that it skips to the
2070 end of a block of non-empty cells. If a block of cells was previously selected
2072 will expand if the argument is @true or be cleared if the argument is @false.
2074 bool MoveCursorDownBlock(bool expandSelection
);
2077 Moves the grid cursor left by one column. If a block of cells was previously
2079 will expand if the argument is @true or be cleared if the argument is @false.
2081 bool MoveCursorLeft(bool expandSelection
);
2084 Moves the grid cursor left in the current row such that it skips to the
2086 end of a block of non-empty cells. If a block of cells was previously selected
2088 will expand if the argument is @true or be cleared if the argument is @false.
2090 bool MoveCursorLeftBlock(bool expandSelection
);
2093 Moves the grid cursor right by one column. If a block of cells was previously
2095 will expand if the argument is @true or be cleared if the argument is @false.
2097 bool MoveCursorRight(bool expandSelection
);
2100 Moves the grid cursor right in the current row such that it skips to the
2102 end of a block of non-empty cells. If a block of cells was previously selected
2104 will expand if the argument is @true or be cleared if the argument is @false.
2106 bool MoveCursorRightBlock(bool expandSelection
);
2109 Moves the grid cursor up by one row. If a block of cells was previously
2111 will expand if the argument is @true or be cleared if the argument is @false.
2113 bool MoveCursorUp(bool expandSelection
);
2116 Moves the grid cursor up in the current column such that it skips to the
2118 end of a block of non-empty cells. If a block of cells was previously selected
2120 will expand if the argument is @true or be cleared if the argument is @false.
2122 bool MoveCursorUpBlock(bool expandSelection
);
2125 Moves the grid cursor down by some number of rows so that the previous bottom
2127 becomes the top visible row.
2129 bool MovePageDown();
2132 Moves the grid cursor up by some number of rows so that the previous top
2134 becomes the bottom visible row.
2139 Methods for a registry for mapping data types to Renderers/Editors
2141 void RegisterDataType(const wxString
& typeName
,
2142 wxGridCellRenderer
* renderer
,
2143 wxGridCellEditor
* editor
);
2154 SetUseNativeColLabels()
2168 AutoSizeRowLabelSize()
2170 AutoSizeColLabelSize()
2172 GetDefaultRowLabelSize()
2174 GetDefaultColLabelSize()
2176 SetRowLabelAlignment()
2178 SetColLabelAlignment()
2180 GetRowLabelAlignment()
2182 GetColLabelAlignment()
2186 SetLabelTextColour()
2188 SetLabelBackgroundColour()
2192 GetLabelBackgroundColour()
2194 GetLabelTextColour()
2196 SetColLabelTextOrientation()
2198 GetColLabelTextOrientation()
2203 Sets the value of the current grid cell to the current in-place edit control
2205 This is called automatically when the grid cursor moves from the current cell
2207 new cell. It is also a good idea to call this function when closing a grid since
2208 any edits to the final cell location will not be saved otherwise.
2210 void SaveEditControlValue();
2213 Selects all cells in the grid.
2219 Selects a rectangular block of cells. If addToSelected is @false then any
2220 existing selection will be
2221 deselected; if @true the column will be added to the existing selection.
2223 void SelectBlock(int topRow
, int leftCol
, int bottomRow
,
2225 bool addToSelected
= false);
2226 void SelectBlock(const wxGridCellCoords
& topLeft
,
2227 const wxGridCellCoords
& bottomRight
,
2228 bool addToSelected
= false);
2232 Selects the specified column. If addToSelected is @false then any existing
2234 deselected; if @true the column will be added to the existing selection.
2236 void SelectCol(int col
, bool addToSelected
= false);
2239 Selects the specified row. If addToSelected is @false then any existing
2241 deselected; if @true the row will be added to the existing selection.
2243 void SelectRow(int row
, bool addToSelected
= false);
2261 This function returns the rectangle that encloses the selected cells
2262 in device coords and clipped to the client size of the grid window.
2264 wxRect
SelectionToDeviceRect();
2268 Sets the horizontal and vertical alignment for grid cell text at the specified
2270 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2273 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2276 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2277 void SetCellAlignment(int align
, int row
, int col
);
2283 void SetCellBackgroundColour(int row
, int col
,
2284 const wxColour
& colour
);
2287 Sets the editor for the grid cell at the specified location.
2288 The grid will take ownership of the pointer.
2289 See wxGridCellEditor and
2290 the @ref overview_gridoverview "wxGrid overview" for more information about
2291 cell editors and renderers.
2293 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2296 Sets the font for text in the grid cell at the specified location.
2298 void SetCellFont(int row
, int col
, const wxFont
& font
);
2301 Sets the renderer for the grid cell at the specified location.
2302 The grid will take ownership of the pointer.
2303 See wxGridCellRenderer and
2304 the @ref overview_gridoverview "wxGrid overview" for more information about
2305 cell editors and renderers.
2307 void SetCellRenderer(int row
, int col
,
2308 wxGridCellRenderer
* renderer
);
2312 Sets the text colour for the grid cell at the specified location.
2314 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2315 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2316 void SetCellTextColour(const wxColour
& colour
);
2321 Sets the string value for the cell at the specified location. For simple
2322 applications where a
2323 grid object automatically uses a default grid table of string values you use
2324 this function together
2325 with GetCellValue() to access cell values.
2326 For more complex applications where you have derived your own grid table class
2328 various data types (e.g. numeric, boolean or user-defined custom types) then
2330 function for those cells that contain string values.
2331 The last form is for backward compatibility only.
2332 See wxGridTableBase::CanSetValueAs
2333 and the @ref overview_gridoverview "wxGrid overview" for more information.
2335 void SetCellValue(int row
, int col
, const wxString
& s
);
2336 void SetCellValue(const wxGridCellCoords
& coords
,
2338 void SetCellValue(const wxString
& val
, int row
, int col
);
2342 Sets the cell attributes for all cells in the specified column.
2343 For more information about controlling grid cell attributes see the
2344 wxGridCellAttr cell attribute class and the
2345 @ref overview_gridoverview.
2347 void SetColAttr(int col
, wxGridCellAttr
* attr
);
2350 Sets the specified column to display boolean values. wxGrid displays boolean
2351 values with a checkbox.
2353 void SetColFormatBool(int col
);
2356 Sets the specified column to display data in a custom format.
2357 See the @ref overview_gridoverview "wxGrid overview" for more information on
2359 with custom data types.
2361 void SetColFormatCustom(int col
, const wxString
& typeName
);
2364 Sets the specified column to display floating point values with the given width
2367 void SetColFormatFloat(int col
, int width
= -1,
2368 int precision
= -1);
2371 Sets the specified column to display integer values.
2373 void SetColFormatNumber(int col
);
2376 Sets the horizontal and vertical alignment of column label text.
2377 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2379 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2382 void SetColLabelAlignment(int horiz
, int vert
);
2385 Sets the height of the column labels.
2386 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
2388 so that no label is truncated. Note that this could be slow for a large table.
2390 void SetColLabelSize(int height
);
2393 Set the value for the given column label. If you are using a derived grid table
2395 override wxGridTableBase::SetColLabelValue
2396 for this to have any effect.
2398 void SetColLabelValue(int col
, const wxString
& value
);
2401 This modifies the minimum column width that can be handled correctly.
2402 Specifying a low value here
2403 allows smaller grid cells to be dealt with correctly. Specifying a value here
2404 which is much smaller
2405 than the actual minimum size will incur a performance penalty in the functions
2407 grid cell index lookup on the basis of screen coordinates.
2408 This should normally be called when creating the grid because it will not
2409 resize existing columns
2410 with sizes smaller than the value specified here.
2412 void SetColMinimalAcceptableWidth(int width
);
2415 Sets the minimal width for the specified column. This should normally be called
2416 when creating the grid
2417 because it will not resize a column that is already narrower than the minimal
2419 The width argument must be higher than the minimimal acceptable column width,
2421 GetColMinimalAcceptableWidth().
2423 void SetColMinimalWidth(int col
, int width
);
2426 Sets the position of the specified column.
2428 void SetColPos(int colID
, int newPos
);
2431 Sets the width of the specified column.
2432 This function does not refresh the grid. If you are calling it outside of a
2433 BeginBatch / EndBatch
2434 block you can use ForceRefresh() to see the changes.
2435 Automatically sizes the column to fit its contents. If setAsMin is @true the
2436 calculated width will
2437 also be set as the minimal width for the column.
2439 void SetColSize(int col
, int width
);
2442 Sets the default horizontal and vertical alignment for grid cell text.
2443 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2445 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2448 void SetDefaultCellAlignment(int horiz
, int vert
);
2451 Sets the default background colour for grid cells.
2453 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2456 Sets the default font to be used for grid cell text.
2458 void SetDefaultCellFont(const wxFont
& font
);
2461 Sets the current default colour for grid cell text.
2463 void SetDefaultCellTextColour(const wxColour
& colour
);
2466 Sets the default width for columns in the grid. This will only affect columns
2467 subsequently added to
2468 the grid unless resizeExistingCols is @true.
2470 void SetDefaultColSize(int width
,
2471 bool resizeExistingCols
= false);
2474 Sets the default editor for grid cells. The grid will take ownership of the
2476 See wxGridCellEditor and
2477 the @ref overview_gridoverview "wxGrid overview" for more information about
2478 cell editors and renderers.
2480 void SetDefaultEditor(wxGridCellEditor
* editor
);
2483 Sets the default renderer for grid cells. The grid will take ownership of the
2485 See wxGridCellRenderer and
2486 the @ref overview_gridoverview "wxGrid overview" for more information about
2487 cell editors and renderers.
2489 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2492 Sets the default height for rows in the grid. This will only affect rows
2494 to the grid unless resizeExistingRows is @true.
2496 void SetDefaultRowSize(int height
,
2497 bool resizeExistingRows
= false);
2500 Set the grid cursor to the specified cell.
2501 This function calls MakeCellVisible().
2503 void SetGridCursor(int row
, int col
);
2506 Sets the colour used to draw grid lines.
2508 void SetGridLineColour(const wxColour
& colour
);
2511 Sets the background colour for row and column labels.
2513 void SetLabelBackgroundColour(const wxColour
& colour
);
2516 Sets the font for row and column labels.
2518 void SetLabelFont(const wxFont
& font
);
2521 Sets the colour for row and column label text.
2523 void SetLabelTextColour(const wxColour
& colour
);
2526 A grid may occupy more space than needed for its rows/columns. This
2527 function allows to set how big this extra space is
2529 void SetMargins(int extraWidth
, int extraHeight
);
2532 Common part of AutoSizeColumn/Row() and GetBestSize()
2534 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= true);
2539 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= true);
2542 Makes the cell at the specified location read-only or editable.
2543 See also IsReadOnly().
2545 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2548 Sets the cell attributes for all cells in the specified row.
2549 See the wxGridCellAttr class for more information
2550 about controlling cell attributes.
2552 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
2555 Sets the horizontal and vertical alignment of row label text.
2556 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2558 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2561 void SetRowLabelAlignment(int horiz
, int vert
);
2564 Sets the width of the row labels.
2565 If @a width equals @c wxGRID_AUTOSIZE then width is calculated automatically
2566 so that no label is truncated. Note that this could be slow for a large table.
2568 void SetRowLabelSize(int width
);
2571 Set the value for the given row label. If you are using a derived grid table
2573 override wxGridTableBase::SetRowLabelValue
2574 for this to have any effect.
2576 void SetRowLabelValue(int row
, const wxString
& value
);
2579 This modifies the minimum row width that can be handled correctly. Specifying a
2581 allows smaller grid cells to be dealt with correctly. Specifying a value here
2582 which is much smaller
2583 than the actual minimum size will incur a performance penalty in the functions
2585 grid cell index lookup on the basis of screen coordinates.
2586 This should normally be called when creating the grid because it will not
2587 resize existing rows
2588 with sizes smaller than the value specified here.
2590 void SetRowMinimalAcceptableHeight(int height
);
2593 Sets the minimal height for the specified row. This should normally be called
2594 when creating the grid
2595 because it will not resize a row that is already shorter than the minimal
2597 The height argument must be higher than the minimimal acceptable row height, see
2598 GetRowMinimalAcceptableHeight().
2600 void SetRowMinimalHeight(int row
, int height
);
2603 Sets the height of the specified row.
2604 This function does not refresh the grid. If you are calling it outside of a
2605 BeginBatch / EndBatch
2606 block you can use ForceRefresh() to see the changes.
2607 Automatically sizes the column to fit its contents. If setAsMin is @true the
2608 calculated width will
2609 also be set as the minimal width for the column.
2611 void SetRowSize(int row
, int height
);
2614 Sets the number of pixels per horizontal scroll increment. The default is 15.
2615 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2616 errors: setting this to 1 can help.
2618 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2620 void SetScrollLineX(int x
);
2623 Sets the number of pixels per vertical scroll increment. The default is 15.
2624 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2625 errors: setting this to 1 can help.
2627 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2629 void SetScrollLineY(int y
);
2634 void SetSelectionBackground(const wxColour
& c
);
2639 void SetSelectionForeground(const wxColour
& c
);
2642 Set the selection behaviour of the grid.
2644 @param wxGridSelectCells()
2645 The default mode where individual cells are selected.
2646 @param wxGridSelectRows()
2647 Selections will consist of whole rows.
2648 @param wxGridSelectColumns()
2649 Selections will consist of whole columns.
2651 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
2654 Passes a pointer to a custom grid table to be used by the grid. This should be
2656 after the grid constructor and before using the grid object. If takeOwnership
2658 @true then the table will be deleted by the wxGrid destructor.
2659 Use this function instead of CreateGrid() when your
2660 application involves complex or non-string data or data sets that are too large
2664 bool SetTable(wxGridTableBase
* table
, bool takeOwnership
= false,
2665 wxGrid::wxGridSelectionModes selmode
= wxGrid::wxGridSelectCells
);
2668 Call this in order to make the column labels use a native look by using
2669 wxRenderer::DrawHeaderButton
2670 internally. There is no equivalent method for drawing row columns as
2671 there is not native look for that. This option is useful when using
2672 wxGrid for displaying tables and not as a spread-sheet.
2674 void SetUseNativeColLabels(bool native
= true);
2677 Displays the in-place cell edit control for the current cell.
2679 void ShowCellEditControl();
2683 The x position to evaluate.
2685 If @true, rather than returning wxNOT_FOUND, it returns either the first or
2686 last column depending on whether x is too far to the left or right respectively.
2688 int XToCol(int x
, bool clipToMinMax
= false);
2691 Returns the column whose right hand edge is close to the given logical x
2693 If no column edge is near to this position @c wxNOT_FOUND is returned.
2695 int XToEdgeOfCol(int x
);
2698 Returns the row whose bottom edge is close to the given logical y position.
2699 If no row edge is near to this position @c wxNOT_FOUND is returned.
2701 int YToEdgeOfRow(int y
);
2704 Returns the grid row that corresponds to the logical y coordinate. Returns
2705 @c wxNOT_FOUND if there is no row at the y position.
2712 @class wxGridCellBoolEditor
2715 The editor for boolean data.
2721 wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor,
2722 wxGridCellTextEditor, wxGridCellChoiceEditor
2724 class wxGridCellBoolEditor
: public wxGridCellEditor
2728 Default constructor.
2730 wxGridCellBoolEditor();
2733 Returns @true if the given @a value is equal to the string representation of
2734 the truth value we currently use (see
2735 wxGridCellBoolEditor::UseStringValues).
2737 static bool IsTrueValue(const wxString
& value
);
2740 , @b const wxString&@e valueFalse = _T(""))
2741 This method allows to customize the values returned by GetValue() method for
2742 the cell using this editor. By default, the default values of the arguments are
2743 used, i.e. @c "1" is returned if the cell is checked and an empty string
2744 otherwise, using this method allows to change this.
2746 static void UseStringValues();
2751 @class wxGridUpdateLocker
2754 This small class can be used to prevent wxGrid from redrawing
2755 during its lifetime by calling wxGrid::BeginBatch
2756 in its constructor and wxGrid::EndBatch in its
2757 destructor. It is typically used in a function performing several operations
2758 with a grid which would otherwise result in flicker. For example:
2763 m_grid = new wxGrid(this, ...);
2765 wxGridUpdateLocker noUpdates(m_grid);
2766 m_grid-AppendColumn();
2767 ... many other operations with m_grid...
2770 // destructor called, grid refreshed
2774 Using this class is easier and safer than calling
2775 wxGrid::BeginBatch and wxGrid::EndBatch
2776 because you don't risk not to call the latter (due to an exception for example).
2781 class wxGridUpdateLocker
2785 Creates an object preventing the updates of the specified @e grid. The
2786 parameter could be @NULL in which case nothing is done. If @a grid is
2787 non-@NULL then the grid must exist for longer than wxGridUpdateLocker object
2789 The default constructor could be followed by a call to
2793 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
2796 Destructor reenables updates for the grid this object is associated with.
2798 ~wxGridUpdateLocker();
2801 This method can be called if the object had been constructed using the default
2802 constructor. It must not be called more than once.
2804 void Create(wxGrid
* grid
);