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