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