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(NO_GCC_PRAGMA)
18 #pragma interface "grid.h"
21 #include "wx/hashmap.h"
23 #include "wx/scrolwin.h"
24 #include "wx/string.h"
25 #include "wx/arrstr.h"
26 #include "wx/scrolbar.h"
28 #include "wx/combobox.h"
29 #include "wx/dynarray.h"
31 #include "wx/clntdata.h"
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 // Default parameters for wxGrid
39 #define WXGRID_DEFAULT_NUMBER_ROWS 10
40 #define WXGRID_DEFAULT_NUMBER_COLS 10
42 #define WXGRID_DEFAULT_ROW_HEIGHT 25
44 #define WXGRID_DEFAULT_ROW_HEIGHT 30
46 #define WXGRID_DEFAULT_COL_WIDTH 80
47 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32
48 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82
49 #define WXGRID_LABEL_EDGE_ZONE 2
50 #define WXGRID_MIN_ROW_HEIGHT 15
51 #define WXGRID_MIN_COL_WIDTH 15
52 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
54 // type names for grid table values
55 #define wxGRID_VALUE_STRING _T("string")
56 #define wxGRID_VALUE_BOOL _T("bool")
57 #define wxGRID_VALUE_NUMBER _T("long")
58 #define wxGRID_VALUE_FLOAT _T("double")
59 #define wxGRID_VALUE_CHOICE _T("choice")
61 #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
62 #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
64 // ----------------------------------------------------------------------------
65 // forward declarations
66 // ----------------------------------------------------------------------------
68 class WXDLLIMPEXP_ADV wxGrid
;
69 class WXDLLIMPEXP_ADV wxGridCellAttr
;
70 class WXDLLIMPEXP_ADV wxGridCellAttrProviderData
;
71 class WXDLLIMPEXP_ADV wxGridColLabelWindow
;
72 class WXDLLIMPEXP_ADV wxGridCornerLabelWindow
;
73 class WXDLLIMPEXP_ADV wxGridRowLabelWindow
;
74 class WXDLLIMPEXP_ADV wxGridTableBase
;
75 class WXDLLIMPEXP_ADV wxGridWindow
;
76 class WXDLLIMPEXP_ADV wxGridTypeRegistry
;
77 class WXDLLIMPEXP_ADV wxGridSelection
;
79 class WXDLLEXPORT wxCheckBox
;
80 class WXDLLEXPORT wxComboBox
;
81 class WXDLLEXPORT wxTextCtrl
;
82 class WXDLLEXPORT wxSpinCtrl
;
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 #define wxSafeIncRef(p) if ( p ) (p)->IncRef()
89 #define wxSafeDecRef(p) if ( p ) (p)->DecRef()
91 // ----------------------------------------------------------------------------
92 // wxGridCellWorker: common base class for wxGridCellRenderer and
95 // NB: this is more an implementation convenience than a design issue, so this
96 // class is not documented and is not public at all
97 // ----------------------------------------------------------------------------
99 class WXDLLIMPEXP_ADV wxGridCellWorker
: public wxClientDataContainer
102 wxGridCellWorker() { m_nRef
= 1; }
104 // this class is ref counted: it is created with ref count of 1, so
105 // calling DecRef() once will delete it. Calling IncRef() allows to lock
106 // it until the matching DecRef() is called
107 void IncRef() { m_nRef
++; }
108 void DecRef() { if ( !--m_nRef
) delete this; }
110 // interpret renderer parameters: arbitrary string whose interpretatin is
111 // left to the derived classes
112 virtual void SetParameters(const wxString
& params
);
115 // virtual dtor for any base class - private because only DecRef() can
117 virtual ~wxGridCellWorker();
122 // suppress the stupid gcc warning about the class having private dtor and
124 friend class wxGridCellWorkerDummyFriend
;
127 // ----------------------------------------------------------------------------
128 // wxGridCellRenderer: this class is responsible for actually drawing the cell
129 // in the grid. You may pass it to the wxGridCellAttr (below) to change the
130 // format of one given cell or to wxGrid::SetDefaultRenderer() to change the
131 // view of all cells. This is an ABC, you will normally use one of the
132 // predefined derived classes or derive your own class from it.
133 // ----------------------------------------------------------------------------
135 class WXDLLIMPEXP_ADV wxGridCellRenderer
: public wxGridCellWorker
138 // draw the given cell on the provided DC inside the given rectangle
139 // using the style specified by the attribute and the default or selected
140 // state corresponding to the isSelected value.
142 // this pure virtual function has a default implementation which will
143 // prepare the DC using the given attribute: it will draw the rectangle
144 // with the bg colour from attr and set the text colour and font
145 virtual void Draw(wxGrid
& grid
,
146 wxGridCellAttr
& attr
,
150 bool isSelected
) = 0;
152 // get the preferred size of the cell for its contents
153 virtual wxSize
GetBestSize(wxGrid
& grid
,
154 wxGridCellAttr
& attr
,
156 int row
, int col
) = 0;
158 // create a new object which is the copy of this one
159 virtual wxGridCellRenderer
*Clone() const = 0;
162 // the default renderer for the cells containing string data
163 class WXDLLIMPEXP_ADV wxGridCellStringRenderer
: public wxGridCellRenderer
167 virtual void Draw(wxGrid
& grid
,
168 wxGridCellAttr
& attr
,
174 // return the string extent
175 virtual wxSize
GetBestSize(wxGrid
& grid
,
176 wxGridCellAttr
& attr
,
180 virtual wxGridCellRenderer
*Clone() const
181 { return new wxGridCellStringRenderer
; }
184 // set the text colours before drawing
185 void SetTextColoursAndFont(wxGrid
& grid
,
186 wxGridCellAttr
& attr
,
190 // calc the string extent for given string/font
191 wxSize
DoGetBestSize(wxGridCellAttr
& attr
,
193 const wxString
& text
);
196 // the default renderer for the cells containing numeric (long) data
197 class WXDLLIMPEXP_ADV wxGridCellNumberRenderer
: public wxGridCellStringRenderer
200 // draw the string right aligned
201 virtual void Draw(wxGrid
& grid
,
202 wxGridCellAttr
& attr
,
208 virtual wxSize
GetBestSize(wxGrid
& grid
,
209 wxGridCellAttr
& attr
,
213 virtual wxGridCellRenderer
*Clone() const
214 { return new wxGridCellNumberRenderer
; }
217 wxString
GetString(wxGrid
& grid
, int row
, int col
);
220 class WXDLLIMPEXP_ADV wxGridCellFloatRenderer
: public wxGridCellStringRenderer
223 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
225 // get/change formatting parameters
226 int GetWidth() const { return m_width
; }
227 void SetWidth(int width
) { m_width
= width
; m_format
.clear(); }
228 int GetPrecision() const { return m_precision
; }
229 void SetPrecision(int precision
) { m_precision
= precision
; m_format
.clear(); }
231 // draw the string right aligned with given width/precision
232 virtual void Draw(wxGrid
& grid
,
233 wxGridCellAttr
& attr
,
239 virtual wxSize
GetBestSize(wxGrid
& grid
,
240 wxGridCellAttr
& attr
,
244 // parameters string format is "width[,precision]"
245 virtual void SetParameters(const wxString
& params
);
247 virtual wxGridCellRenderer
*Clone() const;
250 wxString
GetString(wxGrid
& grid
, int row
, int col
);
253 // formatting parameters
260 // renderer for boolean fields
261 class WXDLLIMPEXP_ADV wxGridCellBoolRenderer
: public wxGridCellRenderer
264 // draw a check mark or nothing
265 virtual void Draw(wxGrid
& grid
,
266 wxGridCellAttr
& attr
,
272 // return the checkmark size
273 virtual wxSize
GetBestSize(wxGrid
& grid
,
274 wxGridCellAttr
& attr
,
278 virtual wxGridCellRenderer
*Clone() const
279 { return new wxGridCellBoolRenderer
; }
282 static wxSize ms_sizeCheckMark
;
285 // ----------------------------------------------------------------------------
286 // wxGridCellEditor: This class is responsible for providing and manipulating
287 // the in-place edit controls for the grid. Instances of wxGridCellEditor
288 // (actually, instances of derived classes since it is an ABC) can be
289 // associated with the cell attributes for individual cells, rows, columns, or
290 // even for the entire grid.
291 // ----------------------------------------------------------------------------
293 class WXDLLIMPEXP_ADV wxGridCellEditor
: public wxGridCellWorker
298 bool IsCreated() { return m_control
!= NULL
; }
299 wxControl
* GetControl() { return m_control
; }
300 void SetControl(wxControl
* control
) { m_control
= control
; }
302 wxGridCellAttr
* GetCellAttr() { return m_attr
; }
303 void SetCellAttr(wxGridCellAttr
* attr
) { m_attr
= attr
; }
305 // Creates the actual edit control
306 virtual void Create(wxWindow
* parent
,
308 wxEvtHandler
* evtHandler
) = 0;
310 // Size and position the edit control
311 virtual void SetSize(const wxRect
& rect
);
313 // Show or hide the edit control, use the specified attributes to set
314 // colours/fonts for it
315 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
317 // Draws the part of the cell not occupied by the control: the base class
318 // version just fills it with background colour from the attribute
319 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
321 // Fetch the value from the table and prepare the edit control
322 // to begin editing. Set the focus to the edit control.
323 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
) = 0;
325 // Complete the editing of the current cell. Returns true if the value has
326 // changed. If necessary, the control may be destroyed.
327 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
) = 0;
329 // Reset the value in the control back to its starting value
330 virtual void Reset() = 0;
332 // return TRUE to allow the given key to start editing: the base class
333 // version only checks that the event has no modifiers. The derived
334 // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in
335 // their IsAcceptedKey() implementation, although, of course, it is not a
336 // mandatory requirment.
338 // NB: if the key is F2 (special), editing will always start and this
339 // method will not be called at all (but StartingKey() will)
340 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
342 // If the editor is enabled by pressing keys on the grid, this will be
343 // called to let the editor do something about that first key if desired
344 virtual void StartingKey(wxKeyEvent
& event
);
346 // if the editor is enabled by clicking on the cell, this method will be
348 virtual void StartingClick();
350 // Some types of controls on some platforms may need some help
351 // with the Return key.
352 virtual void HandleReturn(wxKeyEvent
& event
);
355 virtual void Destroy();
357 // create a new object which is the copy of this one
358 virtual wxGridCellEditor
*Clone() const = 0;
361 // added GetValue so we can get the value which is in the control
362 virtual wxString
GetValue() const = 0;
365 // the dtor is private because only DecRef() can delete us
366 virtual ~wxGridCellEditor();
368 // the control we show on screen
369 wxControl
* m_control
;
371 // a temporary pointer to the attribute being edited
372 wxGridCellAttr
* m_attr
;
374 // if we change the colours/font of the control from the default ones, we
375 // must restore the default later and we save them here between calls to
376 // Show(TRUE) and Show(FALSE)
381 // suppress the stupid gcc warning about the class having private dtor and
383 friend class wxGridCellEditorDummyFriend
;
385 DECLARE_NO_COPY_CLASS(wxGridCellEditor
)
390 // the editor for string/text data
391 class WXDLLIMPEXP_ADV wxGridCellTextEditor
: public wxGridCellEditor
394 wxGridCellTextEditor();
396 virtual void Create(wxWindow
* parent
,
398 wxEvtHandler
* evtHandler
);
399 virtual void SetSize(const wxRect
& rect
);
401 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
403 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
404 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
405 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
407 virtual void Reset();
408 virtual void StartingKey(wxKeyEvent
& event
);
409 virtual void HandleReturn(wxKeyEvent
& event
);
411 // parameters string format is "max_width"
412 virtual void SetParameters(const wxString
& params
);
414 virtual wxGridCellEditor
*Clone() const
415 { return new wxGridCellTextEditor
; }
418 // added GetValue so we can get the value which is in the control
419 virtual wxString
GetValue() const;
421 wxTextCtrl
*Text() const { return (wxTextCtrl
*)m_control
; }
423 // parts of our virtual functions reused by the derived classes
424 void DoBeginEdit(const wxString
& startValue
);
425 void DoReset(const wxString
& startValue
);
428 size_t m_maxChars
; // max number of chars allowed
429 wxString m_startValue
;
431 DECLARE_NO_COPY_CLASS(wxGridCellTextEditor
)
434 // the editor for numeric (long) data
435 class WXDLLIMPEXP_ADV wxGridCellNumberEditor
: public wxGridCellTextEditor
438 // allows to specify the range - if min == max == -1, no range checking is
440 wxGridCellNumberEditor(int min
= -1, int max
= -1);
442 virtual void Create(wxWindow
* parent
,
444 wxEvtHandler
* evtHandler
);
446 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
447 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
448 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
450 virtual void Reset();
451 virtual void StartingKey(wxKeyEvent
& event
);
453 // parameters string format is "min,max"
454 virtual void SetParameters(const wxString
& params
);
456 virtual wxGridCellEditor
*Clone() const
457 { return new wxGridCellNumberEditor(m_min
, m_max
); }
459 // added GetValue so we can get the value which is in the control
460 virtual wxString
GetValue() const;
463 wxSpinCtrl
*Spin() const { return (wxSpinCtrl
*)m_control
; }
465 // if HasRange(), we use wxSpinCtrl - otherwise wxTextCtrl
466 bool HasRange() const { return m_min
!= m_max
; }
468 // string representation of m_valueOld
469 wxString
GetString() const
470 { return wxString::Format(_T("%ld"), m_valueOld
); }
478 DECLARE_NO_COPY_CLASS(wxGridCellNumberEditor
)
481 // the editor for floating point numbers (double) data
482 class WXDLLIMPEXP_ADV wxGridCellFloatEditor
: public wxGridCellTextEditor
485 wxGridCellFloatEditor(int width
= -1, int precision
= -1);
487 virtual void Create(wxWindow
* parent
,
489 wxEvtHandler
* evtHandler
);
491 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
492 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
493 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
495 virtual void Reset();
496 virtual void StartingKey(wxKeyEvent
& event
);
498 virtual wxGridCellEditor
*Clone() const
499 { return new wxGridCellFloatEditor(m_width
, m_precision
); }
501 // parameters string format is "width,precision"
502 virtual void SetParameters(const wxString
& params
);
505 // string representation of m_valueOld
506 wxString
GetString() const;
513 DECLARE_NO_COPY_CLASS(wxGridCellFloatEditor
)
516 #endif // wxUSE_TEXTCTRL
520 // the editor for boolean data
521 class WXDLLIMPEXP_ADV wxGridCellBoolEditor
: public wxGridCellEditor
524 wxGridCellBoolEditor() { }
526 virtual void Create(wxWindow
* parent
,
528 wxEvtHandler
* evtHandler
);
530 virtual void SetSize(const wxRect
& rect
);
531 virtual void Show(bool show
, wxGridCellAttr
*attr
= (wxGridCellAttr
*)NULL
);
533 virtual bool IsAcceptedKey(wxKeyEvent
& event
);
534 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
535 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
537 virtual void Reset();
538 virtual void StartingClick();
540 virtual wxGridCellEditor
*Clone() const
541 { return new wxGridCellBoolEditor
; }
543 // added GetValue so we can get the value which is in the control
544 virtual wxString
GetValue() const;
547 wxCheckBox
*CBox() const { return (wxCheckBox
*)m_control
; }
552 DECLARE_NO_COPY_CLASS(wxGridCellBoolEditor
)
555 #endif // wxUSE_CHECKBOX
559 // the editor for string data allowing to choose from the list of strings
560 class WXDLLIMPEXP_ADV wxGridCellChoiceEditor
: public wxGridCellEditor
563 // if !allowOthers, user can't type a string not in choices array
564 wxGridCellChoiceEditor(size_t count
= 0,
565 const wxString choices
[] = NULL
,
566 bool allowOthers
= FALSE
);
567 wxGridCellChoiceEditor(const wxArrayString
& choices
,
568 bool allowOthers
= FALSE
);
570 virtual void Create(wxWindow
* parent
,
572 wxEvtHandler
* evtHandler
);
574 virtual void PaintBackground(const wxRect
& rectCell
, wxGridCellAttr
*attr
);
576 virtual void BeginEdit(int row
, int col
, wxGrid
* grid
);
577 virtual bool EndEdit(int row
, int col
, wxGrid
* grid
);
579 virtual void Reset();
581 // parameters string format is "item1[,item2[...,itemN]]"
582 virtual void SetParameters(const wxString
& params
);
584 virtual wxGridCellEditor
*Clone() const;
586 // added GetValue so we can get the value which is in the control
587 virtual wxString
GetValue() const;
590 wxComboBox
*Combo() const { return (wxComboBox
*)m_control
; }
592 // DJC - (MAPTEK) you at least need access to m_choices if you
593 // wish to override this class
595 wxString m_startValue
;
596 wxArrayString m_choices
;
599 DECLARE_NO_COPY_CLASS(wxGridCellChoiceEditor
)
602 #endif // wxUSE_COMBOBOX
604 // ----------------------------------------------------------------------------
605 // wxGridCellAttr: this class can be used to alter the cells appearance in
606 // the grid by changing their colour/font/... from default. An object of this
607 // class may be returned by wxGridTable::GetAttr().
608 // ----------------------------------------------------------------------------
610 class WXDLLIMPEXP_ADV wxGridCellAttr
: public wxClientDataContainer
624 wxGridCellAttr(wxGridCellAttr
*attrDefault
= NULL
)
628 // MB: args used to be 0,0 here but wxALIGN_LEFT is 0
629 SetAlignment(-1, -1);
632 // VZ: considering the number of members wxGridCellAttr has now, this ctor
633 // seems to be pretty useless... may be we should just remove it?
634 wxGridCellAttr(const wxColour
& colText
,
635 const wxColour
& colBack
,
639 : m_colText(colText
), m_colBack(colBack
), m_font(font
)
642 SetAlignment(hAlign
, vAlign
);
645 // creates a new copy of this object
646 wxGridCellAttr
*Clone() const;
647 void MergeWith(wxGridCellAttr
*mergefrom
);
649 // this class is ref counted: it is created with ref count of 1, so
650 // calling DecRef() once will delete it. Calling IncRef() allows to lock
651 // it until the matching DecRef() is called
652 void IncRef() { m_nRef
++; }
653 void DecRef() { if ( !--m_nRef
) delete this; }
656 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; }
657 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; }
658 void SetFont(const wxFont
& font
) { m_font
= font
; }
659 void SetAlignment(int hAlign
, int vAlign
)
664 void SetSize(int num_rows
, int num_cols
);
665 void SetOverflow(bool allow
= TRUE
)
666 { m_overflow
= allow
? Overflow
: SingleCell
; }
667 void SetReadOnly(bool isReadOnly
= TRUE
)
668 { m_isReadOnly
= isReadOnly
? ReadOnly
: ReadWrite
; }
670 // takes ownership of the pointer
671 void SetRenderer(wxGridCellRenderer
*renderer
)
672 { wxSafeDecRef(m_renderer
); m_renderer
= renderer
; }
673 void SetEditor(wxGridCellEditor
* editor
)
674 { wxSafeDecRef(m_editor
); m_editor
= editor
; }
676 void SetKind(wxAttrKind kind
) { m_attrkind
= kind
; }
679 bool HasTextColour() const { return m_colText
.Ok(); }
680 bool HasBackgroundColour() const { return m_colBack
.Ok(); }
681 bool HasFont() const { return m_font
.Ok(); }
682 bool HasAlignment() const { return (m_hAlign
!= -1 || m_vAlign
!= -1); }
683 bool HasRenderer() const { return m_renderer
!= NULL
; }
684 bool HasEditor() const { return m_editor
!= NULL
; }
685 bool HasReadWriteMode() const { return m_isReadOnly
!= Unset
; }
686 bool HasOverflowMode() const { return m_overflow
!= UnsetOverflow
; }
688 const wxColour
& GetTextColour() const;
689 const wxColour
& GetBackgroundColour() const;
690 const wxFont
& GetFont() const;
691 void GetAlignment(int *hAlign
, int *vAlign
) const;
692 void GetSize(int *num_rows
, int *num_cols
) const;
693 bool GetOverflow() const
694 { return m_overflow
!= SingleCell
; }
695 wxGridCellRenderer
*GetRenderer(wxGrid
* grid
, int row
, int col
) const;
696 wxGridCellEditor
*GetEditor(wxGrid
* grid
, int row
, int col
) const;
698 bool IsReadOnly() const { return m_isReadOnly
== wxGridCellAttr::ReadOnly
; }
700 wxAttrKind
GetKind() { return m_attrkind
; }
702 void SetDefAttr(wxGridCellAttr
* defAttr
) { m_defGridAttr
= defAttr
; }
712 enum wxAttrOverflowMode
719 // the common part of all ctors
720 void Init(wxGridCellAttr
*attrDefault
= NULL
);
722 // the dtor is private because only DecRef() can delete us
725 wxSafeDecRef(m_renderer
);
726 wxSafeDecRef(m_editor
);
729 // the ref count - when it goes to 0, we die
740 wxAttrOverflowMode m_overflow
;
742 wxGridCellRenderer
* m_renderer
;
743 wxGridCellEditor
* m_editor
;
744 wxGridCellAttr
* m_defGridAttr
;
746 wxAttrReadMode m_isReadOnly
;
748 wxAttrKind m_attrkind
;
750 // use Clone() instead
751 DECLARE_NO_COPY_CLASS(wxGridCellAttr
)
753 // suppress the stupid gcc warning about the class having private dtor and
755 friend class wxGridCellAttrDummyFriend
;
758 // ----------------------------------------------------------------------------
759 // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
761 // ----------------------------------------------------------------------------
763 // implementation note: we separate it from wxGridTableBase because we wish to
764 // avoid deriving a new table class if possible, and sometimes it will be
765 // enough to just derive another wxGridCellAttrProvider instead
767 // the default implementation is reasonably efficient for the generic case,
768 // but you might still wish to implement your own for some specific situations
769 // if you have performance problems with the stock one
770 class WXDLLIMPEXP_ADV wxGridCellAttrProvider
: public wxClientDataContainer
773 wxGridCellAttrProvider();
774 virtual ~wxGridCellAttrProvider();
776 // DecRef() must be called on the returned pointer
777 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
778 wxGridCellAttr::wxAttrKind kind
) const;
780 // all these functions take ownership of the pointer, don't call DecRef()
782 virtual void SetAttr(wxGridCellAttr
*attr
, int row
, int col
);
783 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
784 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
786 // these functions must be called whenever some rows/cols are deleted
787 // because the internal data must be updated then
788 void UpdateAttrRows( size_t pos
, int numRows
);
789 void UpdateAttrCols( size_t pos
, int numCols
);
794 wxGridCellAttrProviderData
*m_data
;
796 DECLARE_NO_COPY_CLASS(wxGridCellAttrProvider
)
799 //////////////////////////////////////////////////////////////////////
801 // Grid table classes
803 //////////////////////////////////////////////////////////////////////
806 class WXDLLIMPEXP_ADV wxGridTableBase
: public wxObject
, public wxClientDataContainer
810 virtual ~wxGridTableBase();
812 // You must override these functions in a derived table class
814 virtual int GetNumberRows() = 0;
815 virtual int GetNumberCols() = 0;
816 virtual bool IsEmptyCell( int row
, int col
) = 0;
817 virtual wxString
GetValue( int row
, int col
) = 0;
818 virtual void SetValue( int row
, int col
, const wxString
& value
) = 0;
820 // Data type determination and value access
821 virtual wxString
GetTypeName( int row
, int col
);
822 virtual bool CanGetValueAs( int row
, int col
, const wxString
& typeName
);
823 virtual bool CanSetValueAs( int row
, int col
, const wxString
& typeName
);
825 virtual long GetValueAsLong( int row
, int col
);
826 virtual double GetValueAsDouble( int row
, int col
);
827 virtual bool GetValueAsBool( int row
, int col
);
829 virtual void SetValueAsLong( int row
, int col
, long value
);
830 virtual void SetValueAsDouble( int row
, int col
, double value
);
831 virtual void SetValueAsBool( int row
, int col
, bool value
);
833 // For user defined types
834 virtual void* GetValueAsCustom( int row
, int col
, const wxString
& typeName
);
835 virtual void SetValueAsCustom( int row
, int col
, const wxString
& typeName
, void* value
);
838 // Overriding these is optional
840 virtual void SetView( wxGrid
*grid
) { m_view
= grid
; }
841 virtual wxGrid
* GetView() const { return m_view
; }
843 virtual void Clear() {}
844 virtual bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
845 virtual bool AppendRows( size_t numRows
= 1 );
846 virtual bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
847 virtual bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
848 virtual bool AppendCols( size_t numCols
= 1 );
849 virtual bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
851 virtual wxString
GetRowLabelValue( int row
);
852 virtual wxString
GetColLabelValue( int col
);
853 virtual void SetRowLabelValue( int WXUNUSED(row
), const wxString
& ) {}
854 virtual void SetColLabelValue( int WXUNUSED(col
), const wxString
& ) {}
856 // Attribute handling
859 // give us the attr provider to use - we take ownership of the pointer
860 void SetAttrProvider(wxGridCellAttrProvider
*attrProvider
);
862 // get the currently used attr provider (may be NULL)
863 wxGridCellAttrProvider
*GetAttrProvider() const { return m_attrProvider
; }
865 // Does this table allow attributes? Default implementation creates
866 // a wxGridCellAttrProvider if necessary.
867 virtual bool CanHaveAttributes();
869 // by default forwarded to wxGridCellAttrProvider if any. May be
870 // overridden to handle attributes directly in the table.
871 virtual wxGridCellAttr
*GetAttr( int row
, int col
,
872 wxGridCellAttr::wxAttrKind kind
);
875 // these functions take ownership of the pointer
876 virtual void SetAttr(wxGridCellAttr
* attr
, int row
, int col
);
877 virtual void SetRowAttr(wxGridCellAttr
*attr
, int row
);
878 virtual void SetColAttr(wxGridCellAttr
*attr
, int col
);
882 wxGridCellAttrProvider
*m_attrProvider
;
884 DECLARE_ABSTRACT_CLASS( wxGridTableBase
);
885 DECLARE_NO_COPY_CLASS(wxGridTableBase
)
889 // ----------------------------------------------------------------------------
890 // wxGridTableMessage
891 // ----------------------------------------------------------------------------
893 // IDs for messages sent from grid table to view
895 enum wxGridTableRequest
897 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
= 2000,
898 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES
,
899 wxGRIDTABLE_NOTIFY_ROWS_INSERTED
,
900 wxGRIDTABLE_NOTIFY_ROWS_APPENDED
,
901 wxGRIDTABLE_NOTIFY_ROWS_DELETED
,
902 wxGRIDTABLE_NOTIFY_COLS_INSERTED
,
903 wxGRIDTABLE_NOTIFY_COLS_APPENDED
,
904 wxGRIDTABLE_NOTIFY_COLS_DELETED
907 class WXDLLIMPEXP_ADV wxGridTableMessage
910 wxGridTableMessage();
911 wxGridTableMessage( wxGridTableBase
*table
, int id
,
915 void SetTableObject( wxGridTableBase
*table
) { m_table
= table
; }
916 wxGridTableBase
* GetTableObject() const { return m_table
; }
917 void SetId( int id
) { m_id
= id
; }
918 int GetId() { return m_id
; }
919 void SetCommandInt( int comInt1
) { m_comInt1
= comInt1
; }
920 int GetCommandInt() { return m_comInt1
; }
921 void SetCommandInt2( int comInt2
) { m_comInt2
= comInt2
; }
922 int GetCommandInt2() { return m_comInt2
; }
925 wxGridTableBase
*m_table
;
930 DECLARE_NO_COPY_CLASS(wxGridTableMessage
)
935 // ------ wxGridStringArray
936 // A 2-dimensional array of strings for data values
939 WX_DECLARE_OBJARRAY_WITH_DECL(wxArrayString
, wxGridStringArray
,
940 class WXDLLIMPEXP_ADV
);
944 // ------ wxGridStringTable
946 // Simplest type of data table for a grid for small tables of strings
947 // that are stored in memory
950 class WXDLLIMPEXP_ADV wxGridStringTable
: public wxGridTableBase
954 wxGridStringTable( int numRows
, int numCols
);
955 virtual ~wxGridStringTable();
957 // these are pure virtual in wxGridTableBase
961 wxString
GetValue( int row
, int col
);
962 void SetValue( int row
, int col
, const wxString
& s
);
963 bool IsEmptyCell( int row
, int col
);
965 // overridden functions from wxGridTableBase
968 bool InsertRows( size_t pos
= 0, size_t numRows
= 1 );
969 bool AppendRows( size_t numRows
= 1 );
970 bool DeleteRows( size_t pos
= 0, size_t numRows
= 1 );
971 bool InsertCols( size_t pos
= 0, size_t numCols
= 1 );
972 bool AppendCols( size_t numCols
= 1 );
973 bool DeleteCols( size_t pos
= 0, size_t numCols
= 1 );
975 void SetRowLabelValue( int row
, const wxString
& );
976 void SetColLabelValue( int col
, const wxString
& );
977 wxString
GetRowLabelValue( int row
);
978 wxString
GetColLabelValue( int col
);
981 wxGridStringArray m_data
;
983 // These only get used if you set your own labels, otherwise the
984 // GetRow/ColLabelValue functions return wxGridTableBase defaults
986 wxArrayString m_rowLabels
;
987 wxArrayString m_colLabels
;
989 DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable
)
994 // ============================================================================
996 // ============================================================================
998 // ----------------------------------------------------------------------------
999 // wxGridCellCoords: location of a cell in the grid
1000 // ----------------------------------------------------------------------------
1002 class WXDLLIMPEXP_ADV wxGridCellCoords
1005 wxGridCellCoords() { m_row
= m_col
= -1; }
1006 wxGridCellCoords( int r
, int c
) { m_row
= r
; m_col
= c
; }
1008 // default copy ctor is ok
1010 int GetRow() const { return m_row
; }
1011 void SetRow( int n
) { m_row
= n
; }
1012 int GetCol() const { return m_col
; }
1013 void SetCol( int n
) { m_col
= n
; }
1014 void Set( int row
, int col
) { m_row
= row
; m_col
= col
; }
1016 wxGridCellCoords
& operator=( const wxGridCellCoords
& other
)
1018 if ( &other
!= this )
1026 bool operator==( const wxGridCellCoords
& other
) const
1028 return (m_row
== other
.m_row
&& m_col
== other
.m_col
);
1031 bool operator!=( const wxGridCellCoords
& other
) const
1033 return (m_row
!= other
.m_row
|| m_col
!= other
.m_col
);
1036 bool operator!() const
1038 return (m_row
== -1 && m_col
== -1 );
1047 // For comparisons...
1049 extern WXDLLIMPEXP_ADV wxGridCellCoords wxGridNoCellCoords
;
1050 extern WXDLLIMPEXP_ADV wxRect wxGridNoCellRect
;
1052 // An array of cell coords...
1054 WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellCoords
, wxGridCellCoordsArray
,
1055 class WXDLLIMPEXP_ADV
);
1057 // ----------------------------------------------------------------------------
1059 // ----------------------------------------------------------------------------
1061 class WXDLLIMPEXP_ADV wxGrid
: public wxScrolledWindow
1066 wxGrid( wxWindow
*parent
,
1068 const wxPoint
& pos
= wxDefaultPosition
,
1069 const wxSize
& size
= wxDefaultSize
,
1070 long style
= wxWANTS_CHARS
,
1071 const wxString
& name
= wxPanelNameStr
);
1073 bool Create( wxWindow
*parent
,
1075 const wxPoint
& pos
= wxDefaultPosition
,
1076 const wxSize
& size
= wxDefaultSize
,
1077 long style
= wxWANTS_CHARS
,
1078 const wxString
& name
= wxPanelNameStr
);
1082 enum wxGridSelectionModes
{wxGridSelectCells
,
1084 wxGridSelectColumns
};
1086 bool CreateGrid( int numRows
, int numCols
,
1087 wxGrid::wxGridSelectionModes selmode
=
1088 wxGrid::wxGridSelectCells
);
1090 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode
);
1091 wxGrid::wxGridSelectionModes
GetSelectionMode() const;
1093 // ------ grid dimensions
1095 int GetNumberRows() { return m_numRows
; }
1096 int GetNumberCols() { return m_numCols
; }
1099 // ------ display update functions
1101 wxArrayInt
CalcRowLabelsExposed( const wxRegion
& reg
);
1103 wxArrayInt
CalcColLabelsExposed( const wxRegion
& reg
);
1104 wxGridCellCoordsArray
CalcCellsExposed( const wxRegion
& reg
);
1107 // ------ event handlers
1109 void ProcessRowLabelMouseEvent( wxMouseEvent
& event
);
1110 void ProcessColLabelMouseEvent( wxMouseEvent
& event
);
1111 void ProcessCornerLabelMouseEvent( wxMouseEvent
& event
);
1112 void ProcessGridCellMouseEvent( wxMouseEvent
& event
);
1113 bool ProcessTableMessage( wxGridTableMessage
& );
1115 void DoEndDragResizeRow();
1116 void DoEndDragResizeCol();
1118 wxGridTableBase
* GetTable() const { return m_table
; }
1119 bool SetTable( wxGridTableBase
*table
, bool takeOwnership
=FALSE
,
1120 wxGrid::wxGridSelectionModes selmode
=
1121 wxGrid::wxGridSelectCells
);
1124 bool InsertRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1125 bool AppendRows( int numRows
= 1, bool updateLabels
=TRUE
);
1126 bool DeleteRows( int pos
= 0, int numRows
= 1, bool updateLabels
=TRUE
);
1127 bool InsertCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1128 bool AppendCols( int numCols
= 1, bool updateLabels
=TRUE
);
1129 bool DeleteCols( int pos
= 0, int numCols
= 1, bool updateLabels
=TRUE
);
1131 void DrawGridCellArea( wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1132 void DrawGridSpace( wxDC
& dc
);
1133 void DrawCellBorder( wxDC
& dc
, const wxGridCellCoords
& );
1134 void DrawAllGridLines( wxDC
& dc
, const wxRegion
& reg
);
1135 void DrawCell( wxDC
& dc
, const wxGridCellCoords
& );
1136 void DrawHighlight(wxDC
& dc
, const wxGridCellCoordsArray
& cells
);
1138 // this function is called when the current cell highlight must be redrawn
1139 // and may be overridden by the user
1140 virtual void DrawCellHighlight( wxDC
& dc
, const wxGridCellAttr
*attr
);
1142 void DrawRowLabels( wxDC
& dc
, const wxArrayInt
& rows
);
1143 void DrawRowLabel( wxDC
& dc
, int row
);
1145 void DrawColLabels( wxDC
& dc
, const wxArrayInt
& cols
);
1146 void DrawColLabel( wxDC
& dc
, int col
);
1149 // ------ Cell text drawing functions
1151 void DrawTextRectangle( wxDC
& dc
, const wxString
&, const wxRect
&,
1152 int horizontalAlignment
= wxALIGN_LEFT
,
1153 int verticalAlignment
= wxALIGN_TOP
,
1154 int textOrientation
= wxHORIZONTAL
);
1156 void DrawTextRectangle( wxDC
& dc
, const wxArrayString
& lines
, const wxRect
&,
1157 int horizontalAlignment
= wxALIGN_LEFT
,
1158 int verticalAlignment
= wxALIGN_TOP
,
1159 int textOrientation
= wxHORIZONTAL
);
1162 // Split a string containing newline chararcters into an array of
1163 // strings and return the number of lines
1165 void StringToLines( const wxString
& value
, wxArrayString
& lines
);
1167 void GetTextBoxSize( wxDC
& dc
,
1168 const wxArrayString
& lines
,
1169 long *width
, long *height
);
1173 // Code that does a lot of grid modification can be enclosed
1174 // between BeginBatch() and EndBatch() calls to avoid screen
1177 void BeginBatch() { m_batchCount
++; }
1180 int GetBatchCount() { return m_batchCount
; }
1182 virtual void Refresh(bool eraseb
= TRUE
,
1183 const wxRect
* rect
= (const wxRect
*) NULL
);
1185 // Use this, rather than wxWindow::Refresh(), to force an
1186 // immediate repainting of the grid. Has no effect if you are
1187 // already inside a BeginBatch / EndBatch block.
1189 // This function is necessary because wxGrid has a minimal OnPaint()
1190 // handler to reduce screen flicker.
1192 void ForceRefresh();
1195 // ------ edit control functions
1197 bool IsEditable() const { return m_editable
; }
1198 void EnableEditing( bool edit
);
1200 void EnableCellEditControl( bool enable
= TRUE
);
1201 void DisableCellEditControl() { EnableCellEditControl(FALSE
); }
1202 bool CanEnableCellControl() const;
1203 bool IsCellEditControlEnabled() const;
1204 bool IsCellEditControlShown() const;
1206 bool IsCurrentCellReadOnly() const;
1208 void ShowCellEditControl();
1209 void HideCellEditControl();
1210 void SaveEditControlValue();
1213 // ------ grid location functions
1214 // Note that all of these functions work with the logical coordinates of
1215 // grid cells and labels so you will need to convert from device
1216 // coordinates for mouse events etc.
1218 void XYToCell( int x
, int y
, wxGridCellCoords
& );
1219 int YToRow( int y
);
1220 int XToCol( int x
);
1222 int YToEdgeOfRow( int y
);
1223 int XToEdgeOfCol( int x
);
1225 wxRect
CellToRect( int row
, int col
);
1226 wxRect
CellToRect( const wxGridCellCoords
& coords
)
1227 { return CellToRect( coords
.GetRow(), coords
.GetCol() ); }
1229 int GetGridCursorRow() { return m_currentCellCoords
.GetRow(); }
1230 int GetGridCursorCol() { return m_currentCellCoords
.GetCol(); }
1232 // check to see if a cell is either wholly visible (the default arg) or
1233 // at least partially visible in the grid window
1235 bool IsVisible( int row
, int col
, bool wholeCellVisible
= TRUE
);
1236 bool IsVisible( const wxGridCellCoords
& coords
, bool wholeCellVisible
= TRUE
)
1237 { return IsVisible( coords
.GetRow(), coords
.GetCol(), wholeCellVisible
); }
1238 void MakeCellVisible( int row
, int col
);
1239 void MakeCellVisible( const wxGridCellCoords
& coords
)
1240 { MakeCellVisible( coords
.GetRow(), coords
.GetCol() ); }
1243 // ------ grid cursor movement functions
1245 void SetGridCursor( int row
, int col
)
1246 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1248 bool MoveCursorUp( bool expandSelection
);
1249 bool MoveCursorDown( bool expandSelection
);
1250 bool MoveCursorLeft( bool expandSelection
);
1251 bool MoveCursorRight( bool expandSelection
);
1252 bool MovePageDown();
1254 bool MoveCursorUpBlock( bool expandSelection
);
1255 bool MoveCursorDownBlock( bool expandSelection
);
1256 bool MoveCursorLeftBlock( bool expandSelection
);
1257 bool MoveCursorRightBlock( bool expandSelection
);
1260 // ------ label and gridline formatting
1262 int GetDefaultRowLabelSize() { return WXGRID_DEFAULT_ROW_LABEL_WIDTH
; }
1263 int GetRowLabelSize() { return m_rowLabelWidth
; }
1264 int GetDefaultColLabelSize() { return WXGRID_DEFAULT_COL_LABEL_HEIGHT
; }
1265 int GetColLabelSize() { return m_colLabelHeight
; }
1266 wxColour
GetLabelBackgroundColour() { return m_labelBackgroundColour
; }
1267 wxColour
GetLabelTextColour() { return m_labelTextColour
; }
1268 wxFont
GetLabelFont() { return m_labelFont
; }
1269 void GetRowLabelAlignment( int *horiz
, int *vert
);
1270 void GetColLabelAlignment( int *horiz
, int *vert
);
1271 int GetColLabelTextOrientation();
1272 wxString
GetRowLabelValue( int row
);
1273 wxString
GetColLabelValue( int col
);
1274 wxColour
GetGridLineColour() { return m_gridLineColour
; }
1275 wxColour
GetCellHighlightColour() { return m_cellHighlightColour
; }
1276 int GetCellHighlightPenWidth() { return m_cellHighlightPenWidth
; }
1277 int GetCellHighlightROPenWidth() { return m_cellHighlightROPenWidth
; }
1279 void SetRowLabelSize( int width
);
1280 void SetColLabelSize( int height
);
1281 void SetLabelBackgroundColour( const wxColour
& );
1282 void SetLabelTextColour( const wxColour
& );
1283 void SetLabelFont( const wxFont
& );
1284 void SetRowLabelAlignment( int horiz
, int vert
);
1285 void SetColLabelAlignment( int horiz
, int vert
);
1286 void SetColLabelTextOrientation( int textOrientation
);
1287 void SetRowLabelValue( int row
, const wxString
& );
1288 void SetColLabelValue( int col
, const wxString
& );
1289 void SetGridLineColour( const wxColour
& );
1290 void SetCellHighlightColour( const wxColour
& );
1291 void SetCellHighlightPenWidth(int width
);
1292 void SetCellHighlightROPenWidth(int width
);
1294 void EnableDragRowSize( bool enable
= TRUE
);
1295 void DisableDragRowSize() { EnableDragRowSize( FALSE
); }
1296 bool CanDragRowSize() { return m_canDragRowSize
; }
1297 void EnableDragColSize( bool enable
= TRUE
);
1298 void DisableDragColSize() { EnableDragColSize( FALSE
); }
1299 bool CanDragColSize() { return m_canDragColSize
; }
1300 void EnableDragGridSize(bool enable
= TRUE
);
1301 void DisableDragGridSize() { EnableDragGridSize(FALSE
); }
1302 bool CanDragGridSize() { return m_canDragGridSize
; }
1304 // this sets the specified attribute for this cell or in this row/col
1305 void SetAttr(int row
, int col
, wxGridCellAttr
*attr
);
1306 void SetRowAttr(int row
, wxGridCellAttr
*attr
);
1307 void SetColAttr(int col
, wxGridCellAttr
*attr
);
1309 // shortcuts for setting the column parameters
1311 // set the format for the data in the column: default is string
1312 void SetColFormatBool(int col
);
1313 void SetColFormatNumber(int col
);
1314 void SetColFormatFloat(int col
, int width
= -1, int precision
= -1);
1315 void SetColFormatCustom(int col
, const wxString
& typeName
);
1317 void EnableGridLines( bool enable
= TRUE
);
1318 bool GridLinesEnabled() { return m_gridLinesEnabled
; }
1320 // ------ row and col formatting
1322 int GetDefaultRowSize();
1323 int GetRowSize( int row
);
1324 int GetDefaultColSize();
1325 int GetColSize( int col
);
1326 wxColour
GetDefaultCellBackgroundColour();
1327 wxColour
GetCellBackgroundColour( int row
, int col
);
1328 wxColour
GetDefaultCellTextColour();
1329 wxColour
GetCellTextColour( int row
, int col
);
1330 wxFont
GetDefaultCellFont();
1331 wxFont
GetCellFont( int row
, int col
);
1332 void GetDefaultCellAlignment( int *horiz
, int *vert
);
1333 void GetCellAlignment( int row
, int col
, int *horiz
, int *vert
);
1334 bool GetDefaultCellOverflow();
1335 bool GetCellOverflow( int row
, int col
);
1336 void GetCellSize( int row
, int col
, int *num_rows
, int *num_cols
);
1338 void SetDefaultRowSize( int height
, bool resizeExistingRows
= FALSE
);
1339 void SetRowSize( int row
, int height
);
1340 void SetDefaultColSize( int width
, bool resizeExistingCols
= FALSE
);
1342 void SetColSize( int col
, int width
);
1344 // automatically size the column or row to fit to its contents, if
1345 // setAsMin is TRUE, this optimal width will also be set as minimal width
1347 void AutoSizeColumn( int col
, bool setAsMin
= TRUE
)
1348 { AutoSizeColOrRow(col
, setAsMin
, TRUE
); }
1349 void AutoSizeRow( int row
, bool setAsMin
= TRUE
)
1350 { AutoSizeColOrRow(row
, setAsMin
, FALSE
); }
1352 // auto size all columns (very ineffective for big grids!)
1353 void AutoSizeColumns( bool setAsMin
= TRUE
)
1354 { (void)SetOrCalcColumnSizes(FALSE
, setAsMin
); }
1356 void AutoSizeRows( bool setAsMin
= TRUE
)
1357 { (void)SetOrCalcRowSizes(FALSE
, setAsMin
); }
1359 // auto size the grid, that is make the columns/rows of the "right" size
1360 // and also set the grid size to just fit its contents
1363 // autosize row height depending on label text
1364 void AutoSizeRowLabelSize( int row
);
1366 // autosize column width depending on label text
1367 void AutoSizeColLabelSize( int col
);
1369 // column won't be resized to be lesser width - this must be called during
1370 // the grid creation because it won't resize the column if it's already
1371 // narrower than the minimal width
1372 void SetColMinimalWidth( int col
, int width
);
1373 void SetRowMinimalHeight( int row
, int width
);
1375 /* These members can be used to query and modify the minimal
1376 * acceptable size of grid rows and columns. Call this function in
1377 * your code which creates the grid if you want to display cells
1378 * with a size smaller than the default acceptable minimum size.
1379 * Like the members SetColMinimalWidth and SetRowMinimalWidth,
1380 * the existing rows or columns will not be checked/resized.
1382 void SetColMinimalAcceptableWidth( int width
);
1383 void SetRowMinimalAcceptableHeight( int width
);
1384 int GetColMinimalAcceptableWidth() const;
1385 int GetRowMinimalAcceptableHeight() const;
1387 void SetDefaultCellBackgroundColour( const wxColour
& );
1388 void SetCellBackgroundColour( int row
, int col
, const wxColour
& );
1389 void SetDefaultCellTextColour( const wxColour
& );
1391 void SetCellTextColour( int row
, int col
, const wxColour
& );
1392 void SetDefaultCellFont( const wxFont
& );
1393 void SetCellFont( int row
, int col
, const wxFont
& );
1394 void SetDefaultCellAlignment( int horiz
, int vert
);
1395 void SetCellAlignment( int row
, int col
, int horiz
, int vert
);
1396 void SetDefaultCellOverflow( bool allow
);
1397 void SetCellOverflow( int row
, int col
, bool allow
);
1398 void SetCellSize( int row
, int col
, int num_rows
, int num_cols
);
1400 // takes ownership of the pointer
1401 void SetDefaultRenderer(wxGridCellRenderer
*renderer
);
1402 void SetCellRenderer(int row
, int col
, wxGridCellRenderer
*renderer
);
1403 wxGridCellRenderer
*GetDefaultRenderer() const;
1404 wxGridCellRenderer
* GetCellRenderer(int row
, int col
);
1406 // takes ownership of the pointer
1407 void SetDefaultEditor(wxGridCellEditor
*editor
);
1408 void SetCellEditor(int row
, int col
, wxGridCellEditor
*editor
);
1409 wxGridCellEditor
*GetDefaultEditor() const;
1410 wxGridCellEditor
* GetCellEditor(int row
, int col
);
1414 // ------ cell value accessors
1416 wxString
GetCellValue( int row
, int col
)
1420 return m_table
->GetValue( row
, col
);
1424 return wxEmptyString
;
1428 wxString
GetCellValue( const wxGridCellCoords
& coords
)
1429 { return GetCellValue( coords
.GetRow(), coords
.GetCol() ); }
1431 void SetCellValue( int row
, int col
, const wxString
& s
);
1432 void SetCellValue( const wxGridCellCoords
& coords
, const wxString
& s
)
1433 { SetCellValue( coords
.GetRow(), coords
.GetCol(), s
); }
1435 // returns TRUE if the cell can't be edited
1436 bool IsReadOnly(int row
, int col
) const;
1438 // make the cell editable/readonly
1439 void SetReadOnly(int row
, int col
, bool isReadOnly
= TRUE
);
1441 // ------ select blocks of cells
1443 void SelectRow( int row
, bool addToSelected
= FALSE
);
1444 void SelectCol( int col
, bool addToSelected
= FALSE
);
1446 void SelectBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
,
1447 bool addToSelected
= FALSE
);
1449 void SelectBlock( const wxGridCellCoords
& topLeft
,
1450 const wxGridCellCoords
& bottomRight
,
1451 bool addToSelected
= FALSE
)
1452 { SelectBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1453 bottomRight
.GetRow(), bottomRight
.GetCol(),
1460 // ------ deselect blocks or cells
1462 void DeselectRow( int row
);
1463 void DeselectCol( int col
);
1464 void DeselectCell( int row
, int col
);
1466 void ClearSelection();
1468 bool IsInSelection( int row
, int col
) const;
1470 bool IsInSelection( const wxGridCellCoords
& coords
) const
1471 { return IsInSelection( coords
.GetRow(), coords
.GetCol() ); }
1473 wxGridCellCoordsArray
GetSelectedCells() const;
1474 wxGridCellCoordsArray
GetSelectionBlockTopLeft() const;
1475 wxGridCellCoordsArray
GetSelectionBlockBottomRight() const;
1476 wxArrayInt
GetSelectedRows() const;
1477 wxArrayInt
GetSelectedCols() const;
1479 // This function returns the rectangle that encloses the block of cells
1480 // limited by TopLeft and BottomRight cell in device coords and clipped
1481 // to the client size of the grid window.
1483 wxRect
BlockToDeviceRect( const wxGridCellCoords
& topLeft
,
1484 const wxGridCellCoords
& bottomRight
);
1486 // Access or update the selection fore/back colours
1487 wxColour
GetSelectionBackground() const
1488 { return m_selectionBackground
; }
1489 wxColour
GetSelectionForeground() const
1490 { return m_selectionForeground
; }
1492 void SetSelectionBackground(const wxColour
& c
) { m_selectionBackground
= c
; }
1493 void SetSelectionForeground(const wxColour
& c
) { m_selectionForeground
= c
; }
1496 // Methods for a registry for mapping data types to Renderers/Editors
1497 void RegisterDataType(const wxString
& typeName
,
1498 wxGridCellRenderer
* renderer
,
1499 wxGridCellEditor
* editor
);
1501 virtual wxGridCellEditor
* GetDefaultEditorForCell(int row
, int col
) const;
1502 wxGridCellEditor
* GetDefaultEditorForCell(const wxGridCellCoords
& c
) const
1503 { return GetDefaultEditorForCell(c
.GetRow(), c
.GetCol()); }
1504 virtual wxGridCellRenderer
* GetDefaultRendererForCell(int row
, int col
) const;
1505 virtual wxGridCellEditor
* GetDefaultEditorForType(const wxString
& typeName
) const;
1506 virtual wxGridCellRenderer
* GetDefaultRendererForType(const wxString
& typeName
) const;
1508 // grid may occupy more space than needed for its rows/columns, this
1509 // function allows to set how big this extra space is
1510 void SetMargins(int extraWidth
, int extraHeight
)
1512 m_extraWidth
= extraWidth
;
1513 m_extraHeight
= extraHeight
;
1518 // Accessors for component windows
1519 wxWindow
* GetGridWindow() { return (wxWindow
*)m_gridWin
; }
1520 wxWindow
* GetGridRowLabelWindow() { return (wxWindow
*)m_rowLabelWin
; }
1521 wxWindow
* GetGridColLabelWindow() { return (wxWindow
*)m_colLabelWin
; }
1522 wxWindow
* GetGridCornerLabelWindow() { return (wxWindow
*)m_cornerLabelWin
; }
1526 // ------ For compatibility with previous wxGrid only...
1528 // ************************************************
1529 // ** Don't use these in new code because they **
1530 // ** are liable to disappear in a future **
1532 // ************************************************
1535 wxGrid( wxWindow
*parent
,
1536 int x
, int y
, int w
= -1, int h
= -1,
1537 long style
= wxWANTS_CHARS
,
1538 const wxString
& name
= wxPanelNameStr
)
1539 : wxScrolledWindow( parent
, -1, wxPoint(x
,y
), wxSize(w
,h
),
1540 (style
|wxWANTS_CHARS
), name
)
1545 void SetCellValue( const wxString
& val
, int row
, int col
)
1546 { SetCellValue( row
, col
, val
); }
1548 void UpdateDimensions()
1549 { CalcDimensions(); }
1551 int GetRows() { return GetNumberRows(); }
1552 int GetCols() { return GetNumberCols(); }
1553 int GetCursorRow() { return GetGridCursorRow(); }
1554 int GetCursorColumn() { return GetGridCursorCol(); }
1556 int GetScrollPosX() { return 0; }
1557 int GetScrollPosY() { return 0; }
1559 void SetScrollX( int WXUNUSED(x
) ) { }
1560 void SetScrollY( int WXUNUSED(y
) ) { }
1562 void SetColumnWidth( int col
, int width
)
1563 { SetColSize( col
, width
); }
1565 int GetColumnWidth( int col
)
1566 { return GetColSize( col
); }
1568 void SetRowHeight( int row
, int height
)
1569 { SetRowSize( row
, height
); }
1571 // GetRowHeight() is below
1573 int GetViewHeight() // returned num whole rows visible
1576 int GetViewWidth() // returned num whole cols visible
1579 void SetLabelSize( int orientation
, int sz
)
1581 if ( orientation
== wxHORIZONTAL
)
1582 SetColLabelSize( sz
);
1584 SetRowLabelSize( sz
);
1587 int GetLabelSize( int orientation
)
1589 if ( orientation
== wxHORIZONTAL
)
1590 return GetColLabelSize();
1592 return GetRowLabelSize();
1595 void SetLabelAlignment( int orientation
, int align
)
1597 if ( orientation
== wxHORIZONTAL
)
1598 SetColLabelAlignment( align
, -1 );
1600 SetRowLabelAlignment( align
, -1 );
1603 int GetLabelAlignment( int orientation
, int WXUNUSED(align
) )
1606 if ( orientation
== wxHORIZONTAL
)
1608 GetColLabelAlignment( &h
, &v
);
1613 GetRowLabelAlignment( &h
, &v
);
1618 void SetLabelValue( int orientation
, const wxString
& val
, int pos
)
1620 if ( orientation
== wxHORIZONTAL
)
1621 SetColLabelValue( pos
, val
);
1623 SetRowLabelValue( pos
, val
);
1626 wxString
GetLabelValue( int orientation
, int pos
)
1628 if ( orientation
== wxHORIZONTAL
)
1629 return GetColLabelValue( pos
);
1631 return GetRowLabelValue( pos
);
1634 wxFont
GetCellTextFont() const
1635 { return m_defaultCellAttr
->GetFont(); }
1637 wxFont
GetCellTextFont(int WXUNUSED(row
), int WXUNUSED(col
)) const
1638 { return m_defaultCellAttr
->GetFont(); }
1640 void SetCellTextFont(const wxFont
& fnt
)
1641 { SetDefaultCellFont( fnt
); }
1643 void SetCellTextFont(const wxFont
& fnt
, int row
, int col
)
1644 { SetCellFont( row
, col
, fnt
); }
1646 void SetCellTextColour(const wxColour
& val
, int row
, int col
)
1647 { SetCellTextColour( row
, col
, val
); }
1649 void SetCellTextColour(const wxColour
& col
)
1650 { SetDefaultCellTextColour( col
); }
1652 void SetCellBackgroundColour(const wxColour
& col
)
1653 { SetDefaultCellBackgroundColour( col
); }
1655 void SetCellBackgroundColour(const wxColour
& colour
, int row
, int col
)
1656 { SetCellBackgroundColour( row
, col
, colour
); }
1658 bool GetEditable() { return IsEditable(); }
1659 void SetEditable( bool edit
= TRUE
) { EnableEditing( edit
); }
1660 bool GetEditInPlace() { return IsCellEditControlEnabled(); }
1662 void SetEditInPlace(bool WXUNUSED(edit
) = TRUE
) { }
1664 void SetCellAlignment( int align
, int row
, int col
)
1665 { SetCellAlignment(row
, col
, align
, wxALIGN_CENTER
); }
1666 void SetCellAlignment( int WXUNUSED(align
) ) {}
1667 void SetCellBitmap(wxBitmap
*WXUNUSED(bitmap
), int WXUNUSED(row
), int WXUNUSED(col
))
1669 void SetDividerPen(const wxPen
& WXUNUSED(pen
)) { }
1670 wxPen
& GetDividerPen() const;
1671 void OnActivate(bool WXUNUSED(active
)) {}
1673 // ******** End of compatibility functions **********
1677 // ------ control IDs
1678 enum { wxGRID_CELLCTRL
= 2000,
1681 // ------ control types
1682 enum { wxGRID_TEXTCTRL
= 2100,
1687 // overridden wxWindow methods
1691 virtual wxSize
DoGetBestSize() const;
1695 wxGridWindow
*m_gridWin
;
1696 wxGridRowLabelWindow
*m_rowLabelWin
;
1697 wxGridColLabelWindow
*m_colLabelWin
;
1698 wxGridCornerLabelWindow
*m_cornerLabelWin
;
1700 wxGridTableBase
*m_table
;
1706 wxGridCellCoords m_currentCellCoords
;
1708 wxGridCellCoords m_selectingTopLeft
;
1709 wxGridCellCoords m_selectingBottomRight
;
1710 wxGridCellCoords m_selectingKeyboard
;
1711 wxGridSelection
*m_selection
;
1712 wxColour m_selectionBackground
;
1713 wxColour m_selectionForeground
;
1715 // NB: *never* access m_row/col arrays directly because they are created
1716 // on demand, *always* use accessor functions instead!
1718 // init the m_rowHeights/Bottoms arrays with default values
1719 void InitRowHeights();
1721 int m_defaultRowHeight
;
1722 int m_minAcceptableRowHeight
;
1723 wxArrayInt m_rowHeights
;
1724 wxArrayInt m_rowBottoms
;
1726 // init the m_colWidths/Rights arrays
1727 void InitColWidths();
1729 int m_defaultColWidth
;
1730 int m_minAcceptableColWidth
;
1731 wxArrayInt m_colWidths
;
1732 wxArrayInt m_colRights
;
1734 // get the col/row coords
1735 int GetColWidth(int col
) const;
1736 int GetColLeft(int col
) const;
1737 int GetColRight(int col
) const;
1739 // this function must be public for compatibility...
1741 int GetRowHeight(int row
) const;
1744 int GetRowTop(int row
) const;
1745 int GetRowBottom(int row
) const;
1747 int m_rowLabelWidth
;
1748 int m_colLabelHeight
;
1750 // the size of the margin left to the right and bottom of the cell area
1754 wxColour m_labelBackgroundColour
;
1755 wxColour m_labelTextColour
;
1758 int m_rowLabelHorizAlign
;
1759 int m_rowLabelVertAlign
;
1760 int m_colLabelHorizAlign
;
1761 int m_colLabelVertAlign
;
1762 int m_colLabelTextOrientation
;
1764 bool m_defaultRowLabelValues
;
1765 bool m_defaultColLabelValues
;
1767 wxColour m_gridLineColour
;
1768 bool m_gridLinesEnabled
;
1769 wxColour m_cellHighlightColour
;
1770 int m_cellHighlightPenWidth
;
1771 int m_cellHighlightROPenWidth
;
1774 // common part of AutoSizeColumn/Row() and GetBestSize()
1775 int SetOrCalcColumnSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1776 int SetOrCalcRowSizes(bool calcOnly
, bool setAsMin
= TRUE
);
1778 // common part of AutoSizeColumn/Row()
1779 void AutoSizeColOrRow(int n
, bool setAsMin
, bool column
/* or row? */);
1781 // if a column has a minimal width, it will be the value for it in this
1783 wxLongToLongHashMap m_colMinWidths
,
1786 // get the minimal width of the given column/row
1787 int GetColMinimalWidth(int col
) const;
1788 int GetRowMinimalHeight(int col
) const;
1790 // do we have some place to store attributes in?
1791 bool CanHaveAttributes();
1793 // returns the attribute we may modify in place: a new one if this cell
1794 // doesn't have any yet or the existing one if it does
1796 // DecRef() must be called on the returned pointer, as usual
1797 wxGridCellAttr
*GetOrCreateCellAttr(int row
, int col
) const;
1799 // cell attribute cache (currently we only cache 1, may be will do
1800 // more/better later)
1804 wxGridCellAttr
*attr
;
1807 // invalidates the attribute cache
1808 void ClearAttrCache();
1810 // adds an attribute to cache
1811 void CacheAttr(int row
, int col
, wxGridCellAttr
*attr
) const;
1813 // looks for an attr in cache, returns TRUE if found
1814 bool LookupAttr(int row
, int col
, wxGridCellAttr
**attr
) const;
1816 // looks for the attr in cache, if not found asks the table and caches the
1818 wxGridCellAttr
*GetCellAttr(int row
, int col
) const;
1819 wxGridCellAttr
*GetCellAttr(const wxGridCellCoords
& coords
)
1820 { return GetCellAttr( coords
.GetRow(), coords
.GetCol() ); }
1822 // the default cell attr object for cells that don't have their own
1823 wxGridCellAttr
* m_defaultCellAttr
;
1830 wxGridTypeRegistry
* m_typeRegistry
;
1834 WXGRID_CURSOR_SELECT_CELL
,
1835 WXGRID_CURSOR_RESIZE_ROW
,
1836 WXGRID_CURSOR_RESIZE_COL
,
1837 WXGRID_CURSOR_SELECT_ROW
,
1838 WXGRID_CURSOR_SELECT_COL
1841 // this method not only sets m_cursorMode but also sets the correct cursor
1842 // for the given mode and, if captureMouse is not FALSE releases the mouse
1843 // if it was captured and captures it if it must be captured
1845 // for this to work, you should always use it and not set m_cursorMode
1847 void ChangeCursorMode(CursorMode mode
,
1848 wxWindow
*win
= (wxWindow
*)NULL
,
1849 bool captureMouse
= TRUE
);
1851 wxWindow
*m_winCapture
; // the window which captured the mouse
1852 CursorMode m_cursorMode
;
1854 bool m_canDragRowSize
;
1855 bool m_canDragColSize
;
1856 bool m_canDragGridSize
;
1860 wxPoint m_startDragPos
;
1862 bool m_waitForSlowClick
;
1864 wxGridCellCoords m_selectionStart
;
1866 wxCursor m_rowResizeCursor
;
1867 wxCursor m_colResizeCursor
;
1869 bool m_editable
; // applies to whole grid
1870 bool m_cellEditCtrlEnabled
; // is in-place edit currently shown?
1875 void CalcDimensions();
1876 void CalcWindowSizes();
1877 bool Redimension( wxGridTableMessage
& );
1880 int SendEvent( const wxEventType
, int row
, int col
, wxMouseEvent
& );
1881 int SendEvent( const wxEventType
, int row
, int col
);
1882 int SendEvent( const wxEventType type
)
1884 return SendEvent(type
,
1885 m_currentCellCoords
.GetRow(),
1886 m_currentCellCoords
.GetCol());
1889 void OnPaint( wxPaintEvent
& );
1890 void OnSize( wxSizeEvent
& );
1891 void OnKeyDown( wxKeyEvent
& );
1892 void OnKeyUp( wxKeyEvent
& );
1893 void OnEraseBackground( wxEraseEvent
& );
1896 void SetCurrentCell( const wxGridCellCoords
& coords
);
1897 void SetCurrentCell( int row
, int col
)
1898 { SetCurrentCell( wxGridCellCoords(row
, col
) ); }
1900 void HighlightBlock( int topRow
, int leftCol
, int bottomRow
, int rightCol
);
1902 void HighlightBlock( const wxGridCellCoords
& topLeft
,
1903 const wxGridCellCoords
& bottomRight
)
1904 { HighlightBlock( topLeft
.GetRow(), topLeft
.GetCol(),
1905 bottomRight
.GetRow(), bottomRight
.GetCol() ); }
1907 // ------ functions to get/send data (see also public functions)
1909 bool GetModelValues();
1910 bool SetModelValues();
1912 friend class WXDLLIMPEXP_ADV wxGridSelection
;
1914 DECLARE_DYNAMIC_CLASS( wxGrid
)
1915 DECLARE_EVENT_TABLE()
1916 DECLARE_NO_COPY_CLASS(wxGrid
)
1920 // ----------------------------------------------------------------------------
1921 // Grid event class and event types
1922 // ----------------------------------------------------------------------------
1924 class WXDLLIMPEXP_ADV wxGridEvent
: public wxNotifyEvent
1928 : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
1929 m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0)
1933 wxGridEvent(int id
, wxEventType type
, wxObject
* obj
,
1934 int row
=-1, int col
=-1, int x
=-1, int y
=-1, bool sel
= TRUE
,
1935 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1937 virtual int GetRow() { return m_row
; }
1938 virtual int GetCol() { return m_col
; }
1939 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1940 bool Selecting() { return m_selecting
; }
1941 bool ControlDown() { return m_control
; }
1942 bool MetaDown() { return m_meta
; }
1943 bool ShiftDown() { return m_shift
; }
1944 bool AltDown() { return m_alt
; }
1957 DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridEvent
)
1960 class WXDLLIMPEXP_ADV wxGridSizeEvent
: public wxNotifyEvent
1964 : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
1965 m_control(0), m_meta(0), m_shift(0), m_alt(0)
1969 wxGridSizeEvent(int id
, wxEventType type
, wxObject
* obj
,
1970 int rowOrCol
=-1, int x
=-1, int y
=-1,
1971 bool control
=FALSE
, bool shift
=FALSE
, bool alt
=FALSE
, bool meta
=FALSE
);
1973 int GetRowOrCol() { return m_rowOrCol
; }
1974 wxPoint
GetPosition() { return wxPoint( m_x
, m_y
); }
1975 bool ControlDown() { return m_control
; }
1976 bool MetaDown() { return m_meta
; }
1977 bool ShiftDown() { return m_shift
; }
1978 bool AltDown() { return m_alt
; }
1989 DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridSizeEvent
)
1993 class WXDLLIMPEXP_ADV wxGridRangeSelectEvent
: public wxNotifyEvent
1996 wxGridRangeSelectEvent()
1999 m_topLeft
= wxGridNoCellCoords
;
2000 m_bottomRight
= wxGridNoCellCoords
;
2001 m_selecting
= FALSE
;
2008 wxGridRangeSelectEvent(int id
, wxEventType type
, wxObject
* obj
,
2009 const wxGridCellCoords
& topLeft
,
2010 const wxGridCellCoords
& bottomRight
,
2012 bool control
=FALSE
, bool shift
=FALSE
,
2013 bool alt
=FALSE
, bool meta
=FALSE
);
2015 wxGridCellCoords
GetTopLeftCoords() { return m_topLeft
; }
2016 wxGridCellCoords
GetBottomRightCoords() { return m_bottomRight
; }
2017 int GetTopRow() { return m_topLeft
.GetRow(); }
2018 int GetBottomRow() { return m_bottomRight
.GetRow(); }
2019 int GetLeftCol() { return m_topLeft
.GetCol(); }
2020 int GetRightCol() { return m_bottomRight
.GetCol(); }
2021 bool Selecting() { return m_selecting
; }
2022 bool ControlDown() { return m_control
; }
2023 bool MetaDown() { return m_meta
; }
2024 bool ShiftDown() { return m_shift
; }
2025 bool AltDown() { return m_alt
; }
2028 wxGridCellCoords m_topLeft
;
2029 wxGridCellCoords m_bottomRight
;
2036 DECLARE_DYNAMIC_CLASS_NO_COPY(wxGridRangeSelectEvent
)
2040 class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent
: public wxCommandEvent
{
2042 wxGridEditorCreatedEvent()
2050 wxGridEditorCreatedEvent(int id
, wxEventType type
, wxObject
* obj
,
2051 int row
, int col
, wxControl
* ctrl
);
2053 int GetRow() { return m_row
; }
2054 int GetCol() { return m_col
; }
2055 wxControl
* GetControl() { return m_ctrl
; }
2056 void SetRow(int row
) { m_row
= row
; }
2057 void SetCol(int col
) { m_col
= col
; }
2058 void SetControl(wxControl
* ctrl
) { m_ctrl
= ctrl
; }
2065 DECLARE_DYNAMIC_CLASS(wxGridEditorCreatedEvent
)
2066 DECLARE_NO_COPY_CLASS(wxGridEditorCreatedEvent
)
2070 BEGIN_DECLARE_EVENT_TYPES()
2071 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_LEFT_CLICK
, 1580)
2072 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_RIGHT_CLICK
, 1581)
2073 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_LEFT_DCLICK
, 1582)
2074 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_RIGHT_DCLICK
, 1583)
2075 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_LEFT_CLICK
, 1584)
2076 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_RIGHT_CLICK
, 1585)
2077 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_LEFT_DCLICK
, 1586)
2078 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_LABEL_RIGHT_DCLICK
, 1587)
2079 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_ROW_SIZE
, 1588)
2080 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_COL_SIZE
, 1589)
2081 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_RANGE_SELECT
, 1590)
2082 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_CELL_CHANGE
, 1591)
2083 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_SELECT_CELL
, 1592)
2084 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_SHOWN
, 1593)
2085 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_HIDDEN
, 1594)
2086 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV
, wxEVT_GRID_EDITOR_CREATED
, 1595)
2087 END_DECLARE_EVENT_TYPES()
2090 typedef void (wxEvtHandler::*wxGridEventFunction
)(wxGridEvent
&);
2091 typedef void (wxEvtHandler::*wxGridSizeEventFunction
)(wxGridSizeEvent
&);
2092 typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction
)(wxGridRangeSelectEvent
&);
2093 typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction
)(wxGridEditorCreatedEvent
&);
2095 #define EVT_GRID_CELL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2096 #define EVT_GRID_CELL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2097 #define EVT_GRID_CELL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2098 #define EVT_GRID_CELL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2099 #define EVT_GRID_LABEL_LEFT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2100 #define EVT_GRID_LABEL_RIGHT_CLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_CLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2101 #define EVT_GRID_LABEL_LEFT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2102 #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_LABEL_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2103 #define EVT_GRID_ROW_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_ROW_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridSizeEventFunction, &fn ), NULL ),
2104 #define EVT_GRID_COL_SIZE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_COL_SIZE, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridSizeEventFunction, &fn ), NULL ),
2105 #define EVT_GRID_RANGE_SELECT(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_RANGE_SELECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridRangeSelectEventFunction, &fn ), NULL ),
2106 #define EVT_GRID_CELL_CHANGE(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CELL_CHANGE, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2107 #define EVT_GRID_SELECT_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_SELECT_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2108 #define EVT_GRID_EDITOR_SHOWN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_SHOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2109 #define EVT_GRID_EDITOR_HIDDEN(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_HIDDEN, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2110 #define EVT_GRID_EDITOR_CREATED(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_EDITOR_CREATED, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEditorCreatedEventFunction, &fn ), NULL ),
2113 #if 0 // TODO: implement these ? others ?
2115 extern const int wxEVT_GRID_CREATE_CELL
;
2116 extern const int wxEVT_GRID_CHANGE_LABELS
;
2117 extern const int wxEVT_GRID_CHANGE_SEL_LABEL
;
2119 #define EVT_GRID_CREATE_CELL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2120 #define EVT_GRID_CHANGE_LABELS(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2121 #define EVT_GRID_CHANGE_SEL_LABEL(fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, -1, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ),
2125 #endif // ifndef wxUSE_GRID