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