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