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