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"
21 #if defined(__GNUG__) && !defined(__APPLE__)
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"
34 #include "wx/clntdata.h"
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 // Default parameters for wxGrid
42 #define WXGRID_DEFAULT_NUMBER_ROWS 10
43 #define WXGRID_DEFAULT_NUMBER_COLS 10
45 #define WXGRID_DEFAULT_ROW_HEIGHT 25
47 #define WXGRID_DEFAULT_ROW_HEIGHT 30
49 #define WXGRID_DEFAULT_COL_WIDTH 80
50 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
51 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
52 #define WXGRID_LABEL_EDGE_ZONE 2
53 #define WXGRID_MIN_ROW_HEIGHT 15
54 #define WXGRID_MIN_COL_WIDTH 15
55 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
57 // type names for grid table values
58 #define wxGRID_VALUE_STRING _T("string")
59 #define wxGRID_VALUE_BOOL _T("bool")
60 #define wxGRID_VALUE_NUMBER _T("long")
61 #define wxGRID_VALUE_FLOAT _T("double")
62 #define wxGRID_VALUE_CHOICE _T("choice")
64 #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
65 #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
67 // ----------------------------------------------------------------------------
68 // forward declarations
69 // ----------------------------------------------------------------------------
71 class WXDLLEXPORT wxGrid
;
72 class WXDLLEXPORT wxGridCellAttr
;
73 class WXDLLEXPORT wxGridCellAttrProviderData
;
74 class WXDLLEXPORT wxGridColLabelWindow
;
75 class WXDLLEXPORT wxGridCornerLabelWindow
;
76 class WXDLLEXPORT wxGridRowLabelWindow
;
77 class WXDLLEXPORT wxGridTableBase
;
78 class WXDLLEXPORT wxGridWindow
;
79 class WXDLLEXPORT wxGridTypeRegistry
;
80 class WXDLLEXPORT wxGridSelection
;
82 class WXDLLEXPORT wxCheckBox
;
83 class WXDLLEXPORT wxComboBox
;
84 class WXDLLEXPORT wxTextCtrl
;
85 class WXDLLEXPORT wxSpinCtrl
;
87 // ----------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
91 #define wxSafeIncRef(p) if ( p ) (p)->IncRef()
92 #define wxSafeDecRef(p) if ( p ) (p)->DecRef()
94 // ----------------------------------------------------------------------------
95 // wxGridCellWorker: common base class for wxGridCellRenderer and
98 // NB: this is more an implementation convenience than a design issue, so this
99 // class is not documented and is not public at all
100 // ----------------------------------------------------------------------------
102 class WXDLLEXPORT wxGridCellWorker
: public wxClientDataContainer
105 wxGridCellWorker() { m_nRef
= 1; }
107 // this class is ref counted: it is created with ref count of 1, so
108 // calling DecRef() once will delete it. Calling IncRef() allows to lock
109 // it until the matching DecRef() is called
110 void IncRef() { m_nRef
++; }
111 void DecRef() { if ( !--m_nRef
) delete this; }
113 // interpret renderer parameters: arbitrary string whose interpretatin is
114 // left to the derived classes
115 virtual void SetParameters(const wxString
& params
);
118 // virtual dtor for any base class - private because only DecRef() can
120 virtual ~wxGridCellWorker();
125 // suppress the stupid gcc warning about the class having private dtor and
127 friend class wxGridCellWorkerDummyFriend
;
130 // ----------------------------------------------------------------------------
131 // wxGridCellRenderer: this class is responsible for actually drawing the cell
132 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
133 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
134 // view of all cells. This is an ABC, you will normally use one of the
135 // predefined derived classes or derive your own class from it.
136 // ----------------------------------------------------------------------------
138 class WXDLLEXPORT wxGridCellRenderer
: public wxGridCellWorker
141 // draw the given cell on the provided DC inside the given rectangle
142 // using the style specified by the attribute and the default or selected
143 // state corresponding to the isSelected value.
145 // this pure virtual function has a default implementation which will
146 // prepare the DC using the given attribute: it will draw the rectangle
147 // with the bg colour from attr and set the text colour and font
148 virtual void Draw(wxGrid
& grid
,
149 wxGridCellAttr
& attr
,
153 bool isSelected
) = 0;
155 // get the preferred size of the cell for its contents
156 virtual wxSize
GetBestSize(wxGrid
& grid
,
157 wxGridCellAttr
& attr
,
159 int row
, int col
) = 0;
161 // create a new object which is the copy of this one
162 virtual wxGridCellRenderer
*Clone() const = 0;
165 // the default renderer for the cells containing string data
166 class WXDLLEXPORT wxGridCellStringRenderer
: public wxGridCellRenderer
170 virtual void Draw(wxGrid
& grid
,
171 wxGridCellAttr
& attr
,
177 // return the string extent
178 virtual wxSize
GetBestSize(wxGrid
& grid
,
179 wxGridCellAttr
& attr
,
183 virtual wxGridCellRenderer
*Clone() const
184 { return new wxGridCellStringRenderer
; }
187 // set the text colours before drawing
188 void SetTextColoursAndFont(wxGrid
& grid
,
189 wxGridCellAttr
& attr
,
193 // calc the string extent for given string/font
194 wxSize
DoGetBestSize(wxGridCellAttr
& attr
,
196 const wxString
& text
);
199 // the default renderer for the cells containing numeric (long) data
200 class WXDLLEXPORT wxGridCellNumberRenderer
: public wxGridCellStringRenderer
203 // draw the string right aligned
204 virtual void Draw(wxGrid
& grid
,
205 wxGridCellAttr
& attr
,
211 virtual wxSize
GetBestSize(wxGrid
& grid
,
212 wxGridCellAttr
& attr
,
216 virtual wxGridCellRenderer
*Clone() const
217 { return new wxGridCellNumberRenderer
; }
220 wxString
GetString(wxGrid
& grid
, int row
, int col
);
223 class WXDLLEXPORT wxGridCellFloatRenderer
: public wxGridCellStringRenderer
226 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
228 // get/change formatting parameters
229 int GetWidth() const { return m_width
; }
230 void SetWidth(int width
) { m_width
= width
; m_format
.clear(); }
231 int GetPrecision() const { return m_precision
; }
232 void SetPrecision(int precision
) { m_precision
= precision
; m_format
.clear(); }
234 // draw the string right aligned with given width/precision
235 virtual void Draw(wxGrid
& grid
,
236 wxGridCellAttr
& attr
,
242 virtual wxSize
GetBestSize(wxGrid
& grid
,
243 wxGridCellAttr
& attr
,
247 // parameters string format is "width[,precision]"
248 virtual void SetParameters(const wxString
& params
);
250 virtual wxGridCellRenderer
*Clone() const;
253 wxString
GetString(wxGrid
& grid
, int row
, int col
);
256 // formatting parameters
263 // renderer for boolean fields
264 class WXDLLEXPORT wxGridCellBoolRenderer
: public wxGridCellRenderer
267 // draw a check mark or nothing
268 virtual void Draw(wxGrid
& grid
,
269 wxGridCellAttr
& attr
,
275 // return the checkmark size
276 virtual wxSize
GetBestSize(wxGrid
& grid
,
277 wxGridCellAttr
& attr
,
281 virtual wxGridCellRenderer
*Clone() const
282 { return new wxGridCellBoolRenderer
; }
285 static wxSize ms_sizeCheckMark
;
288 // ----------------------------------------------------------------------------
289 // wxGridCellEditor: This class is responsible for providing and manipulating
290 // the in-place edit controls for the grid. Instances of wxGridCellEditor
291 // (actually, instances of derived classes since it is an ABC) can be
292 // associated with the cell attributes for individual cells, rows, columns, or
293 // even for the entire grid.
294 // ----------------------------------------------------------------------------
296 class WXDLLEXPORT wxGridCellEditor
: public wxGridCellWorker
301 bool IsCreated() { return m_control
!= NULL
; }
302 wxControl
* GetControl() { return m_control
; }
303 void SetControl(wxControl
* control
) { m_control
= control
; }
305 wxGridCellAttr
* GetCellAttr() { return m_attr
; }
306 void SetCellAttr(wxGridCellAttr
* attr
) { m_attr
= attr
; }
308 // Creates the actual edit control
309 virtual void Create(wxWindow
* parent
,
311 wxEvtHandler
* evtHandler
) = 0;
313 // Size and position the edit control
314 virtual void SetSize(const wxRect
& rect
);
316 // Show or hide the edit control, use the specified attributes to set
317 // colours/fonts for it
318 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
320 // Draws the part of the cell not occupied by the control: the base class
321 // version just fills it with background colour from the attribute
322 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
324 // Fetch the value from the table and prepare the edit control
325 // to begin editing. Set the focus to the edit control.
326 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
328 // Complete the editing of the current cell. Returns true if the value has
329 // changed. If necessary, the control may be destroyed.
330 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
) = 0;
332 // Reset the value in the control back to its starting value
333 virtual void Reset() = 0;
335 // return TRUE to allow the given key to start editing: the base class
336 // version only checks that the event has no modifiers. The derived
337 // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in
338 // their IsAcceptedKey() implementation, although, of course, it is not a
339 // mandatory requirment.
341 // NB: if the key is F2 (special), editing will always start and this
342 // method will not be called at all (but StartingKey() will)
343 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
345 // If the editor is enabled by pressing keys on the grid, this will be
346 // called to let the editor do something about that first key if desired
347 virtual void StartingKey(wxKeyEvent
& event
);
349 // if the editor is enabled by clicking on the cell, this method will be
351 virtual void StartingClick();
353 // Some types of controls on some platforms may need some help
354 // with the Return key.
355 virtual void HandleReturn(wxKeyEvent
& event
);
358 virtual void Destroy();
360 // create a new object which is the copy of this one
361 virtual wxGridCellEditor
*Clone() const = 0;
364 // added GetValue so we can get the value which is in the control
365 virtual wxString
GetValue() const = 0;
368 // the dtor is private because only DecRef() can delete us
369 virtual ~wxGridCellEditor();
371 // the control we show on screen
372 wxControl
* m_control
;
374 // a temporary pointer to the attribute being edited
375 wxGridCellAttr
* m_attr
;
377 // if we change the colours/font of the control from the default ones, we
378 // must restore the default later and we save them here between calls to
379 // Show(TRUE) and Show(FALSE)
384 // suppress the stupid gcc warning about the class having private dtor and
386 friend class wxGridCellEditorDummyFriend
;
388 DECLARE_NO_COPY_CLASS(wxGridCellEditor
)
393 // the editor for string/text data
394 class WXDLLEXPORT wxGridCellTextEditor
: public wxGridCellEditor
397 wxGridCellTextEditor();
399 virtual void Create(wxWindow
* parent
,
401 wxEvtHandler
* evtHandler
);
402 virtual void SetSize(const wxRect
& rect
);
404 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
406 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
407 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
408 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
410 virtual void Reset();
411 virtual void StartingKey(wxKeyEvent
& event
);
412 virtual void HandleReturn(wxKeyEvent
& event
);
414 // parameters string format is "max_width"
415 virtual void SetParameters(const wxString
& params
);
417 virtual wxGridCellEditor
*Clone() const
418 { return new wxGridCellTextEditor
; }
421 // added GetValue so we can get the value which is in the control
422 virtual wxString
GetValue() const;
424 wxTextCtrl
*Text() const { return (wxTextCtrl
*)m_control
; }
426 // parts of our virtual functions reused by the derived classes
427 void DoBeginEdit(const wxString
& startValue
);
428 void DoReset(const wxString
& startValue
);
431 size_t m_maxChars
; // max number of chars allowed
432 wxString m_startValue
;
435 // the editor for numeric (long) data
436 class WXDLLEXPORT wxGridCellNumberEditor
: public wxGridCellTextEditor
439 // allows to specify the range - if min == max == -1, no range checking is
441 wxGridCellNumberEditor(int min
= -1, int max
= -1);
443 virtual void Create(wxWindow
* parent
,
445 wxEvtHandler
* evtHandler
);
447 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
448 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
449 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
451 virtual void Reset();
452 virtual void StartingKey(wxKeyEvent
& event
);
454 // parameters string format is "min,max"
455 virtual void SetParameters(const wxString
& params
);
457 virtual wxGridCellEditor
*Clone() const
458 { return new wxGridCellNumberEditor(m_min
, m_max
); }
460 // added GetValue so we can get the value which is in the control
461 virtual wxString
GetValue() const;
464 wxSpinCtrl
*Spin() const { return (wxSpinCtrl
*)m_control
; }
466 // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
467 bool HasRange() const { return m_min
!= m_max
; }
469 // string representation of m_valueOld
470 wxString
GetString() const
471 { return wxString::Format(_T("%ld"), m_valueOld
); }
480 // the editor for floating point numbers (double) data
481 class WXDLLEXPORT wxGridCellFloatEditor
: public wxGridCellTextEditor
484 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
486 virtual void Create(wxWindow
* parent
,
488 wxEvtHandler
* evtHandler
);
490 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
491 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
492 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
494 virtual void Reset();
495 virtual void StartingKey(wxKeyEvent
& event
);
497 virtual wxGridCellEditor
*Clone() const
498 { return new wxGridCellFloatEditor(m_width
, m_precision
); }
500 // parameters string format is "width,precision"
501 virtual void SetParameters(const wxString
& params
);
504 // string representation of m_valueOld
505 wxString
GetString() const;
513 #endif // wxUSE_TEXTCTRL
517 // the editor for boolean data
518 class WXDLLEXPORT wxGridCellBoolEditor
: public wxGridCellEditor
521 virtual void Create(wxWindow
* parent
,
523 wxEvtHandler
* evtHandler
);
525 virtual void SetSize(const wxRect
& rect
);
526 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
528 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
529 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
530 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
532 virtual void Reset();
533 virtual void StartingClick();
535 virtual wxGridCellEditor
*Clone() const
536 { return new wxGridCellBoolEditor
; }
538 // added GetValue so we can get the value which is in the control
539 virtual wxString
GetValue() const;
542 wxCheckBox
*CBox() const { return (wxCheckBox
*)m_control
; }
548 #endif // wxUSE_CHECKBOX
552 // the editor for string data allowing to choose from the list of strings
553 class WXDLLEXPORT wxGridCellChoiceEditor
: public wxGridCellEditor
556 // if !allowOthers, user can't type a string not in choices array
557 wxGridCellChoiceEditor(size_t count
= 0,
558 const wxString choices
[] = NULL
,
559 bool allowOthers
= FALSE
);
561 virtual void Create(wxWindow
* parent
,
563 wxEvtHandler
* evtHandler
);
565 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
567 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
568 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
570 virtual void Reset();
572 // parameters string format is "item1[,item2[...,itemN]]"
573 virtual void SetParameters(const wxString
& params
);
575 virtual wxGridCellEditor
*Clone() const;
577 // added GetValue so we can get the value which is in the control
578 virtual wxString
GetValue() const;
581 wxComboBox
*Combo() const { return (wxComboBox
*)m_control
; }
583 // DJC - (MAPTEK) you at least need access to m_choices if you
584 // wish to override this class
586 wxString m_startValue
;
587 wxArrayString m_choices
;
591 #endif // wxUSE_COMBOBOX
593 // ----------------------------------------------------------------------------
594 // wxGridCellAttr: this class can be used to alter the cells appearance in
595 // the grid by changing their colour/font/... from default. An object of this
596 // class may be returned by wxGridTable::GetAttr().
597 // ----------------------------------------------------------------------------
599 class WXDLLEXPORT wxGridCellAttr
: public wxClientDataContainer
613 wxGridCellAttr(wxGridCellAttr
*attrDefault
= NULL
)
617 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
618 SetAlignment(-1, -1);
621 // VZ: considering the number of members wxGridCellAttr has now, this ctor
622 // seems to be pretty useless... may be we should just remove it?
623 wxGridCellAttr(const wxColour
& colText
,
624 const wxColour
& colBack
,
628 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
631 SetAlignment(hAlign
, vAlign
);
634 // creates a new copy of this object
635 wxGridCellAttr
*Clone() const;
636 void MergeWith(wxGridCellAttr
*mergefrom
);
638 // this class is ref counted: it is created with ref count of 1, so
639 // calling DecRef() once will delete it. Calling IncRef() allows to lock
640 // it until the matching DecRef() is called
641 void IncRef() { m_nRef
++; }
642 void DecRef() { if ( !--m_nRef
) delete this; }
645 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
646 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
647 void SetFont(const wxFont
& font
) { m_font
= font
; }
648 void SetAlignment(int hAlign
, int vAlign
)
653 void SetSize(int num_rows
, int num_cols
);
654 void SetOverflow( bool allow
) { m_overflow
= allow
; }
655 void SetReadOnly(bool isReadOnly
= TRUE
)
656 { m_isReadOnly
= isReadOnly
? ReadOnly
: ReadWrite
; }
658 // takes ownership of the pointer
659 void SetRenderer(wxGridCellRenderer
*renderer
)
660 { wxSafeDecRef(m_renderer
); m_renderer
= renderer
; }
661 void SetEditor(wxGridCellEditor
* editor
)
662 { wxSafeDecRef(m_editor
); m_editor
= editor
; }
664 void SetKind(wxAttrKind kind
) { m_attrkind
= kind
; }
667 bool HasTextColour() const { return m_colText
.Ok(); }
668 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
669 bool HasFont() const { return m_font
.Ok(); }
670 bool HasAlignment() const { return (m_hAlign
!= -1 || m_vAlign
!= -1); }
671 bool HasRenderer() const { return m_renderer
!= NULL
; }
672 bool HasEditor() const { return m_editor
!= NULL
; }
673 bool HasReadWriteMode() const { return m_isReadOnly
!= Unset
; }
675 const wxColour
& GetTextColour() const;
676 const wxColour
& GetBackgroundColour() const;
677 const wxFont
& GetFont() const;
678 void GetAlignment(int *hAlign
, int *vAlign
) const;
679 void GetSize(int *num_rows
, int *num_cols
) const;
680 bool GetOverflow() const { return m_overflow
; }
681 wxGridCellRenderer
*GetRenderer(wxGrid
* grid
, int row
, int col
) const;
682 wxGridCellEditor
*GetEditor(wxGrid
* grid
, int row
, int col
) const;
684 bool IsReadOnly() const { return m_isReadOnly
== wxGridCellAttr::ReadOnly
; }
686 wxAttrKind
GetKind() { return m_attrkind
; }
688 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
698 // the common part of all ctors
699 void Init(wxGridCellAttr
*attrDefault
= NULL
);
701 // the dtor is private because only DecRef() can delete us
704 wxSafeDecRef(m_renderer
);
705 wxSafeDecRef(m_editor
);
708 // the ref count - when it goes to 0, we die
720 wxGridCellRenderer
* m_renderer
;
721 wxGridCellEditor
* m_editor
;
722 wxGridCellAttr
* m_defGridAttr
;
724 wxAttrReadMode m_isReadOnly
;
726 wxAttrKind m_attrkind
;
728 // use Clone() instead
729 DECLARE_NO_COPY_CLASS(wxGridCellAttr
)
731 // suppress the stupid gcc warning about the class having private dtor and
733 friend class wxGridCellAttrDummyFriend
;
736 // ----------------------------------------------------------------------------
737 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
739 // ----------------------------------------------------------------------------
741 // implementation note: we separate it from wxGridTableBase because we wish to
742 // avoid deriving a new table class if possible, and sometimes it will be
743 // enough to just derive another wxGridCellAttrProvider instead
745 // the default implementation is reasonably efficient for the generic case,
746 // but you might still wish to implement your own for some specific situations
747 // if you have performance problems with the stock one
748 class WXDLLEXPORT wxGridCellAttrProvider
: public wxClientDataContainer
751 wxGridCellAttrProvider();
752 virtual ~wxGridCellAttrProvider();
754 // DecRef() must be called on the returned pointer
755 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
756 wxGridCellAttr::wxAttrKind kind
) const;
758 // all these functions take ownership of the pointer, don't call DecRef()
760 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
761 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
762 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
764 // these functions must be called whenever some rows/cols are deleted
765 // because the internal data must be updated then
766 void UpdateAttrRows( size_t pos
, int numRows
);
767 void UpdateAttrCols( size_t pos
, int numCols
);
772 wxGridCellAttrProviderData
*m_data
;
774 DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider
)
777 //////////////////////////////////////////////////////////////////////
779 // Grid table classes
781 //////////////////////////////////////////////////////////////////////
784 class WXDLLEXPORT wxGridTableBase
: public wxObject
, public wxClientDataContainer
788 virtual ~wxGridTableBase();
790 // You must override these functions in a derived table class
792 virtual int GetNumberRows() = 0;
793 virtual int GetNumberCols() = 0;
794 virtual bool IsEmptyCell( int row
, int col
) = 0;
795 virtual wxString
GetValue( int row
, int col
) = 0;
796 virtual void SetValue( int row
, int col
, const wxString
& value
) = 0;
798 // Data type determination and value access
799 virtual wxString
GetTypeName( int row
, int col
);
800 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
801 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
803 virtual long GetValueAsLong( int row
, int col
);
804 virtual double GetValueAsDouble( int row
, int col
);
805 virtual bool GetValueAsBool( int row
, int col
);
807 virtual void SetValueAsLong( int row
, int col
, long value
);
808 virtual void SetValueAsDouble( int row
, int col
, double value
);
809 virtual void SetValueAsBool( int row
, int col
, bool value
);
811 // For user defined types
812 virtual void* GetValueAsCustom( int row
, int col
, const wxString
& typeName
);
813 virtual void SetValueAsCustom( int row
, int col
, const wxString
& typeName
, void* value
);
816 // Overriding these is optional
818 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
819 virtual wxGrid
* GetView() const { return m_view
; }
821 virtual void Clear() {}
822 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
823 virtual bool AppendRows( size_t numRows
= 1 );
824 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
825 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
826 virtual bool AppendCols( size_t numCols
= 1 );
827 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
829 virtual wxString
GetRowLabelValue( int row
);
830 virtual wxString
GetColLabelValue( int col
);
831 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
832 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
834 // Attribute handling
837 // give us the attr provider to use - we take ownership of the pointer
838 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
840 // get the currently used attr provider (may be NULL)
841 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
843 // Does this table allow attributes? Default implementation creates
844 // a wxGridCellAttrProvider if necessary.
845 virtual bool CanHaveAttributes();
847 // by default forwarded to wxGridCellAttrProvider if any. May be
848 // overridden to handle attributes directly in the table.
849 virtual wxGridCellAttr
*GetAttr( int row
, int col
,
850 wxGridCellAttr::wxAttrKind kind
);
853 // these functions take ownership of the pointer
854 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
855 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
856 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
860 wxGridCellAttrProvider
*m_attrProvider
;
862 DECLARE_ABSTRACT_CLASS( wxGridTableBase
);
863 DECLARE_NO_COPY_CLASS(wxGridTableBase
)
867 // ----------------------------------------------------------------------------
868 // wxGridTableMessage
869 // ----------------------------------------------------------------------------
871 // IDs for messages sent from grid table to view
873 enum wxGridTableRequest
875 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
876 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
877 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
878 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
879 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
880 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
881 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
882 wxGRIDTABLE_NOTIFY_COLS_DELETED
885 class WXDLLEXPORT wxGridTableMessage
888 wxGridTableMessage();
889 wxGridTableMessage( wxGridTableBase
*table
, int id
,
893 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
894 wxGridTableBase
* GetTableObject() const { return m_table
; }
895 void SetId( int id
) { m_id
= id
; }
896 int GetId() { return m_id
; }
897 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
898 int GetCommandInt() { return m_comInt1
; }
899 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
900 int GetCommandInt2() { return m_comInt2
; }
903 wxGridTableBase
*m_table
;
908 DECLARE_NO_COPY_CLASS(wxGridTableMessage
)
913 // ------ wxGridStringArray
914 // A 2-dimensional array of strings for data values
917 WX_DECLARE_EXPORTED_OBJARRAY(wxArrayString
, wxGridStringArray
);
921 // ------ wxGridStringTable
923 // Simplest type of data table for a grid for small tables of strings
924 // that are stored in memory
927 class WXDLLEXPORT wxGridStringTable
: public wxGridTableBase
931 wxGridStringTable( int numRows
, int numCols
);
932 virtual ~wxGridStringTable();
934 // these are pure virtual in wxGridTableBase
938 wxString
GetValue( int row
, int col
);
939 void SetValue( int row
, int col
, const wxString
& s
);
940 bool IsEmptyCell( int row
, int col
);
942 // overridden functions from wxGridTableBase
945 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
946 bool AppendRows( size_t numRows
= 1 );
947 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
948 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
949 bool AppendCols( size_t numCols
= 1 );
950 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
952 void SetRowLabelValue( int row
, const wxString
& );
953 void SetColLabelValue( int col
, const wxString
& );
954 wxString
GetRowLabelValue( int row
);
955 wxString
GetColLabelValue( int col
);
958 wxGridStringArray m_data
;
960 // These only get used if you set your own labels, otherwise the
961 // GetRow/ColLabelValue functions return wxGridTableBase defaults
963 wxArrayString m_rowLabels
;
964 wxArrayString m_colLabels
;
966 DECLARE_DYNAMIC_CLASS( wxGridStringTable
)
971 // ============================================================================
973 // ============================================================================
975 // ----------------------------------------------------------------------------
976 // wxGridCellCoords: location of a cell in the grid
977 // ----------------------------------------------------------------------------
979 class WXDLLEXPORT wxGridCellCoords
982 wxGridCellCoords() { m_row
= m_col
= -1; }
983 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
985 // default copy ctor is ok
987 int GetRow() const { return m_row
; }
988 void SetRow( int n
) { m_row
= n
; }
989 int GetCol() const { return m_col
; }
990 void SetCol( int n
) { m_col
= n
; }
991 void Set( int row
, int col
) { m_row
= row
; m_col
= col
; }
993 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
995 if ( &other
!= this )
1003 bool operator==( const wxGridCellCoords
& other
) const
1005 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
1008 bool operator!=( const wxGridCellCoords
& other
) const
1010 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
1013 bool operator!() const
1015 return (m_row
== -1 && m_col
== -1 );
1024 // For comparisons...
1026 extern WXDLLEXPORT wxGridCellCoords wxGridNoCellCoords
;
1027 extern WXDLLEXPORT wxRect wxGridNoCellRect
;
1029 // An array of cell coords...
1031 WX_DECLARE_EXPORTED_OBJARRAY(wxGridCellCoords
, wxGridCellCoordsArray
);
1033 // ----------------------------------------------------------------------------
1035 // ----------------------------------------------------------------------------
1037 class WXDLLEXPORT wxGrid
: public wxScrolledWindow
1045 wxGrid( wxWindow
*parent
,
1047 const wxPoint
& pos
= wxDefaultPosition
,
1048 const wxSize
& size
= wxDefaultSize
,
1049 long style
= wxWANTS_CHARS
,
1050 const wxString
& name
= wxPanelNameStr
);
1054 enum wxGridSelectionModes
{wxGridSelectCells
,
1056 wxGridSelectColumns
};
1058 bool CreateGrid( int numRows
, int numCols
,
1059 wxGrid::wxGridSelectionModes selmode
=
1060 wxGrid::wxGridSelectCells
);
1062 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
1063 wxGrid::wxGridSelectionModes
GetSelectionMode() const;
1065 // ------ grid dimensions
1067 int GetNumberRows() { return m_numRows
; }
1068 int GetNumberCols() { return m_numCols
; }
1071 // ------ display update functions
1073 wxArrayInt
CalcRowLabelsExposed( const wxRegion
& reg
);
1075 wxArrayInt
CalcColLabelsExposed( const wxRegion
& reg
);
1076 wxGridCellCoordsArray
CalcCellsExposed( const wxRegion
& reg
);
1079 // ------ event handlers
1081 void ProcessRowLabelMouseEvent( wxMouseEvent
& event
);
1082 void ProcessColLabelMouseEvent( wxMouseEvent
& event
);
1083 void ProcessCornerLabelMouseEvent( wxMouseEvent
& event
);
1084 void ProcessGridCellMouseEvent( wxMouseEvent
& event
);
1085 bool ProcessTableMessage( wxGridTableMessage
& );
1087 void DoEndDragResizeRow();
1088 void DoEndDragResizeCol();
1090 wxGridTableBase
* GetTable() const { return m_table
; }
1091 bool SetTable( wxGridTableBase
*table
, bool takeOwnership
=FALSE
,
1092 wxGrid::wxGridSelectionModes selmode
=
1093 wxGrid::wxGridSelectCells
);
1096 bool InsertRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1097 bool AppendRows( int numRows
= 1, bool updateLabels
=TRUE
);
1098 bool DeleteRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1099 bool InsertCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1100 bool AppendCols( int numCols
= 1, bool updateLabels
=TRUE
);
1101 bool DeleteCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1103 void DrawGridCellArea( wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1104 void DrawGridSpace( wxDC
& dc
);
1105 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
1106 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
1107 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
1108 void DrawHighlight(wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1110 // this function is called when the current cell highlight must be redrawn
1111 // and may be overridden by the user
1112 virtual void DrawCellHighlight( wxDC
& dc
, const wxGridCellAttr
*attr
);
1114 void DrawRowLabels( wxDC
& dc
, const wxArrayInt
& rows
);
1115 void DrawRowLabel( wxDC
& dc
, int row
);
1117 void DrawColLabels( wxDC
& dc
, const wxArrayInt
& cols
);
1118 void DrawColLabel( wxDC
& dc
, int col
);
1121 // ------ Cell text drawing functions
1123 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
1124 int horizontalAlignment
= wxALIGN_LEFT
,
1125 int verticalAlignment
= wxALIGN_TOP
);
1127 void DrawTextRectangle( wxDC
& dc
, const wxArrayString
& lines
, const wxRect
&,
1128 int horizontalAlignment
= wxALIGN_LEFT
,
1129 int verticalAlignment
= wxALIGN_TOP
);
1132 // Split a string containing newline chararcters into an array of
1133 // strings and return the number of lines
1135 void StringToLines( const wxString
& value
, wxArrayString
& lines
);
1137 void GetTextBoxSize( wxDC
& dc
,
1138 const wxArrayString
& lines
,
1139 long *width
, long *height
);
1143 // Code that does a lot of grid modification can be enclosed
1144 // between BeginBatch() and EndBatch() calls to avoid screen
1147 void BeginBatch() { m_batchCount
++; }
1150 int GetBatchCount() { return m_batchCount
; }
1152 virtual void Refresh(bool eraseb
= TRUE
,
1153 const wxRect
* rect
= (const wxRect
*) NULL
);
1155 // Use this, rather than wxWindow::Refresh(), to force an
1156 // immediate repainting of the grid. Has no effect if you are
1157 // already inside a BeginBatch / EndBatch block.
1159 // This function is necessary because wxGrid has a minimal OnPaint()
1160 // handler to reduce screen flicker.
1162 void ForceRefresh();
1165 // ------ edit control functions
1167 bool IsEditable() const { return m_editable
; }
1168 void EnableEditing( bool edit
);
1170 void EnableCellEditControl( bool enable
= TRUE
);
1171 void DisableCellEditControl() { EnableCellEditControl(FALSE
); }
1172 bool CanEnableCellControl() const;
1173 bool IsCellEditControlEnabled() const;
1174 bool IsCellEditControlShown() const;
1176 bool IsCurrentCellReadOnly() const;
1178 void ShowCellEditControl();
1179 void HideCellEditControl();
1180 void SaveEditControlValue();
1183 // ------ grid location functions
1184 // Note that all of these functions work with the logical coordinates of
1185 // grid cells and labels so you will need to convert from device
1186 // coordinates for mouse events etc.
1188 void XYToCell( int x
, int y
, wxGridCellCoords
& );
1189 int YToRow( int y
);
1190 int XToCol( int x
);
1192 int YToEdgeOfRow( int y
);
1193 int XToEdgeOfCol( int x
);
1195 wxRect
CellToRect( int row
, int col
);
1196 wxRect
CellToRect( const wxGridCellCoords
& coords
)
1197 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
1199 int GetGridCursorRow() { return m_currentCellCoords
.GetRow(); }
1200 int GetGridCursorCol() { return m_currentCellCoords
.GetCol(); }
1202 // check to see if a cell is either wholly visible (the default arg) or
1203 // at least partially visible in the grid window
1205 bool IsVisible( int row
, int col
, bool wholeCellVisible
= TRUE
);
1206 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= TRUE
)
1207 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
1208 void MakeCellVisible( int row
, int col
);
1209 void MakeCellVisible( const wxGridCellCoords
& coords
)
1210 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
1213 // ------ grid cursor movement functions
1215 void SetGridCursor( int row
, int col
)
1216 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1218 bool MoveCursorUp( bool expandSelection
);
1219 bool MoveCursorDown( bool expandSelection
);
1220 bool MoveCursorLeft( bool expandSelection
);
1221 bool MoveCursorRight( bool expandSelection
);
1222 bool MovePageDown();
1224 bool MoveCursorUpBlock( bool expandSelection
);
1225 bool MoveCursorDownBlock( bool expandSelection
);
1226 bool MoveCursorLeftBlock( bool expandSelection
);
1227 bool MoveCursorRightBlock( bool expandSelection
);
1230 // ------ label and gridline formatting
1232 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
1233 int GetRowLabelSize() { return m_rowLabelWidth
; }
1234 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
1235 int GetColLabelSize() { return m_colLabelHeight
; }
1236 wxColour
GetLabelBackgroundColour() { return m_labelBackgroundColour
; }
1237 wxColour
GetLabelTextColour() { return m_labelTextColour
; }
1238 wxFont
GetLabelFont() { return m_labelFont
; }
1239 void GetRowLabelAlignment( int *horiz
, int *vert
);
1240 void GetColLabelAlignment( int *horiz
, int *vert
);
1241 wxString
GetRowLabelValue( int row
);
1242 wxString
GetColLabelValue( int col
);
1243 wxColour
GetGridLineColour() { return m_gridLineColour
; }
1244 wxColour
GetCellHighlightColour() { return m_cellHighlightColour
; }
1245 int GetCellHighlightPenWidth() { return m_cellHighlightPenWidth
; }
1246 int GetCellHighlightROPenWidth() { return m_cellHighlightROPenWidth
; }
1248 void SetRowLabelSize( int width
);
1249 void SetColLabelSize( int height
);
1250 void SetLabelBackgroundColour( const wxColour
& );
1251 void SetLabelTextColour( const wxColour
& );
1252 void SetLabelFont( const wxFont
& );
1253 void SetRowLabelAlignment( int horiz
, int vert
);
1254 void SetColLabelAlignment( int horiz
, int vert
);
1255 void SetRowLabelValue( int row
, const wxString
& );
1256 void SetColLabelValue( int col
, const wxString
& );
1257 void SetGridLineColour( const wxColour
& );
1258 void SetCellHighlightColour( const wxColour
& );
1259 void SetCellHighlightPenWidth(int width
);
1260 void SetCellHighlightROPenWidth(int width
);
1262 void EnableDragRowSize( bool enable
= TRUE
);
1263 void DisableDragRowSize() { EnableDragRowSize( FALSE
); }
1264 bool CanDragRowSize() { return m_canDragRowSize
; }
1265 void EnableDragColSize( bool enable
= TRUE
);
1266 void DisableDragColSize() { EnableDragColSize( FALSE
); }
1267 bool CanDragColSize() { return m_canDragColSize
; }
1268 void EnableDragGridSize(bool enable
= TRUE
);
1269 void DisableDragGridSize() { EnableDragGridSize(FALSE
); }
1270 bool CanDragGridSize() { return m_canDragGridSize
; }
1272 // this sets the specified attribute for this cell or in this row/col
1273 void SetAttr(int row
, int col
, wxGridCellAttr
*attr
);
1274 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
1275 void SetColAttr(int col
, wxGridCellAttr
*attr
);
1277 // shortcuts for setting the column parameters
1279 // set the format for the data in the column: default is string
1280 void SetColFormatBool(int col
);
1281 void SetColFormatNumber(int col
);
1282 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
1283 void SetColFormatCustom(int col
, const wxString
& typeName
);
1285 void EnableGridLines( bool enable
= TRUE
);
1286 bool GridLinesEnabled() { return m_gridLinesEnabled
; }
1288 // ------ row and col formatting
1290 int GetDefaultRowSize();
1291 int GetRowSize( int row
);
1292 int GetDefaultColSize();
1293 int GetColSize( int col
);
1294 wxColour
GetDefaultCellBackgroundColour();
1295 wxColour
GetCellBackgroundColour( int row
, int col
);
1296 wxColour
GetDefaultCellTextColour();
1297 wxColour
GetCellTextColour( int row
, int col
);
1298 wxFont
GetDefaultCellFont();
1299 wxFont
GetCellFont( int row
, int col
);
1300 void GetDefaultCellAlignment( int *horiz
, int *vert
);
1301 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
);
1302 bool GetDefaultCellOverflow();
1303 bool GetCellOverflow( int row
, int col
);
1304 void GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
);
1306 void SetDefaultRowSize( int height
, bool resizeExistingRows
= FALSE
);
1307 void SetRowSize( int row
, int height
);
1308 void SetDefaultColSize( int width
, bool resizeExistingCols
= FALSE
);
1310 void SetColSize( int col
, int width
);
1312 // automatically size the column or row to fit to its contents, if
1313 // setAsMin is TRUE, this optimal width will also be set as minimal width
1315 void AutoSizeColumn( int col
, bool setAsMin
= TRUE
)
1316 { AutoSizeColOrRow(col
, setAsMin
, TRUE
); }
1317 void AutoSizeRow( int row
, bool setAsMin
= TRUE
)
1318 { AutoSizeColOrRow(row
, setAsMin
, FALSE
); }
1320 // auto size all columns (very ineffective for big grids!)
1321 void AutoSizeColumns( bool setAsMin
= TRUE
)
1322 { (void)SetOrCalcColumnSizes(FALSE
, setAsMin
); }
1324 void AutoSizeRows( bool setAsMin
= TRUE
)
1325 { (void)SetOrCalcRowSizes(FALSE
, setAsMin
); }
1327 // auto size the grid, that is make the columns/rows of the "right" size
1328 // and also set the grid size to just fit its contents
1331 // column won't be resized to be lesser width - this must be called during
1332 // the grid creation because it won't resize the column if it's already
1333 // narrower than the minimal width
1334 void SetColMinimalWidth( int col
, int width
);
1335 void SetRowMinimalHeight( int row
, int width
);
1337 void SetDefaultCellBackgroundColour( const wxColour
& );
1338 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
1339 void SetDefaultCellTextColour( const wxColour
& );
1341 void SetCellTextColour( int row
, int col
, const wxColour
& );
1342 void SetDefaultCellFont( const wxFont
& );
1343 void SetCellFont( int row
, int col
, const wxFont
& );
1344 void SetDefaultCellAlignment( int horiz
, int vert
);
1345 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
1346 void SetDefaultCellOverflow( bool allow
);
1347 void SetCellOverflow( int row
, int col
, bool allow
);
1348 void SetCellSize( int row
, int col
, int num_rows
, int num_cols
);
1350 // takes ownership of the pointer
1351 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
1352 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
1353 wxGridCellRenderer
*GetDefaultRenderer() const;
1354 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
1356 // takes ownership of the pointer
1357 void SetDefaultEditor(wxGridCellEditor
*editor
);
1358 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
1359 wxGridCellEditor
*GetDefaultEditor() const;
1360 wxGridCellEditor
* GetCellEditor(int row
, int col
);
1364 // ------ cell value accessors
1366 wxString
GetCellValue( int row
, int col
)
1370 return m_table
->GetValue( row
, col
);
1374 return wxEmptyString
;
1378 wxString
GetCellValue( const wxGridCellCoords
& coords
)
1379 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
1381 void SetCellValue( int row
, int col
, const wxString
& s
);
1382 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
1383 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
1385 // returns TRUE if the cell can't be edited
1386 bool IsReadOnly(int row
, int col
) const;
1388 // make the cell editable/readonly
1389 void SetReadOnly(int row
, int col
, bool isReadOnly
= TRUE
);
1391 // ------ select blocks of cells
1393 void SelectRow( int row
, bool addToSelected
= FALSE
);
1394 void SelectCol( int col
, bool addToSelected
= FALSE
);
1396 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
,
1397 bool addToSelected
= FALSE
);
1399 void SelectBlock( const wxGridCellCoords
& topLeft
,
1400 const wxGridCellCoords
& bottomRight
,
1401 bool addToSelected
= FALSE
)
1402 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1403 bottomRight
.GetRow(), bottomRight
.GetCol(),
1410 // ------ deselect blocks or cells
1412 void DeselectRow( int row
);
1413 void DeselectCol( int col
);
1414 void DeselectCell( int row
, int col
);
1416 void ClearSelection();
1418 bool IsInSelection( int row
, int col
) const;
1420 bool IsInSelection( const wxGridCellCoords
& coords
) const
1421 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
1423 wxGridCellCoordsArray
GetSelectedCells() const;
1424 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1425 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1426 wxArrayInt
GetSelectedRows() const;
1427 wxArrayInt
GetSelectedCols() const;
1429 // This function returns the rectangle that encloses the block of cells
1430 // limited by TopLeft and BottomRight cell in device coords and clipped
1431 // to the client size of the grid window.
1433 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
1434 const wxGridCellCoords
& bottomRight
);
1436 // Access or update the selection fore/back colours
1437 wxColour
GetSelectionBackground() const
1438 { return m_selectionBackground
; }
1439 wxColour
GetSelectionForeground() const
1440 { return m_selectionForeground
; }
1442 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
1443 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
1446 // Methods for a registry for mapping data types to Renderers/Editors
1447 void RegisterDataType(const wxString
& typeName
,
1448 wxGridCellRenderer
* renderer
,
1449 wxGridCellEditor
* editor
);
1451 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1452 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const
1453 { return GetDefaultEditorForCell(c
.GetRow(), c
.GetCol()); }
1454 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1455 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1456 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1458 // grid may occupy more space than needed for its rows/columns, this
1459 // function allows to set how big this extra space is
1460 void SetMargins(int extraWidth
, int extraHeight
)
1462 m_extraWidth
= extraWidth
;
1463 m_extraHeight
= extraHeight
;
1468 // Accessors for component windows
1469 wxWindow
* GetGridWindow() { return (wxWindow
*)m_gridWin
; }
1470 wxWindow
* GetGridRowLabelWindow() { return (wxWindow
*)m_rowLabelWin
; }
1471 wxWindow
* GetGridColLabelWindow() { return (wxWindow
*)m_colLabelWin
; }
1472 wxWindow
* GetGridCornerLabelWindow() { return (wxWindow
*)m_cornerLabelWin
; }
1476 // ------ For compatibility with previous wxGrid only...
1478 // ************************************************
1479 // ** Don't use these in new code because they **
1480 // ** are liable to disappear in a future **
1482 // ************************************************
1485 wxGrid( wxWindow
*parent
,
1486 int x
, int y
, int w
= -1, int h
= -1,
1487 long style
= wxWANTS_CHARS
,
1488 const wxString
& name
= wxPanelNameStr
)
1489 : wxScrolledWindow( parent
, -1, wxPoint(x
,y
), wxSize(w
,h
),
1490 (style
|wxWANTS_CHARS
), name
)
1495 void SetCellValue( const wxString
& val
, int row
, int col
)
1496 { SetCellValue( row
, col
, val
); }
1498 void UpdateDimensions()
1499 { CalcDimensions(); }
1501 int GetRows() { return GetNumberRows(); }
1502 int GetCols() { return GetNumberCols(); }
1503 int GetCursorRow() { return GetGridCursorRow(); }
1504 int GetCursorColumn() { return GetGridCursorCol(); }
1506 int GetScrollPosX() { return 0; }
1507 int GetScrollPosY() { return 0; }
1509 void SetScrollX( int WXUNUSED(x
) ) { }
1510 void SetScrollY( int WXUNUSED(y
) ) { }
1512 void SetColumnWidth( int col
, int width
)
1513 { SetColSize( col
, width
); }
1515 int GetColumnWidth( int col
)
1516 { return GetColSize( col
); }
1518 void SetRowHeight( int row
, int height
)
1519 { SetRowSize( row
, height
); }
1521 // GetRowHeight() is below
1523 int GetViewHeight() // returned num whole rows visible
1526 int GetViewWidth() // returned num whole cols visible
1529 void SetLabelSize( int orientation
, int sz
)
1531 if ( orientation
== wxHORIZONTAL
)
1532 SetColLabelSize( sz
);
1534 SetRowLabelSize( sz
);
1537 int GetLabelSize( int orientation
)
1539 if ( orientation
== wxHORIZONTAL
)
1540 return GetColLabelSize();
1542 return GetRowLabelSize();
1545 void SetLabelAlignment( int orientation
, int align
)
1547 if ( orientation
== wxHORIZONTAL
)
1548 SetColLabelAlignment( align
, -1 );
1550 SetRowLabelAlignment( align
, -1 );
1553 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) )
1556 if ( orientation
== wxHORIZONTAL
)
1558 GetColLabelAlignment( &h
, &v
);
1563 GetRowLabelAlignment( &h
, &v
);
1568 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
1570 if ( orientation
== wxHORIZONTAL
)
1571 SetColLabelValue( pos
, val
);
1573 SetRowLabelValue( pos
, val
);
1576 wxString
GetLabelValue( int orientation
, int pos
)
1578 if ( orientation
== wxHORIZONTAL
)
1579 return GetColLabelValue( pos
);
1581 return GetRowLabelValue( pos
);
1584 wxFont
GetCellTextFont() const
1585 { return m_defaultCellAttr
->GetFont(); }
1587 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
1588 { return m_defaultCellAttr
->GetFont(); }
1590 void SetCellTextFont(const wxFont
& fnt
)
1591 { SetDefaultCellFont( fnt
); }
1593 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1594 { SetCellFont( row
, col
, fnt
); }
1596 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1597 { SetCellTextColour( row
, col
, val
); }
1599 void SetCellTextColour(const wxColour
& col
)
1600 { SetDefaultCellTextColour( col
); }
1602 void SetCellBackgroundColour(const wxColour
& col
)
1603 { SetDefaultCellBackgroundColour( col
); }
1605 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1606 { SetCellBackgroundColour( row
, col
, colour
); }
1608 bool GetEditable() { return IsEditable(); }
1609 void SetEditable( bool edit
= TRUE
) { EnableEditing( edit
); }
1610 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1612 void SetEditInPlace(bool WXUNUSED(edit
) = TRUE
) { }
1614 void SetCellAlignment( int align
, int row
, int col
)
1615 { SetCellAlignment(row
, col
, align
, wxALIGN_CENTER
); }
1616 void SetCellAlignment( int WXUNUSED(align
) ) {}
1617 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1619 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1620 wxPen
& GetDividerPen() const;
1621 void OnActivate(bool WXUNUSED(active
)) {}
1623 // ******** End of compatibility functions **********
1627 // ------ control IDs
1628 enum { wxGRID_CELLCTRL
= 2000,
1631 // ------ control types
1632 enum { wxGRID_TEXTCTRL
= 2100,
1637 // overridden wxWindow methods
1641 virtual wxSize
DoGetBestSize() const;
1645 wxGridWindow
*m_gridWin
;
1646 wxGridRowLabelWindow
*m_rowLabelWin
;
1647 wxGridColLabelWindow
*m_colLabelWin
;
1648 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1650 wxGridTableBase
*m_table
;
1656 wxGridCellCoords m_currentCellCoords
;
1658 wxGridCellCoords m_selectingTopLeft
;
1659 wxGridCellCoords m_selectingBottomRight
;
1660 wxGridCellCoords m_selectingKeyboard
;
1661 wxGridSelection
*m_selection
;
1662 wxColour m_selectionBackground
;
1663 wxColour m_selectionForeground
;
1665 // NB: *never* access m_row/col arrays directly because they are created
1666 // on demand, *always* use accessor functions instead!
1668 // init the m_rowHeights/Bottoms arrays with default values
1669 void InitRowHeights();
1671 int m_defaultRowHeight
;
1672 wxArrayInt m_rowHeights
;
1673 wxArrayInt m_rowBottoms
;
1675 // init the m_colWidths/Rights arrays
1676 void InitColWidths();
1678 int m_defaultColWidth
;
1679 wxArrayInt m_colWidths
;
1680 wxArrayInt m_colRights
;
1682 // get the col/row coords
1683 int GetColWidth(int col
) const;
1684 int GetColLeft(int col
) const;
1685 int GetColRight(int col
) const;
1687 // this function must be public for compatibility...
1689 int GetRowHeight(int row
) const;
1692 int GetRowTop(int row
) const;
1693 int GetRowBottom(int row
) const;
1695 int m_rowLabelWidth
;
1696 int m_colLabelHeight
;
1698 // the size of the margin left to the right and bottom of the cell area
1702 wxColour m_labelBackgroundColour
;
1703 wxColour m_labelTextColour
;
1706 int m_rowLabelHorizAlign
;
1707 int m_rowLabelVertAlign
;
1708 int m_colLabelHorizAlign
;
1709 int m_colLabelVertAlign
;
1711 bool m_defaultRowLabelValues
;
1712 bool m_defaultColLabelValues
;
1714 wxColour m_gridLineColour
;
1715 bool m_gridLinesEnabled
;
1716 wxColour m_cellHighlightColour
;
1717 int m_cellHighlightPenWidth
;
1718 int m_cellHighlightROPenWidth
;
1721 // common part of AutoSizeColumn/Row() and GetBestSize()
1722 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1723 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1725 // common part of AutoSizeColumn/Row()
1726 void AutoSizeColOrRow(int n
, bool setAsMin
, bool column
/* or row? */);
1728 // if a column has a minimal width, it will be the value for it in this
1730 wxHashTableLong m_colMinWidths
,
1733 // get the minimal width of the given column/row
1734 int GetColMinimalWidth(int col
) const;
1735 int GetRowMinimalHeight(int col
) const;
1737 // do we have some place to store attributes in?
1738 bool CanHaveAttributes();
1740 // returns the attribute we may modify in place: a new one if this cell
1741 // doesn't have any yet or the existing one if it does
1743 // DecRef() must be called on the returned pointer, as usual
1744 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1746 // cell attribute cache (currently we only cache 1, may be will do
1747 // more/better later)
1751 wxGridCellAttr
*attr
;
1754 // invalidates the attribute cache
1755 void ClearAttrCache();
1757 // adds an attribute to cache
1758 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1760 // looks for an attr in cache, returns TRUE if found
1761 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1763 // looks for the attr in cache, if not found asks the table and caches the
1765 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1766 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
)
1767 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1769 // the default cell attr object for cells that don't have their own
1770 wxGridCellAttr
* m_defaultCellAttr
;
1777 wxGridTypeRegistry
* m_typeRegistry
;
1781 WXGRID_CURSOR_SELECT_CELL
,
1782 WXGRID_CURSOR_RESIZE_ROW
,
1783 WXGRID_CURSOR_RESIZE_COL
,
1784 WXGRID_CURSOR_SELECT_ROW
,
1785 WXGRID_CURSOR_SELECT_COL
1788 // this method not only sets m_cursorMode but also sets the correct cursor
1789 // for the given mode and, if captureMouse is not FALSE releases the mouse
1790 // if it was captured and captures it if it must be captured
1792 // for this to work, you should always use it and not set m_cursorMode
1794 void ChangeCursorMode(CursorMode mode
,
1795 wxWindow
*win
= (wxWindow
*)NULL
,
1796 bool captureMouse
= TRUE
);
1798 wxWindow
*m_winCapture
; // the window which captured the mouse
1799 CursorMode m_cursorMode
;
1801 bool m_canDragRowSize
;
1802 bool m_canDragColSize
;
1803 bool m_canDragGridSize
;
1807 wxPoint m_startDragPos
;
1809 bool m_waitForSlowClick
;
1811 wxGridCellCoords m_selectionStart
;
1813 wxCursor m_rowResizeCursor
;
1814 wxCursor m_colResizeCursor
;
1816 bool m_editable
; // applies to whole grid
1817 bool m_cellEditCtrlEnabled
; // is in-place edit currently shown?
1822 void CalcDimensions();
1823 void CalcWindowSizes();
1824 bool Redimension( wxGridTableMessage
& );
1827 int SendEvent( const wxEventType
, int row
, int col
, wxMouseEvent
& );
1828 int SendEvent( const wxEventType
, int row
, int col
);
1829 int SendEvent( const wxEventType type
)
1831 return SendEvent(type
,
1832 m_currentCellCoords
.GetRow(),
1833 m_currentCellCoords
.GetCol());
1836 void OnPaint( wxPaintEvent
& );
1837 void OnSize( wxSizeEvent
& );
1838 void OnKeyDown( wxKeyEvent
& );
1839 void OnKeyUp( wxKeyEvent
& );
1840 void OnEraseBackground( wxEraseEvent
& );
1843 void SetCurrentCell( const wxGridCellCoords
& coords
);
1844 void SetCurrentCell( int row
, int col
)
1845 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1847 void HighlightBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
);
1849 void HighlightBlock( const wxGridCellCoords
& topLeft
,
1850 const wxGridCellCoords
& bottomRight
)
1851 { HighlightBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1852 bottomRight
.GetRow(), bottomRight
.GetCol() ); }
1854 // ------ functions to get/send data (see also public functions)
1856 bool GetModelValues();
1857 bool SetModelValues();
1859 friend class WXDLLEXPORT wxGridSelection
;
1861 DECLARE_DYNAMIC_CLASS( wxGrid
)
1862 DECLARE_EVENT_TABLE()
1863 DECLARE_NO_COPY_CLASS(wxGrid
)
1866 // ----------------------------------------------------------------------------
1867 // Grid event class and event types
1868 // ----------------------------------------------------------------------------
1870 class WXDLLEXPORT wxGridEvent
: public wxNotifyEvent
1874 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1875 m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0)
1879 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
1880 int row
=-1, int col
=-1, int x
=-1, int y
=-1, bool sel
= TRUE
,
1881 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1883 virtual int GetRow() { return m_row
; }
1884 virtual int GetCol() { return m_col
; }
1885 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1886 bool Selecting() { return m_selecting
; }
1887 bool ControlDown() { return m_control
; }
1888 bool MetaDown() { return m_meta
; }
1889 bool ShiftDown() { return m_shift
; }
1890 bool AltDown() { return m_alt
; }
1903 DECLARE_DYNAMIC_CLASS(wxGridEvent
)
1906 class WXDLLEXPORT wxGridSizeEvent
: public wxNotifyEvent
1910 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1911 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1915 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
1916 int rowOrCol
=-1, int x
=-1, int y
=-1,
1917 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1919 int GetRowOrCol() { return m_rowOrCol
; }
1920 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1921 bool ControlDown() { return m_control
; }
1922 bool MetaDown() { return m_meta
; }
1923 bool ShiftDown() { return m_shift
; }
1924 bool AltDown() { return m_alt
; }
1935 DECLARE_DYNAMIC_CLASS(wxGridSizeEvent
)
1939 class WXDLLEXPORT wxGridRangeSelectEvent
: public wxNotifyEvent
1942 wxGridRangeSelectEvent()
1945 m_topLeft
= wxGridNoCellCoords
;
1946 m_bottomRight
= wxGridNoCellCoords
;
1947 m_selecting
= FALSE
;
1954 wxGridRangeSelectEvent(int id
, wxEventType type
, wxObject
* obj
,
1955 const wxGridCellCoords
& topLeft
,
1956 const wxGridCellCoords
& bottomRight
,
1958 bool control
=FALSE
, bool shift
=FALSE
,
1959 bool alt
=FALSE
, bool meta
=FALSE
);
1961 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
1962 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
1963 int GetTopRow() { return m_topLeft
.GetRow(); }
1964 int GetBottomRow() { return m_bottomRight
.GetRow(); }
1965 int GetLeftCol() { return m_topLeft
.GetCol(); }
1966 int GetRightCol() { return m_bottomRight
.GetCol(); }
1967 bool Selecting() { return m_selecting
; }
1968 bool ControlDown() { return m_control
; }
1969 bool MetaDown() { return m_meta
; }
1970 bool ShiftDown() { return m_shift
; }
1971 bool AltDown() { return m_alt
; }
1974 wxGridCellCoords m_topLeft
;
1975 wxGridCellCoords m_bottomRight
;
1982 DECLARE_DYNAMIC_CLASS(wxGridRangeSelectEvent
)
1986 class WXDLLEXPORT wxGridEditorCreatedEvent
: public wxCommandEvent
{
1988 wxGridEditorCreatedEvent()
1996 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
1997 int row
, int col
, wxControl
* ctrl
);
1999 int GetRow() { return m_row
; }
2000 int GetCol() { return m_col
; }
2001 wxControl
* GetControl() { return m_ctrl
; }
2002 void SetRow(int row
) { m_row
= row
; }
2003 void SetCol(int col
) { m_col
= col
; }
2004 void SetControl(wxControl
* ctrl
) { m_ctrl
= ctrl
; }
2011 DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent
)
2012 DECLARE_NO_COPY_CLASS(wxGridEditorCreatedEvent
)
2016 BEGIN_DECLARE_EVENT_TYPES()
2017 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_CLICK
, 1580)
2018 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_CLICK
, 1581)
2019 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_LEFT_DCLICK
, 1582)
2020 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_RIGHT_DCLICK
, 1583)
2021 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_CLICK
, 1584)
2022 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_CLICK
, 1585)
2023 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_LEFT_DCLICK
, 1586)
2024 DECLARE_EVENT_TYPE(wxEVT_GRID_LABEL_RIGHT_DCLICK
, 1587)
2025 DECLARE_EVENT_TYPE(wxEVT_GRID_ROW_SIZE
, 1588)
2026 DECLARE_EVENT_TYPE(wxEVT_GRID_COL_SIZE
, 1589)
2027 DECLARE_EVENT_TYPE(wxEVT_GRID_RANGE_SELECT
, 1590)
2028 DECLARE_EVENT_TYPE(wxEVT_GRID_CELL_CHANGE
, 1591)
2029 DECLARE_EVENT_TYPE(wxEVT_GRID_SELECT_CELL
, 1592)
2030 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_SHOWN
, 1593)
2031 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_HIDDEN
, 1594)
2032 DECLARE_EVENT_TYPE(wxEVT_GRID_EDITOR_CREATED
, 1595)
2033 END_DECLARE_EVENT_TYPES()
2036 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
2037 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
2038 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
2039 typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction
)(wxGridEditorCreatedEvent
&);
2041 #define EVT_GRID_CELL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2042 #define EVT_GRID_CELL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2043 #define EVT_GRID_CELL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2044 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2045 #define EVT_GRID_LABEL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2046 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2047 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2048 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2049 #define EVT_GRID_ROW_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
2050 #define EVT_GRID_COL_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridSizeEventFunction) &fn, NULL ),
2051 #define EVT_GRID_RANGE_SELECT(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridRangeSelectEventFunction) &fn, NULL ),
2052 #define EVT_GRID_CELL_CHANGE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2053 #define EVT_GRID_SELECT_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2054 #define EVT_GRID_EDITOR_SHOWN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2055 #define EVT_GRID_EDITOR_HIDDEN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2056 #define EVT_GRID_EDITOR_CREATED(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_CREATED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEditorCreatedEventFunction) &fn, NULL ),
2059 #if 0 // TODO: implement these ? others ?
2061 extern const int wxEVT_GRID_CREATE_CELL
;
2062 extern const int wxEVT_GRID_CHANGE_LABELS
;
2063 extern const int wxEVT_GRID_CHANGE_SEL_LABEL
;
2065 #define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2066 #define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2067 #define EVT_GRID_CHANGE_SEL_LABEL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxGridEventFunction) &fn, NULL ),
2071 #endif // #ifndef __WXGRID_H__
2073 #endif // ifndef wxUSE_NEW_GRID