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 /////////////////////////////////////////////////////////////////////////////
17 #if defined(__GNUG__) && !defined(__APPLE__)
18 #pragma interface "grid.h"
23 #include "wx/scrolwin.h"
24 #include "wx/string.h"
25 #include "wx/scrolbar.h"
27 #include "wx/combobox.h"
28 #include "wx/dynarray.h"
30 #include "wx/clntdata.h"
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 // Default parameters for wxGrid
38 #define WXGRID_DEFAULT_NUMBER_ROWS 10
39 #define WXGRID_DEFAULT_NUMBER_COLS 10
41 #define WXGRID_DEFAULT_ROW_HEIGHT 25
43 #define WXGRID_DEFAULT_ROW_HEIGHT 30
45 #define WXGRID_DEFAULT_COL_WIDTH 80
46 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
47 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
48 #define WXGRID_LABEL_EDGE_ZONE 2
49 #define WXGRID_MIN_ROW_HEIGHT 15
50 #define WXGRID_MIN_COL_WIDTH 15
51 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
53 // type names for grid table values
54 #define wxGRID_VALUE_STRING _T("string")
55 #define wxGRID_VALUE_BOOL _T("bool")
56 #define wxGRID_VALUE_NUMBER _T("long")
57 #define wxGRID_VALUE_FLOAT _T("double")
58 #define wxGRID_VALUE_CHOICE _T("choice")
60 #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
61 #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
63 // ----------------------------------------------------------------------------
64 // forward declarations
65 // ----------------------------------------------------------------------------
67 class WXDLLEXPORT wxGrid
;
68 class WXDLLEXPORT wxGridCellAttr
;
69 class WXDLLEXPORT wxGridCellAttrProviderData
;
70 class WXDLLEXPORT wxGridColLabelWindow
;
71 class WXDLLEXPORT wxGridCornerLabelWindow
;
72 class WXDLLEXPORT wxGridRowLabelWindow
;
73 class WXDLLEXPORT wxGridTableBase
;
74 class WXDLLEXPORT wxGridWindow
;
75 class WXDLLEXPORT wxGridTypeRegistry
;
76 class WXDLLEXPORT wxGridSelection
;
78 class WXDLLEXPORT wxCheckBox
;
79 class WXDLLEXPORT wxComboBox
;
80 class WXDLLEXPORT wxTextCtrl
;
81 class WXDLLEXPORT wxSpinCtrl
;
83 // ----------------------------------------------------------------------------
85 // ----------------------------------------------------------------------------
87 #define wxSafeIncRef(p) if ( p ) (p)->IncRef()
88 #define wxSafeDecRef(p) if ( p ) (p)->DecRef()
90 // ----------------------------------------------------------------------------
91 // wxGridCellWorker: common base class for wxGridCellRenderer and
94 // NB: this is more an implementation convenience than a design issue, so this
95 // class is not documented and is not public at all
96 // ----------------------------------------------------------------------------
98 class WXDLLEXPORT wxGridCellWorker
: public wxClientDataContainer
101 wxGridCellWorker() { m_nRef
= 1; }
103 // this class is ref counted: it is created with ref count of 1, so
104 // calling DecRef() once will delete it. Calling IncRef() allows to lock
105 // it until the matching DecRef() is called
106 void IncRef() { m_nRef
++; }
107 void DecRef() { if ( !--m_nRef
) delete this; }
109 // interpret renderer parameters: arbitrary string whose interpretatin is
110 // left to the derived classes
111 virtual void SetParameters(const wxString
& params
);
114 // virtual dtor for any base class - private because only DecRef() can
116 virtual ~wxGridCellWorker();
121 // suppress the stupid gcc warning about the class having private dtor and
123 friend class wxGridCellWorkerDummyFriend
;
126 // ----------------------------------------------------------------------------
127 // wxGridCellRenderer: this class is responsible for actually drawing the cell
128 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
129 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
130 // view of all cells. This is an ABC, you will normally use one of the
131 // predefined derived classes or derive your own class from it.
132 // ----------------------------------------------------------------------------
134 class WXDLLEXPORT wxGridCellRenderer
: public wxGridCellWorker
137 // draw the given cell on the provided DC inside the given rectangle
138 // using the style specified by the attribute and the default or selected
139 // state corresponding to the isSelected value.
141 // this pure virtual function has a default implementation which will
142 // prepare the DC using the given attribute: it will draw the rectangle
143 // with the bg colour from attr and set the text colour and font
144 virtual void Draw(wxGrid
& grid
,
145 wxGridCellAttr
& attr
,
149 bool isSelected
) = 0;
151 // get the preferred size of the cell for its contents
152 virtual wxSize
GetBestSize(wxGrid
& grid
,
153 wxGridCellAttr
& attr
,
155 int row
, int col
) = 0;
157 // create a new object which is the copy of this one
158 virtual wxGridCellRenderer
*Clone() const = 0;
161 // the default renderer for the cells containing string data
162 class WXDLLEXPORT wxGridCellStringRenderer
: public wxGridCellRenderer
166 virtual void Draw(wxGrid
& grid
,
167 wxGridCellAttr
& attr
,
173 // return the string extent
174 virtual wxSize
GetBestSize(wxGrid
& grid
,
175 wxGridCellAttr
& attr
,
179 virtual wxGridCellRenderer
*Clone() const
180 { return new wxGridCellStringRenderer
; }
183 // set the text colours before drawing
184 void SetTextColoursAndFont(wxGrid
& grid
,
185 wxGridCellAttr
& attr
,
189 // calc the string extent for given string/font
190 wxSize
DoGetBestSize(wxGridCellAttr
& attr
,
192 const wxString
& text
);
195 // the default renderer for the cells containing numeric (long) data
196 class WXDLLEXPORT wxGridCellNumberRenderer
: public wxGridCellStringRenderer
199 // draw the string right aligned
200 virtual void Draw(wxGrid
& grid
,
201 wxGridCellAttr
& attr
,
207 virtual wxSize
GetBestSize(wxGrid
& grid
,
208 wxGridCellAttr
& attr
,
212 virtual wxGridCellRenderer
*Clone() const
213 { return new wxGridCellNumberRenderer
; }
216 wxString
GetString(wxGrid
& grid
, int row
, int col
);
219 class WXDLLEXPORT wxGridCellFloatRenderer
: public wxGridCellStringRenderer
222 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
224 // get/change formatting parameters
225 int GetWidth() const { return m_width
; }
226 void SetWidth(int width
) { m_width
= width
; m_format
.clear(); }
227 int GetPrecision() const { return m_precision
; }
228 void SetPrecision(int precision
) { m_precision
= precision
; m_format
.clear(); }
230 // draw the string right aligned with given width/precision
231 virtual void Draw(wxGrid
& grid
,
232 wxGridCellAttr
& attr
,
238 virtual wxSize
GetBestSize(wxGrid
& grid
,
239 wxGridCellAttr
& attr
,
243 // parameters string format is "width[,precision]"
244 virtual void SetParameters(const wxString
& params
);
246 virtual wxGridCellRenderer
*Clone() const;
249 wxString
GetString(wxGrid
& grid
, int row
, int col
);
252 // formatting parameters
259 // renderer for boolean fields
260 class WXDLLEXPORT wxGridCellBoolRenderer
: public wxGridCellRenderer
263 // draw a check mark or nothing
264 virtual void Draw(wxGrid
& grid
,
265 wxGridCellAttr
& attr
,
271 // return the checkmark size
272 virtual wxSize
GetBestSize(wxGrid
& grid
,
273 wxGridCellAttr
& attr
,
277 virtual wxGridCellRenderer
*Clone() const
278 { return new wxGridCellBoolRenderer
; }
281 static wxSize ms_sizeCheckMark
;
284 // ----------------------------------------------------------------------------
285 // wxGridCellEditor: This class is responsible for providing and manipulating
286 // the in-place edit controls for the grid. Instances of wxGridCellEditor
287 // (actually, instances of derived classes since it is an ABC) can be
288 // associated with the cell attributes for individual cells, rows, columns, or
289 // even for the entire grid.
290 // ----------------------------------------------------------------------------
292 class WXDLLEXPORT wxGridCellEditor
: public wxGridCellWorker
297 bool IsCreated() { return m_control
!= NULL
; }
298 wxControl
* GetControl() { return m_control
; }
299 void SetControl(wxControl
* control
) { m_control
= control
; }
301 wxGridCellAttr
* GetCellAttr() { return m_attr
; }
302 void SetCellAttr(wxGridCellAttr
* attr
) { m_attr
= attr
; }
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 // added GetValue so we can get the value which is in the control
361 virtual wxString
GetValue() const = 0;
364 // the dtor is private because only DecRef() can delete us
365 virtual ~wxGridCellEditor();
367 // the control we show on screen
368 wxControl
* m_control
;
370 // a temporary pointer to the attribute being edited
371 wxGridCellAttr
* m_attr
;
373 // if we change the colours/font of the control from the default ones, we
374 // must restore the default later and we save them here between calls to
375 // Show(TRUE) and Show(FALSE)
380 // suppress the stupid gcc warning about the class having private dtor and
382 friend class wxGridCellEditorDummyFriend
;
384 DECLARE_NO_COPY_CLASS(wxGridCellEditor
)
389 // the editor for string/text data
390 class WXDLLEXPORT wxGridCellTextEditor
: public wxGridCellEditor
393 wxGridCellTextEditor();
395 virtual void Create(wxWindow
* parent
,
397 wxEvtHandler
* evtHandler
);
398 virtual void SetSize(const wxRect
& rect
);
400 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
402 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
403 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
404 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
406 virtual void Reset();
407 virtual void StartingKey(wxKeyEvent
& event
);
408 virtual void HandleReturn(wxKeyEvent
& event
);
410 // parameters string format is "max_width"
411 virtual void SetParameters(const wxString
& params
);
413 virtual wxGridCellEditor
*Clone() const
414 { return new wxGridCellTextEditor
; }
417 // added GetValue so we can get the value which is in the control
418 virtual wxString
GetValue() const;
420 wxTextCtrl
*Text() const { return (wxTextCtrl
*)m_control
; }
422 // parts of our virtual functions reused by the derived classes
423 void DoBeginEdit(const wxString
& startValue
);
424 void DoReset(const wxString
& startValue
);
427 size_t m_maxChars
; // max number of chars allowed
428 wxString m_startValue
;
431 // the editor for numeric (long) data
432 class WXDLLEXPORT wxGridCellNumberEditor
: public wxGridCellTextEditor
435 // allows to specify the range - if min == max == -1, no range checking is
437 wxGridCellNumberEditor(int min
= -1, int max
= -1);
439 virtual void Create(wxWindow
* parent
,
441 wxEvtHandler
* evtHandler
);
443 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
444 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
445 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
447 virtual void Reset();
448 virtual void StartingKey(wxKeyEvent
& event
);
450 // parameters string format is "min,max"
451 virtual void SetParameters(const wxString
& params
);
453 virtual wxGridCellEditor
*Clone() const
454 { return new wxGridCellNumberEditor(m_min
, m_max
); }
456 // added GetValue so we can get the value which is in the control
457 virtual wxString
GetValue() const;
460 wxSpinCtrl
*Spin() const { return (wxSpinCtrl
*)m_control
; }
462 // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
463 bool HasRange() const { return m_min
!= m_max
; }
465 // string representation of m_valueOld
466 wxString
GetString() const
467 { return wxString::Format(_T("%ld"), m_valueOld
); }
476 // the editor for floating point numbers (double) data
477 class WXDLLEXPORT wxGridCellFloatEditor
: public wxGridCellTextEditor
480 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
482 virtual void Create(wxWindow
* parent
,
484 wxEvtHandler
* evtHandler
);
486 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
487 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
488 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
490 virtual void Reset();
491 virtual void StartingKey(wxKeyEvent
& event
);
493 virtual wxGridCellEditor
*Clone() const
494 { return new wxGridCellFloatEditor(m_width
, m_precision
); }
496 // parameters string format is "width,precision"
497 virtual void SetParameters(const wxString
& params
);
500 // string representation of m_valueOld
501 wxString
GetString() const;
509 #endif // wxUSE_TEXTCTRL
513 // the editor for boolean data
514 class WXDLLEXPORT wxGridCellBoolEditor
: public wxGridCellEditor
517 virtual void Create(wxWindow
* parent
,
519 wxEvtHandler
* evtHandler
);
521 virtual void SetSize(const wxRect
& rect
);
522 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
524 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
525 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
526 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
528 virtual void Reset();
529 virtual void StartingClick();
531 virtual wxGridCellEditor
*Clone() const
532 { return new wxGridCellBoolEditor
; }
534 // added GetValue so we can get the value which is in the control
535 virtual wxString
GetValue() const;
538 wxCheckBox
*CBox() const { return (wxCheckBox
*)m_control
; }
544 #endif // wxUSE_CHECKBOX
548 // the editor for string data allowing to choose from the list of strings
549 class WXDLLEXPORT wxGridCellChoiceEditor
: public wxGridCellEditor
552 // if !allowOthers, user can't type a string not in choices array
553 wxGridCellChoiceEditor(size_t count
= 0,
554 const wxString choices
[] = NULL
,
555 bool allowOthers
= FALSE
);
557 virtual void Create(wxWindow
* parent
,
559 wxEvtHandler
* evtHandler
);
561 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
563 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
564 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
566 virtual void Reset();
568 // parameters string format is "item1[,item2[...,itemN]]"
569 virtual void SetParameters(const wxString
& params
);
571 virtual wxGridCellEditor
*Clone() const;
573 // added GetValue so we can get the value which is in the control
574 virtual wxString
GetValue() const;
577 wxComboBox
*Combo() const { return (wxComboBox
*)m_control
; }
579 // DJC - (MAPTEK) you at least need access to m_choices if you
580 // wish to override this class
582 wxString m_startValue
;
583 wxArrayString m_choices
;
587 #endif // wxUSE_COMBOBOX
589 // ----------------------------------------------------------------------------
590 // wxGridCellAttr: this class can be used to alter the cells appearance in
591 // the grid by changing their colour/font/... from default. An object of this
592 // class may be returned by wxGridTable::GetAttr().
593 // ----------------------------------------------------------------------------
595 class WXDLLEXPORT wxGridCellAttr
: public wxClientDataContainer
609 wxGridCellAttr(wxGridCellAttr
*attrDefault
= NULL
)
613 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
614 SetAlignment(-1, -1);
617 // VZ: considering the number of members wxGridCellAttr has now, this ctor
618 // seems to be pretty useless... may be we should just remove it?
619 wxGridCellAttr(const wxColour
& colText
,
620 const wxColour
& colBack
,
624 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
627 SetAlignment(hAlign
, vAlign
);
630 // creates a new copy of this object
631 wxGridCellAttr
*Clone() const;
632 void MergeWith(wxGridCellAttr
*mergefrom
);
634 // this class is ref counted: it is created with ref count of 1, so
635 // calling DecRef() once will delete it. Calling IncRef() allows to lock
636 // it until the matching DecRef() is called
637 void IncRef() { m_nRef
++; }
638 void DecRef() { if ( !--m_nRef
) delete this; }
641 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
642 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
643 void SetFont(const wxFont
& font
) { m_font
= font
; }
644 void SetAlignment(int hAlign
, int vAlign
)
649 void SetSize(int num_rows
, int num_cols
);
650 void SetOverflow(bool allow
= TRUE
)
651 { m_overflow
= allow
? Overflow
: SingleCell
; }
652 void SetReadOnly(bool isReadOnly
= TRUE
)
653 { m_isReadOnly
= isReadOnly
? ReadOnly
: ReadWrite
; }
655 // takes ownership of the pointer
656 void SetRenderer(wxGridCellRenderer
*renderer
)
657 { wxSafeDecRef(m_renderer
); m_renderer
= renderer
; }
658 void SetEditor(wxGridCellEditor
* editor
)
659 { wxSafeDecRef(m_editor
); m_editor
= editor
; }
661 void SetKind(wxAttrKind kind
) { m_attrkind
= kind
; }
664 bool HasTextColour() const { return m_colText
.Ok(); }
665 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
666 bool HasFont() const { return m_font
.Ok(); }
667 bool HasAlignment() const { return (m_hAlign
!= -1 || m_vAlign
!= -1); }
668 bool HasRenderer() const { return m_renderer
!= NULL
; }
669 bool HasEditor() const { return m_editor
!= NULL
; }
670 bool HasReadWriteMode() const { return m_isReadOnly
!= Unset
; }
671 bool HasOverflowMode() const { return m_overflow
!= UnsetOverflow
; }
673 const wxColour
& GetTextColour() const;
674 const wxColour
& GetBackgroundColour() const;
675 const wxFont
& GetFont() const;
676 void GetAlignment(int *hAlign
, int *vAlign
) const;
677 void GetSize(int *num_rows
, int *num_cols
) const;
678 bool GetOverflow() const
679 { return m_overflow
!= SingleCell
; }
680 wxGridCellRenderer
*GetRenderer(wxGrid
* grid
, int row
, int col
) const;
681 wxGridCellEditor
*GetEditor(wxGrid
* grid
, int row
, int col
) const;
683 bool IsReadOnly() const { return m_isReadOnly
== wxGridCellAttr::ReadOnly
; }
685 wxAttrKind
GetKind() { return m_attrkind
; }
687 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
697 enum wxAttrOverflowMode
704 // the common part of all ctors
705 void Init(wxGridCellAttr
*attrDefault
= NULL
);
707 // the dtor is private because only DecRef() can delete us
710 wxSafeDecRef(m_renderer
);
711 wxSafeDecRef(m_editor
);
714 // the ref count - when it goes to 0, we die
725 wxAttrOverflowMode m_overflow
;
727 wxGridCellRenderer
* m_renderer
;
728 wxGridCellEditor
* m_editor
;
729 wxGridCellAttr
* m_defGridAttr
;
731 wxAttrReadMode m_isReadOnly
;
733 wxAttrKind m_attrkind
;
735 // use Clone() instead
736 DECLARE_NO_COPY_CLASS(wxGridCellAttr
)
738 // suppress the stupid gcc warning about the class having private dtor and
740 friend class wxGridCellAttrDummyFriend
;
743 // ----------------------------------------------------------------------------
744 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
746 // ----------------------------------------------------------------------------
748 // implementation note: we separate it from wxGridTableBase because we wish to
749 // avoid deriving a new table class if possible, and sometimes it will be
750 // enough to just derive another wxGridCellAttrProvider instead
752 // the default implementation is reasonably efficient for the generic case,
753 // but you might still wish to implement your own for some specific situations
754 // if you have performance problems with the stock one
755 class WXDLLEXPORT wxGridCellAttrProvider
: public wxClientDataContainer
758 wxGridCellAttrProvider();
759 virtual ~wxGridCellAttrProvider();
761 // DecRef() must be called on the returned pointer
762 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
763 wxGridCellAttr::wxAttrKind kind
) const;
765 // all these functions take ownership of the pointer, don't call DecRef()
767 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
768 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
769 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
771 // these functions must be called whenever some rows/cols are deleted
772 // because the internal data must be updated then
773 void UpdateAttrRows( size_t pos
, int numRows
);
774 void UpdateAttrCols( size_t pos
, int numCols
);
779 wxGridCellAttrProviderData
*m_data
;
781 DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider
)
784 //////////////////////////////////////////////////////////////////////
786 // Grid table classes
788 //////////////////////////////////////////////////////////////////////
791 class WXDLLEXPORT wxGridTableBase
: public wxObject
, public wxClientDataContainer
795 virtual ~wxGridTableBase();
797 // You must override these functions in a derived table class
799 virtual int GetNumberRows() = 0;
800 virtual int GetNumberCols() = 0;
801 virtual bool IsEmptyCell( int row
, int col
) = 0;
802 virtual wxString
GetValue( int row
, int col
) = 0;
803 virtual void SetValue( int row
, int col
, const wxString
& value
) = 0;
805 // Data type determination and value access
806 virtual wxString
GetTypeName( int row
, int col
);
807 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
808 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
810 virtual long GetValueAsLong( int row
, int col
);
811 virtual double GetValueAsDouble( int row
, int col
);
812 virtual bool GetValueAsBool( int row
, int col
);
814 virtual void SetValueAsLong( int row
, int col
, long value
);
815 virtual void SetValueAsDouble( int row
, int col
, double value
);
816 virtual void SetValueAsBool( int row
, int col
, bool value
);
818 // For user defined types
819 virtual void* GetValueAsCustom( int row
, int col
, const wxString
& typeName
);
820 virtual void SetValueAsCustom( int row
, int col
, const wxString
& typeName
, void* value
);
823 // Overriding these is optional
825 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
826 virtual wxGrid
* GetView() const { return m_view
; }
828 virtual void Clear() {}
829 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
830 virtual bool AppendRows( size_t numRows
= 1 );
831 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
832 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
833 virtual bool AppendCols( size_t numCols
= 1 );
834 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
836 virtual wxString
GetRowLabelValue( int row
);
837 virtual wxString
GetColLabelValue( int col
);
838 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
839 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
841 // Attribute handling
844 // give us the attr provider to use - we take ownership of the pointer
845 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
847 // get the currently used attr provider (may be NULL)
848 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
850 // Does this table allow attributes? Default implementation creates
851 // a wxGridCellAttrProvider if necessary.
852 virtual bool CanHaveAttributes();
854 // by default forwarded to wxGridCellAttrProvider if any. May be
855 // overridden to handle attributes directly in the table.
856 virtual wxGridCellAttr
*GetAttr( int row
, int col
,
857 wxGridCellAttr::wxAttrKind kind
);
860 // these functions take ownership of the pointer
861 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
862 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
863 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
867 wxGridCellAttrProvider
*m_attrProvider
;
869 DECLARE_ABSTRACT_CLASS( wxGridTableBase
);
870 DECLARE_NO_COPY_CLASS(wxGridTableBase
)
874 // ----------------------------------------------------------------------------
875 // wxGridTableMessage
876 // ----------------------------------------------------------------------------
878 // IDs for messages sent from grid table to view
880 enum wxGridTableRequest
882 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
883 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
884 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
885 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
886 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
887 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
888 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
889 wxGRIDTABLE_NOTIFY_COLS_DELETED
892 class WXDLLEXPORT wxGridTableMessage
895 wxGridTableMessage();
896 wxGridTableMessage( wxGridTableBase
*table
, int id
,
900 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
901 wxGridTableBase
* GetTableObject() const { return m_table
; }
902 void SetId( int id
) { m_id
= id
; }
903 int GetId() { return m_id
; }
904 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
905 int GetCommandInt() { return m_comInt1
; }
906 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
907 int GetCommandInt2() { return m_comInt2
; }
910 wxGridTableBase
*m_table
;
915 DECLARE_NO_COPY_CLASS(wxGridTableMessage
)
920 // ------ wxGridStringArray
921 // A 2-dimensional array of strings for data values
924 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString
, wxGridStringArray
);
928 // ------ wxGridStringTable
930 // Simplest type of data table for a grid for small tables of strings
931 // that are stored in memory
934 class WXDLLEXPORT wxGridStringTable
: public wxGridTableBase
938 wxGridStringTable( int numRows
, int numCols
);
939 virtual ~wxGridStringTable();
941 // these are pure virtual in wxGridTableBase
945 wxString
GetValue( int row
, int col
);
946 void SetValue( int row
, int col
, const wxString
& s
);
947 bool IsEmptyCell( int row
, int col
);
949 // overridden functions from wxGridTableBase
952 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
953 bool AppendRows( size_t numRows
= 1 );
954 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
955 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
956 bool AppendCols( size_t numCols
= 1 );
957 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
959 void SetRowLabelValue( int row
, const wxString
& );
960 void SetColLabelValue( int col
, const wxString
& );
961 wxString
GetRowLabelValue( int row
);
962 wxString
GetColLabelValue( int col
);
965 wxGridStringArray m_data
;
967 // These only get used if you set your own labels, otherwise the
968 // GetRow/ColLabelValue functions return wxGridTableBase defaults
970 wxArrayString m_rowLabels
;
971 wxArrayString m_colLabels
;
973 DECLARE_DYNAMIC_CLASS( wxGridStringTable
)
978 // ============================================================================
980 // ============================================================================
982 // ----------------------------------------------------------------------------
983 // wxGridCellCoords: location of a cell in the grid
984 // ----------------------------------------------------------------------------
986 class WXDLLEXPORT wxGridCellCoords
989 wxGridCellCoords() { m_row
= m_col
= -1; }
990 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
992 // default copy ctor is ok
994 int GetRow() const { return m_row
; }
995 void SetRow( int n
) { m_row
= n
; }
996 int GetCol() const { return m_col
; }
997 void SetCol( int n
) { m_col
= n
; }
998 void Set( int row
, int col
) { m_row
= row
; m_col
= col
; }
1000 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
1002 if ( &other
!= this )
1010 bool operator==( const wxGridCellCoords
& other
) const
1012 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
1015 bool operator!=( const wxGridCellCoords
& other
) const
1017 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
1020 bool operator!() const
1022 return (m_row
== -1 && m_col
== -1 );
1031 // For comparisons...
1033 extern WXDLLEXPORT wxGridCellCoords wxGridNoCellCoords
;
1034 extern WXDLLEXPORT wxRect wxGridNoCellRect
;
1036 // An array of cell coords...
1038 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords
, wxGridCellCoordsArray
);
1040 // ----------------------------------------------------------------------------
1042 // ----------------------------------------------------------------------------
1044 class WXDLLEXPORT wxGrid
: public wxScrolledWindow
1052 wxGrid( wxWindow
*parent
,
1054 const wxPoint
& pos
= wxDefaultPosition
,
1055 const wxSize
& size
= wxDefaultSize
,
1056 long style
= wxWANTS_CHARS
,
1057 const wxString
& name
= wxPanelNameStr
);
1061 enum wxGridSelectionModes
{wxGridSelectCells
,
1063 wxGridSelectColumns
};
1065 bool CreateGrid( int numRows
, int numCols
,
1066 wxGrid::wxGridSelectionModes selmode
=
1067 wxGrid::wxGridSelectCells
);
1069 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
1070 wxGrid::wxGridSelectionModes
GetSelectionMode() const;
1072 // ------ grid dimensions
1074 int GetNumberRows() { return m_numRows
; }
1075 int GetNumberCols() { return m_numCols
; }
1078 // ------ display update functions
1080 wxArrayInt
CalcRowLabelsExposed( const wxRegion
& reg
);
1082 wxArrayInt
CalcColLabelsExposed( const wxRegion
& reg
);
1083 wxGridCellCoordsArray
CalcCellsExposed( const wxRegion
& reg
);
1086 // ------ event handlers
1088 void ProcessRowLabelMouseEvent( wxMouseEvent
& event
);
1089 void ProcessColLabelMouseEvent( wxMouseEvent
& event
);
1090 void ProcessCornerLabelMouseEvent( wxMouseEvent
& event
);
1091 void ProcessGridCellMouseEvent( wxMouseEvent
& event
);
1092 bool ProcessTableMessage( wxGridTableMessage
& );
1094 void DoEndDragResizeRow();
1095 void DoEndDragResizeCol();
1097 wxGridTableBase
* GetTable() const { return m_table
; }
1098 bool SetTable( wxGridTableBase
*table
, bool takeOwnership
=FALSE
,
1099 wxGrid::wxGridSelectionModes selmode
=
1100 wxGrid::wxGridSelectCells
);
1103 bool InsertRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1104 bool AppendRows( int numRows
= 1, bool updateLabels
=TRUE
);
1105 bool DeleteRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1106 bool InsertCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1107 bool AppendCols( int numCols
= 1, bool updateLabels
=TRUE
);
1108 bool DeleteCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1110 void DrawGridCellArea( wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1111 void DrawGridSpace( wxDC
& dc
);
1112 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
1113 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
1114 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
1115 void DrawHighlight(wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1117 // this function is called when the current cell highlight must be redrawn
1118 // and may be overridden by the user
1119 virtual void DrawCellHighlight( wxDC
& dc
, const wxGridCellAttr
*attr
);
1121 void DrawRowLabels( wxDC
& dc
, const wxArrayInt
& rows
);
1122 void DrawRowLabel( wxDC
& dc
, int row
);
1124 void DrawColLabels( wxDC
& dc
, const wxArrayInt
& cols
);
1125 void DrawColLabel( wxDC
& dc
, int col
);
1128 // ------ Cell text drawing functions
1130 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
1131 int horizontalAlignment
= wxALIGN_LEFT
,
1132 int verticalAlignment
= wxALIGN_TOP
,
1133 int textOrientation
= wxHORIZONTAL
);
1135 void DrawTextRectangle( wxDC
& dc
, const wxArrayString
& lines
, const wxRect
&,
1136 int horizontalAlignment
= wxALIGN_LEFT
,
1137 int verticalAlignment
= wxALIGN_TOP
,
1138 int textOrientation
= wxHORIZONTAL
);
1141 // Split a string containing newline chararcters into an array of
1142 // strings and return the number of lines
1144 void StringToLines( const wxString
& value
, wxArrayString
& lines
);
1146 void GetTextBoxSize( wxDC
& dc
,
1147 const wxArrayString
& lines
,
1148 long *width
, long *height
);
1152 // Code that does a lot of grid modification can be enclosed
1153 // between BeginBatch() and EndBatch() calls to avoid screen
1156 void BeginBatch() { m_batchCount
++; }
1159 int GetBatchCount() { return m_batchCount
; }
1161 virtual void Refresh(bool eraseb
= TRUE
,
1162 const wxRect
* rect
= (const wxRect
*) NULL
);
1164 // Use this, rather than wxWindow::Refresh(), to force an
1165 // immediate repainting of the grid. Has no effect if you are
1166 // already inside a BeginBatch / EndBatch block.
1168 // This function is necessary because wxGrid has a minimal OnPaint()
1169 // handler to reduce screen flicker.
1171 void ForceRefresh();
1174 // ------ edit control functions
1176 bool IsEditable() const { return m_editable
; }
1177 void EnableEditing( bool edit
);
1179 void EnableCellEditControl( bool enable
= TRUE
);
1180 void DisableCellEditControl() { EnableCellEditControl(FALSE
); }
1181 bool CanEnableCellControl() const;
1182 bool IsCellEditControlEnabled() const;
1183 bool IsCellEditControlShown() const;
1185 bool IsCurrentCellReadOnly() const;
1187 void ShowCellEditControl();
1188 void HideCellEditControl();
1189 void SaveEditControlValue();
1192 // ------ grid location functions
1193 // Note that all of these functions work with the logical coordinates of
1194 // grid cells and labels so you will need to convert from device
1195 // coordinates for mouse events etc.
1197 void XYToCell( int x
, int y
, wxGridCellCoords
& );
1198 int YToRow( int y
);
1199 int XToCol( int x
);
1201 int YToEdgeOfRow( int y
);
1202 int XToEdgeOfCol( int x
);
1204 wxRect
CellToRect( int row
, int col
);
1205 wxRect
CellToRect( const wxGridCellCoords
& coords
)
1206 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
1208 int GetGridCursorRow() { return m_currentCellCoords
.GetRow(); }
1209 int GetGridCursorCol() { return m_currentCellCoords
.GetCol(); }
1211 // check to see if a cell is either wholly visible (the default arg) or
1212 // at least partially visible in the grid window
1214 bool IsVisible( int row
, int col
, bool wholeCellVisible
= TRUE
);
1215 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= TRUE
)
1216 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
1217 void MakeCellVisible( int row
, int col
);
1218 void MakeCellVisible( const wxGridCellCoords
& coords
)
1219 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
1222 // ------ grid cursor movement functions
1224 void SetGridCursor( int row
, int col
)
1225 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1227 bool MoveCursorUp( bool expandSelection
);
1228 bool MoveCursorDown( bool expandSelection
);
1229 bool MoveCursorLeft( bool expandSelection
);
1230 bool MoveCursorRight( bool expandSelection
);
1231 bool MovePageDown();
1233 bool MoveCursorUpBlock( bool expandSelection
);
1234 bool MoveCursorDownBlock( bool expandSelection
);
1235 bool MoveCursorLeftBlock( bool expandSelection
);
1236 bool MoveCursorRightBlock( bool expandSelection
);
1239 // ------ label and gridline formatting
1241 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
1242 int GetRowLabelSize() { return m_rowLabelWidth
; }
1243 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
1244 int GetColLabelSize() { return m_colLabelHeight
; }
1245 wxColour
GetLabelBackgroundColour() { return m_labelBackgroundColour
; }
1246 wxColour
GetLabelTextColour() { return m_labelTextColour
; }
1247 wxFont
GetLabelFont() { return m_labelFont
; }
1248 void GetRowLabelAlignment( int *horiz
, int *vert
);
1249 void GetColLabelAlignment( int *horiz
, int *vert
);
1250 int GetColLabelTextOrientation();
1251 wxString
GetRowLabelValue( int row
);
1252 wxString
GetColLabelValue( int col
);
1253 wxColour
GetGridLineColour() { return m_gridLineColour
; }
1254 wxColour
GetCellHighlightColour() { return m_cellHighlightColour
; }
1255 int GetCellHighlightPenWidth() { return m_cellHighlightPenWidth
; }
1256 int GetCellHighlightROPenWidth() { return m_cellHighlightROPenWidth
; }
1258 void SetRowLabelSize( int width
);
1259 void SetColLabelSize( int height
);
1260 void SetLabelBackgroundColour( const wxColour
& );
1261 void SetLabelTextColour( const wxColour
& );
1262 void SetLabelFont( const wxFont
& );
1263 void SetRowLabelAlignment( int horiz
, int vert
);
1264 void SetColLabelAlignment( int horiz
, int vert
);
1265 void SetColLabelTextOrientation( int textOrientation
);
1266 void SetRowLabelValue( int row
, const wxString
& );
1267 void SetColLabelValue( int col
, const wxString
& );
1268 void SetGridLineColour( const wxColour
& );
1269 void SetCellHighlightColour( const wxColour
& );
1270 void SetCellHighlightPenWidth(int width
);
1271 void SetCellHighlightROPenWidth(int width
);
1273 void EnableDragRowSize( bool enable
= TRUE
);
1274 void DisableDragRowSize() { EnableDragRowSize( FALSE
); }
1275 bool CanDragRowSize() { return m_canDragRowSize
; }
1276 void EnableDragColSize( bool enable
= TRUE
);
1277 void DisableDragColSize() { EnableDragColSize( FALSE
); }
1278 bool CanDragColSize() { return m_canDragColSize
; }
1279 void EnableDragGridSize(bool enable
= TRUE
);
1280 void DisableDragGridSize() { EnableDragGridSize(FALSE
); }
1281 bool CanDragGridSize() { return m_canDragGridSize
; }
1283 // this sets the specified attribute for this cell or in this row/col
1284 void SetAttr(int row
, int col
, wxGridCellAttr
*attr
);
1285 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
1286 void SetColAttr(int col
, wxGridCellAttr
*attr
);
1288 // shortcuts for setting the column parameters
1290 // set the format for the data in the column: default is string
1291 void SetColFormatBool(int col
);
1292 void SetColFormatNumber(int col
);
1293 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
1294 void SetColFormatCustom(int col
, const wxString
& typeName
);
1296 void EnableGridLines( bool enable
= TRUE
);
1297 bool GridLinesEnabled() { return m_gridLinesEnabled
; }
1299 // ------ row and col formatting
1301 int GetDefaultRowSize();
1302 int GetRowSize( int row
);
1303 int GetDefaultColSize();
1304 int GetColSize( int col
);
1305 wxColour
GetDefaultCellBackgroundColour();
1306 wxColour
GetCellBackgroundColour( int row
, int col
);
1307 wxColour
GetDefaultCellTextColour();
1308 wxColour
GetCellTextColour( int row
, int col
);
1309 wxFont
GetDefaultCellFont();
1310 wxFont
GetCellFont( int row
, int col
);
1311 void GetDefaultCellAlignment( int *horiz
, int *vert
);
1312 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
);
1313 bool GetDefaultCellOverflow();
1314 bool GetCellOverflow( int row
, int col
);
1315 void GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
);
1317 void SetDefaultRowSize( int height
, bool resizeExistingRows
= FALSE
);
1318 void SetRowSize( int row
, int height
);
1319 void SetDefaultColSize( int width
, bool resizeExistingCols
= FALSE
);
1321 void SetColSize( int col
, int width
);
1323 // automatically size the column or row to fit to its contents, if
1324 // setAsMin is TRUE, this optimal width will also be set as minimal width
1326 void AutoSizeColumn( int col
, bool setAsMin
= TRUE
)
1327 { AutoSizeColOrRow(col
, setAsMin
, TRUE
); }
1328 void AutoSizeRow( int row
, bool setAsMin
= TRUE
)
1329 { AutoSizeColOrRow(row
, setAsMin
, FALSE
); }
1331 // auto size all columns (very ineffective for big grids!)
1332 void AutoSizeColumns( bool setAsMin
= TRUE
)
1333 { (void)SetOrCalcColumnSizes(FALSE
, setAsMin
); }
1335 void AutoSizeRows( bool setAsMin
= TRUE
)
1336 { (void)SetOrCalcRowSizes(FALSE
, setAsMin
); }
1338 // auto size the grid, that is make the columns/rows of the "right" size
1339 // and also set the grid size to just fit its contents
1342 // autosize row height depending on label text
1343 void AutoSizeRowLabelSize( int row
);
1345 // autosize column width depending on label text
1346 void AutoSizeColLabelSize( int col
);
1348 // column won't be resized to be lesser width - this must be called during
1349 // the grid creation because it won't resize the column if it's already
1350 // narrower than the minimal width
1351 void SetColMinimalWidth( int col
, int width
);
1352 void SetRowMinimalHeight( int row
, int width
);
1354 /* These members can be used to query and modify the minimal
1355 * acceptable size of grid rows and columns. Call this function in
1356 * your code which creates the grid if you want to display cells
1357 * with a size smaller than the default acceptable minimum size.
1358 * Like the members SetColMinimalWidth and SetRowMinimalWidth,
1359 * the existing rows or columns will not be checked/resized.
1361 void SetColMinimalAcceptableWidth( int width
);
1362 void SetRowMinimalAcceptableHeight( int width
);
1363 int GetColMinimalAcceptableWidth() const;
1364 int GetRowMinimalAcceptableHeight() const;
1366 void SetDefaultCellBackgroundColour( const wxColour
& );
1367 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
1368 void SetDefaultCellTextColour( const wxColour
& );
1370 void SetCellTextColour( int row
, int col
, const wxColour
& );
1371 void SetDefaultCellFont( const wxFont
& );
1372 void SetCellFont( int row
, int col
, const wxFont
& );
1373 void SetDefaultCellAlignment( int horiz
, int vert
);
1374 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
1375 void SetDefaultCellOverflow( bool allow
);
1376 void SetCellOverflow( int row
, int col
, bool allow
);
1377 void SetCellSize( int row
, int col
, int num_rows
, int num_cols
);
1379 // takes ownership of the pointer
1380 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
1381 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
1382 wxGridCellRenderer
*GetDefaultRenderer() const;
1383 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
1385 // takes ownership of the pointer
1386 void SetDefaultEditor(wxGridCellEditor
*editor
);
1387 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
1388 wxGridCellEditor
*GetDefaultEditor() const;
1389 wxGridCellEditor
* GetCellEditor(int row
, int col
);
1393 // ------ cell value accessors
1395 wxString
GetCellValue( int row
, int col
)
1399 return m_table
->GetValue( row
, col
);
1403 return wxEmptyString
;
1407 wxString
GetCellValue( const wxGridCellCoords
& coords
)
1408 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
1410 void SetCellValue( int row
, int col
, const wxString
& s
);
1411 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
1412 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
1414 // returns TRUE if the cell can't be edited
1415 bool IsReadOnly(int row
, int col
) const;
1417 // make the cell editable/readonly
1418 void SetReadOnly(int row
, int col
, bool isReadOnly
= TRUE
);
1420 // ------ select blocks of cells
1422 void SelectRow( int row
, bool addToSelected
= FALSE
);
1423 void SelectCol( int col
, bool addToSelected
= FALSE
);
1425 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
,
1426 bool addToSelected
= FALSE
);
1428 void SelectBlock( const wxGridCellCoords
& topLeft
,
1429 const wxGridCellCoords
& bottomRight
,
1430 bool addToSelected
= FALSE
)
1431 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1432 bottomRight
.GetRow(), bottomRight
.GetCol(),
1439 // ------ deselect blocks or cells
1441 void DeselectRow( int row
);
1442 void DeselectCol( int col
);
1443 void DeselectCell( int row
, int col
);
1445 void ClearSelection();
1447 bool IsInSelection( int row
, int col
) const;
1449 bool IsInSelection( const wxGridCellCoords
& coords
) const
1450 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
1452 wxGridCellCoordsArray
GetSelectedCells() const;
1453 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1454 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1455 wxArrayInt
GetSelectedRows() const;
1456 wxArrayInt
GetSelectedCols() const;
1458 // This function returns the rectangle that encloses the block of cells
1459 // limited by TopLeft and BottomRight cell in device coords and clipped
1460 // to the client size of the grid window.
1462 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
1463 const wxGridCellCoords
& bottomRight
);
1465 // Access or update the selection fore/back colours
1466 wxColour
GetSelectionBackground() const
1467 { return m_selectionBackground
; }
1468 wxColour
GetSelectionForeground() const
1469 { return m_selectionForeground
; }
1471 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
1472 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
1475 // Methods for a registry for mapping data types to Renderers/Editors
1476 void RegisterDataType(const wxString
& typeName
,
1477 wxGridCellRenderer
* renderer
,
1478 wxGridCellEditor
* editor
);
1480 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1481 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const
1482 { return GetDefaultEditorForCell(c
.GetRow(), c
.GetCol()); }
1483 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1484 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1485 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1487 // grid may occupy more space than needed for its rows/columns, this
1488 // function allows to set how big this extra space is
1489 void SetMargins(int extraWidth
, int extraHeight
)
1491 m_extraWidth
= extraWidth
;
1492 m_extraHeight
= extraHeight
;
1497 // Accessors for component windows
1498 wxWindow
* GetGridWindow() { return (wxWindow
*)m_gridWin
; }
1499 wxWindow
* GetGridRowLabelWindow() { return (wxWindow
*)m_rowLabelWin
; }
1500 wxWindow
* GetGridColLabelWindow() { return (wxWindow
*)m_colLabelWin
; }
1501 wxWindow
* GetGridCornerLabelWindow() { return (wxWindow
*)m_cornerLabelWin
; }
1505 // ------ For compatibility with previous wxGrid only...
1507 // ************************************************
1508 // ** Don't use these in new code because they **
1509 // ** are liable to disappear in a future **
1511 // ************************************************
1514 wxGrid( wxWindow
*parent
,
1515 int x
, int y
, int w
= -1, int h
= -1,
1516 long style
= wxWANTS_CHARS
,
1517 const wxString
& name
= wxPanelNameStr
)
1518 : wxScrolledWindow( parent
, -1, wxPoint(x
,y
), wxSize(w
,h
),
1519 (style
|wxWANTS_CHARS
), name
)
1524 void SetCellValue( const wxString
& val
, int row
, int col
)
1525 { SetCellValue( row
, col
, val
); }
1527 void UpdateDimensions()
1528 { CalcDimensions(); }
1530 int GetRows() { return GetNumberRows(); }
1531 int GetCols() { return GetNumberCols(); }
1532 int GetCursorRow() { return GetGridCursorRow(); }
1533 int GetCursorColumn() { return GetGridCursorCol(); }
1535 int GetScrollPosX() { return 0; }
1536 int GetScrollPosY() { return 0; }
1538 void SetScrollX( int WXUNUSED(x
) ) { }
1539 void SetScrollY( int WXUNUSED(y
) ) { }
1541 void SetColumnWidth( int col
, int width
)
1542 { SetColSize( col
, width
); }
1544 int GetColumnWidth( int col
)
1545 { return GetColSize( col
); }
1547 void SetRowHeight( int row
, int height
)
1548 { SetRowSize( row
, height
); }
1550 // GetRowHeight() is below
1552 int GetViewHeight() // returned num whole rows visible
1555 int GetViewWidth() // returned num whole cols visible
1558 void SetLabelSize( int orientation
, int sz
)
1560 if ( orientation
== wxHORIZONTAL
)
1561 SetColLabelSize( sz
);
1563 SetRowLabelSize( sz
);
1566 int GetLabelSize( int orientation
)
1568 if ( orientation
== wxHORIZONTAL
)
1569 return GetColLabelSize();
1571 return GetRowLabelSize();
1574 void SetLabelAlignment( int orientation
, int align
)
1576 if ( orientation
== wxHORIZONTAL
)
1577 SetColLabelAlignment( align
, -1 );
1579 SetRowLabelAlignment( align
, -1 );
1582 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) )
1585 if ( orientation
== wxHORIZONTAL
)
1587 GetColLabelAlignment( &h
, &v
);
1592 GetRowLabelAlignment( &h
, &v
);
1597 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
1599 if ( orientation
== wxHORIZONTAL
)
1600 SetColLabelValue( pos
, val
);
1602 SetRowLabelValue( pos
, val
);
1605 wxString
GetLabelValue( int orientation
, int pos
)
1607 if ( orientation
== wxHORIZONTAL
)
1608 return GetColLabelValue( pos
);
1610 return GetRowLabelValue( pos
);
1613 wxFont
GetCellTextFont() const
1614 { return m_defaultCellAttr
->GetFont(); }
1616 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
1617 { return m_defaultCellAttr
->GetFont(); }
1619 void SetCellTextFont(const wxFont
& fnt
)
1620 { SetDefaultCellFont( fnt
); }
1622 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1623 { SetCellFont( row
, col
, fnt
); }
1625 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1626 { SetCellTextColour( row
, col
, val
); }
1628 void SetCellTextColour(const wxColour
& col
)
1629 { SetDefaultCellTextColour( col
); }
1631 void SetCellBackgroundColour(const wxColour
& col
)
1632 { SetDefaultCellBackgroundColour( col
); }
1634 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1635 { SetCellBackgroundColour( row
, col
, colour
); }
1637 bool GetEditable() { return IsEditable(); }
1638 void SetEditable( bool edit
= TRUE
) { EnableEditing( edit
); }
1639 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1641 void SetEditInPlace(bool WXUNUSED(edit
) = TRUE
) { }
1643 void SetCellAlignment( int align
, int row
, int col
)
1644 { SetCellAlignment(row
, col
, align
, wxALIGN_CENTER
); }
1645 void SetCellAlignment( int WXUNUSED(align
) ) {}
1646 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1648 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1649 wxPen
& GetDividerPen() const;
1650 void OnActivate(bool WXUNUSED(active
)) {}
1652 // ******** End of compatibility functions **********
1656 // ------ control IDs
1657 enum { wxGRID_CELLCTRL
= 2000,
1660 // ------ control types
1661 enum { wxGRID_TEXTCTRL
= 2100,
1666 // overridden wxWindow methods
1670 virtual wxSize
DoGetBestSize() const;
1674 wxGridWindow
*m_gridWin
;
1675 wxGridRowLabelWindow
*m_rowLabelWin
;
1676 wxGridColLabelWindow
*m_colLabelWin
;
1677 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1679 wxGridTableBase
*m_table
;
1685 wxGridCellCoords m_currentCellCoords
;
1687 wxGridCellCoords m_selectingTopLeft
;
1688 wxGridCellCoords m_selectingBottomRight
;
1689 wxGridCellCoords m_selectingKeyboard
;
1690 wxGridSelection
*m_selection
;
1691 wxColour m_selectionBackground
;
1692 wxColour m_selectionForeground
;
1694 // NB: *never* access m_row/col arrays directly because they are created
1695 // on demand, *always* use accessor functions instead!
1697 // init the m_rowHeights/Bottoms arrays with default values
1698 void InitRowHeights();
1700 int m_defaultRowHeight
;
1701 int m_minAcceptableRowHeight
;
1702 wxArrayInt m_rowHeights
;
1703 wxArrayInt m_rowBottoms
;
1705 // init the m_colWidths/Rights arrays
1706 void InitColWidths();
1708 int m_defaultColWidth
;
1709 int m_minAcceptableColWidth
;
1710 wxArrayInt m_colWidths
;
1711 wxArrayInt m_colRights
;
1713 // get the col/row coords
1714 int GetColWidth(int col
) const;
1715 int GetColLeft(int col
) const;
1716 int GetColRight(int col
) const;
1718 // this function must be public for compatibility...
1720 int GetRowHeight(int row
) const;
1723 int GetRowTop(int row
) const;
1724 int GetRowBottom(int row
) const;
1726 int m_rowLabelWidth
;
1727 int m_colLabelHeight
;
1729 // the size of the margin left to the right and bottom of the cell area
1733 wxColour m_labelBackgroundColour
;
1734 wxColour m_labelTextColour
;
1737 int m_rowLabelHorizAlign
;
1738 int m_rowLabelVertAlign
;
1739 int m_colLabelHorizAlign
;
1740 int m_colLabelVertAlign
;
1741 int m_colLabelTextOrientation
;
1743 bool m_defaultRowLabelValues
;
1744 bool m_defaultColLabelValues
;
1746 wxColour m_gridLineColour
;
1747 bool m_gridLinesEnabled
;
1748 wxColour m_cellHighlightColour
;
1749 int m_cellHighlightPenWidth
;
1750 int m_cellHighlightROPenWidth
;
1753 // common part of AutoSizeColumn/Row() and GetBestSize()
1754 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1755 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1757 // common part of AutoSizeColumn/Row()
1758 void AutoSizeColOrRow(int n
, bool setAsMin
, bool column
/* or row? */);
1760 // if a column has a minimal width, it will be the value for it in this
1762 wxHashTableLong m_colMinWidths
,
1765 // get the minimal width of the given column/row
1766 int GetColMinimalWidth(int col
) const;
1767 int GetRowMinimalHeight(int col
) const;
1769 // do we have some place to store attributes in?
1770 bool CanHaveAttributes();
1772 // returns the attribute we may modify in place: a new one if this cell
1773 // doesn't have any yet or the existing one if it does
1775 // DecRef() must be called on the returned pointer, as usual
1776 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1778 // cell attribute cache (currently we only cache 1, may be will do
1779 // more/better later)
1783 wxGridCellAttr
*attr
;
1786 // invalidates the attribute cache
1787 void ClearAttrCache();
1789 // adds an attribute to cache
1790 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1792 // looks for an attr in cache, returns TRUE if found
1793 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1795 // looks for the attr in cache, if not found asks the table and caches the
1797 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1798 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
)
1799 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1801 // the default cell attr object for cells that don't have their own
1802 wxGridCellAttr
* m_defaultCellAttr
;
1809 wxGridTypeRegistry
* m_typeRegistry
;
1813 WXGRID_CURSOR_SELECT_CELL
,
1814 WXGRID_CURSOR_RESIZE_ROW
,
1815 WXGRID_CURSOR_RESIZE_COL
,
1816 WXGRID_CURSOR_SELECT_ROW
,
1817 WXGRID_CURSOR_SELECT_COL
1820 // this method not only sets m_cursorMode but also sets the correct cursor
1821 // for the given mode and, if captureMouse is not FALSE releases the mouse
1822 // if it was captured and captures it if it must be captured
1824 // for this to work, you should always use it and not set m_cursorMode
1826 void ChangeCursorMode(CursorMode mode
,
1827 wxWindow
*win
= (wxWindow
*)NULL
,
1828 bool captureMouse
= TRUE
);
1830 wxWindow
*m_winCapture
; // the window which captured the mouse
1831 CursorMode m_cursorMode
;
1833 bool m_canDragRowSize
;
1834 bool m_canDragColSize
;
1835 bool m_canDragGridSize
;
1839 wxPoint m_startDragPos
;
1841 bool m_waitForSlowClick
;
1843 wxGridCellCoords m_selectionStart
;
1845 wxCursor m_rowResizeCursor
;
1846 wxCursor m_colResizeCursor
;
1848 bool m_editable
; // applies to whole grid
1849 bool m_cellEditCtrlEnabled
; // is in-place edit currently shown?
1854 void CalcDimensions();
1855 void CalcWindowSizes();
1856 bool Redimension( wxGridTableMessage
& );
1859 int SendEvent( const wxEventType
, int row
, int col
, wxMouseEvent
& );
1860 int SendEvent( const wxEventType
, int row
, int col
);
1861 int SendEvent( const wxEventType type
)
1863 return SendEvent(type
,
1864 m_currentCellCoords
.GetRow(),
1865 m_currentCellCoords
.GetCol());
1868 void OnPaint( wxPaintEvent
& );
1869 void OnSize( wxSizeEvent
& );
1870 void OnKeyDown( wxKeyEvent
& );
1871 void OnKeyUp( wxKeyEvent
& );
1872 void OnEraseBackground( wxEraseEvent
& );
1875 void SetCurrentCell( const wxGridCellCoords
& coords
);
1876 void SetCurrentCell( int row
, int col
)
1877 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1879 void HighlightBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
);
1881 void HighlightBlock( const wxGridCellCoords
& topLeft
,
1882 const wxGridCellCoords
& bottomRight
)
1883 { HighlightBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1884 bottomRight
.GetRow(), bottomRight
.GetCol() ); }
1886 // ------ functions to get/send data (see also public functions)
1888 bool GetModelValues();
1889 bool SetModelValues();
1891 friend class WXDLLEXPORT wxGridSelection
;
1893 DECLARE_DYNAMIC_CLASS( wxGrid
)
1894 DECLARE_EVENT_TABLE()
1895 DECLARE_NO_COPY_CLASS(wxGrid
)
1899 // ----------------------------------------------------------------------------
1900 // Grid event class and event types
1901 // ----------------------------------------------------------------------------
1903 class WXDLLEXPORT wxGridEvent
: public wxNotifyEvent
1907 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1908 m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0)
1912 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
1913 int row
=-1, int col
=-1, int x
=-1, int y
=-1, bool sel
= TRUE
,
1914 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1916 virtual int GetRow() { return m_row
; }
1917 virtual int GetCol() { return m_col
; }
1918 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1919 bool Selecting() { return m_selecting
; }
1920 bool ControlDown() { return m_control
; }
1921 bool MetaDown() { return m_meta
; }
1922 bool ShiftDown() { return m_shift
; }
1923 bool AltDown() { return m_alt
; }
1936 DECLARE_DYNAMIC_CLASS(wxGridEvent
)
1939 class WXDLLEXPORT wxGridSizeEvent
: public wxNotifyEvent
1943 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1944 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1948 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
1949 int rowOrCol
=-1, int x
=-1, int y
=-1,
1950 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1952 int GetRowOrCol() { return m_rowOrCol
; }
1953 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1954 bool ControlDown() { return m_control
; }
1955 bool MetaDown() { return m_meta
; }
1956 bool ShiftDown() { return m_shift
; }
1957 bool AltDown() { return m_alt
; }
1968 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent
)
1972 class WXDLLEXPORT wxGridRangeSelectEvent
: public wxNotifyEvent
1975 wxGridRangeSelectEvent()
1978 m_topLeft
= wxGridNoCellCoords
;
1979 m_bottomRight
= wxGridNoCellCoords
;
1980 m_selecting
= FALSE
;
1987 wxGridRangeSelectEvent(int id
, wxEventType type
, wxObject
* obj
,
1988 const wxGridCellCoords
& topLeft
,
1989 const wxGridCellCoords
& bottomRight
,
1991 bool control
=FALSE
, bool shift
=FALSE
,
1992 bool alt
=FALSE
, bool meta
=FALSE
);
1994 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
1995 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
1996 int GetTopRow() { return m_topLeft
.GetRow(); }
1997 int GetBottomRow() { return m_bottomRight
.GetRow(); }
1998 int GetLeftCol() { return m_topLeft
.GetCol(); }
1999 int GetRightCol() { return m_bottomRight
.GetCol(); }
2000 bool Selecting() { return m_selecting
; }
2001 bool ControlDown() { return m_control
; }
2002 bool MetaDown() { return m_meta
; }
2003 bool ShiftDown() { return m_shift
; }
2004 bool AltDown() { return m_alt
; }
2007 wxGridCellCoords m_topLeft
;
2008 wxGridCellCoords m_bottomRight
;
2015 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent
)
2019 class WXDLLEXPORT wxGridEditorCreatedEvent
: public wxCommandEvent
{
2021 wxGridEditorCreatedEvent()
2029 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
2030 int row
, int col
, wxControl
* ctrl
);
2032 int GetRow() { return m_row
; }
2033 int GetCol() { return m_col
; }
2034 wxControl
* GetControl() { return m_ctrl
; }
2035 void SetRow(int row
) { m_row
= row
; }
2036 void SetCol(int col
) { m_col
= col
; }
2037 void SetControl(wxControl
* ctrl
) { m_ctrl
= ctrl
; }
2044 DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent
)
2045 DECLARE_NO_COPY_CLASS(wxGridEditorCreatedEvent
)
2049 BEGIN_DECLARE_EVENT_TYPES()
2050 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_CLICK
, 1580)
2051 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_CLICK
, 1581)
2052 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_DCLICK
, 1582)
2053 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_DCLICK
, 1583)
2054 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_CLICK
, 1584)
2055 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_CLICK
, 1585)
2056 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_DCLICK
, 1586)
2057 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_DCLICK
, 1587)
2058 DECLARE_EVENT_TYPE(wxEVT_GRID_ROW_SIZE
, 1588)
2059 DECLARE_EVENT_TYPE(wxEVT_GRID_COL_SIZE
, 1589)
2060 DECLARE_EVENT_TYPE(wxEVT_GRID_RANGE_SELECT
, 1590)
2061 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_CHANGE
, 1591)
2062 DECLARE_EVENT_TYPE(wxEVT_GRID_SELECT_CELL
, 1592)
2063 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_SHOWN
, 1593)
2064 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_HIDDEN
, 1594)
2065 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_CREATED
, 1595)
2066 END_DECLARE_EVENT_TYPES()
2069 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
2070 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
2071 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
2072 typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction
)(wxGridEditorCreatedEvent
&);
2074 #define EVT_GRID_CELL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2075 #define EVT_GRID_CELL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2076 #define EVT_GRID_CELL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2077 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2078 #define EVT_GRID_LABEL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2079 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2080 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2081 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2082 #define EVT_GRID_ROW_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
2083 #define EVT_GRID_COL_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
2084 #define EVT_GRID_RANGE_SELECT(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL ),
2085 #define EVT_GRID_CELL_CHANGE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2086 #define EVT_GRID_SELECT_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2087 #define EVT_GRID_EDITOR_SHOWN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2088 #define EVT_GRID_EDITOR_HIDDEN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2089 #define EVT_GRID_EDITOR_CREATED(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_CREATED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEditorCreatedEventFunction) &fn, NULL ),
2092 #if 0 // TODO: implement these ? others ?
2094 extern const int wxEVT_GRID_CREATE_CELL
;
2095 extern const int wxEVT_GRID_CHANGE_LABELS
;
2096 extern const int wxEVT_GRID_CHANGE_SEL_LABEL
;
2098 #define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2099 #define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2100 #define EVT_GRID_CHANGE_SEL_LABEL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2104 #endif // ifndef wxUSE_GRID