1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions for the new wxGrid and related classes
7 // Created: 17-March-2000
9 // Copyright: (c) 2000 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
20 #include <wx/generic/gridctrl.h>
23 //----------------------------------------------------------------------
26 %include my_typemaps.i
28 // Import some definitions of other classes, etc.
36 %pragma(python) code = "import wx"
38 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
40 // Macros, similar to what's in helpers.h, to aid in the creation of
41 // virtual methods that are able to make callbacks to Python. Many of these
42 // are specific to wxGrid and so are kept here to reduce the mess in helpers.h
47 #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME) \
48 wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \
49 wxGridCellAttr* rval = NULL; \
51 wxPyBeginBlockThreads(); \
52 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
54 wxGridCellAttr* ptr; \
55 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \
57 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellAttr_p")) \
62 wxPyEndBlockThreads(); \
64 rval = PCLASS::CBNAME(a, b, c); \
67 wxGridCellAttr *base_##CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \
68 return PCLASS::CBNAME(a, b, c); \
73 #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME) \
74 void CBNAME(wxGridCellAttr *attr, int a, int b) { \
75 wxPyBeginBlockThreads(); \
77 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
78 PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\
79 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b)); \
82 wxPyEndBlockThreads(); \
84 PCLASS::CBNAME(attr, a, b); \
86 void base_##CBNAME(wxGridCellAttr *attr, int a, int b) { \
87 PCLASS::CBNAME(attr, a, b); \
92 #define PYCALLBACK__GCAINT(PCLASS, CBNAME) \
93 void CBNAME(wxGridCellAttr *attr, int val) { \
94 wxPyBeginBlockThreads(); \
96 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
97 PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\
98 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \
101 wxPyEndBlockThreads(); \
103 PCLASS::CBNAME(attr, val); \
105 void base_##CBNAME(wxGridCellAttr *attr, int val) { \
106 PCLASS::CBNAME(attr, val); \
111 #define PYCALLBACK_INT__pure(CBNAME) \
113 wxPyBeginBlockThreads(); \
115 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
116 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
117 wxPyEndBlockThreads(); \
123 #define PYCALLBACK_BOOL_INTINT_pure(CBNAME) \
124 bool CBNAME(int a, int b) { \
125 wxPyBeginBlockThreads(); \
127 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
128 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
129 wxPyEndBlockThreads(); \
135 #define PYCALLBACK_STRING_INTINT_pure(CBNAME) \
136 wxString CBNAME(int a, int b) { \
137 wxPyBeginBlockThreads(); \
139 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
141 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
143 PyObject* str = PyObject_Str(ro); \
144 rval = PyString_AsString(str); \
145 Py_DECREF(ro); Py_DECREF(str); \
148 wxPyEndBlockThreads(); \
154 #define PYCALLBACK__INTINTSTRING_pure(CBNAME) \
155 void CBNAME(int a, int b, const wxString& c) { \
156 wxPyBeginBlockThreads(); \
157 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
158 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
159 wxPyEndBlockThreads(); \
163 #define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \
164 wxString CBNAME(int a, int b) { \
166 wxPyBeginBlockThreads(); \
168 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
170 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
172 PyObject* str = PyObject_Str(ro); \
173 rval = PyString_AsString(str); \
174 Py_DECREF(ro); Py_DECREF(str); \
177 wxPyEndBlockThreads(); \
179 rval = PCLASS::CBNAME(a, b); \
182 wxString base_##CBNAME(int a, int b) { \
183 return PCLASS::CBNAME(a, b); \
188 #define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \
189 bool CBNAME(int a, int b, const wxString& c) { \
192 wxPyBeginBlockThreads(); \
193 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
194 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str()));\
195 wxPyEndBlockThreads(); \
197 rval = PCLASS::CBNAME(a,b,c); \
200 bool base_##CBNAME(int a, int b, const wxString& c) { \
201 return PCLASS::CBNAME(a,b,c); \
207 #define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME) \
208 long CBNAME(int a, int b) { \
211 wxPyBeginBlockThreads(); \
212 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
213 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
214 wxPyEndBlockThreads(); \
216 rval = PCLASS::CBNAME(a,b); \
219 long base_##CBNAME(int a, int b) { \
220 return PCLASS::CBNAME(a,b); \
225 #define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \
226 bool CBNAME(int a, int b) { \
229 wxPyBeginBlockThreads(); \
230 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
231 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
232 wxPyEndBlockThreads(); \
234 rval = PCLASS::CBNAME(a,b); \
237 bool base_##CBNAME(int a, int b) { \
238 return PCLASS::CBNAME(a,b); \
243 #define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME) \
244 double CBNAME(int a, int b) { \
246 wxPyBeginBlockThreads(); \
248 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
250 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
252 PyObject* str = PyObject_Str(ro); \
253 rval = PyFloat_AsDouble(str); \
254 Py_DECREF(ro); Py_DECREF(str); \
257 wxPyEndBlockThreads(); \
259 rval = PCLASS::CBNAME(a, b); \
262 double base_##CBNAME(int a, int b) { \
263 return PCLASS::CBNAME(a, b); \
268 #define PYCALLBACK__(PCLASS, CBNAME) \
271 wxPyBeginBlockThreads(); \
272 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
273 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
274 wxPyEndBlockThreads(); \
278 void base_##CBNAME() { \
285 #define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME) \
286 bool CBNAME(size_t a, size_t b) { \
289 wxPyBeginBlockThreads(); \
290 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
291 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
292 wxPyEndBlockThreads(); \
294 rval = PCLASS::CBNAME(a,b); \
297 bool base_##CBNAME(size_t a, size_t b) { \
298 return PCLASS::CBNAME(a,b); \
303 #define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME) \
304 bool CBNAME(size_t a) { \
307 wxPyBeginBlockThreads(); \
308 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
309 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
310 wxPyEndBlockThreads(); \
312 rval = PCLASS::CBNAME(a); \
315 bool base_##CBNAME(size_t a) { \
316 return PCLASS::CBNAME(a); \
321 #define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \
322 wxString CBNAME(int a) { \
324 wxPyBeginBlockThreads(); \
326 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
328 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
330 PyObject* str = PyObject_Str(ro); \
331 rval = PyString_AsString(str); \
332 Py_DECREF(ro); Py_DECREF(str); \
335 wxPyEndBlockThreads(); \
337 rval = PCLASS::CBNAME(a); \
340 wxString base_##CBNAME(int a) { \
341 return PCLASS::CBNAME(a); \
346 #define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \
347 void CBNAME(int a, const wxString& c) { \
349 wxPyBeginBlockThreads(); \
350 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
351 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str())); \
352 wxPyEndBlockThreads(); \
354 PCLASS::CBNAME(a,c); \
356 void base_##CBNAME(int a, const wxString& c) { \
357 PCLASS::CBNAME(a,c); \
363 #define PYCALLBACK_BOOL_(PCLASS, CBNAME) \
367 wxPyBeginBlockThreads(); \
368 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
369 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
370 wxPyEndBlockThreads(); \
372 rval = PCLASS::CBNAME(); \
375 bool base_##CBNAME() { \
376 return PCLASS::CBNAME(); \
381 #define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \
382 void CBNAME(size_t a, int b) { \
384 wxPyBeginBlockThreads(); \
385 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
386 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
387 wxPyEndBlockThreads(); \
389 PCLASS::CBNAME(a,b); \
391 void base_##CBNAME(size_t a, int b) { \
392 PCLASS::CBNAME(a,b); \
398 #define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \
399 void CBNAME(int a, int b, long c) { \
401 wxPyBeginBlockThreads(); \
402 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
403 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
404 wxPyEndBlockThreads(); \
406 PCLASS::CBNAME(a,b,c); \
408 void base_##CBNAME(int a, int b, long c) { \
409 PCLASS::CBNAME(a,b,c); \
415 #define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \
416 void CBNAME(int a, int b, double c) { \
418 wxPyBeginBlockThreads(); \
419 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
420 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \
421 wxPyEndBlockThreads(); \
423 PCLASS::CBNAME(a,b,c); \
425 void base_##CBNAME(int a, int b, double c) { \
426 PCLASS::CBNAME(a,b,c); \
431 #define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \
432 void CBNAME(int a, int b, bool c) { \
434 wxPyBeginBlockThreads(); \
435 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
436 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
437 wxPyEndBlockThreads(); \
439 PCLASS::CBNAME(a,b,c); \
441 void base_##CBNAME(int a, int b, bool c) { \
442 PCLASS::CBNAME(a,b,c); \
450 //---------------------------------------------------------------------------
452 class wxGridCellCoords;
453 class wxGridCellAttr;
457 #define wxGRID_VALUE_STRING "string"
458 #define wxGRID_VALUE_BOOL "bool"
459 #define wxGRID_VALUE_NUMBER "long"
460 #define wxGRID_VALUE_FLOAT "double"
461 #define wxGRID_VALUE_CHOICE "choice"
462 #define wxGRID_VALUE_TEXT "string"
463 #define wxGRID_VALUE_LONG "long"
466 wxGridCellCoords wxGridNoCellCoords;
467 wxRect wxGridNoCellRect;
471 //---------------------------------------------------------------------------
472 // wxGridCellRenderer is an ABC, and several derived classes are available.
473 // Classes implemented in Python should be derived from wxPyGridCellRenderer.
476 class wxGridCellRenderer
479 void SetParameters(const wxString& params);
483 virtual void Draw(wxGrid& grid,
484 wxGridCellAttr& attr,
488 bool isSelected) = 0;
489 virtual wxSize GetBestSize(wxGrid& grid,
490 wxGridCellAttr& attr,
492 int row, int col) = 0;
493 virtual wxGridCellRenderer *Clone() const = 0;
497 // The C++ version of wxPyGridCellRenderer
499 class wxPyGridCellRenderer : public wxGridCellRenderer
502 wxPyGridCellRenderer() : wxGridCellRenderer() {};
504 // Implement Python callback aware virtual methods
505 void Draw(wxGrid& grid, wxGridCellAttr& attr,
506 wxDC& dc, const wxRect& rect,
507 int row, int col, bool isSelected) {
508 wxPyBeginBlockThreads();
509 if (wxPyCBH_findCallback(m_myInst, "Draw")) {
510 wxPyCBH_callCallback(m_myInst,
511 Py_BuildValue("(OOOOiii)",
512 wxPyConstructObject((void*)&grid, "wxGrid", 0),
513 wxPyConstructObject((void*)&attr, "wxGridCellAttr", 0),
514 wxPyConstructObject((void*)&dc, "wxDC", 0),
515 wxPyConstructObject((void*)&rect, "wxRect", 0),
516 row, col, isSelected));
518 wxPyEndBlockThreads();
521 wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
524 wxPyBeginBlockThreads();
525 if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) {
528 ro = wxPyCBH_callCallbackObj(m_myInst,
529 Py_BuildValue("(OOOii)",
530 wxPyConstructObject((void*)&grid, "wxGrid", 0),
531 wxPyConstructObject((void*)&attr, "wxGridCellAttr", 0),
532 wxPyConstructObject((void*)&dc, "wxDC", 0),
535 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p"))
540 wxPyEndBlockThreads();
545 wxGridCellRenderer *Clone() const {
546 wxGridCellRenderer* rval = NULL;
547 wxPyBeginBlockThreads();
548 if (wxPyCBH_findCallback(m_myInst, "Clone")) {
550 wxGridCellRenderer* ptr;
551 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
553 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellRenderer_p"))
558 wxPyEndBlockThreads();
562 DEC_PYCALLBACK__STRING(SetParameters);
567 IMP_PYCALLBACK__STRING( wxPyGridCellRenderer, wxGridCellRenderer, SetParameters);
572 // Let SWIG know about it so it can create the Python version
573 class wxPyGridCellRenderer : public wxGridCellRenderer {
575 wxPyGridCellRenderer();
576 void _setCallbackInfo(PyObject* self, PyObject* _class);
577 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellRenderer)"
579 void base_SetParameters(const wxString& params);
582 //---------------------------------------------------------------------------
583 // Predefined Renderers
585 class wxGridCellStringRenderer : public wxGridCellRenderer
588 wxGridCellStringRenderer();
592 class wxGridCellNumberRenderer : public wxGridCellStringRenderer
595 wxGridCellNumberRenderer();
599 class wxGridCellFloatRenderer : public wxGridCellStringRenderer
602 wxGridCellFloatRenderer(int width = -1, int precision = -1);
604 int GetWidth() const;
605 void SetWidth(int width);
606 int GetPrecision() const;
607 void SetPrecision(int precision);
611 class wxGridCellBoolRenderer : public wxGridCellRenderer
614 wxGridCellBoolRenderer();
618 class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
621 wxGridCellDateTimeRenderer(wxString outformat = "%c",
622 wxString informat = "%c");
626 class wxGridCellEnumRenderer : public wxGridCellStringRenderer
629 wxGridCellEnumRenderer( const wxString& choices = "" );
633 class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
636 wxGridCellAutoWrapStringRenderer();
640 //---------------------------------------------------------------------------
641 // wxGridCellEditor is an ABC, and several derived classes are available.
642 // Classes implemented in Python should be derived from wxPyGridCellEditor.
644 class wxGridCellEditor
648 wxControl* GetControl();
649 void SetControl(wxControl* control);
651 void SetParameters(const wxString& params);
655 virtual void Create(wxWindow* parent,
657 wxEvtHandler* evtHandler) = 0;
658 virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
659 virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
660 virtual void Reset() = 0;
661 virtual wxGridCellEditor *Clone() const = 0;
663 virtual void SetSize(const wxRect& rect);
664 virtual void Show(bool show, wxGridCellAttr *attr = NULL);
665 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
666 virtual bool IsAcceptedKey(wxKeyEvent& event);
667 virtual void StartingKey(wxKeyEvent& event);
668 virtual void StartingClick();
669 virtual void HandleReturn(wxKeyEvent& event);
670 virtual void Destroy();
675 // The C++ version of wxPyGridCellEditor
677 class wxPyGridCellEditor : public wxGridCellEditor
680 wxPyGridCellEditor() : wxGridCellEditor() {}
682 void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
683 wxPyBeginBlockThreads();
684 if (wxPyCBH_findCallback(m_myInst, "Create")) {
685 wxPyCBH_callCallback(m_myInst,
686 Py_BuildValue("(OiO)",
687 wxPyConstructObject((void*)parent, "wxWindow", 0),
689 wxPyConstructObject((void*)evtHandler, "wxEvtHandler", 0)));
691 wxPyEndBlockThreads();
695 void BeginEdit(int row, int col, wxGrid* grid) {
696 wxPyBeginBlockThreads();
697 if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) {
698 wxPyCBH_callCallback(m_myInst,
699 Py_BuildValue("(iiO)", row, col,
700 wxPyConstructObject((void*)grid, "wxGrid", 0)));
702 wxPyEndBlockThreads();
706 bool EndEdit(int row, int col, wxGrid* grid) {
708 wxPyBeginBlockThreads();
709 if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
710 rv = wxPyCBH_callCallback(m_myInst,
711 Py_BuildValue("(iiO)", row, col,
712 wxPyConstructObject((void*)grid, "wxGrid", 0)));
714 wxPyEndBlockThreads();
719 wxGridCellEditor*Clone() const {
720 wxGridCellEditor* rval = NULL;
721 wxPyBeginBlockThreads();
722 if (wxPyCBH_findCallback(m_myInst, "Clone")) {
724 wxGridCellEditor* ptr;
725 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
727 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellEditor_p"))
732 wxPyEndBlockThreads();
737 void Show(bool show, wxGridCellAttr *attr) {
739 wxPyBeginBlockThreads();
740 if ((found = wxPyCBH_findCallback(m_myInst, "Show")))
741 wxPyCBH_callCallback(m_myInst,
742 Py_BuildValue("(iO)", show,
743 wxPyConstructObject((void*)attr, "wxGridCellAttr", 0)));
744 wxPyEndBlockThreads();
746 wxGridCellEditor::Show(show, attr);
748 void base_Show(bool show, wxGridCellAttr *attr) {
749 wxGridCellEditor::Show(show, attr);
753 void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
755 wxPyBeginBlockThreads();
756 if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)")))
757 wxPyCBH_callCallback(m_myInst,
758 Py_BuildValue("(OO)",
759 wxPyConstructObject((void*)&rectCell, "wxRect", 0),
760 wxPyConstructObject((void*)attr, "wxGridCellAttr", 0)));
761 wxPyEndBlockThreads();
763 wxGridCellEditor::PaintBackground(rectCell, attr);
765 void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
766 wxGridCellEditor::PaintBackground(rectCell, attr);
770 DEC_PYCALLBACK___pure(Reset);
771 DEC_PYCALLBACK__constany(SetSize, wxRect);
772 DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent);
773 DEC_PYCALLBACK__any(StartingKey, wxKeyEvent);
774 DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent);
775 DEC_PYCALLBACK__(StartingClick);
776 DEC_PYCALLBACK__(Destroy);
777 DEC_PYCALLBACK__STRING(SetParameters);
783 IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters);
784 IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset);
785 IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect);
786 IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent);
787 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent);
788 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent);
789 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick);
790 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, Destroy);
795 // Let SWIG know about it so it can create the Python version
796 class wxPyGridCellEditor : public wxGridCellEditor {
798 wxPyGridCellEditor();
799 void _setCallbackInfo(PyObject* self, PyObject* _class);
800 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellEditor)"
802 void base_SetSize(const wxRect& rect);
803 void base_Show(bool show, wxGridCellAttr *attr = NULL);
804 void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
805 void base_IsAcceptedKey(wxKeyEvent& event);
806 void base_StartingKey(wxKeyEvent& event);
807 void base_StartingClick();
808 void base_HandleReturn(wxKeyEvent& event);
810 void base_SetParameters(const wxString& params);
813 //---------------------------------------------------------------------------
814 // Predefined Editors
816 class wxGridCellTextEditor : public wxGridCellEditor
819 wxGridCellTextEditor();
823 class wxGridCellNumberEditor : public wxGridCellTextEditor
826 wxGridCellNumberEditor(int min = -1, int max = -1);
830 class wxGridCellFloatEditor : public wxGridCellTextEditor
833 wxGridCellFloatEditor();
837 class wxGridCellBoolEditor : public wxGridCellEditor
840 wxGridCellBoolEditor();
843 class wxGridCellChoiceEditor : public wxGridCellEditor
846 wxGridCellChoiceEditor(int LCOUNT = 0,
847 const wxString* choices = NULL,
848 bool allowOthers = FALSE);
852 class wxGridCellEnumEditor : public wxGridCellChoiceEditor
855 wxGridCellEnumEditor( const wxString& choices = "" );
859 class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
862 wxGridCellAutoWrapStringEditor();
867 //---------------------------------------------------------------------------
883 wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
885 wxGridCellAttr *Clone() const;
886 void MergeWith(wxGridCellAttr *mergefrom);
889 void SetTextColour(const wxColour& colText);
890 void SetBackgroundColour(const wxColour& colBack);
891 void SetFont(const wxFont& font);
892 void SetAlignment(int hAlign, int vAlign);
893 void SetReadOnly(bool isReadOnly = TRUE);
895 void SetRenderer(wxGridCellRenderer *renderer);
896 void SetEditor(wxGridCellEditor* editor);
897 void SetKind(wxAttrKind kind);
899 bool HasTextColour() const;
900 bool HasBackgroundColour() const;
901 bool HasFont() const;
902 bool HasAlignment() const;
903 bool HasRenderer() const;
904 bool HasEditor() const;
905 bool HasReadWriteMode() const;
907 wxColour GetTextColour() const;
908 wxColour GetBackgroundColour() const;
909 wxFont GetFont() const;
910 void GetAlignment(int *OUTPUT, int *OUTPUT) const;
911 wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
912 wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
914 bool IsReadOnly() const;
915 void SetDefAttr(wxGridCellAttr* defAttr);
918 //---------------------------------------------------------------------------
920 class wxGridCellAttrProvider
923 wxGridCellAttrProvider();
924 // ???? virtual ~wxGridCellAttrProvider();
926 wxGridCellAttr *GetAttr(int row, int col,
927 wxGridCellAttr::wxAttrKind kind) const;
928 void SetAttr(wxGridCellAttr *attr, int row, int col);
929 void SetRowAttr(wxGridCellAttr *attr, int row);
930 void SetColAttr(wxGridCellAttr *attr, int col);
932 void UpdateAttrRows( size_t pos, int numRows );
933 void UpdateAttrCols( size_t pos, int numCols );
938 // A Python-aware version
940 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
943 wxPyGridCellAttrProvider() : wxGridCellAttrProvider() {};
945 PYCALLBACK_GCA_INTINTKIND(wxGridCellAttrProvider, GetAttr);
946 PYCALLBACK__GCAINTINT(wxGridCellAttrProvider, SetAttr);
947 PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetRowAttr);
948 PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetColAttr);
955 // The python-aware version get's SWIGified
956 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
959 wxPyGridCellAttrProvider();
960 void _setCallbackInfo(PyObject* self, PyObject* _class);
961 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellAttrProvider)"
963 wxGridCellAttr *base_GetAttr(int row, int col,
964 wxGridCellAttr::wxAttrKind kind);
965 void base_SetAttr(wxGridCellAttr *attr, int row, int col);
966 void base_SetRowAttr(wxGridCellAttr *attr, int row);
967 void base_SetColAttr(wxGridCellAttr *attr, int col);
971 //---------------------------------------------------------------------------
972 // Grid Table Base class and Python aware version
976 class wxGridTableBase : public wxObject
979 // wxGridTableBase(); This is an ABC
980 //~wxGridTableBase();
982 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
983 wxGridCellAttrProvider *GetAttrProvider() const;
984 void SetView( wxGrid *grid );
985 wxGrid * GetView() const;
989 virtual int GetNumberRows() = 0;
990 virtual int GetNumberCols() = 0;
991 virtual bool IsEmptyCell( int row, int col ) = 0;
992 virtual wxString GetValue( int row, int col ) = 0;
993 virtual void SetValue( int row, int col, const wxString& value ) = 0;
995 // virtuals overridable in wxPyGridTableBase
996 virtual wxString GetTypeName( int row, int col );
997 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
998 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
999 virtual long GetValueAsLong( int row, int col );
1000 virtual double GetValueAsDouble( int row, int col );
1001 virtual bool GetValueAsBool( int row, int col );
1002 virtual void SetValueAsLong( int row, int col, long value );
1003 virtual void SetValueAsDouble( int row, int col, double value );
1004 virtual void SetValueAsBool( int row, int col, bool value );
1006 //virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
1007 //virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
1010 virtual void Clear();
1011 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
1012 virtual bool AppendRows( size_t numRows = 1 );
1013 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
1014 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
1015 virtual bool AppendCols( size_t numCols = 1 );
1016 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
1018 virtual wxString GetRowLabelValue( int row );
1019 virtual wxString GetColLabelValue( int col );
1020 virtual void SetRowLabelValue( int row, const wxString& value );
1021 virtual void SetColLabelValue( int col, const wxString& value );
1023 virtual bool CanHaveAttributes();
1025 virtual wxGridCellAttr *GetAttr( int row, int col,
1026 wxGridCellAttr::wxAttrKind kind);
1027 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
1028 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
1029 virtual void SetColAttr(wxGridCellAttr *attr, int col);
1035 // Python-aware version
1037 class wxPyGridTableBase : public wxGridTableBase
1040 wxPyGridTableBase() : wxGridTableBase() {}
1042 PYCALLBACK_INT__pure(GetNumberRows);
1043 PYCALLBACK_INT__pure(GetNumberCols);
1044 PYCALLBACK_BOOL_INTINT_pure(IsEmptyCell);
1045 PYCALLBACK_STRING_INTINT(wxGridTableBase, GetTypeName);
1046 PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanGetValueAs);
1047 PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanSetValueAs);
1048 PYCALLBACK__(wxGridTableBase, Clear);
1049 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertRows);
1050 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteRows);
1051 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertCols);
1052 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteCols);
1053 PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendRows);
1054 PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendCols);
1055 PYCALLBACK_STRING_INT(wxGridTableBase, GetRowLabelValue);
1056 PYCALLBACK_STRING_INT(wxGridTableBase, GetColLabelValue);
1057 PYCALLBACK__INTSTRING(wxGridTableBase, SetRowLabelValue);
1058 PYCALLBACK__INTSTRING(wxGridTableBase, SetColLabelValue);
1059 PYCALLBACK_BOOL_(wxGridTableBase, CanHaveAttributes);
1060 PYCALLBACK_GCA_INTINTKIND(wxGridTableBase, GetAttr);
1061 PYCALLBACK__GCAINTINT(wxGridTableBase, SetAttr);
1062 PYCALLBACK__GCAINT(wxGridTableBase, SetRowAttr);
1063 PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
1066 wxString GetValue(int row, int col) {
1067 wxPyBeginBlockThreads();
1069 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1071 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
1073 PyObject* str = PyObject_Str(ro);
1074 rval = PyString_AsString(str);
1079 wxPyEndBlockThreads();
1083 void SetValue(int row, int col, const wxString& val) {
1084 wxPyBeginBlockThreads();
1085 if (wxPyCBH_findCallback(m_myInst, "SetValue"))
1086 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",row,col,val.c_str()));
1087 wxPyEndBlockThreads();
1091 // Map the Get/Set methods for the standard non-string types to
1092 // the GetValue and SetValue python methods.
1093 long GetValueAsLong( int row, int col ) {
1095 wxPyBeginBlockThreads();
1096 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1099 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
1100 if (ro && PyNumber_Check(ro)) {
1101 num = PyNumber_Int(ro);
1103 rval = PyInt_AsLong(num);
1109 wxPyEndBlockThreads();
1113 double GetValueAsDouble( int row, int col ) {
1115 wxPyBeginBlockThreads();
1116 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1119 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
1120 if (ro && PyNumber_Check(ro)) {
1121 num = PyNumber_Float(ro);
1123 rval = PyFloat_AsDouble(num);
1129 wxPyEndBlockThreads();
1133 bool GetValueAsBool( int row, int col ) {
1134 return (bool)GetValueAsLong(row, col);
1137 void SetValueAsLong( int row, int col, long value ) {
1138 wxPyBeginBlockThreads();
1139 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1140 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value));
1142 wxPyEndBlockThreads();
1145 void SetValueAsDouble( int row, int col, double value ) {
1146 wxPyBeginBlockThreads();
1147 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1148 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value));
1150 wxPyEndBlockThreads();
1153 void SetValueAsBool( int row, int col, bool value ) {
1154 SetValueAsLong( row, col, (long)value );
1163 // The python-aware version get's SWIGified
1164 class wxPyGridTableBase : public wxGridTableBase
1167 wxPyGridTableBase();
1168 void _setCallbackInfo(PyObject* self, PyObject* _class);
1169 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridTableBase)"
1171 %addmethods { void Destroy() { delete self; } }
1173 wxString base_GetTypeName( int row, int col );
1174 bool base_CanGetValueAs( int row, int col, const wxString& typeName );
1175 bool base_CanSetValueAs( int row, int col, const wxString& typeName );
1177 bool base_InsertRows( size_t pos = 0, size_t numRows = 1 );
1178 bool base_AppendRows( size_t numRows = 1 );
1179 bool base_DeleteRows( size_t pos = 0, size_t numRows = 1 );
1180 bool base_InsertCols( size_t pos = 0, size_t numCols = 1 );
1181 bool base_AppendCols( size_t numCols = 1 );
1182 bool base_DeleteCols( size_t pos = 0, size_t numCols = 1 );
1183 wxString base_GetRowLabelValue( int row );
1184 wxString base_GetColLabelValue( int col );
1185 void base_SetRowLabelValue( int row, const wxString& value );
1186 void base_SetColLabelValue( int col, const wxString& value );
1187 bool base_CanHaveAttributes();
1188 wxGridCellAttr *base_GetAttr( int row, int col,
1189 wxGridCellAttr::wxAttrKind kind );
1190 void base_SetAttr(wxGridCellAttr* attr, int row, int col);
1191 void base_SetRowAttr(wxGridCellAttr *attr, int row);
1192 void base_SetColAttr(wxGridCellAttr *attr, int col);
1196 //---------------------------------------------------------------------------
1197 // Predefined Tables
1199 class wxGridStringTable : public wxGridTableBase
1202 wxGridStringTable( int numRows=0, int numCols=0 );
1205 //---------------------------------------------------------------------------
1206 // The Table can pass messages to the grid to tell it to update itself if
1207 // something has changed.
1209 enum wxGridTableRequest
1211 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
1212 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
1213 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
1214 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
1215 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
1216 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
1217 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
1218 wxGRIDTABLE_NOTIFY_COLS_DELETED
1222 class wxGridTableMessage
1225 wxGridTableMessage( wxGridTableBase *table, int id,
1228 ~wxGridTableMessage();
1230 void SetTableObject( wxGridTableBase *table );
1231 wxGridTableBase * GetTableObject() const;
1232 void SetId( int id );
1234 void SetCommandInt( int comInt1 );
1235 int GetCommandInt();
1236 void SetCommandInt2( int comInt2 );
1237 int GetCommandInt2();
1241 //---------------------------------------------------------------------------
1243 class wxGridCellCoords
1246 wxGridCellCoords( int r=-1, int c=-1 );
1247 ~wxGridCellCoords();
1249 int GetRow() const { return m_row; }
1250 void SetRow( int n ) { m_row = n; }
1251 int GetCol() const { return m_col; }
1252 void SetCol( int n ) { m_col = n; }
1253 void Set( int row, int col ) { m_row = row; m_col = col; }
1256 PyObject* asTuple() {
1257 PyObject* tup = PyTuple_New(2);
1258 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
1259 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
1263 int __cmp__( const wxGridCellCoords& other ) {
1264 return *self != other;
1267 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
1268 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
1271 // Typemap to allow conversion of sequence objects to wxGridCellCoords...
1272 %typemap(python,in) wxGridCellCoords& (wxGridCellCoords temp) {
1274 if (! wxGridCellCoords_helper($source, &$target))
1278 // ...and here is the associated helper.
1280 bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
1282 // If source is an object instance then it may already be the right type
1283 if (PyInstance_Check(source)) {
1284 wxGridCellCoords* ptr;
1285 if (SWIG_GetPtrObj(source, (void **)&ptr, "_wxGridCellCoords_p"))
1290 // otherwise a 2-tuple of integers is expected
1291 else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
1292 PyObject* o1 = PySequence_GetItem(source, 0);
1293 PyObject* o2 = PySequence_GetItem(source, 1);
1294 **obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2));
1299 PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object.");
1304 //---------------------------------------------------------------------------
1305 //---------------------------------------------------------------------------
1309 // Fool SWIG into treating this enum as an int
1310 typedef int WXGRIDSELECTIONMODES;
1312 // but let the C++ code know what it really is.
1314 typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES;
1319 class wxGrid : public wxScrolledWindow
1322 wxGrid( wxWindow *parent,
1324 const wxPoint& pos = wxDefaultPosition,
1325 const wxSize& size = wxDefaultSize,
1326 long style = wxWANTS_CHARS,
1327 const char* name = wxPanelNameStr );
1329 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1331 enum wxGridSelectionModes {wxGridSelectCells,
1333 wxGridSelectColumns};
1335 bool CreateGrid( int numRows, int numCols,
1336 WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells );
1337 void SetSelectionMode(WXGRIDSELECTIONMODES selmode);
1340 // ------ grid dimensions
1342 int GetNumberRows();
1343 int GetNumberCols();
1346 bool ProcessTableMessage( wxGridTableMessage& );
1349 wxGridTableBase * GetTable() const;
1350 bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE,
1351 WXGRIDSELECTIONMODES selmode =
1352 wxGrid::wxGridSelectCells );
1355 bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
1356 bool AppendRows( int numRows = 1, bool updateLabels=TRUE );
1357 bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
1358 bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
1359 bool AppendCols( int numCols = 1, bool updateLabels=TRUE );
1360 bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
1363 // this function is called when the current cell highlight must be redrawn
1364 // and may be overridden by the user
1365 virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
1368 // ------ Cell text drawing functions
1370 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
1371 int horizontalAlignment = wxLEFT,
1372 int verticalAlignment = wxTOP );
1374 // // Split a string containing newline chararcters into an array of
1375 // // strings and return the number of lines
1377 // void StringToLines( const wxString& value, wxArrayString& lines );
1379 void GetTextBoxSize( wxDC& dc,
1380 wxArrayString& lines,
1381 long *OUTPUT, long *OUTPUT );
1385 // Code that does a lot of grid modification can be enclosed
1386 // between BeginBatch() and EndBatch() calls to avoid screen
1391 int GetBatchCount();
1392 void ForceRefresh();
1395 // ------ edit control functions
1397 bool IsEditable() { return m_editable; }
1398 void EnableEditing( bool edit );
1400 void EnableCellEditControl( bool enable = TRUE );
1401 void DisableCellEditControl();
1402 bool CanEnableCellControl() const;
1403 bool IsCellEditControlEnabled() const;
1404 bool IsCellEditControlShown() const;
1406 bool IsCurrentCellReadOnly() const;
1408 void ShowCellEditControl();
1409 void HideCellEditControl();
1410 void SaveEditControlValue();
1413 // ------ grid location functions
1414 // Note that all of these functions work with the logical coordinates of
1415 // grid cells and labels so you will need to convert from device
1416 // coordinates for mouse events etc.
1419 //void XYToCell( int x, int y, wxGridCellCoords& );
1421 %new wxGridCellCoords* XYToCell(int x, int y) {
1422 wxGridCellCoords rv;
1423 self->XYToCell(x, y, rv);
1424 return new wxGridCellCoords(rv);
1428 int YToRow( int y );
1429 int XToCol( int x );
1431 int YToEdgeOfRow( int y );
1432 int XToEdgeOfCol( int x );
1434 wxRect CellToRect( int row, int col );
1435 // TODO: ??? wxRect CellToRect( const wxGridCellCoords& coords );
1438 int GetGridCursorRow();
1439 int GetGridCursorCol();
1441 // check to see if a cell is either wholly visible (the default arg) or
1442 // at least partially visible in the grid window
1444 bool IsVisible( int row, int col, bool wholeCellVisible = TRUE );
1445 // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE );
1446 void MakeCellVisible( int row, int col );
1447 // TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords );
1450 // ------ grid cursor movement functions
1452 void SetGridCursor( int row, int col );
1453 bool MoveCursorUp( bool expandSelection );
1454 bool MoveCursorDown( bool expandSelection );
1455 bool MoveCursorLeft( bool expandSelection );
1456 bool MoveCursorRight( bool expandSelection );
1457 bool MovePageDown();
1459 bool MoveCursorUpBlock( bool expandSelection );
1460 bool MoveCursorDownBlock( bool expandSelection );
1461 bool MoveCursorLeftBlock( bool expandSelection );
1462 bool MoveCursorRightBlock( bool expandSelection );
1465 // ------ label and gridline formatting
1467 int GetDefaultRowLabelSize();
1468 int GetRowLabelSize();
1469 int GetDefaultColLabelSize();
1470 int GetColLabelSize();
1471 wxColour GetLabelBackgroundColour();
1472 wxColour GetLabelTextColour();
1473 wxFont GetLabelFont();
1474 void GetRowLabelAlignment( int *OUTPUT, int *OUTPUT );
1475 void GetColLabelAlignment( int *OUTPUT, int *OUTPUT );
1476 wxString GetRowLabelValue( int row );
1477 wxString GetColLabelValue( int col );
1478 wxColour GetGridLineColour();
1479 wxColour GetCellHighlightColour();
1480 int GetCellHighlightPenWidth();
1481 int GetCellHighlightROPenWidth();
1483 void SetRowLabelSize( int width );
1484 void SetColLabelSize( int height );
1485 void SetLabelBackgroundColour( const wxColour& );
1486 void SetLabelTextColour( const wxColour& );
1487 void SetLabelFont( const wxFont& );
1488 void SetRowLabelAlignment( int horiz, int vert );
1489 void SetColLabelAlignment( int horiz, int vert );
1490 void SetRowLabelValue( int row, const wxString& );
1491 void SetColLabelValue( int col, const wxString& );
1492 void SetGridLineColour( const wxColour& );
1493 void SetCellHighlightColour( const wxColour& );
1494 void SetCellHighlightPenWidth(int width);
1495 void SetCellHighlightROPenWidth(int width);
1497 void EnableDragRowSize( bool enable = TRUE );
1498 void DisableDragRowSize();
1499 bool CanDragRowSize();
1500 void EnableDragColSize( bool enable = TRUE );
1501 void DisableDragColSize();
1502 bool CanDragColSize();
1503 void EnableDragGridSize(bool enable = TRUE);
1504 void DisableDragGridSize();
1505 bool CanDragGridSize();
1507 // this sets the specified attribute for all cells in this row/col
1508 void SetRowAttr(int row, wxGridCellAttr *attr);
1509 void SetColAttr(int col, wxGridCellAttr *attr);
1511 // shortcuts for setting the column parameters
1513 // set the format for the data in the column: default is string
1514 void SetColFormatBool(int col);
1515 void SetColFormatNumber(int col);
1516 void SetColFormatFloat(int col, int width = -1, int precision = -1);
1517 void SetColFormatCustom(int col, const wxString& typeName);
1519 void EnableGridLines( bool enable = TRUE );
1520 bool GridLinesEnabled();
1522 // ------ row and col formatting
1524 int GetDefaultRowSize();
1525 int GetRowSize( int row );
1526 int GetDefaultColSize();
1527 int GetColSize( int col );
1528 wxColour GetDefaultCellBackgroundColour();
1529 wxColour GetCellBackgroundColour( int row, int col );
1530 wxColour GetDefaultCellTextColour();
1531 wxColour GetCellTextColour( int row, int col );
1532 wxFont GetDefaultCellFont();
1533 wxFont GetCellFont( int row, int col );
1534 void GetDefaultCellAlignment( int *horiz, int *vert );
1535 void GetCellAlignment( int row, int col, int *horiz, int *vert );
1537 void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE );
1538 void SetRowSize( int row, int height );
1539 void SetDefaultColSize( int width, bool resizeExistingCols = FALSE );
1541 void SetColSize( int col, int width );
1543 // automatically size the column or row to fit to its contents, if
1544 // setAsMin is TRUE, this optimal width will also be set as minimal width
1546 void AutoSizeColumn( int col, bool setAsMin = TRUE );
1547 void AutoSizeRow( int row, bool setAsMin = TRUE );
1550 // auto size all columns (very ineffective for big grids!)
1551 void AutoSizeColumns( bool setAsMin = TRUE );
1552 void AutoSizeRows( bool setAsMin = TRUE );
1554 // auto size the grid, that is make the columns/rows of the "right" size
1555 // and also set the grid size to just fit its contents
1558 // column won't be resized to be lesser width - this must be called during
1559 // the grid creation because it won't resize the column if it's already
1560 // narrower than the minimal width
1561 void SetColMinimalWidth( int col, int width );
1562 void SetRowMinimalHeight( int row, int width );
1564 void SetDefaultCellBackgroundColour( const wxColour& );
1565 void SetCellBackgroundColour( int row, int col, const wxColour& );
1566 void SetDefaultCellTextColour( const wxColour& );
1568 void SetCellTextColour( int row, int col, const wxColour& );
1569 void SetDefaultCellFont( const wxFont& );
1570 void SetCellFont( int row, int col, const wxFont& );
1571 void SetDefaultCellAlignment( int horiz, int vert );
1572 void SetCellAlignment( int row, int col, int horiz, int vert );
1574 // takes ownership of the pointer
1575 void SetDefaultRenderer(wxGridCellRenderer *renderer);
1576 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
1577 wxGridCellRenderer *GetDefaultRenderer() const;
1578 wxGridCellRenderer* GetCellRenderer(int row, int col);
1580 // takes ownership of the pointer
1581 void SetDefaultEditor(wxGridCellEditor *editor);
1582 void SetCellEditor(int row, int col, wxGridCellEditor *editor);
1583 wxGridCellEditor *GetDefaultEditor() const;
1584 wxGridCellEditor* GetCellEditor(int row, int col);
1588 // ------ cell value accessors
1590 wxString GetCellValue( int row, int col );
1591 // TODO: ??? wxString GetCellValue( const wxGridCellCoords& coords )
1593 void SetCellValue( int row, int col, const wxString& s );
1594 // TODO: ??? void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
1596 // returns TRUE if the cell can't be edited
1597 bool IsReadOnly(int row, int col) const;
1599 // make the cell editable/readonly
1600 void SetReadOnly(int row, int col, bool isReadOnly = TRUE);
1602 // ------ selections of blocks of cells
1604 void SelectRow( int row, bool addToSelected = FALSE );
1605 void SelectCol( int col, bool addToSelected = FALSE );
1607 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
1608 bool addToSelected = FALSE );
1609 // TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft,
1610 // TODO: ??? const wxGridCellCoords& bottomRight )
1614 void ClearSelection();
1615 bool IsInSelection( int row, int col );
1616 // TODO: ??? bool IsInSelection( const wxGridCellCoords& coords )
1619 // This function returns the rectangle that encloses the block of cells
1620 // limited by TopLeft and BottomRight cell in device coords and clipped
1621 // to the client size of the grid window.
1623 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
1624 const wxGridCellCoords & bottomRight );
1627 // Access or update the selection fore/back colours
1628 wxColour GetSelectionBackground() const;
1629 wxColour GetSelectionForeground() const;
1631 void SetSelectionBackground(const wxColour& c);
1632 void SetSelectionForeground(const wxColour& c);
1635 // Methods for a registry for mapping data types to Renderers/Editors
1636 void RegisterDataType(const wxString& typeName,
1637 wxGridCellRenderer* renderer,
1638 wxGridCellEditor* editor);
1639 wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
1640 // TODO: ??? wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
1641 wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
1642 wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
1643 wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
1645 // grid may occupy more space than needed for its rows/columns, this
1646 // function allows to set how big this extra space is
1647 void SetMargins(int extraWidth, int extraHeight);
1650 // Accessors for component windows
1651 wxWindow* GetGridWindow();
1652 wxWindow* GetGridRowLabelWindow();
1653 wxWindow* GetGridColLabelWindow();
1654 wxWindow* GetGridCornerLabelWindow();
1660 //---------------------------------------------------------------------------
1661 //---------------------------------------------------------------------------
1662 // Grid events and stuff
1666 class wxGridEvent : public wxNotifyEvent
1669 wxGridEvent(int id, wxEventType type, wxGrid* obj,
1670 int row=-1, int col=-1, int x=-1, int y=-1, bool sel = TRUE,
1671 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1673 virtual int GetRow();
1674 virtual int GetCol();
1675 wxPoint GetPosition();
1685 class wxGridSizeEvent : public wxNotifyEvent
1688 wxGridSizeEvent(int id, wxEventType type, wxGrid* obj,
1689 int rowOrCol=-1, int x=-1, int y=-1,
1690 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1693 wxPoint GetPosition();
1702 class wxGridRangeSelectEvent : public wxNotifyEvent
1705 wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj,
1706 const wxGridCellCoords& topLeft,
1707 const wxGridCellCoords& bottomRight,
1709 bool control=FALSE, bool shift=FALSE,
1710 bool alt=FALSE, bool meta=FALSE);
1712 wxGridCellCoords GetTopLeftCoords();
1713 wxGridCellCoords GetBottomRightCoords();
1726 class wxGridEditorCreatedEvent : public wxCommandEvent {
1728 wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
1729 int row, int col, wxControl* ctrl);
1733 wxControl* GetControl();
1734 void SetRow(int row);
1735 void SetCol(int col);
1736 void SetControl(wxControl* ctrl);
1742 wxEVT_GRID_CELL_LEFT_CLICK,
1743 wxEVT_GRID_CELL_RIGHT_CLICK,
1744 wxEVT_GRID_CELL_LEFT_DCLICK,
1745 wxEVT_GRID_CELL_RIGHT_DCLICK,
1746 wxEVT_GRID_LABEL_LEFT_CLICK,
1747 wxEVT_GRID_LABEL_RIGHT_CLICK,
1748 wxEVT_GRID_LABEL_LEFT_DCLICK,
1749 wxEVT_GRID_LABEL_RIGHT_DCLICK,
1750 wxEVT_GRID_ROW_SIZE,
1751 wxEVT_GRID_COL_SIZE,
1752 wxEVT_GRID_RANGE_SELECT,
1753 wxEVT_GRID_CELL_CHANGE,
1754 wxEVT_GRID_SELECT_CELL,
1755 wxEVT_GRID_EDITOR_SHOWN,
1756 wxEVT_GRID_EDITOR_HIDDEN,
1757 wxEVT_GRID_EDITOR_CREATED,
1762 %pragma(python) code = "
1763 def EVT_GRID_CELL_LEFT_CLICK(win, fn):
1764 win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_CLICK, fn)
1766 def EVT_GRID_CELL_RIGHT_CLICK(win, fn):
1767 win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_CLICK, fn)
1769 def EVT_GRID_CELL_LEFT_DCLICK(win, fn):
1770 win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_DCLICK, fn)
1772 def EVT_GRID_CELL_RIGHT_DCLICK(win, fn):
1773 win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_DCLICK, fn)
1775 def EVT_GRID_LABEL_LEFT_CLICK(win, fn):
1776 win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_CLICK, fn)
1778 def EVT_GRID_LABEL_RIGHT_CLICK(win, fn):
1779 win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_CLICK, fn)
1781 def EVT_GRID_LABEL_LEFT_DCLICK(win, fn):
1782 win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_DCLICK, fn)
1784 def EVT_GRID_LABEL_RIGHT_DCLICK(win, fn):
1785 win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_DCLICK, fn)
1787 def EVT_GRID_ROW_SIZE(win, fn):
1788 win.Connect(-1, -1, wxEVT_GRID_ROW_SIZE, fn)
1790 def EVT_GRID_COL_SIZE(win, fn):
1791 win.Connect(-1, -1, wxEVT_GRID_COL_SIZE, fn)
1793 def EVT_GRID_RANGE_SELECT(win, fn):
1794 win.Connect(-1, -1, wxEVT_GRID_RANGE_SELECT, fn)
1796 def EVT_GRID_CELL_CHANGE(win, fn):
1797 win.Connect(-1, -1, wxEVT_GRID_CELL_CHANGE, fn)
1799 def EVT_GRID_SELECT_CELL(win, fn):
1800 win.Connect(-1, -1, wxEVT_GRID_SELECT_CELL, fn)
1802 def EVT_GRID_EDITOR_SHOWN(win, fn):
1803 win.Connect(-1, -1, wxEVT_GRID_EDITOR_SHOWN, fn)
1805 def EVT_GRID_EDITOR_HIDDEN(win, fn):
1806 win.Connect(-1, -1, wxEVT_GRID_EDITOR_HIDDEN, fn)
1808 def EVT_GRID_EDITOR_CREATED(win, fn):
1809 win.Connect(-1, -1, wxEVT_GRID_EDITOR_CREATED, fn)
1813 //---------------------------------------------------------------------------
1816 wxClassInfo::CleanUpClasses();
1817 wxClassInfo::InitializeClasses();
1820 //---------------------------------------------------------------------------
1822 %pragma(python) include="_gridextras.py";
1824 //---------------------------------------------------------------------------