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