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