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 /////////////////////////////////////////////////////////////////////////////
 
  16 #include "wx/wxPython/wxPython.h"
 
  17 #include "wx/wxPython/pyclasses.h"
 
  18 #include "wx/wxPython/printfw.h"
 
  21 #include <wx/generic/gridctrl.h>
 
  26 //---------------------------------------------------------------------------
 
  29 %pythoncode { wx = _core }
 
  30 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
 
  33 %include _grid_rename.i
 
  35 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
 
  36 MAKE_CONST_WXSTRING_NOSWIG(PanelNameStr);
 
  37 MAKE_CONST_WXSTRING2(DateTimeFormatStr, wxT("%c"));
 
  40 //---------------------------------------------------------------------------
 
  41 // OOR related typemaps and helper functions
 
  43 %typemap(out) wxGridCellRenderer*     { $result = wxPyMake_wxGridCellRenderer($1); }
 
  44 %typemap(out) wxGridCellEditor*       { $result = wxPyMake_wxGridCellEditor($1); }
 
  45 %typemap(out) wxGridCellAttr*         { $result = wxPyMake_wxGridCellAttr($1); }
 
  46 %typemap(out) wxGridCellAttrProvider* { $result = wxPyMake_wxGridCellAttrProvider($1); }
 
  47 %typemap(out) wxGridTableBase*        { $result = wxPyMake_wxGridTableBase($1); }
 
  52 #define wxPyMake_TEMPLATE(TYPE) \
 
  53 PyObject* wxPyMake_##TYPE(TYPE* source) { \
 
  54     PyObject* target = NULL; \
 
  56         /* Check if there is already a pointer to a Python object in the \
 
  57            OOR data that we can use. */ \
 
  58         wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \
 
  60             target = data->m_obj; \
 
  63         /* Otherwise make a new wrapper for it the old fashioned way and \
 
  64            give it the OOR treatment */ \
 
  66             target = wxPyConstructObject(source, wxT(#TYPE), False); \
 
  68                 source->SetClientObject(new wxPyOORClientData(target)); \
 
  70     } else {  /* source was NULL so return None. */ \
 
  71         Py_INCREF(Py_None); target = Py_None; \
 
  77 wxPyMake_TEMPLATE(wxGridCellRenderer)
 
  78 wxPyMake_TEMPLATE(wxGridCellEditor)
 
  79 wxPyMake_TEMPLATE(wxGridCellAttr)
 
  80 wxPyMake_TEMPLATE(wxGridCellAttrProvider)
 
  81 wxPyMake_TEMPLATE(wxGridTableBase)
 
  85 //---------------------------------------------------------------------------
 
  86 // Macros, similar to what's in helpers.h, to aid in the creation of
 
  87 // virtual methods that are able to make callbacks to Python.  Many of these
 
  88 // are specific to wxGrid and so are kept here to reduce the mess in helpers.h
 
  93 #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME)                               \
 
  94     wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) {        \
 
  95         wxGridCellAttr* rval = NULL;                                            \
 
  97         bool blocked = wxPyBeginBlockThreads();                            \
 
  98         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 100             wxGridCellAttr* ptr;                                                \
 
 101             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \
 
 103                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellAttr")))    \
 
 108         wxPyEndBlockThreads(blocked);                                             \
 
 110             rval = PCLASS::CBNAME(a, b, c);                                     \
 
 113     wxGridCellAttr *base_##CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \
 
 114         return PCLASS::CBNAME(a, b, c);                                         \
 
 119 #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME)                                   \
 
 120     void CBNAME(wxGridCellAttr *attr, int a, int b) {                           \
 
 121         bool blocked = wxPyBeginBlockThreads();                                                \
 
 123         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 124             PyObject* obj = wxPyMake_wxGridCellAttr(attr);                      \
 
 125             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b));  \
 
 128         wxPyEndBlockThreads(blocked);                                                  \
 
 130             PCLASS::CBNAME(attr, a, b);                                         \
 
 132     void base_##CBNAME(wxGridCellAttr *attr, int a, int b) {                    \
 
 133         PCLASS::CBNAME(attr, a, b);                                             \
 
 138 #define PYCALLBACK__GCAINT(PCLASS, CBNAME)                                      \
 
 139     void CBNAME(wxGridCellAttr *attr, int val) {                                \
 
 140         bool blocked = wxPyBeginBlockThreads();                                                \
 
 142         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 143             PyObject* obj = wxPyMake_wxGridCellAttr(attr);                      \
 
 144             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val));    \
 
 147         wxPyEndBlockThreads(blocked);                                             \
 
 149             PCLASS::CBNAME(attr, val);                                          \
 
 151     void base_##CBNAME(wxGridCellAttr *attr, int val) {                         \
 
 152         PCLASS::CBNAME(attr, val);                                              \
 
 157 #define PYCALLBACK_INT__pure(CBNAME)                                            \
 
 159         bool blocked = wxPyBeginBlockThreads();                            \
 
 161         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                            \
 
 162             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \
 
 163         wxPyEndBlockThreads(blocked);                                             \
 
 169 #define PYCALLBACK_BOOL_INTINT_pure(CBNAME)                                     \
 
 170     bool CBNAME(int a, int b) {                                                 \
 
 171         bool blocked = wxPyBeginBlockThreads();                            \
 
 173         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                            \
 
 174             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b));   \
 
 175         wxPyEndBlockThreads(blocked);                                             \
 
 180 #define PYCALLBACK_STRING_INTINT_pure(CBNAME)                                   \
 
 181     wxString CBNAME(int a, int b) {                                             \
 
 182         bool blocked = wxPyBeginBlockThreads();                                                \
 
 184         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
 
 186             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));  \
 
 188                 rval = Py2wxString(ro);                                         \
 
 192         wxPyEndBlockThreads(blocked);                                                  \
 
 197 #define PYCALLBACK__INTINTSTRING_pure(CBNAME)                                   \
 
 198     void CBNAME(int a, int b, const wxString& c) {                              \
 
 199         bool blocked = wxPyBeginBlockThreads();                                                \
 
 200         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
 
 201             PyObject* s = wx2PyString(c);                                       \
 
 202             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
 
 205         wxPyEndBlockThreads(blocked);                                                  \
 
 209 #define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME)                                \
 
 210     wxString CBNAME(int a, int b) {                                             \
 
 212         bool blocked = wxPyBeginBlockThreads();                                                \
 
 214         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 216             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));  \
 
 218                 rval = Py2wxString(ro);                                         \
 
 222         wxPyEndBlockThreads(blocked);                                                  \
 
 224             rval = PCLASS::CBNAME(a, b);                                        \
 
 227     wxString base_##CBNAME(int a, int b) {                                      \
 
 228         return PCLASS::CBNAME(a, b);                                            \
 
 232 #define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME)                            \
 
 233     bool CBNAME(int a, int b, const wxString& c)  {                             \
 
 236         bool blocked = wxPyBeginBlockThreads();                                                \
 
 237         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 238             PyObject* s = wx2PyString(c);                                       \
 
 239             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
 
 242         wxPyEndBlockThreads(blocked);                                                  \
 
 244             rval = PCLASS::CBNAME(a,b,c);                                       \
 
 247     bool base_##CBNAME(int a, int b, const wxString& c) {                       \
 
 248         return PCLASS::CBNAME(a,b,c);                                           \
 
 254 #define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME)                                  \
 
 255     long CBNAME(int a, int b)  {                                                \
 
 258         bool blocked = wxPyBeginBlockThreads();                            \
 
 259         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 260             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));  \
 
 261         wxPyEndBlockThreads(blocked);                                             \
 
 263             rval = PCLASS::CBNAME(a,b);                                         \
 
 266     long base_##CBNAME(int a, int b) {                                          \
 
 267         return PCLASS::CBNAME(a,b);                                             \
 
 272 #define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME)                                  \
 
 273     bool CBNAME(int a, int b)  {                                                \
 
 276         bool blocked = wxPyBeginBlockThreads();                            \
 
 277         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 278             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));  \
 
 279         wxPyEndBlockThreads(blocked);                                             \
 
 281             rval = PCLASS::CBNAME(a,b);                                         \
 
 284     bool base_##CBNAME(int a, int b) {                                          \
 
 285         return PCLASS::CBNAME(a,b);                                             \
 
 290 #define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME)                                \
 
 291     double CBNAME(int a, int b) {                                               \
 
 293         bool blocked = wxPyBeginBlockThreads();                            \
 
 295         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 297             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));  \
 
 299                 PyObject* str = PyObject_Str(ro);                               \
 
 300                 rval = PyFloat_AsDouble(str);                                   \
 
 301                 Py_DECREF(ro);   Py_DECREF(str);                                \
 
 304         wxPyEndBlockThreads(blocked);                                                  \
 
 306             rval = PCLASS::CBNAME(a, b);                                        \
 
 309     double base_##CBNAME(int a, int b) {                                        \
 
 310         return PCLASS::CBNAME(a, b);                                            \
 
 315 #define PYCALLBACK__(PCLASS, CBNAME)                                            \
 
 318         bool blocked = wxPyBeginBlockThreads();                                                \
 
 319         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 320             wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));                \
 
 321         wxPyEndBlockThreads(blocked);                                                  \
 
 325     void base_##CBNAME() {                                                      \
 
 332 #define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME)                              \
 
 333     bool CBNAME(size_t a, size_t b)  {                                          \
 
 336         bool blocked = wxPyBeginBlockThreads();                                                \
 
 337         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 338             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));  \
 
 339         wxPyEndBlockThreads(blocked);                                                  \
 
 341             rval = PCLASS::CBNAME(a,b);                                         \
 
 344     bool base_##CBNAME(size_t a, size_t b) {                                    \
 
 345         return PCLASS::CBNAME(a,b);                                             \
 
 350 #define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME)                                   \
 
 351     bool CBNAME(size_t a)  {                                                    \
 
 354         bool blocked = wxPyBeginBlockThreads();                                                \
 
 355         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 356             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));     \
 
 357         wxPyEndBlockThreads(blocked);                                                  \
 
 359             rval = PCLASS::CBNAME(a);                                           \
 
 362     bool base_##CBNAME(size_t a) {                                              \
 
 363         return PCLASS::CBNAME(a);                                               \
 
 367 #define PYCALLBACK_STRING_INT(PCLASS, CBNAME)                                   \
 
 368     wxString CBNAME(int a) {                                                    \
 
 370         bool blocked = wxPyBeginBlockThreads();                                                \
 
 372         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 374             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a));     \
 
 376                 rval = Py2wxString(ro);                                         \
 
 380         wxPyEndBlockThreads(blocked);                                                  \
 
 382             rval = PCLASS::CBNAME(a);                                           \
 
 385     wxString base_##CBNAME(int a) {                                             \
 
 386         return PCLASS::CBNAME(a);                                               \
 
 390 #define PYCALLBACK__INTSTRING(PCLASS, CBNAME)                                   \
 
 391     void CBNAME(int a, const wxString& c)  {                                    \
 
 393         bool blocked = wxPyBeginBlockThreads();                                                \
 
 394         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 395             PyObject* s = wx2PyString(c);                                       \
 
 396             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)",a,s));          \
 
 399         wxPyEndBlockThreads(blocked);                                                  \
 
 401             PCLASS::CBNAME(a,c);                                                \
 
 403     void base_##CBNAME(int a, const wxString& c) {                              \
 
 404         PCLASS::CBNAME(a,c);                                                    \
 
 410 #define PYCALLBACK_BOOL_(PCLASS, CBNAME)                                        \
 
 414         bool blocked = wxPyBeginBlockThreads();                                                \
 
 415         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 416             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \
 
 417         wxPyEndBlockThreads(blocked);                                                  \
 
 419             rval = PCLASS::CBNAME();                                            \
 
 422     bool base_##CBNAME() {                                                      \
 
 423         return PCLASS::CBNAME();                                                \
 
 428 #define PYCALLBACK__SIZETINT(PCLASS, CBNAME)                                    \
 
 429     void CBNAME(size_t a, int b)  {                                             \
 
 431         bool blocked = wxPyBeginBlockThreads();                                                \
 
 432         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 433             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));         \
 
 434         wxPyEndBlockThreads(blocked);                                                  \
 
 436             PCLASS::CBNAME(a,b);                                                \
 
 438     void base_##CBNAME(size_t a, int b) {                                       \
 
 439         PCLASS::CBNAME(a,b);                                                    \
 
 445 #define PYCALLBACK__INTINTLONG(PCLASS, CBNAME)                                  \
 
 446     void CBNAME(int a, int b, long c)  {                                        \
 
 448         bool blocked = wxPyBeginBlockThreads();                                                \
 
 449         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 450             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));      \
 
 451         wxPyEndBlockThreads(blocked);                                                  \
 
 453             PCLASS::CBNAME(a,b,c);                                              \
 
 455     void base_##CBNAME(int a, int b, long c) {                                  \
 
 456         PCLASS::CBNAME(a,b,c);                                                  \
 
 462 #define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME)                                \
 
 463     void CBNAME(int a, int b, double c)  {                                      \
 
 465         bool blocked = wxPyBeginBlockThreads();                                                \
 
 466         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 467             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c));      \
 
 468         wxPyEndBlockThreads(blocked);                                                  \
 
 470             PCLASS::CBNAME(a,b,c);                                              \
 
 472     void base_##CBNAME(int a, int b, double c) {                                \
 
 473         PCLASS::CBNAME(a,b,c);                                                  \
 
 478 #define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME)                                  \
 
 479     void CBNAME(int a, int b, bool c)  {                                        \
 
 481         bool blocked = wxPyBeginBlockThreads();                                                \
 
 482         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 483             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));      \
 
 484         wxPyEndBlockThreads(blocked);                                                  \
 
 486             PCLASS::CBNAME(a,b,c);                                              \
 
 488     void base_##CBNAME(int a, int b, bool c) {                                  \
 
 489         PCLASS::CBNAME(a,b,c);                                                  \
 
 497 //---------------------------------------------------------------------------
 
 499 class wxGridCellCoords;
 
 500 class wxGridCellAttr;
 
 502 #define wxGRID_VALUE_STRING     "string"
 
 503 #define wxGRID_VALUE_BOOL       "bool"
 
 504 #define wxGRID_VALUE_NUMBER     "long"
 
 505 #define wxGRID_VALUE_FLOAT      "double"
 
 506 #define wxGRID_VALUE_CHOICE     "choice"
 
 507 #define wxGRID_VALUE_TEXT       "string"
 
 508 #define wxGRID_VALUE_LONG       "long"
 
 509 #define wxGRID_VALUE_CHOICEINT  "choiceint"
 
 510 #define wxGRID_VALUE_DATETIME   "datetime"
 
 514 const wxGridCellCoords wxGridNoCellCoords;
 
 515 const wxRect           wxGridNoCellRect;
 
 519 //---------------------------------------------------------------------------
 
 520 // wxGridCellRenderer is an ABC, and several derived classes are available.
 
 521 // Classes implemented in Python should be derived from wxPyGridCellRenderer.
 
 524 class wxGridCellRenderer
 
 528         void _setOORInfo(PyObject* _self) {
 
 529             self->SetClientObject(new wxPyOORClientData(_self));
 
 533     void SetParameters(const wxString& params);
 
 537     virtual void Draw(wxGrid& grid,
 
 538                       wxGridCellAttr& attr,
 
 543     virtual wxSize GetBestSize(wxGrid& grid,
 
 544                                wxGridCellAttr& attr,
 
 547     virtual wxGridCellRenderer *Clone() const;
 
 551 // The C++ version of wxPyGridCellRenderer
 
 553 class wxPyGridCellRenderer : public wxGridCellRenderer
 
 556     wxPyGridCellRenderer() : wxGridCellRenderer() {};
 
 558     // Implement Python callback aware virtual methods
 
 559     void Draw(wxGrid& grid, wxGridCellAttr& attr,
 
 560               wxDC& dc, const wxRect& rect,
 
 561               int row, int col, bool isSelected) {
 
 562         bool blocked = wxPyBeginBlockThreads();
 
 563         if (wxPyCBH_findCallback(m_myInst, "Draw")) {
 
 564             PyObject* go = wxPyMake_wxObject(&grid);
 
 565             PyObject* dco = wxPyMake_wxObject(&dc);
 
 566             PyObject* ao = wxPyMake_wxGridCellAttr(&attr);
 
 567             PyObject* ro = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
 
 569             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOiii)", go, ao, dco, ro,
 
 570                                                          row, col, isSelected));
 
 576         wxPyEndBlockThreads(blocked);
 
 579     wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
 
 582         bool blocked = wxPyBeginBlockThreads();
 
 583         if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) {
 
 586             PyObject* go = wxPyMake_wxObject(&grid);
 
 587             PyObject* dco = wxPyMake_wxObject(&dc);
 
 588             PyObject* ao = wxPyMake_wxGridCellAttr(&attr);
 
 590             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOii)",
 
 598                 const char* errmsg = "GetBestSize should return a 2-tuple of integers or a wxSize object.";
 
 599                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) {
 
 602                 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) {
 
 603                     PyObject* o1 = PySequence_GetItem(ro, 0);
 
 604                     PyObject* o2 = PySequence_GetItem(ro, 1);
 
 605                     if (PyNumber_Check(o1) && PyNumber_Check(o2))
 
 606                         rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2));
 
 608                         PyErr_SetString(PyExc_TypeError, errmsg);
 
 613                     PyErr_SetString(PyExc_TypeError, errmsg);
 
 618         wxPyEndBlockThreads(blocked);
 
 623     wxGridCellRenderer *Clone() const {
 
 624         wxGridCellRenderer* rval = NULL;
 
 625         bool blocked = wxPyBeginBlockThreads();
 
 626         if (wxPyCBH_findCallback(m_myInst, "Clone")) {
 
 628             wxGridCellRenderer* ptr;
 
 629             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 631                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellRenderer")))
 
 636         wxPyEndBlockThreads(blocked);
 
 640     DEC_PYCALLBACK__STRING(SetParameters);
 
 645 IMP_PYCALLBACK__STRING( wxPyGridCellRenderer, wxGridCellRenderer, SetParameters);
 
 650 // Let SWIG know about it so it can create the Python version
 
 651 class wxPyGridCellRenderer : public wxGridCellRenderer {
 
 653     %pythonAppend wxPyGridCellRenderer  "self._setCallbackInfo(self, PyGridCellRenderer);self._setOORInfo(self)"
 
 655     wxPyGridCellRenderer();
 
 656     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 658     void base_SetParameters(const wxString& params);
 
 661 //---------------------------------------------------------------------------
 
 662 //  Predefined Renderers
 
 664 class wxGridCellStringRenderer : public wxGridCellRenderer
 
 667     %pythonAppend wxGridCellStringRenderer "self._setOORInfo(self)"
 
 668     wxGridCellStringRenderer();
 
 672 class  wxGridCellNumberRenderer : public wxGridCellStringRenderer
 
 675     %pythonAppend wxGridCellNumberRenderer "self._setOORInfo(self)"
 
 676     wxGridCellNumberRenderer();
 
 680 class  wxGridCellFloatRenderer : public wxGridCellStringRenderer
 
 683     %pythonAppend wxGridCellFloatRenderer "self._setOORInfo(self)"
 
 684     wxGridCellFloatRenderer(int width = -1, int precision = -1);
 
 686     int GetWidth() const;
 
 687     void SetWidth(int width);
 
 688     int GetPrecision() const;
 
 689     void SetPrecision(int precision);
 
 693 class  wxGridCellBoolRenderer : public wxGridCellRenderer
 
 696     %pythonAppend wxGridCellBoolRenderer "self._setOORInfo(self)"
 
 697     wxGridCellBoolRenderer();
 
 701 class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
 
 704     %pythonAppend wxGridCellDateTimeRenderer "self._setOORInfo(self)"
 
 705     wxGridCellDateTimeRenderer(wxString outformat = wxPyDateTimeFormatStr,
 
 706                                wxString informat =  wxPyDateTimeFormatStr);
 
 710 class wxGridCellEnumRenderer : public wxGridCellStringRenderer
 
 713     %pythonAppend wxGridCellEnumRenderer "self._setOORInfo(self)"
 
 714     wxGridCellEnumRenderer( const wxString& choices = wxPyEmptyString );
 
 718 class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
 
 721     %pythonAppend wxGridCellAutoWrapStringRenderer "self._setOORInfo(self)"
 
 722     wxGridCellAutoWrapStringRenderer();
 
 726 //---------------------------------------------------------------------------
 
 727 // wxGridCellEditor is an ABC, and several derived classes are available.
 
 728 // Classes implemented in Python should be derived from wxPyGridCellEditor.
 
 730 class  wxGridCellEditor
 
 734         void _setOORInfo(PyObject* _self) {
 
 735             self->SetClientObject(new wxPyOORClientData(_self));
 
 740     wxControl* GetControl();
 
 741     void SetControl(wxControl* control);
 
 743     wxGridCellAttr* GetCellAttr();
 
 744     void SetCellAttr(wxGridCellAttr* attr);
 
 746     void SetParameters(const wxString& params);
 
 750     virtual void Create(wxWindow* parent,
 
 752                         wxEvtHandler* evtHandler);
 
 753     virtual void BeginEdit(int row, int col, wxGrid* grid);
 
 754     virtual bool EndEdit(int row, int col, wxGrid* grid);
 
 755     virtual void Reset();
 
 756     virtual wxGridCellEditor *Clone() const;
 
 758     virtual void SetSize(const wxRect& rect);
 
 759     virtual void Show(bool show, wxGridCellAttr *attr = NULL);
 
 760     virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
 
 761     virtual bool IsAcceptedKey(wxKeyEvent& event);
 
 762     virtual void StartingKey(wxKeyEvent& event);
 
 763     virtual void StartingClick();
 
 764     virtual void HandleReturn(wxKeyEvent& event);
 
 765     virtual void Destroy();
 
 770 // The C++ version of wxPyGridCellEditor
 
 772 class wxPyGridCellEditor : public wxGridCellEditor
 
 775     wxPyGridCellEditor() : wxGridCellEditor() {}
 
 777     void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
 
 778         bool blocked = wxPyBeginBlockThreads();
 
 779         if (wxPyCBH_findCallback(m_myInst, "Create")) {
 
 780             PyObject* po = wxPyMake_wxObject(parent);
 
 781             PyObject* eo = wxPyMake_wxObject(evtHandler);
 
 783             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", po, id, eo));
 
 787         wxPyEndBlockThreads(blocked);
 
 791     void BeginEdit(int row, int col, wxGrid* grid) {
 
 792         bool blocked = wxPyBeginBlockThreads();
 
 793         if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) {
 
 794             PyObject* go = wxPyMake_wxObject(grid);
 
 795             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
 
 798         wxPyEndBlockThreads(blocked);
 
 802     bool EndEdit(int row, int col, wxGrid* grid) {
 
 804         bool blocked = wxPyBeginBlockThreads();
 
 805         if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
 
 806             PyObject* go = wxPyMake_wxObject(grid);
 
 807             rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
 
 810         wxPyEndBlockThreads(blocked);
 
 815     wxGridCellEditor* Clone() const {
 
 816         wxGridCellEditor* rval = NULL;
 
 817         bool blocked = wxPyBeginBlockThreads();
 
 818         if (wxPyCBH_findCallback(m_myInst, "Clone")) {
 
 820             wxGridCellEditor* ptr;
 
 821             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 823                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellEditor")))
 
 828         wxPyEndBlockThreads(blocked);
 
 833     void Show(bool show, wxGridCellAttr *attr) {
 
 835         bool blocked = wxPyBeginBlockThreads();
 
 836         if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) {
 
 837             PyObject* ao = wxPyMake_wxGridCellAttr(attr);
 
 838             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", show, ao));
 
 841         wxPyEndBlockThreads(blocked);
 
 843             wxGridCellEditor::Show(show, attr);
 
 845     void base_Show(bool show, wxGridCellAttr *attr) {
 
 846         wxGridCellEditor::Show(show, attr);
 
 850     void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
 
 852         bool blocked = wxPyBeginBlockThreads();
 
 853         if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) {
 
 854             PyObject* ao = wxPyMake_wxGridCellAttr(attr);
 
 855             PyObject* ro = wxPyConstructObject((void*)&rectCell, wxT("wxRect"), 0);
 
 857             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", ro, ao));
 
 862         wxPyEndBlockThreads(blocked);
 
 864             wxGridCellEditor::PaintBackground(rectCell, attr);
 
 866     void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
 
 867         wxGridCellEditor::PaintBackground(rectCell, attr);
 
 871     DEC_PYCALLBACK___pure(Reset);
 
 872     DEC_PYCALLBACK__constany(SetSize, wxRect);
 
 873     DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent);
 
 874     DEC_PYCALLBACK__any(StartingKey, wxKeyEvent);
 
 875     DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent);
 
 876     DEC_PYCALLBACK__(StartingClick);
 
 877     DEC_PYCALLBACK__(Destroy);
 
 878     DEC_PYCALLBACK__STRING(SetParameters);
 
 879     DEC_PYCALLBACK_STRING__constpure(GetValue);
 
 885 IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters);
 
 886 IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset);
 
 887 IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect);
 
 888 IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent);
 
 889 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent);
 
 890 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent);
 
 891 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick);
 
 892 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, Destroy);
 
 893 IMP_PYCALLBACK_STRING__constpure(wxPyGridCellEditor, wxGridCellEditor, GetValue);
 
 898 // Let SWIG know about it so it can create the Python version
 
 899 class wxPyGridCellEditor : public wxGridCellEditor {
 
 901     %pythonAppend wxPyGridCellEditor  "self._setCallbackInfo(self, PyGridCellEditor);self._setOORInfo(self)"
 
 903     wxPyGridCellEditor();
 
 904     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 906     void base_SetSize(const wxRect& rect);
 
 907     void base_Show(bool show, wxGridCellAttr *attr = NULL);
 
 908     void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
 
 909     bool base_IsAcceptedKey(wxKeyEvent& event);
 
 910     void base_StartingKey(wxKeyEvent& event);
 
 911     void base_StartingClick();
 
 912     void base_HandleReturn(wxKeyEvent& event);
 
 914     void base_SetParameters(const wxString& params);
 
 917 //---------------------------------------------------------------------------
 
 918 //  Predefined Editors
 
 920 class wxGridCellTextEditor : public wxGridCellEditor
 
 923     %pythonAppend wxGridCellTextEditor  "self._setOORInfo(self)"
 
 924     wxGridCellTextEditor();
 
 925     virtual wxString GetValue();
 
 929 class wxGridCellNumberEditor : public wxGridCellTextEditor
 
 932     %pythonAppend wxGridCellNumberEditor  "self._setOORInfo(self)"
 
 933     wxGridCellNumberEditor(int min = -1, int max = -1);
 
 934     virtual wxString GetValue();
 
 938 class wxGridCellFloatEditor : public wxGridCellTextEditor
 
 941     %pythonAppend wxGridCellFloatEditor  "self._setOORInfo(self)"
 
 942     wxGridCellFloatEditor(int width = -1, int precision = -1);
 
 943     virtual wxString GetValue();
 
 947 class wxGridCellBoolEditor : public wxGridCellEditor
 
 950     %pythonAppend wxGridCellBoolEditor  "self._setOORInfo(self)"
 
 951     wxGridCellBoolEditor();
 
 952     virtual wxString GetValue();
 
 955 class wxGridCellChoiceEditor : public wxGridCellEditor
 
 958     %pythonAppend wxGridCellChoiceEditor  "self._setOORInfo(self)"
 
 959     wxGridCellChoiceEditor(int choices = 0,
 
 960                            const wxString* choices_array = NULL,
 
 961                            bool allowOthers = False);
 
 962     virtual wxString GetValue();
 
 966 class wxGridCellEnumEditor : public wxGridCellChoiceEditor
 
 969     %pythonAppend wxGridCellEnumEditor  "self._setOORInfo(self)"
 
 970     wxGridCellEnumEditor( const wxString& choices = wxPyEmptyString );
 
 971     virtual wxString GetValue();
 
 975 class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
 
 978     %pythonAppend wxGridCellAutoWrapStringEditor  "self._setOORInfo(self)"
 
 979     wxGridCellAutoWrapStringEditor();
 
 980     virtual wxString GetValue();
 
 985 //---------------------------------------------------------------------------
 
1002         void _setOORInfo(PyObject* _self) {
 
1003             self->SetClientObject(new wxPyOORClientData(_self));
 
1007     %pythonAppend wxGridCellAttr  "self._setOORInfo(self)"
 
1009     wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
 
1011     wxGridCellAttr *Clone() const;
 
1012     void MergeWith(wxGridCellAttr *mergefrom);
 
1015     void SetTextColour(const wxColour& colText);
 
1016     void SetBackgroundColour(const wxColour& colBack);
 
1017     void SetFont(const wxFont& font);
 
1018     void SetAlignment(int hAlign, int vAlign);
 
1019     void SetSize(int num_rows, int num_cols);
 
1020     void SetOverflow( bool allow = True );
 
1021     void SetReadOnly(bool isReadOnly = True);
 
1023     void SetRenderer(wxGridCellRenderer *renderer);
 
1024     void SetEditor(wxGridCellEditor* editor);
 
1025     void SetKind(wxAttrKind kind);
 
1027     bool HasTextColour() const;
 
1028     bool HasBackgroundColour() const;
 
1029     bool HasFont() const;
 
1030     bool HasAlignment() const;
 
1031     bool HasRenderer() const;
 
1032     bool HasEditor() const;
 
1033     bool HasReadWriteMode() const;
 
1034     bool HasOverflowMode() const;
 
1036     wxColour GetTextColour() const;
 
1037     wxColour GetBackgroundColour() const;
 
1038     wxFont GetFont() const;
 
1041         void, GetAlignment(int *OUTPUT, int *OUTPUT) const,
 
1042         "GetAlignment() -> (hAlign, vAlign)");
 
1045         void, GetSize(int *OUTPUT, int *OUTPUT) const,
 
1046         "GetSize() -> (num_rows, num_cols)");
 
1048     bool GetOverflow() const;
 
1049     wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
 
1050     wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
 
1052     bool IsReadOnly() const;
 
1053     void SetDefAttr(wxGridCellAttr* defAttr);
 
1056 //---------------------------------------------------------------------------
 
1058 class wxGridCellAttrProvider
 
1061     %pythonAppend wxGridCellAttrProvider "self._setOORInfo(self)"
 
1062     wxGridCellAttrProvider();
 
1063     // ???? virtual ~wxGridCellAttrProvider();
 
1066         void _setOORInfo(PyObject* _self) {
 
1067             self->SetClientObject(new wxPyOORClientData(_self));
 
1071     wxGridCellAttr *GetAttr(int row, int col,
 
1072                             wxGridCellAttr::wxAttrKind  kind) const;
 
1073     void SetAttr(wxGridCellAttr *attr, int row, int col);
 
1074     void SetRowAttr(wxGridCellAttr *attr, int row);
 
1075     void SetColAttr(wxGridCellAttr *attr, int col);
 
1077     void UpdateAttrRows( size_t pos, int numRows );
 
1078     void UpdateAttrCols( size_t pos, int numCols );
 
1083 // A Python-aware version
 
1085 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
 
1088     wxPyGridCellAttrProvider() : wxGridCellAttrProvider() {};
 
1090     PYCALLBACK_GCA_INTINTKIND(wxGridCellAttrProvider, GetAttr);
 
1091     PYCALLBACK__GCAINTINT(wxGridCellAttrProvider, SetAttr);
 
1092     PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetRowAttr);
 
1093     PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetColAttr);
 
1100 // The python-aware version get's SWIGified
 
1101 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
 
1104     %pythonAppend wxPyGridCellAttrProvider  "self._setCallbackInfo(self, PyGridCellAttrProvider)"
 
1105     wxPyGridCellAttrProvider();
 
1106     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
1108     wxGridCellAttr *base_GetAttr(int row, int col,
 
1109                                  wxGridCellAttr::wxAttrKind kind);
 
1110     void base_SetAttr(wxGridCellAttr *attr, int row, int col);
 
1111     void base_SetRowAttr(wxGridCellAttr *attr, int row);
 
1112     void base_SetColAttr(wxGridCellAttr *attr, int col);
 
1116 //---------------------------------------------------------------------------
 
1117 // Grid Table Base class and Python aware version
 
1120 class wxGridTableBase : public wxObject
 
1123     // wxGridTableBase();   This is an ABC
 
1124     //~wxGridTableBase();
 
1127         void _setOORInfo(PyObject* _self) {
 
1128             self->SetClientObject(new wxPyOORClientData(_self));
 
1132     void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
 
1133     wxGridCellAttrProvider *GetAttrProvider() const;
 
1134     void SetView( wxGrid *grid );
 
1135     wxGrid * GetView() const;
 
1139     virtual int GetNumberRows();
 
1140     virtual int GetNumberCols();
 
1141     virtual bool IsEmptyCell( int row, int col );
 
1142     virtual wxString GetValue( int row, int col );
 
1143     virtual void SetValue( int row, int col, const wxString& value );
 
1145     // virtuals overridable in wxPyGridTableBase
 
1146     virtual wxString GetTypeName( int row, int col );
 
1147     virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
 
1148     virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
 
1149     virtual long GetValueAsLong( int row, int col );
 
1150     virtual double GetValueAsDouble( int row, int col );
 
1151     virtual bool GetValueAsBool( int row, int col );
 
1152     virtual void SetValueAsLong( int row, int col, long value );
 
1153     virtual void SetValueAsDouble( int row, int col, double value );
 
1154     virtual void SetValueAsBool( int row, int col, bool value );
 
1156     //virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
 
1157     //virtual void  SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
 
1160     virtual void Clear();
 
1161     virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
 
1162     virtual bool AppendRows( size_t numRows = 1 );
 
1163     virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
 
1164     virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
 
1165     virtual bool AppendCols( size_t numCols = 1 );
 
1166     virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
 
1168     virtual wxString GetRowLabelValue( int row );
 
1169     virtual wxString GetColLabelValue( int col );
 
1170     virtual void SetRowLabelValue( int row, const wxString& value );
 
1171     virtual void SetColLabelValue( int col, const wxString& value );
 
1173     virtual bool CanHaveAttributes();
 
1175     virtual wxGridCellAttr *GetAttr( int row, int col,
 
1176                                      wxGridCellAttr::wxAttrKind  kind);
 
1177     virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
 
1178     virtual void SetRowAttr(wxGridCellAttr *attr, int row);
 
1179     virtual void SetColAttr(wxGridCellAttr *attr, int col);
 
1185 // Python-aware version
 
1187 class wxPyGridTableBase : public wxGridTableBase
 
1190     wxPyGridTableBase() : wxGridTableBase() {}
 
1192     PYCALLBACK_INT__pure(GetNumberRows);
 
1193     PYCALLBACK_INT__pure(GetNumberCols);
 
1194     PYCALLBACK_BOOL_INTINT_pure(IsEmptyCell);
 
1195     PYCALLBACK_STRING_INTINT(wxGridTableBase, GetTypeName);
 
1196     PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanGetValueAs);
 
1197     PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanSetValueAs);
 
1198     PYCALLBACK__(wxGridTableBase, Clear);
 
1199     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertRows);
 
1200     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteRows);
 
1201     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertCols);
 
1202     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteCols);
 
1203     PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendRows);
 
1204     PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendCols);
 
1205     PYCALLBACK_STRING_INT(wxGridTableBase, GetRowLabelValue);
 
1206     PYCALLBACK_STRING_INT(wxGridTableBase, GetColLabelValue);
 
1207     PYCALLBACK__INTSTRING(wxGridTableBase, SetRowLabelValue);
 
1208     PYCALLBACK__INTSTRING(wxGridTableBase, SetColLabelValue);
 
1209     PYCALLBACK_BOOL_(wxGridTableBase, CanHaveAttributes);
 
1210     PYCALLBACK_GCA_INTINTKIND(wxGridTableBase, GetAttr);
 
1211     PYCALLBACK__GCAINTINT(wxGridTableBase, SetAttr);
 
1212     PYCALLBACK__GCAINT(wxGridTableBase, SetRowAttr);
 
1213     PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
 
1216     wxString GetValue(int row, int col) {
 
1217         bool blocked = wxPyBeginBlockThreads();
 
1219         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1221             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
 
1223                 rval = Py2wxString(ro);
 
1227         wxPyEndBlockThreads(blocked);
 
1231     void SetValue(int row, int col, const wxString& val) {
 
1232         bool blocked = wxPyBeginBlockThreads();
 
1233         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1234             PyObject* s = wx2PyString(val);
 
1235             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,s));
 
1238         wxPyEndBlockThreads(blocked);
 
1242     // Map the Get/Set methods for the standard non-string types to
 
1243     // the GetValue and SetValue python methods.
 
1244     long GetValueAsLong( int row, int col ) {
 
1246         bool blocked = wxPyBeginBlockThreads();
 
1247         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1250             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
 
1251             if (ro && PyNumber_Check(ro)) {
 
1252                 num = PyNumber_Int(ro);
 
1254                     rval = PyInt_AsLong(num);
 
1260         wxPyEndBlockThreads(blocked);
 
1264     double GetValueAsDouble( int row, int col ) {
 
1266         bool blocked = wxPyBeginBlockThreads();
 
1267         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1270             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
 
1271             if (ro && PyNumber_Check(ro)) {
 
1272                 num = PyNumber_Float(ro);
 
1274                     rval = PyFloat_AsDouble(num);
 
1280         wxPyEndBlockThreads(blocked);
 
1284     bool GetValueAsBool( int row, int col ) {
 
1285         return (bool)GetValueAsLong(row, col);
 
1288     void SetValueAsLong( int row, int col, long value ) {
 
1289         bool blocked = wxPyBeginBlockThreads();
 
1290         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1291             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value));
 
1293         wxPyEndBlockThreads(blocked);
 
1296     void SetValueAsDouble( int row, int col, double value ) {
 
1297         bool blocked = wxPyBeginBlockThreads();
 
1298         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1299             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value));
 
1301         wxPyEndBlockThreads(blocked);
 
1304     void SetValueAsBool( int row, int col, bool value ) {
 
1305         SetValueAsLong( row, col, (long)value );
 
1314 // The python-aware version get's SWIGified
 
1315 class wxPyGridTableBase : public wxGridTableBase
 
1318     %pythonAppend wxPyGridTableBase "self._setCallbackInfo(self, PyGridTableBase);self._setOORInfo(self)"
 
1319     wxPyGridTableBase();
 
1320     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
1322     %extend { void Destroy() { delete self; } }
 
1324     wxString base_GetTypeName( int row, int col );
 
1325     bool base_CanGetValueAs( int row, int col, const wxString& typeName );
 
1326     bool base_CanSetValueAs( int row, int col, const wxString& typeName );
 
1328     bool base_InsertRows( size_t pos = 0, size_t numRows = 1 );
 
1329     bool base_AppendRows( size_t numRows = 1 );
 
1330     bool base_DeleteRows( size_t pos = 0, size_t numRows = 1 );
 
1331     bool base_InsertCols( size_t pos = 0, size_t numCols = 1 );
 
1332     bool base_AppendCols( size_t numCols = 1 );
 
1333     bool base_DeleteCols( size_t pos = 0, size_t numCols = 1 );
 
1334     wxString base_GetRowLabelValue( int row );
 
1335     wxString base_GetColLabelValue( int col );
 
1336     void base_SetRowLabelValue( int row, const wxString& value );
 
1337     void base_SetColLabelValue( int col, const wxString& value );
 
1338     bool base_CanHaveAttributes();
 
1339     wxGridCellAttr *base_GetAttr( int row, int col,
 
1340                                   wxGridCellAttr::wxAttrKind kind );
 
1341     void base_SetAttr(wxGridCellAttr* attr, int row, int col);
 
1342     void base_SetRowAttr(wxGridCellAttr *attr, int row);
 
1343     void base_SetColAttr(wxGridCellAttr *attr, int col);
 
1347 //---------------------------------------------------------------------------
 
1348 // Predefined Tables
 
1350 class  wxGridStringTable : public wxGridTableBase
 
1353     %pythonAppend wxGridStringTable "self._setOORInfo(self)"
 
1354     wxGridStringTable( int numRows=0, int numCols=0 );
 
1357 //---------------------------------------------------------------------------
 
1358 // The Table can pass messages to the grid to tell it to update itself if
 
1359 // something has changed.
 
1361 enum wxGridTableRequest
 
1363     wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
 
1364     wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
 
1365     wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
 
1366     wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
 
1367     wxGRIDTABLE_NOTIFY_ROWS_DELETED,
 
1368     wxGRIDTABLE_NOTIFY_COLS_INSERTED,
 
1369     wxGRIDTABLE_NOTIFY_COLS_APPENDED,
 
1370     wxGRIDTABLE_NOTIFY_COLS_DELETED
 
1374 class wxGridTableMessage
 
1377     wxGridTableMessage( wxGridTableBase *table, int id,
 
1380     ~wxGridTableMessage();
 
1382     void SetTableObject( wxGridTableBase *table );
 
1383     wxGridTableBase * GetTableObject() const;
 
1384     void SetId( int id );
 
1386     void SetCommandInt( int comInt1 );
 
1387     int  GetCommandInt();
 
1388     void SetCommandInt2( int comInt2 );
 
1389     int  GetCommandInt2();
 
1393 //---------------------------------------------------------------------------
 
1396 // Typemap to allow conversion of sequence objects to wxGridCellCoords...
 
1397 %typemap(in) wxGridCellCoords& (wxGridCellCoords temp) {
 
1399     if (! wxGridCellCoords_helper($input, &$1)) SWIG_fail;
 
1401 %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxGridCellCoords& {
 
1402     $1 = wxGridCellCoords_typecheck($input);
 
1406 // ...and here is the associated helper.
 
1408 bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
 
1410     if (source == Py_None) {
 
1411         **obj = wxGridCellCoords(-1,-1);
 
1415     // If source is an object instance then it may already be the right type
 
1416     if (wxPySwigInstance_Check(source)) {
 
1417         wxGridCellCoords* ptr;
 
1418         if (! wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
 
1423     // otherwise a 2-tuple of integers is expected
 
1424     else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
 
1425         PyObject* o1 = PySequence_GetItem(source, 0);
 
1426         PyObject* o2 = PySequence_GetItem(source, 1);
 
1427         if (!PyNumber_Check(o1) || !PyNumber_Check(o2)) {
 
1432         **obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2));
 
1439     PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object.");
 
1444 bool wxGridCellCoords_typecheck(PyObject* source) {
 
1447     if (wxPySwigInstance_Check(source) &&
 
1448         wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
 
1452     if (PySequence_Check(source) && PySequence_Length(source) == 2)
 
1460 // Typemap to convert an array of cells coords to a list of tuples...
 
1461 %typemap(out) wxGridCellCoordsArray {
 
1462     $result = wxGridCellCoordsArray_helper($1);
 
1465 // %typemap(ret) wxGridCellCoordsArray {
 
1470 // ...and the helper function for the above typemap.
 
1472 PyObject* wxGridCellCoordsArray_helper(const wxGridCellCoordsArray& source)
 
1474     PyObject* list = PyList_New(0);
 
1476     for (idx = 0; idx < source.GetCount(); idx += 1) {
 
1477         wxGridCellCoords& coord = source.Item(idx);
 
1478         PyObject* tup = PyTuple_New(2);
 
1479         PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(coord.GetRow()));
 
1480         PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(coord.GetCol()));
 
1481         PyList_Append(list, tup);
 
1492 class wxGridCellCoords
 
1495     wxGridCellCoords( int r=-1, int c=-1 );
 
1496     ~wxGridCellCoords();
 
1499     void SetRow( int n );
 
1501     void SetCol( int n );
 
1502     void Set( int row, int col );
 
1504     bool operator==( const wxGridCellCoords& other ) const;
 
1505     bool operator!=( const wxGridCellCoords& other ) const;
 
1509             PyObject* tup = PyTuple_New(2);
 
1510             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
 
1511             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
 
1516     asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
 
1517     def __str__(self):                   return str(self.Get())
 
1518     def __repr__(self):                  return 'wxGridCellCoords'+str(self.Get())
 
1519     def __len__(self):                   return len(self.Get())
 
1520     def __getitem__(self, index):        return self.asTuple()[index]
 
1521     def __setitem__(self, index, val):
 
1522         if index == 0: self.SetRow(val)
 
1523         elif index == 1: self.SetCol(val)
 
1524         else: raise IndexError
 
1530 //---------------------------------------------------------------------------
 
1531 //---------------------------------------------------------------------------
 
1535 // Fool SWIG into treating this enum as an int
 
1536 typedef int WXGRIDSELECTIONMODES;
 
1538 // but let the C++ code know what it really is.
 
1540 typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES;
 
1545 class wxGrid : public wxScrolledWindow
 
1548     %pythonAppend wxGrid "self._setOORInfo(self)"
 
1550     wxGrid( wxWindow *parent,
 
1552             const wxPoint& pos = wxDefaultPosition,
 
1553             const wxSize& size = wxDefaultSize,
 
1554             long style = wxWANTS_CHARS,
 
1555             const wxString& name = wxPyPanelNameStr);
 
1558     enum wxGridSelectionModes {
 
1564         SelectCells =   wxGridSelectCells
 
1565         SelectRows =    wxGridSelectRows
 
1566         SelectColumns = wxGridSelectColumns
 
1569     bool CreateGrid( int numRows, int numCols,
 
1570                      WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells );
 
1571     void SetSelectionMode(WXGRIDSELECTIONMODES selmode);
 
1572     WXGRIDSELECTIONMODES GetSelectionMode();
 
1575     // ------ grid dimensions
 
1577     int      GetNumberRows();
 
1578     int      GetNumberCols();
 
1581     bool ProcessTableMessage( wxGridTableMessage& );
 
1584     wxGridTableBase * GetTable() const;
 
1585     bool SetTable( wxGridTableBase *table, bool takeOwnership=False,
 
1586                    WXGRIDSELECTIONMODES selmode =
 
1587                    wxGrid::wxGridSelectCells );
 
1590     bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=True );
 
1591     bool AppendRows( int numRows = 1, bool updateLabels=True );
 
1592     bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=True );
 
1593     bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=True );
 
1594     bool AppendCols( int numCols = 1, bool updateLabels=True );
 
1595     bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=True );
 
1598     // this function is called when the current cell highlight must be redrawn
 
1599     // and may be overridden by the user
 
1600     virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
 
1603     // ------ Cell text drawing functions
 
1605     void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
 
1606                             int horizontalAlignment = wxLEFT,
 
1607                             int verticalAlignment = wxTOP,
 
1608                             int textOrientation = wxHORIZONTAL );
 
1610 //      // Split a string containing newline chararcters into an array of
 
1611 //      // strings and return the number of lines
 
1613 //      void StringToLines( const wxString& value, wxArrayString& lines );
 
1616         void, GetTextBoxSize( wxDC& dc, wxArrayString& lines,
 
1617                               long *OUTPUT, long *OUTPUT ),
 
1618         "GetTextBoxSize(DC dc, list lines) -> (width, height)");
 
1622     // Code that does a lot of grid modification can be enclosed
 
1623     // between BeginBatch() and EndBatch() calls to avoid screen
 
1628     int      GetBatchCount();
 
1629     void     ForceRefresh();
 
1632     // ------ edit control functions
 
1635     void EnableEditing( bool edit );
 
1637     void EnableCellEditControl( bool enable = True );
 
1638     void DisableCellEditControl();
 
1639     bool CanEnableCellControl() const;
 
1640     bool IsCellEditControlEnabled() const;
 
1641     bool IsCellEditControlShown() const;
 
1643     bool IsCurrentCellReadOnly() const;
 
1645     void ShowCellEditControl();
 
1646     void HideCellEditControl();
 
1647     void SaveEditControlValue();
 
1650     // ------ grid location functions
 
1651     //  Note that all of these functions work with the logical coordinates of
 
1652     //  grid cells and labels so you will need to convert from device
 
1653     //  coordinates for mouse events etc.
 
1656     //void XYToCell( int x, int y, wxGridCellCoords& );
 
1658         wxGridCellCoords XYToCell(int x, int y) {
 
1659             wxGridCellCoords rv;
 
1660             self->XYToCell(x, y, rv);
 
1665     int  YToRow( int y );
 
1666     int  XToCol( int x );
 
1668     int  YToEdgeOfRow( int y );
 
1669     int  XToEdgeOfCol( int x );
 
1671     wxRect CellToRect( int row, int col );
 
1672     // TODO: ??? wxRect CellToRect( const wxGridCellCoords& coords );
 
1675     int  GetGridCursorRow();
 
1676     int  GetGridCursorCol();
 
1678     // check to see if a cell is either wholly visible (the default arg) or
 
1679     // at least partially visible in the grid window
 
1681     bool IsVisible( int row, int col, bool wholeCellVisible = True );
 
1682     // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = True );
 
1683     void MakeCellVisible( int row, int col );
 
1684     // TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords );
 
1687     // ------ grid cursor movement functions
 
1689     void SetGridCursor( int row, int col );
 
1690     bool MoveCursorUp( bool expandSelection );
 
1691     bool MoveCursorDown( bool expandSelection );
 
1692     bool MoveCursorLeft( bool expandSelection );
 
1693     bool MoveCursorRight( bool expandSelection );
 
1694     bool MovePageDown();
 
1696     bool MoveCursorUpBlock( bool expandSelection );
 
1697     bool MoveCursorDownBlock( bool expandSelection );
 
1698     bool MoveCursorLeftBlock( bool expandSelection );
 
1699     bool MoveCursorRightBlock( bool expandSelection );
 
1702     // ------ label and gridline formatting
 
1704     int      GetDefaultRowLabelSize();
 
1705     int      GetRowLabelSize();
 
1706     int      GetDefaultColLabelSize();
 
1707     int      GetColLabelSize();
 
1708     wxColour GetLabelBackgroundColour();
 
1709     wxColour GetLabelTextColour();
 
1710     wxFont   GetLabelFont();
 
1713         void, GetRowLabelAlignment( int *OUTPUT, int *OUTPUT ),
 
1714         "GetRowLabelAlignment() -> (horiz, vert)");
 
1717         void, GetColLabelAlignment( int *OUTPUT, int *OUTPUT ),
 
1718         "GetColLabelAlignment() -> (horiz, vert)");
 
1720     int      GetColLabelTextOrientation();
 
1721     wxString GetRowLabelValue( int row );
 
1722     wxString GetColLabelValue( int col );
 
1723     wxColour GetGridLineColour();
 
1724     wxColour GetCellHighlightColour();
 
1725     int      GetCellHighlightPenWidth();
 
1726     int      GetCellHighlightROPenWidth();
 
1728     void     SetRowLabelSize( int width );
 
1729     void     SetColLabelSize( int height );
 
1730     void     SetLabelBackgroundColour( const wxColour& );
 
1731     void     SetLabelTextColour( const wxColour& );
 
1732     void     SetLabelFont( const wxFont& );
 
1733     void     SetRowLabelAlignment( int horiz, int vert );
 
1734     void     SetColLabelAlignment( int horiz, int vert );
 
1735     void     SetColLabelTextOrientation( int textOrientation );
 
1736     void     SetRowLabelValue( int row, const wxString& );
 
1737     void     SetColLabelValue( int col, const wxString& );
 
1738     void     SetGridLineColour( const wxColour& );
 
1739     void     SetCellHighlightColour( const wxColour& );
 
1740     void     SetCellHighlightPenWidth(int width);
 
1741     void     SetCellHighlightROPenWidth(int width);
 
1743     void     EnableDragRowSize( bool enable = True );
 
1744     void     DisableDragRowSize();
 
1745     bool     CanDragRowSize();
 
1746     void     EnableDragColSize( bool enable = True );
 
1747     void     DisableDragColSize();
 
1748     bool     CanDragColSize();
 
1749     void     EnableDragGridSize(bool enable = True);
 
1750     void     DisableDragGridSize();
 
1751     bool     CanDragGridSize();
 
1753     // this sets the specified attribute for all cells in this row/col
 
1754     void     SetAttr(int row, int col, wxGridCellAttr *attr);
 
1755     void     SetRowAttr(int row, wxGridCellAttr *attr);
 
1756     void     SetColAttr(int col, wxGridCellAttr *attr);
 
1758     // shortcuts for setting the column parameters
 
1760     // set the format for the data in the column: default is string
 
1761     void     SetColFormatBool(int col);
 
1762     void     SetColFormatNumber(int col);
 
1763     void     SetColFormatFloat(int col, int width = -1, int precision = -1);
 
1764     void     SetColFormatCustom(int col, const wxString& typeName);
 
1766     void     EnableGridLines( bool enable = True );
 
1767     bool     GridLinesEnabled();
 
1769     // ------ row and col formatting
 
1771     int      GetDefaultRowSize();
 
1772     int      GetRowSize( int row );
 
1773     int      GetDefaultColSize();
 
1774     int      GetColSize( int col );
 
1775     wxColour GetDefaultCellBackgroundColour();
 
1776     wxColour GetCellBackgroundColour( int row, int col );
 
1777     wxColour GetDefaultCellTextColour();
 
1778     wxColour GetCellTextColour( int row, int col );
 
1779     wxFont   GetDefaultCellFont();
 
1780     wxFont   GetCellFont( int row, int col );
 
1783         void, GetDefaultCellAlignment( int *OUTPUT, int *OUTPUT ),
 
1784         "GetDefaultCellAlignment() -> (horiz, vert)");
 
1787         void, GetCellAlignment( int row, int col, int *OUTPUT, int *OUTPUT ),
 
1788         "GetCellAlignment() -> (horiz, vert)");
 
1790     bool     GetDefaultCellOverflow();
 
1791     bool     GetCellOverflow( int row, int col );
 
1794         void, GetCellSize( int row, int col, int *OUTPUT, int *OUTPUT ),
 
1795         "GetCellSize(int row, int col) -> (num_rows, num_cols)");
 
1797     void     SetDefaultRowSize( int height, bool resizeExistingRows = False );
 
1798     void     SetRowSize( int row, int height );
 
1799     void     SetDefaultColSize( int width, bool resizeExistingCols = False );
 
1801     void     SetColSize( int col, int width );
 
1803     // automatically size the column or row to fit to its contents, if
 
1804     // setAsMin is True, this optimal width will also be set as minimal width
 
1806     void     AutoSizeColumn( int col, bool setAsMin = True );
 
1807     void     AutoSizeRow( int row, bool setAsMin = True );
 
1810     // auto size all columns (very ineffective for big grids!)
 
1811     void     AutoSizeColumns( bool setAsMin = True );
 
1812     void     AutoSizeRows( bool setAsMin = True );
 
1814     // auto size the grid, that is make the columns/rows of the "right" size
 
1815     // and also set the grid size to just fit its contents
 
1818     // autosize row height depending on label text
 
1819     void     AutoSizeRowLabelSize( int row );
 
1821     // autosize column width depending on label text
 
1822     void     AutoSizeColLabelSize( int col );
 
1825     // column won't be resized to be lesser width - this must be called during
 
1826     // the grid creation because it won't resize the column if it's already
 
1827     // narrower than the minimal width
 
1828     void     SetColMinimalWidth( int col, int width );
 
1829     void     SetRowMinimalHeight( int row, int width );
 
1831     void     SetColMinimalAcceptableWidth( int width );
 
1832     void     SetRowMinimalAcceptableHeight( int width );
 
1833     int      GetColMinimalAcceptableWidth() const;
 
1834     int      GetRowMinimalAcceptableHeight() const;
 
1836     void     SetDefaultCellBackgroundColour( const wxColour& );
 
1837     void     SetCellBackgroundColour( int row, int col, const wxColour& );
 
1838     void     SetDefaultCellTextColour( const wxColour& );
 
1840     void     SetCellTextColour( int row, int col, const wxColour& );
 
1841     void     SetDefaultCellFont( const wxFont& );
 
1842     void     SetCellFont( int row, int col, const wxFont& );
 
1843     void     SetDefaultCellAlignment( int horiz, int vert );
 
1844     void     SetCellAlignment( int row, int col, int horiz, int vert );
 
1845     void     SetDefaultCellOverflow( bool allow );
 
1846     void     SetCellOverflow( int row, int col, bool allow );
 
1847     void     SetCellSize( int row, int col, int num_rows, int num_cols );
 
1849     // takes ownership of the pointer
 
1850     void SetDefaultRenderer(wxGridCellRenderer *renderer);
 
1851     void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
 
1852     wxGridCellRenderer *GetDefaultRenderer() const;
 
1853     wxGridCellRenderer* GetCellRenderer(int row, int col);
 
1855     // takes ownership of the pointer
 
1856     void SetDefaultEditor(wxGridCellEditor *editor);
 
1857     void SetCellEditor(int row, int col, wxGridCellEditor *editor);
 
1858     wxGridCellEditor *GetDefaultEditor() const;
 
1859     wxGridCellEditor* GetCellEditor(int row, int col);
 
1863     // ------ cell value accessors
 
1865     wxString GetCellValue( int row, int col );
 
1866     // TODO: ??? wxString GetCellValue( const wxGridCellCoords& coords )
 
1868     void SetCellValue( int row, int col, const wxString& s );
 
1869     // TODO: ??? void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
 
1871     // returns True if the cell can't be edited
 
1872     bool IsReadOnly(int row, int col) const;
 
1874     // make the cell editable/readonly
 
1875     void SetReadOnly(int row, int col, bool isReadOnly = True);
 
1877     // ------ selections of blocks of cells
 
1879     void SelectRow( int row, bool addToSelected = False );
 
1880     void SelectCol( int col, bool addToSelected = False );
 
1882     void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
 
1883                       bool addToSelected = False );
 
1884     // TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft,
 
1885     // TODO: ???                   const wxGridCellCoords& bottomRight )
 
1889     void ClearSelection();
 
1890     bool IsInSelection( int row, int col );
 
1891     // TODO: ??? bool IsInSelection( const wxGridCellCoords& coords )
 
1893     const wxGridCellCoordsArray GetSelectedCells() const;
 
1894     const wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
 
1895     const wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
 
1896     const wxArrayInt GetSelectedRows() const;
 
1897     const wxArrayInt GetSelectedCols() const;
 
1899     void DeselectRow( int row );
 
1900     void DeselectCol( int col );
 
1901     void DeselectCell( int row, int col );
 
1904     // This function returns the rectangle that encloses the block of cells
 
1905     // limited by TopLeft and BottomRight cell in device coords and clipped
 
1906     //  to the client size of the grid window.
 
1908     wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
 
1909                               const wxGridCellCoords & bottomRight );
 
1912     // Access or update the selection fore/back colours
 
1913     wxColour GetSelectionBackground() const;
 
1914     wxColour GetSelectionForeground() const;
 
1916     void SetSelectionBackground(const wxColour& c);
 
1917     void SetSelectionForeground(const wxColour& c);
 
1920     // Methods for a registry for mapping data types to Renderers/Editors
 
1921     void RegisterDataType(const wxString& typeName,
 
1922                           wxGridCellRenderer* renderer,
 
1923                           wxGridCellEditor* editor);
 
1924     wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
 
1925     // TODO: ??? wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
 
1926     wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
 
1927     wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
 
1928     wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
 
1930     // grid may occupy more space than needed for its rows/columns, this
 
1931     // function allows to set how big this extra space is
 
1932     void SetMargins(int extraWidth, int extraHeight);
 
1935     // Accessors for component windows
 
1936     wxWindow* GetGridWindow();
 
1937     wxWindow* GetGridRowLabelWindow();
 
1938     wxWindow* GetGridColLabelWindow();
 
1939     wxWindow* GetGridCornerLabelWindow();
 
1942     static wxVisualAttributes
 
1943     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
1947 //---------------------------------------------------------------------------
 
1948 //---------------------------------------------------------------------------
 
1949 // Grid events and stuff
 
1953 class wxGridEvent : public wxNotifyEvent
 
1956     wxGridEvent(int id, wxEventType type, wxGrid* obj,
 
1957                 int row=-1, int col=-1, int x=-1, int y=-1, bool sel = True,
 
1958                 bool control=False, bool shift=False, bool alt=False, bool meta=False);
 
1960     virtual int GetRow();
 
1961     virtual int GetCol();
 
1962     wxPoint     GetPosition();
 
1972 class  wxGridSizeEvent : public wxNotifyEvent
 
1975     wxGridSizeEvent(int id, wxEventType type, wxGrid* obj,
 
1976                 int rowOrCol=-1, int x=-1, int y=-1,
 
1977                 bool control=False, bool shift=False, bool alt=False, bool meta=False);
 
1980     wxPoint     GetPosition();
 
1989 class wxGridRangeSelectEvent : public wxNotifyEvent
 
1992     wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj,
 
1993                            const wxGridCellCoords& topLeft,
 
1994                            const wxGridCellCoords& bottomRight,
 
1996                            bool control=False, bool shift=False,
 
1997                            bool alt=False, bool meta=False);
 
1999     wxGridCellCoords GetTopLeftCoords();
 
2000     wxGridCellCoords GetBottomRightCoords();
 
2013 class wxGridEditorCreatedEvent : public wxCommandEvent {
 
2015     wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
 
2016                              int row, int col, wxControl* ctrl);
 
2020     wxControl* GetControl();
 
2021     void SetRow(int row);
 
2022     void SetCol(int col);
 
2023     void SetControl(wxControl* ctrl);
 
2028 %constant wxEventType wxEVT_GRID_CELL_LEFT_CLICK;
 
2029 %constant wxEventType wxEVT_GRID_CELL_RIGHT_CLICK;
 
2030 %constant wxEventType wxEVT_GRID_CELL_LEFT_DCLICK;
 
2031 %constant wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK;
 
2032 %constant wxEventType wxEVT_GRID_LABEL_LEFT_CLICK;
 
2033 %constant wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK;
 
2034 %constant wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK;
 
2035 %constant wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK;
 
2036 %constant wxEventType wxEVT_GRID_ROW_SIZE;
 
2037 %constant wxEventType wxEVT_GRID_COL_SIZE;
 
2038 %constant wxEventType wxEVT_GRID_RANGE_SELECT;
 
2039 %constant wxEventType wxEVT_GRID_CELL_CHANGE;
 
2040 %constant wxEventType wxEVT_GRID_SELECT_CELL;
 
2041 %constant wxEventType wxEVT_GRID_EDITOR_SHOWN;
 
2042 %constant wxEventType wxEVT_GRID_EDITOR_HIDDEN;
 
2043 %constant wxEventType wxEVT_GRID_EDITOR_CREATED;
 
2048 EVT_GRID_CELL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_CLICK )
 
2049 EVT_GRID_CELL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_CLICK )
 
2050 EVT_GRID_CELL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_DCLICK )
 
2051 EVT_GRID_CELL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_DCLICK )
 
2052 EVT_GRID_LABEL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_CLICK )
 
2053 EVT_GRID_LABEL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_CLICK )
 
2054 EVT_GRID_LABEL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_DCLICK )
 
2055 EVT_GRID_LABEL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_DCLICK )
 
2056 EVT_GRID_ROW_SIZE = wx.PyEventBinder( wxEVT_GRID_ROW_SIZE )
 
2057 EVT_GRID_COL_SIZE = wx.PyEventBinder( wxEVT_GRID_COL_SIZE )
 
2058 EVT_GRID_RANGE_SELECT = wx.PyEventBinder( wxEVT_GRID_RANGE_SELECT )
 
2059 EVT_GRID_CELL_CHANGE = wx.PyEventBinder( wxEVT_GRID_CELL_CHANGE )
 
2060 EVT_GRID_SELECT_CELL = wx.PyEventBinder( wxEVT_GRID_SELECT_CELL )
 
2061 EVT_GRID_EDITOR_SHOWN = wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN )
 
2062 EVT_GRID_EDITOR_HIDDEN = wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN )
 
2063 EVT_GRID_EDITOR_CREATED = wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED )
 
2066 //---------------------------------------------------------------------------
 
2071 //---------------------------------------------------------------------------
 
2072 //---------------------------------------------------------------------------