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 /////////////////////////////////////////////////////////////////////////////
14 "Classes for implementing a spreadsheet-like control."
17 %module(package="wx", docstring=DOCSTRING) grid
21 #include "wx/wxPython/wxPython.h"
22 #include "wx/wxPython/pyclasses.h"
23 #include "wx/wxPython/printfw.h"
26 #include <wx/generic/gridctrl.h>
31 //---------------------------------------------------------------------------
34 %pythoncode { wx = _core }
35 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
38 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
39 MAKE_CONST_WXSTRING_NOSWIG(GridNameStr);
40 MAKE_CONST_WXSTRING_NOSWIG(DefaultDateTimeFormat);
42 //---------------------------------------------------------------------------
43 // OOR related typemaps and helper functions
45 %typemap(out) wxGridCellRenderer* { $result = wxPyMake_wxGridCellRenderer($1, (bool)$owner); }
46 %typemap(out) wxGridCellEditor* { $result = wxPyMake_wxGridCellEditor($1, (bool)$owner); }
47 %typemap(out) wxGridCellAttr* { $result = wxPyMake_wxGridCellAttr($1, (bool)$owner); }
48 %typemap(out) wxGridCellAttrProvider* { $result = wxPyMake_wxGridCellAttrProvider($1, (bool)$owner); }
49 %typemap(out) wxGridTableBase* { $result = wxPyMake_wxGridTableBase($1, (bool)$owner); }
54 #define wxPyMake_TEMPLATE(TYPE) \
55 PyObject* wxPyMake_##TYPE(TYPE* source, bool setThisOwn) { \
56 PyObject* target = NULL; \
58 /* Check if there is already a pointer to a Python object in the \
59 OOR data that we can use. */ \
60 wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \
62 target = data->m_obj; \
66 /* Otherwise make a new wrapper for it the old fashioned way and \
67 give it the OOR treatment */ \
69 target = wxPyConstructObject(source, wxT(#TYPE), setThisOwn); \
71 source->SetClientObject(new wxPyOORClientData(target)); \
73 } else { /* source was NULL so return None. */ \
74 Py_INCREF(Py_None); target = Py_None; \
80 wxPyMake_TEMPLATE(wxGridCellRenderer)
81 wxPyMake_TEMPLATE(wxGridCellEditor)
82 wxPyMake_TEMPLATE(wxGridCellAttr)
83 wxPyMake_TEMPLATE(wxGridCellAttrProvider)
84 wxPyMake_TEMPLATE(wxGridTableBase)
88 //---------------------------------------------------------------------------
89 // Macros, similar to what's in helpers.h, to aid in the creation of
90 // virtual methods that are able to make callbacks to Python. Many of these
91 // are specific to wxGrid and so are kept here to reduce the mess in helpers.h
96 #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME) \
97 wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \
98 wxGridCellAttr* rval = NULL; \
100 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
101 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
103 wxGridCellAttr* ptr; \
104 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \
106 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellAttr"))) \
111 wxPyEndBlockThreads(blocked); \
113 rval = PCLASS::CBNAME(a, b, c); \
118 #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME) \
119 void CBNAME(wxGridCellAttr *attr, int a, int b) { \
120 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
122 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
123 PyObject* obj = wxPyMake_wxGridCellAttr(attr,false); \
124 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b)); \
127 wxPyEndBlockThreads(blocked); \
129 PCLASS::CBNAME(attr, a, b); \
134 #define PYCALLBACK__GCAINT(PCLASS, CBNAME) \
135 void CBNAME(wxGridCellAttr *attr, int val) { \
136 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
138 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
139 PyObject* obj = wxPyMake_wxGridCellAttr(attr,false); \
140 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \
143 wxPyEndBlockThreads(blocked); \
145 PCLASS::CBNAME(attr, val); \
150 #define PYCALLBACK_INT__pure(CBNAME) \
152 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
154 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
155 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
156 wxPyEndBlockThreads(blocked); \
162 #define PYCALLBACK_BOOL_INTINT_pure(CBNAME) \
163 bool CBNAME(int a, int b) { \
164 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
166 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
167 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
168 wxPyEndBlockThreads(blocked); \
173 #define PYCALLBACK_STRING_INTINT_pure(CBNAME) \
174 wxString CBNAME(int a, int b) { \
175 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
177 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
179 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
181 rval = Py2wxString(ro); \
185 wxPyEndBlockThreads(blocked); \
190 #define PYCALLBACK__INTINTSTRING_pure(CBNAME) \
191 void CBNAME(int a, int b, const wxString& c) { \
192 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
193 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
194 PyObject* s = wx2PyString(c); \
195 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
198 wxPyEndBlockThreads(blocked); \
202 #define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \
203 wxString CBNAME(int a, int b) { \
205 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
207 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
209 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
211 rval = Py2wxString(ro); \
215 wxPyEndBlockThreads(blocked); \
217 rval = PCLASS::CBNAME(a, b); \
222 #define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \
223 bool CBNAME(int a, int b, const wxString& c) { \
226 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
227 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
228 PyObject* s = wx2PyString(c); \
229 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
232 wxPyEndBlockThreads(blocked); \
234 rval = PCLASS::CBNAME(a,b,c); \
241 #define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME) \
242 long CBNAME(int a, int b) { \
245 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
246 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
247 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
248 wxPyEndBlockThreads(blocked); \
250 rval = PCLASS::CBNAME(a,b); \
255 #define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \
256 bool CBNAME(int a, int b) { \
259 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
260 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
261 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
262 wxPyEndBlockThreads(blocked); \
264 rval = PCLASS::CBNAME(a,b); \
270 #define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME) \
271 double CBNAME(int a, int b) { \
273 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
275 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
277 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \
279 PyObject* str = PyObject_Str(ro); \
280 rval = PyFloat_AsDouble(str); \
281 Py_DECREF(ro); Py_DECREF(str); \
284 wxPyEndBlockThreads(blocked); \
286 rval = PCLASS::CBNAME(a, b); \
292 #define PYCALLBACK__(PCLASS, CBNAME) \
295 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
296 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
297 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
298 wxPyEndBlockThreads(blocked); \
305 #define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME) \
306 bool CBNAME(size_t a, size_t b) { \
309 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
310 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
311 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
312 wxPyEndBlockThreads(blocked); \
314 rval = PCLASS::CBNAME(a,b); \
320 #define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME) \
321 bool CBNAME(size_t a) { \
324 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
325 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
326 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
327 wxPyEndBlockThreads(blocked); \
329 rval = PCLASS::CBNAME(a); \
334 #define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \
335 wxString CBNAME(int a) { \
337 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
339 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
341 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
343 rval = Py2wxString(ro); \
347 wxPyEndBlockThreads(blocked); \
349 rval = PCLASS::CBNAME(a); \
354 #define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \
355 void CBNAME(int a, const wxString& c) { \
357 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
358 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
359 PyObject* s = wx2PyString(c); \
360 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)",a,s)); \
363 wxPyEndBlockThreads(blocked); \
365 PCLASS::CBNAME(a,c); \
371 #define PYCALLBACK_BOOL_(PCLASS, CBNAME) \
375 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
376 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
377 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
378 wxPyEndBlockThreads(blocked); \
380 rval = PCLASS::CBNAME(); \
386 #define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \
387 void CBNAME(size_t a, int b) { \
389 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
390 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
391 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \
392 wxPyEndBlockThreads(blocked); \
394 PCLASS::CBNAME(a,b); \
400 #define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \
401 void CBNAME(int a, int b, long c) { \
403 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
404 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
405 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
406 wxPyEndBlockThreads(blocked); \
408 PCLASS::CBNAME(a,b,c); \
414 #define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \
415 void CBNAME(int a, int b, double c) { \
417 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
418 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
419 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \
420 wxPyEndBlockThreads(blocked); \
422 PCLASS::CBNAME(a,b,c); \
427 #define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \
428 void CBNAME(int a, int b, bool c) { \
430 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
431 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
432 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \
433 wxPyEndBlockThreads(blocked); \
435 PCLASS::CBNAME(a,b,c); \
442 //---------------------------------------------------------------------------
444 class wxGridCellCoords;
445 class wxGridCellAttr;
447 #define wxGRID_VALUE_STRING "string"
448 #define wxGRID_VALUE_BOOL "bool"
449 #define wxGRID_VALUE_NUMBER "long"
450 #define wxGRID_VALUE_FLOAT "double"
451 #define wxGRID_VALUE_CHOICE "choice"
452 #define wxGRID_VALUE_TEXT "string"
453 #define wxGRID_VALUE_LONG "long"
454 #define wxGRID_VALUE_CHOICEINT "choiceint"
455 #define wxGRID_VALUE_DATETIME "datetime"
459 const wxGridCellCoords wxGridNoCellCoords;
460 const wxRect wxGridNoCellRect;
465 #define wxGRID_DEFAULT_NUMBER_ROWS WXGRID_DEFAULT_NUMBER_ROWS
466 #define wxGRID_DEFAULT_NUMBER_COLS WXGRID_DEFAULT_NUMBER_COLS
467 #define wxGRID_DEFAULT_ROW_HEIGHT WXGRID_DEFAULT_ROW_HEIGHT
468 #define wxGRID_DEFAULT_COL_WIDTH WXGRID_DEFAULT_COL_WIDTH
469 #define wxGRID_DEFAULT_COL_LABEL_HEIGHT WXGRID_DEFAULT_COL_LABEL_HEIGHT
470 #define wxGRID_DEFAULT_ROW_LABEL_WIDTH WXGRID_DEFAULT_ROW_LABEL_WIDTH
471 #define wxGRID_LABEL_EDGE_ZONE WXGRID_LABEL_EDGE_ZONE
472 #define wxGRID_MIN_ROW_HEIGHT WXGRID_MIN_ROW_HEIGHT
473 #define wxGRID_MIN_COL_WIDTH WXGRID_MIN_COL_WIDTH
474 #define wxGRID_DEFAULT_SCROLLBAR_WIDTH WXGRID_DEFAULT_SCROLLBAR_WIDTH
478 wxGRID_DEFAULT_NUMBER_ROWS,
479 wxGRID_DEFAULT_NUMBER_COLS,
480 wxGRID_DEFAULT_ROW_HEIGHT,
481 wxGRID_DEFAULT_COL_WIDTH,
482 wxGRID_DEFAULT_COL_LABEL_HEIGHT,
483 wxGRID_DEFAULT_ROW_LABEL_WIDTH,
484 wxGRID_LABEL_EDGE_ZONE,
485 wxGRID_MIN_ROW_HEIGHT,
486 wxGRID_MIN_COL_WIDTH,
487 wxGRID_DEFAULT_SCROLLBAR_WIDTH
491 //---------------------------------------------------------------------------
493 // TODO: Use these to have SWIG automatically handle the IncRef/DecRef calls:
495 // %ref wxGridCellWorker "$this->IncRef();";
496 // %unref wxGridCellWorker "$this->DecRef();";
499 class wxGridCellWorker
503 void _setOORInfo(PyObject* _self) {
504 if (!self->GetClientObject())
505 self->SetClientObject(new wxPyOORClientData(_self));
508 // A dummy dtor to shut up SWIG. (The real one is protected and can
509 // only be called by DecRef)
510 ~wxGridCellWorker() {
514 void SetParameters(const wxString& params);
521 // wxGridCellRenderer is an ABC, and several derived classes are available.
522 // Classes implemented in Python should be derived from wxPyGridCellRenderer.
524 class wxGridCellRenderer : public wxGridCellWorker
526 virtual void Draw(wxGrid& grid,
527 wxGridCellAttr& attr,
532 virtual wxSize GetBestSize(wxGrid& grid,
533 wxGridCellAttr& attr,
536 virtual wxGridCellRenderer *Clone() const;
541 // The C++ version of wxPyGridCellRenderer
543 class wxPyGridCellRenderer : public wxGridCellRenderer
546 wxPyGridCellRenderer() : wxGridCellRenderer() {};
548 // Implement Python callback aware virtual methods
549 void Draw(wxGrid& grid, wxGridCellAttr& attr,
550 wxDC& dc, const wxRect& rect,
551 int row, int col, bool isSelected) {
552 wxPyBlock_t blocked = wxPyBeginBlockThreads();
553 if (wxPyCBH_findCallback(m_myInst, "Draw")) {
554 PyObject* go = wxPyMake_wxObject(&grid,false);
555 PyObject* dco = wxPyMake_wxObject(&dc,false);
556 PyObject* ao = wxPyMake_wxGridCellAttr(&attr,false);
557 PyObject* ro = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
559 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOiii)", go, ao, dco, ro,
560 row, col, isSelected));
566 wxPyEndBlockThreads(blocked);
569 wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
572 wxPyBlock_t blocked = wxPyBeginBlockThreads();
573 if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) {
576 PyObject* go = wxPyMake_wxObject(&grid,false);
577 PyObject* dco = wxPyMake_wxObject(&dc,false);
578 PyObject* ao = wxPyMake_wxGridCellAttr(&attr,false);
580 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOii)",
588 const char* errmsg = "GetBestSize should return a 2-tuple of integers or a wxSize object.";
589 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) {
592 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) {
593 PyObject* o1 = PySequence_GetItem(ro, 0);
594 PyObject* o2 = PySequence_GetItem(ro, 1);
595 if (PyNumber_Check(o1) && PyNumber_Check(o2))
596 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2));
598 PyErr_SetString(PyExc_TypeError, errmsg);
603 PyErr_SetString(PyExc_TypeError, errmsg);
608 wxPyEndBlockThreads(blocked);
613 wxGridCellRenderer *Clone() const {
614 wxGridCellRenderer* rval = NULL;
615 wxPyBlock_t blocked = wxPyBeginBlockThreads();
616 if (wxPyCBH_findCallback(m_myInst, "Clone")) {
618 wxGridCellRenderer* ptr;
619 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
621 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellRenderer")))
626 wxPyEndBlockThreads(blocked);
630 DEC_PYCALLBACK__STRING(SetParameters);
635 IMP_PYCALLBACK__STRING( wxPyGridCellRenderer, wxGridCellRenderer, SetParameters);
640 // Let SWIG know about it so it can create the Python version
641 class wxPyGridCellRenderer : public wxGridCellRenderer {
643 %pythonAppend wxPyGridCellRenderer "self._setCallbackInfo(self, PyGridCellRenderer);self._setOORInfo(self)"
645 wxPyGridCellRenderer();
646 void _setCallbackInfo(PyObject* self, PyObject* _class);
648 void SetParameters(const wxString& params);
649 %MAKE_BASE_FUNC(PyGridCellRenderer, SetParameters);
652 //---------------------------------------------------------------------------
653 // Predefined Renderers
655 class wxGridCellStringRenderer : public wxGridCellRenderer
658 %pythonAppend wxGridCellStringRenderer "self._setOORInfo(self)"
659 wxGridCellStringRenderer();
663 class wxGridCellNumberRenderer : public wxGridCellStringRenderer
666 %pythonAppend wxGridCellNumberRenderer "self._setOORInfo(self)"
667 wxGridCellNumberRenderer();
671 class wxGridCellFloatRenderer : public wxGridCellStringRenderer
674 %pythonAppend wxGridCellFloatRenderer "self._setOORInfo(self)"
675 wxGridCellFloatRenderer(int width = -1, int precision = -1);
677 int GetWidth() const;
678 void SetWidth(int width);
679 int GetPrecision() const;
680 void SetPrecision(int precision);
682 %property(Precision, GetPrecision, SetPrecision, doc="See `GetPrecision` and `SetPrecision`");
683 %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
687 class wxGridCellBoolRenderer : public wxGridCellRenderer
690 %pythonAppend wxGridCellBoolRenderer "self._setOORInfo(self)"
691 wxGridCellBoolRenderer();
695 class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
698 %pythonAppend wxGridCellDateTimeRenderer "self._setOORInfo(self)"
699 wxGridCellDateTimeRenderer(wxString outformat = wxPyDefaultDateTimeFormat,
700 wxString informat = wxPyDefaultDateTimeFormat);
704 class wxGridCellEnumRenderer : public wxGridCellStringRenderer
707 %pythonAppend wxGridCellEnumRenderer "self._setOORInfo(self)"
708 wxGridCellEnumRenderer( const wxString& choices = wxPyEmptyString );
712 class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
715 %pythonAppend wxGridCellAutoWrapStringRenderer "self._setOORInfo(self)"
716 wxGridCellAutoWrapStringRenderer();
720 //---------------------------------------------------------------------------
721 // wxGridCellEditor is an ABC, and several derived classes are available.
722 // Classes implemented in Python should be derived from wxPyGridCellEditor.
724 class wxGridCellEditor : public wxGridCellWorker
728 wxControl* GetControl();
729 void SetControl(wxControl* control);
731 wxGridCellAttr* GetCellAttr();
732 void SetCellAttr(wxGridCellAttr* attr);
734 virtual void Create(wxWindow* parent,
736 wxEvtHandler* evtHandler);
737 virtual void BeginEdit(int row, int col, wxGrid* grid);
738 virtual bool EndEdit(int row, int col, wxGrid* grid);
739 virtual void Reset();
740 virtual wxGridCellEditor *Clone() const;
742 virtual void SetSize(const wxRect& rect);
743 virtual void Show(bool show, wxGridCellAttr *attr = NULL);
744 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
745 virtual bool IsAcceptedKey(wxKeyEvent& event);
746 virtual void StartingKey(wxKeyEvent& event);
747 virtual void StartingClick();
748 virtual void HandleReturn(wxKeyEvent& event);
750 %pythonAppend Destroy "args[0].thisown = 0"
751 virtual void Destroy();
753 %property(CellAttr, GetCellAttr, SetCellAttr, doc="See `GetCellAttr` and `SetCellAttr`");
754 %property(Control, GetControl, SetControl, doc="See `GetControl` and `SetControl`");
758 // The C++ version of wxPyGridCellEditor
760 class wxPyGridCellEditor : public wxGridCellEditor
763 wxPyGridCellEditor() : wxGridCellEditor() {}
765 void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
766 wxPyBlock_t blocked = wxPyBeginBlockThreads();
767 if (wxPyCBH_findCallback(m_myInst, "Create")) {
768 PyObject* po = wxPyMake_wxObject(parent,false);
769 PyObject* eo = wxPyMake_wxObject(evtHandler,false);
771 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", po, id, eo));
775 wxPyEndBlockThreads(blocked);
779 void BeginEdit(int row, int col, wxGrid* grid) {
780 wxPyBlock_t blocked = wxPyBeginBlockThreads();
781 if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) {
782 PyObject* go = wxPyMake_wxObject(grid,false);
783 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
786 wxPyEndBlockThreads(blocked);
790 bool EndEdit(int row, int col, wxGrid* grid) {
792 wxPyBlock_t blocked = wxPyBeginBlockThreads();
793 if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
794 PyObject* go = wxPyMake_wxObject(grid,false);
795 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
798 wxPyEndBlockThreads(blocked);
803 wxGridCellEditor* Clone() const {
804 wxGridCellEditor* rval = NULL;
805 wxPyBlock_t blocked = wxPyBeginBlockThreads();
806 if (wxPyCBH_findCallback(m_myInst, "Clone")) {
808 wxGridCellEditor* ptr;
809 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
811 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellEditor")))
816 wxPyEndBlockThreads(blocked);
821 void Show(bool show, wxGridCellAttr *attr) {
823 wxPyBlock_t blocked = wxPyBeginBlockThreads();
824 if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) {
825 PyObject* ao = wxPyMake_wxGridCellAttr(attr,false);
826 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", show, ao));
829 wxPyEndBlockThreads(blocked);
831 wxGridCellEditor::Show(show, attr);
835 void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
837 wxPyBlock_t blocked = wxPyBeginBlockThreads();
838 if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) {
839 PyObject* ao = wxPyMake_wxGridCellAttr(attr,false);
840 PyObject* ro = wxPyConstructObject((void*)&rectCell, wxT("wxRect"), 0);
842 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", ro, ao));
847 wxPyEndBlockThreads(blocked);
849 wxGridCellEditor::PaintBackground(rectCell, attr);
853 DEC_PYCALLBACK___pure(Reset);
854 DEC_PYCALLBACK__constany(SetSize, wxRect);
855 DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent);
856 DEC_PYCALLBACK__any(StartingKey, wxKeyEvent);
857 DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent);
858 DEC_PYCALLBACK__(StartingClick);
859 DEC_PYCALLBACK__(Destroy);
860 DEC_PYCALLBACK__STRING(SetParameters);
861 DEC_PYCALLBACK_STRING__constpure(GetValue);
867 IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters);
868 IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset);
869 IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect);
870 IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent);
871 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent);
872 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent);
873 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick);
874 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, Destroy);
875 IMP_PYCALLBACK_STRING__constpure(wxPyGridCellEditor, wxGridCellEditor, GetValue);
880 // Let SWIG know about it so it can create the Python version
881 class wxPyGridCellEditor : public wxGridCellEditor {
883 %pythonAppend wxPyGridCellEditor "self._setCallbackInfo(self, PyGridCellEditor);self._setOORInfo(self)"
885 wxPyGridCellEditor();
886 void _setCallbackInfo(PyObject* self, PyObject* _class);
888 void SetSize(const wxRect& rect);
889 void Show(bool show, wxGridCellAttr *attr = NULL);
890 void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
891 bool IsAcceptedKey(wxKeyEvent& event);
892 void StartingKey(wxKeyEvent& event);
893 void StartingClick();
894 void HandleReturn(wxKeyEvent& event);
896 void SetParameters(const wxString& params);
898 %MAKE_BASE_FUNC(PyGridCellEditor, SetSize);
899 %MAKE_BASE_FUNC(PyGridCellEditor, Show);
900 %MAKE_BASE_FUNC(PyGridCellEditor, PaintBackground);
901 %MAKE_BASE_FUNC(PyGridCellEditor, IsAcceptedKey);
902 %MAKE_BASE_FUNC(PyGridCellEditor, StartingKey);
903 %MAKE_BASE_FUNC(PyGridCellEditor, StartingClick);
904 %MAKE_BASE_FUNC(PyGridCellEditor, HandleReturn);
905 %MAKE_BASE_FUNC(PyGridCellEditor, Destroy);
906 %MAKE_BASE_FUNC(PyGridCellEditor, SetParameters);
909 //---------------------------------------------------------------------------
910 // Predefined Editors
912 class wxGridCellTextEditor : public wxGridCellEditor
915 %pythonAppend wxGridCellTextEditor "self._setOORInfo(self)"
916 wxGridCellTextEditor();
917 virtual wxString GetValue();
919 %property(Value, GetValue, doc="See `GetValue`");
923 class wxGridCellNumberEditor : public wxGridCellTextEditor
926 %pythonAppend wxGridCellNumberEditor "self._setOORInfo(self)"
927 wxGridCellNumberEditor(int min = -1, int max = -1);
931 class wxGridCellFloatEditor : public wxGridCellTextEditor
934 %pythonAppend wxGridCellFloatEditor "self._setOORInfo(self)"
935 wxGridCellFloatEditor(int width = -1, int precision = -1);
939 class wxGridCellBoolEditor : public wxGridCellEditor
942 %pythonAppend wxGridCellBoolEditor "self._setOORInfo(self)"
943 wxGridCellBoolEditor();
946 class wxGridCellChoiceEditor : public wxGridCellEditor
949 %pythonAppend wxGridCellChoiceEditor "self._setOORInfo(self)"
950 wxGridCellChoiceEditor(int choices = 0,
951 const wxString* choices_array = NULL,
952 bool allowOthers = false);
956 class wxGridCellEnumEditor : public wxGridCellChoiceEditor
959 %pythonAppend wxGridCellEnumEditor "self._setOORInfo(self)"
960 wxGridCellEnumEditor( const wxString& choices = wxPyEmptyString );
964 class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
967 %pythonAppend wxGridCellAutoWrapStringEditor "self._setOORInfo(self)"
968 wxGridCellAutoWrapStringEditor();
973 //---------------------------------------------------------------------------
990 void _setOORInfo(PyObject* _self) {
991 if (!self->GetClientObject())
992 self->SetClientObject(new wxPyOORClientData(_self));
996 %pythonAppend wxGridCellAttr "self._setOORInfo(self)"
998 wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
1001 // A dummy dtor to shut up SWIG. (The real one is protected and can
1002 // only be called by DecRef)
1007 wxGridCellAttr *Clone() const;
1008 void MergeWith(wxGridCellAttr *mergefrom);
1013 void SetTextColour(const wxColour& colText);
1014 void SetBackgroundColour(const wxColour& colBack);
1015 void SetFont(const wxFont& font);
1016 void SetAlignment(int hAlign, int vAlign);
1017 void SetSize(int num_rows, int num_cols);
1018 void SetOverflow( bool allow = true );
1019 void SetReadOnly(bool isReadOnly = true);
1021 void SetRenderer(wxGridCellRenderer *renderer);
1022 void SetEditor(wxGridCellEditor* editor);
1023 void SetKind(wxAttrKind kind);
1025 bool HasTextColour() const;
1026 bool HasBackgroundColour() const;
1027 bool HasFont() const;
1028 bool HasAlignment() const;
1029 bool HasRenderer() const;
1030 bool HasEditor() const;
1031 bool HasReadWriteMode() const;
1032 bool HasOverflowMode() const;
1034 wxColour GetTextColour() const;
1035 wxColour GetBackgroundColour() const;
1036 wxFont GetFont() const;
1039 void, GetAlignment(int *OUTPUT, int *OUTPUT) const,
1040 "GetAlignment() -> (hAlign, vAlign)");
1043 void, GetSize(int *OUTPUT, int *OUTPUT) const,
1044 "GetSize() -> (num_rows, num_cols)");
1046 bool GetOverflow() const;
1047 wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
1048 wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
1050 bool IsReadOnly() const;
1051 wxAttrKind GetKind();
1052 void SetDefAttr(wxGridCellAttr* defAttr);
1054 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
1055 %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
1056 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
1057 %property(Kind, GetKind, SetKind, doc="See `GetKind` and `SetKind`");
1058 %property(Overflow, GetOverflow, SetOverflow, doc="See `GetOverflow` and `SetOverflow`");
1059 %property(Size, GetSize, SetSize, doc="See `GetSize` and `SetSize`");
1060 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
1063 //---------------------------------------------------------------------------
1065 class wxGridCellAttrProvider
1068 %pythonAppend wxGridCellAttrProvider "self._setOORInfo(self)"
1069 wxGridCellAttrProvider();
1070 // ???? virtual ~wxGridCellAttrProvider();
1073 void _setOORInfo(PyObject* _self) {
1074 if (!self->GetClientObject())
1075 self->SetClientObject(new wxPyOORClientData(_self));
1079 wxGridCellAttr *GetAttr(int row, int col,
1080 wxGridCellAttr::wxAttrKind kind) const;
1081 void SetAttr(wxGridCellAttr *attr, int row, int col);
1082 void SetRowAttr(wxGridCellAttr *attr, int row);
1083 void SetColAttr(wxGridCellAttr *attr, int col);
1085 void UpdateAttrRows( size_t pos, int numRows );
1086 void UpdateAttrCols( size_t pos, int numCols );
1091 // A Python-aware version
1093 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
1096 wxPyGridCellAttrProvider() : wxGridCellAttrProvider() {};
1098 PYCALLBACK_GCA_INTINTKIND(wxGridCellAttrProvider, GetAttr);
1099 PYCALLBACK__GCAINTINT(wxGridCellAttrProvider, SetAttr);
1100 PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetRowAttr);
1101 PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetColAttr);
1108 // The python-aware version get's SWIGified
1109 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
1112 %pythonAppend wxPyGridCellAttrProvider "self._setCallbackInfo(self, PyGridCellAttrProvider)"
1113 wxPyGridCellAttrProvider();
1114 void _setCallbackInfo(PyObject* self, PyObject* _class);
1116 wxGridCellAttr *GetAttr(int row, int col,
1117 wxGridCellAttr::wxAttrKind kind);
1118 void SetAttr(wxGridCellAttr *attr, int row, int col);
1119 void SetRowAttr(wxGridCellAttr *attr, int row);
1120 void SetColAttr(wxGridCellAttr *attr, int col);
1122 %MAKE_BASE_FUNC(PyGridCellAttrProvider, GetAttr);
1123 %MAKE_BASE_FUNC(PyGridCellAttrProvider, SetAttr);
1124 %MAKE_BASE_FUNC(PyGridCellAttrProvider, SetRowAttr);
1125 %MAKE_BASE_FUNC(PyGridCellAttrProvider, SetColAttr);
1129 //---------------------------------------------------------------------------
1130 // Grid Table Base class and Python aware version
1133 class wxGridTableBase : public wxObject
1136 // wxGridTableBase(); This is an ABC
1140 void _setOORInfo(PyObject* _self) {
1141 if (!self->GetClientObject())
1142 self->SetClientObject(new wxPyOORClientData(_self));
1146 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
1147 wxGridCellAttrProvider *GetAttrProvider() const;
1148 void SetView( wxGrid *grid );
1149 wxGrid * GetView() const;
1153 virtual int GetNumberRows();
1154 virtual int GetNumberCols();
1155 virtual bool IsEmptyCell( int row, int col );
1156 virtual wxString GetValue( int row, int col );
1157 virtual void SetValue( int row, int col, const wxString& value );
1159 // virtuals overridable in wxPyGridTableBase
1160 virtual wxString GetTypeName( int row, int col );
1161 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
1162 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
1163 virtual long GetValueAsLong( int row, int col );
1164 virtual double GetValueAsDouble( int row, int col );
1165 virtual bool GetValueAsBool( int row, int col );
1166 virtual void SetValueAsLong( int row, int col, long value );
1167 virtual void SetValueAsDouble( int row, int col, double value );
1168 virtual void SetValueAsBool( int row, int col, bool value );
1170 //virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
1171 //virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
1174 virtual void Clear();
1175 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
1176 virtual bool AppendRows( size_t numRows = 1 );
1177 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
1178 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
1179 virtual bool AppendCols( size_t numCols = 1 );
1180 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
1182 virtual wxString GetRowLabelValue( int row );
1183 virtual wxString GetColLabelValue( int col );
1184 virtual void SetRowLabelValue( int row, const wxString& value );
1185 virtual void SetColLabelValue( int col, const wxString& value );
1187 virtual bool CanHaveAttributes();
1189 virtual wxGridCellAttr *GetAttr( int row, int col,
1190 wxGridCellAttr::wxAttrKind kind);
1191 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
1192 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
1193 virtual void SetColAttr(wxGridCellAttr *attr, int col);
1195 %property(AttrProvider, GetAttrProvider, SetAttrProvider, doc="See `GetAttrProvider` and `SetAttrProvider`");
1196 %property(NumberCols, GetNumberCols, doc="See `GetNumberCols`");
1197 %property(NumberRows, GetNumberRows, doc="See `GetNumberRows`");
1198 %property(View, GetView, SetView, doc="See `GetView` and `SetView`");
1203 // Python-aware version
1205 class wxPyGridTableBase : public wxGridTableBase
1208 wxPyGridTableBase() : wxGridTableBase() {}
1210 PYCALLBACK_INT__pure(GetNumberRows);
1211 PYCALLBACK_INT__pure(GetNumberCols);
1212 PYCALLBACK_BOOL_INTINT_pure(IsEmptyCell);
1213 PYCALLBACK_STRING_INTINT(wxGridTableBase, GetTypeName);
1214 PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanGetValueAs);
1215 PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanSetValueAs);
1216 PYCALLBACK__(wxGridTableBase, Clear);
1217 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertRows);
1218 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteRows);
1219 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertCols);
1220 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteCols);
1221 PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendRows);
1222 PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendCols);
1223 PYCALLBACK_STRING_INT(wxGridTableBase, GetRowLabelValue);
1224 PYCALLBACK_STRING_INT(wxGridTableBase, GetColLabelValue);
1225 PYCALLBACK__INTSTRING(wxGridTableBase, SetRowLabelValue);
1226 PYCALLBACK__INTSTRING(wxGridTableBase, SetColLabelValue);
1227 PYCALLBACK_BOOL_(wxGridTableBase, CanHaveAttributes);
1228 PYCALLBACK_GCA_INTINTKIND(wxGridTableBase, GetAttr);
1229 PYCALLBACK__GCAINTINT(wxGridTableBase, SetAttr);
1230 PYCALLBACK__GCAINT(wxGridTableBase, SetRowAttr);
1231 PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
1234 wxString GetValue(int row, int col) {
1235 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1237 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1239 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
1241 if (!PyString_Check(ro) && !PyUnicode_Check(ro)) {
1243 ro = PyObject_Str(ro);
1246 rval = Py2wxString(ro);
1250 wxPyEndBlockThreads(blocked);
1254 void SetValue(int row, int col, const wxString& val) {
1255 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1256 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1257 PyObject* s = wx2PyString(val);
1258 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,s));
1261 wxPyEndBlockThreads(blocked);
1265 // Map the Get/Set methods for the standard non-string types to
1266 // the GetValue and SetValue python methods.
1267 long GetValueAsLong( int row, int col ) {
1269 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1270 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1273 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
1274 if (ro && PyNumber_Check(ro)) {
1275 num = PyNumber_Int(ro);
1277 rval = PyInt_AsLong(num);
1283 wxPyEndBlockThreads(blocked);
1287 double GetValueAsDouble( int row, int col ) {
1289 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1290 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1293 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
1294 if (ro && PyNumber_Check(ro)) {
1295 num = PyNumber_Float(ro);
1297 rval = PyFloat_AsDouble(num);
1303 wxPyEndBlockThreads(blocked);
1307 bool GetValueAsBool( int row, int col ) {
1308 return (bool)GetValueAsLong(row, col);
1311 void SetValueAsLong( int row, int col, long value ) {
1312 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1313 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1314 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value));
1316 wxPyEndBlockThreads(blocked);
1319 void SetValueAsDouble( int row, int col, double value ) {
1320 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1321 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1322 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value));
1324 wxPyEndBlockThreads(blocked);
1327 void SetValueAsBool( int row, int col, bool value ) {
1328 SetValueAsLong( row, col, (long)value );
1337 // The python-aware version get's SWIGified
1338 class wxPyGridTableBase : public wxGridTableBase
1341 %pythonAppend wxPyGridTableBase "self._setCallbackInfo(self, PyGridTableBase);self._setOORInfo(self)"
1342 wxPyGridTableBase();
1343 void _setCallbackInfo(PyObject* self, PyObject* _class);
1345 %pythonAppend Destroy "args[0].thisown = 0"
1346 %extend { void Destroy() { delete self; } }
1348 wxString GetTypeName( int row, int col );
1349 bool CanGetValueAs( int row, int col, const wxString& typeName );
1350 bool CanSetValueAs( int row, int col, const wxString& typeName );
1352 bool InsertRows( size_t pos = 0, size_t numRows = 1 );
1353 bool AppendRows( size_t numRows = 1 );
1354 bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
1355 bool InsertCols( size_t pos = 0, size_t numCols = 1 );
1356 bool AppendCols( size_t numCols = 1 );
1357 bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
1358 wxString GetRowLabelValue( int row );
1359 wxString GetColLabelValue( int col );
1360 void SetRowLabelValue( int row, const wxString& value );
1361 void SetColLabelValue( int col, const wxString& value );
1362 bool CanHaveAttributes();
1363 wxGridCellAttr *GetAttr( int row, int col,
1364 wxGridCellAttr::wxAttrKind kind );
1365 void SetAttr(wxGridCellAttr* attr, int row, int col);
1366 void SetRowAttr(wxGridCellAttr *attr, int row);
1367 void SetColAttr(wxGridCellAttr *attr, int col);
1369 %MAKE_BASE_FUNC(PyGridTableBase, GetTypeName);
1370 %MAKE_BASE_FUNC(PyGridTableBase, CanGetValueAs);
1371 %MAKE_BASE_FUNC(PyGridTableBase, CanSetValueAs);
1372 %MAKE_BASE_FUNC(PyGridTableBase, Clear);
1373 %MAKE_BASE_FUNC(PyGridTableBase, InsertRows);
1374 %MAKE_BASE_FUNC(PyGridTableBase, AppendRows);
1375 %MAKE_BASE_FUNC(PyGridTableBase, DeleteRows);
1376 %MAKE_BASE_FUNC(PyGridTableBase, InsertCols);
1377 %MAKE_BASE_FUNC(PyGridTableBase, AppendCols);
1378 %MAKE_BASE_FUNC(PyGridTableBase, DeleteCols);
1379 %MAKE_BASE_FUNC(PyGridTableBase, GetRowLabelValue);
1380 %MAKE_BASE_FUNC(PyGridTableBase, GetColLabelValue);
1381 %MAKE_BASE_FUNC(PyGridTableBase, SetRowLabelValue);
1382 %MAKE_BASE_FUNC(PyGridTableBase, SetColLabelValue);
1383 %MAKE_BASE_FUNC(PyGridTableBase, CanHaveAttributes);
1384 %MAKE_BASE_FUNC(PyGridTableBase, GetAttr);
1385 %MAKE_BASE_FUNC(PyGridTableBase, SetAttr);
1386 %MAKE_BASE_FUNC(PyGridTableBase, SetRowAttr);
1387 %MAKE_BASE_FUNC(PyGridTableBase, SetColAttr);
1391 //---------------------------------------------------------------------------
1392 // Predefined Tables
1394 class wxGridStringTable : public wxGridTableBase
1397 %pythonAppend wxGridStringTable "self._setOORInfo(self)"
1398 wxGridStringTable( int numRows=0, int numCols=0 );
1401 //---------------------------------------------------------------------------
1402 // The Table can pass messages to the grid to tell it to update itself if
1403 // something has changed.
1405 enum wxGridTableRequest
1407 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
1408 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
1409 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
1410 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
1411 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
1412 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
1413 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
1414 wxGRIDTABLE_NOTIFY_COLS_DELETED
1418 class wxGridTableMessage
1421 wxGridTableMessage( wxGridTableBase *table, int id,
1424 ~wxGridTableMessage();
1426 void SetTableObject( wxGridTableBase *table );
1427 wxGridTableBase * GetTableObject() const;
1428 void SetId( int id );
1430 void SetCommandInt( int comInt1 );
1431 int GetCommandInt();
1432 void SetCommandInt2( int comInt2 );
1433 int GetCommandInt2();
1435 %property(CommandInt, GetCommandInt, SetCommandInt, doc="See `GetCommandInt` and `SetCommandInt`");
1436 %property(CommandInt2, GetCommandInt2, SetCommandInt2, doc="See `GetCommandInt2` and `SetCommandInt2`");
1437 %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
1438 %property(TableObject, GetTableObject, SetTableObject, doc="See `GetTableObject` and `SetTableObject`");
1442 //---------------------------------------------------------------------------
1445 // Typemap to allow conversion of sequence objects to wxGridCellCoords...
1446 %typemap(in) wxGridCellCoords& (wxGridCellCoords temp) {
1448 if (! wxGridCellCoords_helper($input, &$1)) SWIG_fail;
1450 %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxGridCellCoords& {
1451 $1 = wxGridCellCoords_typecheck($input);
1455 // ...and here is the associated helper.
1457 bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
1459 if (source == Py_None) {
1460 **obj = wxGridCellCoords(-1,-1);
1464 // If source is an object instance then it may already be the right type
1465 if (wxPySwigInstance_Check(source)) {
1466 wxGridCellCoords* ptr;
1467 if (! wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
1472 // otherwise a 2-tuple of integers is expected
1473 else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
1474 PyObject* o1 = PySequence_GetItem(source, 0);
1475 PyObject* o2 = PySequence_GetItem(source, 1);
1476 if (!PyNumber_Check(o1) || !PyNumber_Check(o2)) {
1481 **obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2));
1488 PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object.");
1493 bool wxGridCellCoords_typecheck(PyObject* source) {
1496 if (wxPySwigInstance_Check(source) &&
1497 wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
1501 if (PySequence_Check(source) && PySequence_Length(source) == 2)
1509 // Typemap to convert an array of cells coords to a list of tuples...
1510 %typemap(out) wxGridCellCoordsArray {
1511 $result = wxGridCellCoordsArray_helper($1);
1514 // %typemap(ret) wxGridCellCoordsArray {
1519 // ...and the helper function for the above typemap.
1521 PyObject* wxGridCellCoordsArray_helper(const wxGridCellCoordsArray& source)
1523 PyObject* list = PyList_New(0);
1525 for (idx = 0; idx < source.GetCount(); idx += 1) {
1526 wxGridCellCoords& coord = source.Item(idx);
1527 PyObject* tup = PyTuple_New(2);
1528 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(coord.GetRow()));
1529 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(coord.GetCol()));
1530 PyList_Append(list, tup);
1541 class wxGridCellCoords
1544 wxGridCellCoords( int r=-1, int c=-1 );
1545 ~wxGridCellCoords();
1548 void SetRow( int n );
1550 void SetCol( int n );
1551 void Set( int row, int col );
1555 DocStr(__eq__, "Test for equality of GridCellCoords objects.", "");
1556 bool __eq__(PyObject* other) {
1557 wxGridCellCoords temp, *obj = &temp;
1558 if ( other == Py_None ) return false;
1559 if ( ! wxGridCellCoords_helper(other, &obj) ) {
1563 return self->operator==(*obj);
1568 DocStr(__ne__, "Test for inequality of GridCellCoords objects.", "");
1569 bool __ne__(PyObject* other) {
1570 wxGridCellCoords temp, *obj = &temp;
1571 if ( other == Py_None ) return true;
1572 if ( ! wxGridCellCoords_helper(other, &obj)) {
1576 return self->operator!=(*obj);
1583 PyObject* tup = PyTuple_New(2);
1584 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
1585 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
1590 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
1591 def __str__(self): return str(self.Get())
1592 def __repr__(self): return 'wxGridCellCoords'+str(self.Get())
1593 def __len__(self): return len(self.Get())
1594 def __getitem__(self, index): return self.asTuple()[index]
1595 def __setitem__(self, index, val):
1596 if index == 0: self.SetRow(val)
1597 elif index == 1: self.SetCol(val)
1598 else: raise IndexError
1601 %property(Col, GetCol, SetCol, doc="See `GetCol` and `SetCol`");
1602 %property(Row, GetRow, SetRow, doc="See `GetRow` and `SetRow`");
1606 //---------------------------------------------------------------------------
1607 //---------------------------------------------------------------------------
1611 // Fool SWIG into treating this enum as an int
1612 typedef int WXGRIDSELECTIONMODES;
1614 // but let the C++ code know what it really is.
1616 typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES;
1621 MustHaveApp(wxGrid);
1623 class wxGrid : public wxScrolledWindow
1626 %pythonAppend wxGrid "self._setOORInfo(self)"
1627 %pythonAppend wxGrid() ""
1629 %typemap(out) wxGrid*; // turn off this typemap
1631 wxGrid( wxWindow *parent,
1633 const wxPoint& pos = wxDefaultPosition,
1634 const wxSize& size = wxDefaultSize,
1635 long style = wxWANTS_CHARS,
1636 const wxString& name = wxPyGridNameStr);
1638 %RenameCtor(PreGrid, wxGrid());
1641 // Turn it back on again
1642 %typemap(out) wxGrid* { $result = wxPyMake_wxObject($1, $owner); }
1645 bool Create( wxWindow *parent,
1647 const wxPoint& pos = wxDefaultPosition,
1648 const wxSize& size = wxDefaultSize,
1649 long style = wxWANTS_CHARS,
1650 const wxString& name = wxPyGridNameStr );
1652 // Override the global renamer to leave these as they are, for backwards
1654 %rename(wxGridSelectCells) wxGridSelectCells;
1655 %rename(wxGridSelectRows) wxGridSelectRows;
1656 %rename(wxGridSelectColumns) wxGridSelectColumns;
1658 enum wxGridSelectionModes {
1664 SelectCells = wxGridSelectCells
1665 SelectRows = wxGridSelectRows
1666 SelectColumns = wxGridSelectColumns
1669 bool CreateGrid( int numRows, int numCols,
1670 WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells );
1671 void SetSelectionMode(WXGRIDSELECTIONMODES selmode);
1672 WXGRIDSELECTIONMODES GetSelectionMode();
1675 // ------ grid dimensions
1677 int GetNumberRows();
1678 int GetNumberCols();
1681 bool ProcessTableMessage( wxGridTableMessage& );
1684 wxGridTableBase * GetTable() const;
1686 %disownarg(wxGridTableBase *);
1687 bool SetTable( wxGridTableBase *table, bool takeOwnership=false,
1688 WXGRIDSELECTIONMODES selmode =
1689 wxGrid::wxGridSelectCells );
1690 %cleardisown(wxGridTableBase *);
1693 bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=true );
1694 bool AppendRows( int numRows = 1, bool updateLabels=true );
1695 bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=true );
1696 bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=true );
1697 bool AppendCols( int numCols = 1, bool updateLabels=true );
1698 bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=true );
1701 // this function is called when the current cell highlight must be redrawn
1702 // and may be overridden by the user
1703 virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
1706 // ------ Cell text drawing functions
1708 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
1709 int horizontalAlignment = wxLEFT,
1710 int verticalAlignment = wxTOP,
1711 int textOrientation = wxHORIZONTAL );
1713 // // Split a string containing newline chararcters into an array of
1714 // // strings and return the number of lines
1716 // void StringToLines( const wxString& value, wxArrayString& lines );
1719 void, GetTextBoxSize( wxDC& dc, wxArrayString& lines,
1720 long *OUTPUT, long *OUTPUT ),
1721 "GetTextBoxSize(DC dc, list lines) -> (width, height)");
1725 // Code that does a lot of grid modification can be enclosed
1726 // between BeginBatch() and EndBatch() calls to avoid screen
1731 int GetBatchCount();
1732 void ForceRefresh();
1735 // ------ edit control functions
1738 void EnableEditing( bool edit );
1740 void EnableCellEditControl( bool enable = true );
1741 void DisableCellEditControl();
1742 bool CanEnableCellControl() const;
1743 bool IsCellEditControlEnabled() const;
1744 bool IsCellEditControlShown() const;
1746 bool IsCurrentCellReadOnly() const;
1748 void ShowCellEditControl();
1749 void HideCellEditControl();
1750 void SaveEditControlValue();
1753 // ------ grid location functions
1754 // Note that all of these functions work with the logical coordinates of
1755 // grid cells and labels so you will need to convert from device
1756 // coordinates for mouse events etc.
1759 //void XYToCell( int x, int y, wxGridCellCoords& );
1761 wxGridCellCoords XYToCell(int x, int y) {
1762 wxGridCellCoords rv;
1763 self->XYToCell(x, y, rv);
1768 int YToRow( int y );
1769 int XToCol( int x, bool clipToMinMax = false );
1771 int YToEdgeOfRow( int y );
1772 int XToEdgeOfCol( int x );
1774 wxRect CellToRect( int row, int col );
1775 // TODO: ??? wxRect CellToRect( const wxGridCellCoords& coords );
1778 int GetGridCursorRow();
1779 int GetGridCursorCol();
1781 // check to see if a cell is either wholly visible (the default arg) or
1782 // at least partially visible in the grid window
1784 bool IsVisible( int row, int col, bool wholeCellVisible = true );
1785 // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = true );
1786 void MakeCellVisible( int row, int col );
1787 // TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords );
1790 // ------ grid cursor movement functions
1792 void SetGridCursor( int row, int col );
1793 bool MoveCursorUp( bool expandSelection );
1794 bool MoveCursorDown( bool expandSelection );
1795 bool MoveCursorLeft( bool expandSelection );
1796 bool MoveCursorRight( bool expandSelection );
1797 bool MovePageDown();
1799 bool MoveCursorUpBlock( bool expandSelection );
1800 bool MoveCursorDownBlock( bool expandSelection );
1801 bool MoveCursorLeftBlock( bool expandSelection );
1802 bool MoveCursorRightBlock( bool expandSelection );
1805 // ------ label and gridline formatting
1807 int GetDefaultRowLabelSize();
1808 int GetRowLabelSize();
1809 int GetDefaultColLabelSize();
1810 int GetColLabelSize();
1811 wxColour GetLabelBackgroundColour();
1812 wxColour GetLabelTextColour();
1813 wxFont GetLabelFont();
1816 void, GetRowLabelAlignment( int *OUTPUT, int *OUTPUT ),
1817 "GetRowLabelAlignment() -> (horiz, vert)");
1820 void, GetColLabelAlignment( int *OUTPUT, int *OUTPUT ),
1821 "GetColLabelAlignment() -> (horiz, vert)");
1823 int GetColLabelTextOrientation();
1824 wxString GetRowLabelValue( int row );
1825 wxString GetColLabelValue( int col );
1826 wxColour GetGridLineColour();
1828 virtual wxPen GetDefaultGridLinePen();
1829 virtual wxPen GetRowGridLinePen(int row);
1830 virtual wxPen GetColGridLinePen(int col);
1833 wxColour GetCellHighlightColour();
1834 int GetCellHighlightPenWidth();
1835 int GetCellHighlightROPenWidth();
1837 void SetRowLabelSize( int width );
1838 void SetColLabelSize( int height );
1839 void SetLabelBackgroundColour( const wxColour& );
1840 void SetLabelTextColour( const wxColour& );
1841 void SetLabelFont( const wxFont& );
1842 void SetRowLabelAlignment( int horiz, int vert );
1843 void SetColLabelAlignment( int horiz, int vert );
1844 void SetColLabelTextOrientation( int textOrientation );
1845 void SetRowLabelValue( int row, const wxString& );
1846 void SetColLabelValue( int col, const wxString& );
1847 void SetGridLineColour( const wxColour& );
1848 void SetCellHighlightColour( const wxColour& );
1849 void SetCellHighlightPenWidth(int width);
1850 void SetCellHighlightROPenWidth(int width);
1852 void EnableDragRowSize( bool enable = true );
1853 void DisableDragRowSize();
1854 bool CanDragRowSize();
1855 void EnableDragColSize( bool enable = true );
1856 void DisableDragColSize();
1857 bool CanDragColSize();
1858 void EnableDragColMove( bool enable = true );
1859 void DisableDragColMove() { EnableDragColMove( false ); }
1860 bool CanDragColMove() { return m_canDragColMove; }
1861 void EnableDragGridSize(bool enable = true);
1862 void DisableDragGridSize();
1863 bool CanDragGridSize();
1865 void EnableDragCell( bool enable = true );
1866 void DisableDragCell();
1869 // this sets the specified attribute for all cells in this row/col
1870 void SetAttr(int row, int col, wxGridCellAttr *attr);
1871 void SetRowAttr(int row, wxGridCellAttr *attr);
1872 void SetColAttr(int col, wxGridCellAttr *attr);
1874 // returns the attribute we may modify in place: a new one if this cell
1875 // doesn't have any yet or the existing one if it does
1877 // DecRef() must be called on the returned pointer, as usual
1878 wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
1881 // shortcuts for setting the column parameters
1883 // set the format for the data in the column: default is string
1884 void SetColFormatBool(int col);
1885 void SetColFormatNumber(int col);
1886 void SetColFormatFloat(int col, int width = -1, int precision = -1);
1887 void SetColFormatCustom(int col, const wxString& typeName);
1889 void EnableGridLines( bool enable = true );
1890 bool GridLinesEnabled();
1892 // ------ row and col formatting
1894 int GetDefaultRowSize();
1895 int GetRowSize( int row );
1896 int GetDefaultColSize();
1897 int GetColSize( int col );
1898 wxColour GetDefaultCellBackgroundColour();
1899 wxColour GetCellBackgroundColour( int row, int col );
1900 wxColour GetDefaultCellTextColour();
1901 wxColour GetCellTextColour( int row, int col );
1902 wxFont GetDefaultCellFont();
1903 wxFont GetCellFont( int row, int col );
1906 void, GetDefaultCellAlignment( int *OUTPUT, int *OUTPUT ),
1907 "GetDefaultCellAlignment() -> (horiz, vert)");
1910 void, GetCellAlignment( int row, int col, int *OUTPUT, int *OUTPUT ),
1911 "GetCellAlignment(int row, int col) -> (horiz, vert)");
1913 bool GetDefaultCellOverflow();
1914 bool GetCellOverflow( int row, int col );
1917 void, GetCellSize( int row, int col, int *OUTPUT, int *OUTPUT ),
1918 "GetCellSize(int row, int col) -> (num_rows, num_cols)");
1920 void SetDefaultRowSize( int height, bool resizeExistingRows = false );
1921 void SetRowSize( int row, int height );
1922 void SetDefaultColSize( int width, bool resizeExistingCols = false );
1924 void SetColSize( int col, int width );
1926 int GetColAt( int colPos ) const;
1927 void SetColPos( int colID, int newPos );
1928 int GetColPos( int colID ) const;
1930 // automatically size the column or row to fit to its contents, if
1931 // setAsMin is True, this optimal width will also be set as minimal width
1933 void AutoSizeColumn( int col, bool setAsMin = true );
1934 void AutoSizeRow( int row, bool setAsMin = true );
1937 // auto size all columns (very ineffective for big grids!)
1938 void AutoSizeColumns( bool setAsMin = true );
1939 void AutoSizeRows( bool setAsMin = true );
1941 // auto size the grid, that is make the columns/rows of the "right" size
1942 // and also set the grid size to just fit its contents
1945 // autosize row height depending on label text
1946 void AutoSizeRowLabelSize( int row );
1948 // autosize column width depending on label text
1949 void AutoSizeColLabelSize( int col );
1952 // column won't be resized to be lesser width - this must be called during
1953 // the grid creation because it won't resize the column if it's already
1954 // narrower than the minimal width
1955 void SetColMinimalWidth( int col, int width );
1956 void SetRowMinimalHeight( int row, int width );
1958 void SetColMinimalAcceptableWidth( int width );
1959 void SetRowMinimalAcceptableHeight( int width );
1960 int GetColMinimalAcceptableWidth() const;
1961 int GetRowMinimalAcceptableHeight() const;
1963 void SetDefaultCellBackgroundColour( const wxColour& );
1964 void SetCellBackgroundColour( int row, int col, const wxColour& );
1965 void SetDefaultCellTextColour( const wxColour& );
1967 void SetCellTextColour( int row, int col, const wxColour& );
1968 void SetDefaultCellFont( const wxFont& );
1969 void SetCellFont( int row, int col, const wxFont& );
1970 void SetDefaultCellAlignment( int horiz, int vert );
1971 void SetCellAlignment( int row, int col, int horiz, int vert );
1972 void SetDefaultCellOverflow( bool allow );
1973 void SetCellOverflow( int row, int col, bool allow );
1974 void SetCellSize( int row, int col, int num_rows, int num_cols );
1976 // takes ownership of the pointer
1977 void SetDefaultRenderer(wxGridCellRenderer *renderer);
1978 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
1979 wxGridCellRenderer *GetDefaultRenderer() const;
1980 wxGridCellRenderer* GetCellRenderer(int row, int col);
1982 // takes ownership of the pointer
1983 void SetDefaultEditor(wxGridCellEditor *editor);
1984 void SetCellEditor(int row, int col, wxGridCellEditor *editor);
1985 wxGridCellEditor *GetDefaultEditor() const;
1986 wxGridCellEditor* GetCellEditor(int row, int col);
1990 // ------ cell value accessors
1992 wxString GetCellValue( int row, int col );
1993 // TODO: ??? wxString GetCellValue( const wxGridCellCoords& coords )
1995 void SetCellValue( int row, int col, const wxString& s );
1996 // TODO: ??? void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
1998 // returns True if the cell can't be edited
1999 bool IsReadOnly(int row, int col) const;
2001 // make the cell editable/readonly
2002 void SetReadOnly(int row, int col, bool isReadOnly = true);
2004 // ------ selections of blocks of cells
2006 void SelectRow( int row, bool addToSelected = false );
2007 void SelectCol( int col, bool addToSelected = false );
2009 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
2010 bool addToSelected = false );
2011 // TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft,
2012 // TODO: ??? const wxGridCellCoords& bottomRight )
2016 void ClearSelection();
2017 bool IsInSelection( int row, int col );
2018 // TODO: ??? bool IsInSelection( const wxGridCellCoords& coords )
2020 const wxGridCellCoordsArray GetSelectedCells() const;
2021 const wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
2022 const wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
2023 const wxArrayInt GetSelectedRows() const;
2024 const wxArrayInt GetSelectedCols() const;
2026 void DeselectRow( int row );
2027 void DeselectCol( int col );
2028 void DeselectCell( int row, int col );
2031 // This function returns the rectangle that encloses the block of cells
2032 // limited by TopLeft and BottomRight cell in device coords and clipped
2033 // to the client size of the grid window.
2035 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
2036 const wxGridCellCoords & bottomRight );
2039 // Access or update the selection fore/back colours
2040 wxColour GetSelectionBackground() const;
2041 wxColour GetSelectionForeground() const;
2043 void SetSelectionBackground(const wxColour& c);
2044 void SetSelectionForeground(const wxColour& c);
2047 // Methods for a registry for mapping data types to Renderers/Editors
2048 void RegisterDataType(const wxString& typeName,
2049 wxGridCellRenderer* renderer,
2050 wxGridCellEditor* editor);
2051 wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
2052 // TODO: ??? wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
2053 wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
2054 wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
2055 wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
2057 // grid may occupy more space than needed for its rows/columns, this
2058 // function allows to set how big this extra space is
2059 void SetMargins(int extraWidth, int extraHeight);
2062 // Accessors for component windows
2063 wxWindow* GetGridWindow();
2064 wxWindow* GetGridRowLabelWindow();
2065 wxWindow* GetGridColLabelWindow();
2066 wxWindow* GetGridCornerLabelWindow();
2068 // Allow adjustment of scroll increment. The default is (15, 15).
2069 void SetScrollLineX(int x);
2070 void SetScrollLineY(int y);
2071 int GetScrollLineX() const;
2072 int GetScrollLineY() const;
2074 int GetScrollX(int x) const;
2075 int GetScrollY(int y) const;
2077 static wxVisualAttributes
2078 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
2080 %property(BatchCount, GetBatchCount, doc="See `GetBatchCount`");
2081 %property(CellHighlightColour, GetCellHighlightColour, SetCellHighlightColour, doc="See `GetCellHighlightColour` and `SetCellHighlightColour`");
2082 %property(CellHighlightPenWidth, GetCellHighlightPenWidth, SetCellHighlightPenWidth, doc="See `GetCellHighlightPenWidth` and `SetCellHighlightPenWidth`");
2083 %property(CellHighlightROPenWidth, GetCellHighlightROPenWidth, SetCellHighlightROPenWidth, doc="See `GetCellHighlightROPenWidth` and `SetCellHighlightROPenWidth`");
2084 %property(CellSize, GetCellSize, SetCellSize, doc="See `GetCellSize` and `SetCellSize`");
2085 %property(ColLabelAlignment, GetColLabelAlignment, SetColLabelAlignment, doc="See `GetColLabelAlignment` and `SetColLabelAlignment`");
2086 %property(ColLabelSize, GetColLabelSize, SetColLabelSize, doc="See `GetColLabelSize` and `SetColLabelSize`");
2087 %property(ColLabelTextOrientation, GetColLabelTextOrientation, SetColLabelTextOrientation, doc="See `GetColLabelTextOrientation` and `SetColLabelTextOrientation`");
2088 %property(ColMinimalAcceptableWidth, GetColMinimalAcceptableWidth, SetColMinimalAcceptableWidth, doc="See `GetColMinimalAcceptableWidth` and `SetColMinimalAcceptableWidth`");
2089 %property(DefaultCellAlignment, GetDefaultCellAlignment, SetDefaultCellAlignment, doc="See `GetDefaultCellAlignment` and `SetDefaultCellAlignment`");
2090 %property(DefaultCellBackgroundColour, GetDefaultCellBackgroundColour, SetDefaultCellBackgroundColour, doc="See `GetDefaultCellBackgroundColour` and `SetDefaultCellBackgroundColour`");
2091 %property(DefaultCellFont, GetDefaultCellFont, SetDefaultCellFont, doc="See `GetDefaultCellFont` and `SetDefaultCellFont`");
2092 %property(DefaultCellOverflow, GetDefaultCellOverflow, SetDefaultCellOverflow, doc="See `GetDefaultCellOverflow` and `SetDefaultCellOverflow`");
2093 %property(DefaultCellTextColour, GetDefaultCellTextColour, SetDefaultCellTextColour, doc="See `GetDefaultCellTextColour` and `SetDefaultCellTextColour`");
2094 %property(DefaultColLabelSize, GetDefaultColLabelSize, doc="See `GetDefaultColLabelSize`");
2095 %property(DefaultColSize, GetDefaultColSize, SetDefaultColSize, doc="See `GetDefaultColSize` and `SetDefaultColSize`");
2096 %property(DefaultEditor, GetDefaultEditor, SetDefaultEditor, doc="See `GetDefaultEditor` and `SetDefaultEditor`");
2097 %property(DefaultGridLinePen, GetDefaultGridLinePen, doc="See `GetDefaultGridLinePen`");
2098 %property(DefaultRenderer, GetDefaultRenderer, SetDefaultRenderer, doc="See `GetDefaultRenderer` and `SetDefaultRenderer`");
2099 %property(DefaultRowLabelSize, GetDefaultRowLabelSize, doc="See `GetDefaultRowLabelSize`");
2100 %property(DefaultRowSize, GetDefaultRowSize, SetDefaultRowSize, doc="See `GetDefaultRowSize` and `SetDefaultRowSize`");
2101 %property(GridColLabelWindow, GetGridColLabelWindow, doc="See `GetGridColLabelWindow`");
2102 %property(GridCornerLabelWindow, GetGridCornerLabelWindow, doc="See `GetGridCornerLabelWindow`");
2103 %property(GridCursorCol, GetGridCursorCol, doc="See `GetGridCursorCol`");
2104 %property(GridCursorRow, GetGridCursorRow, doc="See `GetGridCursorRow`");
2105 %property(GridLineColour, GetGridLineColour, SetGridLineColour, doc="See `GetGridLineColour` and `SetGridLineColour`");
2106 %property(GridRowLabelWindow, GetGridRowLabelWindow, doc="See `GetGridRowLabelWindow`");
2107 %property(GridWindow, GetGridWindow, doc="See `GetGridWindow`");
2108 %property(LabelBackgroundColour, GetLabelBackgroundColour, SetLabelBackgroundColour, doc="See `GetLabelBackgroundColour` and `SetLabelBackgroundColour`");
2109 %property(LabelFont, GetLabelFont, SetLabelFont, doc="See `GetLabelFont` and `SetLabelFont`");
2110 %property(LabelTextColour, GetLabelTextColour, SetLabelTextColour, doc="See `GetLabelTextColour` and `SetLabelTextColour`");
2111 %property(NumberCols, GetNumberCols, doc="See `GetNumberCols`");
2112 %property(NumberRows, GetNumberRows, doc="See `GetNumberRows`");
2113 %property(RowLabelAlignment, GetRowLabelAlignment, SetRowLabelAlignment, doc="See `GetRowLabelAlignment` and `SetRowLabelAlignment`");
2114 %property(RowLabelSize, GetRowLabelSize, SetRowLabelSize, doc="See `GetRowLabelSize` and `SetRowLabelSize`");
2115 %property(RowMinimalAcceptableHeight, GetRowMinimalAcceptableHeight, SetRowMinimalAcceptableHeight, doc="See `GetRowMinimalAcceptableHeight` and `SetRowMinimalAcceptableHeight`");
2116 %property(ScrollLineX, GetScrollLineX, SetScrollLineX, doc="See `GetScrollLineX` and `SetScrollLineX`");
2117 %property(ScrollLineY, GetScrollLineY, SetScrollLineY, doc="See `GetScrollLineY` and `SetScrollLineY`");
2118 %property(SelectedCells, GetSelectedCells, doc="See `GetSelectedCells`");
2119 %property(SelectedCols, GetSelectedCols, doc="See `GetSelectedCols`");
2120 %property(SelectedRows, GetSelectedRows, doc="See `GetSelectedRows`");
2121 %property(SelectionBackground, GetSelectionBackground, SetSelectionBackground, doc="See `GetSelectionBackground` and `SetSelectionBackground`");
2122 %property(SelectionBlockBottomRight, GetSelectionBlockBottomRight, doc="See `GetSelectionBlockBottomRight`");
2123 %property(SelectionBlockTopLeft, GetSelectionBlockTopLeft, doc="See `GetSelectionBlockTopLeft`");
2124 %property(SelectionForeground, GetSelectionForeground, SetSelectionForeground, doc="See `GetSelectionForeground` and `SetSelectionForeground`");
2125 %property(SelectionMode, GetSelectionMode, SetSelectionMode, doc="See `GetSelectionMode` and `SetSelectionMode`");
2126 %property(Table, GetTable, SetTable, doc="See `GetTable` and `SetTable`");
2131 //---------------------------------------------------------------------------
2132 //---------------------------------------------------------------------------
2133 // Grid events and stuff
2137 class wxGridEvent : public wxNotifyEvent
2140 wxGridEvent(int id, wxEventType type, wxGrid* obj,
2141 int row=-1, int col=-1, int x=-1, int y=-1, bool sel = true,
2142 bool control=false, bool shift=false, bool alt=false, bool meta=false);
2144 virtual int GetRow();
2145 virtual int GetCol();
2146 wxPoint GetPosition();
2154 %property(Col, GetCol, doc="See `GetCol`");
2155 %property(Position, GetPosition, doc="See `GetPosition`");
2156 %property(Row, GetRow, doc="See `GetRow`");
2160 class wxGridSizeEvent : public wxNotifyEvent
2163 wxGridSizeEvent(int id, wxEventType type, wxGrid* obj,
2164 int rowOrCol=-1, int x=-1, int y=-1,
2165 bool control=false, bool shift=false, bool alt=false, bool meta=false);
2168 wxPoint GetPosition();
2175 %property(Position, GetPosition, doc="See `GetPosition`");
2176 %property(RowOrCol, GetRowOrCol, doc="See `GetRowOrCol`");
2180 class wxGridRangeSelectEvent : public wxNotifyEvent
2183 wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj,
2184 const wxGridCellCoords& topLeft,
2185 const wxGridCellCoords& bottomRight,
2187 bool control=false, bool shift=false,
2188 bool alt=false, bool meta=false);
2190 wxGridCellCoords GetTopLeftCoords();
2191 wxGridCellCoords GetBottomRightCoords();
2203 %property(BottomRightCoords, GetBottomRightCoords, doc="See `GetBottomRightCoords`");
2204 %property(BottomRow, GetBottomRow, doc="See `GetBottomRow`");
2205 %property(LeftCol, GetLeftCol, doc="See `GetLeftCol`");
2206 %property(RightCol, GetRightCol, doc="See `GetRightCol`");
2207 %property(TopLeftCoords, GetTopLeftCoords, doc="See `GetTopLeftCoords`");
2208 %property(TopRow, GetTopRow, doc="See `GetTopRow`");
2212 class wxGridEditorCreatedEvent : public wxCommandEvent {
2214 wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
2215 int row, int col, wxControl* ctrl);
2219 wxControl* GetControl();
2220 void SetRow(int row);
2221 void SetCol(int col);
2222 void SetControl(wxControl* ctrl);
2224 %property(Col, GetCol, SetCol, doc="See `GetCol` and `SetCol`");
2225 %property(Control, GetControl, SetControl, doc="See `GetControl` and `SetControl`");
2226 %property(Row, GetRow, SetRow, doc="See `GetRow` and `SetRow`");
2231 %constant wxEventType wxEVT_GRID_CELL_LEFT_CLICK;
2232 %constant wxEventType wxEVT_GRID_CELL_RIGHT_CLICK;
2233 %constant wxEventType wxEVT_GRID_CELL_LEFT_DCLICK;
2234 %constant wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK;
2235 %constant wxEventType wxEVT_GRID_LABEL_LEFT_CLICK;
2236 %constant wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK;
2237 %constant wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK;
2238 %constant wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK;
2239 %constant wxEventType wxEVT_GRID_ROW_SIZE;
2240 %constant wxEventType wxEVT_GRID_COL_SIZE;
2241 %constant wxEventType wxEVT_GRID_RANGE_SELECT;
2242 %constant wxEventType wxEVT_GRID_CELL_CHANGE;
2243 %constant wxEventType wxEVT_GRID_SELECT_CELL;
2244 %constant wxEventType wxEVT_GRID_EDITOR_SHOWN;
2245 %constant wxEventType wxEVT_GRID_EDITOR_HIDDEN;
2246 %constant wxEventType wxEVT_GRID_EDITOR_CREATED;
2247 %constant wxEventType wxEVT_GRID_CELL_BEGIN_DRAG;
2252 EVT_GRID_CELL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_CLICK )
2253 EVT_GRID_CELL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_CLICK )
2254 EVT_GRID_CELL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_DCLICK )
2255 EVT_GRID_CELL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_DCLICK )
2256 EVT_GRID_LABEL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_CLICK )
2257 EVT_GRID_LABEL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_CLICK )
2258 EVT_GRID_LABEL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_DCLICK )
2259 EVT_GRID_LABEL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_DCLICK )
2260 EVT_GRID_ROW_SIZE = wx.PyEventBinder( wxEVT_GRID_ROW_SIZE )
2261 EVT_GRID_COL_SIZE = wx.PyEventBinder( wxEVT_GRID_COL_SIZE )
2262 EVT_GRID_RANGE_SELECT = wx.PyEventBinder( wxEVT_GRID_RANGE_SELECT )
2263 EVT_GRID_CELL_CHANGE = wx.PyEventBinder( wxEVT_GRID_CELL_CHANGE )
2264 EVT_GRID_SELECT_CELL = wx.PyEventBinder( wxEVT_GRID_SELECT_CELL )
2265 EVT_GRID_EDITOR_SHOWN = wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN )
2266 EVT_GRID_EDITOR_HIDDEN = wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN )
2267 EVT_GRID_EDITOR_CREATED = wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED )
2268 EVT_GRID_CELL_BEGIN_DRAG = wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG )
2271 %# The same as above but with the ability to specify an identifier
2272 EVT_GRID_CMD_CELL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_CLICK, 1 )
2273 EVT_GRID_CMD_CELL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_CLICK, 1 )
2274 EVT_GRID_CMD_CELL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_DCLICK, 1 )
2275 EVT_GRID_CMD_CELL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_DCLICK, 1 )
2276 EVT_GRID_CMD_LABEL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_CLICK, 1 )
2277 EVT_GRID_CMD_LABEL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_CLICK, 1 )
2278 EVT_GRID_CMD_LABEL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_DCLICK, 1 )
2279 EVT_GRID_CMD_LABEL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_DCLICK, 1 )
2280 EVT_GRID_CMD_ROW_SIZE = wx.PyEventBinder( wxEVT_GRID_ROW_SIZE, 1 )
2281 EVT_GRID_CMD_COL_SIZE = wx.PyEventBinder( wxEVT_GRID_COL_SIZE, 1 )
2282 EVT_GRID_CMD_RANGE_SELECT = wx.PyEventBinder( wxEVT_GRID_RANGE_SELECT, 1 )
2283 EVT_GRID_CMD_CELL_CHANGE = wx.PyEventBinder( wxEVT_GRID_CELL_CHANGE, 1 )
2284 EVT_GRID_CMD_SELECT_CELL = wx.PyEventBinder( wxEVT_GRID_SELECT_CELL, 1 )
2285 EVT_GRID_CMD_EDITOR_SHOWN = wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN, 1 )
2286 EVT_GRID_CMD_EDITOR_HIDDEN = wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN, 1 )
2287 EVT_GRID_CMD_EDITOR_CREATED = wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED, 1 )
2288 EVT_GRID_CMD_CELL_BEGIN_DRAG = wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG, 1 )
2292 //---------------------------------------------------------------------------
2297 //---------------------------------------------------------------------------
2298 //---------------------------------------------------------------------------