1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGridCellFloatRenderer
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxGridCellFloatRenderer
12 This class may be used to format floating point data in a cell.
17 @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer,
18 wxGridCellBoolRenderer
20 class wxGridCellFloatRenderer
: public wxGridCellStringRenderer
25 Minimum number of characters to be shown.
27 Number of digits after the decimal dot.
29 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
32 Returns the precision.
34 int GetPrecision() const;
42 Parameters string format is "width[,precision]".
44 void SetParameters(const wxString
& params
);
49 void SetPrecision(int precision
);
54 void SetWidth(int width
);
60 @class wxGridTableBase
67 class wxGridTableBase
: public wxObject
83 bool AppendCols(size_t numCols
= 1);
88 bool AppendRows(size_t numRows
= 1);
93 bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
96 Does this table allow attributes? Default implementation creates
97 a wxGridCellAttrProvider if necessary.
99 bool CanHaveAttributes();
104 bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
114 bool DeleteCols(size_t pos
= 0, size_t numCols
= 1);
119 bool DeleteRows(size_t pos
= 0, size_t numRows
= 1);
122 by default forwarded to wxGridCellAttrProvider if any. May be
123 overridden to handle attributes directly in the table.
125 wxGridCellAttr
* GetAttr(int row
, int col
);
128 get the currently used attr provider (may be @NULL)
130 wxGridCellAttrProvider
* GetAttrProvider() const;
135 wxString
GetColLabelValue(int col
);
143 You must override these functions in a derived table class.
150 wxString
GetRowLabelValue(int row
);
153 Data type determination and value access.
155 wxString
GetTypeName(int row
, int col
);
160 wxString
GetValue(int row
, int col
);
165 bool GetValueAsBool(int row
, int col
);
168 For user defined types
170 void* GetValueAsCustom(int row
, int col
,
171 const wxString
& typeName
);
176 double GetValueAsDouble(int row
, int col
);
181 long GetValueAsLong(int row
, int col
);
186 wxGrid
* GetView() const;
191 bool InsertCols(size_t pos
= 0, size_t numCols
= 1);
196 bool InsertRows(size_t pos
= 0, size_t numRows
= 1);
201 bool IsEmptyCell(int row
, int col
);
204 these functions take ownership of the pointer
206 void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
210 give us the attr provider to use - we take ownership of the pointer
212 void SetAttrProvider(wxGridCellAttrProvider
* attrProvider
);
217 void SetColAttr(wxGridCellAttr
* attr
, int col
);
222 void SetColLabelValue() const;
227 void SetRowAttr(wxGridCellAttr
* attr
, int row
);
232 void SetRowLabelValue() const;
237 void SetValue(int row
, int col
, const wxString
& value
);
242 void SetValueAsBool(int row
, int col
, bool value
);
247 void SetValueAsCustom(int row
, int col
, const wxString
& typeName
,
253 void SetValueAsDouble(int row
, int col
, double value
);
258 void SetValueAsLong(int row
, int col
, long value
);
261 Overriding these is optional
263 void SetView(wxGrid
* grid
);
268 void UpdateAttrCols(size_t pos
, int numCols
);
271 change row/col number in attribute if needed
273 void UpdateAttrRows(size_t pos
, int numRows
);
279 @class wxGridCellEditor
281 This class is responsible for providing and manipulating
282 the in-place edit controls for the grid. Instances of wxGridCellEditor
283 (actually, instances of derived classes since it is an abstract class) can be
284 associated with the cell attributes for individual cells, rows, columns, or
285 even for the entire grid.
290 @see wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
291 wxGridCellNumberEditor, wxGridCellChoiceEditor
293 class wxGridCellEditor
302 The dtor is private because only DecRef() can delete us.
307 Fetch the value from the table and prepare the edit control
308 to begin editing. Set the focus to the edit control.
310 void BeginEdit(int row
, int col
, wxGrid
* grid
);
313 Create a new object which is the copy of this one.
315 wxGridCellEditor
* Clone() const;
318 Creates the actual edit control.
320 void Create(wxWindow
* parent
, wxWindowID id
,
321 wxEvtHandler
* evtHandler
);
329 Complete the editing of the current cell. Returns @true if the value has
330 changed. If necessary, the control may be destroyed.
332 bool EndEdit(int row
, int col
, wxGrid
* grid
);
335 Some types of controls on some platforms may need some help
338 void HandleReturn(wxKeyEvent
& event
);
346 Draws the part of the cell not occupied by the control: the base class
347 version just fills it with background colour from the attribute.
349 void PaintBackground(const wxRect
& rectCell
,
350 wxGridCellAttr
* attr
);
353 Reset the value in the control back to its starting value.
358 Size and position the edit control.
360 void SetSize(const wxRect
& rect
);
363 Show or hide the edit control, use the specified attributes to set
364 colours/fonts for it.
366 void Show(bool show
, wxGridCellAttr
* attr
= NULL
);
369 If the editor is enabled by clicking on the cell, this method will be
372 void StartingClick();
375 If the editor is enabled by pressing keys on the grid,
376 this will be called to let the editor do something about
377 that first key if desired.
379 void StartingKey(wxKeyEvent
& event
);
385 @class wxGridCellTextEditor
387 The editor for string/text data.
392 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
393 wxGridCellNumberEditor, wxGridCellChoiceEditor
395 class wxGridCellTextEditor
: public wxGridCellEditor
401 wxGridCellTextEditor();
404 The parameters string format is "n" where n is a number representing the
407 void SetParameters(const wxString
& params
);
413 @class wxGridCellStringRenderer
415 This class may be used to format string data in a cell; it is the default
421 @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
422 wxGridCellBoolRenderer
424 class wxGridCellStringRenderer
: public wxGridCellRenderer
430 wxGridCellStringRenderer();
436 @class wxGridCellChoiceEditor
438 The editor for string data allowing to choose from a list of strings.
443 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
444 wxGridCellTextEditor, wxGridCellNumberEditor
446 class wxGridCellChoiceEditor
: public wxGridCellEditor
452 Number of strings from which the user can choose.
454 An array of strings from which the user can choose.
456 If allowOthers is @true, the user can type a string not in choices array.
458 wxGridCellChoiceEditor(size_t count
= 0,
459 const wxString choices
[] = NULL
,
460 bool allowOthers
= false);
461 wxGridCellChoiceEditor(const wxArrayString
& choices
,
462 bool allowOthers
= false);
466 Parameters string format is "item1[,item2[...,itemN]]"
468 void SetParameters(const wxString
& params
);
474 @class wxGridEditorCreatedEvent
480 class wxGridEditorCreatedEvent
: public wxCommandEvent
487 wxGridEditorCreatedEvent();
488 wxGridEditorCreatedEvent(int id
, wxEventType type
,
496 Returns the column at which the event occurred.
501 Returns the edit control.
503 wxControl
* GetControl();
506 Returns the row at which the event occurred.
511 Sets the column at which the event occurred.
513 void SetCol(int col
);
516 Sets the edit control.
518 void SetControl(wxControl
* ctrl
);
521 Sets the row at which the event occurred.
523 void SetRow(int row
);
529 @class wxGridRangeSelectEvent
535 class wxGridRangeSelectEvent
: public wxNotifyEvent
542 wxGridRangeSelectEvent();
543 wxGridRangeSelectEvent(int id
, wxEventType type
,
545 const wxGridCellCoords
& topLeft
,
546 const wxGridCellCoords
& bottomRight
,
548 bool control
= false,
555 Returns @true if the Alt key was down at the time of the event.
560 Returns @true if the Control key was down at the time of the event.
565 Top left corner of the rectangular area that was (de)selected.
567 wxGridCellCoords
GetBottomRightCoords();
570 Bottom row of the rectangular area that was (de)selected.
575 Left column of the rectangular area that was (de)selected.
580 Right column of the rectangular area that was (de)selected.
585 Top left corner of the rectangular area that was (de)selected.
587 wxGridCellCoords
GetTopLeftCoords();
590 Top row of the rectangular area that was (de)selected.
595 Returns @true if the Meta key was down at the time of the event.
600 Returns @true if the area was selected, @false otherwise.
605 Returns @true if the Shift key was down at the time of the event.
613 @class wxGridCellRenderer
615 This class is responsible for actually drawing the cell
616 in the grid. You may pass it to the wxGridCellAttr (below) to change the
617 format of one given cell or to wxGrid::SetDefaultRenderer() to change the
618 view of all cells. This is an abstract class, and you will normally use one of
620 predefined derived classes or derive your own class from it.
625 @see wxGridCellStringRenderer, wxGridCellNumberRenderer,
626 wxGridCellFloatRenderer, wxGridCellBoolRenderer
628 class wxGridCellRenderer
634 wxGridCellRenderer
* Clone() const;
637 Draw the given cell on the provided DC inside the given rectangle
638 using the style specified by the attribute and the default or selected
639 state corresponding to the isSelected value.
640 This pure virtual function has a default implementation which will
641 prepare the DC using the given attribute: it will draw the rectangle
642 with the background colour from attr and set the text colour and font.
644 void Draw(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
645 const wxRect
& rect
, int row
, int col
,
649 Get the preferred size of the cell for its contents.
651 wxSize
GetBestSize(wxGrid
& grid
, wxGridCellAttr
& attr
, wxDC
& dc
,
658 @class wxGridCellNumberEditor
660 The editor for numeric integer data.
665 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
666 wxGridCellTextEditor, wxGridCellChoiceEditor
668 class wxGridCellNumberEditor
: public wxGridCellTextEditor
672 Allows to specify the range for acceptable data;
673 if min == max == -1, no range checking is done
675 wxGridCellNumberEditor(int min
= -1, int max
= -1);
678 String representation of the value.
680 wxString
GetString() const;
683 If the return value is @true, the editor uses a wxSpinCtrl to get user input,
684 otherwise it uses a wxTextCtrl.
686 bool HasRange() const;
689 Parameters string format is "min,max".
691 void SetParameters(const wxString
& params
);
697 @class wxGridSizeEvent
699 This event class contains information about a row/column resize event.
704 class wxGridSizeEvent
: public wxNotifyEvent
712 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
716 bool control
= false,
723 Returns @true if the Alt key was down at the time of the event.
728 Returns @true if the Control key was down at the time of the event.
733 Position in pixels at which the event occurred.
735 wxPoint
GetPosition();
738 Row or column at that was resized.
743 Returns @true if the Meta key was down at the time of the event.
748 Returns @true if the Shift key was down at the time of the event.
756 @class wxGridCellNumberRenderer
758 This class may be used to format integer data in a cell.
763 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
764 wxGridCellBoolRenderer
766 class wxGridCellNumberRenderer
: public wxGridCellStringRenderer
772 wxGridCellNumberRenderer();
778 @class wxGridCellAttr
780 This class can be used to alter the cells' appearance in
781 the grid by changing their colour/font/... from default. An object of this
782 class may be returned by wxGridTableBase::GetAttr.
792 Constructor specifying some of the often used attributes.
795 wxGridCellAttr(const wxColour
& colText
,
796 const wxColour
& colBack
,
798 int hAlign
, int vAlign
);
802 Creates a new copy of this object.
804 wxGridCellAttr
* Clone() const;
812 See SetAlignment() for the returned values.
814 void GetAlignment(int* hAlign
, int* vAlign
) const;
819 const wxColour
GetBackgroundColour() const;
824 wxGridCellEditor
* GetEditor(wxGrid
* grid
, int row
, int col
) const;
829 const wxFont
GetFont() const;
834 wxGridCellRenderer
* GetRenderer(wxGrid
* grid
, int row
, int col
) const;
839 const wxColour
GetTextColour() const;
844 bool HasAlignment() const;
849 bool HasBackgroundColour() const;
854 bool HasEditor() const;
859 bool HasFont() const;
864 bool HasRenderer() const;
869 bool HasTextColour() const;
872 This class is ref counted: it is created with ref count of 1, so
873 calling DecRef() once will delete it. Calling IncRef() allows to lock
874 it until the matching DecRef() is called
881 bool IsReadOnly() const;
884 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
885 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one
886 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
888 void SetAlignment(int hAlign
, int vAlign
);
891 Sets the background colour.
893 void SetBackgroundColour(const wxColour
& colBack
);
898 void SetDefAttr(wxGridCellAttr
* defAttr
);
903 void SetEditor(wxGridCellEditor
* editor
);
908 void SetFont(const wxFont
& font
);
913 void SetReadOnly(bool isReadOnly
= true);
916 takes ownership of the pointer
918 void SetRenderer(wxGridCellRenderer
* renderer
);
921 Sets the text colour.
923 void SetTextColour(const wxColour
& colText
);
929 @class wxGridCellBoolRenderer
931 This class may be used to format boolean data in a cell.
937 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
938 wxGridCellNumberRenderer
940 class wxGridCellBoolRenderer
: public wxGridCellRenderer
946 wxGridCellBoolRenderer();
954 This event class contains information about various grid events.
959 class wxGridEvent
: public wxNotifyEvent
967 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
968 int row
= -1, int col
= -1,
969 int x
= -1, int y
= -1,
971 bool control
= false,
978 Returns @true if the Alt key was down at the time of the event.
983 Returns @true if the Control key was down at the time of the event.
988 Column at which the event occurred.
993 Position in pixels at which the event occurred.
995 wxPoint
GetPosition();
998 Row at which the event occurred.
1003 Returns @true if the Meta key was down at the time of the event.
1008 Returns @true if the user is selecting grid cells, @false -- if
1014 Returns @true if the Shift key was down at the time of the event.
1022 @class wxGridCellFloatEditor
1024 The editor for floating point numbers data.
1029 @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
1030 wxGridCellTextEditor, wxGridCellChoiceEditor
1032 class wxGridCellFloatEditor
: public wxGridCellTextEditor
1037 Minimum number of characters to be shown.
1039 Number of digits after the decimal dot.
1041 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
1044 Parameters string format is "width,precision"
1046 void SetParameters(const wxString
& params
);
1054 wxGrid and its related classes are used for displaying and editing tabular
1056 They provide a rich set of features for display, editing, and interacting
1057 with a variety of data sources. For simple applications, and to help you
1058 get started, wxGrid is the only class you need to refer to directly. It
1059 will set up default instances of the other classes and manage them for you.
1060 For more complex applications you can derive your own classes for custom
1061 grid views, grid data tables, cell editors and renderers. The @ref
1062 overview_gridoverview has examples of simple and more complex applications,
1063 explains the relationship between the various grid classes and has a
1064 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1066 wxGrid has been greatly expanded and redesigned for wxWidgets 2.2 onwards.
1067 The new grid classes are reasonably backward-compatible but there are some
1068 exceptions. There are also easier ways of doing many things compared to the
1069 previous implementation.
1071 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1072 class. One or more wxGrid classes may act as a view for one table class.
1073 The default table class is called wxGridStringTable and holds an array of
1074 strings. An instance of such a class is created by wxGrid::CreateGrid.
1076 wxGridCellRenderer is the abstract base class for rendereing contents in a
1077 cell. The following renderers are predefined:
1078 - wxGridCellStringRenderer,
1079 - wxGridCellBoolRenderer,
1080 - wxGridCellFloatRenderer,
1081 - wxGridCellNumberRenderer.
1082 The look of a cell can be further defined using wxGridCellAttr. An object
1083 of this type may be returned by wxGridTableBase::GetAttr.
1085 wxGridCellEditor is the abstract base class for editing the value of a
1086 cell. The following editors are predefined:
1087 - wxGridCellTextEditor
1088 - wxGridCellBoolEditor
1089 - wxGridCellChoiceEditor
1090 - wxGridCellNumberEditor.
1095 @see @ref overview_gridoverview "wxGrid overview"
1097 class wxGrid
: public wxScrolledWindow
1101 Different selection modes supported by the grid.
1103 enum wxGridSelectionModes
1106 The default selection mode allowing selection of the individual
1107 cells as well as of the entire rows and columns.
1112 The selection mode allowing the selection of the entire rows only.
1114 The user won't be able to select any cells or columns in this mode.
1119 The selection mode allowing the selection of the entire columns only.
1121 The user won't be able to select any cells or rows in this mode.
1127 Default constructor.
1129 You must call Create() to really create the grid window and also call
1130 CreateGrid() or SetTable() to initialize the grid contents.
1135 Constructor creating the grid window.
1137 You must call either CreateGrid() or SetTable() to initialize the grid
1138 contents before using it.
1140 wxGrid(wxWindow
* parent
,
1142 const wxPoint
& pos
= wxDefaultPosition
,
1143 const wxSize
& size
= wxDefaultSize
,
1144 long style
= wxWANTS_CHARS
,
1145 const wxString
& name
= wxGridNameStr
);
1148 Creates the grid window for an object initialized using the default
1151 You must call either CreateGrid() or SetTable() to initialize the grid
1152 contents before using it.
1154 bool Create(wxWindow
* parent
,
1156 const wxPoint
& pos
= wxDefaultPosition
,
1157 const wxSize
& size
= wxDefaultSize
,
1158 long style
= wxWANTS_CHARS
,
1159 const wxString
& name
= wxGridNameStr
);
1164 This will also destroy the associated grid table unless you passed a
1165 table object to the grid and specified that the grid should not take
1166 ownership of the table (see wxGrid::SetTable).
1171 Appends one or more new columns to the right of the grid.
1173 The @a updateLabels argument is not used at present. If you are using a
1174 derived grid table class you will need to override
1175 wxGridTableBase::AppendCols. See InsertCols() for further information.
1177 @return @true on success or @false if appending columns failed.
1179 bool AppendCols(int numCols
= 1, bool updateLabels
= true);
1182 Appends one or more new rows to the bottom of the grid.
1184 The @a updateLabels argument is not used at present. If you are using a
1185 derived grid table class you will need to override
1186 wxGridTableBase::AppendRows. See InsertRows() for further information.
1188 @return @true on success or @false if appending rows failed.
1190 bool AppendRows(int numRows
= 1, bool updateLabels
= true);
1193 Automatically sets the height and width of all rows and columns to fit their
1199 Automatically adjusts width of the column to fit its label.
1201 void AutoSizeColLabelSize(int col
);
1204 Automatically sizes the column to fit its contents. If setAsMin is @true the
1205 calculated width will
1206 also be set as the minimal width for the column.
1208 void AutoSizeColumn(int col
, bool setAsMin
= true);
1211 Automatically sizes all columns to fit their contents. If setAsMin is @true the
1212 calculated widths will
1213 also be set as the minimal widths for the columns.
1215 void AutoSizeColumns(bool setAsMin
= true);
1218 Automatically sizes the row to fit its contents. If setAsMin is @true the
1219 calculated height will
1220 also be set as the minimal height for the row.
1222 void AutoSizeRow(int row
, bool setAsMin
= true);
1225 Automatically adjusts height of the row to fit its label.
1227 void AutoSizeRowLabelSize(int col
);
1230 Automatically sizes all rows to fit their contents. If setAsMin is @true the
1231 calculated heights will
1232 also be set as the minimal heights for the rows.
1234 void AutoSizeRows(bool setAsMin
= true);
1237 Increments the grid's batch count.
1239 When the count is greater than zero repainting of the grid is
1240 suppressed. Each call to BeginBatch must be matched by a later call to
1241 EndBatch(). Code that does a lot of grid modification can be enclosed
1242 between BeginBatch and EndBatch calls to avoid screen flicker. The
1243 final EndBatch will cause the grid to be repainted.
1245 Notice that you should use wxGridUpdateLocker which ensures that there
1246 is always a matching EndBatch() call for this BeginBatch() if possible
1247 instead of calling this method directly.
1252 This function returns the rectangle that encloses the block of cells
1253 limited by TopLeft and BottomRight cell in device coords and clipped
1254 to the client size of the grid window.
1256 wxRect
BlockToDeviceRect(const wxGridCellCoords
& topLeft
,
1257 const wxGridCellCoords
& bottomRight
) const;
1260 Returns @true if columns can be moved by dragging with the mouse.
1262 Columns can be moved by dragging on their labels.
1264 bool CanDragColMove() const;
1267 Returns @true if columns can be resized by dragging with the mouse.
1268 Columns can be resized by dragging the edges of their labels. If grid
1269 line dragging is enabled they can also be resized by dragging the right
1270 edge of the column in the grid cell area (see
1271 wxGrid::EnableDragGridSize).
1273 bool CanDragColSize() const;
1276 Return @true if the dragging of grid lines to resize rows and columns is enabled
1277 or @false otherwise.
1279 bool CanDragGridSize() const;
1282 Returns @true if rows can be resized by dragging with the mouse.
1283 Rows can be resized by dragging the edges of their labels. If grid line
1284 dragging is enabled they can also be resized by dragging the lower edge
1285 of the row in the grid cell area (see wxGrid::EnableDragGridSize).
1287 bool CanDragRowSize() const;
1290 Returns @true if the in-place edit control for the current grid cell can be used
1292 @false otherwise (e.g. if the current cell is read-only).
1294 bool CanEnableCellControl() const;
1297 Do we have some place to store attributes in?
1299 bool CanHaveAttributes() const;
1303 Return the rectangle corresponding to the grid cell's size and position in
1307 wxRect
CellToRect(int row
, int col
) const;
1308 const wxRect
CellToRect(const wxGridCellCoords
& coords
) const;
1312 Clears all data in the underlying grid table and repaints the grid.
1314 The table is not deleted by this function. If you are using a derived
1315 table class then you need to override wxGridTableBase::Clear() for this
1316 function to have any effect.
1321 Deselects all cells that are currently selected.
1323 void ClearSelection();
1326 Creates a grid with the specified initial number of rows and columns.
1327 Call this directly after the grid constructor. When you use this
1328 function wxGrid will create and manage a simple table of string values
1329 for you. All of the grid data will be stored in memory.
1330 For applications with more complex data types or relationships, or for
1331 dealing with very large datasets, you should derive your own grid table
1332 class and pass a table object to the grid with SetTable().
1334 bool CreateGrid(int numRows
, int numCols
,
1335 wxGridSelectionModes selmode
= wxGridSelectCells
);
1338 Deletes one or more columns from a grid starting at the specified
1341 The @a updateLabels argument is not used at present. If you are using a
1342 derived grid table class you will need to override
1343 wxGridTableBase::DeleteCols. See InsertCols() for further information.
1345 @return @true on success or @false if deleting columns failed.
1347 bool DeleteCols(int pos
= 0, int numCols
= 1, bool updateLabels
= true);
1350 Deletes one or more rows from a grid starting at the specified position.
1352 The @a updateLabels argument is not used at present. If you are using a
1353 derived grid table class you will need to override
1354 wxGridTableBase::DeleteRows. See InsertRows() for further information.
1356 @return @true on success or @false if appending rows failed.
1358 bool DeleteRows(int pos
= 0, int numRows
= 1, bool updateLabels
= true);
1361 Disables in-place editing of grid cells.
1362 Equivalent to calling EnableCellEditControl(@false).
1364 void DisableCellEditControl();
1367 Disables column moving by dragging with the mouse.
1369 Equivalent to passing @false to EnableDragColMove().
1371 void DisableDragColMove();
1374 Disables column sizing by dragging with the mouse.
1376 Equivalent to passing @false to EnableDragColSize().
1378 void DisableDragColSize();
1381 Disable mouse dragging of grid lines to resize rows and columns.
1383 Equivalent to passing @false to EnableDragGridSize()
1385 void DisableDragGridSize();
1388 Disables row sizing by dragging with the mouse.
1390 Equivalent to passing @false to EnableDragRowSize().
1392 void DisableDragRowSize();
1395 Enables or disables in-place editing of grid cell data.
1397 The grid will issue either a wxEVT_GRID_EDITOR_SHOWN or
1398 wxEVT_GRID_EDITOR_HIDDEN event.
1400 void EnableCellEditControl(bool enable
= true);
1403 Enables or disables column moving by dragging with the mouse.
1405 void EnableDragColMove(bool enable
= true);
1408 Enables or disables column sizing by dragging with the mouse.
1410 void EnableDragColSize(bool enable
= true);
1413 Enables or disables row and column resizing by dragging gridlines with the
1416 void EnableDragGridSize(bool enable
= true);
1419 Enables or disables row sizing by dragging with the mouse.
1421 void EnableDragRowSize(bool enable
= true);
1424 Makes the grid globally editable or read-only.
1426 If the edit argument is @false this function sets the whole grid as
1427 read-only. If the argument is @true the grid is set to the default
1428 state where cells may be editable. In the default state you can set
1429 single grid cells and whole rows and columns to be editable or
1430 read-only via wxGridCellAttribute::SetReadOnly. For single cells you
1431 can also use the shortcut function SetReadOnly().
1433 For more information about controlling grid cell attributes see the
1434 wxGridCellAttr cell attribute class and the
1435 @ref overview_gridoverview.
1437 void EnableEditing(bool edit
);
1440 Turns the drawing of grid lines on or off.
1442 void EnableGridLines(bool enable
= true);
1445 Decrements the grid's batch count.
1447 When the count is greater than zero repainting of the grid is
1448 suppressed. Each previous call to BeginBatch() must be matched by a
1449 later call to EndBatch. Code that does a lot of grid modification can
1450 be enclosed between BeginBatch and EndBatch calls to avoid screen
1451 flicker. The final EndBatch will cause the grid to be repainted.
1453 @see wxGridUpdateLocker
1458 Overridden wxWindow method.
1463 Causes immediate repainting of the grid.
1465 Use this instead of the usual wxWindow::Refresh.
1467 void ForceRefresh();
1470 Returns the number of times that BeginBatch() has been called
1471 without (yet) matching calls to EndBatch(). While
1472 the grid's batch count is greater than zero the display will not be updated.
1474 int GetBatchCount() const;
1477 Sets the arguments to the horizontal and vertical text alignment values
1478 for the grid cell at the specified location.
1480 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1481 or @c wxALIGN_RIGHT.
1483 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1486 void GetCellAlignment(int row
, int col
, int* horiz
, int* vert
) const;
1489 Returns the background colour of the cell at the specified location.
1491 wxColour
GetCellBackgroundColour(int row
, int col
) const;
1494 Returns a pointer to the editor for the cell at the specified location.
1495 See wxGridCellEditor and
1496 the @ref overview_gridoverview "wxGrid overview" for more information about
1497 cell editors and renderers.
1499 wxGridCellEditor
* GetCellEditor(int row
, int col
) const;
1502 Returns the font for text in the grid cell at the specified location.
1504 wxFont
GetCellFont(int row
, int col
) const;
1507 Returns a pointer to the renderer for the grid cell at the specified location.
1508 See wxGridCellRenderer and
1509 the @ref overview_gridoverview "wxGrid overview" for more information about
1510 cell editors and renderers.
1512 wxGridCellRenderer
* GetCellRenderer(int row
, int col
) const;
1515 Returns the text colour for the grid cell at the specified location.
1517 wxColour
GetCellTextColour(int row
, int col
) const;
1521 Returns the string contained in the cell at the specified location. For simple
1522 applications where a
1523 grid object automatically uses a default grid table of string values you use
1524 this function together
1525 with SetCellValue() to access cell values.
1526 For more complex applications where you have derived your own grid table class
1528 various data types (e.g. numeric, boolean or user-defined custom types) then
1530 function for those cells that contain string values.
1531 See wxGridTableBase::CanGetValueAs
1532 and the @ref overview_gridoverview "wxGrid overview" for more information.
1534 wxString
GetCellValue(int row
, int col
) const;
1535 const wxString
GetCellValue(const wxGridCellCoords
& coords
) const;
1539 Returns the column ID of the specified column position.
1541 int GetColAt(int colPos
) const;
1544 Returns the pen used for vertical grid lines. This virtual function may be
1545 overridden in derived classes in order to change the appearance of individual
1546 grid lines for the given column @e col.
1547 See GetRowGridLinePen() for an example.
1549 wxPen
GetColGridLinePen(int col
);
1552 Sets the arguments to the current column label alignment values.
1554 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1555 or @c wxALIGN_RIGHT.
1557 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1560 void GetColLabelAlignment(int* horiz
, int* vert
) const;
1563 Returns the current height of the column labels.
1565 int GetColLabelSize() const;
1568 Returns the specified column label.
1570 The default grid table class provides column labels of the form
1571 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1572 override wxGridTableBase::GetColLabelValue to provide your own labels.
1574 wxString
GetColLabelValue(int col
) const;
1577 Returns the coordinate of the left border specified column.
1579 int GetColLeft(int col
) const;
1582 This returns the value of the lowest column width that can be handled
1584 member SetColMinimalAcceptableWidth() for details.
1586 int GetColMinimalAcceptableWidth() const;
1589 Get the minimal width of the given column/row.
1591 int GetColMinimalWidth(int col
) const;
1594 Returns the position of the specified column.
1596 int GetColPos(int colID
) const;
1599 Returns the coordinate of the right border specified column.
1601 int GetColRight(int col
) const;
1604 Returns the width of the specified column.
1606 int GetColSize(int col
) const;
1609 Sets the arguments to the current default horizontal and vertical text alignment
1611 Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or
1614 Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
1616 void GetDefaultCellAlignment(int* horiz
, int* vert
) const;
1619 Returns the current default background colour for grid cells.
1621 wxColour
GetDefaultCellBackgroundColour() const;
1624 Returns the current default font for grid cell text.
1626 wxFont
GetDefaultCellFont() const;
1629 Returns the current default colour for grid cell text.
1631 wxColour
GetDefaultCellTextColour() const;
1634 Returns the default height for column labels.
1636 int GetDefaultColLabelSize() const;
1639 Returns the current default width for grid columns.
1641 int GetDefaultColSize() const;
1644 Returns a pointer to the current default grid cell editor.
1645 See wxGridCellEditor and
1646 the @ref overview_gridoverview "wxGrid overview" for more information about
1647 cell editors and renderers.
1649 wxGridCellEditor
* GetDefaultEditor() const;
1655 wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1656 const wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const;
1662 wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1665 Returns the pen used for grid lines. This virtual function may be overridden in
1666 derived classes in order to change the appearance of grid lines. Note that
1667 currently the pen width must be 1.
1669 @see GetColGridLinePen(), GetRowGridLinePen()
1671 wxPen
GetDefaultGridLinePen();
1674 Returns a pointer to the current default grid cell renderer.
1675 See wxGridCellRenderer and
1676 the @ref overview_gridoverview "wxGrid overview" for more information about
1677 cell editors and renderers.
1679 wxGridCellRenderer
* GetDefaultRenderer() const;
1684 wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1689 wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1692 Returns the default width for the row labels.
1694 int GetDefaultRowLabelSize() const;
1697 Returns the current default height for grid rows.
1699 int GetDefaultRowSize() const;
1702 Returns the current grid cell column position.
1704 int GetGridCursorCol() const;
1707 Returns the current grid cell row position.
1709 int GetGridCursorRow() const;
1712 Returns the colour used for grid lines.
1714 @see GetDefaultGridLinePen()
1716 wxColour
GetGridLineColour() const;
1719 Returns the colour used for the background of row and column labels.
1721 wxColour
GetLabelBackgroundColour() const;
1724 Returns the font used for row and column labels.
1726 wxFont
GetLabelFont() const;
1729 Returns the colour used for row and column label text.
1731 wxColour
GetLabelTextColour() const;
1734 Returns the total number of grid columns (actually the number of columns in the
1738 int GetNumberCols() const;
1741 Returns the total number of grid rows (actually the number of rows in the
1742 underlying grid table).
1744 int GetNumberRows() const;
1749 wxGridCellAttr
* GetOrCreateCellAttr(int row
, int col
) const;
1752 Returns the pen used for horizontal grid lines. This virtual function may be
1753 overridden in derived classes in order to change the appearance of individual
1754 grid line for the given row @e row.
1757 wxPen
GetRowGridLinePen(int row
);
1760 Sets the arguments to the current row label alignment values.
1761 Horizontal alignment will be one of wxLEFT, wxCENTRE or wxRIGHT.
1763 Vertical alignment will be one of wxTOP, wxCENTRE or wxBOTTOM.
1765 void GetRowLabelAlignment(int* horiz
, int* vert
) const;
1768 Returns the current width of the row labels.
1770 int GetRowLabelSize() const;
1773 Returns the specified row label. The default grid table class provides numeric
1775 If you are using a custom grid table you can override
1776 wxGridTableBase::GetRowLabelValue to provide
1779 wxString
GetRowLabelValue(int row
) const;
1782 This returns the value of the lowest row width that can be handled correctly.
1784 member SetRowMinimalAcceptableHeight() for details.
1786 int GetRowMinimalAcceptableHeight() const;
1791 int GetRowMinimalHeight(int col
) const;
1794 Returns the height of the specified row.
1796 int GetRowSize(int row
) const;
1799 Returns the number of pixels per horizontal scroll increment. The default is 15.
1801 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
1803 int GetScrollLineX() const;
1806 Returns the number of pixels per vertical scroll increment. The default is 15.
1808 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
1810 int GetScrollLineY() const;
1813 Returns an array of singly selected cells.
1815 wxGridCellCoordsArray
GetSelectedCells() const;
1818 Returns an array of selected cols.
1820 Please notice that this method alone is not sufficient to find all the
1821 selected columns, see the explanation in GetSelectedRows()
1822 documentation for more details.
1824 wxArrayInt
GetSelectedCols() const;
1827 Returns an array of selected rows.
1829 Note that this array contains only the rows which were individually
1830 selected (using the mouse with the row header or combinations involving
1831 @c Ctrl key for selecting individual rows). In particular if the user
1832 selects many rows at once (e.g. by pressing @c Shift key) this array is
1833 @b not updated because this could mean storing a very large number of
1834 elements in it. So in general to find the current selection you need to
1835 use both this method and GetSelectionBlockTopLeft() and
1836 GetSelectionBlockBottomRight() ones.
1838 wxArrayInt
GetSelectedRows() const;
1841 Access or update the selection fore/back colours
1843 wxColour
GetSelectionBackground() const;
1846 Returns an array of the bottom right corners of blocks of selected cells,
1847 see GetSelectionBlockTopLeft().
1849 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1852 Returns an array of the top left corners of blocks of selected cells,
1853 see GetSelectionBlockBottomRight().
1855 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1860 wxColour
GetSelectionForeground() const;
1863 Returns the current selection mode, see SetSelectionMode().
1865 wxGridSelectionModes
GetSelectionMode() const;
1868 Returns a base pointer to the current table object.
1870 wxGridTableBase
* GetTable() const;
1873 Returned number of whole cols visible.
1875 int GetViewWidth() const;
1886 GetDefaultGridLinePen()
1895 Returns @true if drawing of grid lines is turned on, @false otherwise.
1897 bool GridLinesEnabled() const;
1900 Hides the in-place cell edit control.
1902 void HideCellEditControl();
1905 Hides the column labels by calling SetColLabelSize()
1906 with a size of 0. Show labels again by calling that method with
1907 a width greater than 0.
1909 void HideColLabels();
1912 Hides the row labels by calling SetRowLabelSize()
1913 with a size of 0. Show labels again by calling that method with
1914 a width greater than 0.
1916 void HideRowLabels();
1919 Init the m_colWidths/Rights arrays
1921 void InitColWidths();
1924 @note @e never access m_row/col arrays directly because they are created
1925 on demand, @e always use accessor functions instead!
1926 Init the m_rowHeights/Bottoms arrays with default values.
1928 void InitRowHeights();
1931 Inserts one or more new columns into a grid with the first new column at the
1932 specified position and returns @true if successful. The updateLabels argument is
1935 The sequence of actions begins with the grid object requesting the underlying
1937 table to insert new columns. If this is successful the table notifies the grid
1939 grid updates the display. For a default grid (one where you have called
1940 wxGrid::CreateGrid) this process is automatic. If you are
1941 using a custom grid table (specified with wxGrid::SetTable)
1942 then you must override
1943 wxGridTableBase::InsertCols in your derived
1946 bool InsertCols(int pos
= 0, int numCols
= 1,
1947 bool updateLabels
= true);
1950 Inserts one or more new rows into a grid with the first new row at the specified
1951 position and returns @true if successful. The updateLabels argument is not used
1954 The sequence of actions begins with the grid object requesting the underlying
1956 table to insert new rows. If this is successful the table notifies the grid and
1958 grid updates the display. For a default grid (one where you have called
1959 wxGrid::CreateGrid) this process is automatic. If you are
1960 using a custom grid table (specified with wxGrid::SetTable)
1961 then you must override
1962 wxGridTableBase::InsertRows in your derived
1965 bool InsertRows(int pos
= 0, int numRows
= 1,
1966 bool updateLabels
= true);
1969 Returns @true if the in-place edit control is currently enabled.
1971 bool IsCellEditControlEnabled() const;
1974 Returns @true if the current cell has been set to read-only
1975 (see wxGrid::SetReadOnly).
1977 bool IsCurrentCellReadOnly() const;
1980 Returns @false if the whole grid has been set as read-only or @true otherwise.
1981 See EnableEditing() for more information about
1982 controlling the editing status of grid cells.
1984 bool IsEditable() const;
1988 Is this cell currently selected.
1990 bool IsInSelection(int row
, int col
) const;
1991 const bool IsInSelection(const wxGridCellCoords
& coords
) const;
1995 Returns @true if the cell at the specified location can't be edited.
1996 See also IsReadOnly().
1998 bool IsReadOnly(int row
, int col
) const;
2001 Returns @true if there are currently rows, columns or blocks of cells selected.
2003 bool IsSelection() const;
2007 Returns @true if a cell is either wholly visible (the default) or at least
2009 visible in the grid window.
2011 bool IsVisible(int row
, int col
, bool wholeCellVisible
= true) const;
2012 const bool IsVisible(const wxGridCellCoords
& coords
,
2013 bool wholeCellVisible
= true) const;
2018 Brings the specified cell into the visible grid cell area with minimal
2020 nothing if the cell is already visible.
2022 void MakeCellVisible(int row
, int col
);
2023 void MakeCellVisible(const wxGridCellCoords
& coords
);
2027 Moves the grid cursor down by one row. If a block of cells was previously
2029 will expand if the argument is @true or be cleared if the argument is @false.
2031 bool MoveCursorDown(bool expandSelection
);
2034 Moves the grid cursor down in the current column such that it skips to the
2036 end of a block of non-empty cells. If a block of cells was previously selected
2038 will expand if the argument is @true or be cleared if the argument is @false.
2040 bool MoveCursorDownBlock(bool expandSelection
);
2043 Moves the grid cursor left by one column. If a block of cells was previously
2045 will expand if the argument is @true or be cleared if the argument is @false.
2047 bool MoveCursorLeft(bool expandSelection
);
2050 Moves the grid cursor left in the current row such that it skips to the
2052 end of a block of non-empty cells. If a block of cells was previously selected
2054 will expand if the argument is @true or be cleared if the argument is @false.
2056 bool MoveCursorLeftBlock(bool expandSelection
);
2059 Moves the grid cursor right by one column. If a block of cells was previously
2061 will expand if the argument is @true or be cleared if the argument is @false.
2063 bool MoveCursorRight(bool expandSelection
);
2066 Moves the grid cursor right in the current row such that it skips to the
2068 end of a block of non-empty cells. If a block of cells was previously selected
2070 will expand if the argument is @true or be cleared if the argument is @false.
2072 bool MoveCursorRightBlock(bool expandSelection
);
2075 Moves the grid cursor up by one row. If a block of cells was previously
2077 will expand if the argument is @true or be cleared if the argument is @false.
2079 bool MoveCursorUp(bool expandSelection
);
2082 Moves the grid cursor up in the current column such that it skips to the
2084 end of a block of non-empty cells. If a block of cells was previously selected
2086 will expand if the argument is @true or be cleared if the argument is @false.
2088 bool MoveCursorUpBlock(bool expandSelection
);
2091 Moves the grid cursor down by some number of rows so that the previous bottom
2093 becomes the top visible row.
2095 bool MovePageDown();
2098 Moves the grid cursor up by some number of rows so that the previous top
2100 becomes the bottom visible row.
2105 Methods for a registry for mapping data types to Renderers/Editors
2107 void RegisterDataType(const wxString
& typeName
,
2108 wxGridCellRenderer
* renderer
,
2109 wxGridCellEditor
* editor
);
2112 Sets the value of the current grid cell to the current in-place edit control
2114 This is called automatically when the grid cursor moves from the current cell
2116 new cell. It is also a good idea to call this function when closing a grid since
2117 any edits to the final cell location will not be saved otherwise.
2119 void SaveEditControlValue();
2122 Selects all cells in the grid.
2128 Selects a rectangular block of cells. If addToSelected is @false then any
2129 existing selection will be
2130 deselected; if @true the column will be added to the existing selection.
2132 void SelectBlock(int topRow
, int leftCol
, int bottomRow
,
2134 bool addToSelected
= false);
2135 void SelectBlock(const wxGridCellCoords
& topLeft
,
2136 const wxGridCellCoords
& bottomRight
,
2137 bool addToSelected
= false);
2141 Selects the specified column. If addToSelected is @false then any existing
2143 deselected; if @true the column will be added to the existing selection.
2145 void SelectCol(int col
, bool addToSelected
= false);
2148 Selects the specified row. If addToSelected is @false then any existing
2150 deselected; if @true the row will be added to the existing selection.
2152 void SelectRow(int row
, bool addToSelected
= false);
2155 This function returns the rectangle that encloses the selected cells
2156 in device coords and clipped to the client size of the grid window.
2158 wxRect
SelectionToDeviceRect() const;
2162 Sets the horizontal and vertical alignment for grid cell text at the specified
2164 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2167 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2170 void SetCellAlignment(int row
, int col
, int horiz
, int vert
);
2171 void SetCellAlignment(int align
, int row
, int col
);
2177 void SetCellBackgroundColour(int row
, int col
,
2178 const wxColour
& colour
);
2181 Sets the editor for the grid cell at the specified location.
2182 The grid will take ownership of the pointer.
2183 See wxGridCellEditor and
2184 the @ref overview_gridoverview "wxGrid overview" for more information about
2185 cell editors and renderers.
2187 void SetCellEditor(int row
, int col
, wxGridCellEditor
* editor
);
2190 Sets the font for text in the grid cell at the specified location.
2192 void SetCellFont(int row
, int col
, const wxFont
& font
);
2195 Sets the renderer for the grid cell at the specified location.
2196 The grid will take ownership of the pointer.
2197 See wxGridCellRenderer and
2198 the @ref overview_gridoverview "wxGrid overview" for more information about
2199 cell editors and renderers.
2201 void SetCellRenderer(int row
, int col
,
2202 wxGridCellRenderer
* renderer
);
2206 Sets the text colour for the grid cell at the specified location.
2208 void SetCellTextColour(int row
, int col
, const wxColour
& colour
);
2209 void SetCellTextColour(const wxColour
& val
, int row
, int col
);
2210 void SetCellTextColour(const wxColour
& colour
);
2215 Sets the string value for the cell at the specified location. For simple
2216 applications where a
2217 grid object automatically uses a default grid table of string values you use
2218 this function together
2219 with GetCellValue() to access cell values.
2220 For more complex applications where you have derived your own grid table class
2222 various data types (e.g. numeric, boolean or user-defined custom types) then
2224 function for those cells that contain string values.
2225 The last form is for backward compatibility only.
2226 See wxGridTableBase::CanSetValueAs
2227 and the @ref overview_gridoverview "wxGrid overview" for more information.
2229 void SetCellValue(int row
, int col
, const wxString
& s
);
2230 void SetCellValue(const wxGridCellCoords
& coords
,
2232 void SetCellValue(const wxString
& val
, int row
, int col
);
2236 Sets the cell attributes for all cells in the specified column.
2237 For more information about controlling grid cell attributes see the
2238 wxGridCellAttr cell attribute class and the
2239 @ref overview_gridoverview.
2241 void SetColAttr(int col
, wxGridCellAttr
* attr
);
2244 Sets the specified column to display boolean values. wxGrid displays boolean
2245 values with a checkbox.
2247 void SetColFormatBool(int col
);
2250 Sets the specified column to display data in a custom format.
2251 See the @ref overview_gridoverview "wxGrid overview" for more information on
2253 with custom data types.
2255 void SetColFormatCustom(int col
, const wxString
& typeName
);
2258 Sets the specified column to display floating point values with the given width
2261 void SetColFormatFloat(int col
, int width
= -1,
2262 int precision
= -1);
2265 Sets the specified column to display integer values.
2267 void SetColFormatNumber(int col
);
2270 Sets the horizontal and vertical alignment of column label text.
2271 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 SetColLabelAlignment(int horiz
, int vert
);
2279 Sets the height of the column labels.
2280 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
2282 so that no label is truncated. Note that this could be slow for a large table.
2284 void SetColLabelSize(int height
);
2287 Set the value for the given column label. If you are using a derived grid table
2289 override wxGridTableBase::SetColLabelValue
2290 for this to have any effect.
2292 void SetColLabelValue(int col
, const wxString
& value
);
2295 This modifies the minimum column width that can be handled correctly.
2296 Specifying a low value here
2297 allows smaller grid cells to be dealt with correctly. Specifying a value here
2298 which is much smaller
2299 than the actual minimum size will incur a performance penalty in the functions
2301 grid cell index lookup on the basis of screen coordinates.
2302 This should normally be called when creating the grid because it will not
2303 resize existing columns
2304 with sizes smaller than the value specified here.
2306 void SetColMinimalAcceptableWidth(int width
);
2309 Sets the minimal width for the specified column. This should normally be called
2310 when creating the grid
2311 because it will not resize a column that is already narrower than the minimal
2313 The width argument must be higher than the minimimal acceptable column width,
2315 GetColMinimalAcceptableWidth().
2317 void SetColMinimalWidth(int col
, int width
);
2320 Sets the position of the specified column.
2322 void SetColPos(int colID
, int newPos
);
2325 Sets the width of the specified column.
2326 This function does not refresh the grid. If you are calling it outside of a
2327 BeginBatch / EndBatch
2328 block you can use ForceRefresh() to see the changes.
2329 Automatically sizes the column to fit its contents. If setAsMin is @true the
2330 calculated width will
2331 also be set as the minimal width for the column.
2333 void SetColSize(int col
, int width
);
2336 Sets the default horizontal and vertical alignment for grid cell text.
2337 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2339 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2342 void SetDefaultCellAlignment(int horiz
, int vert
);
2345 Sets the default background colour for grid cells.
2347 void SetDefaultCellBackgroundColour(const wxColour
& colour
);
2350 Sets the default font to be used for grid cell text.
2352 void SetDefaultCellFont(const wxFont
& font
);
2355 Sets the current default colour for grid cell text.
2357 void SetDefaultCellTextColour(const wxColour
& colour
);
2360 Sets the default width for columns in the grid. This will only affect columns
2361 subsequently added to
2362 the grid unless resizeExistingCols is @true.
2364 void SetDefaultColSize(int width
,
2365 bool resizeExistingCols
= false);
2368 Sets the default editor for grid cells. The grid will take ownership of the
2370 See wxGridCellEditor and
2371 the @ref overview_gridoverview "wxGrid overview" for more information about
2372 cell editors and renderers.
2374 void SetDefaultEditor(wxGridCellEditor
* editor
);
2377 Sets the default renderer for grid cells. The grid will take ownership of the
2379 See wxGridCellRenderer and
2380 the @ref overview_gridoverview "wxGrid overview" for more information about
2381 cell editors and renderers.
2383 void SetDefaultRenderer(wxGridCellRenderer
* renderer
);
2386 Sets the default height for rows in the grid. This will only affect rows
2388 to the grid unless resizeExistingRows is @true.
2390 void SetDefaultRowSize(int height
,
2391 bool resizeExistingRows
= false);
2394 Set the grid cursor to the specified cell.
2395 This function calls MakeCellVisible().
2397 void SetGridCursor(int row
, int col
);
2400 Sets the colour used to draw grid lines.
2402 void SetGridLineColour(const wxColour
& colour
);
2405 Sets the background colour for row and column labels.
2407 void SetLabelBackgroundColour(const wxColour
& colour
);
2410 Sets the font for row and column labels.
2412 void SetLabelFont(const wxFont
& font
);
2415 Sets the colour for row and column label text.
2417 void SetLabelTextColour(const wxColour
& colour
);
2420 A grid may occupy more space than needed for its rows/columns. This
2421 function allows to set how big this extra space is
2423 void SetMargins(int extraWidth
, int extraHeight
);
2426 Common part of AutoSizeColumn/Row() and GetBestSize()
2428 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= true);
2433 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= true);
2436 Makes the cell at the specified location read-only or editable.
2437 See also IsReadOnly().
2439 void SetReadOnly(int row
, int col
, bool isReadOnly
= true);
2442 Sets the cell attributes for all cells in the specified row.
2443 See the wxGridCellAttr class for more information
2444 about controlling cell attributes.
2446 void SetRowAttr(int row
, wxGridCellAttr
* attr
);
2449 Sets the horizontal and vertical alignment of row label text.
2450 Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or
2452 Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or
2455 void SetRowLabelAlignment(int horiz
, int vert
);
2458 Sets the width of the row labels.
2459 If @a width equals @c wxGRID_AUTOSIZE then width is calculated automatically
2460 so that no label is truncated. Note that this could be slow for a large table.
2462 void SetRowLabelSize(int width
);
2465 Set the value for the given row label. If you are using a derived grid table
2467 override wxGridTableBase::SetRowLabelValue
2468 for this to have any effect.
2470 void SetRowLabelValue(int row
, const wxString
& value
);
2473 This modifies the minimum row width that can be handled correctly. Specifying a
2475 allows smaller grid cells to be dealt with correctly. Specifying a value here
2476 which is much smaller
2477 than the actual minimum size will incur a performance penalty in the functions
2479 grid cell index lookup on the basis of screen coordinates.
2480 This should normally be called when creating the grid because it will not
2481 resize existing rows
2482 with sizes smaller than the value specified here.
2484 void SetRowMinimalAcceptableHeight(int height
);
2487 Sets the minimal height for the specified row. This should normally be called
2488 when creating the grid
2489 because it will not resize a row that is already shorter than the minimal
2491 The height argument must be higher than the minimimal acceptable row height, see
2492 GetRowMinimalAcceptableHeight().
2494 void SetRowMinimalHeight(int row
, int height
);
2497 Sets the height of the specified row.
2498 This function does not refresh the grid. If you are calling it outside of a
2499 BeginBatch / EndBatch
2500 block you can use ForceRefresh() to see the changes.
2501 Automatically sizes the column to fit its contents. If setAsMin is @true the
2502 calculated width will
2503 also be set as the minimal width for the column.
2505 void SetRowSize(int row
, int height
);
2508 Sets the number of pixels per horizontal scroll increment. The default is 15.
2509 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2510 errors: setting this to 1 can help.
2512 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2514 void SetScrollLineX(int x
);
2517 Sets the number of pixels per vertical scroll increment. The default is 15.
2518 Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding
2519 errors: setting this to 1 can help.
2521 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2523 void SetScrollLineY(int y
);
2528 void SetSelectionBackground(const wxColour
& c
);
2533 void SetSelectionForeground(const wxColour
& c
);
2536 Set the selection behaviour of the grid.
2538 The existing selection is converted to conform to the new mode if
2539 possible and discarded otherwise (e.g. any individual selected cells
2540 are deselected if the new mode allows only the selection of the entire
2543 void SetSelectionMode(wxGridSelectionModes selmode
);
2546 Passes a pointer to a custom grid table to be used by the grid. This should be
2548 after the grid constructor and before using the grid object. If takeOwnership
2550 @true then the table will be deleted by the wxGrid destructor.
2551 Use this function instead of CreateGrid() when your
2552 application involves complex or non-string data or data sets that are too large
2556 bool SetTable(wxGridTableBase
* table
,
2557 bool takeOwnership
= false,
2558 wxGridSelectionModes selmode
= wxGridSelectCells
);
2561 Call this in order to make the column labels use a native look by using
2562 wxRenderer::DrawHeaderButton internally.
2564 There is no equivalent method for drawing row columns as there is not
2565 native look for that. This option is useful when using wxGrid for
2566 displaying tables and not as a spread-sheet.
2568 void SetUseNativeColLabels(bool native
= true);
2571 Displays the in-place cell edit control for the current cell.
2573 void ShowCellEditControl();
2577 The x position to evaluate.
2579 If @true, rather than returning wxNOT_FOUND, it returns either the first or
2580 last column depending on whether x is too far to the left or right respectively.
2582 int XToCol(int x
, bool clipToMinMax
= false) const;
2585 Returns the column whose right hand edge is close to the given logical x
2587 If no column edge is near to this position @c wxNOT_FOUND is returned.
2589 int XToEdgeOfCol(int x
) const;
2592 Returns the row whose bottom edge is close to the given logical y position.
2593 If no row edge is near to this position @c wxNOT_FOUND is returned.
2595 int YToEdgeOfRow(int y
) const;
2598 Returns the grid row that corresponds to the logical y coordinate. Returns
2599 @c wxNOT_FOUND if there is no row at the y position.
2601 int YToRow(int y
) const;
2607 @class wxGridCellBoolEditor
2609 The editor for boolean data.
2614 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor,
2615 wxGridCellTextEditor, wxGridCellChoiceEditor
2617 class wxGridCellBoolEditor
: public wxGridCellEditor
2621 Default constructor.
2623 wxGridCellBoolEditor();
2626 Returns @true if the given @a value is equal to the string representation of
2627 the truth value we currently use (see
2628 wxGridCellBoolEditor::UseStringValues).
2630 static bool IsTrueValue(const wxString
& value
);
2633 , wxString&@e valueFalse = _T(""))
2634 This method allows to customize the values returned by GetValue() method for
2635 the cell using this editor. By default, the default values of the arguments are
2636 used, i.e. @c "1" is returned if the cell is checked and an empty string
2637 otherwise, using this method allows to change this.
2639 static void UseStringValues() const;
2645 @class wxGridUpdateLocker
2647 This small class can be used to prevent wxGrid from redrawing
2648 during its lifetime by calling wxGrid::BeginBatch
2649 in its constructor and wxGrid::EndBatch in its
2650 destructor. It is typically used in a function performing several operations
2651 with a grid which would otherwise result in flicker. For example:
2656 m_grid = new wxGrid(this, ...);
2658 wxGridUpdateLocker noUpdates(m_grid);
2659 m_grid-AppendColumn();
2660 ... many other operations with m_grid...
2663 // destructor called, grid refreshed
2667 Using this class is easier and safer than calling
2668 wxGrid::BeginBatch and wxGrid::EndBatch
2669 because you don't risk not to call the latter (due to an exception for example).
2674 class wxGridUpdateLocker
2678 Creates an object preventing the updates of the specified @e grid. The
2679 parameter could be @NULL in which case nothing is done. If @a grid is
2680 non-@NULL then the grid must exist for longer than wxGridUpdateLocker object
2682 The default constructor could be followed by a call to
2686 wxGridUpdateLocker(wxGrid
* grid
= NULL
);
2689 Destructor reenables updates for the grid this object is associated with.
2691 ~wxGridUpdateLocker();
2694 This method can be called if the object had been constructed using the default
2695 constructor. It must not be called more than once.
2697 void Create(wxGrid
* grid
);