setting parameters for wxGridCellFloatRenderer seems to work
[wxWidgets.git] / include / wx / generic / grid.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/grid.h
3 // Purpose: wxGrid and related classes
4 // Author: Michael Bedward (based on code by Julian Smart, Robin Dunn)
5 // Modified by:
6 // Created: 1/08/1999
7 // RCS-ID: $Id$
8 // Copyright: (c) Michael Bedward
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/defs.h"
13
14 #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
15 #include "gridg.h"
16 #else
17
18 #ifndef __WXGRID_H__
19 #define __WXGRID_H__
20
21 #ifdef __GNUG__
22 #pragma interface "grid.h"
23 #endif
24
25 #include "wx/hash.h"
26 #include "wx/panel.h"
27 #include "wx/scrolwin.h"
28 #include "wx/string.h"
29 #include "wx/scrolbar.h"
30 #include "wx/event.h"
31 #include "wx/combobox.h"
32 #include "wx/dynarray.h"
33 #include "wx/timer.h"
34
35 // ----------------------------------------------------------------------------
36 // constants
37 // ----------------------------------------------------------------------------
38
39 // Default parameters for wxGrid
40 //
41 #define WXGRID_DEFAULT_NUMBER_ROWS 10
42 #define WXGRID_DEFAULT_NUMBER_COLS 10
43 #ifdef __WXMSW__
44 #define WXGRID_DEFAULT_ROW_HEIGHT 25
45 #else
46 #define WXGRID_DEFAULT_ROW_HEIGHT 30
47 #endif // __WXMSW__
48 #define WXGRID_DEFAULT_COL_WIDTH 80
49 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
50 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
51 #define WXGRID_LABEL_EDGE_ZONE 5
52 #define WXGRID_MIN_ROW_HEIGHT 15
53 #define WXGRID_MIN_COL_WIDTH 15
54 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
55
56 // type names for grid table values
57 #define wxGRID_VALUE_STRING _T("string")
58 #define wxGRID_VALUE_BOOL _T("bool")
59 #define wxGRID_VALUE_NUMBER _T("long")
60 #define wxGRID_VALUE_FLOAT _T("double")
61
62 #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
63 #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
64
65 // ----------------------------------------------------------------------------
66 // forward declarations
67 // ----------------------------------------------------------------------------
68
69 class WXDLLEXPORT wxGrid;
70 class WXDLLEXPORT wxGridCellAttr;
71 class WXDLLEXPORT wxGridCellAttrProviderData;
72 class WXDLLEXPORT wxGridColLabelWindow;
73 class WXDLLEXPORT wxGridCornerLabelWindow;
74 class WXDLLEXPORT wxGridRowLabelWindow;
75 class WXDLLEXPORT wxGridTableBase;
76 class WXDLLEXPORT wxGridWindow;
77 class WXDLLEXPORT wxGridTypeRegistry;
78
79 class WXDLLEXPORT wxCheckBox;
80 class WXDLLEXPORT wxComboBox;
81 class WXDLLEXPORT wxTextCtrl;
82 class WXDLLEXPORT wxSpinCtrl;
83
84 // ----------------------------------------------------------------------------
85 // macros
86 // ----------------------------------------------------------------------------
87
88 #define wxSafeIncRef(p) if ( p ) (p)->IncRef()
89 #define wxSafeDecRef(p) if ( p ) (p)->DecRef()
90
91 // ----------------------------------------------------------------------------
92 // wxGridCellRenderer: this class is responsible for actually drawing the cell
93 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
94 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
95 // view of all cells. This is an ABC, you will normally use one of the
96 // predefined derived classes or derive your own class from it.
97 // ----------------------------------------------------------------------------
98
99 class WXDLLEXPORT wxGridCellRenderer
100 {
101 public:
102 wxGridCellRenderer() { m_nRef = 1; }
103
104 // this class is ref counted: it is created with ref count of 1, so
105 // calling DecRef() once will delete it. Calling IncRef() allows to lock
106 // it until the matching DecRef() is called
107 void IncRef() { m_nRef++; }
108 void DecRef() { if ( !--m_nRef ) delete this; }
109
110 // draw the given cell on the provided DC inside the given rectangle
111 // using the style specified by the attribute and the default or selected
112 // state corresponding to the isSelected value.
113 //
114 // this pure virtual function has a default implementation which will
115 // prepare the DC using the given attribute: it will draw the rectangle
116 // with the bg colour from attr and set the text colour and font
117 virtual void Draw(wxGrid& grid,
118 wxGridCellAttr& attr,
119 wxDC& dc,
120 const wxRect& rect,
121 int row, int col,
122 bool isSelected) = 0;
123
124 // get the preferred size of the cell for its contents
125 virtual wxSize GetBestSize(wxGrid& grid,
126 wxGridCellAttr& attr,
127 wxDC& dc,
128 int row, int col) = 0;
129
130 // interpret renderer parameters: arbitrary string whose interpretatin is
131 // left to the derived classes
132 virtual void SetParameters(const wxString& params);
133
134 // create a new object which is the copy of this one
135 virtual wxGridCellRenderer *Clone() const = 0;
136
137 protected:
138 // virtual dtor for any base class - private because only DecRef() can
139 // delete us
140 virtual ~wxGridCellRenderer();
141
142 private:
143 size_t m_nRef;
144
145 // suppress the stupid gcc warning about the class having private dtor and
146 // no friends
147 friend class wxGridCellRendererDummyFriend;
148 };
149
150 // the default renderer for the cells containing string data
151 class WXDLLEXPORT wxGridCellStringRenderer : public wxGridCellRenderer
152 {
153 public:
154 // draw the string
155 virtual void Draw(wxGrid& grid,
156 wxGridCellAttr& attr,
157 wxDC& dc,
158 const wxRect& rect,
159 int row, int col,
160 bool isSelected);
161
162 // return the string extent
163 virtual wxSize GetBestSize(wxGrid& grid,
164 wxGridCellAttr& attr,
165 wxDC& dc,
166 int row, int col);
167
168 virtual wxGridCellRenderer *Clone() const
169 { return new wxGridCellStringRenderer; }
170
171 protected:
172 // set the text colours before drawing
173 void SetTextColoursAndFont(wxGrid& grid,
174 wxGridCellAttr& attr,
175 wxDC& dc,
176 bool isSelected);
177
178 // calc the string extent for given string/font
179 wxSize DoGetBestSize(wxGridCellAttr& attr,
180 wxDC& dc,
181 const wxString& text);
182 };
183
184 // the default renderer for the cells containing numeric (long) data
185 class WXDLLEXPORT wxGridCellNumberRenderer : public wxGridCellStringRenderer
186 {
187 public:
188 // draw the string right aligned
189 virtual void Draw(wxGrid& grid,
190 wxGridCellAttr& attr,
191 wxDC& dc,
192 const wxRect& rect,
193 int row, int col,
194 bool isSelected);
195
196 virtual wxSize GetBestSize(wxGrid& grid,
197 wxGridCellAttr& attr,
198 wxDC& dc,
199 int row, int col);
200
201 virtual wxGridCellRenderer *Clone() const
202 { return new wxGridCellNumberRenderer; }
203
204 protected:
205 wxString GetString(wxGrid& grid, int row, int col);
206 };
207
208 class WXDLLEXPORT wxGridCellFloatRenderer : public wxGridCellStringRenderer
209 {
210 public:
211 wxGridCellFloatRenderer(int width = -1, int precision = -1);
212
213 // get/change formatting parameters
214 int GetWidth() const { return m_width; }
215 void SetWidth(int width) { m_width = width; m_format.clear(); }
216 int GetPrecision() const { return m_precision; }
217 void SetPrecision(int precision) { m_precision = precision; m_format.clear(); }
218
219 // draw the string right aligned with given width/precision
220 virtual void Draw(wxGrid& grid,
221 wxGridCellAttr& attr,
222 wxDC& dc,
223 const wxRect& rect,
224 int row, int col,
225 bool isSelected);
226
227 virtual wxSize GetBestSize(wxGrid& grid,
228 wxGridCellAttr& attr,
229 wxDC& dc,
230 int row, int col);
231
232 // parameters string format is "width[,precision]"
233 virtual void SetParameters(const wxString& params);
234
235 virtual wxGridCellRenderer *Clone() const;
236
237 protected:
238 wxString GetString(wxGrid& grid, int row, int col);
239
240 private:
241 // formatting parameters
242 int m_width,
243 m_precision;
244
245 wxString m_format;
246 };
247
248 // renderer for boolean fields
249 class WXDLLEXPORT wxGridCellBoolRenderer : public wxGridCellRenderer
250 {
251 public:
252 // draw a check mark or nothing
253 virtual void Draw(wxGrid& grid,
254 wxGridCellAttr& attr,
255 wxDC& dc,
256 const wxRect& rect,
257 int row, int col,
258 bool isSelected);
259
260 // return the checkmark size
261 virtual wxSize GetBestSize(wxGrid& grid,
262 wxGridCellAttr& attr,
263 wxDC& dc,
264 int row, int col);
265
266 virtual wxGridCellRenderer *Clone() const
267 { return new wxGridCellBoolRenderer; }
268
269 private:
270 static wxSize ms_sizeCheckMark;
271 };
272
273 // ----------------------------------------------------------------------------
274 // wxGridCellEditor: This class is responsible for providing and manipulating
275 // the in-place edit controls for the grid. Instances of wxGridCellEditor
276 // (actually, instances of derived classes since it is an ABC) can be
277 // associated with the cell attributes for individual cells, rows, columns, or
278 // even for the entire grid.
279 // ----------------------------------------------------------------------------
280
281 class WXDLLEXPORT wxGridCellEditor
282 {
283 public:
284 wxGridCellEditor();
285
286 // this class is ref counted: it is created with ref count of 1, so
287 // calling DecRef() once will delete it. Calling IncRef() allows to lock
288 // it until the matching DecRef() is called
289 void IncRef() { m_nRef++; }
290 void DecRef() { if ( !--m_nRef ) delete this; }
291
292 bool IsCreated() { return m_control != NULL; }
293
294 // Creates the actual edit control
295 virtual void Create(wxWindow* parent,
296 wxWindowID id,
297 wxEvtHandler* evtHandler) = 0;
298
299 // Size and position the edit control
300 virtual void SetSize(const wxRect& rect);
301
302 // Show or hide the edit control, use the specified attributes to set
303 // colours/fonts for it
304 virtual void Show(bool show, wxGridCellAttr *attr = (wxGridCellAttr *)NULL);
305
306 // Draws the part of the cell not occupied by the control: the base class
307 // version just fills it with background colour from the attribute
308 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
309
310 // Fetch the value from the table and prepare the edit control
311 // to begin editing. Set the focus to the edit control.
312 virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
313
314 // Complete the editing of the current cell. Returns true if the value has
315 // changed. If necessary, the control may be destroyed.
316 virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
317
318 // Reset the value in the control back to its starting value
319 virtual void Reset() = 0;
320
321 // If the editor is enabled by pressing keys on the grid,
322 // this will be called to let the editor do something about
323 // that first key if desired.
324 virtual void StartingKey(wxKeyEvent& event);
325
326 // if the editor is enabled by clicking on the cell, this method will be
327 // called
328 virtual void StartingClick();
329
330 // Some types of controls on some platforms may need some help
331 // with the Return key.
332 virtual void HandleReturn(wxKeyEvent& event);
333
334 // Final cleanup
335 virtual void Destroy();
336
337 protected:
338 // the dtor is private because only DecRef() can delete us
339 virtual ~wxGridCellEditor();
340
341 // the ref count - when it goes to 0, we die
342 size_t m_nRef;
343
344 // the control we show on screen
345 wxControl* m_control;
346
347 // if we change the colours/font of the control from the default ones, we
348 // must restore the default later and we save them here between calls to
349 // Show(TRUE) and Show(FALSE)
350 wxColour m_colFgOld,
351 m_colBgOld;
352 wxFont m_fontOld;
353
354 // suppress the stupid gcc warning about the class having private dtor and
355 // no friends
356 friend class wxGridCellEditorDummyFriend;
357 };
358
359 // the editor for string/text data
360 class WXDLLEXPORT wxGridCellTextEditor : public wxGridCellEditor
361 {
362 public:
363 wxGridCellTextEditor();
364
365 virtual void Create(wxWindow* parent,
366 wxWindowID id,
367 wxEvtHandler* evtHandler);
368 virtual void SetSize(const wxRect& rect);
369
370 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
371
372 virtual void BeginEdit(int row, int col, wxGrid* grid);
373 virtual bool EndEdit(int row, int col, wxGrid* grid);
374
375 virtual void Reset();
376 virtual void StartingKey(wxKeyEvent& event);
377 virtual void HandleReturn(wxKeyEvent& event);
378
379 protected:
380 wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
381
382 // parts of our virtual functions reused by the derived classes
383 void DoBeginEdit(const wxString& startValue);
384 void DoReset(const wxString& startValue);
385
386 private:
387 wxString m_startValue;
388 };
389
390 // the editor for numeric (long) data
391 class WXDLLEXPORT wxGridCellNumberEditor : public wxGridCellTextEditor
392 {
393 public:
394 // allows to specify the range - if min == max == -1, no range checking is
395 // done
396 wxGridCellNumberEditor(int min = -1, int max = -1);
397
398 virtual void Create(wxWindow* parent,
399 wxWindowID id,
400 wxEvtHandler* evtHandler);
401
402 virtual void BeginEdit(int row, int col, wxGrid* grid);
403 virtual bool EndEdit(int row, int col, wxGrid* grid);
404
405 virtual void Reset();
406 virtual void StartingKey(wxKeyEvent& event);
407
408 protected:
409 wxSpinCtrl *Spin() const { return (wxSpinCtrl *)m_control; }
410
411 // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
412 bool HasRange() const { return m_min != m_max; }
413
414 // string representation of m_valueOld
415 wxString GetString() const
416 { return wxString::Format(_T("%ld"), m_valueOld); }
417
418 private:
419 int m_min,
420 m_max;
421
422 long m_valueOld;
423 };
424
425 // the editor for floating point numbers (double) data
426 class WXDLLEXPORT wxGridCellFloatEditor : public wxGridCellTextEditor
427 {
428 public:
429 virtual void Create(wxWindow* parent,
430 wxWindowID id,
431 wxEvtHandler* evtHandler);
432
433 virtual void BeginEdit(int row, int col, wxGrid* grid);
434 virtual bool EndEdit(int row, int col, wxGrid* grid);
435
436 virtual void Reset();
437 virtual void StartingKey(wxKeyEvent& event);
438
439 protected:
440 // string representation of m_valueOld
441 wxString GetString() const
442 { return wxString::Format(_T("%f"), m_valueOld); }
443
444 private:
445 double m_valueOld;
446 };
447
448 // the editor for boolean data
449 class WXDLLEXPORT wxGridCellBoolEditor : public wxGridCellEditor
450 {
451 public:
452 virtual void Create(wxWindow* parent,
453 wxWindowID id,
454 wxEvtHandler* evtHandler);
455
456 virtual void SetSize(const wxRect& rect);
457 virtual void Show(bool show, wxGridCellAttr *attr = (wxGridCellAttr *)NULL);
458
459 virtual void BeginEdit(int row, int col, wxGrid* grid);
460 virtual bool EndEdit(int row, int col, wxGrid* grid);
461
462 virtual void Reset();
463 virtual void StartingClick();
464
465 protected:
466 wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }
467
468 private:
469 bool m_startValue;
470 };
471
472 // the editor for string data allowing to choose from the list of strings
473 class WXDLLEXPORT wxGridCellChoiceEditor : public wxGridCellEditor
474 {
475 public:
476 // if !allowOthers, user can't type a string not in choices array
477 wxGridCellChoiceEditor(size_t count, const wxChar* choices[],
478 bool allowOthers = FALSE);
479
480 virtual void Create(wxWindow* parent,
481 wxWindowID id,
482 wxEvtHandler* evtHandler);
483
484 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
485
486 virtual void BeginEdit(int row, int col, wxGrid* grid);
487 virtual bool EndEdit(int row, int col, wxGrid* grid);
488
489 virtual void Reset();
490
491 protected:
492 wxComboBox *Combo() const { return (wxComboBox *)m_control; }
493
494 private:
495 wxString m_startValue;
496 wxArrayString m_choices;
497 bool m_allowOthers;
498 };
499
500 // ----------------------------------------------------------------------------
501 // wxGridCellAttr: this class can be used to alter the cells appearance in
502 // the grid by changing their colour/font/... from default. An object of this
503 // class may be returned by wxGridTable::GetAttr().
504 // ----------------------------------------------------------------------------
505
506 class WXDLLEXPORT wxGridCellAttr
507 {
508 public:
509 // ctors
510 wxGridCellAttr()
511 {
512 Init();
513 SetAlignment(0, 0);
514 }
515
516 // VZ: considering the number of members wxGridCellAttr has now, this ctor
517 // seems to be pretty useless... may be we should just remove it?
518 wxGridCellAttr(const wxColour& colText,
519 const wxColour& colBack,
520 const wxFont& font,
521 int hAlign,
522 int vAlign)
523 : m_colText(colText), m_colBack(colBack), m_font(font)
524 {
525 Init();
526 SetAlignment(hAlign, vAlign);
527 }
528
529 // creates a new copy of this object
530 wxGridCellAttr *Clone() const;
531
532 // this class is ref counted: it is created with ref count of 1, so
533 // calling DecRef() once will delete it. Calling IncRef() allows to lock
534 // it until the matching DecRef() is called
535 void IncRef() { m_nRef++; }
536 void DecRef() { if ( !--m_nRef ) delete this; }
537
538 // setters
539 void SetTextColour(const wxColour& colText) { m_colText = colText; }
540 void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
541 void SetFont(const wxFont& font) { m_font = font; }
542 void SetAlignment(int hAlign, int vAlign)
543 {
544 m_hAlign = hAlign;
545 m_vAlign = vAlign;
546 }
547 void SetReadOnly(bool isReadOnly = TRUE) { m_isReadOnly = isReadOnly; }
548
549 // takes ownership of the pointer
550 void SetRenderer(wxGridCellRenderer *renderer)
551 { wxSafeDecRef(m_renderer); m_renderer = renderer; }
552 void SetEditor(wxGridCellEditor* editor)
553 { wxSafeDecRef(m_editor); m_editor = editor; }
554
555 // accessors
556 bool HasTextColour() const { return m_colText.Ok(); }
557 bool HasBackgroundColour() const { return m_colBack.Ok(); }
558 bool HasFont() const { return m_font.Ok(); }
559 bool HasAlignment() const { return m_hAlign || m_vAlign; }
560 bool HasRenderer() const { return m_renderer != NULL; }
561 bool HasEditor() const { return m_editor != NULL; }
562
563 const wxColour& GetTextColour() const;
564 const wxColour& GetBackgroundColour() const;
565 const wxFont& GetFont() const;
566 void GetAlignment(int *hAlign, int *vAlign) const;
567 wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
568 wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
569
570 bool IsReadOnly() const { return m_isReadOnly; }
571
572 void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; }
573
574 private:
575 // the common part of all ctors
576 void Init()
577 {
578 m_nRef = 1;
579
580 m_isReadOnly = FALSE;
581
582 m_renderer = NULL;
583 m_editor = NULL;
584 }
585
586 // the dtor is private because only DecRef() can delete us
587 ~wxGridCellAttr()
588 {
589 wxSafeDecRef(m_renderer);
590 wxSafeDecRef(m_editor);
591 }
592
593 // the ref count - when it goes to 0, we die
594 size_t m_nRef;
595
596 wxColour m_colText,
597 m_colBack;
598 wxFont m_font;
599 int m_hAlign,
600 m_vAlign;
601
602 wxGridCellRenderer* m_renderer;
603 wxGridCellEditor* m_editor;
604 wxGridCellAttr* m_defGridAttr;
605
606 bool m_isReadOnly;
607
608 // use Clone() instead
609 DECLARE_NO_COPY_CLASS(wxGridCellAttr);
610
611 // suppress the stupid gcc warning about the class having private dtor and
612 // no friends
613 friend class wxGridCellAttrDummyFriend;
614 };
615
616 // ----------------------------------------------------------------------------
617 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
618 // cell attributes.
619 // ----------------------------------------------------------------------------
620
621 // implementation note: we separate it from wxGridTableBase because we wish to
622 // avoid deriving a new table class if possible, and sometimes it will be
623 // enough to just derive another wxGridCellAttrProvider instead
624 //
625 // the default implementation is reasonably efficient for the generic case,
626 // but you might still wish to implement your own for some specific situations
627 // if you have performance problems with the stock one
628 class WXDLLEXPORT wxGridCellAttrProvider
629 {
630 public:
631 wxGridCellAttrProvider();
632 virtual ~wxGridCellAttrProvider();
633
634 // DecRef() must be called on the returned pointer
635 virtual wxGridCellAttr *GetAttr(int row, int col) const;
636
637 // all these functions take ownership of the pointer, don't call DecRef()
638 // on it
639 virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
640 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
641 virtual void SetColAttr(wxGridCellAttr *attr, int col);
642
643 // these functions must be called whenever some rows/cols are deleted
644 // because the internal data must be updated then
645 void UpdateAttrRows( size_t pos, int numRows );
646 void UpdateAttrCols( size_t pos, int numCols );
647
648 private:
649 void InitData();
650
651 wxGridCellAttrProviderData *m_data;
652 };
653
654 //////////////////////////////////////////////////////////////////////
655 //
656 // Grid table classes
657 //
658 //////////////////////////////////////////////////////////////////////
659
660
661 class WXDLLEXPORT wxGridTableBase : public wxObject
662 {
663 public:
664 wxGridTableBase();
665 virtual ~wxGridTableBase();
666
667 // You must override these functions in a derived table class
668 //
669 virtual long GetNumberRows() = 0;
670 virtual long GetNumberCols() = 0;
671 virtual bool IsEmptyCell( int row, int col ) = 0;
672 virtual wxString GetValue( int row, int col ) = 0;
673 virtual void SetValue( int row, int col, const wxString& value ) = 0;
674
675 // Data type determination and value access
676 virtual wxString GetTypeName( int row, int col );
677 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
678 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
679
680 virtual long GetValueAsLong( int row, int col );
681 virtual double GetValueAsDouble( int row, int col );
682 virtual bool GetValueAsBool( int row, int col );
683
684 virtual void SetValueAsLong( int row, int col, long value );
685 virtual void SetValueAsDouble( int row, int col, double value );
686 virtual void SetValueAsBool( int row, int col, bool value );
687
688 // For user defined types
689 virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
690 virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
691
692
693 // Overriding these is optional
694 //
695 virtual void SetView( wxGrid *grid ) { m_view = grid; }
696 virtual wxGrid * GetView() const { return m_view; }
697
698 virtual void Clear() {}
699 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
700 virtual bool AppendRows( size_t numRows = 1 );
701 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
702 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
703 virtual bool AppendCols( size_t numCols = 1 );
704 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
705
706 virtual wxString GetRowLabelValue( int row );
707 virtual wxString GetColLabelValue( int col );
708 virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {}
709 virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {}
710
711 // Attribute handling
712 //
713
714 // give us the attr provider to use - we take ownership of the pointer
715 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
716
717 // get the currently used attr provider (may be NULL)
718 wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; }
719
720 // Does this table allow attributes? Default implementation creates
721 // a wxGridCellAttrProvider if necessary.
722 virtual bool CanHaveAttributes();
723
724
725 // change row/col number in attribute if needed
726 virtual void UpdateAttrRows( size_t pos, int numRows );
727 virtual void UpdateAttrCols( size_t pos, int numCols );
728
729 // by default forwarded to wxGridCellAttrProvider if any. May be
730 // overridden to handle attributes directly in the table.
731 virtual wxGridCellAttr *GetAttr( int row, int col );
732
733 // these functions take ownership of the pointer
734 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
735 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
736 virtual void SetColAttr(wxGridCellAttr *attr, int col);
737
738 private:
739 wxGrid * m_view;
740 wxGridCellAttrProvider *m_attrProvider;
741
742 DECLARE_ABSTRACT_CLASS( wxGridTableBase );
743 };
744
745
746 // ----------------------------------------------------------------------------
747 // wxGridTableMessage
748 // ----------------------------------------------------------------------------
749
750 // IDs for messages sent from grid table to view
751 //
752 enum wxGridTableRequest
753 {
754 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
755 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
756 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
757 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
758 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
759 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
760 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
761 wxGRIDTABLE_NOTIFY_COLS_DELETED
762 };
763
764 class WXDLLEXPORT wxGridTableMessage
765 {
766 public:
767 wxGridTableMessage();
768 wxGridTableMessage( wxGridTableBase *table, int id,
769 int comInt1 = -1,
770 int comInt2 = -1 );
771
772 void SetTableObject( wxGridTableBase *table ) { m_table = table; }
773 wxGridTableBase * GetTableObject() const { return m_table; }
774 void SetId( int id ) { m_id = id; }
775 int GetId() { return m_id; }
776 void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; }
777 int GetCommandInt() { return m_comInt1; }
778 void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; }
779 int GetCommandInt2() { return m_comInt2; }
780
781 private:
782 wxGridTableBase *m_table;
783 int m_id;
784 int m_comInt1;
785 int m_comInt2;
786 };
787
788
789
790 // ------ wxGridStringArray
791 // A 2-dimensional array of strings for data values
792 //
793
794 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString, wxGridStringArray);
795
796
797
798 // ------ wxGridStringTable
799 //
800 // Simplest type of data table for a grid for small tables of strings
801 // that are stored in memory
802 //
803
804 class WXDLLEXPORT wxGridStringTable : public wxGridTableBase
805 {
806 public:
807 wxGridStringTable();
808 wxGridStringTable( int numRows, int numCols );
809 ~wxGridStringTable();
810
811 // these are pure virtual in wxGridTableBase
812 //
813 long GetNumberRows();
814 long GetNumberCols();
815 wxString GetValue( int row, int col );
816 void SetValue( int row, int col, const wxString& s );
817 bool IsEmptyCell( int row, int col );
818
819 // overridden functions from wxGridTableBase
820 //
821 void Clear();
822 bool InsertRows( size_t pos = 0, size_t numRows = 1 );
823 bool AppendRows( size_t numRows = 1 );
824 bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
825 bool InsertCols( size_t pos = 0, size_t numCols = 1 );
826 bool AppendCols( size_t numCols = 1 );
827 bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
828
829 void SetRowLabelValue( int row, const wxString& );
830 void SetColLabelValue( int col, const wxString& );
831 wxString GetRowLabelValue( int row );
832 wxString GetColLabelValue( int col );
833
834 private:
835 wxGridStringArray m_data;
836
837 // These only get used if you set your own labels, otherwise the
838 // GetRow/ColLabelValue functions return wxGridTableBase defaults
839 //
840 wxArrayString m_rowLabels;
841 wxArrayString m_colLabels;
842
843 DECLARE_DYNAMIC_CLASS( wxGridStringTable )
844 };
845
846
847
848 // ============================================================================
849 // Grid view classes
850 // ============================================================================
851
852 // ----------------------------------------------------------------------------
853 // wxGridCellCoords: location of a cell in the grid
854 // ----------------------------------------------------------------------------
855
856 class WXDLLEXPORT wxGridCellCoords
857 {
858 public:
859 wxGridCellCoords() { m_row = m_col = -1; }
860 wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; }
861
862 // default copy ctor is ok
863
864 long GetRow() const { return m_row; }
865 void SetRow( long n ) { m_row = n; }
866 long GetCol() const { return m_col; }
867 void SetCol( long n ) { m_col = n; }
868 void Set( long row, long col ) { m_row = row; m_col = col; }
869
870 wxGridCellCoords& operator=( const wxGridCellCoords& other )
871 {
872 if ( &other != this )
873 {
874 m_row=other.m_row;
875 m_col=other.m_col;
876 }
877 return *this;
878 }
879
880 bool operator==( const wxGridCellCoords& other ) const
881 {
882 return (m_row == other.m_row && m_col == other.m_col);
883 }
884
885 bool operator!=( const wxGridCellCoords& other ) const
886 {
887 return (m_row != other.m_row || m_col != other.m_col);
888 }
889
890 bool operator!() const
891 {
892 return (m_row == -1 && m_col == -1 );
893 }
894
895 private:
896 long m_row;
897 long m_col;
898 };
899
900
901 // For comparisons...
902 //
903 extern wxGridCellCoords wxGridNoCellCoords;
904 extern wxRect wxGridNoCellRect;
905
906 // An array of cell coords...
907 //
908 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords, wxGridCellCoordsArray);
909
910 // ----------------------------------------------------------------------------
911 // wxGrid
912 // ----------------------------------------------------------------------------
913
914 class WXDLLEXPORT wxGrid : public wxScrolledWindow
915 {
916 public:
917 wxGrid()
918 {
919 Create();
920 }
921
922 wxGrid( wxWindow *parent,
923 wxWindowID id,
924 const wxPoint& pos = wxDefaultPosition,
925 const wxSize& size = wxDefaultSize,
926 long style = wxWANTS_CHARS,
927 const wxString& name = wxPanelNameStr );
928
929 ~wxGrid();
930
931 bool CreateGrid( int numRows, int numCols );
932
933
934 // ------ grid dimensions
935 //
936 int GetNumberRows() { return m_numRows; }
937 int GetNumberCols() { return m_numCols; }
938
939
940 // ------ display update functions
941 //
942 void CalcRowLabelsExposed( wxRegion& reg );
943
944 void CalcColLabelsExposed( wxRegion& reg );
945 void CalcCellsExposed( wxRegion& reg );
946
947
948 // ------ event handlers
949 //
950 void ProcessRowLabelMouseEvent( wxMouseEvent& event );
951 void ProcessColLabelMouseEvent( wxMouseEvent& event );
952 void ProcessCornerLabelMouseEvent( wxMouseEvent& event );
953 void ProcessGridCellMouseEvent( wxMouseEvent& event );
954 bool ProcessTableMessage( wxGridTableMessage& );
955
956 void DoEndDragResizeRow();
957 void DoEndDragResizeCol();
958
959 wxGridTableBase * GetTable() const { return m_table; }
960 bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE );
961
962 void ClearGrid();
963 bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
964 bool AppendRows( int numRows = 1, bool updateLabels=TRUE );
965 bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
966 bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
967 bool AppendCols( int numCols = 1, bool updateLabels=TRUE );
968 bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
969
970 void DrawGridCellArea( wxDC& dc );
971 void DrawGridSpace( wxDC& dc );
972 void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
973 void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
974 void DrawCell( wxDC& dc, const wxGridCellCoords& );
975 void DrawHighlight(wxDC& dc);
976
977 // this function is called when the current cell highlight must be redrawn
978 // and may be overridden by the user
979 virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
980
981 void DrawRowLabels( wxDC& dc );
982 void DrawRowLabel( wxDC& dc, int row );
983
984 void DrawColLabels( wxDC& dc );
985 void DrawColLabel( wxDC& dc, int col );
986
987
988 // ------ Cell text drawing functions
989 //
990 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
991 int horizontalAlignment = wxLEFT,
992 int verticalAlignment = wxTOP );
993
994 // Split a string containing newline chararcters into an array of
995 // strings and return the number of lines
996 //
997 void StringToLines( const wxString& value, wxArrayString& lines );
998
999 void GetTextBoxSize( wxDC& dc,
1000 wxArrayString& lines,
1001 long *width, long *height );
1002
1003
1004 // ------
1005 // Code that does a lot of grid modification can be enclosed
1006 // between BeginBatch() and EndBatch() calls to avoid screen
1007 // flicker
1008 //
1009 void BeginBatch() { m_batchCount++; }
1010 void EndBatch() { if ( m_batchCount > 0 ) m_batchCount--; }
1011 int GetBatchCount() { return m_batchCount; }
1012
1013
1014 // ------ edit control functions
1015 //
1016 bool IsEditable() { return m_editable; }
1017 void EnableEditing( bool edit );
1018
1019 void EnableCellEditControl( bool enable = TRUE );
1020 void DisableCellEditControl() { EnableCellEditControl(FALSE); }
1021 bool CanEnableCellControl() const;
1022 bool IsCellEditControlEnabled() const;
1023
1024 bool IsCurrentCellReadOnly() const;
1025
1026 void ShowCellEditControl();
1027 void HideCellEditControl();
1028 void SaveEditControlValue();
1029
1030
1031 // ------ grid location functions
1032 // Note that all of these functions work with the logical coordinates of
1033 // grid cells and labels so you will need to convert from device
1034 // coordinates for mouse events etc.
1035 //
1036 void XYToCell( int x, int y, wxGridCellCoords& );
1037 int YToRow( int y );
1038 int XToCol( int x );
1039
1040 int YToEdgeOfRow( int y );
1041 int XToEdgeOfCol( int x );
1042
1043 wxRect CellToRect( int row, int col );
1044 wxRect CellToRect( const wxGridCellCoords& coords )
1045 { return CellToRect( coords.GetRow(), coords.GetCol() ); }
1046
1047 int GetGridCursorRow() { return m_currentCellCoords.GetRow(); }
1048 int GetGridCursorCol() { return m_currentCellCoords.GetCol(); }
1049
1050 // check to see if a cell is either wholly visible (the default arg) or
1051 // at least partially visible in the grid window
1052 //
1053 bool IsVisible( int row, int col, bool wholeCellVisible = TRUE );
1054 bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE )
1055 { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); }
1056 void MakeCellVisible( int row, int col );
1057 void MakeCellVisible( const wxGridCellCoords& coords )
1058 { MakeCellVisible( coords.GetRow(), coords.GetCol() ); }
1059
1060
1061 // ------ grid cursor movement functions
1062 //
1063 void SetGridCursor( int row, int col )
1064 { SetCurrentCell( wxGridCellCoords(row, col) ); }
1065
1066 bool MoveCursorUp();
1067 bool MoveCursorDown();
1068 bool MoveCursorLeft();
1069 bool MoveCursorRight();
1070 bool MovePageDown();
1071 bool MovePageUp();
1072 bool MoveCursorUpBlock();
1073 bool MoveCursorDownBlock();
1074 bool MoveCursorLeftBlock();
1075 bool MoveCursorRightBlock();
1076
1077
1078 // ------ label and gridline formatting
1079 //
1080 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; }
1081 int GetRowLabelSize() { return m_rowLabelWidth; }
1082 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; }
1083 int GetColLabelSize() { return m_colLabelHeight; }
1084 wxColour GetLabelBackgroundColour() { return m_labelBackgroundColour; }
1085 wxColour GetLabelTextColour() { return m_labelTextColour; }
1086 wxFont GetLabelFont() { return m_labelFont; }
1087 void GetRowLabelAlignment( int *horiz, int *vert );
1088 void GetColLabelAlignment( int *horiz, int *vert );
1089 wxString GetRowLabelValue( int row );
1090 wxString GetColLabelValue( int col );
1091 wxColour GetGridLineColour() { return m_gridLineColour; }
1092
1093 void SetRowLabelSize( int width );
1094 void SetColLabelSize( int height );
1095 void SetLabelBackgroundColour( const wxColour& );
1096 void SetLabelTextColour( const wxColour& );
1097 void SetLabelFont( const wxFont& );
1098 void SetRowLabelAlignment( int horiz, int vert );
1099 void SetColLabelAlignment( int horiz, int vert );
1100 void SetRowLabelValue( int row, const wxString& );
1101 void SetColLabelValue( int col, const wxString& );
1102 void SetGridLineColour( const wxColour& );
1103
1104 void EnableDragRowSize( bool enable = TRUE );
1105 void DisableDragRowSize() { EnableDragRowSize( FALSE ); }
1106 bool CanDragRowSize() { return m_canDragRowSize; }
1107 void EnableDragColSize( bool enable = TRUE );
1108 void DisableDragColSize() { EnableDragColSize( FALSE ); }
1109 bool CanDragColSize() { return m_canDragColSize; }
1110 void EnableDragGridSize(bool enable = TRUE);
1111 void DisableDragGridSize() { EnableDragGridSize(FALSE); }
1112 bool CanDragGridSize() { return m_canDragGridSize; }
1113
1114 // this sets the specified attribute for all cells in this row/col
1115 void SetRowAttr(int row, wxGridCellAttr *attr);
1116 void SetColAttr(int col, wxGridCellAttr *attr);
1117
1118 // shortcuts for setting the column parameters
1119
1120 // set the format for the data in the column: default is string
1121 void SetColFormatBool(int col);
1122 void SetColFormatNumber(int col);
1123 void SetColFormatFloat(int col, int width = -1, int precision = -1);
1124 void SetColFormatCustom(int col, const wxString& typeName);
1125
1126 void EnableGridLines( bool enable = TRUE );
1127 bool GridLinesEnabled() { return m_gridLinesEnabled; }
1128
1129 // ------ row and col formatting
1130 //
1131 int GetDefaultRowSize();
1132 int GetRowSize( int row );
1133 int GetDefaultColSize();
1134 int GetColSize( int col );
1135 wxColour GetDefaultCellBackgroundColour();
1136 wxColour GetCellBackgroundColour( int row, int col );
1137 wxColour GetDefaultCellTextColour();
1138 wxColour GetCellTextColour( int row, int col );
1139 wxFont GetDefaultCellFont();
1140 wxFont GetCellFont( int row, int col );
1141 void GetDefaultCellAlignment( int *horiz, int *vert );
1142 void GetCellAlignment( int row, int col, int *horiz, int *vert );
1143
1144 void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE );
1145 void SetRowSize( int row, int height );
1146 void SetDefaultColSize( int width, bool resizeExistingCols = FALSE );
1147
1148 void SetColSize( int col, int width );
1149
1150 // automatically size the column or row to fit to its contents, if
1151 // setAsMin is TRUE, this optimal width will also be set as minimal width
1152 // for this column
1153 void AutoSizeColumn( int col, bool setAsMin = TRUE )
1154 { AutoSizeColOrRow(col, setAsMin, TRUE); }
1155 void AutoSizeRow( int row, bool setAsMin = TRUE )
1156 { AutoSizeColOrRow(row, setAsMin, FALSE); }
1157
1158 // auto size all columns (very ineffective for big grids!)
1159 void AutoSizeColumns( bool setAsMin = TRUE )
1160 { (void)SetOrCalcColumnSizes(FALSE, setAsMin); }
1161
1162 void AutoSizeRows( bool setAsMin = TRUE )
1163 { (void)SetOrCalcRowSizes(FALSE, setAsMin); }
1164
1165 // auto size the grid, that is make the columns/rows of the "right" size
1166 // and also set the grid size to just fit its contents
1167 void AutoSize();
1168
1169 // column won't be resized to be lesser width - this must be called during
1170 // the grid creation because it won't resize the column if it's already
1171 // narrower than the minimal width
1172 void SetColMinimalWidth( int col, int width );
1173 void SetRowMinimalHeight( int row, int width );
1174
1175 void SetDefaultCellBackgroundColour( const wxColour& );
1176 void SetCellBackgroundColour( int row, int col, const wxColour& );
1177 void SetDefaultCellTextColour( const wxColour& );
1178
1179 void SetCellTextColour( int row, int col, const wxColour& );
1180 void SetDefaultCellFont( const wxFont& );
1181 void SetCellFont( int row, int col, const wxFont& );
1182 void SetDefaultCellAlignment( int horiz, int vert );
1183 void SetCellAlignment( int row, int col, int horiz, int vert );
1184
1185 // takes ownership of the pointer
1186 void SetDefaultRenderer(wxGridCellRenderer *renderer);
1187 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
1188 wxGridCellRenderer *GetDefaultRenderer() const;
1189 wxGridCellRenderer* GetCellRenderer(int row, int col);
1190
1191 // takes ownership of the pointer
1192 void SetDefaultEditor(wxGridCellEditor *editor);
1193 void SetCellEditor(int row, int col, wxGridCellEditor *editor);
1194 wxGridCellEditor *GetDefaultEditor() const;
1195 wxGridCellEditor* GetCellEditor(int row, int col);
1196
1197
1198
1199 // ------ cell value accessors
1200 //
1201 wxString GetCellValue( int row, int col )
1202 {
1203 if ( m_table )
1204 {
1205 return m_table->GetValue( row, col );
1206 }
1207 else
1208 {
1209 return wxEmptyString;
1210 }
1211 }
1212
1213 wxString GetCellValue( const wxGridCellCoords& coords )
1214 { return GetCellValue( coords.GetRow(), coords.GetCol() ); }
1215
1216 void SetCellValue( int row, int col, const wxString& s );
1217 void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
1218 { SetCellValue( coords.GetRow(), coords.GetCol(), s ); }
1219
1220 // returns TRUE if the cell can't be edited
1221 bool IsReadOnly(int row, int col) const;
1222
1223 // make the cell editable/readonly
1224 void SetReadOnly(int row, int col, bool isReadOnly = TRUE);
1225
1226 // ------ selections of blocks of cells
1227 //
1228 void SelectRow( int row, bool addToSelected = FALSE );
1229 void SelectCol( int col, bool addToSelected = FALSE );
1230
1231 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol );
1232
1233 void SelectBlock( const wxGridCellCoords& topLeft,
1234 const wxGridCellCoords& bottomRight )
1235 { SelectBlock( topLeft.GetRow(), topLeft.GetCol(),
1236 bottomRight.GetRow(), bottomRight.GetCol() ); }
1237
1238 void SelectAll();
1239
1240 bool IsSelection()
1241 { return ( m_selectedTopLeft != wxGridNoCellCoords &&
1242 m_selectedBottomRight != wxGridNoCellCoords );
1243 }
1244
1245 void ClearSelection();
1246
1247 bool IsInSelection( int row, int col )
1248 { return ( IsSelection() &&
1249 row >= m_selectedTopLeft.GetRow() &&
1250 col >= m_selectedTopLeft.GetCol() &&
1251 row <= m_selectedBottomRight.GetRow() &&
1252 col <= m_selectedBottomRight.GetCol() );
1253 }
1254
1255 bool IsInSelection( const wxGridCellCoords& coords )
1256 { return IsInSelection( coords.GetRow(), coords.GetCol() ); }
1257
1258 void GetSelection( int* topRow, int* leftCol, int* bottomRow, int* rightCol )
1259 {
1260 // these will all be -1 if there is no selected block
1261 //
1262 *topRow = m_selectedTopLeft.GetRow();
1263 *leftCol = m_selectedTopLeft.GetCol();
1264 *bottomRow = m_selectedBottomRight.GetRow();
1265 *rightCol = m_selectedBottomRight.GetCol();
1266 }
1267
1268
1269 // This function returns the rectangle that encloses the block of cells
1270 // limited by TopLeft and BottomRight cell in device coords and clipped
1271 // to the client size of the grid window.
1272 //
1273 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
1274 const wxGridCellCoords & bottomRight );
1275
1276 // This function returns the rectangle that encloses the selected cells
1277 // in device coords and clipped to the client size of the grid window.
1278 //
1279 wxRect SelectionToDeviceRect()
1280 {
1281 return BlockToDeviceRect( m_selectedTopLeft,
1282 m_selectedBottomRight );
1283 }
1284
1285 // Access or update the selection fore/back colours
1286 wxColour GetSelectionBackground() const
1287 { return m_selectionBackground; }
1288 wxColour GetSelectionForeground() const
1289 { return m_selectionForeground; }
1290
1291 void SetSelectionBackground(const wxColour& c) { m_selectionBackground = c; }
1292 void SetSelectionForeground(const wxColour& c) { m_selectionForeground = c; }
1293
1294
1295 // Methods for a registry for mapping data types to Renderers/Editors
1296 void RegisterDataType(const wxString& typeName,
1297 wxGridCellRenderer* renderer,
1298 wxGridCellEditor* editor);
1299 wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
1300 wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
1301 { return GetDefaultEditorForCell(c.GetRow(), c.GetCol()); }
1302 wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
1303 wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
1304 wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
1305
1306 // grid may occupy more space than needed for its rows/columns, this
1307 // function allows to set how big this extra space is
1308 void SetMargins(int extraWidth, int extraHeight)
1309 {
1310 m_extraWidth = extraWidth;
1311 m_extraHeight = extraHeight;
1312 }
1313
1314 // ------ For compatibility with previous wxGrid only...
1315 //
1316 // ************************************************
1317 // ** Don't use these in new code because they **
1318 // ** are liable to disappear in a future **
1319 // ** revision **
1320 // ************************************************
1321 //
1322
1323 wxGrid( wxWindow *parent,
1324 int x, int y, int w = -1, int h = -1,
1325 long style = wxWANTS_CHARS,
1326 const wxString& name = wxPanelNameStr )
1327 : wxScrolledWindow( parent, -1, wxPoint(x,y), wxSize(w,h),
1328 (style|wxWANTS_CHARS), name )
1329 {
1330 Create();
1331 }
1332
1333 void SetCellValue( const wxString& val, int row, int col )
1334 { SetCellValue( row, col, val ); }
1335
1336 void UpdateDimensions()
1337 { CalcDimensions(); }
1338
1339 int GetRows() { return GetNumberRows(); }
1340 int GetCols() { return GetNumberCols(); }
1341 int GetCursorRow() { return GetGridCursorRow(); }
1342 int GetCursorColumn() { return GetGridCursorCol(); }
1343
1344 int GetScrollPosX() { return 0; }
1345 int GetScrollPosY() { return 0; }
1346
1347 void SetScrollX( int x ) { }
1348 void SetScrollY( int y ) { }
1349
1350 void SetColumnWidth( int col, int width )
1351 { SetColSize( col, width ); }
1352
1353 int GetColumnWidth( int col )
1354 { return GetColSize( col ); }
1355
1356 void SetRowHeight( int row, int height )
1357 { SetRowSize( row, height ); }
1358
1359 // GetRowHeight() is below
1360
1361 int GetViewHeight() // returned num whole rows visible
1362 { return 0; }
1363
1364 int GetViewWidth() // returned num whole cols visible
1365 { return 0; }
1366
1367 void SetLabelSize( int orientation, int sz )
1368 {
1369 if ( orientation == wxHORIZONTAL )
1370 SetColLabelSize( sz );
1371 else
1372 SetRowLabelSize( sz );
1373 }
1374
1375 int GetLabelSize( int orientation )
1376 {
1377 if ( orientation == wxHORIZONTAL )
1378 return GetColLabelSize();
1379 else
1380 return GetRowLabelSize();
1381 }
1382
1383 void SetLabelAlignment( int orientation, int align )
1384 {
1385 if ( orientation == wxHORIZONTAL )
1386 SetColLabelAlignment( align, -1 );
1387 else
1388 SetRowLabelAlignment( align, -1 );
1389 }
1390
1391 int GetLabelAlignment( int orientation, int WXUNUSED(align) )
1392 {
1393 int h, v;
1394 if ( orientation == wxHORIZONTAL )
1395 {
1396 GetColLabelAlignment( &h, &v );
1397 return h;
1398 }
1399 else
1400 {
1401 GetRowLabelAlignment( &h, &v );
1402 return h;
1403 }
1404 }
1405
1406 void SetLabelValue( int orientation, const wxString& val, int pos )
1407 {
1408 if ( orientation == wxHORIZONTAL )
1409 SetColLabelValue( pos, val );
1410 else
1411 SetRowLabelValue( pos, val );
1412 }
1413
1414 wxString GetLabelValue( int orientation, int pos)
1415 {
1416 if ( orientation == wxHORIZONTAL )
1417 return GetColLabelValue( pos );
1418 else
1419 return GetRowLabelValue( pos );
1420 }
1421
1422 wxFont GetCellTextFont() const
1423 { return m_defaultCellAttr->GetFont(); }
1424
1425 wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const
1426 { return m_defaultCellAttr->GetFont(); }
1427
1428 void SetCellTextFont(const wxFont& fnt)
1429 { SetDefaultCellFont( fnt ); }
1430
1431 void SetCellTextFont(const wxFont& fnt, int row, int col)
1432 { SetCellFont( row, col, fnt ); }
1433
1434 void SetCellTextColour(const wxColour& val, int row, int col)
1435 { SetCellTextColour( row, col, val ); }
1436
1437 void SetCellTextColour(const wxColour& col)
1438 { SetDefaultCellTextColour( col ); }
1439
1440 void SetCellBackgroundColour(const wxColour& col)
1441 { SetDefaultCellBackgroundColour( col ); }
1442
1443 void SetCellBackgroundColour(const wxColour& colour, int row, int col)
1444 { SetCellBackgroundColour( row, col, colour ); }
1445
1446 bool GetEditable() { return IsEditable(); }
1447 void SetEditable( bool edit = TRUE ) { EnableEditing( edit ); }
1448 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1449
1450 void SetEditInPlace(bool edit = TRUE) { }
1451
1452 void SetCellAlignment( int align, int row, int col)
1453 { SetCellAlignment(row, col, align, wxCENTER); }
1454 void SetCellAlignment( int WXUNUSED(align) ) {}
1455 void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col))
1456 { }
1457 void SetDividerPen(const wxPen& WXUNUSED(pen)) { }
1458 wxPen& GetDividerPen() const { return wxNullPen; }
1459 void OnActivate(bool WXUNUSED(active)) {}
1460
1461 // ******** End of compatibility functions **********
1462
1463
1464
1465 // ------ control IDs
1466 enum { wxGRID_CELLCTRL = 2000,
1467 wxGRID_TOPCTRL };
1468
1469 // ------ control types
1470 enum { wxGRID_TEXTCTRL = 2100,
1471 wxGRID_CHECKBOX,
1472 wxGRID_CHOICE,
1473 wxGRID_COMBOBOX };
1474
1475 // overridden wxWindow methods
1476 virtual void Fit();
1477
1478 protected:
1479 virtual wxSize DoGetBestSize() const;
1480
1481 bool m_created;
1482 bool m_displayed;
1483
1484 wxGridWindow *m_gridWin;
1485 wxGridRowLabelWindow *m_rowLabelWin;
1486 wxGridColLabelWindow *m_colLabelWin;
1487 wxGridCornerLabelWindow *m_cornerLabelWin;
1488
1489 wxGridTableBase *m_table;
1490 bool m_ownTable;
1491
1492 int m_left;
1493 int m_top;
1494 int m_right;
1495 int m_bottom;
1496
1497 int m_numRows;
1498 int m_numCols;
1499
1500 wxGridCellCoords m_currentCellCoords;
1501
1502 wxGridCellCoords m_selectedTopLeft;
1503 wxGridCellCoords m_selectedBottomRight;
1504 wxColour m_selectionBackground;
1505 wxColour m_selectionForeground;
1506
1507 // NB: *never* access m_row/col arrays directly because they are created
1508 // on demand, *always* use accessor functions instead!
1509
1510 // init the m_rowHeights/Bottoms arrays with default values
1511 void InitRowHeights();
1512
1513 int m_defaultRowHeight;
1514 wxArrayInt m_rowHeights;
1515 wxArrayInt m_rowBottoms;
1516
1517 // init the m_colWidths/Rights arrays
1518 void InitColWidths();
1519
1520 int m_defaultColWidth;
1521 wxArrayInt m_colWidths;
1522 wxArrayInt m_colRights;
1523
1524 // get the col/row coords
1525 int GetColWidth(int col) const;
1526 int GetColLeft(int col) const;
1527 int GetColRight(int col) const;
1528
1529 // this function must be public for compatibility...
1530 public:
1531 int GetRowHeight(int row) const;
1532 protected:
1533
1534 int GetRowTop(int row) const;
1535 int GetRowBottom(int row) const;
1536
1537 int m_rowLabelWidth;
1538 int m_colLabelHeight;
1539
1540 // the size of the margin left to the right and bottom of the cell area
1541 int m_extraWidth,
1542 m_extraHeight;
1543
1544 wxColour m_labelBackgroundColour;
1545 wxColour m_labelTextColour;
1546 wxFont m_labelFont;
1547
1548 int m_rowLabelHorizAlign;
1549 int m_rowLabelVertAlign;
1550 int m_colLabelHorizAlign;
1551 int m_colLabelVertAlign;
1552
1553 bool m_defaultRowLabelValues;
1554 bool m_defaultColLabelValues;
1555
1556 wxColour m_gridLineColour;
1557 bool m_gridLinesEnabled;
1558
1559 // common part of AutoSizeColumn/Row() and GetBestSize()
1560 int SetOrCalcColumnSizes(bool calcOnly, bool setAsMin = TRUE);
1561 int SetOrCalcRowSizes(bool calcOnly, bool setAsMin = TRUE);
1562
1563 // common part of AutoSizeColumn/Row()
1564 void AutoSizeColOrRow(int n, bool setAsMin, bool column /* or row? */);
1565
1566 // if a column has a minimal width, it will be the value for it in this
1567 // hash table
1568 wxHashTableLong m_colMinWidths,
1569 m_rowMinHeights;
1570
1571 // get the minimal width of the given column/row
1572 int GetColMinimalWidth(int col) const;
1573 int GetRowMinimalHeight(int col) const;
1574
1575 // do we have some place to store attributes in?
1576 bool CanHaveAttributes();
1577
1578 // returns the attribute we may modify in place: a new one if this cell
1579 // doesn't have any yet or the existing one if it does
1580 //
1581 // DecRef() must be called on the returned pointer, as usual
1582 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
1583
1584 // cell attribute cache (currently we only cache 1, may be will do
1585 // more/better later)
1586 struct CachedAttr
1587 {
1588 int row, col;
1589 wxGridCellAttr *attr;
1590 } m_attrCache;
1591
1592 // invalidates the attribute cache
1593 void ClearAttrCache();
1594
1595 // adds an attribute to cache
1596 void CacheAttr(int row, int col, wxGridCellAttr *attr) const;
1597
1598 // looks for an attr in cache, returns TRUE if found
1599 bool LookupAttr(int row, int col, wxGridCellAttr **attr) const;
1600
1601 // looks for the attr in cache, if not found asks the table and caches the
1602 // result
1603 wxGridCellAttr *GetCellAttr(int row, int col) const;
1604 wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords )
1605 { return GetCellAttr( coords.GetRow(), coords.GetCol() ); }
1606
1607 // the default cell attr object for cells that don't have their own
1608 wxGridCellAttr* m_defaultCellAttr;
1609
1610
1611 wxGridCellCoordsArray m_cellsExposed;
1612 wxArrayInt m_rowsExposed;
1613 wxArrayInt m_colsExposed;
1614 wxArrayInt m_rowLabelsExposed;
1615 wxArrayInt m_colLabelsExposed;
1616
1617 bool m_inOnKeyDown;
1618 int m_batchCount;
1619
1620
1621 wxGridTypeRegistry* m_typeRegistry;
1622
1623 enum CursorMode
1624 {
1625 WXGRID_CURSOR_SELECT_CELL,
1626 WXGRID_CURSOR_RESIZE_ROW,
1627 WXGRID_CURSOR_RESIZE_COL,
1628 WXGRID_CURSOR_SELECT_ROW,
1629 WXGRID_CURSOR_SELECT_COL
1630 };
1631
1632 // this method not only sets m_cursorMode but also sets the correct cursor
1633 // for the given mode and, if captureMouse is not FALSE releases the mouse
1634 // if it was captured and captures it if it must be captured
1635 //
1636 // for this to work, you should always use it and not set m_cursorMode
1637 // directly!
1638 void ChangeCursorMode(CursorMode mode,
1639 wxWindow *win = (wxWindow *)NULL,
1640 bool captureMouse = TRUE);
1641
1642 wxWindow *m_winCapture; // the window which captured the mouse
1643 CursorMode m_cursorMode;
1644
1645 bool m_canDragRowSize;
1646 bool m_canDragColSize;
1647 bool m_canDragGridSize;
1648 int m_dragLastPos;
1649 int m_dragRowOrCol;
1650 bool m_isDragging;
1651 wxPoint m_startDragPos;
1652
1653 bool m_waitForSlowClick;
1654
1655 wxGridCellCoords m_selectionStart;
1656
1657 wxCursor m_rowResizeCursor;
1658 wxCursor m_colResizeCursor;
1659
1660 bool m_editable; // applies to whole grid
1661 bool m_cellEditCtrlEnabled; // is in-place edit currently shown?
1662
1663
1664 void Create();
1665 void Init();
1666 void CalcDimensions();
1667 void CalcWindowSizes();
1668 bool Redimension( wxGridTableMessage& );
1669
1670
1671 bool SendEvent( const wxEventType, int row, int col, wxMouseEvent& );
1672 bool SendEvent( const wxEventType, int row, int col );
1673 bool SendEvent( const wxEventType type)
1674 {
1675 return SendEvent(type,
1676 m_currentCellCoords.GetRow(),
1677 m_currentCellCoords.GetCol());
1678 }
1679
1680 void OnPaint( wxPaintEvent& );
1681 void OnSize( wxSizeEvent& );
1682 void OnKeyDown( wxKeyEvent& );
1683 void OnEraseBackground( wxEraseEvent& );
1684
1685
1686 void SetCurrentCell( const wxGridCellCoords& coords );
1687 void SetCurrentCell( int row, int col )
1688 { SetCurrentCell( wxGridCellCoords(row, col) ); }
1689
1690
1691 // ------ functions to get/send data (see also public functions)
1692 //
1693 bool GetModelValues();
1694 bool SetModelValues();
1695
1696
1697 DECLARE_DYNAMIC_CLASS( wxGrid )
1698 DECLARE_EVENT_TABLE()
1699 };
1700
1701 // ----------------------------------------------------------------------------
1702 // Grid event class and event types
1703 // ----------------------------------------------------------------------------
1704
1705 class WXDLLEXPORT wxGridEvent : public wxNotifyEvent
1706 {
1707 public:
1708 wxGridEvent()
1709 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1710 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1711 {
1712 }
1713
1714 wxGridEvent(int id, wxEventType type, wxObject* obj,
1715 int row=-1, int col=-1, int x=-1, int y=-1,
1716 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1717
1718 virtual int GetRow() { return m_row; }
1719 virtual int GetCol() { return m_col; }
1720 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
1721 bool ControlDown() { return m_control; }
1722 bool MetaDown() { return m_meta; }
1723 bool ShiftDown() { return m_shift; }
1724 bool AltDown() { return m_alt; }
1725
1726 protected:
1727 int m_row;
1728 int m_col;
1729 int m_x;
1730 int m_y;
1731 bool m_control;
1732 bool m_meta;
1733 bool m_shift;
1734 bool m_alt;
1735
1736 DECLARE_DYNAMIC_CLASS(wxGridEvent)
1737 };
1738
1739 class WXDLLEXPORT wxGridSizeEvent : public wxNotifyEvent
1740 {
1741 public:
1742 wxGridSizeEvent()
1743 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1744 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1745 {
1746 }
1747
1748 wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
1749 int rowOrCol=-1, int x=-1, int y=-1,
1750 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1751
1752 int GetRowOrCol() { return m_rowOrCol; }
1753 wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
1754 bool ControlDown() { return m_control; }
1755 bool MetaDown() { return m_meta; }
1756 bool ShiftDown() { return m_shift; }
1757 bool AltDown() { return m_alt; }
1758
1759 protected:
1760 int m_rowOrCol;
1761 int m_x;
1762 int m_y;
1763 bool m_control;
1764 bool m_meta;
1765 bool m_shift;
1766 bool m_alt;
1767
1768 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent)
1769 };
1770
1771
1772 class WXDLLEXPORT wxGridRangeSelectEvent : public wxNotifyEvent
1773 {
1774 public:
1775 wxGridRangeSelectEvent()
1776 : wxNotifyEvent()
1777 {
1778 m_topLeft = wxGridNoCellCoords;
1779 m_bottomRight = wxGridNoCellCoords;
1780 m_control = FALSE;
1781 m_meta = FALSE;
1782 m_shift = FALSE;
1783 m_alt = FALSE;
1784 }
1785
1786 wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
1787 const wxGridCellCoords& topLeft,
1788 const wxGridCellCoords& bottomRight,
1789 bool control=FALSE, bool shift=FALSE,
1790 bool alt=FALSE, bool meta=FALSE);
1791
1792 wxGridCellCoords GetTopLeftCoords() { return m_topLeft; }
1793 wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; }
1794 int GetTopRow() { return m_topLeft.GetRow(); }
1795 int GetBottomRow() { return m_bottomRight.GetRow(); }
1796 int GetLeftCol() { return m_topLeft.GetCol(); }
1797 int GetRightCol() { return m_bottomRight.GetCol(); }
1798 bool ControlDown() { return m_control; }
1799 bool MetaDown() { return m_meta; }
1800 bool ShiftDown() { return m_shift; }
1801 bool AltDown() { return m_alt; }
1802
1803 protected:
1804 wxGridCellCoords m_topLeft;
1805 wxGridCellCoords m_bottomRight;
1806 bool m_control;
1807 bool m_meta;
1808 bool m_shift;
1809 bool m_alt;
1810
1811 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent)
1812 };
1813
1814 // TODO move to wx/event.h
1815 const wxEventType wxEVT_GRID_CELL_LEFT_CLICK = wxEVT_FIRST + 1580;
1816 const wxEventType wxEVT_GRID_CELL_RIGHT_CLICK = wxEVT_FIRST + 1581;
1817 const wxEventType wxEVT_GRID_CELL_LEFT_DCLICK = wxEVT_FIRST + 1582;
1818 const wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK = wxEVT_FIRST + 1583;
1819 const wxEventType wxEVT_GRID_LABEL_LEFT_CLICK = wxEVT_FIRST + 1584;
1820 const wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK = wxEVT_FIRST + 1585;
1821 const wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK = wxEVT_FIRST + 1586;
1822 const wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK = wxEVT_FIRST + 1587;
1823 const wxEventType wxEVT_GRID_ROW_SIZE = wxEVT_FIRST + 1588;
1824 const wxEventType wxEVT_GRID_COL_SIZE = wxEVT_FIRST + 1589;
1825 const wxEventType wxEVT_GRID_RANGE_SELECT = wxEVT_FIRST + 1590;
1826 const wxEventType wxEVT_GRID_CELL_CHANGE = wxEVT_FIRST + 1591;
1827 const wxEventType wxEVT_GRID_SELECT_CELL = wxEVT_FIRST + 1592;
1828 const wxEventType wxEVT_GRID_EDITOR_SHOWN = wxEVT_FIRST + 1593;
1829 const wxEventType wxEVT_GRID_EDITOR_HIDDEN = wxEVT_FIRST + 1594;
1830
1831
1832 typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&);
1833 typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&);
1834 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&);
1835
1836 #define EVT_GRID_CELL_LEFT_CLICK(fn) { wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1837 #define EVT_GRID_CELL_RIGHT_CLICK(fn) { wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1838 #define EVT_GRID_CELL_LEFT_DCLICK(fn) { wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1839 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) { wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1840 #define EVT_GRID_LABEL_LEFT_CLICK(fn) { wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1841 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) { wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1842 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) { wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1843 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) { wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1844 #define EVT_GRID_ROW_SIZE(fn) { wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1845 #define EVT_GRID_COL_SIZE(fn) { wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL },
1846 #define EVT_GRID_RANGE_SELECT(fn) { wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL },
1847 #define EVT_GRID_CELL_CHANGE(fn) { wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1848 #define EVT_GRID_SELECT_CELL(fn) { wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1849 #define EVT_GRID_EDITOR_SHOWN(fn) { wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1850 #define EVT_GRID_EDITOR_HIDDEN(fn) { wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1851
1852
1853 #if 0 // TODO: implement these ? others ?
1854
1855 const wxEventType wxEVT_GRID_CREATE_CELL = wxEVT_FIRST + 1576;
1856 const wxEventType wxEVT_GRID_CHANGE_LABELS = wxEVT_FIRST + 1577;
1857 const wxEventType wxEVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578;
1858
1859 #define EVT_GRID_CREATE_CELL(fn) { wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1860 #define EVT_GRID_CHANGE_LABELS(fn) { wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1861 #define EVT_GRID_CHANGE_SEL_LABEL(fn) { wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL },
1862
1863 #endif
1864
1865 #endif // #ifndef __WXGRID_H__
1866
1867 #endif // ifndef wxUSE_NEW_GRID
1868