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