]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/grid.h
fix docs for wxInputStream::GetC(); fixes #4461
[wxWidgets.git] / interface / wx / grid.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: grid.h
e54c96f1 3// Purpose: interface of wxGridCellFloatRenderer
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxGridCellFloatRenderer
7c913512 11
23324ae1 12 This class may be used to format floating point data in a cell.
7c913512 13
23324ae1 14 @library{wxadv}
42b5841f 15 @category{grid}
7c913512 16
e54c96f1 17 @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer,
23324ae1
FM
18 wxGridCellBoolRenderer
19*/
20class wxGridCellFloatRenderer : public wxGridCellStringRenderer
21{
22public:
23 /**
7c913512 24 @param width
4cc4bfaf 25 Minimum number of characters to be shown.
7c913512 26 @param precision
4cc4bfaf 27 Number of digits after the decimal dot.
23324ae1
FM
28 */
29 wxGridCellFloatRenderer(int width = -1, int precision = -1);
30
31 /**
42b5841f 32 Returns the precision.
23324ae1 33 */
328f5751 34 int GetPrecision() const;
23324ae1
FM
35
36 /**
42b5841f 37 Returns the width.
23324ae1 38 */
328f5751 39 int GetWidth() const;
23324ae1
FM
40
41 /**
42 Parameters string format is "width[,precision]".
43 */
adaaa686 44 virtual void SetParameters(const wxString& params);
23324ae1
FM
45
46 /**
42b5841f 47 Sets the precision.
23324ae1
FM
48 */
49 void SetPrecision(int precision);
50
51 /**
42b5841f 52 Sets the width.
23324ae1
FM
53 */
54 void SetWidth(int width);
55};
56
57
e54c96f1 58
23324ae1
FM
59/**
60 @class wxGridTableBase
7c913512 61
5039f140
VZ
62 The almost abstract base class for grid tables.
63
64 A grid table is responsible for storing the grid data and, indirectly, grid
65 cell attributes. The data can be stored in the way most convenient for the
66 application but has to be provided in string form to wxGrid. It is also
67 possible to provide cells values in other formats if appropriate, e.g. as
68 numbers.
69
70 This base class is not quite abstract as it implements a trivial strategy
71 for storing the attributes by forwarding it to wxGridCellAttrProvider and
72 also provides stubs for some other functions. However it does have a number
73 of pure virtual methods which must be implemented in the derived classes.
74
75 @see wxGridStringTable
7c913512 76
23324ae1 77 @library{wxadv}
42b5841f 78 @category{grid}
23324ae1
FM
79*/
80class wxGridTableBase : public wxObject
81{
82public:
5039f140 83 /// Default constructor.
23324ae1
FM
84 wxGridTableBase();
85
5039f140
VZ
86 /// Destructor frees the attribute provider if it was created.
87 virtual ~wxGridTableBase();
3c4f71cc 88
77d2c45c
VZ
89 /**
90 Must be overridden to return the number of rows in the table.
91
92 For backwards compatibility reasons, this method is not const.
93 Use GetRowsCount() instead of it in const methods of derived table
94 classes.
95 */
5039f140 96 virtual int GetNumberRows() = 0;
23324ae1 97
77d2c45c
VZ
98 /**
99 Must be overridden to return the number of columns in the table.
100
101 For backwards compatibility reasons, this method is not const.
102 Use GetColsCount() instead of it in const methods of derived table
103 classes,
104 */
5039f140 105 virtual int GetNumberCols() = 0;
3c4f71cc 106
77d2c45c
VZ
107 /**
108 Return the number of rows in the table.
109
110 This method is not virtual and is only provided as a convenience for
111 the derived classes which can't call GetNumberRows() without a @c
112 const_cast from their const methods.
113 */
114 int GetRowsCount() const;
115
116 /**
117 Return the number of columns in the table.
118
119 This method is not virtual and is only provided as a convenience for
120 the derived classes which can't call GetNumberCols() without a @c
121 const_cast from their const methods.
122 */
123 int GetColsCount() const;
124
23324ae1
FM
125
126 /**
5039f140
VZ
127 Accessing table cells.
128 */
129 //@{
3c4f71cc 130
5039f140
VZ
131 /// Must be overridden to implement testing for empty cells.
132 virtual bool IsEmptyCell(int row, int col) = 0;
23324ae1 133
10a4531d
VZ
134 /**
135 Same as IsEmptyCell() but taking wxGridCellCoords.
136
137 Notice that this method is not virtual, only IsEmptyCell() should be
138 overridden.
139 */
140 bool IsEmpty(const wxGridCellCoords& coords);
141
5039f140
VZ
142 /// Must be overridden to implement accessing the table values as text.
143 virtual wxString GetValue(int row, int col) = 0;
3c4f71cc 144
5039f140
VZ
145 /// Must be overridden to implement setting the table values as text.
146 virtual void SetValue(int row, int col, const wxString& value) = 0;
23324ae1
FM
147
148 /**
5039f140
VZ
149 Returns the type of the value in the given cell.
150
151 By default all cells are strings and this method returns @c
152 wxGRID_VALUE_STRING.
153 */
154 virtual wxString GetTypeName(int row, int col);
23324ae1
FM
155
156 /**
5039f140
VZ
157 Returns true if the value of the given cell can be accessed as if it
158 were of the specified type.
3c4f71cc 159
5039f140
VZ
160 By default the cells can only be accessed as strings. Note that a cell
161 could be accessible in different ways, e.g. a numeric cell may return
162 @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
163 indicating that the value can be coerced to a string form.
164 */
165 virtual bool CanGetValueAs(int row, int col, const wxString& typeName);
23324ae1
FM
166
167 /**
5039f140
VZ
168 Returns true if the value of the given cell can be set as if it were of
169 the specified type.
3c4f71cc 170
5039f140
VZ
171 @see CanGetValueAs()
172 */
173 virtual bool CanSetValueAs(int row, int col, const wxString& typeName);
23324ae1
FM
174
175 /**
5039f140 176 Returns the value of the given cell as a long.
3c4f71cc 177
5039f140
VZ
178 This should only be called if CanGetValueAs() returns @true when called
179 with @c wxGRID_VALUE_NUMBER argument. Default implementation always
180 return 0.
181 */
182 virtual long GetValueAsLong(int row, int col);
23324ae1
FM
183
184 /**
5039f140 185 Returns the value of the given cell as a double.
3c4f71cc 186
5039f140
VZ
187 This should only be called if CanGetValueAs() returns @true when called
188 with @c wxGRID_VALUE_FLOAT argument. Default implementation always
189 return 0.0.
190 */
191 virtual double GetValueAsDouble(int row, int col);
23324ae1
FM
192
193 /**
5039f140 194 Returns the value of the given cell as a boolean.
23324ae1 195
5039f140
VZ
196 This should only be called if CanGetValueAs() returns @true when called
197 with @c wxGRID_VALUE_BOOL argument. Default implementation always
198 return false.
199 */
200 virtual bool GetValueAsBool(int row, int col);
23324ae1
FM
201
202 /**
5039f140
VZ
203 Returns the value of the given cell as a user-defined type.
204
205 This should only be called if CanGetValueAs() returns @true when called
206 with @a typeName. Default implementation always return @NULL.
207 */
208 virtual void *GetValueAsCustom(int row, int col, const wxString& typeName);
3c4f71cc 209
23324ae1
FM
210
211 /**
5039f140 212 Sets the value of the given cell as a long.
3c4f71cc 213
5039f140
VZ
214 This should only be called if CanSetValueAs() returns @true when called
215 with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
216 anything.
217 */
218 virtual void SetValueAsLong(int row, int col, long value);
23324ae1
FM
219
220 /**
5039f140
VZ
221 Sets the value of the given cell as a double.
222
223 This should only be called if CanSetValueAs() returns @true when called
224 with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
225 anything.
226 */
227 virtual void SetValueAsDouble(int row, int col, double value);
23324ae1
FM
228
229 /**
5039f140 230 Sets the value of the given cell as a boolean.
3c4f71cc 231
5039f140
VZ
232 This should only be called if CanSetValueAs() returns @true when called
233 with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
234 anything.
235 */
236 virtual void SetValueAsBool( int row, int col, bool value );
23324ae1
FM
237
238 /**
5039f140 239 Sets the value of the given cell as a user-defined type.
23324ae1 240
5039f140
VZ
241 This should only be called if CanSetValueAs() returns @true when called
242 with @a typeName. Default implementation doesn't do anything.
243 */
244 virtual void SetValueAsCustom(int row, int col, const wxString& typeName,
245 void *value);
3c4f71cc 246
5039f140 247 //@}
23324ae1
FM
248
249 /**
5039f140 250 Called by the grid when the table is associated with it.
3c4f71cc 251
5039f140
VZ
252 The default implementation stores the pointer and returns it from its
253 GetView() and so only makes sense if the table cannot be associated
254 with more than one grid at a time.
255 */
256 virtual void SetView(wxGrid *grid);
23324ae1
FM
257
258 /**
5039f140
VZ
259 Returns the last grid passed to SetView().
260 */
261 virtual wxGrid *GetView() const;
262
23324ae1
FM
263
264 /**
5039f140 265 Modifying the table structure.
3c4f71cc 266
5039f140
VZ
267 Notice that none of these functions are pure virtual as they don't have
268 to be implemented if the table structure is never modified after
269 creation, i.e. neither rows nor columns are never added or deleted but
270 that you do need to implement them if they are called, i.e. if your
271 code either calls them directly or uses the matching wxGrid methods, as
272 by default they simply do nothing which is definitely inappropriate.
273 */
274 //@{
23324ae1
FM
275
276 /**
5039f140 277 Clear the table contents.
3c4f71cc 278
5039f140
VZ
279 This method is used by wxGrid::ClearGrid().
280 */
281 virtual void Clear();
23324ae1
FM
282
283 /**
5039f140 284 Insert additional rows into the table.
3c4f71cc 285
5039f140
VZ
286 @param pos
287 The position of the first new row.
288 @param numRows
289 The number of rows to insert.
290 */
291 virtual bool InsertRows(size_t pos = 0, size_t numRows = 1);
23324ae1
FM
292
293 /**
5039f140 294 Append additional rows at the end of the table.
3c4f71cc 295
5039f140
VZ
296 This method is provided in addition to InsertRows() as some data models
297 may only support appending rows to them but not inserting them at
298 arbitrary locations. In such case you may implement this method only
299 and leave InsertRows() unimplemented.
300
5039f140
VZ
301 @param numRows
302 The number of rows to add.
303 */
304 virtual bool AppendRows(size_t numRows = 1);
23324ae1
FM
305
306 /**
5039f140 307 Delete rows from the table.
3c4f71cc 308
5039f140
VZ
309 @param pos
310 The first row to delete.
311 @param numRows
312 The number of rows to delete.
313 */
314 virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1);
23324ae1 315
5039f140
VZ
316 /// Exactly the same as InsertRows() but for columns.
317 virtual bool InsertCols(size_t pos = 0, size_t numCols = 1);
3c4f71cc 318
5039f140
VZ
319 /// Exactly the same as AppendRows() but for columns.
320 virtual bool AppendCols(size_t numCols = 1);
23324ae1 321
5039f140
VZ
322 /// Exactly the same as DeleteRows() but for columns.
323 virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1);
23324ae1 324
5039f140 325 //@}
23324ae1
FM
326
327 /**
5039f140 328 Table rows and columns labels.
3c4f71cc 329
5039f140
VZ
330 By default the numbers are used for labeling rows and Latin letters for
331 labeling columns. If the table has more than 26 columns, the pairs of
332 letters are used starting from the 27-th one and so on, i.e. the
333 sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
334 AAA, ...
335 */
336 //@{
23324ae1 337
5039f140
VZ
338 /// Return the label of the specified row.
339 virtual wxString GetRowLabelValue(int row);
340
341 /// Return the label of the specified column.
342 virtual wxString GetColLabelValue(int col);
23324ae1
FM
343
344 /**
5039f140 345 Set the given label for the specified row.
3c4f71cc 346
5039f140
VZ
347 The default version does nothing, i.e. the label is not stored. You
348 must override this method in your derived class if you wish
349 wxGrid::SetRowLabelValue() to work.
350 */
351 virtual void SetRowLabelValue(int row, const wxString& label);
352
353 /// Exactly the same as SetRowLabelValue() but for columns.
354 virtual void SetColLabelValue(int col, const wxString& label);
355
356 //@}
23324ae1 357
23324ae1
FM
358
359 /**
5039f140 360 Attributes management.
3c4f71cc 361
5039f140
VZ
362 By default the attributes management is delegated to
363 wxGridCellAttrProvider class. You may override the methods in this
364 section to handle the attributes directly if, for example, they can be
365 computed from the cell values.
366 */
367 //@{
23324ae1
FM
368
369 /**
5039f140 370 Associate this attributes provider with the table.
3c4f71cc 371
5039f140
VZ
372 The table takes ownership of @a attrProvider pointer and will delete it
373 when it doesn't need it any more. The pointer can be @NULL, however
374 this won't disable attributes management in the table but will just
375 result in a default attributes being recreated the next time any of the
376 other functions in this section is called. To completely disable the
377 attributes support, should this be needed, you need to override
378 CanHaveAttributes() to return @false.
379 */
380 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
23324ae1
FM
381
382 /**
5039f140 383 Returns the attribute provider currently being used.
3c4f71cc 384
5039f140
VZ
385 This function may return @NULL if the attribute provider hasn't been
386 neither associated with this table by SetAttrProvider() nor created on
387 demand by any other methods.
388 */
78e37b46 389 wxGridCellAttrProvider *GetAttrProvider() const;
23324ae1 390
23324ae1 391 /**
5039f140 392 Return the attribute for the given cell.
3c4f71cc 393
5039f140
VZ
394 By default this function is simply forwarded to
395 wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
396 attributes directly in the table.
397 */
398 virtual wxGridCellAttr *GetAttr(int row, int col,
399 wxGridCellAttr::wxAttrKind kind);
23324ae1
FM
400
401 /**
5039f140
VZ
402 Set attribute of the specified cell.
403
404 By default this function is simply forwarded to
405 wxGridCellAttrProvider::SetAttr().
406
407 The table takes ownership of @a attr, i.e. will call DecRef() on it.
408 */
409 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
23324ae1
FM
410
411 /**
5039f140 412 Set attribute of the specified row.
3c4f71cc 413
5039f140
VZ
414 By default this function is simply forwarded to
415 wxGridCellAttrProvider::SetRowAttr().
416
417 The table takes ownership of @a attr, i.e. will call DecRef() on it.
418 */
419 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
23324ae1
FM
420
421 /**
5039f140
VZ
422 Set attribute of the specified column.
423
424 By default this function is simply forwarded to
425 wxGridCellAttrProvider::SetColAttr().
426
427 The table takes ownership of @a attr, i.e. will call DecRef() on it.
428 */
429 virtual void SetColAttr(wxGridCellAttr *attr, int col);
430
431 //@}
5e6e278d
FM
432
433 /**
434 Returns true if this table supports attributes or false otherwise.
435
436 By default, the table automatically creates a wxGridCellAttrProvider
437 when this function is called if it had no attribute provider before and
438 returns @true.
439 */
440 virtual bool CanHaveAttributes();
23324ae1
FM
441};
442
443
e54c96f1 444
23324ae1
FM
445/**
446 @class wxGridCellEditor
7c913512 447
23324ae1
FM
448 This class is responsible for providing and manipulating
449 the in-place edit controls for the grid. Instances of wxGridCellEditor
450 (actually, instances of derived classes since it is an abstract class) can be
451 associated with the cell attributes for individual cells, rows, columns, or
452 even for the entire grid.
7c913512 453
23324ae1 454 @library{wxadv}
42b5841f 455 @category{grid}
7c913512 456
e54c96f1 457 @see wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
23324ae1
FM
458 wxGridCellNumberEditor, wxGridCellChoiceEditor
459*/
7c913512 460class wxGridCellEditor
23324ae1
FM
461{
462public:
463 /**
3c4f71cc 464
23324ae1
FM
465 */
466 wxGridCellEditor();
467
23324ae1
FM
468 /**
469 Fetch the value from the table and prepare the edit control
470 to begin editing. Set the focus to the edit control.
471 */
da1ed74c 472 virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
23324ae1
FM
473
474 /**
475 Create a new object which is the copy of this one.
476 */
da1ed74c 477 virtual wxGridCellEditor* Clone() const = 0;
23324ae1
FM
478
479 /**
480 Creates the actual edit control.
481 */
fadc2df6
FM
482 virtual void Create(wxWindow* parent, wxWindowID id,
483 wxEvtHandler* evtHandler) = 0;
23324ae1
FM
484
485 /**
486 Final cleanup.
487 */
adaaa686 488 virtual void Destroy();
23324ae1
FM
489
490 /**
491 Complete the editing of the current cell. Returns @true if the value has
492 changed. If necessary, the control may be destroyed.
493 */
da1ed74c 494 virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
23324ae1
FM
495
496 /**
497 Some types of controls on some platforms may need some help
498 with the Return key.
499 */
adaaa686 500 virtual void HandleReturn(wxKeyEvent& event);
23324ae1
FM
501
502 /**
3c4f71cc 503
23324ae1
FM
504 */
505 bool IsCreated();
506
507 /**
508 Draws the part of the cell not occupied by the control: the base class
509 version just fills it with background colour from the attribute.
510 */
fadc2df6 511 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr* attr);
23324ae1
FM
512
513 /**
514 Reset the value in the control back to its starting value.
515 */
da1ed74c 516 virtual void Reset() = 0;
23324ae1
FM
517
518 /**
519 Size and position the edit control.
520 */
adaaa686 521 virtual void SetSize(const wxRect& rect);
23324ae1
FM
522
523 /**
524 Show or hide the edit control, use the specified attributes to set
525 colours/fonts for it.
526 */
adaaa686 527 virtual void Show(bool show, wxGridCellAttr* attr = NULL);
23324ae1
FM
528
529 /**
530 If the editor is enabled by clicking on the cell, this method will be
531 called.
532 */
adaaa686 533 virtual void StartingClick();
23324ae1
FM
534
535 /**
536 If the editor is enabled by pressing keys on the grid,
537 this will be called to let the editor do something about
538 that first key if desired.
539 */
adaaa686 540 virtual void StartingKey(wxKeyEvent& event);
5e6e278d
FM
541
542protected:
543
544 /**
545 The dtor is private because only DecRef() can delete us.
546 */
547 virtual ~wxGridCellEditor();
23324ae1
FM
548};
549
550
e54c96f1 551
23324ae1
FM
552/**
553 @class wxGridCellTextEditor
7c913512 554
23324ae1 555 The editor for string/text data.
7c913512 556
23324ae1 557 @library{wxadv}
42b5841f 558 @category{grid}
7c913512 559
e54c96f1 560 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
23324ae1
FM
561 wxGridCellNumberEditor, wxGridCellChoiceEditor
562*/
563class wxGridCellTextEditor : public wxGridCellEditor
564{
565public:
566 /**
567 Default constructor.
568 */
569 wxGridCellTextEditor();
570
571 /**
572 The parameters string format is "n" where n is a number representing the
573 maximum width.
574 */
adaaa686 575 virtual void SetParameters(const wxString& params);
23324ae1
FM
576};
577
578
e54c96f1 579
23324ae1
FM
580/**
581 @class wxGridCellStringRenderer
7c913512 582
23324ae1
FM
583 This class may be used to format string data in a cell; it is the default
584 for string cells.
7c913512 585
23324ae1 586 @library{wxadv}
42b5841f 587 @category{grid}
7c913512 588
e54c96f1 589 @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer,
23324ae1
FM
590 wxGridCellBoolRenderer
591*/
592class wxGridCellStringRenderer : public wxGridCellRenderer
593{
594public:
595 /**
596 Default constructor
597 */
598 wxGridCellStringRenderer();
599};
600
601
e54c96f1 602
23324ae1
FM
603/**
604 @class wxGridCellChoiceEditor
7c913512 605
23324ae1 606 The editor for string data allowing to choose from a list of strings.
7c913512 607
23324ae1 608 @library{wxadv}
42b5841f 609 @category{grid}
7c913512 610
e54c96f1 611 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
23324ae1
FM
612 wxGridCellTextEditor, wxGridCellNumberEditor
613*/
614class wxGridCellChoiceEditor : public wxGridCellEditor
615{
616public:
617 //@{
618 /**
7c913512 619 @param count
4cc4bfaf 620 Number of strings from which the user can choose.
7c913512 621 @param choices
4cc4bfaf 622 An array of strings from which the user can choose.
7c913512 623 @param allowOthers
4cc4bfaf 624 If allowOthers is @true, the user can type a string not in choices array.
23324ae1
FM
625 */
626 wxGridCellChoiceEditor(size_t count = 0,
4cc4bfaf
FM
627 const wxString choices[] = NULL,
628 bool allowOthers = false);
12fd0e1d
VZ
629 /**
630 @param choices
631 An array of strings from which the user can choose.
632 @param allowOthers
633 If allowOthers is @true, the user can type a string not in choices array.
634 */
7c913512 635 wxGridCellChoiceEditor(const wxArrayString& choices,
4cc4bfaf 636 bool allowOthers = false);
23324ae1
FM
637 //@}
638
639 /**
640 Parameters string format is "item1[,item2[...,itemN]]"
641 */
adaaa686 642 virtual void SetParameters(const wxString& params);
23324ae1
FM
643};
644
645
e54c96f1 646
23324ae1
FM
647/**
648 @class wxGridEditorCreatedEvent
7c913512
FM
649
650
23324ae1 651 @library{wxadv}
42b5841f 652 @category{grid}
23324ae1
FM
653*/
654class wxGridEditorCreatedEvent : public wxCommandEvent
655{
656public:
657 //@{
658 /**
3c4f71cc 659
23324ae1
FM
660 */
661 wxGridEditorCreatedEvent();
7c913512
FM
662 wxGridEditorCreatedEvent(int id, wxEventType type,
663 wxObject* obj,
664 int row,
665 int col,
666 wxControl* ctrl);
23324ae1
FM
667 //@}
668
669 /**
670 Returns the column at which the event occurred.
671 */
672 int GetCol();
673
674 /**
675 Returns the edit control.
676 */
677 wxControl* GetControl();
678
679 /**
680 Returns the row at which the event occurred.
681 */
682 int GetRow();
683
684 /**
685 Sets the column at which the event occurred.
686 */
687 void SetCol(int col);
688
689 /**
690 Sets the edit control.
691 */
692 void SetControl(wxControl* ctrl);
693
694 /**
695 Sets the row at which the event occurred.
696 */
697 void SetRow(int row);
698};
699
700
e54c96f1 701
23324ae1
FM
702/**
703 @class wxGridRangeSelectEvent
7c913512
FM
704
705
23324ae1 706 @library{wxadv}
42b5841f 707 @category{grid}
23324ae1
FM
708*/
709class wxGridRangeSelectEvent : public wxNotifyEvent
710{
711public:
712 //@{
713 /**
3c4f71cc 714
23324ae1
FM
715 */
716 wxGridRangeSelectEvent();
7c913512
FM
717 wxGridRangeSelectEvent(int id, wxEventType type,
718 wxObject* obj,
719 const wxGridCellCoords& topLeft,
720 const wxGridCellCoords& bottomRight,
4cc4bfaf
FM
721 bool sel = true,
722 bool control = false,
723 bool shift = false,
724 bool alt = false,
725 bool meta = false);
23324ae1
FM
726 //@}
727
728 /**
729 Returns @true if the Alt key was down at the time of the event.
730 */
0004982c 731 bool AltDown() const;
23324ae1
FM
732
733 /**
734 Returns @true if the Control key was down at the time of the event.
735 */
0004982c 736 bool ControlDown() const;
23324ae1
FM
737
738 /**
739 Top left corner of the rectangular area that was (de)selected.
740 */
741 wxGridCellCoords GetBottomRightCoords();
742
743 /**
744 Bottom row of the rectangular area that was (de)selected.
745 */
746 int GetBottomRow();
747
748 /**
749 Left column of the rectangular area that was (de)selected.
750 */
751 int GetLeftCol();
752
753 /**
754 Right column of the rectangular area that was (de)selected.
755 */
756 int GetRightCol();
757
758 /**
759 Top left corner of the rectangular area that was (de)selected.
760 */
761 wxGridCellCoords GetTopLeftCoords();
762
763 /**
764 Top row of the rectangular area that was (de)selected.
765 */
766 int GetTopRow();
767
768 /**
769 Returns @true if the Meta key was down at the time of the event.
770 */
0004982c 771 bool MetaDown() const;
23324ae1
FM
772
773 /**
774 Returns @true if the area was selected, @false otherwise.
775 */
776 bool Selecting();
777
778 /**
779 Returns @true if the Shift key was down at the time of the event.
780 */
0004982c 781 bool ShiftDown() const;
23324ae1
FM
782};
783
784
e54c96f1 785
23324ae1
FM
786/**
787 @class wxGridCellRenderer
7c913512 788
23324ae1
FM
789 This class is responsible for actually drawing the cell
790 in the grid. You may pass it to the wxGridCellAttr (below) to change the
791 format of one given cell or to wxGrid::SetDefaultRenderer() to change the
792 view of all cells. This is an abstract class, and you will normally use one of
793 the
794 predefined derived classes or derive your own class from it.
7c913512 795
23324ae1 796 @library{wxadv}
42b5841f 797 @category{grid}
7c913512 798
e54c96f1
FM
799 @see wxGridCellStringRenderer, wxGridCellNumberRenderer,
800 wxGridCellFloatRenderer, wxGridCellBoolRenderer
23324ae1 801*/
7c913512 802class wxGridCellRenderer
23324ae1
FM
803{
804public:
805 /**
3c4f71cc 806
23324ae1 807 */
da1ed74c 808 virtual wxGridCellRenderer* Clone() const = 0;
23324ae1
FM
809
810 /**
811 Draw the given cell on the provided DC inside the given rectangle
812 using the style specified by the attribute and the default or selected
813 state corresponding to the isSelected value.
23324ae1
FM
814 This pure virtual function has a default implementation which will
815 prepare the DC using the given attribute: it will draw the rectangle
816 with the background colour from attr and set the text colour and font.
817 */
da1ed74c
FM
818 virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
819 const wxRect& rect, int row, int col,
820 bool isSelected) = 0;
23324ae1
FM
821
822 /**
823 Get the preferred size of the cell for its contents.
824 */
fadc2df6
FM
825 virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
826 int row, int col) = 0;
23324ae1
FM
827};
828
829
e54c96f1 830
23324ae1
FM
831/**
832 @class wxGridCellNumberEditor
7c913512 833
23324ae1 834 The editor for numeric integer data.
7c913512 835
23324ae1 836 @library{wxadv}
42b5841f 837 @category{grid}
7c913512 838
e54c96f1 839 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor,
23324ae1
FM
840 wxGridCellTextEditor, wxGridCellChoiceEditor
841*/
842class wxGridCellNumberEditor : public wxGridCellTextEditor
843{
844public:
845 /**
846 Allows to specify the range for acceptable data;
847 if min == max == -1, no range checking is done
848 */
849 wxGridCellNumberEditor(int min = -1, int max = -1);
850
5e6e278d 851
23324ae1 852 /**
5e6e278d 853 Parameters string format is "min,max".
23324ae1 854 */
5e6e278d
FM
855 virtual void SetParameters(const wxString& params);
856
857protected:
23324ae1
FM
858
859 /**
860 If the return value is @true, the editor uses a wxSpinCtrl to get user input,
861 otherwise it uses a wxTextCtrl.
862 */
328f5751 863 bool HasRange() const;
23324ae1
FM
864
865 /**
5e6e278d 866 String representation of the value.
23324ae1 867 */
5e6e278d 868 wxString GetString() const;
23324ae1
FM
869};
870
871
e54c96f1 872
23324ae1
FM
873/**
874 @class wxGridSizeEvent
7c913512 875
23324ae1 876 This event class contains information about a row/column resize event.
7c913512 877
23324ae1 878 @library{wxadv}
42b5841f 879 @category{grid}
23324ae1
FM
880*/
881class wxGridSizeEvent : public wxNotifyEvent
882{
883public:
884 //@{
885 /**
3c4f71cc 886
23324ae1
FM
887 */
888 wxGridSizeEvent();
7c913512
FM
889 wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
890 int rowOrCol = -1,
891 int x = -1,
892 int y = -1,
4cc4bfaf
FM
893 bool control = false,
894 bool shift = false,
895 bool alt = false,
896 bool meta = false);
23324ae1
FM
897 //@}
898
899 /**
900 Returns @true if the Alt key was down at the time of the event.
901 */
0004982c 902 bool AltDown() const;
23324ae1
FM
903
904 /**
905 Returns @true if the Control key was down at the time of the event.
906 */
0004982c 907 bool ControlDown() const;
23324ae1
FM
908
909 /**
910 Position in pixels at which the event occurred.
911 */
912 wxPoint GetPosition();
913
914 /**
915 Row or column at that was resized.
916 */
917 int GetRowOrCol();
918
919 /**
920 Returns @true if the Meta key was down at the time of the event.
921 */
0004982c 922 bool MetaDown() const;
23324ae1
FM
923
924 /**
925 Returns @true if the Shift key was down at the time of the event.
926 */
0004982c 927 bool ShiftDown() const;
23324ae1
FM
928};
929
930
e54c96f1 931
23324ae1
FM
932/**
933 @class wxGridCellNumberRenderer
7c913512 934
23324ae1 935 This class may be used to format integer data in a cell.
7c913512 936
23324ae1 937 @library{wxadv}
42b5841f 938 @category{grid}
7c913512 939
e54c96f1 940 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
23324ae1
FM
941 wxGridCellBoolRenderer
942*/
943class wxGridCellNumberRenderer : public wxGridCellStringRenderer
944{
945public:
946 /**
947 Default constructor
948 */
949 wxGridCellNumberRenderer();
950};
951
952
e54c96f1 953
23324ae1
FM
954/**
955 @class wxGridCellAttr
7c913512 956
23324ae1
FM
957 This class can be used to alter the cells' appearance in
958 the grid by changing their colour/font/... from default. An object of this
959 class may be returned by wxGridTableBase::GetAttr.
7c913512 960
23324ae1 961 @library{wxadv}
42b5841f 962 @category{grid}
23324ae1 963*/
7c913512 964class wxGridCellAttr
23324ae1
FM
965{
966public:
967 //@{
968 /**
969 Constructor specifying some of the often used attributes.
970 */
971 wxGridCellAttr();
7c913512
FM
972 wxGridCellAttr(const wxColour& colText,
973 const wxColour& colBack,
974 const wxFont& font,
975 int hAlign, int vAlign);
23324ae1
FM
976 //@}
977
978 /**
979 Creates a new copy of this object.
980 */
328f5751 981 wxGridCellAttr* Clone() const;
23324ae1
FM
982
983 /**
3c4f71cc 984
23324ae1
FM
985 */
986 void DecRef();
987
988 /**
989 See SetAlignment() for the returned values.
990 */
328f5751 991 void GetAlignment(int* hAlign, int* vAlign) const;
23324ae1
FM
992
993 /**
3c4f71cc 994
23324ae1 995 */
5267aefd 996 const wxColour& GetBackgroundColour() const;
23324ae1
FM
997
998 /**
3c4f71cc 999
23324ae1 1000 */
5267aefd 1001 wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const;
23324ae1
FM
1002
1003 /**
3c4f71cc 1004
23324ae1 1005 */
5267aefd 1006 const wxFont& GetFont() const;
23324ae1
FM
1007
1008 /**
3c4f71cc 1009
23324ae1 1010 */
5267aefd 1011 wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const;
23324ae1
FM
1012
1013 /**
3c4f71cc 1014
23324ae1 1015 */
5267aefd 1016 const wxColour& GetTextColour() const;
23324ae1
FM
1017
1018 /**
3c4f71cc 1019
23324ae1 1020 */
328f5751 1021 bool HasAlignment() const;
23324ae1
FM
1022
1023 /**
3c4f71cc 1024
23324ae1 1025 */
328f5751 1026 bool HasBackgroundColour() const;
23324ae1
FM
1027
1028 /**
3c4f71cc 1029
23324ae1 1030 */
328f5751 1031 bool HasEditor() const;
23324ae1
FM
1032
1033 /**
3c4f71cc 1034
23324ae1 1035 */
328f5751 1036 bool HasFont() const;
23324ae1
FM
1037
1038 /**
3c4f71cc 1039
23324ae1 1040 */
328f5751 1041 bool HasRenderer() const;
23324ae1
FM
1042
1043 /**
1044 accessors
1045 */
328f5751 1046 bool HasTextColour() const;
23324ae1
FM
1047
1048 /**
1049 This class is ref counted: it is created with ref count of 1, so
1050 calling DecRef() once will delete it. Calling IncRef() allows to lock
1051 it until the matching DecRef() is called
1052 */
1053 void IncRef();
1054
1055 /**
3c4f71cc 1056
23324ae1 1057 */
328f5751 1058 bool IsReadOnly() const;
23324ae1
FM
1059
1060 /**
4cc4bfaf
FM
1061 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
1062 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one
23324ae1
FM
1063 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1064 */
1065 void SetAlignment(int hAlign, int vAlign);
1066
1067 /**
1068 Sets the background colour.
1069 */
1070 void SetBackgroundColour(const wxColour& colBack);
1071
1072 /**
3c4f71cc 1073
23324ae1
FM
1074 */
1075 void SetDefAttr(wxGridCellAttr* defAttr);
1076
1077 /**
3c4f71cc 1078
23324ae1
FM
1079 */
1080 void SetEditor(wxGridCellEditor* editor);
1081
1082 /**
1083 Sets the font.
1084 */
1085 void SetFont(const wxFont& font);
1086
1087 /**
3c4f71cc 1088
23324ae1 1089 */
4cc4bfaf 1090 void SetReadOnly(bool isReadOnly = true);
23324ae1
FM
1091
1092 /**
1093 takes ownership of the pointer
1094 */
1095 void SetRenderer(wxGridCellRenderer* renderer);
1096
1097 /**
1098 Sets the text colour.
1099 */
1100 void SetTextColour(const wxColour& colText);
1101};
1102
1103
e54c96f1 1104
23324ae1
FM
1105/**
1106 @class wxGridCellBoolRenderer
7c913512 1107
23324ae1
FM
1108 This class may be used to format boolean data in a cell.
1109 for string cells.
7c913512 1110
23324ae1 1111 @library{wxadv}
42b5841f 1112 @category{grid}
7c913512 1113
e54c96f1 1114 @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer,
23324ae1
FM
1115 wxGridCellNumberRenderer
1116*/
1117class wxGridCellBoolRenderer : public wxGridCellRenderer
1118{
1119public:
1120 /**
1121 Default constructor
1122 */
1123 wxGridCellBoolRenderer();
1124};
1125
1126
e54c96f1 1127
23324ae1
FM
1128/**
1129 @class wxGridEvent
7c913512 1130
23324ae1 1131 This event class contains information about various grid events.
7c913512 1132
23324ae1 1133 @library{wxadv}
42b5841f 1134 @category{grid}
23324ae1
FM
1135*/
1136class wxGridEvent : public wxNotifyEvent
1137{
1138public:
1139 //@{
1140 /**
3c4f71cc 1141
23324ae1
FM
1142 */
1143 wxGridEvent();
7c913512
FM
1144 wxGridEvent(int id, wxEventType type, wxObject* obj,
1145 int row = -1, int col = -1,
1146 int x = -1, int y = -1,
4cc4bfaf
FM
1147 bool sel = true,
1148 bool control = false,
1149 bool shift = false,
1150 bool alt = false,
1151 bool meta = false);
23324ae1
FM
1152 //@}
1153
1154 /**
1155 Returns @true if the Alt key was down at the time of the event.
1156 */
0004982c 1157 bool AltDown() const;
23324ae1
FM
1158
1159 /**
1160 Returns @true if the Control key was down at the time of the event.
1161 */
0004982c 1162 bool ControlDown() const;
23324ae1
FM
1163
1164 /**
1165 Column at which the event occurred.
1166 */
adaaa686 1167 virtual int GetCol();
23324ae1
FM
1168
1169 /**
1170 Position in pixels at which the event occurred.
1171 */
1172 wxPoint GetPosition();
1173
1174 /**
1175 Row at which the event occurred.
1176 */
adaaa686 1177 virtual int GetRow();
23324ae1
FM
1178
1179 /**
1180 Returns @true if the Meta key was down at the time of the event.
1181 */
0004982c 1182 bool MetaDown() const;
23324ae1
FM
1183
1184 /**
1185 Returns @true if the user is selecting grid cells, @false -- if
1186 deselecting.
1187 */
1188 bool Selecting();
1189
1190 /**
1191 Returns @true if the Shift key was down at the time of the event.
1192 */
0004982c 1193 bool ShiftDown() const;
23324ae1
FM
1194};
1195
1196
e54c96f1 1197
23324ae1
FM
1198/**
1199 @class wxGridCellFloatEditor
7c913512 1200
23324ae1 1201 The editor for floating point numbers data.
7c913512 1202
23324ae1 1203 @library{wxadv}
42b5841f 1204 @category{grid}
7c913512 1205
e54c96f1 1206 @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
23324ae1
FM
1207 wxGridCellTextEditor, wxGridCellChoiceEditor
1208*/
1209class wxGridCellFloatEditor : public wxGridCellTextEditor
1210{
1211public:
1212 /**
7c913512 1213 @param width
4cc4bfaf 1214 Minimum number of characters to be shown.
7c913512 1215 @param precision
4cc4bfaf 1216 Number of digits after the decimal dot.
23324ae1
FM
1217 */
1218 wxGridCellFloatEditor(int width = -1, int precision = -1);
1219
1220 /**
1221 Parameters string format is "width,precision"
1222 */
adaaa686 1223 virtual void SetParameters(const wxString& params);
23324ae1
FM
1224};
1225
1226
e54c96f1 1227
23324ae1
FM
1228/**
1229 @class wxGrid
7c913512 1230
23324ae1 1231 wxGrid and its related classes are used for displaying and editing tabular
55f0bf1f
VZ
1232 data.
1233 They provide a rich set of features for display, editing, and interacting
1234 with a variety of data sources. For simple applications, and to help you
1235 get started, wxGrid is the only class you need to refer to directly. It
1236 will set up default instances of the other classes and manage them for you.
1237 For more complex applications you can derive your own classes for custom
1238 grid views, grid data tables, cell editors and renderers. The @ref
c7d4ca81 1239 overview_grid "wxGrid overview" has examples of simple and more complex applications,
55f0bf1f
VZ
1240 explains the relationship between the various grid classes and has a
1241 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1242
1243 wxGrid has been greatly expanded and redesigned for wxWidgets 2.2 onwards.
1244 The new grid classes are reasonably backward-compatible but there are some
1245 exceptions. There are also easier ways of doing many things compared to the
1246 previous implementation.
1247
1248 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1249 class. One or more wxGrid classes may act as a view for one table class.
1250 The default table class is called wxGridStringTable and holds an array of
1251 strings. An instance of such a class is created by wxGrid::CreateGrid.
1252
1253 wxGridCellRenderer is the abstract base class for rendereing contents in a
1254 cell. The following renderers are predefined:
1255 - wxGridCellStringRenderer,
1256 - wxGridCellBoolRenderer,
1257 - wxGridCellFloatRenderer,
1258 - wxGridCellNumberRenderer.
1259 The look of a cell can be further defined using wxGridCellAttr. An object
1260 of this type may be returned by wxGridTableBase::GetAttr.
1261
1262 wxGridCellEditor is the abstract base class for editing the value of a
1263 cell. The following editors are predefined:
1264 - wxGridCellTextEditor
1265 - wxGridCellBoolEditor
1266 - wxGridCellChoiceEditor
1267 - wxGridCellNumberEditor.
7c913512 1268
23324ae1 1269 @library{wxadv}
55f0bf1f 1270 @category{grid}
7c913512 1271
c7d4ca81 1272 @see @ref overview_grid "wxGrid overview"
23324ae1
FM
1273*/
1274class wxGrid : public wxScrolledWindow
1275{
1276public:
23324ae1 1277 /**
55f0bf1f
VZ
1278 Different selection modes supported by the grid.
1279 */
1280 enum wxGridSelectionModes
1281 {
1282 /**
1283 The default selection mode allowing selection of the individual
1284 cells as well as of the entire rows and columns.
1285 */
1286 wxGridSelectCells,
1287
1288 /**
1289 The selection mode allowing the selection of the entire rows only.
1290
1291 The user won't be able to select any cells or columns in this mode.
1292 */
1293 wxGridSelectRows,
1294
1295 /**
1296 The selection mode allowing the selection of the entire columns only.
1297
1298 The user won't be able to select any cells or rows in this mode.
1299 */
1300 wxGridSelectColumns
1301 };
1302
1303 /**
1304 Default constructor.
1305
1306 You must call Create() to really create the grid window and also call
1307 CreateGrid() or SetTable() to initialize the grid contents.
1308 */
23324ae1 1309 wxGrid();
55f0bf1f
VZ
1310
1311 /**
1312 Constructor creating the grid window.
1313
1314 You must call either CreateGrid() or SetTable() to initialize the grid
1315 contents before using it.
1316 */
1317 wxGrid(wxWindow* parent,
1318 wxWindowID id,
7c913512
FM
1319 const wxPoint& pos = wxDefaultPosition,
1320 const wxSize& size = wxDefaultSize,
1321 long style = wxWANTS_CHARS,
55f0bf1f 1322 const wxString& name = wxGridNameStr);
23324ae1
FM
1323
1324 /**
55f0bf1f
VZ
1325 Creates the grid window for an object initialized using the default
1326 constructor.
1327
1328 You must call either CreateGrid() or SetTable() to initialize the grid
1329 contents before using it.
1330 */
1331 bool Create(wxWindow* parent,
1332 wxWindowID id,
1333 const wxPoint& pos = wxDefaultPosition,
1334 const wxSize& size = wxDefaultSize,
1335 long style = wxWANTS_CHARS,
1336 const wxString& name = wxGridNameStr);
1337
1338 /**
1339 Destructor.
1340
1341 This will also destroy the associated grid table unless you passed a
1342 table object to the grid and specified that the grid should not take
1343 ownership of the table (see wxGrid::SetTable).
23324ae1 1344 */
55f0bf1f 1345 virtual ~wxGrid();
23324ae1
FM
1346
1347 /**
55f0bf1f
VZ
1348 Appends one or more new columns to the right of the grid.
1349
1350 The @a updateLabels argument is not used at present. If you are using a
1351 derived grid table class you will need to override
1352 wxGridTableBase::AppendCols. See InsertCols() for further information.
1353
1354 @return @true on success or @false if appending columns failed.
23324ae1 1355 */
4cc4bfaf 1356 bool AppendCols(int numCols = 1, bool updateLabels = true);
23324ae1
FM
1357
1358 /**
55f0bf1f
VZ
1359 Appends one or more new rows to the bottom of the grid.
1360
1361 The @a updateLabels argument is not used at present. If you are using a
1362 derived grid table class you will need to override
1363 wxGridTableBase::AppendRows. See InsertRows() for further information.
1364
1365 @return @true on success or @false if appending rows failed.
23324ae1 1366 */
4cc4bfaf 1367 bool AppendRows(int numRows = 1, bool updateLabels = true);
23324ae1 1368
9f7aee01
VZ
1369 /**
1370 Return @true if the horizontal grid lines stop at the last column
1371 boundary or @false if they continue to the end of the window.
1372
1373 The default is to clip grid lines.
1374
1375 @see ClipHorzGridLines(), AreVertGridLinesClipped()
1376 */
1377 bool AreHorzGridLinesClipped() const;
1378
1379 /**
1380 Return @true if the vertical grid lines stop at the last row
1381 boundary or @false if they continue to the end of the window.
1382
1383 The default is to clip grid lines.
1384
1385 @see ClipVertGridLines(), AreHorzGridLinesClipped()
1386 */
1387 bool AreVertGridLinesClipped() const;
1388
23324ae1
FM
1389 /**
1390 Automatically sets the height and width of all rows and columns to fit their
1391 contents.
1392 */
1393 void AutoSize();
1394
1395 /**
1396 Automatically adjusts width of the column to fit its label.
1397 */
1398 void AutoSizeColLabelSize(int col);
1399
1400 /**
1401 Automatically sizes the column to fit its contents. If setAsMin is @true the
1402 calculated width will
1403 also be set as the minimal width for the column.
1404 */
4cc4bfaf 1405 void AutoSizeColumn(int col, bool setAsMin = true);
23324ae1
FM
1406
1407 /**
1408 Automatically sizes all columns to fit their contents. If setAsMin is @true the
1409 calculated widths will
1410 also be set as the minimal widths for the columns.
1411 */
4cc4bfaf 1412 void AutoSizeColumns(bool setAsMin = true);
23324ae1
FM
1413
1414 /**
1415 Automatically sizes the row to fit its contents. If setAsMin is @true the
1416 calculated height will
1417 also be set as the minimal height for the row.
1418 */
4cc4bfaf 1419 void AutoSizeRow(int row, bool setAsMin = true);
23324ae1
FM
1420
1421 /**
1422 Automatically adjusts height of the row to fit its label.
1423 */
1424 void AutoSizeRowLabelSize(int col);
1425
1426 /**
1427 Automatically sizes all rows to fit their contents. If setAsMin is @true the
1428 calculated heights will
1429 also be set as the minimal heights for the rows.
1430 */
4cc4bfaf 1431 void AutoSizeRows(bool setAsMin = true);
23324ae1
FM
1432
1433 /**
55f0bf1f 1434 Increments the grid's batch count.
3c4f71cc 1435
55f0bf1f
VZ
1436 When the count is greater than zero repainting of the grid is
1437 suppressed. Each call to BeginBatch must be matched by a later call to
1438 EndBatch(). Code that does a lot of grid modification can be enclosed
1439 between BeginBatch and EndBatch calls to avoid screen flicker. The
1440 final EndBatch will cause the grid to be repainted.
3c4f71cc 1441
55f0bf1f
VZ
1442 Notice that you should use wxGridUpdateLocker which ensures that there
1443 is always a matching EndBatch() call for this BeginBatch() if possible
1444 instead of calling this method directly.
23324ae1
FM
1445 */
1446 void BeginBatch();
1447
1448 /**
08dd9b5a
VZ
1449 Convert grid cell coordinates to grid window pixel coordinates.
1450
23324ae1 1451 This function returns the rectangle that encloses the block of cells
08dd9b5a
VZ
1452 limited by @a topLeft and @a bottomRight cell in device coords and
1453 clipped to the client size of the grid window.
1454
1455 @see CellToRect()
23324ae1 1456 */
4cc4bfaf 1457 wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft,
328f5751 1458 const wxGridCellCoords& bottomRight) const;
23324ae1
FM
1459
1460 /**
55f0bf1f
VZ
1461 Returns @true if columns can be moved by dragging with the mouse.
1462
1463 Columns can be moved by dragging on their labels.
23324ae1 1464 */
328f5751 1465 bool CanDragColMove() const;
23324ae1
FM
1466
1467 /**
55f0bf1f 1468 Returns @true if columns can be resized by dragging with the mouse.
08dd9b5a 1469
55f0bf1f
VZ
1470 Columns can be resized by dragging the edges of their labels. If grid
1471 line dragging is enabled they can also be resized by dragging the right
1472 edge of the column in the grid cell area (see
1473 wxGrid::EnableDragGridSize).
23324ae1 1474 */
328f5751 1475 bool CanDragColSize() const;
23324ae1
FM
1476
1477 /**
08dd9b5a
VZ
1478 Return @true if the dragging of grid lines to resize rows and columns
1479 is enabled or @false otherwise.
23324ae1 1480 */
328f5751 1481 bool CanDragGridSize() const;
23324ae1
FM
1482
1483 /**
55f0bf1f 1484 Returns @true if rows can be resized by dragging with the mouse.
08dd9b5a 1485
55f0bf1f
VZ
1486 Rows can be resized by dragging the edges of their labels. If grid line
1487 dragging is enabled they can also be resized by dragging the lower edge
1488 of the row in the grid cell area (see wxGrid::EnableDragGridSize).
23324ae1 1489 */
328f5751 1490 bool CanDragRowSize() const;
23324ae1
FM
1491
1492 /**
08dd9b5a
VZ
1493 Returns @true if the in-place edit control for the current grid cell
1494 can be used and @false otherwise.
1495
1496 This function always returns @false for the read-only cells.
23324ae1 1497 */
328f5751 1498 bool CanEnableCellControl() const;
23324ae1 1499
23324ae1
FM
1500 //@{
1501 /**
08dd9b5a
VZ
1502 Return the rectangle corresponding to the grid cell's size and position
1503 in logical coordinates.
1504
1505 @see BlockToDeviceRect()
23324ae1 1506 */
328f5751 1507 wxRect CellToRect(int row, int col) const;
08dd9b5a
VZ
1508 const wxRect CellToRect(const wxGridCellCoords& coords) const;
1509
23324ae1
FM
1510 //@}
1511
1512 /**
55f0bf1f
VZ
1513 Clears all data in the underlying grid table and repaints the grid.
1514
1515 The table is not deleted by this function. If you are using a derived
1516 table class then you need to override wxGridTableBase::Clear() for this
1517 function to have any effect.
23324ae1
FM
1518 */
1519 void ClearGrid();
1520
1521 /**
1522 Deselects all cells that are currently selected.
1523 */
1524 void ClearSelection();
1525
9f7aee01
VZ
1526 /**
1527 Change whether the horizontal grid lines are clipped by the end of the
1528 last column.
1529
1530 By default the grid lines are not drawn beyond the end of the last
1531 column but after calling this function with @a clip set to @false they
1532 will be drawn across the entire grid window.
1533
1534 @see AreHorzGridLinesClipped(), ClipVertGridLines()
1535 */
1536 void ClipHorzGridLines(bool clip);
1537
1538 /**
1539 Change whether the vertical grid lines are clipped by the end of the
1540 last row.
1541
1542 By default the grid lines are not drawn beyond the end of the last
1543 row but after calling this function with @a clip set to @false they
1544 will be drawn across the entire grid window.
1545
1546 @see AreVertzGridLinesClipped(), ClipHorzGridLines()
1547 */
1548 void ClipVertzGridLines(bool clip);
1549
23324ae1
FM
1550 /**
1551 Creates a grid with the specified initial number of rows and columns.
08dd9b5a 1552
23324ae1
FM
1553 Call this directly after the grid constructor. When you use this
1554 function wxGrid will create and manage a simple table of string values
1555 for you. All of the grid data will be stored in memory.
23324ae1
FM
1556 For applications with more complex data types or relationships, or for
1557 dealing with very large datasets, you should derive your own grid table
1558 class and pass a table object to the grid with SetTable().
1559 */
1560 bool CreateGrid(int numRows, int numCols,
55f0bf1f 1561 wxGridSelectionModes selmode = wxGridSelectCells);
23324ae1
FM
1562
1563 /**
55f0bf1f
VZ
1564 Deletes one or more columns from a grid starting at the specified
1565 position.
3c4f71cc 1566
55f0bf1f
VZ
1567 The @a updateLabels argument is not used at present. If you are using a
1568 derived grid table class you will need to override
1569 wxGridTableBase::DeleteCols. See InsertCols() for further information.
3c4f71cc 1570
55f0bf1f 1571 @return @true on success or @false if deleting columns failed.
23324ae1 1572 */
55f0bf1f 1573 bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true);
23324ae1
FM
1574
1575 /**
55f0bf1f 1576 Deletes one or more rows from a grid starting at the specified position.
23324ae1 1577
55f0bf1f
VZ
1578 The @a updateLabels argument is not used at present. If you are using a
1579 derived grid table class you will need to override
1580 wxGridTableBase::DeleteRows. See InsertRows() for further information.
1581
1582 @return @true on success or @false if appending rows failed.
23324ae1 1583 */
55f0bf1f 1584 bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true);
23324ae1
FM
1585
1586 /**
1587 Disables in-place editing of grid cells.
08dd9b5a 1588
23324ae1
FM
1589 Equivalent to calling EnableCellEditControl(@false).
1590 */
1591 void DisableCellEditControl();
1592
1593 /**
55f0bf1f
VZ
1594 Disables column moving by dragging with the mouse.
1595
1596 Equivalent to passing @false to EnableDragColMove().
23324ae1
FM
1597 */
1598 void DisableDragColMove();
1599
1600 /**
55f0bf1f
VZ
1601 Disables column sizing by dragging with the mouse.
1602
1603 Equivalent to passing @false to EnableDragColSize().
23324ae1
FM
1604 */
1605 void DisableDragColSize();
1606
1607 /**
55f0bf1f
VZ
1608 Disable mouse dragging of grid lines to resize rows and columns.
1609
1610 Equivalent to passing @false to EnableDragGridSize()
23324ae1
FM
1611 */
1612 void DisableDragGridSize();
1613
1614 /**
55f0bf1f
VZ
1615 Disables row sizing by dragging with the mouse.
1616
1617 Equivalent to passing @false to EnableDragRowSize().
23324ae1
FM
1618 */
1619 void DisableDragRowSize();
1620
1621 /**
55f0bf1f
VZ
1622 Enables or disables in-place editing of grid cell data.
1623
1624 The grid will issue either a wxEVT_GRID_EDITOR_SHOWN or
1625 wxEVT_GRID_EDITOR_HIDDEN event.
23324ae1 1626 */
4cc4bfaf 1627 void EnableCellEditControl(bool enable = true);
23324ae1
FM
1628
1629 /**
1630 Enables or disables column moving by dragging with the mouse.
1631 */
4cc4bfaf 1632 void EnableDragColMove(bool enable = true);
23324ae1
FM
1633
1634 /**
1635 Enables or disables column sizing by dragging with the mouse.
1636 */
4cc4bfaf 1637 void EnableDragColSize(bool enable = true);
23324ae1
FM
1638
1639 /**
1640 Enables or disables row and column resizing by dragging gridlines with the
1641 mouse.
1642 */
4cc4bfaf 1643 void EnableDragGridSize(bool enable = true);
23324ae1
FM
1644
1645 /**
1646 Enables or disables row sizing by dragging with the mouse.
1647 */
4cc4bfaf 1648 void EnableDragRowSize(bool enable = true);
23324ae1
FM
1649
1650 /**
55f0bf1f
VZ
1651 Makes the grid globally editable or read-only.
1652
1653 If the edit argument is @false this function sets the whole grid as
1654 read-only. If the argument is @true the grid is set to the default
1655 state where cells may be editable. In the default state you can set
1656 single grid cells and whole rows and columns to be editable or
1657 read-only via wxGridCellAttribute::SetReadOnly. For single cells you
1658 can also use the shortcut function SetReadOnly().
1659
23324ae1
FM
1660 For more information about controlling grid cell attributes see the
1661 wxGridCellAttr cell attribute class and the
c7d4ca81 1662 @ref overview_grid "wxGrid overview".
23324ae1
FM
1663 */
1664 void EnableEditing(bool edit);
1665
1666 /**
1667 Turns the drawing of grid lines on or off.
1668 */
4cc4bfaf 1669 void EnableGridLines(bool enable = true);
23324ae1
FM
1670
1671 /**
55f0bf1f
VZ
1672 Decrements the grid's batch count.
1673
1674 When the count is greater than zero repainting of the grid is
1675 suppressed. Each previous call to BeginBatch() must be matched by a
1676 later call to EndBatch. Code that does a lot of grid modification can
1677 be enclosed between BeginBatch and EndBatch calls to avoid screen
1678 flicker. The final EndBatch will cause the grid to be repainted.
3c4f71cc 1679
4cc4bfaf 1680 @see wxGridUpdateLocker
23324ae1
FM
1681 */
1682 void EndBatch();
1683
1684 /**
1685 Overridden wxWindow method.
1686 */
a44f3b5a 1687 virtual void Fit();
23324ae1
FM
1688
1689 /**
55f0bf1f
VZ
1690 Causes immediate repainting of the grid.
1691
1692 Use this instead of the usual wxWindow::Refresh.
23324ae1
FM
1693 */
1694 void ForceRefresh();
1695
1696 /**
1697 Returns the number of times that BeginBatch() has been called
1698 without (yet) matching calls to EndBatch(). While
1699 the grid's batch count is greater than zero the display will not be updated.
1700 */
adaaa686 1701 int GetBatchCount();
23324ae1
FM
1702
1703 /**
55f0bf1f
VZ
1704 Sets the arguments to the horizontal and vertical text alignment values
1705 for the grid cell at the specified location.
3c4f71cc 1706
55f0bf1f
VZ
1707 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1708 or @c wxALIGN_RIGHT.
1709
1710 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1711 @c wxALIGN_BOTTOM.
23324ae1 1712 */
328f5751 1713 void GetCellAlignment(int row, int col, int* horiz, int* vert) const;
23324ae1
FM
1714
1715 /**
1716 Returns the background colour of the cell at the specified location.
1717 */
328f5751 1718 wxColour GetCellBackgroundColour(int row, int col) const;
23324ae1
FM
1719
1720 /**
1721 Returns a pointer to the editor for the cell at the specified location.
08dd9b5a 1722
5e6e278d 1723 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
c7d4ca81 1724 for more information about cell editors and renderers.
08dd9b5a
VZ
1725
1726 The caller must call DecRef() on the returned pointer.
23324ae1 1727 */
328f5751 1728 wxGridCellEditor* GetCellEditor(int row, int col) const;
23324ae1
FM
1729
1730 /**
1731 Returns the font for text in the grid cell at the specified location.
1732 */
328f5751 1733 wxFont GetCellFont(int row, int col) const;
23324ae1
FM
1734
1735 /**
08dd9b5a
VZ
1736 Returns a pointer to the renderer for the grid cell at the specified
1737 location.
1738
c7d4ca81
RR
1739 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
1740 for more information about cell editors and renderers.
08dd9b5a
VZ
1741
1742 The caller must call DecRef() on the returned pointer.
23324ae1 1743 */
328f5751 1744 wxGridCellRenderer* GetCellRenderer(int row, int col) const;
23324ae1
FM
1745
1746 /**
1747 Returns the text colour for the grid cell at the specified location.
1748 */
328f5751 1749 wxColour GetCellTextColour(int row, int col) const;
23324ae1
FM
1750
1751 //@{
1752 /**
08dd9b5a
VZ
1753 Returns the string contained in the cell at the specified location.
1754
1755 For simple applications where a grid object automatically uses a
1756 default grid table of string values you use this function together with
1757 SetCellValue() to access cell values. For more complex applications
1758 where you have derived your own grid table class that contains various
1759 data types (e.g. numeric, boolean or user-defined custom types) then
1760 you only use this function for those cells that contain string values.
1761
c7d4ca81
RR
1762 See wxGridTableBase::CanGetValueAs and the @ref overview_grid "wxGrid overview"
1763 for more information.
23324ae1 1764 */
328f5751
FM
1765 wxString GetCellValue(int row, int col) const;
1766 const wxString GetCellValue(const wxGridCellCoords& coords) const;
23324ae1
FM
1767 //@}
1768
1769 /**
1770 Returns the column ID of the specified column position.
1771 */
328f5751 1772 int GetColAt(int colPos) const;
23324ae1
FM
1773
1774 /**
08dd9b5a
VZ
1775 Returns the pen used for vertical grid lines.
1776
1777 This virtual function may be overridden in derived classes in order to
1778 change the appearance of individual grid lines for the given column @e
1779 col.
1780
23324ae1
FM
1781 See GetRowGridLinePen() for an example.
1782 */
adaaa686 1783 virtual wxPen GetColGridLinePen(int col);
23324ae1
FM
1784
1785 /**
1786 Sets the arguments to the current column label alignment values.
3c4f71cc 1787
55f0bf1f
VZ
1788 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1789 or @c wxALIGN_RIGHT.
1790
1791 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1792 @c wxALIGN_BOTTOM.
23324ae1 1793 */
328f5751 1794 void GetColLabelAlignment(int* horiz, int* vert) const;
23324ae1
FM
1795
1796 /**
1797 Returns the current height of the column labels.
1798 */
328f5751 1799 int GetColLabelSize() const;
23324ae1
FM
1800
1801 /**
55f0bf1f
VZ
1802 Returns the specified column label.
1803
1804 The default grid table class provides column labels of the form
1805 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1806 override wxGridTableBase::GetColLabelValue to provide your own labels.
23324ae1 1807 */
328f5751 1808 wxString GetColLabelValue(int col) const;
23324ae1 1809
23324ae1 1810 /**
08dd9b5a
VZ
1811 Returns the minimal width to which a column may be resized.
1812
1813 Use SetColMinimalAcceptableWidth() to change this value globally or
1814 SetColMinimalWidth() to do it for individual columns.
23324ae1 1815 */
328f5751 1816 int GetColMinimalAcceptableWidth() const;
23324ae1 1817
23324ae1
FM
1818 /**
1819 Returns the position of the specified column.
1820 */
328f5751 1821 int GetColPos(int colID) const;
23324ae1 1822
23324ae1
FM
1823 /**
1824 Returns the width of the specified column.
1825 */
328f5751 1826 int GetColSize(int col) const;
23324ae1
FM
1827
1828 /**
08dd9b5a 1829 Returns the default cell alignment.
3c4f71cc 1830
08dd9b5a
VZ
1831 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1832 or @c wxALIGN_RIGHT.
1833
1834 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1835 @c wxALIGN_BOTTOM.
1836
1837 @see SetDefaultCellAlignment()
23324ae1 1838 */
328f5751 1839 void GetDefaultCellAlignment(int* horiz, int* vert) const;
23324ae1
FM
1840
1841 /**
1842 Returns the current default background colour for grid cells.
1843 */
328f5751 1844 wxColour GetDefaultCellBackgroundColour() const;
23324ae1
FM
1845
1846 /**
1847 Returns the current default font for grid cell text.
1848 */
328f5751 1849 wxFont GetDefaultCellFont() const;
23324ae1
FM
1850
1851 /**
1852 Returns the current default colour for grid cell text.
1853 */
328f5751 1854 wxColour GetDefaultCellTextColour() const;
23324ae1
FM
1855
1856 /**
1857 Returns the default height for column labels.
1858 */
328f5751 1859 int GetDefaultColLabelSize() const;
23324ae1
FM
1860
1861 /**
1862 Returns the current default width for grid columns.
1863 */
328f5751 1864 int GetDefaultColSize() const;
23324ae1
FM
1865
1866 /**
1867 Returns a pointer to the current default grid cell editor.
08dd9b5a 1868
c7d4ca81
RR
1869 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
1870 for more information about cell editors and renderers.
23324ae1 1871 */
328f5751 1872 wxGridCellEditor* GetDefaultEditor() const;
23324ae1
FM
1873
1874 //@{
1875 /**
08dd9b5a
VZ
1876 Returns the default editor for the specified cell.
1877
1878 The base class version returns the editor appropriate for the current
1879 cell type but this method may be overridden in the derived classes to
1880 use custom editors for some cells by default.
3c4f71cc 1881
08dd9b5a
VZ
1882 Notice that the same may be usually achieved in simpler way by
1883 associating a custom editor with the given cell or cells.
1884
1885 The caller must call DecRef() on the returned pointer.
23324ae1 1886 */
08dd9b5a
VZ
1887 virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
1888 wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const;
23324ae1
FM
1889 //@}
1890
1891 /**
08dd9b5a
VZ
1892 Returns the default editor for the cells containing values of the given
1893 type.
1894
1895 The base class version returns the editor which was associated with the
1896 specified @a typeName when it was registered RegisterDataType() but
1897 this function may be overridden to return something different. This
1898 allows to override an editor used for one of the standard types.
3c4f71cc 1899
08dd9b5a 1900 The caller must call DecRef() on the returned pointer.
23324ae1 1901 */
08dd9b5a
VZ
1902 virtual wxGridCellEditor *
1903 GetDefaultEditorForType(const wxString& typeName) const;
23324ae1
FM
1904
1905 /**
08dd9b5a
VZ
1906 Returns the pen used for grid lines.
1907
1908 This virtual function may be overridden in derived classes in order to
1909 change the appearance of grid lines. Note that currently the pen width
1910 must be 1.
3c4f71cc 1911
4cc4bfaf 1912 @see GetColGridLinePen(), GetRowGridLinePen()
23324ae1 1913 */
adaaa686 1914 virtual wxPen GetDefaultGridLinePen();
23324ae1
FM
1915
1916 /**
1917 Returns a pointer to the current default grid cell renderer.
08dd9b5a 1918
c7d4ca81
RR
1919 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
1920 for more information about cell editors and renderers.
08dd9b5a
VZ
1921
1922 The caller must call DecRef() on the returned pointer.
23324ae1 1923 */
328f5751 1924 wxGridCellRenderer* GetDefaultRenderer() const;
23324ae1
FM
1925
1926 /**
08dd9b5a 1927 Returns the default renderer for the given cell.
3c4f71cc 1928
08dd9b5a
VZ
1929 The base class version returns the renderer appropriate for the current
1930 cell type but this method may be overridden in the derived classes to
1931 use custom renderers for some cells by default.
1932
1933 The caller must call DecRef() on the returned pointer.
23324ae1 1934 */
08dd9b5a 1935 virtual wxGridCellRenderer *GetDefaultRendererForCell(int row, int col) const;
23324ae1
FM
1936
1937 /**
08dd9b5a
VZ
1938 Returns the default renderer for the cell containing values of the
1939 given type.
3c4f71cc 1940
08dd9b5a 1941 @see GetDefaultEditorForType()
23324ae1 1942 */
08dd9b5a
VZ
1943 virtual wxGridCellRenderer *
1944 GetDefaultRendererForType(const wxString& typeName) const;
23324ae1
FM
1945
1946 /**
1947 Returns the default width for the row labels.
1948 */
328f5751 1949 int GetDefaultRowLabelSize() const;
23324ae1
FM
1950
1951 /**
1952 Returns the current default height for grid rows.
1953 */
328f5751 1954 int GetDefaultRowSize() const;
23324ae1
FM
1955
1956 /**
1957 Returns the current grid cell column position.
1958 */
328f5751 1959 int GetGridCursorCol() const;
23324ae1
FM
1960
1961 /**
1962 Returns the current grid cell row position.
1963 */
328f5751 1964 int GetGridCursorRow() const;
23324ae1
FM
1965
1966 /**
1967 Returns the colour used for grid lines.
3c4f71cc 1968
4cc4bfaf 1969 @see GetDefaultGridLinePen()
23324ae1 1970 */
328f5751 1971 wxColour GetGridLineColour() const;
23324ae1
FM
1972
1973 /**
1974 Returns the colour used for the background of row and column labels.
1975 */
328f5751 1976 wxColour GetLabelBackgroundColour() const;
23324ae1
FM
1977
1978 /**
1979 Returns the font used for row and column labels.
1980 */
328f5751 1981 wxFont GetLabelFont() const;
23324ae1
FM
1982
1983 /**
1984 Returns the colour used for row and column label text.
1985 */
328f5751 1986 wxColour GetLabelTextColour() const;
23324ae1
FM
1987
1988 /**
08dd9b5a
VZ
1989 Returns the total number of grid columns.
1990
1991 This is the same as the number of columns in the underlying grid
1992 table.
23324ae1 1993 */
328f5751 1994 int GetNumberCols() const;
23324ae1
FM
1995
1996 /**
08dd9b5a
VZ
1997 Returns the total number of grid rows.
1998
1999 This is the same as the number of rows in the underlying grid table.
23324ae1 2000 */
328f5751 2001 int GetNumberRows() const;
23324ae1
FM
2002
2003 /**
08dd9b5a 2004 Returns the attribute for the given cell creating one if necessary.
3c4f71cc 2005
08dd9b5a
VZ
2006 If the cell already has an attribute, it is returned. Otherwise a new
2007 attribute is created, associated with the cell and returned. In any
2008 case the caller must call DecRef() on the returned pointer.
2009
2010 This function may only be called if CanHaveAttributes() returns @true.
23324ae1 2011 */
08dd9b5a 2012 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
23324ae1
FM
2013
2014 /**
08dd9b5a
VZ
2015 Returns the pen used for horizontal grid lines.
2016
2017 This virtual function may be overridden in derived classes in order to
2018 change the appearance of individual grid line for the given row @e row.
2019
23324ae1 2020 Example:
08dd9b5a
VZ
2021 @code
2022 // in a grid displaying music notation, use a solid black pen between
2023 // octaves (C0=row 127, C1=row 115 etc.)
2024 wxPen MidiGrid::GetRowGridLinePen(int row)
2025 {
2026 if ( row % 12 == 7 )
2027 return wxPen(*wxBLACK, 1, wxSOLID);
2028 else
2029 return GetDefaultGridLinePen();
2030 }
2031 @endcode
23324ae1 2032 */
adaaa686 2033 virtual wxPen GetRowGridLinePen(int row);
23324ae1
FM
2034
2035 /**
08dd9b5a 2036 Returns the alignment used for row labels.
3c4f71cc 2037
08dd9b5a
VZ
2038 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
2039 or @c wxALIGN_RIGHT.
2040
2041 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
2042 @c wxALIGN_BOTTOM.
23324ae1 2043 */
328f5751 2044 void GetRowLabelAlignment(int* horiz, int* vert) const;
23324ae1
FM
2045
2046 /**
2047 Returns the current width of the row labels.
2048 */
328f5751 2049 int GetRowLabelSize() const;
23324ae1
FM
2050
2051 /**
08dd9b5a
VZ
2052 Returns the specified row label.
2053
2054 The default grid table class provides numeric row labels. If you are
2055 using a custom grid table you can override
2056 wxGridTableBase::GetRowLabelValue to provide your own labels.
23324ae1 2057 */
328f5751 2058 wxString GetRowLabelValue(int row) const;
23324ae1
FM
2059
2060 /**
08dd9b5a
VZ
2061 Returns the minimal size to which rows can be resized.
2062
2063 Use SetRowMinimalAcceptableHeight() to change this value globally or
2064 SetRowMinimalHeight() to do it for individual cells.
2065
2066 @see GetColMinimalAcceptableWidth()
23324ae1 2067 */
328f5751 2068 int GetRowMinimalAcceptableHeight() const;
23324ae1 2069
23324ae1
FM
2070 /**
2071 Returns the height of the specified row.
2072 */
328f5751 2073 int GetRowSize(int row) const;
23324ae1
FM
2074
2075 /**
08dd9b5a
VZ
2076 Returns the number of pixels per horizontal scroll increment.
2077
2078 The default is 15.
3c4f71cc 2079
4cc4bfaf 2080 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
23324ae1 2081 */
328f5751 2082 int GetScrollLineX() const;
23324ae1
FM
2083
2084 /**
08dd9b5a
VZ
2085 Returns the number of pixels per vertical scroll increment.
2086
2087 The default is 15.
3c4f71cc 2088
4cc4bfaf 2089 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
23324ae1 2090 */
328f5751 2091 int GetScrollLineY() const;
23324ae1
FM
2092
2093 /**
08dd9b5a
VZ
2094 Returns an array of individually selected cells.
2095
2096 Notice that this array does @em not contain all the selected cells in
2097 general as it doesn't include the cells selected as part of column, row
2098 or block selection. You must use this method, GetSelectedCols(),
2099 GetSelectedRows() and GetSelectionBlockTopLeft() and
2100 GetSelectionBlockBottomRight() methods to obtain the entire selection
2101 in general.
2102
2103 Please notice this behaviour is by design and is needed in order to
2104 support grids of arbitrary size (when an entire column is selected in
2105 a grid with a million of columns, we don't want to create an array with
2106 a million of entries in this function, instead it returns an empty
2107 array and GetSelectedCols() returns an array containing one element).
23324ae1 2108 */
328f5751 2109 wxGridCellCoordsArray GetSelectedCells() const;
23324ae1
FM
2110
2111 /**
08dd9b5a 2112 Returns an array of selected columns.
bb778cae
VZ
2113
2114 Please notice that this method alone is not sufficient to find all the
08dd9b5a
VZ
2115 selected columns as it contains only the columns which were
2116 individually selected but not those being part of the block selection
2117 or being selected in virtue of all of their cells being selected
2118 individually, please see GetSelectedCells() for more details.
23324ae1 2119 */
328f5751 2120 wxArrayInt GetSelectedCols() const;
23324ae1
FM
2121
2122 /**
2123 Returns an array of selected rows.
bb778cae 2124
08dd9b5a
VZ
2125 Please notice that this method alone is not sufficient to find all the
2126 selected rows as it contains only the rows which were individually
2127 selected but not those being part of the block selection or being
2128 selected in virtue of all of their cells being selected individually,
2129 please see GetSelectedCells() for more details.
23324ae1 2130 */
328f5751 2131 wxArrayInt GetSelectedRows() const;
23324ae1
FM
2132
2133 /**
2134 Access or update the selection fore/back colours
2135 */
328f5751 2136 wxColour GetSelectionBackground() const;
23324ae1
FM
2137
2138 /**
08dd9b5a
VZ
2139 Returns an array of the bottom right corners of blocks of selected
2140 cells.
2141
2142 Please see GetSelectedCells() for more information about the selection
2143 representation in wxGrid.
2144
2145 @see GetSelectionBlockTopLeft()
23324ae1 2146 */
328f5751 2147 wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
23324ae1
FM
2148
2149 /**
08dd9b5a
VZ
2150 Returns an array of the top left corners of blocks of selected cells.
2151
2152 Please see GetSelectedCells() for more information about the selection
2153 representation in wxGrid.
2154
2155 @see GetSelectionBlockBottomRight()
23324ae1 2156 */
328f5751 2157 wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
23324ae1
FM
2158
2159 /**
08dd9b5a 2160 Returns the colour used for drawing the selection foreground.
23324ae1 2161 */
328f5751 2162 wxColour GetSelectionForeground() const;
23324ae1
FM
2163
2164 /**
08dd9b5a
VZ
2165 Returns the current selection mode.
2166
2167 @see SetSelectionMode().
23324ae1 2168 */
55f0bf1f 2169 wxGridSelectionModes GetSelectionMode() const;
23324ae1
FM
2170
2171 /**
2172 Returns a base pointer to the current table object.
3c4f71cc 2173
08dd9b5a 2174 The returned pointer is still owned by the grid.
23324ae1 2175 */
08dd9b5a 2176 wxGridTableBase *GetTable() const;
23324ae1 2177
8a3e536c
VZ
2178 //@{
2179 /**
2180 Make the given cell current and ensure it is visible.
2181
2182 This method is equivalent to calling MakeCellVisible() and
2183 SetGridCursor() and so, as with the latter, a wxEVT_GRID_SELECT_CELL
2184 event is generated by it and the selected cell doesn't change if the
2185 event is vetoed.
2186 */
2187 void GoToCell(int row, int col);
2188 void GoToCell(const wxGridCellCoords& coords);
2189 //@}
2190
23324ae1
FM
2191 /**
2192 Returns @true if drawing of grid lines is turned on, @false otherwise.
2193 */
328f5751 2194 bool GridLinesEnabled() const;
23324ae1
FM
2195
2196 /**
2197 Hides the in-place cell edit control.
2198 */
2199 void HideCellEditControl();
2200
2201 /**
2202 Hides the column labels by calling SetColLabelSize()
2203 with a size of 0. Show labels again by calling that method with
2204 a width greater than 0.
2205 */
2206 void HideColLabels();
2207
2208 /**
08dd9b5a
VZ
2209 Hides the row labels by calling SetRowLabelSize() with a size of 0.
2210
2211 The labels can be shown again by calling SetRowLabelSize() with a width
2212 greater than 0.
23324ae1
FM
2213 */
2214 void HideRowLabels();
2215
2216 /**
08dd9b5a
VZ
2217 Inserts one or more new columns into a grid with the first new column
2218 at the specified position.
23324ae1 2219
08dd9b5a
VZ
2220 Notice that inserting the columns in the grid requires grid table
2221 cooperation: when this method is called, grid object begins by
2222 requesting the underlying grid table to insert new columns. If this is
2223 successful the table notifies the grid and the grid updates the
2224 display. For a default grid (one where you have called
2225 wxGrid::CreateGrid) this process is automatic. If you are using a
2226 custom grid table (specified with wxGrid::SetTable) then you must
2227 override wxGridTableBase::InsertCols() in your derived table class.
23324ae1 2228
08dd9b5a
VZ
2229 @param pos
2230 The position which the first newly inserted column will have.
2231 @param numCols
2232 The number of columns to insert.
2233 @param updateLabels
2234 Currently not used.
2235 @return
2236 @true if the columns were successfully inserted, @false if an error
2237 occurred (most likely the table couldn't be updated).
23324ae1 2238 */
08dd9b5a 2239 bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true);
23324ae1
FM
2240
2241 /**
08dd9b5a
VZ
2242 Inserts one or more new rows into a grid with the first new row at the
2243 specified position.
2244
2245 Notice that you must implement wxGridTableBase::InsertRows() if you use
2246 a grid with a custom table, please see InsertCols() for more
2247 information.
2248
2249 @param pos
2250 The position which the first newly inserted row will have.
2251 @param numRows
2252 The number of rows to insert.
2253 @param updateLabels
2254 Currently not used.
2255 @return
2256 @true if the rows were successfully inserted, @false if an error
2257 occurred (most likely the table couldn't be updated).
23324ae1 2258 */
08dd9b5a 2259 bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true);
23324ae1
FM
2260
2261 /**
2262 Returns @true if the in-place edit control is currently enabled.
2263 */
328f5751 2264 bool IsCellEditControlEnabled() const;
23324ae1
FM
2265
2266 /**
08dd9b5a
VZ
2267 Returns @true if the current cell is read-only.
2268
2269 @see SetReadOnly(), IsReadOnly()
23324ae1 2270 */
328f5751 2271 bool IsCurrentCellReadOnly() const;
23324ae1
FM
2272
2273 /**
08dd9b5a
VZ
2274 Returns @false if the whole grid has been set as read-only or @true
2275 otherwise.
2276
2277 See EnableEditing() for more information about controlling the editing
2278 status of grid cells.
23324ae1 2279 */
328f5751 2280 bool IsEditable() const;
23324ae1
FM
2281
2282 //@{
2283 /**
08dd9b5a 2284 Is this cell currently selected?
23324ae1 2285 */
328f5751 2286 bool IsInSelection(int row, int col) const;
08dd9b5a 2287 bool IsInSelection(const wxGridCellCoords& coords) const;
23324ae1
FM
2288 //@}
2289
2290 /**
2291 Returns @true if the cell at the specified location can't be edited.
08dd9b5a
VZ
2292
2293 @see SetReadOnly(), IsCurrentCellReadOnly()
23324ae1 2294 */
328f5751 2295 bool IsReadOnly(int row, int col) const;
23324ae1
FM
2296
2297 /**
08dd9b5a
VZ
2298 Returns @true if there are currently any selected cells, rows, columns
2299 or blocks.
23324ae1 2300 */
328f5751 2301 bool IsSelection() const;
23324ae1
FM
2302
2303 //@{
2304 /**
08dd9b5a
VZ
2305 Returns @true if a cell is either wholly or at least partially visible
2306 in the grid window.
2307
2308 By default, the cell must be entirely visible for this function to
2309 return true but if @a wholeCellVisible is @false, the function returns
2310 @true even if the cell is only partially visible.
23324ae1 2311 */
328f5751 2312 bool IsVisible(int row, int col, bool wholeCellVisible = true) const;
11e3af6e
FM
2313 bool IsVisible(const wxGridCellCoords& coords,
2314 bool wholeCellVisible = true) const;
23324ae1
FM
2315 //@}
2316
2317 //@{
2318 /**
2319 Brings the specified cell into the visible grid cell area with minimal
08dd9b5a
VZ
2320 scrolling.
2321
2322 Does nothing if the cell is already visible.
23324ae1
FM
2323 */
2324 void MakeCellVisible(int row, int col);
7c913512 2325 void MakeCellVisible(const wxGridCellCoords& coords);
23324ae1
FM
2326 //@}
2327
2328 /**
08dd9b5a
VZ
2329 Moves the grid cursor down by one row.
2330
2331 If a block of cells was previously selected it will expand if the
2332 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2333 */
2334 bool MoveCursorDown(bool expandSelection);
2335
2336 /**
08dd9b5a
VZ
2337 Moves the grid cursor down in the current column such that it skips to
2338 the beginning or end of a block of non-empty cells.
2339
2340 If a block of cells was previously selected it will expand if the
2341 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2342 */
2343 bool MoveCursorDownBlock(bool expandSelection);
2344
2345 /**
08dd9b5a
VZ
2346 Moves the grid cursor left by one column.
2347
2348 If a block of cells was previously selected it will expand if the
2349 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2350 */
2351 bool MoveCursorLeft(bool expandSelection);
2352
2353 /**
2354 Moves the grid cursor left in the current row such that it skips to the
08dd9b5a
VZ
2355 beginning or end of a block of non-empty cells.
2356
2357 If a block of cells was previously selected it will expand if the
2358 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2359 */
2360 bool MoveCursorLeftBlock(bool expandSelection);
2361
2362 /**
08dd9b5a
VZ
2363 Moves the grid cursor right by one column.
2364
2365 If a block of cells was previously selected it will expand if the
2366 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2367 */
2368 bool MoveCursorRight(bool expandSelection);
2369
2370 /**
08dd9b5a
VZ
2371 Moves the grid cursor right in the current row such that it skips to
2372 the beginning or end of a block of non-empty cells.
2373
2374 If a block of cells was previously selected it will expand if the
2375 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2376 */
2377 bool MoveCursorRightBlock(bool expandSelection);
2378
2379 /**
08dd9b5a
VZ
2380 Moves the grid cursor up by one row.
2381
2382 If a block of cells was previously selected it will expand if the
2383 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2384 */
2385 bool MoveCursorUp(bool expandSelection);
2386
2387 /**
08dd9b5a
VZ
2388 Moves the grid cursor up in the current column such that it skips to
2389 the beginning or end of a block of non-empty cells.
2390
2391 If a block of cells was previously selected it will expand if the
2392 argument is @true or be cleared if the argument is @false.
23324ae1
FM
2393 */
2394 bool MoveCursorUpBlock(bool expandSelection);
2395
2396 /**
08dd9b5a
VZ
2397 Moves the grid cursor down by some number of rows so that the previous
2398 bottom visible row becomes the top visible row.
23324ae1
FM
2399 */
2400 bool MovePageDown();
2401
2402 /**
08dd9b5a
VZ
2403 Moves the grid cursor up by some number of rows so that the previous
2404 top visible row becomes the bottom visible row.
23324ae1
FM
2405 */
2406 bool MovePageUp();
2407
2408 /**
08dd9b5a
VZ
2409 Register a new data type.
2410
2411 The data types allow to naturally associate specific renderers and
2412 editors to the cells containing values of the given type. For example,
2413 the grid automatically registers a data type with the name @c
2414 wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
2415 wxGridCellTextEditor as its renderer and editor respectively -- this is
2416 the data type used by all the cells of the default wxGridStringTable,
2417 so this renderer and editor are used by default for all grid cells.
2418
2419 However if a custom table returns @c wxGRID_VALUE_BOOL from its
2420 wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
2421 wxGridCellBoolEditor are used for it because the grid also registers a
2422 boolean data type with this name.
2423
2424 And as this mechanism is completely generic, you may register your own
2425 data types using your own custom renderers and editors. Just remember
2426 that the table must identify a cell as being of the given type for them
2427 to be used for this cell.
2428
2429 @param typeName
2430 Name of the new type. May be any string, but if the type name is
2431 the same as the name of an already registered type, including one
2432 of the standard ones (which are @c wxGRID_VALUE_STRING, @c
2433 wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT
2434 and @c wxGRID_VALUE_CHOICE), then the new registration information
2435 replaces the previously used renderer and editor.
2436 @param renderer
2437 The renderer to use for the cells of this type. Its ownership is
2438 taken by the grid, i.e. it will call DecRef() on this pointer when
2439 it doesn't need it any longer.
2440 @param editor
2441 The editor to use for the cells of this type. Its ownership is also
2442 taken by the grid.
23324ae1
FM
2443 */
2444 void RegisterDataType(const wxString& typeName,
2445 wxGridCellRenderer* renderer,
2446 wxGridCellEditor* editor);
2447
23324ae1 2448 /**
08dd9b5a
VZ
2449 Sets the value of the current grid cell to the current in-place edit
2450 control value.
2451
2452 This is called automatically when the grid cursor moves from the
2453 current cell to a new cell. It is also a good idea to call this
2454 function when closing a grid since any edits to the final cell location
2455 will not be saved otherwise.
23324ae1
FM
2456 */
2457 void SaveEditControlValue();
2458
2459 /**
2460 Selects all cells in the grid.
2461 */
2462 void SelectAll();
2463
2464 //@{
2465 /**
08dd9b5a
VZ
2466 Selects a rectangular block of cells.
2467
2468 If @a addToSelected is @false then any existing selection will be
2469 deselected; if @true the column will be added to the existing
2470 selection.
23324ae1 2471 */
08dd9b5a 2472 void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol,
4cc4bfaf 2473 bool addToSelected = false);
7c913512
FM
2474 void SelectBlock(const wxGridCellCoords& topLeft,
2475 const wxGridCellCoords& bottomRight,
4cc4bfaf 2476 bool addToSelected = false);
23324ae1
FM
2477 //@}
2478
2479 /**
08dd9b5a
VZ
2480 Selects the specified column.
2481
2482 If @a addToSelected is @false then any existing selection will be
2483 deselected; if @true the column will be added to the existing
2484 selection.
2485
2486 This method won't select anything if the current selection mode is
2487 wxGridSelectRows.
23324ae1 2488 */
4cc4bfaf 2489 void SelectCol(int col, bool addToSelected = false);
23324ae1
FM
2490
2491 /**
08dd9b5a
VZ
2492 Selects the specified row.
2493
2494 If @a addToSelected is @false then any existing selection will be
23324ae1 2495 deselected; if @true the row will be added to the existing selection.
23324ae1 2496
08dd9b5a
VZ
2497 This method won't select anything if the current selection mode is
2498 wxGridSelectColumns.
23324ae1 2499 */
08dd9b5a 2500 void SelectRow(int row, bool addToSelected = false);
23324ae1
FM
2501
2502 //@{
2503 /**
08dd9b5a
VZ
2504 Sets the horizontal and vertical alignment for grid cell text at the
2505 specified location.
3c4f71cc 2506
08dd9b5a
VZ
2507 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2508 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2509
2510 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2511 or @c wxALIGN_BOTTOM.
23324ae1
FM
2512 */
2513 void SetCellAlignment(int row, int col, int horiz, int vert);
7c913512 2514 void SetCellAlignment(int align, int row, int col);
23324ae1
FM
2515 //@}
2516
08dd9b5a 2517 //@{
23324ae1 2518 /**
08dd9b5a 2519 Set the background colour for the given cell or all cells by default.
23324ae1 2520 */
08dd9b5a
VZ
2521 void SetCellBackgroundColour(int row, int col, const wxColour& colour);
2522 //@}
23324ae1
FM
2523
2524 /**
2525 Sets the editor for the grid cell at the specified location.
08dd9b5a 2526
23324ae1 2527 The grid will take ownership of the pointer.
08dd9b5a 2528
c7d4ca81
RR
2529 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
2530 for more information about cell editors and renderers.
23324ae1
FM
2531 */
2532 void SetCellEditor(int row, int col, wxGridCellEditor* editor);
2533
2534 /**
2535 Sets the font for text in the grid cell at the specified location.
2536 */
2537 void SetCellFont(int row, int col, const wxFont& font);
2538
2539 /**
2540 Sets the renderer for the grid cell at the specified location.
08dd9b5a 2541
23324ae1 2542 The grid will take ownership of the pointer.
08dd9b5a 2543
c7d4ca81
RR
2544 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
2545 for more information about cell editors and renderers.
23324ae1 2546 */
08dd9b5a 2547 void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer);
23324ae1
FM
2548
2549 //@{
2550 /**
08dd9b5a 2551 Sets the text colour for the given cell or all cells by default.
23324ae1
FM
2552 */
2553 void SetCellTextColour(int row, int col, const wxColour& colour);
7c913512
FM
2554 void SetCellTextColour(const wxColour& val, int row, int col);
2555 void SetCellTextColour(const wxColour& colour);
23324ae1
FM
2556 //@}
2557
2558 //@{
2559 /**
08dd9b5a
VZ
2560 Sets the string value for the cell at the specified location.
2561
2562 For simple applications where a grid object automatically uses a
2563 default grid table of string values you use this function together with
2564 GetCellValue() to access cell values. For more complex applications
2565 where you have derived your own grid table class that contains various
2566 data types (e.g. numeric, boolean or user-defined custom types) then
2567 you only use this function for those cells that contain string values.
23324ae1 2568 The last form is for backward compatibility only.
08dd9b5a 2569
c7d4ca81 2570 See wxGridTableBase::CanSetValueAs and the @ref overview_grid
08dd9b5a 2571 "wxGrid overview" for more information.
23324ae1
FM
2572 */
2573 void SetCellValue(int row, int col, const wxString& s);
08dd9b5a 2574 void SetCellValue(const wxGridCellCoords& coords, const wxString& s);
7c913512 2575 void SetCellValue(const wxString& val, int row, int col);
23324ae1
FM
2576 //@}
2577
2578 /**
2579 Sets the cell attributes for all cells in the specified column.
08dd9b5a 2580
23324ae1 2581 For more information about controlling grid cell attributes see the
c7d4ca81 2582 wxGridCellAttr cell attribute class and the @ref overview_grid "wxGrid overview".
23324ae1
FM
2583 */
2584 void SetColAttr(int col, wxGridCellAttr* attr);
2585
2586 /**
08dd9b5a
VZ
2587 Sets the specified column to display boolean values.
2588
2589 @see SetColFormatCustom()
23324ae1
FM
2590 */
2591 void SetColFormatBool(int col);
2592
2593 /**
2594 Sets the specified column to display data in a custom format.
08dd9b5a
VZ
2595
2596 This method provides an alternative to defining a custom grid table
2597 which would return @a typeName from its GetTypeName() method for the
2598 cells in this column: while it doesn't really change the type of the
2599 cells in this column, it does associate the renderer and editor used
2600 for the cells of the specified type with them.
2601
c7d4ca81 2602 See the @ref overview_grid "wxGrid overview" for more
08dd9b5a 2603 information on working with custom data types.
23324ae1
FM
2604 */
2605 void SetColFormatCustom(int col, const wxString& typeName);
2606
2607 /**
08dd9b5a
VZ
2608 Sets the specified column to display floating point values with the
2609 given width and precision.
2610
2611 @see SetColFormatCustom()
23324ae1 2612 */
08dd9b5a 2613 void SetColFormatFloat(int col, int width = -1, int precision = -1);
23324ae1
FM
2614
2615 /**
2616 Sets the specified column to display integer values.
08dd9b5a
VZ
2617
2618 @see SetColFormatCustom()
23324ae1
FM
2619 */
2620 void SetColFormatNumber(int col);
2621
2622 /**
2623 Sets the horizontal and vertical alignment of column label text.
08dd9b5a
VZ
2624
2625 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2626 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2627 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2628 or @c wxALIGN_BOTTOM.
23324ae1
FM
2629 */
2630 void SetColLabelAlignment(int horiz, int vert);
2631
2632 /**
2633 Sets the height of the column labels.
08dd9b5a 2634
4cc4bfaf 2635 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
08dd9b5a
VZ
2636 automatically so that no label is truncated. Note that this could be
2637 slow for a large table.
23324ae1
FM
2638 */
2639 void SetColLabelSize(int height);
2640
2641 /**
08dd9b5a
VZ
2642 Set the value for the given column label.
2643
2644 If you are using a custom grid table you must override
2645 wxGridTableBase::SetColLabelValue for this to have any effect.
23324ae1
FM
2646 */
2647 void SetColLabelValue(int col, const wxString& value);
2648
2649 /**
08dd9b5a
VZ
2650 Sets the minimal width to which the user can resize columns.
2651
2652 @see GetColMinimalAcceptableWidth()
23324ae1
FM
2653 */
2654 void SetColMinimalAcceptableWidth(int width);
2655
2656 /**
08dd9b5a
VZ
2657 Sets the minimal width for the specified column.
2658
2659 It is usually best to call this method during grid creation as calling
2660 it later will not resize the column to the given minimal width even if
2661 it is currently narrower than it.
2662
2663 @a width must be greater than the minimal acceptable column width as
2664 returned by GetColMinimalAcceptableWidth().
23324ae1
FM
2665 */
2666 void SetColMinimalWidth(int col, int width);
2667
2668 /**
2669 Sets the position of the specified column.
2670 */
2671 void SetColPos(int colID, int newPos);
2672
2673 /**
2674 Sets the width of the specified column.
08dd9b5a
VZ
2675
2676 Notice that this function does not refresh the grid, you need to call
2677 ForceRefresh() to make the changes take effect immediately.
2678
2679 @param col
2680 The column index.
2681 @param width
2682 The new column width in pixels or a negative value to fit the
2683 column width to its label width.
23324ae1
FM
2684 */
2685 void SetColSize(int col, int width);
2686
2687 /**
2688 Sets the default horizontal and vertical alignment for grid cell text.
08dd9b5a
VZ
2689
2690 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2691 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2692 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2693 or @c wxALIGN_BOTTOM.
23324ae1
FM
2694 */
2695 void SetDefaultCellAlignment(int horiz, int vert);
2696
2697 /**
2698 Sets the default background colour for grid cells.
2699 */
2700 void SetDefaultCellBackgroundColour(const wxColour& colour);
2701
2702 /**
2703 Sets the default font to be used for grid cell text.
2704 */
2705 void SetDefaultCellFont(const wxFont& font);
2706
2707 /**
2708 Sets the current default colour for grid cell text.
2709 */
2710 void SetDefaultCellTextColour(const wxColour& colour);
2711
2712 /**
08dd9b5a
VZ
2713 Sets the default width for columns in the grid.
2714
2715 This will only affect columns subsequently added to the grid unless
2716 @a resizeExistingCols is @true.
2717
2718 If @a width is less than GetColMinimalAcceptableWidth(), then the
2719 minimal acceptable width is used instead of it.
23324ae1 2720 */
08dd9b5a 2721 void SetDefaultColSize(int width, bool resizeExistingCols = false);
23324ae1
FM
2722
2723 /**
08dd9b5a
VZ
2724 Sets the default editor for grid cells.
2725
2726 The grid will take ownership of the pointer.
2727
c7d4ca81
RR
2728 See wxGridCellEditor and the @ref overview_grid "wxGrid overview"
2729 for more information about cell editors and renderers.
23324ae1
FM
2730 */
2731 void SetDefaultEditor(wxGridCellEditor* editor);
2732
2733 /**
08dd9b5a
VZ
2734 Sets the default renderer for grid cells.
2735
2736 The grid will take ownership of the pointer.
2737
5e6e278d 2738 See wxGridCellRenderer and the @ref overview_grid "wxGrid overview"
c7d4ca81 2739 for more information about cell editors and renderers.
23324ae1
FM
2740 */
2741 void SetDefaultRenderer(wxGridCellRenderer* renderer);
2742
2743 /**
08dd9b5a
VZ
2744 Sets the default height for rows in the grid.
2745
2746 This will only affect rows subsequently added to the grid unless
2747 @a resizeExistingRows is @true.
2748
2749 If @a height is less than GetRowMinimalAcceptableHeight(), then the
2750 minimal acceptable heihgt is used instead of it.
23324ae1 2751 */
08dd9b5a 2752 void SetDefaultRowSize(int height, bool resizeExistingRows = false);
23324ae1 2753
8a3e536c 2754 //@{
23324ae1
FM
2755 /**
2756 Set the grid cursor to the specified cell.
08dd9b5a 2757
8a3e536c
VZ
2758 The grid cursor indicates the current cell and can be moved by the user
2759 using the arrow keys or the mouse.
2760
2761 Calling this function generates a wxEVT_GRID_SELECT_CELL event and if
2762 the event handler vetoes this event, the cursor is not moved.
2763
2764 This function doesn't make the target call visible, use GoToCell() to
2765 do this.
23324ae1
FM
2766 */
2767 void SetGridCursor(int row, int col);
8a3e536c
VZ
2768 void SetGridCursor(const wxGridCellCoords& coords);
2769 //@}
23324ae1
FM
2770
2771 /**
2772 Sets the colour used to draw grid lines.
2773 */
2774 void SetGridLineColour(const wxColour& colour);
2775
2776 /**
2777 Sets the background colour for row and column labels.
2778 */
2779 void SetLabelBackgroundColour(const wxColour& colour);
2780
2781 /**
2782 Sets the font for row and column labels.
2783 */
2784 void SetLabelFont(const wxFont& font);
2785
2786 /**
2787 Sets the colour for row and column label text.
2788 */
2789 void SetLabelTextColour(const wxColour& colour);
2790
2791 /**
08dd9b5a 2792 Sets the extra margins used around the grid area.
23324ae1 2793
08dd9b5a
VZ
2794 A grid may occupy more space than needed for its data display and
2795 this function allows to set how big this extra space is
23324ae1 2796 */
08dd9b5a 2797 void SetMargins(int extraWidth, int extraHeight);
23324ae1
FM
2798
2799 /**
2800 Makes the cell at the specified location read-only or editable.
08dd9b5a
VZ
2801
2802 @see IsReadOnly()
23324ae1 2803 */
4cc4bfaf 2804 void SetReadOnly(int row, int col, bool isReadOnly = true);
23324ae1
FM
2805
2806 /**
2807 Sets the cell attributes for all cells in the specified row.
08dd9b5a
VZ
2808
2809 The grid takes ownership of the attribute pointer.
2810
2811 See the wxGridCellAttr class for more information about controlling
2812 cell attributes.
23324ae1
FM
2813 */
2814 void SetRowAttr(int row, wxGridCellAttr* attr);
2815
2816 /**
2817 Sets the horizontal and vertical alignment of row label text.
08dd9b5a
VZ
2818
2819 Horizontal alignment should be one of @c wxALIGN_LEFT, @c
2820 wxALIGN_CENTRE or @c wxALIGN_RIGHT.
2821 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
2822 or @c wxALIGN_BOTTOM.
23324ae1
FM
2823 */
2824 void SetRowLabelAlignment(int horiz, int vert);
2825
2826 /**
2827 Sets the width of the row labels.
08dd9b5a
VZ
2828
2829 If @a width equals @c wxGRID_AUTOSIZE then width is calculated
2830 automatically so that no label is truncated. Note that this could be
2831 slow for a large table.
23324ae1
FM
2832 */
2833 void SetRowLabelSize(int width);
2834
2835 /**
08dd9b5a
VZ
2836 Sets the value for the given row label.
2837
2838 If you are using a derived grid table you must override
2839 wxGridTableBase::SetRowLabelValue for this to have any effect.
23324ae1
FM
2840 */
2841 void SetRowLabelValue(int row, const wxString& value);
2842
2843 /**
08dd9b5a
VZ
2844 Sets the minimal row height used by default.
2845
2846 See SetColMinimalAcceptableWidth() for more information.
23324ae1
FM
2847 */
2848 void SetRowMinimalAcceptableHeight(int height);
2849
2850 /**
08dd9b5a
VZ
2851 Sets the minimal height for the specified row.
2852
2853 See SetColMinimalWidth() for more information.
23324ae1
FM
2854 */
2855 void SetRowMinimalHeight(int row, int height);
2856
2857 /**
2858 Sets the height of the specified row.
08dd9b5a
VZ
2859
2860 See SetColSize() for more information.
23324ae1
FM
2861 */
2862 void SetRowSize(int row, int height);
2863
2864 /**
08dd9b5a
VZ
2865 Sets the number of pixels per horizontal scroll increment.
2866
2867 The default is 15.
3c4f71cc 2868
4cc4bfaf 2869 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
23324ae1
FM
2870 */
2871 void SetScrollLineX(int x);
2872
2873 /**
08dd9b5a
VZ
2874 Sets the number of pixels per vertical scroll increment.
2875
2876 The default is 15.
3c4f71cc 2877
4cc4bfaf 2878 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
23324ae1
FM
2879 */
2880 void SetScrollLineY(int y);
2881
2882 /**
08dd9b5a 2883 Set the colour to be used for drawing the selection background.
23324ae1
FM
2884 */
2885 void SetSelectionBackground(const wxColour& c);
2886
2887 /**
08dd9b5a 2888 Set the colour to be used for drawing the selection foreground.
23324ae1
FM
2889 */
2890 void SetSelectionForeground(const wxColour& c);
2891
2892 /**
2893 Set the selection behaviour of the grid.
3c4f71cc 2894
55f0bf1f
VZ
2895 The existing selection is converted to conform to the new mode if
2896 possible and discarded otherwise (e.g. any individual selected cells
2897 are deselected if the new mode allows only the selection of the entire
2898 rows or columns).
23324ae1 2899 */
55f0bf1f 2900 void SetSelectionMode(wxGridSelectionModes selmode);
23324ae1
FM
2901
2902 /**
08dd9b5a
VZ
2903 Passes a pointer to a custom grid table to be used by the grid.
2904
2905 This should be called after the grid constructor and before using the
2906 grid object. If @a takeOwnership is set to @true then the table will be
2907 deleted by the wxGrid destructor.
2908
2909 Use this function instead of CreateGrid() when your application
2910 involves complex or non-string data or data sets that are too large to
2911 fit wholly in memory.
23324ae1 2912 */
55f0bf1f
VZ
2913 bool SetTable(wxGridTableBase* table,
2914 bool takeOwnership = false,
2915 wxGridSelectionModes selmode = wxGridSelectCells);
23324ae1
FM
2916
2917 /**
2918 Call this in order to make the column labels use a native look by using
55f0bf1f
VZ
2919 wxRenderer::DrawHeaderButton internally.
2920
2921 There is no equivalent method for drawing row columns as there is not
2922 native look for that. This option is useful when using wxGrid for
2923 displaying tables and not as a spread-sheet.
23324ae1 2924 */
4cc4bfaf 2925 void SetUseNativeColLabels(bool native = true);
23324ae1
FM
2926
2927 /**
2928 Displays the in-place cell edit control for the current cell.
2929 */
2930 void ShowCellEditControl();
2931
2932 /**
08dd9b5a
VZ
2933 Returns the column at the given pixel position.
2934
7c913512 2935 @param x
4cc4bfaf 2936 The x position to evaluate.
7c913512 2937 @param clipToMinMax
08dd9b5a
VZ
2938 If @true, rather than returning wxNOT_FOUND, it returns either the
2939 first or last column depending on whether x is too far to the left
2940 or right respectively.
2941 @return
2942 The column index or wxNOT_FOUND.
23324ae1 2943 */
328f5751 2944 int XToCol(int x, bool clipToMinMax = false) const;
23324ae1
FM
2945
2946 /**
08dd9b5a
VZ
2947 Returns the column whose right hand edge is close to the given logical
2948 x position.
2949
23324ae1
FM
2950 If no column edge is near to this position @c wxNOT_FOUND is returned.
2951 */
328f5751 2952 int XToEdgeOfCol(int x) const;
23324ae1 2953
8a3e536c
VZ
2954 //@{
2955 /**
2956 Translates logical pixel coordinates to the grid cell coordinates.
2957
2958 Notice that this function expects logical coordinates on input so if
2959 you use this function in a mouse event handler you need to translate
2960 the mouse position, which is expressed in device coordinates, to
2961 logical ones.
2962
2963 @see XToCol(), YToRow()
2964 */
2965
2966 // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
2967 // undocumented, using it is ugly and non-const reference parameters are
2968 // not used in wxWidgets API
2969
2970 wxGridCellCoords XYToCell(int x, int y) const;
2971 wxGridCellCoords XYToCell(const wxPoint& pos) const;
2972
2973 //@}
2974
23324ae1 2975 /**
08dd9b5a
VZ
2976 Returns the row whose bottom edge is close to the given logical y
2977 position.
2978
23324ae1
FM
2979 If no row edge is near to this position @c wxNOT_FOUND is returned.
2980 */
328f5751 2981 int YToEdgeOfRow(int y) const;
23324ae1
FM
2982
2983 /**
08dd9b5a
VZ
2984 Returns the grid row that corresponds to the logical y coordinate.
2985
2986 Returns @c wxNOT_FOUND if there is no row at the y position.
23324ae1 2987 */
5267aefd 2988 int YToRow(int y, bool clipToMinMax = false) const;
5e6e278d
FM
2989
2990protected:
2991 /**
2992 Returns @true if this grid has support for cell attributes.
2993
2994 The grid supports attributes if it has the associated table which, in
2995 turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
2996 returns @true.
2997 */
2998 bool CanHaveAttributes() const;
2999
3000 /**
3001 Get the minimal width of the given column/row.
3002
3003 The value returned by this function may be different than that returned
3004 by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
3005 called for this column.
3006 */
3007 int GetColMinimalWidth(int col) const;
3008
3009 /**
3010 Returns the coordinate of the right border specified column.
3011 */
3012 int GetColRight(int col) const;
3013
3014 /**
3015 Returns the coordinate of the left border specified column.
3016 */
3017 int GetColLeft(int col) const;
3018
3019 /**
3020 Returns the minimal size for the given column.
3021
3022 The value returned by this function may be different than that returned
3023 by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
3024 called for this row.
3025 */
3026 int GetRowMinimalHeight(int col) const;
23324ae1
FM
3027};
3028
3029
e54c96f1 3030
23324ae1
FM
3031/**
3032 @class wxGridCellBoolEditor
7c913512 3033
23324ae1 3034 The editor for boolean data.
7c913512 3035
23324ae1 3036 @library{wxadv}
42b5841f 3037 @category{grid}
7c913512 3038
e54c96f1 3039 @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor,
23324ae1
FM
3040 wxGridCellTextEditor, wxGridCellChoiceEditor
3041*/
3042class wxGridCellBoolEditor : public wxGridCellEditor
3043{
3044public:
3045 /**
3046 Default constructor.
3047 */
3048 wxGridCellBoolEditor();
3049
3050 /**
4cc4bfaf 3051 Returns @true if the given @a value is equal to the string representation of
7c913512 3052 the truth value we currently use (see
23324ae1
FM
3053 wxGridCellBoolEditor::UseStringValues).
3054 */
3055 static bool IsTrueValue(const wxString& value);
3056
3057 /**
328f5751 3058 , wxString&@e valueFalse = _T(""))
23324ae1
FM
3059 This method allows to customize the values returned by GetValue() method for
3060 the cell using this editor. By default, the default values of the arguments are
3061 used, i.e. @c "1" is returned if the cell is checked and an empty string
3062 otherwise, using this method allows to change this.
3063 */
328f5751 3064 static void UseStringValues() const;
23324ae1
FM
3065};
3066
3067
e54c96f1 3068
23324ae1
FM
3069/**
3070 @class wxGridUpdateLocker
7c913512 3071
23324ae1
FM
3072 This small class can be used to prevent wxGrid from redrawing
3073 during its lifetime by calling wxGrid::BeginBatch
3074 in its constructor and wxGrid::EndBatch in its
3075 destructor. It is typically used in a function performing several operations
3076 with a grid which would otherwise result in flicker. For example:
7c913512 3077
23324ae1
FM
3078 @code
3079 void MyFrame::Foo()
3080 {
3081 m_grid = new wxGrid(this, ...);
7c913512 3082
23324ae1
FM
3083 wxGridUpdateLocker noUpdates(m_grid);
3084 m_grid-AppendColumn();
3085 ... many other operations with m_grid...
3086 m_grid-AppendRow();
7c913512 3087
23324ae1
FM
3088 // destructor called, grid refreshed
3089 }
3090 @endcode
7c913512
FM
3091
3092 Using this class is easier and safer than calling
23324ae1
FM
3093 wxGrid::BeginBatch and wxGrid::EndBatch
3094 because you don't risk not to call the latter (due to an exception for example).
7c913512 3095
23324ae1 3096 @library{wxadv}
42b5841f 3097 @category{grid}
23324ae1 3098*/
7c913512 3099class wxGridUpdateLocker
23324ae1
FM
3100{
3101public:
3102 /**
3103 Creates an object preventing the updates of the specified @e grid. The
4cc4bfaf 3104 parameter could be @NULL in which case nothing is done. If @a grid is
23324ae1
FM
3105 non-@NULL then the grid must exist for longer than wxGridUpdateLocker object
3106 itself.
7c913512 3107 The default constructor could be followed by a call to
23324ae1
FM
3108 Create() to set the
3109 grid object later.
3110 */
4cc4bfaf 3111 wxGridUpdateLocker(wxGrid* grid = NULL);
23324ae1
FM
3112
3113 /**
3114 Destructor reenables updates for the grid this object is associated with.
3115 */
3116 ~wxGridUpdateLocker();
3117
3118 /**
3119 This method can be called if the object had been constructed using the default
3120 constructor. It must not be called more than once.
3121 */
3122 void Create(wxGrid* grid);
3123};
e54c96f1 3124