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)
8 // Copyright: (c) Michael Bedward
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
15 #include "wx/generic/gridg.h"
22 #pragma interface "grid.h"
27 #include "wx/scrolwin.h"
28 #include "wx/string.h"
29 #include "wx/scrolbar.h"
31 #include "wx/combobox.h"
32 #include "wx/dynarray.h"
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 // Default parameters for wxGrid
41 #define WXGRID_DEFAULT_NUMBER_ROWS 10
42 #define WXGRID_DEFAULT_NUMBER_COLS 10
44 #define WXGRID_DEFAULT_ROW_HEIGHT 25
46 #define WXGRID_DEFAULT_ROW_HEIGHT 30
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 2
52 #define WXGRID_MIN_ROW_HEIGHT 15
53 #define WXGRID_MIN_COL_WIDTH 15
54 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
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 #define wxGRID_VALUE_CHOICE _T("choice")
63 #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
64 #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
66 // ----------------------------------------------------------------------------
67 // forward declarations
68 // ----------------------------------------------------------------------------
70 class WXDLLEXPORT wxGrid
;
71 class WXDLLEXPORT wxGridCellAttr
;
72 class WXDLLEXPORT wxGridCellAttrProviderData
;
73 class WXDLLEXPORT wxGridColLabelWindow
;
74 class WXDLLEXPORT wxGridCornerLabelWindow
;
75 class WXDLLEXPORT wxGridRowLabelWindow
;
76 class WXDLLEXPORT wxGridTableBase
;
77 class WXDLLEXPORT wxGridWindow
;
78 class WXDLLEXPORT wxGridTypeRegistry
;
79 class WXDLLEXPORT wxGridSelection
;
81 class WXDLLEXPORT wxCheckBox
;
82 class WXDLLEXPORT wxComboBox
;
83 class WXDLLEXPORT wxTextCtrl
;
84 class WXDLLEXPORT wxSpinCtrl
;
86 // ----------------------------------------------------------------------------
88 // ----------------------------------------------------------------------------
90 #define wxSafeIncRef(p) if ( p ) (p)->IncRef()
91 #define wxSafeDecRef(p) if ( p ) (p)->DecRef()
93 // ----------------------------------------------------------------------------
94 // wxGridCellWorker: common base class for wxGridCellRenderer and
97 // NB: this is more an implementation convenience than a design issue, so this
98 // class is not documented and is not public at all
99 // ----------------------------------------------------------------------------
101 class WXDLLEXPORT wxGridCellWorker
104 wxGridCellWorker() { m_nRef
= 1; }
106 // this class is ref counted: it is created with ref count of 1, so
107 // calling DecRef() once will delete it. Calling IncRef() allows to lock
108 // it until the matching DecRef() is called
109 void IncRef() { m_nRef
++; }
110 void DecRef() { if ( !--m_nRef
) delete this; }
112 // interpret renderer parameters: arbitrary string whose interpretatin is
113 // left to the derived classes
114 virtual void SetParameters(const wxString
& params
);
117 // virtual dtor for any base class - private because only DecRef() can
119 virtual ~wxGridCellWorker();
124 // suppress the stupid gcc warning about the class having private dtor and
126 friend class wxGridCellWorkerDummyFriend
;
129 // ----------------------------------------------------------------------------
130 // wxGridCellRenderer: this class is responsible for actually drawing the cell
131 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
132 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
133 // view of all cells. This is an ABC, you will normally use one of the
134 // predefined derived classes or derive your own class from it.
135 // ----------------------------------------------------------------------------
137 class WXDLLEXPORT wxGridCellRenderer
: public wxGridCellWorker
140 // draw the given cell on the provided DC inside the given rectangle
141 // using the style specified by the attribute and the default or selected
142 // state corresponding to the isSelected value.
144 // this pure virtual function has a default implementation which will
145 // prepare the DC using the given attribute: it will draw the rectangle
146 // with the bg colour from attr and set the text colour and font
147 virtual void Draw(wxGrid
& grid
,
148 wxGridCellAttr
& attr
,
152 bool isSelected
) = 0;
154 // get the preferred size of the cell for its contents
155 virtual wxSize
GetBestSize(wxGrid
& grid
,
156 wxGridCellAttr
& attr
,
158 int row
, int col
) = 0;
160 // create a new object which is the copy of this one
161 virtual wxGridCellRenderer
*Clone() const = 0;
164 // the default renderer for the cells containing string data
165 class WXDLLEXPORT wxGridCellStringRenderer
: public wxGridCellRenderer
169 virtual void Draw(wxGrid
& grid
,
170 wxGridCellAttr
& attr
,
176 // return the string extent
177 virtual wxSize
GetBestSize(wxGrid
& grid
,
178 wxGridCellAttr
& attr
,
182 virtual wxGridCellRenderer
*Clone() const
183 { return new wxGridCellStringRenderer
; }
186 // set the text colours before drawing
187 void SetTextColoursAndFont(wxGrid
& grid
,
188 wxGridCellAttr
& attr
,
192 // calc the string extent for given string/font
193 wxSize
DoGetBestSize(wxGridCellAttr
& attr
,
195 const wxString
& text
);
198 // the default renderer for the cells containing numeric (long) data
199 class WXDLLEXPORT wxGridCellNumberRenderer
: public wxGridCellStringRenderer
202 // draw the string right aligned
203 virtual void Draw(wxGrid
& grid
,
204 wxGridCellAttr
& attr
,
210 virtual wxSize
GetBestSize(wxGrid
& grid
,
211 wxGridCellAttr
& attr
,
215 virtual wxGridCellRenderer
*Clone() const
216 { return new wxGridCellNumberRenderer
; }
219 wxString
GetString(wxGrid
& grid
, int row
, int col
);
222 class WXDLLEXPORT wxGridCellFloatRenderer
: public wxGridCellStringRenderer
225 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
227 // get/change formatting parameters
228 int GetWidth() const { return m_width
; }
229 void SetWidth(int width
) { m_width
= width
; m_format
.clear(); }
230 int GetPrecision() const { return m_precision
; }
231 void SetPrecision(int precision
) { m_precision
= precision
; m_format
.clear(); }
233 // draw the string right aligned with given width/precision
234 virtual void Draw(wxGrid
& grid
,
235 wxGridCellAttr
& attr
,
241 virtual wxSize
GetBestSize(wxGrid
& grid
,
242 wxGridCellAttr
& attr
,
246 // parameters string format is "width[,precision]"
247 virtual void SetParameters(const wxString
& params
);
249 virtual wxGridCellRenderer
*Clone() const;
252 wxString
GetString(wxGrid
& grid
, int row
, int col
);
255 // formatting parameters
262 // renderer for boolean fields
263 class WXDLLEXPORT wxGridCellBoolRenderer
: public wxGridCellRenderer
266 // draw a check mark or nothing
267 virtual void Draw(wxGrid
& grid
,
268 wxGridCellAttr
& attr
,
274 // return the checkmark size
275 virtual wxSize
GetBestSize(wxGrid
& grid
,
276 wxGridCellAttr
& attr
,
280 virtual wxGridCellRenderer
*Clone() const
281 { return new wxGridCellBoolRenderer
; }
284 static wxSize ms_sizeCheckMark
;
287 // ----------------------------------------------------------------------------
288 // wxGridCellEditor: This class is responsible for providing and manipulating
289 // the in-place edit controls for the grid. Instances of wxGridCellEditor
290 // (actually, instances of derived classes since it is an ABC) can be
291 // associated with the cell attributes for individual cells, rows, columns, or
292 // even for the entire grid.
293 // ----------------------------------------------------------------------------
295 class WXDLLEXPORT wxGridCellEditor
: public wxGridCellWorker
300 bool IsCreated() { return m_control
!= NULL
; }
301 wxControl
* GetControl() { return m_control
; }
302 void SetControl(wxControl
* control
) { m_control
= control
; }
304 // Creates the actual edit control
305 virtual void Create(wxWindow
* parent
,
307 wxEvtHandler
* evtHandler
) = 0;
309 // Size and position the edit control
310 virtual void SetSize(const wxRect
& rect
);
312 // Show or hide the edit control, use the specified attributes to set
313 // colours/fonts for it
314 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
316 // Draws the part of the cell not occupied by the control: the base class
317 // version just fills it with background colour from the attribute
318 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
320 // Fetch the value from the table and prepare the edit control
321 // to begin editing. Set the focus to the edit control.
322 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
324 // Complete the editing of the current cell. Returns true if the value has
325 // changed. If necessary, the control may be destroyed.
326 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
) = 0;
328 // Reset the value in the control back to its starting value
329 virtual void Reset() = 0;
331 // return TRUE to allow the given key to start editing: the base class
332 // version only checks that the event has no modifiers. The derived
333 // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in
334 // their IsAcceptedKey() implementation, although, of course, it is not a
335 // mandatory requirment.
337 // NB: if the key is F2 (special), editing will always start and this
338 // method will not be called at all (but StartingKey() will)
339 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
341 // If the editor is enabled by pressing keys on the grid, this will be
342 // called to let the editor do something about that first key if desired
343 virtual void StartingKey(wxKeyEvent
& event
);
345 // if the editor is enabled by clicking on the cell, this method will be
347 virtual void StartingClick();
349 // Some types of controls on some platforms may need some help
350 // with the Return key.
351 virtual void HandleReturn(wxKeyEvent
& event
);
354 virtual void Destroy();
356 // create a new object which is the copy of this one
357 virtual wxGridCellEditor
*Clone() const = 0;
360 // the dtor is private because only DecRef() can delete us
361 virtual ~wxGridCellEditor();
363 // the control we show on screen
364 wxControl
* m_control
;
366 // if we change the colours/font of the control from the default ones, we
367 // must restore the default later and we save them here between calls to
368 // Show(TRUE) and Show(FALSE)
373 // suppress the stupid gcc warning about the class having private dtor and
375 friend class wxGridCellEditorDummyFriend
;
380 // the editor for string/text data
381 class WXDLLEXPORT wxGridCellTextEditor
: public wxGridCellEditor
384 wxGridCellTextEditor();
386 virtual void Create(wxWindow
* parent
,
388 wxEvtHandler
* evtHandler
);
389 virtual void SetSize(const wxRect
& rect
);
391 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
393 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
394 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
395 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
397 virtual void Reset();
398 virtual void StartingKey(wxKeyEvent
& event
);
399 virtual void HandleReturn(wxKeyEvent
& event
);
401 // parameters string format is "max_width"
402 virtual void SetParameters(const wxString
& params
);
404 virtual wxGridCellEditor
*Clone() const
405 { return new wxGridCellTextEditor
; }
408 wxTextCtrl
*Text() const { return (wxTextCtrl
*)m_control
; }
410 // parts of our virtual functions reused by the derived classes
411 void DoBeginEdit(const wxString
& startValue
);
412 void DoReset(const wxString
& startValue
);
415 size_t m_maxChars
; // max number of chars allowed
416 wxString m_startValue
;
419 // the editor for numeric (long) data
420 class WXDLLEXPORT wxGridCellNumberEditor
: public wxGridCellTextEditor
423 // allows to specify the range - if min == max == -1, no range checking is
425 wxGridCellNumberEditor(int min
= -1, int max
= -1);
427 virtual void Create(wxWindow
* parent
,
429 wxEvtHandler
* evtHandler
);
431 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
432 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
433 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
435 virtual void Reset();
436 virtual void StartingKey(wxKeyEvent
& event
);
438 // parameters string format is "min,max"
439 virtual void SetParameters(const wxString
& params
);
441 virtual wxGridCellEditor
*Clone() const
442 { return new wxGridCellNumberEditor(m_min
, m_max
); }
445 wxSpinCtrl
*Spin() const { return (wxSpinCtrl
*)m_control
; }
447 // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
448 bool HasRange() const { return m_min
!= m_max
; }
450 // string representation of m_valueOld
451 wxString
GetString() const
452 { return wxString::Format(_T("%ld"), m_valueOld
); }
461 // the editor for floating point numbers (double) data
462 class WXDLLEXPORT wxGridCellFloatEditor
: public wxGridCellTextEditor
465 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
467 virtual void Create(wxWindow
* parent
,
469 wxEvtHandler
* evtHandler
);
471 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
472 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
473 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
475 virtual void Reset();
476 virtual void StartingKey(wxKeyEvent
& event
);
478 virtual wxGridCellEditor
*Clone() const
479 { return new wxGridCellFloatEditor
; }
481 // parameters string format is "width,precision"
482 virtual void SetParameters(const wxString
& params
);
485 // string representation of m_valueOld
486 wxString
GetString() const;
494 #endif // wxUSE_TEXTCTRL
498 // the editor for boolean data
499 class WXDLLEXPORT wxGridCellBoolEditor
: public wxGridCellEditor
502 virtual void Create(wxWindow
* parent
,
504 wxEvtHandler
* evtHandler
);
506 virtual void SetSize(const wxRect
& rect
);
507 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
509 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
510 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
511 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
513 virtual void Reset();
514 virtual void StartingClick();
516 virtual wxGridCellEditor
*Clone() const
517 { return new wxGridCellBoolEditor
; }
520 wxCheckBox
*CBox() const { return (wxCheckBox
*)m_control
; }
526 #endif // wxUSE_CHECKBOX
530 // the editor for string data allowing to choose from the list of strings
531 class WXDLLEXPORT wxGridCellChoiceEditor
: public wxGridCellEditor
534 // if !allowOthers, user can't type a string not in choices array
535 wxGridCellChoiceEditor(size_t count
= 0,
536 const wxString choices
[] = NULL
,
537 bool allowOthers
= FALSE
);
539 virtual void Create(wxWindow
* parent
,
541 wxEvtHandler
* evtHandler
);
543 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
545 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
546 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
548 virtual void Reset();
550 // parameters string format is "item1[,item2[...,itemN]]"
551 virtual void SetParameters(const wxString
& params
);
553 virtual wxGridCellEditor
*Clone() const;
556 wxComboBox
*Combo() const { return (wxComboBox
*)m_control
; }
559 wxString m_startValue
;
560 wxArrayString m_choices
;
564 #endif // wxUSE_COMBOBOX
566 // ----------------------------------------------------------------------------
567 // wxGridCellAttr: this class can be used to alter the cells appearance in
568 // the grid by changing their colour/font/... from default. An object of this
569 // class may be returned by wxGridTable::GetAttr().
570 // ----------------------------------------------------------------------------
572 class WXDLLEXPORT wxGridCellAttr
589 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
590 SetAlignment(-1, -1);
593 // VZ: considering the number of members wxGridCellAttr has now, this ctor
594 // seems to be pretty useless... may be we should just remove it?
595 wxGridCellAttr(const wxColour
& colText
,
596 const wxColour
& colBack
,
600 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
603 SetAlignment(hAlign
, vAlign
);
606 // creates a new copy of this object
607 wxGridCellAttr
*Clone() const;
608 void MergeWith(wxGridCellAttr
*mergefrom
);
610 // this class is ref counted: it is created with ref count of 1, so
611 // calling DecRef() once will delete it. Calling IncRef() allows to lock
612 // it until the matching DecRef() is called
613 void IncRef() { m_nRef
++; }
614 void DecRef() { if ( !--m_nRef
) delete this; }
617 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
618 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
619 void SetFont(const wxFont
& font
) { m_font
= font
; }
620 void SetAlignment(int hAlign
, int vAlign
)
625 void SetReadOnly(bool isReadOnly
= TRUE
)
626 { m_isReadOnly
= isReadOnly
? ReadOnly
: ReadWrite
; }
628 // takes ownership of the pointer
629 void SetRenderer(wxGridCellRenderer
*renderer
)
630 { wxSafeDecRef(m_renderer
); m_renderer
= renderer
; }
631 void SetEditor(wxGridCellEditor
* editor
)
632 { wxSafeDecRef(m_editor
); m_editor
= editor
; }
634 void SetKind(wxAttrKind kind
) { m_attrkind
= kind
; }
637 bool HasTextColour() const { return m_colText
.Ok(); }
638 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
639 bool HasFont() const { return m_font
.Ok(); }
640 bool HasAlignment() const { return (m_hAlign
!= -1 || m_vAlign
!= -1); }
641 bool HasRenderer() const { return m_renderer
!= NULL
; }
642 bool HasEditor() const { return m_editor
!= NULL
; }
643 bool HasReadWriteMode() const { return m_isReadOnly
!= Unset
; }
645 const wxColour
& GetTextColour() const;
646 const wxColour
& GetBackgroundColour() const;
647 const wxFont
& GetFont() const;
648 void GetAlignment(int *hAlign
, int *vAlign
) const;
649 wxGridCellRenderer
*GetRenderer(wxGrid
* grid
, int row
, int col
) const;
650 wxGridCellEditor
*GetEditor(wxGrid
* grid
, int row
, int col
) const;
652 bool IsReadOnly() const { return m_isReadOnly
== wxGridCellAttr::ReadOnly
; }
654 wxAttrKind
GetKind() { return m_attrkind
; }
656 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
666 // the common part of all ctors
671 m_isReadOnly
= Unset
;
676 m_attrkind
= wxGridCellAttr::Cell
;
679 // the dtor is private because only DecRef() can delete us
682 wxSafeDecRef(m_renderer
);
683 wxSafeDecRef(m_editor
);
686 // the ref count - when it goes to 0, we die
695 wxGridCellRenderer
* m_renderer
;
696 wxGridCellEditor
* m_editor
;
697 wxGridCellAttr
* m_defGridAttr
;
699 wxAttrReadMode m_isReadOnly
;
701 wxAttrKind m_attrkind
;
703 // use Clone() instead
704 DECLARE_NO_COPY_CLASS(wxGridCellAttr
)
706 // suppress the stupid gcc warning about the class having private dtor and
708 friend class wxGridCellAttrDummyFriend
;
711 // ----------------------------------------------------------------------------
712 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
714 // ----------------------------------------------------------------------------
716 // implementation note: we separate it from wxGridTableBase because we wish to
717 // avoid deriving a new table class if possible, and sometimes it will be
718 // enough to just derive another wxGridCellAttrProvider instead
720 // the default implementation is reasonably efficient for the generic case,
721 // but you might still wish to implement your own for some specific situations
722 // if you have performance problems with the stock one
723 class WXDLLEXPORT wxGridCellAttrProvider
726 wxGridCellAttrProvider();
727 virtual ~wxGridCellAttrProvider();
729 // DecRef() must be called on the returned pointer
730 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
731 wxGridCellAttr::wxAttrKind kind
) const;
733 // all these functions take ownership of the pointer, don't call DecRef()
735 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
736 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
737 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
739 // these functions must be called whenever some rows/cols are deleted
740 // because the internal data must be updated then
741 void UpdateAttrRows( size_t pos
, int numRows
);
742 void UpdateAttrCols( size_t pos
, int numCols
);
747 wxGridCellAttrProviderData
*m_data
;
750 //////////////////////////////////////////////////////////////////////
752 // Grid table classes
754 //////////////////////////////////////////////////////////////////////
757 class WXDLLEXPORT wxGridTableBase
: public wxObject
761 virtual ~wxGridTableBase();
763 // You must override these functions in a derived table class
765 virtual int GetNumberRows() = 0;
766 virtual int GetNumberCols() = 0;
767 virtual bool IsEmptyCell( int row
, int col
) = 0;
768 virtual wxString
GetValue( int row
, int col
) = 0;
769 virtual void SetValue( int row
, int col
, const wxString
& value
) = 0;
771 // Data type determination and value access
772 virtual wxString
GetTypeName( int row
, int col
);
773 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
774 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
776 virtual long GetValueAsLong( int row
, int col
);
777 virtual double GetValueAsDouble( int row
, int col
);
778 virtual bool GetValueAsBool( int row
, int col
);
780 virtual void SetValueAsLong( int row
, int col
, long value
);
781 virtual void SetValueAsDouble( int row
, int col
, double value
);
782 virtual void SetValueAsBool( int row
, int col
, bool value
);
784 // For user defined types
785 virtual void* GetValueAsCustom( int row
, int col
, const wxString
& typeName
);
786 virtual void SetValueAsCustom( int row
, int col
, const wxString
& typeName
, void* value
);
789 // Overriding these is optional
791 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
792 virtual wxGrid
* GetView() const { return m_view
; }
794 virtual void Clear() {}
795 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
796 virtual bool AppendRows( size_t numRows
= 1 );
797 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
798 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
799 virtual bool AppendCols( size_t numCols
= 1 );
800 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
802 virtual wxString
GetRowLabelValue( int row
);
803 virtual wxString
GetColLabelValue( int col
);
804 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
805 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
807 // Attribute handling
810 // give us the attr provider to use - we take ownership of the pointer
811 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
813 // get the currently used attr provider (may be NULL)
814 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
816 // Does this table allow attributes? Default implementation creates
817 // a wxGridCellAttrProvider if necessary.
818 virtual bool CanHaveAttributes();
820 // by default forwarded to wxGridCellAttrProvider if any. May be
821 // overridden to handle attributes directly in the table.
822 virtual wxGridCellAttr
*GetAttr( int row
, int col
,
823 wxGridCellAttr::wxAttrKind kind
);
826 // these functions take ownership of the pointer
827 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
828 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
829 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
833 wxGridCellAttrProvider
*m_attrProvider
;
835 DECLARE_ABSTRACT_CLASS( wxGridTableBase
);
839 // ----------------------------------------------------------------------------
840 // wxGridTableMessage
841 // ----------------------------------------------------------------------------
843 // IDs for messages sent from grid table to view
845 enum wxGridTableRequest
847 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
848 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
849 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
850 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
851 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
852 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
853 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
854 wxGRIDTABLE_NOTIFY_COLS_DELETED
857 class WXDLLEXPORT wxGridTableMessage
860 wxGridTableMessage();
861 wxGridTableMessage( wxGridTableBase
*table
, int id
,
865 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
866 wxGridTableBase
* GetTableObject() const { return m_table
; }
867 void SetId( int id
) { m_id
= id
; }
868 int GetId() { return m_id
; }
869 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
870 int GetCommandInt() { return m_comInt1
; }
871 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
872 int GetCommandInt2() { return m_comInt2
; }
875 wxGridTableBase
*m_table
;
883 // ------ wxGridStringArray
884 // A 2-dimensional array of strings for data values
887 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString
, wxGridStringArray
);
891 // ------ wxGridStringTable
893 // Simplest type of data table for a grid for small tables of strings
894 // that are stored in memory
897 class WXDLLEXPORT wxGridStringTable
: public wxGridTableBase
901 wxGridStringTable( int numRows
, int numCols
);
902 ~wxGridStringTable();
904 // these are pure virtual in wxGridTableBase
908 wxString
GetValue( int row
, int col
);
909 void SetValue( int row
, int col
, const wxString
& s
);
910 bool IsEmptyCell( int row
, int col
);
912 // overridden functions from wxGridTableBase
915 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
916 bool AppendRows( size_t numRows
= 1 );
917 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
918 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
919 bool AppendCols( size_t numCols
= 1 );
920 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
922 void SetRowLabelValue( int row
, const wxString
& );
923 void SetColLabelValue( int col
, const wxString
& );
924 wxString
GetRowLabelValue( int row
);
925 wxString
GetColLabelValue( int col
);
928 wxGridStringArray m_data
;
930 // These only get used if you set your own labels, otherwise the
931 // GetRow/ColLabelValue functions return wxGridTableBase defaults
933 wxArrayString m_rowLabels
;
934 wxArrayString m_colLabels
;
936 DECLARE_DYNAMIC_CLASS( wxGridStringTable
)
941 // ============================================================================
943 // ============================================================================
945 // ----------------------------------------------------------------------------
946 // wxGridCellCoords: location of a cell in the grid
947 // ----------------------------------------------------------------------------
949 class WXDLLEXPORT wxGridCellCoords
952 wxGridCellCoords() { m_row
= m_col
= -1; }
953 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
955 // default copy ctor is ok
957 int GetRow() const { return m_row
; }
958 void SetRow( int n
) { m_row
= n
; }
959 int GetCol() const { return m_col
; }
960 void SetCol( int n
) { m_col
= n
; }
961 void Set( int row
, int col
) { m_row
= row
; m_col
= col
; }
963 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
965 if ( &other
!= this )
973 bool operator==( const wxGridCellCoords
& other
) const
975 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
978 bool operator!=( const wxGridCellCoords
& other
) const
980 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
983 bool operator!() const
985 return (m_row
== -1 && m_col
== -1 );
994 // For comparisons...
996 extern WXDLLEXPORT wxGridCellCoords wxGridNoCellCoords
;
997 extern WXDLLEXPORT wxRect wxGridNoCellRect
;
999 // An array of cell coords...
1001 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords
, wxGridCellCoordsArray
);
1003 // ----------------------------------------------------------------------------
1005 // ----------------------------------------------------------------------------
1007 class WXDLLEXPORT wxGrid
: public wxScrolledWindow
1015 wxGrid( wxWindow
*parent
,
1017 const wxPoint
& pos
= wxDefaultPosition
,
1018 const wxSize
& size
= wxDefaultSize
,
1019 long style
= wxWANTS_CHARS
,
1020 const wxString
& name
= wxPanelNameStr
);
1024 enum wxGridSelectionModes
{wxGridSelectCells
,
1026 wxGridSelectColumns
};
1028 bool CreateGrid( int numRows
, int numCols
,
1029 wxGrid::wxGridSelectionModes selmode
=
1030 wxGrid::wxGridSelectCells
);
1032 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
1034 // ------ grid dimensions
1036 int GetNumberRows() { return m_numRows
; }
1037 int GetNumberCols() { return m_numCols
; }
1040 // ------ display update functions
1042 wxArrayInt
CalcRowLabelsExposed( const wxRegion
& reg
);
1044 wxArrayInt
CalcColLabelsExposed( const wxRegion
& reg
);
1045 wxGridCellCoordsArray
CalcCellsExposed( const wxRegion
& reg
);
1048 // ------ event handlers
1050 void ProcessRowLabelMouseEvent( wxMouseEvent
& event
);
1051 void ProcessColLabelMouseEvent( wxMouseEvent
& event
);
1052 void ProcessCornerLabelMouseEvent( wxMouseEvent
& event
);
1053 void ProcessGridCellMouseEvent( wxMouseEvent
& event
);
1054 bool ProcessTableMessage( wxGridTableMessage
& );
1056 void DoEndDragResizeRow();
1057 void DoEndDragResizeCol();
1059 wxGridTableBase
* GetTable() const { return m_table
; }
1060 bool SetTable( wxGridTableBase
*table
, bool takeOwnership
=FALSE
,
1061 wxGrid::wxGridSelectionModes selmode
=
1062 wxGrid::wxGridSelectCells
);
1065 bool InsertRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1066 bool AppendRows( int numRows
= 1, bool updateLabels
=TRUE
);
1067 bool DeleteRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1068 bool InsertCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1069 bool AppendCols( int numCols
= 1, bool updateLabels
=TRUE
);
1070 bool DeleteCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1072 void DrawGridCellArea( wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1073 void DrawGridSpace( wxDC
& dc
);
1074 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
1075 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
1076 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
1077 void DrawHighlight(wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1079 // this function is called when the current cell highlight must be redrawn
1080 // and may be overridden by the user
1081 virtual void DrawCellHighlight( wxDC
& dc
, const wxGridCellAttr
*attr
);
1083 void DrawRowLabels( wxDC
& dc
, const wxArrayInt
& rows
);
1084 void DrawRowLabel( wxDC
& dc
, int row
);
1086 void DrawColLabels( wxDC
& dc
, const wxArrayInt
& cols
);
1087 void DrawColLabel( wxDC
& dc
, int col
);
1090 // ------ Cell text drawing functions
1092 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
1093 int horizontalAlignment
= wxALIGN_LEFT
,
1094 int verticalAlignment
= wxALIGN_TOP
);
1096 void DrawTextRectangle( wxDC
& dc
, const wxArrayString
& lines
, const wxRect
&,
1097 int horizontalAlignment
= wxALIGN_LEFT
,
1098 int verticalAlignment
= wxALIGN_TOP
);
1101 // Split a string containing newline chararcters into an array of
1102 // strings and return the number of lines
1104 void StringToLines( const wxString
& value
, wxArrayString
& lines
);
1106 void GetTextBoxSize( wxDC
& dc
,
1107 const wxArrayString
& lines
,
1108 long *width
, long *height
);
1112 // Code that does a lot of grid modification can be enclosed
1113 // between BeginBatch() and EndBatch() calls to avoid screen
1116 void BeginBatch() { m_batchCount
++; }
1119 int GetBatchCount() { return m_batchCount
; }
1121 // Use this, rather than wxWindow::Refresh(), to force an
1122 // immediate repainting of the grid. Has no effect if you are
1123 // already inside a BeginBatch / EndBatch block.
1125 // This function is necessary because wxGrid has a minimal OnPaint()
1126 // handler to reduce screen flicker.
1128 void ForceRefresh();
1131 // ------ edit control functions
1133 bool IsEditable() { return m_editable
; }
1134 void EnableEditing( bool edit
);
1136 void EnableCellEditControl( bool enable
= TRUE
);
1137 void DisableCellEditControl() { EnableCellEditControl(FALSE
); }
1138 bool CanEnableCellControl() const;
1139 bool IsCellEditControlEnabled() const;
1140 bool IsCellEditControlShown() const;
1142 bool IsCurrentCellReadOnly() const;
1144 void ShowCellEditControl();
1145 void HideCellEditControl();
1146 void SaveEditControlValue();
1149 // ------ grid location functions
1150 // Note that all of these functions work with the logical coordinates of
1151 // grid cells and labels so you will need to convert from device
1152 // coordinates for mouse events etc.
1154 void XYToCell( int x
, int y
, wxGridCellCoords
& );
1155 int YToRow( int y
);
1156 int XToCol( int x
);
1158 int YToEdgeOfRow( int y
);
1159 int XToEdgeOfCol( int x
);
1161 wxRect
CellToRect( int row
, int col
);
1162 wxRect
CellToRect( const wxGridCellCoords
& coords
)
1163 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
1165 int GetGridCursorRow() { return m_currentCellCoords
.GetRow(); }
1166 int GetGridCursorCol() { return m_currentCellCoords
.GetCol(); }
1168 // check to see if a cell is either wholly visible (the default arg) or
1169 // at least partially visible in the grid window
1171 bool IsVisible( int row
, int col
, bool wholeCellVisible
= TRUE
);
1172 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= TRUE
)
1173 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
1174 void MakeCellVisible( int row
, int col
);
1175 void MakeCellVisible( const wxGridCellCoords
& coords
)
1176 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
1179 // ------ grid cursor movement functions
1181 void SetGridCursor( int row
, int col
)
1182 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1184 bool MoveCursorUp( bool expandSelection
);
1185 bool MoveCursorDown( bool expandSelection
);
1186 bool MoveCursorLeft( bool expandSelection
);
1187 bool MoveCursorRight( bool expandSelection
);
1188 bool MovePageDown();
1190 bool MoveCursorUpBlock( bool expandSelection
);
1191 bool MoveCursorDownBlock( bool expandSelection
);
1192 bool MoveCursorLeftBlock( bool expandSelection
);
1193 bool MoveCursorRightBlock( bool expandSelection
);
1196 // ------ label and gridline formatting
1198 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
1199 int GetRowLabelSize() { return m_rowLabelWidth
; }
1200 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
1201 int GetColLabelSize() { return m_colLabelHeight
; }
1202 wxColour
GetLabelBackgroundColour() { return m_labelBackgroundColour
; }
1203 wxColour
GetLabelTextColour() { return m_labelTextColour
; }
1204 wxFont
GetLabelFont() { return m_labelFont
; }
1205 void GetRowLabelAlignment( int *horiz
, int *vert
);
1206 void GetColLabelAlignment( int *horiz
, int *vert
);
1207 wxString
GetRowLabelValue( int row
);
1208 wxString
GetColLabelValue( int col
);
1209 wxColour
GetGridLineColour() { return m_gridLineColour
; }
1210 wxColour
GetCellHighlightColour() { return m_cellHighlightColour
; }
1211 int GetCellHighlightPenWidth() { return m_cellHighlightPenWidth
; }
1212 int GetCellHighlightROPenWidth() { return m_cellHighlightROPenWidth
; }
1214 void SetRowLabelSize( int width
);
1215 void SetColLabelSize( int height
);
1216 void SetLabelBackgroundColour( const wxColour
& );
1217 void SetLabelTextColour( const wxColour
& );
1218 void SetLabelFont( const wxFont
& );
1219 void SetRowLabelAlignment( int horiz
, int vert
);
1220 void SetColLabelAlignment( int horiz
, int vert
);
1221 void SetRowLabelValue( int row
, const wxString
& );
1222 void SetColLabelValue( int col
, const wxString
& );
1223 void SetGridLineColour( const wxColour
& );
1224 void SetCellHighlightColour( const wxColour
& );
1225 void SetCellHighlightPenWidth(int width
);
1226 void SetCellHighlightROPenWidth(int width
);
1228 void EnableDragRowSize( bool enable
= TRUE
);
1229 void DisableDragRowSize() { EnableDragRowSize( FALSE
); }
1230 bool CanDragRowSize() { return m_canDragRowSize
; }
1231 void EnableDragColSize( bool enable
= TRUE
);
1232 void DisableDragColSize() { EnableDragColSize( FALSE
); }
1233 bool CanDragColSize() { return m_canDragColSize
; }
1234 void EnableDragGridSize(bool enable
= TRUE
);
1235 void DisableDragGridSize() { EnableDragGridSize(FALSE
); }
1236 bool CanDragGridSize() { return m_canDragGridSize
; }
1238 // this sets the specified attribute for all cells in this row/col
1239 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
1240 void SetColAttr(int col
, wxGridCellAttr
*attr
);
1242 // shortcuts for setting the column parameters
1244 // set the format for the data in the column: default is string
1245 void SetColFormatBool(int col
);
1246 void SetColFormatNumber(int col
);
1247 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
1248 void SetColFormatCustom(int col
, const wxString
& typeName
);
1250 void EnableGridLines( bool enable
= TRUE
);
1251 bool GridLinesEnabled() { return m_gridLinesEnabled
; }
1253 // ------ row and col formatting
1255 int GetDefaultRowSize();
1256 int GetRowSize( int row
);
1257 int GetDefaultColSize();
1258 int GetColSize( int col
);
1259 wxColour
GetDefaultCellBackgroundColour();
1260 wxColour
GetCellBackgroundColour( int row
, int col
);
1261 wxColour
GetDefaultCellTextColour();
1262 wxColour
GetCellTextColour( int row
, int col
);
1263 wxFont
GetDefaultCellFont();
1264 wxFont
GetCellFont( int row
, int col
);
1265 void GetDefaultCellAlignment( int *horiz
, int *vert
);
1266 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
);
1268 void SetDefaultRowSize( int height
, bool resizeExistingRows
= FALSE
);
1269 void SetRowSize( int row
, int height
);
1270 void SetDefaultColSize( int width
, bool resizeExistingCols
= FALSE
);
1272 void SetColSize( int col
, int width
);
1274 // automatically size the column or row to fit to its contents, if
1275 // setAsMin is TRUE, this optimal width will also be set as minimal width
1277 void AutoSizeColumn( int col
, bool setAsMin
= TRUE
)
1278 { AutoSizeColOrRow(col
, setAsMin
, TRUE
); }
1279 void AutoSizeRow( int row
, bool setAsMin
= TRUE
)
1280 { AutoSizeColOrRow(row
, setAsMin
, FALSE
); }
1282 // auto size all columns (very ineffective for big grids!)
1283 void AutoSizeColumns( bool setAsMin
= TRUE
)
1284 { (void)SetOrCalcColumnSizes(FALSE
, setAsMin
); }
1286 void AutoSizeRows( bool setAsMin
= TRUE
)
1287 { (void)SetOrCalcRowSizes(FALSE
, setAsMin
); }
1289 // auto size the grid, that is make the columns/rows of the "right" size
1290 // and also set the grid size to just fit its contents
1293 // column won't be resized to be lesser width - this must be called during
1294 // the grid creation because it won't resize the column if it's already
1295 // narrower than the minimal width
1296 void SetColMinimalWidth( int col
, int width
);
1297 void SetRowMinimalHeight( int row
, int width
);
1299 void SetDefaultCellBackgroundColour( const wxColour
& );
1300 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
1301 void SetDefaultCellTextColour( const wxColour
& );
1303 void SetCellTextColour( int row
, int col
, const wxColour
& );
1304 void SetDefaultCellFont( const wxFont
& );
1305 void SetCellFont( int row
, int col
, const wxFont
& );
1306 void SetDefaultCellAlignment( int horiz
, int vert
);
1307 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
1309 // takes ownership of the pointer
1310 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
1311 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
1312 wxGridCellRenderer
*GetDefaultRenderer() const;
1313 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
1315 // takes ownership of the pointer
1316 void SetDefaultEditor(wxGridCellEditor
*editor
);
1317 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
1318 wxGridCellEditor
*GetDefaultEditor() const;
1319 wxGridCellEditor
* GetCellEditor(int row
, int col
);
1323 // ------ cell value accessors
1325 wxString
GetCellValue( int row
, int col
)
1329 return m_table
->GetValue( row
, col
);
1333 return wxEmptyString
;
1337 wxString
GetCellValue( const wxGridCellCoords
& coords
)
1338 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
1340 void SetCellValue( int row
, int col
, const wxString
& s
);
1341 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
1342 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
1344 // returns TRUE if the cell can't be edited
1345 bool IsReadOnly(int row
, int col
) const;
1347 // make the cell editable/readonly
1348 void SetReadOnly(int row
, int col
, bool isReadOnly
= TRUE
);
1350 // ------ selections of blocks of cells
1352 void SelectRow( int row
, bool addToSelected
= FALSE
);
1353 void SelectCol( int col
, bool addToSelected
= FALSE
);
1355 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
,
1356 bool addToSelected
= FALSE
);
1358 void SelectBlock( const wxGridCellCoords
& topLeft
,
1359 const wxGridCellCoords
& bottomRight
,
1360 bool addToSelected
= FALSE
)
1361 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1362 bottomRight
.GetRow(), bottomRight
.GetCol(),
1369 // ------ deselection
1371 void DeselectRow( int row
);
1372 void DeselectCol( int col
);
1373 void DeselectCell( int row
, int col
);
1375 void ClearSelection();
1377 bool IsInSelection( int row
, int col
);
1379 bool IsInSelection( const wxGridCellCoords
& coords
)
1380 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
1383 // This function returns the rectangle that encloses the block of cells
1384 // limited by TopLeft and BottomRight cell in device coords and clipped
1385 // to the client size of the grid window.
1387 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
1388 const wxGridCellCoords
& bottomRight
);
1390 // Access or update the selection fore/back colours
1391 wxColour
GetSelectionBackground() const
1392 { return m_selectionBackground
; }
1393 wxColour
GetSelectionForeground() const
1394 { return m_selectionForeground
; }
1396 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
1397 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
1400 // Methods for a registry for mapping data types to Renderers/Editors
1401 void RegisterDataType(const wxString
& typeName
,
1402 wxGridCellRenderer
* renderer
,
1403 wxGridCellEditor
* editor
);
1404 wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1405 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const
1406 { return GetDefaultEditorForCell(c
.GetRow(), c
.GetCol()); }
1407 wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1408 wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1409 wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1411 // grid may occupy more space than needed for its rows/columns, this
1412 // function allows to set how big this extra space is
1413 void SetMargins(int extraWidth
, int extraHeight
)
1415 m_extraWidth
= extraWidth
;
1416 m_extraHeight
= extraHeight
;
1419 // Accessors for component windows
1420 wxWindow
* GetGridWindow() { return (wxWindow
*)m_gridWin
; }
1421 wxWindow
* GetGridRowLabelWindow() { return (wxWindow
*)m_rowLabelWin
; }
1422 wxWindow
* GetGridColLabelWindow() { return (wxWindow
*)m_colLabelWin
; }
1423 wxWindow
* GetGridCornerLabelWindow() { return (wxWindow
*)m_cornerLabelWin
; }
1427 // ------ For compatibility with previous wxGrid only...
1429 // ************************************************
1430 // ** Don't use these in new code because they **
1431 // ** are liable to disappear in a future **
1433 // ************************************************
1436 wxGrid( wxWindow
*parent
,
1437 int x
, int y
, int w
= -1, int h
= -1,
1438 long style
= wxWANTS_CHARS
,
1439 const wxString
& name
= wxPanelNameStr
)
1440 : wxScrolledWindow( parent
, -1, wxPoint(x
,y
), wxSize(w
,h
),
1441 (style
|wxWANTS_CHARS
), name
)
1446 void SetCellValue( const wxString
& val
, int row
, int col
)
1447 { SetCellValue( row
, col
, val
); }
1449 void UpdateDimensions()
1450 { CalcDimensions(); }
1452 int GetRows() { return GetNumberRows(); }
1453 int GetCols() { return GetNumberCols(); }
1454 int GetCursorRow() { return GetGridCursorRow(); }
1455 int GetCursorColumn() { return GetGridCursorCol(); }
1457 int GetScrollPosX() { return 0; }
1458 int GetScrollPosY() { return 0; }
1460 void SetScrollX( int WXUNUSED(x
) ) { }
1461 void SetScrollY( int WXUNUSED(y
) ) { }
1463 void SetColumnWidth( int col
, int width
)
1464 { SetColSize( col
, width
); }
1466 int GetColumnWidth( int col
)
1467 { return GetColSize( col
); }
1469 void SetRowHeight( int row
, int height
)
1470 { SetRowSize( row
, height
); }
1472 // GetRowHeight() is below
1474 int GetViewHeight() // returned num whole rows visible
1477 int GetViewWidth() // returned num whole cols visible
1480 void SetLabelSize( int orientation
, int sz
)
1482 if ( orientation
== wxHORIZONTAL
)
1483 SetColLabelSize( sz
);
1485 SetRowLabelSize( sz
);
1488 int GetLabelSize( int orientation
)
1490 if ( orientation
== wxHORIZONTAL
)
1491 return GetColLabelSize();
1493 return GetRowLabelSize();
1496 void SetLabelAlignment( int orientation
, int align
)
1498 if ( orientation
== wxHORIZONTAL
)
1499 SetColLabelAlignment( align
, -1 );
1501 SetRowLabelAlignment( align
, -1 );
1504 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) )
1507 if ( orientation
== wxHORIZONTAL
)
1509 GetColLabelAlignment( &h
, &v
);
1514 GetRowLabelAlignment( &h
, &v
);
1519 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
1521 if ( orientation
== wxHORIZONTAL
)
1522 SetColLabelValue( pos
, val
);
1524 SetRowLabelValue( pos
, val
);
1527 wxString
GetLabelValue( int orientation
, int pos
)
1529 if ( orientation
== wxHORIZONTAL
)
1530 return GetColLabelValue( pos
);
1532 return GetRowLabelValue( pos
);
1535 wxFont
GetCellTextFont() const
1536 { return m_defaultCellAttr
->GetFont(); }
1538 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
1539 { return m_defaultCellAttr
->GetFont(); }
1541 void SetCellTextFont(const wxFont
& fnt
)
1542 { SetDefaultCellFont( fnt
); }
1544 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1545 { SetCellFont( row
, col
, fnt
); }
1547 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1548 { SetCellTextColour( row
, col
, val
); }
1550 void SetCellTextColour(const wxColour
& col
)
1551 { SetDefaultCellTextColour( col
); }
1553 void SetCellBackgroundColour(const wxColour
& col
)
1554 { SetDefaultCellBackgroundColour( col
); }
1556 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1557 { SetCellBackgroundColour( row
, col
, colour
); }
1559 bool GetEditable() { return IsEditable(); }
1560 void SetEditable( bool edit
= TRUE
) { EnableEditing( edit
); }
1561 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1563 void SetEditInPlace(bool WXUNUSED(edit
) = TRUE
) { }
1565 void SetCellAlignment( int align
, int row
, int col
)
1566 { SetCellAlignment(row
, col
, align
, wxALIGN_CENTER
); }
1567 void SetCellAlignment( int WXUNUSED(align
) ) {}
1568 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1570 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1571 wxPen
& GetDividerPen() const;
1572 void OnActivate(bool WXUNUSED(active
)) {}
1574 // ******** End of compatibility functions **********
1578 // ------ control IDs
1579 enum { wxGRID_CELLCTRL
= 2000,
1582 // ------ control types
1583 enum { wxGRID_TEXTCTRL
= 2100,
1588 // overridden wxWindow methods
1592 virtual wxSize
DoGetBestSize() const;
1596 wxGridWindow
*m_gridWin
;
1597 wxGridRowLabelWindow
*m_rowLabelWin
;
1598 wxGridColLabelWindow
*m_colLabelWin
;
1599 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1601 wxGridTableBase
*m_table
;
1607 wxGridCellCoords m_currentCellCoords
;
1609 wxGridCellCoords m_selectingTopLeft
;
1610 wxGridCellCoords m_selectingBottomRight
;
1611 wxGridCellCoords m_selectingKeyboard
;
1612 wxGridSelection
*m_selection
;
1613 wxColour m_selectionBackground
;
1614 wxColour m_selectionForeground
;
1616 // NB: *never* access m_row/col arrays directly because they are created
1617 // on demand, *always* use accessor functions instead!
1619 // init the m_rowHeights/Bottoms arrays with default values
1620 void InitRowHeights();
1622 int m_defaultRowHeight
;
1623 wxArrayInt m_rowHeights
;
1624 wxArrayInt m_rowBottoms
;
1626 // init the m_colWidths/Rights arrays
1627 void InitColWidths();
1629 int m_defaultColWidth
;
1630 wxArrayInt m_colWidths
;
1631 wxArrayInt m_colRights
;
1633 // get the col/row coords
1634 int GetColWidth(int col
) const;
1635 int GetColLeft(int col
) const;
1636 int GetColRight(int col
) const;
1638 // this function must be public for compatibility...
1640 int GetRowHeight(int row
) const;
1643 int GetRowTop(int row
) const;
1644 int GetRowBottom(int row
) const;
1646 int m_rowLabelWidth
;
1647 int m_colLabelHeight
;
1649 // the size of the margin left to the right and bottom of the cell area
1653 wxColour m_labelBackgroundColour
;
1654 wxColour m_labelTextColour
;
1657 int m_rowLabelHorizAlign
;
1658 int m_rowLabelVertAlign
;
1659 int m_colLabelHorizAlign
;
1660 int m_colLabelVertAlign
;
1662 bool m_defaultRowLabelValues
;
1663 bool m_defaultColLabelValues
;
1665 wxColour m_gridLineColour
;
1666 bool m_gridLinesEnabled
;
1667 wxColour m_cellHighlightColour
;
1668 int m_cellHighlightPenWidth
;
1669 int m_cellHighlightROPenWidth
;
1672 // common part of AutoSizeColumn/Row() and GetBestSize()
1673 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1674 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1676 // common part of AutoSizeColumn/Row()
1677 void AutoSizeColOrRow(int n
, bool setAsMin
, bool column
/* or row? */);
1679 // if a column has a minimal width, it will be the value for it in this
1681 wxHashTableLong m_colMinWidths
,
1684 // get the minimal width of the given column/row
1685 int GetColMinimalWidth(int col
) const;
1686 int GetRowMinimalHeight(int col
) const;
1688 // do we have some place to store attributes in?
1689 bool CanHaveAttributes();
1691 // returns the attribute we may modify in place: a new one if this cell
1692 // doesn't have any yet or the existing one if it does
1694 // DecRef() must be called on the returned pointer, as usual
1695 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1697 // cell attribute cache (currently we only cache 1, may be will do
1698 // more/better later)
1702 wxGridCellAttr
*attr
;
1705 // invalidates the attribute cache
1706 void ClearAttrCache();
1708 // adds an attribute to cache
1709 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1711 // looks for an attr in cache, returns TRUE if found
1712 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1714 // looks for the attr in cache, if not found asks the table and caches the
1716 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1717 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
)
1718 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1720 // the default cell attr object for cells that don't have their own
1721 wxGridCellAttr
* m_defaultCellAttr
;
1728 wxGridTypeRegistry
* m_typeRegistry
;
1732 WXGRID_CURSOR_SELECT_CELL
,
1733 WXGRID_CURSOR_RESIZE_ROW
,
1734 WXGRID_CURSOR_RESIZE_COL
,
1735 WXGRID_CURSOR_SELECT_ROW
,
1736 WXGRID_CURSOR_SELECT_COL
1739 // this method not only sets m_cursorMode but also sets the correct cursor
1740 // for the given mode and, if captureMouse is not FALSE releases the mouse
1741 // if it was captured and captures it if it must be captured
1743 // for this to work, you should always use it and not set m_cursorMode
1745 void ChangeCursorMode(CursorMode mode
,
1746 wxWindow
*win
= (wxWindow
*)NULL
,
1747 bool captureMouse
= TRUE
);
1749 wxWindow
*m_winCapture
; // the window which captured the mouse
1750 CursorMode m_cursorMode
;
1752 bool m_canDragRowSize
;
1753 bool m_canDragColSize
;
1754 bool m_canDragGridSize
;
1758 wxPoint m_startDragPos
;
1760 bool m_waitForSlowClick
;
1762 wxGridCellCoords m_selectionStart
;
1764 wxCursor m_rowResizeCursor
;
1765 wxCursor m_colResizeCursor
;
1767 bool m_editable
; // applies to whole grid
1768 bool m_cellEditCtrlEnabled
; // is in-place edit currently shown?
1773 void CalcDimensions();
1774 void CalcWindowSizes();
1775 bool Redimension( wxGridTableMessage
& );
1778 int SendEvent( const wxEventType
, int row
, int col
, wxMouseEvent
& );
1779 int SendEvent( const wxEventType
, int row
, int col
);
1780 int SendEvent( const wxEventType type
)
1782 return SendEvent(type
,
1783 m_currentCellCoords
.GetRow(),
1784 m_currentCellCoords
.GetCol());
1787 void OnPaint( wxPaintEvent
& );
1788 void OnSize( wxSizeEvent
& );
1789 void OnKeyDown( wxKeyEvent
& );
1790 void OnKeyUp( wxKeyEvent
& );
1791 void OnEraseBackground( wxEraseEvent
& );
1794 void SetCurrentCell( const wxGridCellCoords
& coords
);
1795 void SetCurrentCell( int row
, int col
)
1796 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1798 void HighlightBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
);
1800 void HighlightBlock( const wxGridCellCoords
& topLeft
,
1801 const wxGridCellCoords
& bottomRight
)
1802 { HighlightBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1803 bottomRight
.GetRow(), bottomRight
.GetCol() ); }
1805 // ------ functions to get/send data (see also public functions)
1807 bool GetModelValues();
1808 bool SetModelValues();
1810 friend class wxGridSelection
;
1812 DECLARE_DYNAMIC_CLASS( wxGrid
)
1813 DECLARE_EVENT_TABLE()
1816 // ----------------------------------------------------------------------------
1817 // Grid event class and event types
1818 // ----------------------------------------------------------------------------
1820 class WXDLLEXPORT wxGridEvent
: public wxNotifyEvent
1824 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1825 m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0)
1829 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
1830 int row
=-1, int col
=-1, int x
=-1, int y
=-1, bool sel
= TRUE
,
1831 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1833 virtual int GetRow() { return m_row
; }
1834 virtual int GetCol() { return m_col
; }
1835 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1836 bool Selecting() { return m_selecting
; }
1837 bool ControlDown() { return m_control
; }
1838 bool MetaDown() { return m_meta
; }
1839 bool ShiftDown() { return m_shift
; }
1840 bool AltDown() { return m_alt
; }
1853 DECLARE_DYNAMIC_CLASS(wxGridEvent
)
1856 class WXDLLEXPORT wxGridSizeEvent
: public wxNotifyEvent
1860 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1861 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1865 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
1866 int rowOrCol
=-1, int x
=-1, int y
=-1,
1867 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1869 int GetRowOrCol() { return m_rowOrCol
; }
1870 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1871 bool ControlDown() { return m_control
; }
1872 bool MetaDown() { return m_meta
; }
1873 bool ShiftDown() { return m_shift
; }
1874 bool AltDown() { return m_alt
; }
1885 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent
)
1889 class WXDLLEXPORT wxGridRangeSelectEvent
: public wxNotifyEvent
1892 wxGridRangeSelectEvent()
1895 m_topLeft
= wxGridNoCellCoords
;
1896 m_bottomRight
= wxGridNoCellCoords
;
1897 m_selecting
= FALSE
;
1904 wxGridRangeSelectEvent(int id
, wxEventType type
, wxObject
* obj
,
1905 const wxGridCellCoords
& topLeft
,
1906 const wxGridCellCoords
& bottomRight
,
1908 bool control
=FALSE
, bool shift
=FALSE
,
1909 bool alt
=FALSE
, bool meta
=FALSE
);
1911 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
1912 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
1913 int GetTopRow() { return m_topLeft
.GetRow(); }
1914 int GetBottomRow() { return m_bottomRight
.GetRow(); }
1915 int GetLeftCol() { return m_topLeft
.GetCol(); }
1916 int GetRightCol() { return m_bottomRight
.GetCol(); }
1917 bool Selecting() { return m_selecting
; }
1918 bool ControlDown() { return m_control
; }
1919 bool MetaDown() { return m_meta
; }
1920 bool ShiftDown() { return m_shift
; }
1921 bool AltDown() { return m_alt
; }
1924 wxGridCellCoords m_topLeft
;
1925 wxGridCellCoords m_bottomRight
;
1932 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent
)
1936 class WXDLLEXPORT wxGridEditorCreatedEvent
: public wxCommandEvent
{
1938 wxGridEditorCreatedEvent()
1946 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
1947 int row
, int col
, wxControl
* ctrl
);
1949 int GetRow() { return m_row
; }
1950 int GetCol() { return m_col
; }
1951 wxControl
* GetControl() { return m_ctrl
; }
1952 void SetRow(int row
) { m_row
= row
; }
1953 void SetCol(int col
) { m_col
= col
; }
1954 void SetControl(wxControl
* ctrl
) { m_ctrl
= ctrl
; }
1961 DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent
)
1965 BEGIN_DECLARE_EVENT_TYPES()
1966 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_CLICK
, 1580)
1967 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_CLICK
, 1581)
1968 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_DCLICK
, 1582)
1969 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_DCLICK
, 1583)
1970 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_CLICK
, 1584)
1971 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_CLICK
, 1585)
1972 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_DCLICK
, 1586)
1973 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_DCLICK
, 1587)
1974 DECLARE_EVENT_TYPE(wxEVT_GRID_ROW_SIZE
, 1588)
1975 DECLARE_EVENT_TYPE(wxEVT_GRID_COL_SIZE
, 1589)
1976 DECLARE_EVENT_TYPE(wxEVT_GRID_RANGE_SELECT
, 1590)
1977 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_CHANGE
, 1591)
1978 DECLARE_EVENT_TYPE(wxEVT_GRID_SELECT_CELL
, 1592)
1979 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_SHOWN
, 1593)
1980 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_HIDDEN
, 1594)
1981 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_CREATED
, 1595)
1982 END_DECLARE_EVENT_TYPES()
1985 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
1986 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
1987 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
1988 typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction
)(wxGridEditorCreatedEvent
&);
1990 #define EVT_GRID_CELL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1991 #define EVT_GRID_CELL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1992 #define EVT_GRID_CELL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1993 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1994 #define EVT_GRID_LABEL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1995 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1996 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1997 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
1998 #define EVT_GRID_ROW_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
1999 #define EVT_GRID_COL_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
2000 #define EVT_GRID_RANGE_SELECT(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL ),
2001 #define EVT_GRID_CELL_CHANGE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2002 #define EVT_GRID_SELECT_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2003 #define EVT_GRID_EDITOR_SHOWN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2004 #define EVT_GRID_EDITOR_HIDDEN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2005 #define EVT_GRID_EDITOR_CREATED(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_CREATED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEditorCreatedEventFunction) &fn, NULL ),
2008 #if 0 // TODO: implement these ? others ?
2010 extern const int wxEVT_GRID_CREATE_CELL
;
2011 extern const int wxEVT_GRID_CHANGE_LABELS
;
2012 extern const int wxEVT_GRID_CHANGE_SEL_LABEL
;
2014 #define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2015 #define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2016 #define EVT_GRID_CHANGE_SEL_LABEL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2020 #endif // #ifndef __WXGRID_H__
2022 #endif // ifndef wxUSE_NEW_GRID