Document wxGridCellAttrProvider.
[wxWidgets.git] / interface / wx / grid.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: grid.h
3 // Purpose: interface of wxGrid and related classes
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxGridCellRenderer
11
12 This class is responsible for actually drawing the cell in the grid. You
13 may pass it to the wxGridCellAttr (below) to change the format of one given
14 cell or to wxGrid::SetDefaultRenderer() to change the view of all cells.
15 This is an abstract class, and you will normally use one of the predefined
16 derived classes or derive your own class from it.
17
18 @library{wxadv}
19 @category{grid}
20
21 @see wxGridCellBoolRenderer, wxGridCellFloatRenderer,
22 wxGridCellNumberRenderer, wxGridCellStringRenderer
23 */
24 class wxGridCellRenderer
25 {
26 public:
27 /**
28 This function must be implemented in derived classes to return a copy
29 of itself.
30 */
31 virtual wxGridCellRenderer* Clone() const = 0;
32
33 /**
34 Draw the given cell on the provided DC inside the given rectangle using
35 the style specified by the attribute and the default or selected state
36 corresponding to the isSelected value.
37
38 This pure virtual function has a default implementation which will
39 prepare the DC using the given attribute: it will draw the rectangle
40 with the background colour from attr and set the text colour and font.
41 */
42 virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
43 const wxRect& rect, int row, int col,
44 bool isSelected) = 0;
45
46 /**
47 Get the preferred size of the cell for its contents.
48 */
49 virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
50 int row, int col) = 0;
51 };
52
53 /**
54 @class wxGridCellBoolRenderer
55
56 This class may be used to format boolean data in a cell.
57
58 @library{wxadv}
59 @category{grid}
60
61 @see wxGridCellRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer,
62 wxGridCellStringRenderer
63 */
64 class wxGridCellBoolRenderer : public wxGridCellRenderer
65 {
66 public:
67 /**
68 Default constructor.
69 */
70 wxGridCellBoolRenderer();
71 };
72
73 /**
74 @class wxGridCellFloatRenderer
75
76 This class may be used to format floating point data in a cell.
77
78 @library{wxadv}
79 @category{grid}
80
81 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellNumberRenderer,
82 wxGridCellStringRenderer
83 */
84 class wxGridCellFloatRenderer : public wxGridCellStringRenderer
85 {
86 public:
87 /**
88 @param width
89 Minimum number of characters to be shown.
90 @param precision
91 Number of digits after the decimal dot.
92 */
93 wxGridCellFloatRenderer(int width = -1, int precision = -1);
94
95 /**
96 Returns the precision.
97 */
98 int GetPrecision() const;
99
100 /**
101 Returns the width.
102 */
103 int GetWidth() const;
104
105 /**
106 Parameters string format is "width[,precision]".
107 */
108 virtual void SetParameters(const wxString& params);
109
110 /**
111 Sets the precision.
112 */
113 void SetPrecision(int precision);
114
115 /**
116 Sets the width.
117 */
118 void SetWidth(int width);
119 };
120
121 /**
122 @class wxGridCellNumberRenderer
123
124 This class may be used to format integer data in a cell.
125
126 @library{wxadv}
127 @category{grid}
128
129 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer,
130 wxGridCellStringRenderer
131 */
132 class wxGridCellNumberRenderer : public wxGridCellStringRenderer
133 {
134 public:
135 /**
136 Default constructor.
137 */
138 wxGridCellNumberRenderer();
139 };
140
141 /**
142 @class wxGridCellStringRenderer
143
144 This class may be used to format string data in a cell; it is the default
145 for string cells.
146
147 @library{wxadv}
148 @category{grid}
149
150 @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer,
151 wxGridCellNumberRenderer
152 */
153 class wxGridCellStringRenderer : public wxGridCellRenderer
154 {
155 public:
156 /**
157 Default constructor.
158 */
159 wxGridCellStringRenderer();
160 };
161
162
163
164 /**
165 @class wxGridCellEditor
166
167 This class is responsible for providing and manipulating the in-place edit
168 controls for the grid. Instances of wxGridCellEditor (actually, instances
169 of derived classes since it is an abstract class) can be associated with
170 the cell attributes for individual cells, rows, columns, or even for the
171 entire grid.
172
173 @library{wxadv}
174 @category{grid}
175
176 @see wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellFloatEditor,
177 wxGridCellNumberEditor, wxGridCellTextEditor
178 */
179 class wxGridCellEditor
180 {
181 public:
182 /**
183 Default constructor.
184 */
185 wxGridCellEditor();
186
187 /**
188 Fetch the value from the table and prepare the edit control to begin
189 editing.
190
191 This function should save the original value of the grid cell at the
192 given @a row and @a col and show the control allowing the user to
193 change it.
194
195 @see EndEdit()
196 */
197 virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
198
199 /**
200 Create a new object which is the copy of this one.
201 */
202 virtual wxGridCellEditor* Clone() const = 0;
203
204 /**
205 Creates the actual edit control.
206 */
207 virtual void Create(wxWindow* parent, wxWindowID id,
208 wxEvtHandler* evtHandler) = 0;
209
210 /**
211 Final cleanup.
212 */
213 virtual void Destroy();
214
215 /**
216 End editing the cell.
217
218 This function must check if the current value of the editing control is
219 valid and different from the original value (available as @a oldval in
220 its string form and possibly saved internally using its real type by
221 BeginEdit()). If it isn't, it just returns @false, otherwise it must do
222 the following:
223 # Save the new value internally so that ApplyEdit() could apply it.
224 # Fill @a newval (which is never @NULL) with the string
225 representation of the new value.
226 # Return @true
227
228 Notice that it must @em not modify the grid as the change could still
229 be vetoed.
230
231 If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto
232 this change, ApplyEdit() will be called next.
233 */
234 virtual bool EndEdit(int row, int col, const wxGrid* grid,
235 const wxString& oldval, wxString* newval) = 0;
236
237 /**
238 Effectively save the changes in the grid.
239
240 This function should save the value of the control in the grid. It is
241 called only after EndEdit() returns @true.
242 */
243 virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0;
244
245 /**
246 Some types of controls on some platforms may need some help with the
247 Return key.
248 */
249 virtual void HandleReturn(wxKeyEvent& event);
250
251 /**
252 Returns @true if the edit control has been created.
253 */
254 bool IsCreated();
255
256 /**
257 Draws the part of the cell not occupied by the control: the base class
258 version just fills it with background colour from the attribute.
259 */
260 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr* attr);
261
262 /**
263 Reset the value in the control back to its starting value.
264 */
265 virtual void Reset() = 0;
266
267 /**
268 Size and position the edit control.
269 */
270 virtual void SetSize(const wxRect& rect);
271
272 /**
273 Show or hide the edit control, use the specified attributes to set
274 colours/fonts for it.
275 */
276 virtual void Show(bool show, wxGridCellAttr* attr = NULL);
277
278 /**
279 If the editor is enabled by clicking on the cell, this method will be
280 called.
281 */
282 virtual void StartingClick();
283
284 /**
285 If the editor is enabled by pressing keys on the grid, this will be
286 called to let the editor do something about that first key if desired.
287 */
288 virtual void StartingKey(wxKeyEvent& event);
289
290 protected:
291
292 /**
293 The destructor is private because only DecRef() can delete us.
294 */
295 virtual ~wxGridCellEditor();
296 };
297
298 /**
299 @class wxGridCellBoolEditor
300
301 Grid cell editor for boolean data.
302
303 @library{wxadv}
304 @category{grid}
305
306 @see wxGridCellEditor, wxGridCellChoiceEditor, wxGridCellFloatEditor,
307 wxGridCellNumberEditor, wxGridCellTextEditor
308 */
309 class wxGridCellBoolEditor : public wxGridCellEditor
310 {
311 public:
312 /**
313 Default constructor.
314 */
315 wxGridCellBoolEditor();
316
317 /**
318 Returns @true if the given @a value is equal to the string
319 representation of the truth value we currently use (see
320 UseStringValues()).
321 */
322 static bool IsTrueValue(const wxString& value);
323
324 /**
325 This method allows you to customize the values returned by GetValue()
326 for the cell using this editor. By default, the default values of the
327 arguments are used, i.e. @c "1" is returned if the cell is checked and
328 an empty string otherwise.
329 */
330 static void UseStringValues(const wxString& valueTrue = "1",
331 const wxString& valueFalse = wxEmptyString);
332 };
333
334 /**
335 @class wxGridCellChoiceEditor
336
337 Grid cell editor for string data providing the user a choice from a list of
338 strings.
339
340 @library{wxadv}
341 @category{grid}
342
343 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellFloatEditor,
344 wxGridCellNumberEditor, wxGridCellTextEditor
345 */
346 class wxGridCellChoiceEditor : public wxGridCellEditor
347 {
348 public:
349 /**
350 @param count
351 Number of strings from which the user can choose.
352 @param choices
353 An array of strings from which the user can choose.
354 @param allowOthers
355 If allowOthers is @true, the user can type a string not in choices
356 array.
357 */
358 wxGridCellChoiceEditor(size_t count = 0,
359 const wxString choices[] = NULL,
360 bool allowOthers = false);
361 /**
362 @param choices
363 An array of strings from which the user can choose.
364 @param allowOthers
365 If allowOthers is @true, the user can type a string not in choices
366 array.
367 */
368 wxGridCellChoiceEditor(const wxArrayString& choices,
369 bool allowOthers = false);
370
371 /**
372 Parameters string format is "item1[,item2[...,itemN]]"
373 */
374 virtual void SetParameters(const wxString& params);
375 };
376
377 /**
378 @class wxGridCellTextEditor
379
380 Grid cell editor for string/text data.
381
382 @library{wxadv}
383 @category{grid}
384
385 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
386 wxGridCellFloatEditor, wxGridCellNumberEditor
387 */
388 class wxGridCellTextEditor : public wxGridCellEditor
389 {
390 public:
391 /**
392 Default constructor.
393 */
394 wxGridCellTextEditor();
395
396 /**
397 The parameters string format is "n" where n is a number representing
398 the maximum width.
399 */
400 virtual void SetParameters(const wxString& params);
401 };
402
403 /**
404 @class wxGridCellFloatEditor
405
406 The editor for floating point numbers data.
407
408 @library{wxadv}
409 @category{grid}
410
411 @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor,
412 wxGridCellTextEditor, wxGridCellChoiceEditor
413 */
414 class wxGridCellFloatEditor : public wxGridCellTextEditor
415 {
416 public:
417 /**
418 @param width
419 Minimum number of characters to be shown.
420 @param precision
421 Number of digits after the decimal dot.
422 */
423 wxGridCellFloatEditor(int width = -1, int precision = -1);
424
425 /**
426 Parameters string format is "width,precision"
427 */
428 virtual void SetParameters(const wxString& params);
429 };
430
431 /**
432 @class wxGridCellNumberEditor
433
434 Grid cell editor for numeric integer data.
435
436 @library{wxadv}
437 @category{grid}
438
439 @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor,
440 wxGridCellFloatEditor, wxGridCellTextEditor
441 */
442 class wxGridCellNumberEditor : public wxGridCellTextEditor
443 {
444 public:
445 /**
446 Allows you to specify the range for acceptable data. Values equal to
447 -1 for both @a min and @a max indicate that no range checking should be
448 done.
449 */
450 wxGridCellNumberEditor(int min = -1, int max = -1);
451
452
453 /**
454 Parameters string format is "min,max".
455 */
456 virtual void SetParameters(const wxString& params);
457
458 protected:
459
460 /**
461 If the return value is @true, the editor uses a wxSpinCtrl to get user
462 input, otherwise it uses a wxTextCtrl.
463 */
464 bool HasRange() const;
465
466 /**
467 String representation of the value.
468 */
469 wxString GetString() const;
470 };
471
472
473
474 /**
475 @class wxGridCellAttr
476
477 This class can be used to alter the cells' appearance in the grid by
478 changing their attributes from the defaults. An object of this class may be
479 returned by wxGridTableBase::GetAttr().
480
481 @library{wxadv}
482 @category{grid}
483 */
484 class wxGridCellAttr
485 {
486 public:
487 /**
488 Kind of the attribute to retrieve.
489
490 @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr()
491 */
492 enum wxAttrKind
493 {
494 /// Return the combined effective attribute for the cell.
495 Any,
496
497 /// Return the attribute explicitly set for this cell.
498 Cell,
499
500 /// Return the attribute set for this cells row.
501 Row,
502
503 /// Return the attribute set for this cells column.
504 Col
505 };
506
507 /**
508 Default constructor.
509 */
510 wxGridCellAttr(wxGridCellAttr* attrDefault = NULL);
511 /**
512 Constructor specifying some of the often used attributes.
513 */
514 wxGridCellAttr(const wxColour& colText, const wxColour& colBack,
515 const wxFont& font, int hAlign, int vAlign);
516
517 /**
518 Creates a new copy of this object.
519 */
520 wxGridCellAttr* Clone() const;
521
522 /**
523 This class is reference counted: it is created with ref count of 1, so
524 calling DecRef() once will delete it. Calling IncRef() allows to lock
525 it until the matching DecRef() is called.
526 */
527 void DecRef();
528
529 /**
530 See SetAlignment() for the returned values.
531 */
532 void GetAlignment(int* hAlign, int* vAlign) const;
533
534 /**
535 Returns the background colour.
536 */
537 const wxColour& GetBackgroundColour() const;
538
539 /**
540 Returns the cell editor.
541 */
542 wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const;
543
544 /**
545 Returns the font.
546 */
547 const wxFont& GetFont() const;
548
549 /**
550 Returns the cell renderer.
551 */
552 wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const;
553
554 /**
555 Returns the text colour.
556 */
557 const wxColour& GetTextColour() const;
558
559 /**
560 Returns @true if this attribute has a valid alignment set.
561 */
562 bool HasAlignment() const;
563
564 /**
565 Returns @true if this attribute has a valid background colour set.
566 */
567 bool HasBackgroundColour() const;
568
569 /**
570 Returns @true if this attribute has a valid cell editor set.
571 */
572 bool HasEditor() const;
573
574 /**
575 Returns @true if this attribute has a valid font set.
576 */
577 bool HasFont() const;
578
579 /**
580 Returns @true if this attribute has a valid cell renderer set.
581 */
582 bool HasRenderer() const;
583
584 /**
585 Returns @true if this attribute has a valid text colour set.
586 */
587 bool HasTextColour() const;
588
589 /**
590 This class is reference counted: it is created with ref count of 1, so
591 calling DecRef() once will delete it. Calling IncRef() allows to lock
592 it until the matching DecRef() is called.
593 */
594 void IncRef();
595
596 /**
597 Returns @true if this cell is set as read-only.
598 */
599 bool IsReadOnly() const;
600
601 /**
602 Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT,
603 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of
604 @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
605 */
606 void SetAlignment(int hAlign, int vAlign);
607
608 /**
609 Sets the background colour.
610 */
611 void SetBackgroundColour(const wxColour& colBack);
612
613 /**
614 @todo Needs documentation.
615 */
616 void SetDefAttr(wxGridCellAttr* defAttr);
617
618 /**
619 Sets the editor to be used with the cells with this attribute.
620 */
621 void SetEditor(wxGridCellEditor* editor);
622
623 /**
624 Sets the font.
625 */
626 void SetFont(const wxFont& font);
627
628 /**
629 Sets the cell as read-only.
630 */
631 void SetReadOnly(bool isReadOnly = true);
632
633 /**
634 Sets the renderer to be used for cells with this attribute. Takes
635 ownership of the pointer.
636 */
637 void SetRenderer(wxGridCellRenderer* renderer);
638
639 /**
640 Sets the text colour.
641 */
642 void SetTextColour(const wxColour& colText);
643 };
644
645 /**
646 Class providing attributes to be used for the grid cells.
647
648 This class both defines an interface which grid cell attributes providers
649 should implement -- and which can be implemented differently in derived
650 classes -- and a default implementation of this interface which is often
651 good enough to be used without modification, especially with not very large
652 grids for which the efficiency of attributes storage hardly matters (see
653 the discussion below).
654
655 An object of this class can be associated with a wxGrid using
656 wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you
657 intend to use the default provider as it is used by wxGridTableBase by
658 default anyhow.
659
660 Notice that while attributes provided by this class can be set for
661 individual cells using SetAttr() or the entire rows or columns using
662 SetRowAttr() and SetColAttr() they are always retrieved using GetAttr()
663 function.
664
665
666 The default implementation of this class stores the attributes passed to
667 its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A
668 derived class may use its knowledge about how the attributes are used in
669 your program to implement it much more efficiently: for example, using a
670 special background colour for all even-numbered rows can be implemented by
671 simply returning the same attribute from GetAttr() if the row number is
672 even instead of having to store N/2 row attributes where N is the total
673 number of rows in the grid.
674
675 Notice that objects of this class can't be copied.
676 */
677 class wxGridCellAttrProvider : public wxClientDataContainer
678 {
679 public:
680 /// Trivial default constructor.
681 wxGridCellAttrProvider();
682
683 /// Destructor releases any attributes held by this class.
684 virtual ~wxGridCellAttrProvider();
685
686 /**
687 Get the attribute to use for the specified cell.
688
689 If wxGridCellAttr::Any is used as @a kind value, this function combines
690 the attributes set for this cell using SetAttr() and those for its row
691 or column (set with SetRowAttr() or SetColAttr() respectively), with
692 the cell attribute having the highest precedence.
693
694 Notice that the caller must call DecRef() on the returned pointer if it
695 is non-@NULL.
696
697 @param row
698 The row of the cell.
699 @param col
700 The column of the cell.
701 @param kind
702 The kind of the attribute to return.
703 @return
704 The attribute to use which should be DecRef()'d by caller or @NULL
705 if no attributes are defined for this cell.
706 */
707 virtual wxGridCellAttr *GetAttr(int row, int col,
708 wxGridCellAttr::wxAttrKind kind) const;
709
710 /**
711 Setting attributes.
712
713 All these functions take ownership of the attribute passed to them,
714 i.e. will call DecRef() on it themselves later and so it should not be
715 destroyed by the caller. And the attribute can be @NULL to reset a
716 previously set value.
717 */
718 //@{
719
720 /// Set attribute for the specified cell.
721 virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
722
723 /// Set attribute for the specified row.
724 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
725
726 /// Set attribute for the specified column.
727 virtual void SetColAttr(wxGridCellAttr *attr, int col);
728
729 //@}
730 };
731
732
733 /**
734 @class wxGridTableBase
735
736 The almost abstract base class for grid tables.
737
738 A grid table is responsible for storing the grid data and, indirectly, grid
739 cell attributes. The data can be stored in the way most convenient for the
740 application but has to be provided in string form to wxGrid. It is also
741 possible to provide cells values in other formats if appropriate, e.g. as
742 numbers.
743
744 This base class is not quite abstract as it implements a trivial strategy
745 for storing the attributes by forwarding it to wxGridCellAttrProvider and
746 also provides stubs for some other functions. However it does have a number
747 of pure virtual methods which must be implemented in the derived classes.
748
749 @see wxGridStringTable
750
751 @library{wxadv}
752 @category{grid}
753 */
754 class wxGridTableBase : public wxObject
755 {
756 public:
757 /**
758 Default constructor.
759 */
760 wxGridTableBase();
761
762 /**
763 Destructor frees the attribute provider if it was created.
764 */
765 virtual ~wxGridTableBase();
766
767 /**
768 Must be overridden to return the number of rows in the table.
769
770 For backwards compatibility reasons, this method is not const.
771 Use GetRowsCount() instead of it in const methods of derived table
772 classes.
773 */
774 virtual int GetNumberRows() = 0;
775
776 /**
777 Must be overridden to return the number of columns in the table.
778
779 For backwards compatibility reasons, this method is not const.
780 Use GetColsCount() instead of it in const methods of derived table
781 classes,
782 */
783 virtual int GetNumberCols() = 0;
784
785 /**
786 Return the number of rows in the table.
787
788 This method is not virtual and is only provided as a convenience for
789 the derived classes which can't call GetNumberRows() without a
790 @c const_cast from their const methods.
791 */
792 int GetRowsCount() const;
793
794 /**
795 Return the number of columns in the table.
796
797 This method is not virtual and is only provided as a convenience for
798 the derived classes which can't call GetNumberCols() without a
799 @c const_cast from their const methods.
800 */
801 int GetColsCount() const;
802
803
804 /**
805 @name Table Cell Accessors
806 */
807 //@{
808
809 /**
810 May be overridden to implement testing for empty cells.
811
812 This method is used by the grid to test if the given cell is not used
813 and so whether a neighbouring cell may overflow into it. By default it
814 only returns true if the value of the given cell, as returned by
815 GetValue(), is empty.
816 */
817 virtual bool IsEmptyCell(int row, int col);
818
819 /**
820 Same as IsEmptyCell() but taking wxGridCellCoords.
821
822 Notice that this method is not virtual, only IsEmptyCell() should be
823 overridden.
824 */
825 bool IsEmpty(const wxGridCellCoords& coords);
826
827 /**
828 Must be overridden to implement accessing the table values as text.
829 */
830 virtual wxString GetValue(int row, int col) = 0;
831
832 /**
833 Must be overridden to implement setting the table values as text.
834 */
835 virtual void SetValue(int row, int col, const wxString& value) = 0;
836
837 /**
838 Returns the type of the value in the given cell.
839
840 By default all cells are strings and this method returns
841 @c wxGRID_VALUE_STRING.
842 */
843 virtual wxString GetTypeName(int row, int col);
844
845 /**
846 Returns true if the value of the given cell can be accessed as if it
847 were of the specified type.
848
849 By default the cells can only be accessed as strings. Note that a cell
850 could be accessible in different ways, e.g. a numeric cell may return
851 @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING
852 indicating that the value can be coerced to a string form.
853 */
854 virtual bool CanGetValueAs(int row, int col, const wxString& typeName);
855
856 /**
857 Returns true if the value of the given cell can be set as if it were of
858 the specified type.
859
860 @see CanGetValueAs()
861 */
862 virtual bool CanSetValueAs(int row, int col, const wxString& typeName);
863
864 /**
865 Returns the value of the given cell as a long.
866
867 This should only be called if CanGetValueAs() returns @true when called
868 with @c wxGRID_VALUE_NUMBER argument. Default implementation always
869 return 0.
870 */
871 virtual long GetValueAsLong(int row, int col);
872
873 /**
874 Returns the value of the given cell as a double.
875
876 This should only be called if CanGetValueAs() returns @true when called
877 with @c wxGRID_VALUE_FLOAT argument. Default implementation always
878 return 0.0.
879 */
880 virtual double GetValueAsDouble(int row, int col);
881
882 /**
883 Returns the value of the given cell as a boolean.
884
885 This should only be called if CanGetValueAs() returns @true when called
886 with @c wxGRID_VALUE_BOOL argument. Default implementation always
887 return false.
888 */
889 virtual bool GetValueAsBool(int row, int col);
890
891 /**
892 Returns the value of the given cell as a user-defined type.
893
894 This should only be called if CanGetValueAs() returns @true when called
895 with @a typeName. Default implementation always return @NULL.
896 */
897 virtual void *GetValueAsCustom(int row, int col, const wxString& typeName);
898
899 /**
900 Sets the value of the given cell as a long.
901
902 This should only be called if CanSetValueAs() returns @true when called
903 with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do
904 anything.
905 */
906 virtual void SetValueAsLong(int row, int col, long value);
907
908 /**
909 Sets the value of the given cell as a double.
910
911 This should only be called if CanSetValueAs() returns @true when called
912 with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do
913 anything.
914 */
915 virtual void SetValueAsDouble(int row, int col, double value);
916
917 /**
918 Sets the value of the given cell as a boolean.
919
920 This should only be called if CanSetValueAs() returns @true when called
921 with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do
922 anything.
923 */
924 virtual void SetValueAsBool( int row, int col, bool value );
925
926 /**
927 Sets the value of the given cell as a user-defined type.
928
929 This should only be called if CanSetValueAs() returns @true when called
930 with @a typeName. Default implementation doesn't do anything.
931 */
932 virtual void SetValueAsCustom(int row, int col, const wxString& typeName,
933 void *value);
934
935 //@}
936
937
938 /**
939 Called by the grid when the table is associated with it.
940
941 The default implementation stores the pointer and returns it from its
942 GetView() and so only makes sense if the table cannot be associated
943 with more than one grid at a time.
944 */
945 virtual void SetView(wxGrid *grid);
946
947 /**
948 Returns the last grid passed to SetView().
949 */
950 virtual wxGrid *GetView() const;
951
952
953 /**
954 @name Table Structure Modifiers
955
956 Notice that none of these functions are pure virtual as they don't have
957 to be implemented if the table structure is never modified after
958 creation, i.e. neither rows nor columns are never added or deleted but
959 that you do need to implement them if they are called, i.e. if your
960 code either calls them directly or uses the matching wxGrid methods, as
961 by default they simply do nothing which is definitely inappropriate.
962 */
963 //@{
964
965 /**
966 Clear the table contents.
967
968 This method is used by wxGrid::ClearGrid().
969 */
970 virtual void Clear();
971
972 /**
973 Insert additional rows into the table.
974
975 @param pos
976 The position of the first new row.
977 @param numRows
978 The number of rows to insert.
979 */
980 virtual bool InsertRows(size_t pos = 0, size_t numRows = 1);
981
982 /**
983 Append additional rows at the end of the table.
984
985 This method is provided in addition to InsertRows() as some data models
986 may only support appending rows to them but not inserting them at
987 arbitrary locations. In such case you may implement this method only
988 and leave InsertRows() unimplemented.
989
990 @param numRows
991 The number of rows to add.
992 */
993 virtual bool AppendRows(size_t numRows = 1);
994
995 /**
996 Delete rows from the table.
997
998 @param pos
999 The first row to delete.
1000 @param numRows
1001 The number of rows to delete.
1002 */
1003 virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1);
1004
1005 /**
1006 Exactly the same as InsertRows() but for columns.
1007 */
1008 virtual bool InsertCols(size_t pos = 0, size_t numCols = 1);
1009
1010 /**
1011 Exactly the same as AppendRows() but for columns.
1012 */
1013 virtual bool AppendCols(size_t numCols = 1);
1014
1015 /**
1016 Exactly the same as DeleteRows() but for columns.
1017 */
1018 virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1);
1019
1020 //@}
1021
1022 /**
1023 @name Table Row and Column Labels
1024
1025 By default the numbers are used for labeling rows and Latin letters for
1026 labeling columns. If the table has more than 26 columns, the pairs of
1027 letters are used starting from the 27-th one and so on, i.e. the
1028 sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ,
1029 AAA, ...
1030 */
1031 //@{
1032
1033 /**
1034 Return the label of the specified row.
1035 */
1036 virtual wxString GetRowLabelValue(int row);
1037
1038 /**
1039 Return the label of the specified column.
1040 */
1041 virtual wxString GetColLabelValue(int col);
1042
1043 /**
1044 Set the given label for the specified row.
1045
1046 The default version does nothing, i.e. the label is not stored. You
1047 must override this method in your derived class if you wish
1048 wxGrid::SetRowLabelValue() to work.
1049 */
1050 virtual void SetRowLabelValue(int row, const wxString& label);
1051
1052 /**
1053 Exactly the same as SetRowLabelValue() but for columns.
1054 */
1055 virtual void SetColLabelValue(int col, const wxString& label);
1056
1057 //@}
1058
1059
1060 /**
1061 @name Attributes Management
1062
1063 By default the attributes management is delegated to
1064 wxGridCellAttrProvider class. You may override the methods in this
1065 section to handle the attributes directly if, for example, they can be
1066 computed from the cell values.
1067 */
1068 //@{
1069
1070 /**
1071 Associate this attributes provider with the table.
1072
1073 The table takes ownership of @a attrProvider pointer and will delete it
1074 when it doesn't need it any more. The pointer can be @NULL, however
1075 this won't disable attributes management in the table but will just
1076 result in a default attributes being recreated the next time any of the
1077 other functions in this section is called. To completely disable the
1078 attributes support, should this be needed, you need to override
1079 CanHaveAttributes() to return @false.
1080 */
1081 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
1082
1083 /**
1084 Returns the attribute provider currently being used.
1085
1086 This function may return @NULL if the attribute provider hasn't been
1087 neither associated with this table by SetAttrProvider() nor created on
1088 demand by any other methods.
1089 */
1090 wxGridCellAttrProvider *GetAttrProvider() const;
1091
1092 /**
1093 Return the attribute for the given cell.
1094
1095 By default this function is simply forwarded to
1096 wxGridCellAttrProvider::GetAttr() but it may be overridden to handle
1097 attributes directly in the table.
1098 */
1099 virtual wxGridCellAttr *GetAttr(int row, int col,
1100 wxGridCellAttr::wxAttrKind kind);
1101
1102 /**
1103 Set attribute of the specified cell.
1104
1105 By default this function is simply forwarded to
1106 wxGridCellAttrProvider::SetAttr().
1107
1108 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1109 */
1110 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
1111
1112 /**
1113 Set attribute of the specified row.
1114
1115 By default this function is simply forwarded to
1116 wxGridCellAttrProvider::SetRowAttr().
1117
1118 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1119 */
1120 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
1121
1122 /**
1123 Set attribute of the specified column.
1124
1125 By default this function is simply forwarded to
1126 wxGridCellAttrProvider::SetColAttr().
1127
1128 The table takes ownership of @a attr, i.e. will call DecRef() on it.
1129 */
1130 virtual void SetColAttr(wxGridCellAttr *attr, int col);
1131
1132 //@}
1133
1134 /**
1135 Returns true if this table supports attributes or false otherwise.
1136
1137 By default, the table automatically creates a wxGridCellAttrProvider
1138 when this function is called if it had no attribute provider before and
1139 returns @true.
1140 */
1141 virtual bool CanHaveAttributes();
1142 };
1143
1144 /**
1145 @class wxGridSizesInfo
1146
1147 wxGridSizesInfo stores information about sizes of all wxGrid rows or
1148 columns.
1149
1150 It assumes that most of the rows or columns (which are both called elements
1151 here as the difference between them doesn't matter at this class level)
1152 have the default size and so stores it separately. And it uses a wxHashMap
1153 to store the sizes of all elements which have the non-default size.
1154
1155 This structure is particularly useful for serializing the sizes of all
1156 wxGrid elements at once.
1157
1158 @library{wxadv}
1159 @category{grid}
1160 */
1161 struct wxGridSizesInfo
1162 {
1163 /**
1164 Default constructor.
1165
1166 m_sizeDefault and m_customSizes must be initialized later.
1167 */
1168 wxGridSizesInfo();
1169
1170 /**
1171 Constructor.
1172
1173 This constructor is used by wxGrid::GetRowSizes() and GetColSizes()
1174 methods. User code will usually use the default constructor instead.
1175
1176 @param defSize
1177 The default element size.
1178 @param allSizes
1179 Array containing the sizes of @em all elements, including those
1180 which have the default size.
1181 */
1182 wxGridSizesInfo(int defSize, const wxArrayInt& allSizes);
1183
1184 /**
1185 Get the element size.
1186
1187 @param pos
1188 The index of the element.
1189 @return
1190 The size for this element, using m_customSizes if @a pos is in it
1191 or m_sizeDefault otherwise.
1192 */
1193 int GetSize(unsigned pos) const;
1194
1195
1196 /// Default size
1197 int m_sizeDefault;
1198
1199 /**
1200 Map with element indices as keys and their sizes as values.
1201
1202 This map only contains the elements with non-default size.
1203 */
1204 wxUnsignedToIntHashMap m_customSizes;
1205 };
1206
1207
1208 /**
1209 @class wxGrid
1210
1211 wxGrid and its related classes are used for displaying and editing tabular
1212 data. They provide a rich set of features for display, editing, and
1213 interacting with a variety of data sources. For simple applications, and to
1214 help you get started, wxGrid is the only class you need to refer to
1215 directly. It will set up default instances of the other classes and manage
1216 them for you. For more complex applications you can derive your own classes
1217 for custom grid views, grid data tables, cell editors and renderers. The
1218 @ref overview_grid has examples of simple and more complex applications,
1219 explains the relationship between the various grid classes and has a
1220 summary of the keyboard shortcuts and mouse functions provided by wxGrid.
1221
1222 A wxGridTableBase class holds the actual data to be displayed by a wxGrid
1223 class. One or more wxGrid classes may act as a view for one table class.
1224 The default table class is called wxGridStringTable and holds an array of
1225 strings. An instance of such a class is created by CreateGrid().
1226
1227 wxGridCellRenderer is the abstract base class for rendereing contents in a
1228 cell. The following renderers are predefined:
1229
1230 - wxGridCellBoolRenderer
1231 - wxGridCellFloatRenderer
1232 - wxGridCellNumberRenderer
1233 - wxGridCellStringRenderer
1234
1235 The look of a cell can be further defined using wxGridCellAttr. An object
1236 of this type may be returned by wxGridTableBase::GetAttr().
1237
1238 wxGridCellEditor is the abstract base class for editing the value of a
1239 cell. The following editors are predefined:
1240
1241 - wxGridCellBoolEditor
1242 - wxGridCellChoiceEditor
1243 - wxGridCellFloatEditor
1244 - wxGridCellNumberEditor
1245 - wxGridCellTextEditor
1246
1247 Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and
1248 wxGridEditorCreatedEvent for the documentation of all event types you can
1249 use with wxGrid.
1250
1251 @library{wxadv}
1252 @category{grid}
1253
1254 @see @ref overview_grid, wxGridUpdateLocker
1255 */
1256 class wxGrid : public wxScrolledWindow
1257 {
1258 public:
1259
1260 /**
1261 Different selection modes supported by the grid.
1262 */
1263 enum wxGridSelectionModes
1264 {
1265 /**
1266 The default selection mode allowing selection of the individual
1267 cells as well as of the entire rows and columns.
1268 */
1269 wxGridSelectCells,
1270
1271 /**
1272 The selection mode allowing the selection of the entire rows only.
1273
1274 The user won't be able to select any cells or columns in this mode.
1275 */
1276 wxGridSelectRows,
1277
1278 /**
1279 The selection mode allowing the selection of the entire columns only.
1280
1281 The user won't be able to select any cells or rows in this mode.
1282 */
1283 wxGridSelectColumns
1284 };
1285
1286
1287 /**
1288 @name Constructors and Initialization
1289 */
1290 //@{
1291
1292 /**
1293 Default constructor.
1294
1295 You must call Create() to really create the grid window and also call
1296 CreateGrid() or SetTable() to initialize the grid contents.
1297 */
1298 wxGrid();
1299 /**
1300 Constructor creating the grid window.
1301
1302 You must call either CreateGrid() or SetTable() to initialize the grid
1303 contents before using it.
1304 */
1305 wxGrid(wxWindow* parent, wxWindowID id,
1306 const wxPoint& pos = wxDefaultPosition,
1307 const wxSize& size = wxDefaultSize,
1308 long style = wxWANTS_CHARS,
1309 const wxString& name = wxGridNameStr);
1310
1311 /**
1312 Destructor.
1313
1314 This will also destroy the associated grid table unless you passed a
1315 table object to the grid and specified that the grid should not take
1316 ownership of the table (see SetTable()).
1317 */
1318 virtual ~wxGrid();
1319
1320 /**
1321 Creates the grid window for an object initialized using the default
1322 constructor.
1323
1324 You must call either CreateGrid() or SetTable() to initialize the grid
1325 contents before using it.
1326 */
1327 bool Create(wxWindow* parent, wxWindowID id,
1328 const wxPoint& pos = wxDefaultPosition,
1329 const wxSize& size = wxDefaultSize,
1330 long style = wxWANTS_CHARS,
1331 const wxString& name = wxGridNameStr);
1332
1333 /**
1334 Creates a grid with the specified initial number of rows and columns.
1335
1336 Call this directly after the grid constructor. When you use this
1337 function wxGrid will create and manage a simple table of string values
1338 for you. All of the grid data will be stored in memory.
1339
1340 For applications with more complex data types or relationships, or for
1341 dealing with very large datasets, you should derive your own grid table
1342 class and pass a table object to the grid with SetTable().
1343 */
1344 bool CreateGrid(int numRows, int numCols,
1345 wxGridSelectionModes selmode = wxGridSelectCells);
1346
1347 /**
1348 Passes a pointer to a custom grid table to be used by the grid.
1349
1350 This should be called after the grid constructor and before using the
1351 grid object. If @a takeOwnership is set to @true then the table will be
1352 deleted by the wxGrid destructor.
1353
1354 Use this function instead of CreateGrid() when your application
1355 involves complex or non-string data or data sets that are too large to
1356 fit wholly in memory.
1357 */
1358 bool SetTable(wxGridTableBase* table, bool takeOwnership = false,
1359 wxGridSelectionModes selmode = wxGridSelectCells);
1360
1361 //@}
1362
1363
1364 /**
1365 @name Grid Line Formatting
1366 */
1367 //@{
1368
1369 /**
1370 Turns the drawing of grid lines on or off.
1371 */
1372 void EnableGridLines(bool enable = true);
1373
1374 /**
1375 Returns the pen used for vertical grid lines.
1376
1377 This virtual function may be overridden in derived classes in order to
1378 change the appearance of individual grid lines for the given column
1379 @a col.
1380
1381 See GetRowGridLinePen() for an example.
1382 */
1383 virtual wxPen GetColGridLinePen(int col);
1384
1385 /**
1386 Returns the pen used for grid lines.
1387
1388 This virtual function may be overridden in derived classes in order to
1389 change the appearance of grid lines. Note that currently the pen width
1390 must be 1.
1391
1392 @see GetColGridLinePen(), GetRowGridLinePen()
1393 */
1394 virtual wxPen GetDefaultGridLinePen();
1395
1396 /**
1397 Returns the colour used for grid lines.
1398
1399 @see GetDefaultGridLinePen()
1400 */
1401 wxColour GetGridLineColour() const;
1402
1403 /**
1404 Returns the pen used for horizontal grid lines.
1405
1406 This virtual function may be overridden in derived classes in order to
1407 change the appearance of individual grid line for the given @a row.
1408
1409 Example:
1410 @code
1411 // in a grid displaying music notation, use a solid black pen between
1412 // octaves (C0=row 127, C1=row 115 etc.)
1413 wxPen MidiGrid::GetRowGridLinePen(int row)
1414 {
1415 if ( row % 12 == 7 )
1416 return wxPen(*wxBLACK, 1, wxSOLID);
1417 else
1418 return GetDefaultGridLinePen();
1419 }
1420 @endcode
1421 */
1422 virtual wxPen GetRowGridLinePen(int row);
1423
1424 /**
1425 Returns @true if drawing of grid lines is turned on, @false otherwise.
1426 */
1427 bool GridLinesEnabled() const;
1428
1429 /**
1430 Sets the colour used to draw grid lines.
1431 */
1432 void SetGridLineColour(const wxColour& colour);
1433
1434 //@}
1435
1436
1437 /**
1438 @name Label Values and Formatting
1439 */
1440 //@{
1441
1442 /**
1443 Sets the arguments to the current column label alignment values.
1444
1445 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1446 or @c wxALIGN_RIGHT.
1447
1448 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1449 @c wxALIGN_BOTTOM.
1450 */
1451 void GetColLabelAlignment(int* horiz, int* vert) const;
1452
1453 /**
1454 Returns the orientation of the column labels (either @c wxHORIZONTAL or
1455 @c wxVERTICAL).
1456 */
1457 int GetColLabelTextOrientation() const;
1458
1459 /**
1460 Returns the specified column label.
1461
1462 The default grid table class provides column labels of the form
1463 A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can
1464 override wxGridTableBase::GetColLabelValue() to provide your own
1465 labels.
1466 */
1467 wxString GetColLabelValue(int col) const;
1468
1469 /**
1470 Returns the colour used for the background of row and column labels.
1471 */
1472 wxColour GetLabelBackgroundColour() const;
1473
1474 /**
1475 Returns the font used for row and column labels.
1476 */
1477 wxFont GetLabelFont() const;
1478
1479 /**
1480 Returns the colour used for row and column label text.
1481 */
1482 wxColour GetLabelTextColour() const;
1483
1484 /**
1485 Returns the alignment used for row labels.
1486
1487 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1488 or @c wxALIGN_RIGHT.
1489
1490 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1491 @c wxALIGN_BOTTOM.
1492 */
1493 void GetRowLabelAlignment(int* horiz, int* vert) const;
1494
1495 /**
1496 Returns the specified row label.
1497
1498 The default grid table class provides numeric row labels. If you are
1499 using a custom grid table you can override
1500 wxGridTableBase::GetRowLabelValue() to provide your own labels.
1501 */
1502 wxString GetRowLabelValue(int row) const;
1503
1504 /**
1505 Hides the column labels by calling SetColLabelSize() with a size of 0.
1506 Show labels again by calling that method with a width greater than 0.
1507 */
1508 void HideColLabels();
1509
1510 /**
1511 Hides the row labels by calling SetRowLabelSize() with a size of 0.
1512
1513 The labels can be shown again by calling SetRowLabelSize() with a width
1514 greater than 0.
1515 */
1516 void HideRowLabels();
1517
1518 /**
1519 Sets the horizontal and vertical alignment of column label text.
1520
1521 Horizontal alignment should be one of @c wxALIGN_LEFT,
1522 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
1523 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1524 */
1525 void SetColLabelAlignment(int horiz, int vert);
1526
1527 /**
1528 Sets the orientation of the column labels (either @c wxHORIZONTAL or
1529 @c wxVERTICAL).
1530 */
1531 void SetColLabelTextOrientation(int textOrientation);
1532
1533 /**
1534 Set the value for the given column label.
1535
1536 If you are using a custom grid table you must override
1537 wxGridTableBase::SetColLabelValue() for this to have any effect.
1538 */
1539 void SetColLabelValue(int col, const wxString& value);
1540
1541 /**
1542 Sets the background colour for row and column labels.
1543 */
1544 void SetLabelBackgroundColour(const wxColour& colour);
1545
1546 /**
1547 Sets the font for row and column labels.
1548 */
1549 void SetLabelFont(const wxFont& font);
1550
1551 /**
1552 Sets the colour for row and column label text.
1553 */
1554 void SetLabelTextColour(const wxColour& colour);
1555
1556 /**
1557 Sets the horizontal and vertical alignment of row label text.
1558
1559 Horizontal alignment should be one of @c wxALIGN_LEFT,
1560 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
1561 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1562 */
1563 void SetRowLabelAlignment(int horiz, int vert);
1564
1565 /**
1566 Sets the value for the given row label.
1567
1568 If you are using a derived grid table you must override
1569 wxGridTableBase::SetRowLabelValue() for this to have any effect.
1570 */
1571 void SetRowLabelValue(int row, const wxString& value);
1572
1573 /**
1574 Call this in order to make the column labels use a native look by using
1575 wxRendererNative::DrawHeaderButton() internally.
1576
1577 There is no equivalent method for drawing row columns as there is not
1578 native look for that. This option is useful when using wxGrid for
1579 displaying tables and not as a spread-sheet.
1580
1581 @see UseNativeColHeader()
1582 */
1583 void SetUseNativeColLabels(bool native = true);
1584
1585 /**
1586 Enable the use of native header window for column labels.
1587
1588 If this function is called with @true argument, a wxHeaderCtrl is used
1589 instead to display the column labels instead of drawing them in wxGrid
1590 code itself. This has the advantage of making the grid look and feel
1591 perfectly the same as native applications (using SetUseNativeColLabels()
1592 the grid can be made to look more natively but it still doesn't feel
1593 natively, notably the column resizing and dragging still works slightly
1594 differently as it is implemented in wxWidgets itself) but results in
1595 different behaviour for column and row headers, for which there is no
1596 equivalent function, and, most importantly, is unsuitable for grids
1597 with huge numbers of columns as wxHeaderCtrl doesn't support virtual
1598 mode. Because of this, by default the grid does not use the native
1599 header control but you should call this function to enable it if you
1600 are using the grid to display tabular data and don't have thousands of
1601 columns in it.
1602
1603 Also note that currently @c wxEVT_GRID_LABEL_LEFT_DCLICK and
1604 @c wxEVT_GRID_LABEL_RIGHT_DCLICK events are not generated for the column
1605 labels if the native columns header is used (but this limitation could
1606 possibly be lifted in the future).
1607 */
1608 void UseNativeColHeader(bool native = true);
1609
1610 //@}
1611
1612
1613 /**
1614 @name Cell Formatting
1615
1616 Note that wxGridCellAttr can be used alternatively to most of these
1617 methods. See the "Attributes Management" of wxGridTableBase.
1618 */
1619 //@{
1620
1621 /**
1622 Sets the arguments to the horizontal and vertical text alignment values
1623 for the grid cell at the specified location.
1624
1625 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1626 or @c wxALIGN_RIGHT.
1627
1628 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1629 @c wxALIGN_BOTTOM.
1630 */
1631 void GetCellAlignment(int row, int col, int* horiz, int* vert) const;
1632
1633 /**
1634 Returns the background colour of the cell at the specified location.
1635 */
1636 wxColour GetCellBackgroundColour(int row, int col) const;
1637
1638 /**
1639 Returns the font for text in the grid cell at the specified location.
1640 */
1641 wxFont GetCellFont(int row, int col) const;
1642
1643 /**
1644 Returns the text colour for the grid cell at the specified location.
1645 */
1646 wxColour GetCellTextColour(int row, int col) const;
1647
1648 /**
1649 Returns the default cell alignment.
1650
1651 Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE
1652 or @c wxALIGN_RIGHT.
1653
1654 Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or
1655 @c wxALIGN_BOTTOM.
1656
1657 @see SetDefaultCellAlignment()
1658 */
1659 void GetDefaultCellAlignment(int* horiz, int* vert) const;
1660
1661 /**
1662 Returns the current default background colour for grid cells.
1663 */
1664 wxColour GetDefaultCellBackgroundColour() const;
1665
1666 /**
1667 Returns the current default font for grid cell text.
1668 */
1669 wxFont GetDefaultCellFont() const;
1670
1671 /**
1672 Returns the current default colour for grid cell text.
1673 */
1674 wxColour GetDefaultCellTextColour() const;
1675
1676 /**
1677 Sets the horizontal and vertical alignment for grid cell text at the
1678 specified location.
1679
1680 Horizontal alignment should be one of @c wxALIGN_LEFT,
1681 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
1682
1683 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
1684 or @c wxALIGN_BOTTOM.
1685 */
1686 void SetCellAlignment(int row, int col, int horiz, int vert);
1687 /**
1688 Sets the horizontal and vertical alignment for grid cell text at the
1689 specified location.
1690
1691 Horizontal alignment should be one of @c wxALIGN_LEFT,
1692 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT.
1693
1694 Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE
1695 or @c wxALIGN_BOTTOM.
1696 */
1697 void SetCellAlignment(int align, int row, int col);
1698
1699 /**
1700 Set the background colour for the given cell or all cells by default.
1701 */
1702 void SetCellBackgroundColour(int row, int col, const wxColour& colour);
1703
1704 /**
1705 Sets the font for text in the grid cell at the specified location.
1706 */
1707 void SetCellFont(int row, int col, const wxFont& font);
1708
1709 /**
1710 Sets the text colour for the given cell.
1711 */
1712 void SetCellTextColour(int row, int col, const wxColour& colour);
1713 /**
1714 Sets the text colour for the given cell.
1715 */
1716 void SetCellTextColour(const wxColour& val, int row, int col);
1717 /**
1718 Sets the text colour for all cells by default.
1719 */
1720 void SetCellTextColour(const wxColour& colour);
1721
1722 /**
1723 Sets the default horizontal and vertical alignment for grid cell text.
1724
1725 Horizontal alignment should be one of @c wxALIGN_LEFT,
1726 @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one
1727 of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM.
1728 */
1729 void SetDefaultCellAlignment(int horiz, int vert);
1730
1731 /**
1732 Sets the default background colour for grid cells.
1733 */
1734 void SetDefaultCellBackgroundColour(const wxColour& colour);
1735
1736 /**
1737 Sets the default font to be used for grid cell text.
1738 */
1739 void SetDefaultCellFont(const wxFont& font);
1740
1741 /**
1742 Sets the current default colour for grid cell text.
1743 */
1744 void SetDefaultCellTextColour(const wxColour& colour);
1745
1746 //@}
1747
1748
1749 /**
1750 @name Cell Values, Editors, and Renderers
1751
1752 Note that wxGridCellAttr can be used alternatively to most of these
1753 methods. See the "Attributes Management" of wxGridTableBase.
1754 */
1755 //@{
1756
1757 /**
1758 Returns @true if the in-place edit control for the current grid cell
1759 can be used and @false otherwise.
1760
1761 This function always returns @false for the read-only cells.
1762 */
1763 bool CanEnableCellControl() const;
1764
1765 /**
1766 Disables in-place editing of grid cells.
1767
1768 Equivalent to calling EnableCellEditControl(@false).
1769 */
1770 void DisableCellEditControl();
1771
1772 /**
1773 Enables or disables in-place editing of grid cell data.
1774
1775 The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or
1776 @c wxEVT_GRID_EDITOR_HIDDEN event.
1777 */
1778 void EnableCellEditControl(bool enable = true);
1779
1780 /**
1781 Makes the grid globally editable or read-only.
1782
1783 If the edit argument is @false this function sets the whole grid as
1784 read-only. If the argument is @true the grid is set to the default
1785 state where cells may be editable. In the default state you can set
1786 single grid cells and whole rows and columns to be editable or
1787 read-only via wxGridCellAttr::SetReadOnly(). For single cells you
1788 can also use the shortcut function SetReadOnly().
1789
1790 For more information about controlling grid cell attributes see the
1791 wxGridCellAttr class and the @ref overview_grid.
1792 */
1793 void EnableEditing(bool edit);
1794
1795 /**
1796 Returns a pointer to the editor for the cell at the specified location.
1797
1798 See wxGridCellEditor and the @ref overview_grid for more information
1799 about cell editors and renderers.
1800
1801 The caller must call DecRef() on the returned pointer.
1802 */
1803 wxGridCellEditor* GetCellEditor(int row, int col) const;
1804
1805 /**
1806 Returns a pointer to the renderer for the grid cell at the specified
1807 location.
1808
1809 See wxGridCellRenderer and the @ref overview_grid for more information
1810 about cell editors and renderers.
1811
1812 The caller must call DecRef() on the returned pointer.
1813 */
1814 wxGridCellRenderer* GetCellRenderer(int row, int col) const;
1815
1816 /**
1817 Returns the string contained in the cell at the specified location.
1818
1819 For simple applications where a grid object automatically uses a
1820 default grid table of string values you use this function together with
1821 SetCellValue() to access cell values. For more complex applications
1822 where you have derived your own grid table class that contains various
1823 data types (e.g. numeric, boolean or user-defined custom types) then
1824 you only use this function for those cells that contain string values.
1825
1826 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
1827 more information.
1828 */
1829 wxString GetCellValue(int row, int col) const;
1830 /**
1831 Returns the string contained in the cell at the specified location.
1832
1833 For simple applications where a grid object automatically uses a
1834 default grid table of string values you use this function together with
1835 SetCellValue() to access cell values. For more complex applications
1836 where you have derived your own grid table class that contains various
1837 data types (e.g. numeric, boolean or user-defined custom types) then
1838 you only use this function for those cells that contain string values.
1839
1840 See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for
1841 more information.
1842 */
1843 wxString GetCellValue(const wxGridCellCoords& coords) const;
1844
1845 /**
1846 Returns a pointer to the current default grid cell editor.
1847
1848 See wxGridCellEditor and the @ref overview_grid for more information
1849 about cell editors and renderers.
1850 */
1851 wxGridCellEditor* GetDefaultEditor() const;
1852
1853 /**
1854 Returns the default editor for the specified cell.
1855
1856 The base class version returns the editor appropriate for the current
1857 cell type but this method may be overridden in the derived classes to
1858 use custom editors for some cells by default.
1859
1860 Notice that the same may be achieved in a usually simpler way by
1861 associating a custom editor with the given cell or cells.
1862
1863 The caller must call DecRef() on the returned pointer.
1864 */
1865 virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
1866 /**
1867 Returns the default editor for the specified cell.
1868
1869 The base class version returns the editor appropriate for the current
1870 cell type but this method may be overridden in the derived classes to
1871 use custom editors for some cells by default.
1872
1873 Notice that the same may be achieved in a usually simpler way by
1874 associating a custom editor with the given cell or cells.
1875
1876 The caller must call DecRef() on the returned pointer.
1877 */
1878 wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const;
1879
1880 /**
1881 Returns the default editor for the cells containing values of the given
1882 type.
1883
1884 The base class version returns the editor which was associated with the
1885 specified @a typeName when it was registered RegisterDataType() but
1886 this function may be overridden to return something different. This
1887 allows to override an editor used for one of the standard types.
1888
1889 The caller must call DecRef() on the returned pointer.
1890 */
1891 virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
1892
1893 /**
1894 Returns a pointer to the current default grid cell renderer.
1895
1896 See wxGridCellRenderer and the @ref overview_grid for more information
1897 about cell editors and renderers.
1898
1899 The caller must call DecRef() on the returned pointer.
1900 */
1901 wxGridCellRenderer* GetDefaultRenderer() const;
1902
1903 /**
1904 Returns the default renderer for the given cell.
1905
1906 The base class version returns the renderer appropriate for the current
1907 cell type but this method may be overridden in the derived classes to
1908 use custom renderers for some cells by default.
1909
1910 The caller must call DecRef() on the returned pointer.
1911 */
1912 virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
1913
1914 /**
1915 Returns the default renderer for the cell containing values of the
1916 given type.
1917
1918 @see GetDefaultEditorForType()
1919 */
1920 virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
1921
1922 /**
1923 Hides the in-place cell edit control.
1924 */
1925 void HideCellEditControl();
1926
1927 /**
1928 Returns @true if the in-place edit control is currently enabled.
1929 */
1930 bool IsCellEditControlEnabled() const;
1931
1932 /**
1933 Returns @true if the current cell is read-only.
1934
1935 @see SetReadOnly(), IsReadOnly()
1936 */
1937 bool IsCurrentCellReadOnly() const;
1938
1939 /**
1940 Returns @false if the whole grid has been set as read-only or @true
1941 otherwise.
1942
1943 See EnableEditing() for more information about controlling the editing
1944 status of grid cells.
1945 */
1946 bool IsEditable() const;
1947
1948 /**
1949 Returns @true if the cell at the specified location can't be edited.
1950
1951 @see SetReadOnly(), IsCurrentCellReadOnly()
1952 */
1953 bool IsReadOnly(int row, int col) const;
1954
1955 /**
1956 Register a new data type.
1957
1958 The data types allow to naturally associate specific renderers and
1959 editors to the cells containing values of the given type. For example,
1960 the grid automatically registers a data type with the name
1961 @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and
1962 wxGridCellTextEditor as its renderer and editor respectively -- this is
1963 the data type used by all the cells of the default wxGridStringTable,
1964 so this renderer and editor are used by default for all grid cells.
1965
1966 However if a custom table returns @c wxGRID_VALUE_BOOL from its
1967 wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and
1968 wxGridCellBoolEditor are used for it because the grid also registers a
1969 boolean data type with this name.
1970
1971 And as this mechanism is completely generic, you may register your own
1972 data types using your own custom renderers and editors. Just remember
1973 that the table must identify a cell as being of the given type for them
1974 to be used for this cell.
1975
1976 @param typeName
1977 Name of the new type. May be any string, but if the type name is
1978 the same as the name of an already registered type, including one
1979 of the standard ones (which are @c wxGRID_VALUE_STRING, @c
1980 wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT
1981 and @c wxGRID_VALUE_CHOICE), then the new registration information
1982 replaces the previously used renderer and editor.
1983 @param renderer
1984 The renderer to use for the cells of this type. Its ownership is
1985 taken by the grid, i.e. it will call DecRef() on this pointer when
1986 it doesn't need it any longer.
1987 @param editor
1988 The editor to use for the cells of this type. Its ownership is also
1989 taken by the grid.
1990 */
1991 void RegisterDataType(const wxString& typeName,
1992 wxGridCellRenderer* renderer,
1993 wxGridCellEditor* editor);
1994
1995 /**
1996 Sets the value of the current grid cell to the current in-place edit
1997 control value.
1998
1999 This is called automatically when the grid cursor moves from the
2000 current cell to a new cell. It is also a good idea to call this
2001 function when closing a grid since any edits to the final cell location
2002 will not be saved otherwise.
2003 */
2004 void SaveEditControlValue();
2005
2006 /**
2007 Sets the editor for the grid cell at the specified location.
2008
2009 The grid will take ownership of the pointer.
2010
2011 See wxGridCellEditor and the @ref overview_grid for more information
2012 about cell editors and renderers.
2013 */
2014 void SetCellEditor(int row, int col, wxGridCellEditor* editor);
2015
2016 /**
2017 Sets the renderer for the grid cell at the specified location.
2018
2019 The grid will take ownership of the pointer.
2020
2021 See wxGridCellRenderer and the @ref overview_grid for more information
2022 about cell editors and renderers.
2023 */
2024 void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer);
2025
2026 /**
2027 Sets the string value for the cell at the specified location.
2028
2029 For simple applications where a grid object automatically uses a
2030 default grid table of string values you use this function together with
2031 GetCellValue() to access cell values. For more complex applications
2032 where you have derived your own grid table class that contains various
2033 data types (e.g. numeric, boolean or user-defined custom types) then
2034 you only use this function for those cells that contain string values.
2035
2036 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2037 more information.
2038 */
2039 void SetCellValue(int row, int col, const wxString& s);
2040 /**
2041 Sets the string value for the cell at the specified location.
2042
2043 For simple applications where a grid object automatically uses a
2044 default grid table of string values you use this function together with
2045 GetCellValue() to access cell values. For more complex applications
2046 where you have derived your own grid table class that contains various
2047 data types (e.g. numeric, boolean or user-defined custom types) then
2048 you only use this function for those cells that contain string values.
2049
2050 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2051 more information.
2052 */
2053 void SetCellValue(const wxGridCellCoords& coords, const wxString& s);
2054 /**
2055 @deprecated Please use SetCellValue(int,int,const wxString&) or
2056 SetCellValue(const wxGridCellCoords&,const wxString&)
2057 instead.
2058
2059 Sets the string value for the cell at the specified location.
2060
2061 For simple applications where a grid object automatically uses a
2062 default grid table of string values you use this function together with
2063 GetCellValue() to access cell values. For more complex applications
2064 where you have derived your own grid table class that contains various
2065 data types (e.g. numeric, boolean or user-defined custom types) then
2066 you only use this function for those cells that contain string values.
2067
2068 See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for
2069 more information.
2070 */
2071 void SetCellValue(const wxString& val, int row, int col);
2072
2073 /**
2074 Sets the specified column to display boolean values.
2075
2076 @see SetColFormatCustom()
2077 */
2078 void SetColFormatBool(int col);
2079
2080 /**
2081 Sets the specified column to display data in a custom format.
2082
2083 This method provides an alternative to defining a custom grid table
2084 which would return @a typeName from its GetTypeName() method for the
2085 cells in this column: while it doesn't really change the type of the
2086 cells in this column, it does associate the renderer and editor used
2087 for the cells of the specified type with them.
2088
2089 See the @ref overview_grid for more information on working with custom
2090 data types.
2091 */
2092 void SetColFormatCustom(int col, const wxString& typeName);
2093
2094 /**
2095 Sets the specified column to display floating point values with the
2096 given width and precision.
2097
2098 @see SetColFormatCustom()
2099 */
2100 void SetColFormatFloat(int col, int width = -1, int precision = -1);
2101
2102 /**
2103 Sets the specified column to display integer values.
2104
2105 @see SetColFormatCustom()
2106 */
2107 void SetColFormatNumber(int col);
2108
2109 /**
2110 Sets the default editor for grid cells.
2111
2112 The grid will take ownership of the pointer.
2113
2114 See wxGridCellEditor and the @ref overview_grid for more information
2115 about cell editors and renderers.
2116 */
2117 void SetDefaultEditor(wxGridCellEditor* editor);
2118
2119 /**
2120 Sets the default renderer for grid cells.
2121
2122 The grid will take ownership of the pointer.
2123
2124 See wxGridCellRenderer and the @ref overview_grid for more information
2125 about cell editors and renderers.
2126 */
2127 void SetDefaultRenderer(wxGridCellRenderer* renderer);
2128
2129 /**
2130 Makes the cell at the specified location read-only or editable.
2131
2132 @see IsReadOnly()
2133 */
2134 void SetReadOnly(int row, int col, bool isReadOnly = true);
2135
2136 /**
2137 Displays the in-place cell edit control for the current cell.
2138 */
2139 void ShowCellEditControl();
2140
2141 //@}
2142
2143
2144 /**
2145 @name Column and Row Sizes
2146
2147 @see @ref overview_grid_resizing
2148 */
2149 //@{
2150
2151 /**
2152 Automatically sets the height and width of all rows and columns to fit
2153 their contents.
2154 */
2155 void AutoSize();
2156
2157 /**
2158 Automatically adjusts width of the column to fit its label.
2159 */
2160 void AutoSizeColLabelSize(int col);
2161
2162 /**
2163 Automatically sizes the column to fit its contents. If @a setAsMin is
2164 @true the calculated width will also be set as the minimal width for
2165 the column.
2166 */
2167 void AutoSizeColumn(int col, bool setAsMin = true);
2168
2169 /**
2170 Automatically sizes all columns to fit their contents. If @a setAsMin
2171 is @true the calculated widths will also be set as the minimal widths
2172 for the columns.
2173 */
2174 void AutoSizeColumns(bool setAsMin = true);
2175
2176 /**
2177 Automatically sizes the row to fit its contents. If @a setAsMin is
2178 @true the calculated height will also be set as the minimal height for
2179 the row.
2180 */
2181 void AutoSizeRow(int row, bool setAsMin = true);
2182
2183 /**
2184 Automatically adjusts height of the row to fit its label.
2185 */
2186 void AutoSizeRowLabelSize(int col);
2187
2188 /**
2189 Automatically sizes all rows to fit their contents. If @a setAsMin is
2190 @true the calculated heights will also be set as the minimal heights
2191 for the rows.
2192 */
2193 void AutoSizeRows(bool setAsMin = true);
2194
2195 /**
2196 Returns the current height of the column labels.
2197 */
2198 int GetColLabelSize() const;
2199
2200 /**
2201 Returns the minimal width to which a column may be resized.
2202
2203 Use SetColMinimalAcceptableWidth() to change this value globally or
2204 SetColMinimalWidth() to do it for individual columns.
2205
2206 @see GetRowMinimalAcceptableHeight()
2207 */
2208 int GetColMinimalAcceptableWidth() const;
2209
2210 /**
2211 Returns the width of the specified column.
2212 */
2213 int GetColSize(int col) const;
2214
2215 /**
2216 Returns @true if the specified column is not currently hidden.
2217 */
2218 bool IsColShown(int col) const;
2219
2220 /**
2221 Returns the default height for column labels.
2222 */
2223 int GetDefaultColLabelSize() const;
2224
2225 /**
2226 Returns the current default width for grid columns.
2227 */
2228 int GetDefaultColSize() const;
2229
2230 /**
2231 Returns the default width for the row labels.
2232 */
2233 int GetDefaultRowLabelSize() const;
2234
2235 /**
2236 Returns the current default height for grid rows.
2237 */
2238 int GetDefaultRowSize() const;
2239
2240 /**
2241 Returns the minimal size to which rows can be resized.
2242
2243 Use SetRowMinimalAcceptableHeight() to change this value globally or
2244 SetRowMinimalHeight() to do it for individual cells.
2245
2246 @see GetColMinimalAcceptableWidth()
2247 */
2248 int GetRowMinimalAcceptableHeight() const;
2249
2250 /**
2251 Returns the current width of the row labels.
2252 */
2253 int GetRowLabelSize() const;
2254
2255 /**
2256 Returns the height of the specified row.
2257 */
2258 int GetRowSize(int row) const;
2259
2260 /**
2261 Returns @true if the specified row is not currently hidden.
2262 */
2263 bool IsRowShown(int row) const;
2264
2265 /**
2266 Sets the height of the column labels.
2267
2268 If @a height equals to @c wxGRID_AUTOSIZE then height is calculated
2269 automatically so that no label is truncated. Note that this could be
2270 slow for a large table.
2271 */
2272 void SetColLabelSize(int height);
2273
2274 /**
2275 Sets the minimal @a width to which the user can resize columns.
2276
2277 @see GetColMinimalAcceptableWidth()
2278 */
2279 void SetColMinimalAcceptableWidth(int width);
2280
2281 /**
2282 Sets the minimal @a width for the specified column @a col.
2283
2284 It is usually best to call this method during grid creation as calling
2285 it later will not resize the column to the given minimal width even if
2286 it is currently narrower than it.
2287
2288 @a width must be greater than the minimal acceptable column width as
2289 returned by GetColMinimalAcceptableWidth().
2290 */
2291 void SetColMinimalWidth(int col, int width);
2292
2293 /**
2294 Sets the width of the specified column.
2295
2296 @param col
2297 The column index.
2298 @param width
2299 The new column width in pixels, 0 to hide the column or -1 to fit
2300 the column width to its label width.
2301 */
2302 void SetColSize(int col, int width);
2303
2304 /**
2305 Hides the specified column.
2306
2307 To show the column later you need to call SetColSize() with non-0
2308 width or ShowCol().
2309
2310 @param col
2311 The column index.
2312 */
2313 void HideCol(int col);
2314
2315 /**
2316 Shows the previously hidden column by resizing it to non-0 size.
2317
2318 @see HideCol(), SetColSize()
2319 */
2320 void ShowCol(int col);
2321
2322
2323 /**
2324 Sets the default width for columns in the grid.
2325
2326 This will only affect columns subsequently added to the grid unless
2327 @a resizeExistingCols is @true.
2328
2329 If @a width is less than GetColMinimalAcceptableWidth(), then the
2330 minimal acceptable width is used instead of it.
2331 */
2332 void SetDefaultColSize(int width, bool resizeExistingCols = false);
2333
2334 /**
2335 Sets the default height for rows in the grid.
2336
2337 This will only affect rows subsequently added to the grid unless
2338 @a resizeExistingRows is @true.
2339
2340 If @a height is less than GetRowMinimalAcceptableHeight(), then the
2341 minimal acceptable heihgt is used instead of it.
2342 */
2343 void SetDefaultRowSize(int height, bool resizeExistingRows = false);
2344
2345 /**
2346 Sets the width of the row labels.
2347
2348 If @a width equals @c wxGRID_AUTOSIZE then width is calculated
2349 automatically so that no label is truncated. Note that this could be
2350 slow for a large table.
2351 */
2352 void SetRowLabelSize(int width);
2353
2354 /**
2355 Sets the minimal row @a height used by default.
2356
2357 See SetColMinimalAcceptableWidth() for more information.
2358 */
2359 void SetRowMinimalAcceptableHeight(int height);
2360
2361 /**
2362 Sets the minimal @a height for the specified @a row.
2363
2364 See SetColMinimalWidth() for more information.
2365 */
2366 void SetRowMinimalHeight(int row, int height);
2367
2368 /**
2369 Sets the height of the specified row.
2370
2371 See SetColSize() for more information.
2372 */
2373 void SetRowSize(int row, int height);
2374
2375 /**
2376 Hides the specified row.
2377
2378 To show the row later you need to call SetRowSize() with non-0
2379 width or ShowRow().
2380
2381 @param col
2382 The row index.
2383 */
2384 void HideRow(int col);
2385
2386 /**
2387 Shows the previously hidden row by resizing it to non-0 size.
2388
2389 @see HideRow(), SetRowSize()
2390 */
2391 void ShowRow(int col);
2392
2393 /**
2394 Get size information for all columns at once.
2395
2396 This method is useful when the information about all column widths
2397 needs to be saved. The widths can be later restored using
2398 SetColSizes().
2399
2400 @sa wxGridSizesInfo, GetRowSizes()
2401 */
2402 wxGridSizesInfo GetColSizes() const;
2403
2404 /**
2405 Get size information for all row at once.
2406
2407 @sa wxGridSizesInfo, GetColSizes()
2408 */
2409 wxGridSizesInfo GetRowSizes() const;
2410
2411 /**
2412 Restore all columns sizes.
2413
2414 This is usually called with wxGridSizesInfo object previously returned
2415 by GetColSizes().
2416
2417 @sa SetRowSizes()
2418 */
2419 void SetColSizes(const wxGridSizesInfo& sizeInfo);
2420
2421 /**
2422 Restore all rows sizes.
2423
2424 @sa SetColSizes()
2425 */
2426 void SetRowSizes(const wxGridSizesInfo& sizeInfo);
2427
2428 //@}
2429
2430
2431 /**
2432 @name User-Resizing and Dragging
2433
2434 Functions controlling various interactive mouse operations.
2435
2436 By default, columns and rows can be resized by dragging the edges of
2437 their labels (this can be disabled using DisableDragColSize() and
2438 DisableDragRowSize() methods). And if grid line dragging is enabled with
2439 EnableDragGridSize() they can also be resized by dragging the right or
2440 bottom edge of the grid cells.
2441
2442 Columns can also be moved to interactively change their order but this
2443 needs to be explicitly enabled with EnableDragColMove().
2444 */
2445 //@{
2446
2447 /**
2448 Return @true if the dragging of cells is enabled or @false otherwise.
2449 */
2450 bool CanDragCell() const;
2451
2452 /**
2453 Returns @true if columns can be moved by dragging with the mouse.
2454
2455 Columns can be moved by dragging on their labels.
2456 */
2457 bool CanDragColMove() const;
2458
2459 /**
2460 Returns @true if the given column can be resized by dragging with the
2461 mouse.
2462
2463 This function returns @true if resizing the columns interactively is
2464 globally enabled, i.e. if DisableDragColSize() hadn't been called, and
2465 if this column wasn't explicitly marked as non-resizable with
2466 DisableColResize().
2467 */
2468 bool CanDragColSize(int col) const;
2469
2470 /**
2471 Return @true if the dragging of grid lines to resize rows and columns
2472 is enabled or @false otherwise.
2473 */
2474 bool CanDragGridSize() const;
2475
2476 /**
2477 Returns @true if the given row can be resized by dragging with the
2478 mouse.
2479
2480 This is the same as CanDragColSize() but for rows.
2481 */
2482 bool CanDragRowSize(int row) const;
2483
2484 /**
2485 Disable interactive resizing of the specified column.
2486
2487 This method allows to disable resizing of an individual column in a
2488 grid where the columns are otherwise resizable (which is the case by
2489 default).
2490
2491 Notice that currently there is no way to make some columns resizable in
2492 a grid where columns can't be resized by default as there doesn't seem
2493 to be any need for this in practice. There is also no way to make the
2494 column marked as fixed using this method resizeable again because it is
2495 supposed that fixed columns are used for static parts of the grid and
2496 so should remain fixed during the entire grid lifetime.
2497
2498 Also notice that disabling interactive column resizing will not prevent
2499 the program from changing the column size.
2500
2501 @see EnableDragColSize()
2502 */
2503 void DisableColResize(int col);
2504
2505 /**
2506 Disable interactive resizing of the specified row.
2507
2508 This is the same as DisableColResize() but for rows.
2509
2510 @see EnableDragRowSize()
2511 */
2512 void DisableRowResize(int row);
2513
2514 /**
2515 Disables column moving by dragging with the mouse.
2516
2517 Equivalent to passing @false to EnableDragColMove().
2518 */
2519 void DisableDragColMove();
2520
2521 /**
2522 Disables column sizing by dragging with the mouse.
2523
2524 Equivalent to passing @false to EnableDragColSize().
2525 */
2526 void DisableDragColSize();
2527
2528 /**
2529 Disable mouse dragging of grid lines to resize rows and columns.
2530
2531 Equivalent to passing @false to EnableDragGridSize()
2532 */
2533 void DisableDragGridSize();
2534
2535 /**
2536 Disables row sizing by dragging with the mouse.
2537
2538 Equivalent to passing @false to EnableDragRowSize().
2539 */
2540 void DisableDragRowSize();
2541
2542 /**
2543 Enables or disables cell dragging with the mouse.
2544 */
2545 void EnableDragCell(bool enable = true);
2546
2547 /**
2548 Enables or disables column moving by dragging with the mouse.
2549 */
2550 void EnableDragColMove(bool enable = true);
2551
2552 /**
2553 Enables or disables column sizing by dragging with the mouse.
2554
2555 @see DisableColResize()
2556 */
2557 void EnableDragColSize(bool enable = true);
2558
2559 /**
2560 Enables or disables row and column resizing by dragging gridlines with
2561 the mouse.
2562 */
2563 void EnableDragGridSize(bool enable = true);
2564
2565 /**
2566 Enables or disables row sizing by dragging with the mouse.
2567
2568 @see DisableRowResize()
2569 */
2570 void EnableDragRowSize(bool enable = true);
2571
2572 /**
2573 Returns the column ID of the specified column position.
2574 */
2575 int GetColAt(int colPos) const;
2576
2577 /**
2578 Returns the position of the specified column.
2579 */
2580 int GetColPos(int colID) const;
2581
2582 /**
2583 Sets the position of the specified column.
2584 */
2585 void SetColPos(int colID, int newPos);
2586
2587 /**
2588 Sets the positions of all columns at once.
2589
2590 This method takes an array containing the indices of the columns in
2591 their display order, i.e. uses the same convention as
2592 wxHeaderCtrl::SetColumnsOrder().
2593 */
2594 void SetColumnsOrder(const wxArrayInt& order);
2595
2596 /**
2597 Resets the position of the columns to the default.
2598 */
2599 void ResetColPos();
2600
2601 //@}
2602
2603
2604 /**
2605 @name Cursor Movement
2606 */
2607 //@{
2608
2609 /**
2610 Returns the current grid cell column position.
2611 */
2612 int GetGridCursorCol() const;
2613
2614 /**
2615 Returns the current grid cell row position.
2616 */
2617 int GetGridCursorRow() const;
2618
2619 /**
2620 Make the given cell current and ensure it is visible.
2621
2622 This method is equivalent to calling MakeCellVisible() and
2623 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
2624 event is generated by it and the selected cell doesn't change if the
2625 event is vetoed.
2626 */
2627 void GoToCell(int row, int col);
2628 /**
2629 Make the given cell current and ensure it is visible.
2630
2631 This method is equivalent to calling MakeCellVisible() and
2632 SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL
2633 event is generated by it and the selected cell doesn't change if the
2634 event is vetoed.
2635 */
2636 void GoToCell(const wxGridCellCoords& coords);
2637
2638 /**
2639 Moves the grid cursor down by one row.
2640
2641 If a block of cells was previously selected it will expand if the
2642 argument is @true or be cleared if the argument is @false.
2643 */
2644 bool MoveCursorDown(bool expandSelection);
2645
2646 /**
2647 Moves the grid cursor down in the current column such that it skips to
2648 the beginning or end of a block of non-empty cells.
2649
2650 If a block of cells was previously selected it will expand if the
2651 argument is @true or be cleared if the argument is @false.
2652 */
2653 bool MoveCursorDownBlock(bool expandSelection);
2654
2655 /**
2656 Moves the grid cursor left by one column.
2657
2658 If a block of cells was previously selected it will expand if the
2659 argument is @true or be cleared if the argument is @false.
2660 */
2661 bool MoveCursorLeft(bool expandSelection);
2662
2663 /**
2664 Moves the grid cursor left in the current row such that it skips to the
2665 beginning or end of a block of non-empty cells.
2666
2667 If a block of cells was previously selected it will expand if the
2668 argument is @true or be cleared if the argument is @false.
2669 */
2670 bool MoveCursorLeftBlock(bool expandSelection);
2671
2672 /**
2673 Moves the grid cursor right by one column.
2674
2675 If a block of cells was previously selected it will expand if the
2676 argument is @true or be cleared if the argument is @false.
2677 */
2678 bool MoveCursorRight(bool expandSelection);
2679
2680 /**
2681 Moves the grid cursor right in the current row such that it skips to
2682 the beginning or end of a block of non-empty cells.
2683
2684 If a block of cells was previously selected it will expand if the
2685 argument is @true or be cleared if the argument is @false.
2686 */
2687 bool MoveCursorRightBlock(bool expandSelection);
2688
2689 /**
2690 Moves the grid cursor up by one row.
2691
2692 If a block of cells was previously selected it will expand if the
2693 argument is @true or be cleared if the argument is @false.
2694 */
2695 bool MoveCursorUp(bool expandSelection);
2696
2697 /**
2698 Moves the grid cursor up in the current column such that it skips to
2699 the beginning or end of a block of non-empty cells.
2700
2701 If a block of cells was previously selected it will expand if the
2702 argument is @true or be cleared if the argument is @false.
2703 */
2704 bool MoveCursorUpBlock(bool expandSelection);
2705
2706 /**
2707 Moves the grid cursor down by some number of rows so that the previous
2708 bottom visible row becomes the top visible row.
2709 */
2710 bool MovePageDown();
2711
2712 /**
2713 Moves the grid cursor up by some number of rows so that the previous
2714 top visible row becomes the bottom visible row.
2715 */
2716 bool MovePageUp();
2717
2718 /**
2719 Set the grid cursor to the specified cell.
2720
2721 The grid cursor indicates the current cell and can be moved by the user
2722 using the arrow keys or the mouse.
2723
2724 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
2725 if the event handler vetoes this event, the cursor is not moved.
2726
2727 This function doesn't make the target call visible, use GoToCell() to
2728 do this.
2729 */
2730 void SetGridCursor(int row, int col);
2731 /**
2732 Set the grid cursor to the specified cell.
2733
2734 The grid cursor indicates the current cell and can be moved by the user
2735 using the arrow keys or the mouse.
2736
2737 Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and
2738 if the event handler vetoes this event, the cursor is not moved.
2739
2740 This function doesn't make the target call visible, use GoToCell() to
2741 do this.
2742 */
2743 void SetGridCursor(const wxGridCellCoords& coords);
2744
2745 //@}
2746
2747
2748 /**
2749 @name User Selection
2750 */
2751 //@{
2752
2753 /**
2754 Deselects all cells that are currently selected.
2755 */
2756 void ClearSelection();
2757
2758 /**
2759 Returns an array of individually selected cells.
2760
2761 Notice that this array does @em not contain all the selected cells in
2762 general as it doesn't include the cells selected as part of column, row
2763 or block selection. You must use this method, GetSelectedCols(),
2764 GetSelectedRows() and GetSelectionBlockTopLeft() and
2765 GetSelectionBlockBottomRight() methods to obtain the entire selection
2766 in general.
2767
2768 Please notice this behaviour is by design and is needed in order to
2769 support grids of arbitrary size (when an entire column is selected in
2770 a grid with a million of columns, we don't want to create an array with
2771 a million of entries in this function, instead it returns an empty
2772 array and GetSelectedCols() returns an array containing one element).
2773 */
2774 wxGridCellCoordsArray GetSelectedCells() const;
2775
2776 /**
2777 Returns an array of selected columns.
2778
2779 Please notice that this method alone is not sufficient to find all the
2780 selected columns as it contains only the columns which were
2781 individually selected but not those being part of the block selection
2782 or being selected in virtue of all of their cells being selected
2783 individually, please see GetSelectedCells() for more details.
2784 */
2785 wxArrayInt GetSelectedCols() const;
2786
2787 /**
2788 Returns an array of selected rows.
2789
2790 Please notice that this method alone is not sufficient to find all the
2791 selected rows as it contains only the rows which were individually
2792 selected but not those being part of the block selection or being
2793 selected in virtue of all of their cells being selected individually,
2794 please see GetSelectedCells() for more details.
2795 */
2796 wxArrayInt GetSelectedRows() const;
2797
2798 /**
2799 Returns the colour used for drawing the selection background.
2800 */
2801 wxColour GetSelectionBackground() const;
2802
2803 /**
2804 Returns an array of the bottom right corners of blocks of selected
2805 cells.
2806
2807 Please see GetSelectedCells() for more information about the selection
2808 representation in wxGrid.
2809
2810 @see GetSelectionBlockTopLeft()
2811 */
2812 wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
2813
2814 /**
2815 Returns an array of the top left corners of blocks of selected cells.
2816
2817 Please see GetSelectedCells() for more information about the selection
2818 representation in wxGrid.
2819
2820 @see GetSelectionBlockBottomRight()
2821 */
2822 wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
2823
2824 /**
2825 Returns the colour used for drawing the selection foreground.
2826 */
2827 wxColour GetSelectionForeground() const;
2828
2829 /**
2830 Returns the current selection mode.
2831
2832 @see SetSelectionMode().
2833 */
2834 wxGridSelectionModes GetSelectionMode() const;
2835
2836 /**
2837 Returns @true if the given cell is selected.
2838 */
2839 bool IsInSelection(int row, int col) const;
2840 /**
2841 Returns @true if the given cell is selected.
2842 */
2843 bool IsInSelection(const wxGridCellCoords& coords) const;
2844
2845 /**
2846 Returns @true if there are currently any selected cells, rows, columns
2847 or blocks.
2848 */
2849 bool IsSelection() const;
2850
2851 /**
2852 Selects all cells in the grid.
2853 */
2854 void SelectAll();
2855
2856 /**
2857 Selects a rectangular block of cells.
2858
2859 If @a addToSelected is @false then any existing selection will be
2860 deselected; if @true the column will be added to the existing
2861 selection.
2862 */
2863 void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol,
2864 bool addToSelected = false);
2865 /**
2866 Selects a rectangular block of cells.
2867
2868 If @a addToSelected is @false then any existing selection will be
2869 deselected; if @true the column will be added to the existing
2870 selection.
2871 */
2872 void SelectBlock(const wxGridCellCoords& topLeft,
2873 const wxGridCellCoords& bottomRight,
2874 bool addToSelected = false);
2875
2876 /**
2877 Selects the specified column.
2878
2879 If @a addToSelected is @false then any existing selection will be
2880 deselected; if @true the column will be added to the existing
2881 selection.
2882
2883 This method won't select anything if the current selection mode is
2884 wxGridSelectRows.
2885 */
2886 void SelectCol(int col, bool addToSelected = false);
2887
2888 /**
2889 Selects the specified row.
2890
2891 If @a addToSelected is @false then any existing selection will be
2892 deselected; if @true the row will be added to the existing selection.
2893
2894 This method won't select anything if the current selection mode is
2895 wxGridSelectColumns.
2896 */
2897 void SelectRow(int row, bool addToSelected = false);
2898
2899 /**
2900 Set the colour to be used for drawing the selection background.
2901 */
2902 void SetSelectionBackground(const wxColour& c);
2903
2904 /**
2905 Set the colour to be used for drawing the selection foreground.
2906 */
2907 void SetSelectionForeground(const wxColour& c);
2908
2909 /**
2910 Set the selection behaviour of the grid.
2911
2912 The existing selection is converted to conform to the new mode if
2913 possible and discarded otherwise (e.g. any individual selected cells
2914 are deselected if the new mode allows only the selection of the entire
2915 rows or columns).
2916 */
2917 void SetSelectionMode(wxGridSelectionModes selmode);
2918
2919 //@}
2920
2921
2922 /**
2923 @name Scrolling
2924 */
2925 //@{
2926
2927 /**
2928 Returns the number of pixels per horizontal scroll increment.
2929
2930 The default is 15.
2931
2932 @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY()
2933 */
2934 int GetScrollLineX() const;
2935
2936 /**
2937 Returns the number of pixels per vertical scroll increment.
2938
2939 The default is 15.
2940
2941 @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY()
2942 */
2943 int GetScrollLineY() const;
2944
2945 /**
2946 Returns @true if a cell is either entirely or at least partially
2947 visible in the grid window.
2948
2949 By default, the cell must be entirely visible for this function to
2950 return @true but if @a wholeCellVisible is @false, the function returns
2951 @true even if the cell is only partially visible.
2952 */
2953 bool IsVisible(int row, int col, bool wholeCellVisible = true) const;
2954 /**
2955 Returns @true if a cell is either entirely or at least partially
2956 visible in the grid window.
2957
2958 By default, the cell must be entirely visible for this function to
2959 return @true but if @a wholeCellVisible is @false, the function returns
2960 @true even if the cell is only partially visible.
2961 */
2962 bool IsVisible(const wxGridCellCoords& coords,
2963 bool wholeCellVisible = true) const;
2964
2965 /**
2966 Brings the specified cell into the visible grid cell area with minimal
2967 scrolling.
2968
2969 Does nothing if the cell is already visible.
2970 */
2971 void MakeCellVisible(int row, int col);
2972 /**
2973 Brings the specified cell into the visible grid cell area with minimal
2974 scrolling.
2975
2976 Does nothing if the cell is already visible.
2977 */
2978 void MakeCellVisible(const wxGridCellCoords& coords);
2979
2980 /**
2981 Sets the number of pixels per horizontal scroll increment.
2982
2983 The default is 15.
2984
2985 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY()
2986 */
2987 void SetScrollLineX(int x);
2988
2989 /**
2990 Sets the number of pixels per vertical scroll increment.
2991
2992 The default is 15.
2993
2994 @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX()
2995 */
2996 void SetScrollLineY(int y);
2997
2998 //@}
2999
3000
3001 /**
3002 @name Cell and Device Coordinate Translation
3003 */
3004 //@{
3005
3006 /**
3007 Convert grid cell coordinates to grid window pixel coordinates.
3008
3009 This function returns the rectangle that encloses the block of cells
3010 limited by @a topLeft and @a bottomRight cell in device coords and
3011 clipped to the client size of the grid window.
3012
3013 @see CellToRect()
3014 */
3015 wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft,
3016 const wxGridCellCoords& bottomRight) const;
3017
3018 /**
3019 Return the rectangle corresponding to the grid cell's size and position
3020 in logical coordinates.
3021
3022 @see BlockToDeviceRect()
3023 */
3024 wxRect CellToRect(int row, int col) const;
3025 /**
3026 Return the rectangle corresponding to the grid cell's size and position
3027 in logical coordinates.
3028
3029 @see BlockToDeviceRect()
3030 */
3031 wxRect CellToRect(const wxGridCellCoords& coords) const;
3032
3033 /**
3034 Returns the column at the given pixel position.
3035
3036 @param x
3037 The x position to evaluate.
3038 @param clipToMinMax
3039 If @true, rather than returning @c wxNOT_FOUND, it returns either
3040 the first or last column depending on whether @a x is too far to
3041 the left or right respectively.
3042 @return
3043 The column index or @c wxNOT_FOUND.
3044 */
3045 int XToCol(int x, bool clipToMinMax = false) const;
3046
3047 /**
3048 Returns the column whose right hand edge is close to the given logical
3049 @a x position.
3050
3051 If no column edge is near to this position @c wxNOT_FOUND is returned.
3052 */
3053 int XToEdgeOfCol(int x) const;
3054
3055 /**
3056 Translates logical pixel coordinates to the grid cell coordinates.
3057
3058 Notice that this function expects logical coordinates on input so if
3059 you use this function in a mouse event handler you need to translate
3060 the mouse position, which is expressed in device coordinates, to
3061 logical ones.
3062
3063 @see XToCol(), YToRow()
3064 */
3065 wxGridCellCoords XYToCell(int x, int y) const;
3066 /**
3067 Translates logical pixel coordinates to the grid cell coordinates.
3068
3069 Notice that this function expects logical coordinates on input so if
3070 you use this function in a mouse event handler you need to translate
3071 the mouse position, which is expressed in device coordinates, to
3072 logical ones.
3073
3074 @see XToCol(), YToRow()
3075 */
3076 wxGridCellCoords XYToCell(const wxPoint& pos) const;
3077 // XYToCell(int, int, wxGridCellCoords&) overload is intentionally
3078 // undocumented, using it is ugly and non-const reference parameters are
3079 // not used in wxWidgets API
3080
3081 /**
3082 Returns the row whose bottom edge is close to the given logical @a y
3083 position.
3084
3085 If no row edge is near to this position @c wxNOT_FOUND is returned.
3086 */
3087 int YToEdgeOfRow(int y) const;
3088
3089 /**
3090 Returns the grid row that corresponds to the logical @a y coordinate.
3091
3092 Returns @c wxNOT_FOUND if there is no row at the @a y position.
3093 */
3094 int YToRow(int y, bool clipToMinMax = false) const;
3095
3096 //@}
3097
3098
3099 /**
3100 @name Miscellaneous Functions
3101 */
3102 //@{
3103
3104 /**
3105 Appends one or more new columns to the right of the grid.
3106
3107 The @a updateLabels argument is not used at present. If you are using a
3108 derived grid table class you will need to override
3109 wxGridTableBase::AppendCols(). See InsertCols() for further
3110 information.
3111
3112 @return @true on success or @false if appending columns failed.
3113 */
3114 bool AppendCols(int numCols = 1, bool updateLabels = true);
3115
3116 /**
3117 Appends one or more new rows to the bottom of the grid.
3118
3119 The @a updateLabels argument is not used at present. If you are using a
3120 derived grid table class you will need to override
3121 wxGridTableBase::AppendRows(). See InsertRows() for further
3122 information.
3123
3124 @return @true on success or @false if appending rows failed.
3125 */
3126 bool AppendRows(int numRows = 1, bool updateLabels = true);
3127
3128 /**
3129 Return @true if the horizontal grid lines stop at the last column
3130 boundary or @false if they continue to the end of the window.
3131
3132 The default is to clip grid lines.
3133
3134 @see ClipHorzGridLines(), AreVertGridLinesClipped()
3135 */
3136 bool AreHorzGridLinesClipped() const;
3137
3138 /**
3139 Return @true if the vertical grid lines stop at the last row
3140 boundary or @false if they continue to the end of the window.
3141
3142 The default is to clip grid lines.
3143
3144 @see ClipVertGridLines(), AreHorzGridLinesClipped()
3145 */
3146 bool AreVertGridLinesClipped() const;
3147
3148 /**
3149 Increments the grid's batch count.
3150
3151 When the count is greater than zero repainting of the grid is
3152 suppressed. Each call to BeginBatch must be matched by a later call to
3153 EndBatch(). Code that does a lot of grid modification can be enclosed
3154 between BeginBatch() and EndBatch() calls to avoid screen flicker. The
3155 final EndBatch() call will cause the grid to be repainted.
3156
3157 Notice that you should use wxGridUpdateLocker which ensures that there
3158 is always a matching EndBatch() call for this BeginBatch() if possible
3159 instead of calling this method directly.
3160 */
3161 void BeginBatch();
3162
3163 /**
3164 Clears all data in the underlying grid table and repaints the grid.
3165
3166 The table is not deleted by this function. If you are using a derived
3167 table class then you need to override wxGridTableBase::Clear() for this
3168 function to have any effect.
3169 */
3170 void ClearGrid();
3171
3172 /**
3173 Change whether the horizontal grid lines are clipped by the end of the
3174 last column.
3175
3176 By default the grid lines are not drawn beyond the end of the last
3177 column but after calling this function with @a clip set to @false they
3178 will be drawn across the entire grid window.
3179
3180 @see AreHorzGridLinesClipped(), ClipVertGridLines()
3181 */
3182 void ClipHorzGridLines(bool clip);
3183
3184 /**
3185 Change whether the vertical grid lines are clipped by the end of the
3186 last row.
3187
3188 By default the grid lines are not drawn beyond the end of the last
3189 row but after calling this function with @a clip set to @false they
3190 will be drawn across the entire grid window.
3191
3192 @see AreVertGridLinesClipped(), ClipHorzGridLines()
3193 */
3194 void ClipVertGridLines(bool clip);
3195
3196 /**
3197 Deletes one or more columns from a grid starting at the specified
3198 position.
3199
3200 The @a updateLabels argument is not used at present. If you are using a
3201 derived grid table class you will need to override
3202 wxGridTableBase::DeleteCols(). See InsertCols() for further
3203 information.
3204
3205 @return @true on success or @false if deleting columns failed.
3206 */
3207 bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true);
3208
3209 /**
3210 Deletes one or more rows from a grid starting at the specified
3211 position.
3212
3213 The @a updateLabels argument is not used at present. If you are using a
3214 derived grid table class you will need to override
3215 wxGridTableBase::DeleteRows(). See InsertRows() for further
3216 information.
3217
3218 @return @true on success or @false if appending rows failed.
3219 */
3220 bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true);
3221
3222 /**
3223 Decrements the grid's batch count.
3224
3225 When the count is greater than zero repainting of the grid is
3226 suppressed. Each previous call to BeginBatch() must be matched by a
3227 later call to EndBatch(). Code that does a lot of grid modification can
3228 be enclosed between BeginBatch() and EndBatch() calls to avoid screen
3229 flicker. The final EndBatch() will cause the grid to be repainted.
3230
3231 @see wxGridUpdateLocker
3232 */
3233 void EndBatch();
3234
3235 /**
3236 Overridden wxWindow method.
3237 */
3238 virtual void Fit();
3239
3240 /**
3241 Causes immediate repainting of the grid.
3242
3243 Use this instead of the usual wxWindow::Refresh().
3244 */
3245 void ForceRefresh();
3246
3247 /**
3248 Returns the number of times that BeginBatch() has been called without
3249 (yet) matching calls to EndBatch(). While the grid's batch count is
3250 greater than zero the display will not be updated.
3251 */
3252 int GetBatchCount();
3253
3254 /**
3255 Returns the total number of grid columns.
3256
3257 This is the same as the number of columns in the underlying grid table.
3258 */
3259 int GetNumberCols() const;
3260
3261 /**
3262 Returns the total number of grid rows.
3263
3264 This is the same as the number of rows in the underlying grid table.
3265 */
3266 int GetNumberRows() const;
3267
3268 /**
3269 Returns the attribute for the given cell creating one if necessary.
3270
3271 If the cell already has an attribute, it is returned. Otherwise a new
3272 attribute is created, associated with the cell and returned. In any
3273 case the caller must call DecRef() on the returned pointer.
3274
3275 This function may only be called if CanHaveAttributes() returns @true.
3276 */
3277 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
3278
3279 /**
3280 Returns a base pointer to the current table object.
3281
3282 The returned pointer is still owned by the grid.
3283 */
3284 wxGridTableBase *GetTable() const;
3285
3286 /**
3287 Inserts one or more new columns into a grid with the first new column
3288 at the specified position.
3289
3290 Notice that inserting the columns in the grid requires grid table
3291 cooperation: when this method is called, grid object begins by
3292 requesting the underlying grid table to insert new columns. If this is
3293 successful the table notifies the grid and the grid updates the
3294 display. For a default grid (one where you have called CreateGrid())
3295 this process is automatic. If you are using a custom grid table
3296 (specified with SetTable()) then you must override
3297 wxGridTableBase::InsertCols() in your derived table class.
3298
3299 @param pos
3300 The position which the first newly inserted column will have.
3301 @param numCols
3302 The number of columns to insert.
3303 @param updateLabels
3304 Currently not used.
3305 @return
3306 @true if the columns were successfully inserted, @false if an error
3307 occurred (most likely the table couldn't be updated).
3308 */
3309 bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true);
3310
3311 /**
3312 Inserts one or more new rows into a grid with the first new row at the
3313 specified position.
3314
3315 Notice that you must implement wxGridTableBase::InsertRows() if you use
3316 a grid with a custom table, please see InsertCols() for more
3317 information.
3318
3319 @param pos
3320 The position which the first newly inserted row will have.
3321 @param numRows
3322 The number of rows to insert.
3323 @param updateLabels
3324 Currently not used.
3325 @return
3326 @true if the rows were successfully inserted, @false if an error
3327 occurred (most likely the table couldn't be updated).
3328 */
3329 bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true);
3330
3331 /**
3332 Sets the cell attributes for all cells in the specified column.
3333
3334 For more information about controlling grid cell attributes see the
3335 wxGridCellAttr cell attribute class and the @ref overview_grid.
3336 */
3337 void SetColAttr(int col, wxGridCellAttr* attr);
3338
3339 /**
3340 Sets the extra margins used around the grid area.
3341
3342 A grid may occupy more space than needed for its data display and
3343 this function allows to set how big this extra space is
3344 */
3345 void SetMargins(int extraWidth, int extraHeight);
3346
3347 /**
3348 Sets the cell attributes for all cells in the specified row.
3349
3350 The grid takes ownership of the attribute pointer.
3351
3352 See the wxGridCellAttr class for more information about controlling
3353 cell attributes.
3354 */
3355 void SetRowAttr(int row, wxGridCellAttr* attr);
3356
3357 //@}
3358
3359
3360 /**
3361 @name Sorting support.
3362
3363 wxGrid doesn't provide any support for sorting the data but it does
3364 generate events allowing the user code to sort it and supports
3365 displaying the sort indicator in the column used for sorting.
3366
3367 To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT
3368 event (and not veto it) and resort the data displayed in the grid. The
3369 grid will automatically update the sorting indicator on the column
3370 which was clicked.
3371
3372 You can also call the functions in this section directly to update the
3373 sorting indicator. Once again, they don't do anything with the grid
3374 data, it remains your responsibility to actually sort it appropriately.
3375 */
3376 //@{
3377
3378 /**
3379 Return the column in which the sorting indicator is currently
3380 displayed.
3381
3382 Returns @c wxNOT_FOUND if sorting indicator is not currently displayed
3383 at all.
3384
3385 @see SetSortingColumn()
3386 */
3387 int GetSortingColumn() const;
3388
3389 /**
3390 Return @true if this column is currently used for sorting.
3391
3392 @see GetSortingColumn()
3393 */
3394 bool IsSortingBy(int col) const;
3395
3396 /**
3397 Return @true if the current sorting order is ascending or @false if it
3398 is descending.
3399
3400 It only makes sense to call this function if GetSortingColumn() returns
3401 a valid column index and not @c wxNOT_FOUND.
3402
3403 @see SetSortingColumn()
3404 */
3405 bool IsSortOrderAscending() const;
3406
3407 /**
3408 Set the column to display the sorting indicator in and its direction.
3409
3410 @param col
3411 The column to display the sorting indicator in or @c wxNOT_FOUND to
3412 remove any currently displayed sorting indicator.
3413 @param ascending
3414 If @true, display the ascending sort indicator, otherwise display
3415 the descending sort indicator.
3416
3417 @see GetSortingColumn(), IsSortOrderAscending()
3418 */
3419 void SetSortingColumn(int col, bool ascending = true);
3420
3421 /**
3422 Remove any currently shown sorting indicator.
3423
3424 This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND
3425 first argument.
3426 */
3427 void UnsetSortingColumn();
3428 //@}
3429
3430
3431 /**
3432 @name Accessors for component windows.
3433
3434 Return the various child windows of wxGrid.
3435
3436 wxGrid is an empty parent window for 4 children representing the column
3437 labels window (top), the row labels window (left), the corner window
3438 (top left) and the main grid window. It may be necessary to use these
3439 individual windows and not the wxGrid window itself if you need to
3440 handle events for them (this can be done using wxEvtHandler::Connect()
3441 or wxWindow::PushEventHandler()) or do something else requiring the use
3442 of the correct window pointer. Notice that you should not, however,
3443 change these windows (e.g. reposition them or draw over them) because
3444 they are managed by wxGrid itself.
3445 */
3446 //@{
3447
3448 /**
3449 Return the main grid window containing the grid cells.
3450
3451 This window is always shown.
3452 */
3453 wxWindow *GetGridWindow() const;
3454
3455 /**
3456 Return the row labels window.
3457
3458 This window is not shown if the row labels were hidden using
3459 HideRowLabels().
3460 */
3461 wxWindow *GetGridRowLabelWindow() const;
3462
3463 /**
3464 Return the column labels window.
3465
3466 This window is not shown if the columns labels were hidden using
3467 HideColLabels().
3468
3469 Depending on whether UseNativeColHeader() was called or not this can be
3470 either a wxHeaderCtrl or a plain wxWindow. This function returns a valid
3471 window pointer in either case but in the former case you can also use
3472 GetGridColHeader() to access it if you need wxHeaderCtrl-specific
3473 functionality.
3474 */
3475 wxWindow *GetGridColLabelWindow() const;
3476
3477 /**
3478 Return the window in the top left grid corner.
3479
3480 This window is shown only of both columns and row labels are shown and
3481 normally doesn't contain anything. Clicking on it is handled by wxGrid
3482 however and can be used to select the entire grid.
3483 */
3484 wxWindow *GetGridCornerLabelWindow() const;
3485
3486 /**
3487 Return the header control used for column labels display.
3488
3489 This function can only be called if UseNativeColHeader() had been
3490 called.
3491 */
3492 wxHeaderCtrl *GetGridColHeader() const;
3493
3494 //@}
3495
3496 protected:
3497 /**
3498 Returns @true if this grid has support for cell attributes.
3499
3500 The grid supports attributes if it has the associated table which, in
3501 turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes()
3502 returns @true.
3503 */
3504 bool CanHaveAttributes() const;
3505
3506 /**
3507 Get the minimal width of the given column/row.
3508
3509 The value returned by this function may be different than that returned
3510 by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been
3511 called for this column.
3512 */
3513 int GetColMinimalWidth(int col) const;
3514
3515 /**
3516 Returns the coordinate of the right border specified column.
3517 */
3518 int GetColRight(int col) const;
3519
3520 /**
3521 Returns the coordinate of the left border specified column.
3522 */
3523 int GetColLeft(int col) const;
3524
3525 /**
3526 Returns the minimal size for the given column.
3527
3528 The value returned by this function may be different than that returned
3529 by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been
3530 called for this row.
3531 */
3532 int GetRowMinimalHeight(int col) const;
3533 };
3534
3535
3536
3537 /**
3538 @class wxGridUpdateLocker
3539
3540 This small class can be used to prevent wxGrid from redrawing during its
3541 lifetime by calling wxGrid::BeginBatch() in its constructor and
3542 wxGrid::EndBatch() in its destructor. It is typically used in a function
3543 performing several operations with a grid which would otherwise result in
3544 flicker. For example:
3545
3546 @code
3547 void MyFrame::Foo()
3548 {
3549 m_grid = new wxGrid(this, ...);
3550
3551 wxGridUpdateLocker noUpdates(m_grid);
3552 m_grid-AppendColumn();
3553 // ... many other operations with m_grid ...
3554 m_grid-AppendRow();
3555
3556 // destructor called, grid refreshed
3557 }
3558 @endcode
3559
3560 Using this class is easier and safer than calling wxGrid::BeginBatch() and
3561 wxGrid::EndBatch() because you don't risk missing the call the latter (due
3562 to an exception for example).
3563
3564 @library{wxadv}
3565 @category{grid}
3566 */
3567 class wxGridUpdateLocker
3568 {
3569 public:
3570 /**
3571 Creates an object preventing the updates of the specified @a grid. The
3572 parameter could be @NULL in which case nothing is done. If @a grid is
3573 non-@NULL then the grid must exist for longer than this
3574 wxGridUpdateLocker object itself.
3575
3576 The default constructor could be followed by a call to Create() to set
3577 the grid object later.
3578 */
3579 wxGridUpdateLocker(wxGrid* grid = NULL);
3580
3581 /**
3582 Destructor reenables updates for the grid this object is associated
3583 with.
3584 */
3585 ~wxGridUpdateLocker();
3586
3587 /**
3588 This method can be called if the object had been constructed using the
3589 default constructor. It must not be called more than once.
3590 */
3591 void Create(wxGrid* grid);
3592 };
3593
3594
3595
3596 /**
3597 @class wxGridEvent
3598
3599 This event class contains information about various grid events.
3600
3601 Notice that all grid event table macros are available in two versions:
3602 @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the
3603 two is that the former doesn't allow to specify the grid window identifier
3604 and so takes a single parameter, the event handler, but is not suitable if
3605 there is more than one grid control in the window where the event table is
3606 used (as it would catch the events from all the grids). The version with @c
3607 CMD takes the id as first argument and the event handler as the second one
3608 and so can be used with multiple grids as well. Otherwise there are no
3609 difference between the two and only the versions without the id are
3610 documented below for brevity.
3611
3612 @beginEventTable{wxGridEvent}
3613 @event{EVT_GRID_CELL_CHANGING(func)}
3614 The user is about to change the data in a cell. The new cell value as
3615 string is available from GetString() event object method. This event
3616 can be vetoed if the change is not allowed.
3617 Processes a @c wxEVT_GRID_CELL_CHANGING event type.
3618 @event{EVT_GRID_CELL_CHANGED(func)}
3619 The user changed the data in a cell. The old cell value as string is
3620 available from GetString() event object method. Notice that vetoing
3621 this event still works for backwards compatibility reasons but any new
3622 code should only veto EVT_GRID_CELL_CHANGING event and not this one.
3623 Processes a @c wxEVT_GRID_CELL_CHANGED event type.
3624 @event{EVT_GRID_CELL_LEFT_CLICK(func)}
3625 The user clicked a cell with the left mouse button. Processes a
3626 @c wxEVT_GRID_CELL_LEFT_CLICK event type.
3627 @event{EVT_GRID_CELL_LEFT_DCLICK(func)}
3628 The user double-clicked a cell with the left mouse button. Processes a
3629 @c wxEVT_GRID_CELL_LEFT_DCLICK event type.
3630 @event{EVT_GRID_CELL_RIGHT_CLICK(func)}
3631 The user clicked a cell with the right mouse button. Processes a
3632 @c wxEVT_GRID_CELL_RIGHT_CLICK event type.
3633 @event{EVT_GRID_CELL_RIGHT_DCLICK(func)}
3634 The user double-clicked a cell with the right mouse button. Processes a
3635 @c wxEVT_GRID_CELL_RIGHT_DCLICK event type.
3636 @event{EVT_GRID_EDITOR_HIDDEN(func)}
3637 The editor for a cell was hidden. Processes a
3638 @c wxEVT_GRID_EDITOR_HIDDEN event type.
3639 @event{EVT_GRID_EDITOR_SHOWN(func)}
3640 The editor for a cell was shown. Processes a
3641 @c wxEVT_GRID_EDITOR_SHOWN event type.
3642 @event{EVT_GRID_LABEL_LEFT_CLICK(func)}
3643 The user clicked a label with the left mouse button. Processes a
3644 @c wxEVT_GRID_LABEL_LEFT_CLICK event type.
3645 @event{EVT_GRID_LABEL_LEFT_DCLICK(func)}
3646 The user double-clicked a label with the left mouse button. Processes a
3647 @c wxEVT_GRID_LABEL_LEFT_DCLICK event type.
3648 @event{EVT_GRID_LABEL_RIGHT_CLICK(func)}
3649 The user clicked a label with the right mouse button. Processes a
3650 @c wxEVT_GRID_LABEL_RIGHT_CLICK event type.
3651 @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)}
3652 The user double-clicked a label with the right mouse button. Processes
3653 a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type.
3654 @event{EVT_GRID_SELECT_CELL(func)}
3655 The given cell was made current, either by user or by the program via a
3656 call to SetGridCursor() or GoToCell(). Processes a
3657 @c wxEVT_GRID_SELECT_CELL event type.
3658 @event{EVT_GRID_COL_MOVE(func)}
3659 The user tries to change the order of the columns in the grid by
3660 dragging the column specified by GetCol(). This event can be vetoed to
3661 either prevent the user from reordering the column change completely
3662 (but notice that if you don't want to allow it at all, you simply
3663 shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed
3664 but handled in some way in the handler, e.g. by really moving the
3665 column to the new position at the associated table level, or allowed to
3666 proceed in which case wxGrid::SetColPos() is used to reorder the
3667 columns display order without affecting the use of the column indices
3668 otherwise.
3669 This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type.
3670 @event{EVT_GRID_COL_SORT(func)}
3671 This event is generated when a column is clicked by the user and its
3672 name is explained by the fact that the custom reaction to a click on a
3673 column is to sort the grid contents by this column. However the grid
3674 itself has no special support for sorting and it's up to the handler of
3675 this event to update the associated table. But if the event is handled
3676 (and not vetoed) the grid supposes that the table was indeed resorted
3677 and updates the column to indicate the new sort order and refreshes
3678 itself.
3679 This event macro corresponds to @c wxEVT_GRID_COL_SORT event type.
3680 @endEventTable
3681
3682 @library{wxadv}
3683 @category{grid,events}
3684 */
3685 class wxGridEvent : public wxNotifyEvent
3686 {
3687 public:
3688 /**
3689 Default constructor.
3690 */
3691 wxGridEvent();
3692 /**
3693 Constructor for initializing all event attributes.
3694 */
3695 wxGridEvent(int id, wxEventType type, wxObject* obj,
3696 int row = -1, int col = -1, int x = -1, int y = -1,
3697 bool sel = true, const wxKeyboardState& kbd = wxKeyboardState());
3698
3699 /**
3700 Returns @true if the Alt key was down at the time of the event.
3701 */
3702 bool AltDown() const;
3703
3704 /**
3705 Returns @true if the Control key was down at the time of the event.
3706 */
3707 bool ControlDown() const;
3708
3709 /**
3710 Column at which the event occurred.
3711 */
3712 virtual int GetCol();
3713
3714 /**
3715 Position in pixels at which the event occurred.
3716 */
3717 wxPoint GetPosition();
3718
3719 /**
3720 Row at which the event occurred.
3721 */
3722 virtual int GetRow();
3723
3724 /**
3725 Returns @true if the Meta key was down at the time of the event.
3726 */
3727 bool MetaDown() const;
3728
3729 /**
3730 Returns @true if the user is selecting grid cells, or @false if
3731 deselecting.
3732 */
3733 bool Selecting();
3734
3735 /**
3736 Returns @true if the Shift key was down at the time of the event.
3737 */
3738 bool ShiftDown() const;
3739 };
3740
3741
3742
3743 /**
3744 @class wxGridSizeEvent
3745
3746 This event class contains information about a row/column resize event.
3747
3748 @beginEventTable{wxGridSizeEvent}
3749 @event{EVT_GRID_CMD_COL_SIZE(id, func)}
3750 The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event
3751 type.
3752 @event{EVT_GRID_CMD_ROW_SIZE(id, func)}
3753 The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event
3754 type.
3755 @event{EVT_GRID_COL_SIZE(func)}
3756 Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id.
3757 @event{EVT_GRID_ROW_SIZE(func)}
3758 Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id.
3759 @endEventTable
3760
3761 @library{wxadv}
3762 @category{grid,events}
3763 */
3764 class wxGridSizeEvent : public wxNotifyEvent
3765 {
3766 public:
3767 /**
3768 Default constructor.
3769 */
3770 wxGridSizeEvent();
3771 /**
3772 Constructor for initializing all event attributes.
3773 */
3774 wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
3775 int rowOrCol = -1, int x = -1, int y = -1,
3776 const wxKeyboardState& kbd = wxKeyboardState());
3777
3778 /**
3779 Returns @true if the Alt key was down at the time of the event.
3780 */
3781 bool AltDown() const;
3782
3783 /**
3784 Returns @true if the Control key was down at the time of the event.
3785 */
3786 bool ControlDown() const;
3787
3788 /**
3789 Position in pixels at which the event occurred.
3790 */
3791 wxPoint GetPosition();
3792
3793 /**
3794 Row or column at that was resized.
3795 */
3796 int GetRowOrCol();
3797
3798 /**
3799 Returns @true if the Meta key was down at the time of the event.
3800 */
3801 bool MetaDown() const;
3802
3803 /**
3804 Returns @true if the Shift key was down at the time of the event.
3805 */
3806 bool ShiftDown() const;
3807 };
3808
3809
3810
3811 /**
3812 @class wxGridRangeSelectEvent
3813
3814 @beginEventTable{wxGridRangeSelectEvent}
3815 @event{EVT_GRID_RANGE_SELECT(func)}
3816 The user selected a group of contiguous cells. Processes a
3817 @c wxEVT_GRID_RANGE_SELECT event type.
3818 @event{EVT_GRID_CMD_RANGE_SELECT(id, func)}
3819 The user selected a group of contiguous cells; variant taking a window
3820 identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type.
3821 @endEventTable
3822
3823 @library{wxadv}
3824 @category{grid,events}
3825 */
3826 class wxGridRangeSelectEvent : public wxNotifyEvent
3827 {
3828 public:
3829 /**
3830 Default constructor.
3831 */
3832 wxGridRangeSelectEvent();
3833 /**
3834 Constructor for initializing all event attributes.
3835 */
3836 wxGridRangeSelectEvent(int id, wxEventType type,
3837 wxObject* obj,
3838 const wxGridCellCoords& topLeft,
3839 const wxGridCellCoords& bottomRight,
3840 bool sel = true, const wxKeyboardState& kbd = wxKeyboardState());
3841
3842 /**
3843 Returns @true if the Alt key was down at the time of the event.
3844 */
3845 bool AltDown() const;
3846
3847 /**
3848 Returns @true if the Control key was down at the time of the event.
3849 */
3850 bool ControlDown() const;
3851
3852 /**
3853 Top left corner of the rectangular area that was (de)selected.
3854 */
3855 wxGridCellCoords GetBottomRightCoords();
3856
3857 /**
3858 Bottom row of the rectangular area that was (de)selected.
3859 */
3860 int GetBottomRow();
3861
3862 /**
3863 Left column of the rectangular area that was (de)selected.
3864 */
3865 int GetLeftCol();
3866
3867 /**
3868 Right column of the rectangular area that was (de)selected.
3869 */
3870 int GetRightCol();
3871
3872 /**
3873 Top left corner of the rectangular area that was (de)selected.
3874 */
3875 wxGridCellCoords GetTopLeftCoords();
3876
3877 /**
3878 Top row of the rectangular area that was (de)selected.
3879 */
3880 int GetTopRow();
3881
3882 /**
3883 Returns @true if the Meta key was down at the time of the event.
3884 */
3885 bool MetaDown() const;
3886
3887 /**
3888 Returns @true if the area was selected, @false otherwise.
3889 */
3890 bool Selecting();
3891
3892 /**
3893 Returns @true if the Shift key was down at the time of the event.
3894 */
3895 bool ShiftDown() const;
3896 };
3897
3898
3899
3900 /**
3901 @class wxGridEditorCreatedEvent
3902
3903 @beginEventTable{wxGridEditorCreatedEvent}
3904 @event{EVT_GRID_EDITOR_CREATED(func)}
3905 The editor for a cell was created. Processes a
3906 @c wxEVT_GRID_EDITOR_CREATED event type.
3907 @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)}
3908 The editor for a cell was created; variant taking a window identifier.
3909 Processes a @c wxEVT_GRID_EDITOR_CREATED event type.
3910 @endEventTable
3911
3912 @library{wxadv}
3913 @category{grid,events}
3914 */
3915 class wxGridEditorCreatedEvent : public wxCommandEvent
3916 {
3917 public:
3918 /**
3919 Default constructor.
3920 */
3921 wxGridEditorCreatedEvent();
3922 /**
3923 Constructor for initializing all event attributes.
3924 */
3925 wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
3926 int row, int col, wxControl* ctrl);
3927
3928 /**
3929 Returns the column at which the event occurred.
3930 */
3931 int GetCol();
3932
3933 /**
3934 Returns the edit control.
3935 */
3936 wxControl* GetControl();
3937
3938 /**
3939 Returns the row at which the event occurred.
3940 */
3941 int GetRow();
3942
3943 /**
3944 Sets the column at which the event occurred.
3945 */
3946 void SetCol(int col);
3947
3948 /**
3949 Sets the edit control.
3950 */
3951 void SetControl(wxControl* ctrl);
3952
3953 /**
3954 Sets the row at which the event occurred.
3955 */
3956 void SetRow(int row);
3957 };
3958