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 %include _grid_rename.i
 
  40 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
 
  41 MAKE_CONST_WXSTRING_NOSWIG(PanelNameStr);
 
  42 MAKE_CONST_WXSTRING_NOSWIG(DefaultDateTimeFormat);
 
  44 //---------------------------------------------------------------------------
 
  45 // OOR related typemaps and helper functions
 
  47 %typemap(out) wxGridCellRenderer*     { $result = wxPyMake_wxGridCellRenderer($1, (bool)$owner); }
 
  48 %typemap(out) wxGridCellEditor*       { $result = wxPyMake_wxGridCellEditor($1,   (bool)$owner); }
 
  49 %typemap(out) wxGridCellAttr*         { $result = wxPyMake_wxGridCellAttr($1,     (bool)$owner); }
 
  50 %typemap(out) wxGridCellAttrProvider* { $result = wxPyMake_wxGridCellAttrProvider($1, (bool)$owner); }
 
  51 %typemap(out) wxGridTableBase*        { $result = wxPyMake_wxGridTableBase($1,    (bool)$owner); }
 
  56 #define wxPyMake_TEMPLATE(TYPE) \
 
  57 PyObject* wxPyMake_##TYPE(TYPE* source, bool setThisOwn) { \
 
  58     PyObject* target = NULL; \
 
  60         /* Check if there is already a pointer to a Python object in the \
 
  61            OOR data that we can use. */ \
 
  62         wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \
 
  64             target = data->m_obj; \
 
  68         /* Otherwise make a new wrapper for it the old fashioned way and \
 
  69            give it the OOR treatment */ \
 
  71             target = wxPyConstructObject(source, wxT(#TYPE), setThisOwn); \
 
  73                 source->SetClientObject(new wxPyOORClientData(target)); \
 
  75     } else {  /* source was NULL so return None. */ \
 
  76         Py_INCREF(Py_None); target = Py_None; \
 
  82 wxPyMake_TEMPLATE(wxGridCellRenderer)
 
  83 wxPyMake_TEMPLATE(wxGridCellEditor)
 
  84 wxPyMake_TEMPLATE(wxGridCellAttr)
 
  85 wxPyMake_TEMPLATE(wxGridCellAttrProvider)
 
  86 wxPyMake_TEMPLATE(wxGridTableBase)
 
  90 //---------------------------------------------------------------------------
 
  91 // Macros, similar to what's in helpers.h, to aid in the creation of
 
  92 // virtual methods that are able to make callbacks to Python.  Many of these
 
  93 // are specific to wxGrid and so are kept here to reduce the mess in helpers.h
 
  98 #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME)                               \
 
  99     wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) {        \
 
 100         wxGridCellAttr* rval = NULL;                                            \
 
 102         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 103         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 105             wxGridCellAttr* ptr;                                                \
 
 106             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \
 
 108                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellAttr"))) \
 
 113         wxPyEndBlockThreads(blocked);                                           \
 
 115             rval = PCLASS::CBNAME(a, b, c);                                     \
 
 120 #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME)                                   \
 
 121     void CBNAME(wxGridCellAttr *attr, int a, int b) {                           \
 
 122         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 124         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 125             PyObject* obj = wxPyMake_wxGridCellAttr(attr,false);                \
 
 126             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b));  \
 
 129         wxPyEndBlockThreads(blocked);                                           \
 
 131             PCLASS::CBNAME(attr, a, b);                                         \
 
 136 #define PYCALLBACK__GCAINT(PCLASS, CBNAME)                                      \
 
 137     void CBNAME(wxGridCellAttr *attr, int val) {                                \
 
 138         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 140         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 141             PyObject* obj = wxPyMake_wxGridCellAttr(attr,false);                \
 
 142             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val));    \
 
 145         wxPyEndBlockThreads(blocked);                                           \
 
 147             PCLASS::CBNAME(attr, val);                                          \
 
 152 #define PYCALLBACK_INT__pure(CBNAME)                                            \
 
 154         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 156         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                            \
 
 157             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \
 
 158         wxPyEndBlockThreads(blocked);                                           \
 
 164 #define PYCALLBACK_BOOL_INTINT_pure(CBNAME)                                     \
 
 165     bool CBNAME(int a, int b) {                                                 \
 
 166         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 168         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                            \
 
 169             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b));   \
 
 170         wxPyEndBlockThreads(blocked);                                           \
 
 175 #define PYCALLBACK_STRING_INTINT_pure(CBNAME)                                   \
 
 176     wxString CBNAME(int a, int b) {                                             \
 
 177         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 179         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
 
 181             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));  \
 
 183                 rval = Py2wxString(ro);                                         \
 
 187         wxPyEndBlockThreads(blocked);                                           \
 
 192 #define PYCALLBACK__INTINTSTRING_pure(CBNAME)                                   \
 
 193     void CBNAME(int a, int b, const wxString& c) {                              \
 
 194         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 195         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
 
 196             PyObject* s = wx2PyString(c);                                       \
 
 197             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
 
 200         wxPyEndBlockThreads(blocked);                                           \
 
 204 #define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME)                                \
 
 205     wxString CBNAME(int a, int b) {                                             \
 
 207         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 209         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 211             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));  \
 
 213                 rval = Py2wxString(ro);                                         \
 
 217         wxPyEndBlockThreads(blocked);                                           \
 
 219             rval = PCLASS::CBNAME(a, b);                                        \
 
 224 #define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME)                            \
 
 225     bool CBNAME(int a, int b, const wxString& c)  {                             \
 
 228         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 229         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 230             PyObject* s = wx2PyString(c);                                       \
 
 231             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
 
 234         wxPyEndBlockThreads(blocked);                                           \
 
 236             rval = PCLASS::CBNAME(a,b,c);                                       \
 
 243 #define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME)                                  \
 
 244     long CBNAME(int a, int b)  {                                                \
 
 247         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 248         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 249             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));  \
 
 250         wxPyEndBlockThreads(blocked);                                           \
 
 252             rval = PCLASS::CBNAME(a,b);                                         \
 
 257 #define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME)                                  \
 
 258     bool CBNAME(int a, int b)  {                                                \
 
 261         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 262         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 263             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));  \
 
 264         wxPyEndBlockThreads(blocked);                                           \
 
 266             rval = PCLASS::CBNAME(a,b);                                         \
 
 272 #define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME)                                \
 
 273     double CBNAME(int a, int b) {                                               \
 
 275         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 277         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 279             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));  \
 
 281                 PyObject* str = PyObject_Str(ro);                               \
 
 282                 rval = PyFloat_AsDouble(str);                                   \
 
 283                 Py_DECREF(ro);   Py_DECREF(str);                                \
 
 286         wxPyEndBlockThreads(blocked);                                           \
 
 288             rval = PCLASS::CBNAME(a, b);                                        \
 
 294 #define PYCALLBACK__(PCLASS, CBNAME)                                            \
 
 297         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 298         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 299             wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));                \
 
 300         wxPyEndBlockThreads(blocked);                                           \
 
 307 #define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME)                              \
 
 308     bool CBNAME(size_t a, size_t b)  {                                          \
 
 311         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 312         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 313             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));  \
 
 314         wxPyEndBlockThreads(blocked);                                           \
 
 316             rval = PCLASS::CBNAME(a,b);                                         \
 
 322 #define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME)                                   \
 
 323     bool CBNAME(size_t a)  {                                                    \
 
 326         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 327         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 328             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));     \
 
 329         wxPyEndBlockThreads(blocked);                                           \
 
 331             rval = PCLASS::CBNAME(a);                                           \
 
 336 #define PYCALLBACK_STRING_INT(PCLASS, CBNAME)                                   \
 
 337     wxString CBNAME(int a) {                                                    \
 
 339         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 341         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 343             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a));     \
 
 345                 rval = Py2wxString(ro);                                         \
 
 349         wxPyEndBlockThreads(blocked);                                           \
 
 351             rval = PCLASS::CBNAME(a);                                           \
 
 356 #define PYCALLBACK__INTSTRING(PCLASS, CBNAME)                                   \
 
 357     void CBNAME(int a, const wxString& c)  {                                    \
 
 359         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 360         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
 
 361             PyObject* s = wx2PyString(c);                                       \
 
 362             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)",a,s));          \
 
 365         wxPyEndBlockThreads(blocked);                                           \
 
 367             PCLASS::CBNAME(a,c);                                                \
 
 373 #define PYCALLBACK_BOOL_(PCLASS, CBNAME)                                        \
 
 377         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 378         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 379             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \
 
 380         wxPyEndBlockThreads(blocked);                                           \
 
 382             rval = PCLASS::CBNAME();                                            \
 
 388 #define PYCALLBACK__SIZETINT(PCLASS, CBNAME)                                    \
 
 389     void CBNAME(size_t a, int b)  {                                             \
 
 391         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 392         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 393             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));         \
 
 394         wxPyEndBlockThreads(blocked);                                           \
 
 396             PCLASS::CBNAME(a,b);                                                \
 
 402 #define PYCALLBACK__INTINTLONG(PCLASS, CBNAME)                                  \
 
 403     void CBNAME(int a, int b, long c)  {                                        \
 
 405         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 406         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 407             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));      \
 
 408         wxPyEndBlockThreads(blocked);                                           \
 
 410             PCLASS::CBNAME(a,b,c);                                              \
 
 416 #define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME)                                \
 
 417     void CBNAME(int a, int b, double c)  {                                      \
 
 419         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 420         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 421             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c));      \
 
 422         wxPyEndBlockThreads(blocked);                                           \
 
 424             PCLASS::CBNAME(a,b,c);                                              \
 
 429 #define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME)                                  \
 
 430     void CBNAME(int a, int b, bool c)  {                                        \
 
 432         wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
 
 433         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
 
 434             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));      \
 
 435         wxPyEndBlockThreads(blocked);                                           \
 
 437             PCLASS::CBNAME(a,b,c);                                              \
 
 444 //---------------------------------------------------------------------------
 
 446 class wxGridCellCoords;
 
 447 class wxGridCellAttr;
 
 449 #define wxGRID_VALUE_STRING     "string"
 
 450 #define wxGRID_VALUE_BOOL       "bool"
 
 451 #define wxGRID_VALUE_NUMBER     "long"
 
 452 #define wxGRID_VALUE_FLOAT      "double"
 
 453 #define wxGRID_VALUE_CHOICE     "choice"
 
 454 #define wxGRID_VALUE_TEXT       "string"
 
 455 #define wxGRID_VALUE_LONG       "long"
 
 456 #define wxGRID_VALUE_CHOICEINT  "choiceint"
 
 457 #define wxGRID_VALUE_DATETIME   "datetime"
 
 461 const wxGridCellCoords wxGridNoCellCoords;
 
 462 const wxRect           wxGridNoCellRect;
 
 467 #define wxGRID_DEFAULT_NUMBER_ROWS        WXGRID_DEFAULT_NUMBER_ROWS
 
 468 #define wxGRID_DEFAULT_NUMBER_COLS        WXGRID_DEFAULT_NUMBER_COLS
 
 469 #define wxGRID_DEFAULT_ROW_HEIGHT         WXGRID_DEFAULT_ROW_HEIGHT
 
 470 #define wxGRID_DEFAULT_COL_WIDTH          WXGRID_DEFAULT_COL_WIDTH
 
 471 #define wxGRID_DEFAULT_COL_LABEL_HEIGHT   WXGRID_DEFAULT_COL_LABEL_HEIGHT
 
 472 #define wxGRID_DEFAULT_ROW_LABEL_WIDTH    WXGRID_DEFAULT_ROW_LABEL_WIDTH
 
 473 #define wxGRID_LABEL_EDGE_ZONE            WXGRID_LABEL_EDGE_ZONE
 
 474 #define wxGRID_MIN_ROW_HEIGHT             WXGRID_MIN_ROW_HEIGHT
 
 475 #define wxGRID_MIN_COL_WIDTH              WXGRID_MIN_COL_WIDTH
 
 476 #define wxGRID_DEFAULT_SCROLLBAR_WIDTH    WXGRID_DEFAULT_SCROLLBAR_WIDTH
 
 480     wxGRID_DEFAULT_NUMBER_ROWS,
 
 481     wxGRID_DEFAULT_NUMBER_COLS,
 
 482     wxGRID_DEFAULT_ROW_HEIGHT,
 
 483     wxGRID_DEFAULT_COL_WIDTH,
 
 484     wxGRID_DEFAULT_COL_LABEL_HEIGHT,
 
 485     wxGRID_DEFAULT_ROW_LABEL_WIDTH,
 
 486     wxGRID_LABEL_EDGE_ZONE,
 
 487     wxGRID_MIN_ROW_HEIGHT,
 
 488     wxGRID_MIN_COL_WIDTH,
 
 489     wxGRID_DEFAULT_SCROLLBAR_WIDTH
 
 493 //---------------------------------------------------------------------------
 
 495 // TODO: Use these to have SWIG automatically handle the IncRef/DecRef calls:
 
 497 //        %ref   wxGridCellWorker "$this->IncRef();";
 
 498 //        %unref wxGridCellWorker "$this->DecRef();";
 
 501 class  wxGridCellWorker
 
 505         void _setOORInfo(PyObject* _self) {
 
 506             if (!self->GetClientObject())
 
 507                 self->SetClientObject(new wxPyOORClientData(_self));
 
 510         // A dummy dtor to shut up SWIG.  (The real one is protected and can
 
 511         // only be called by DecRef)
 
 512         ~wxGridCellWorker() {
 
 516     void SetParameters(const wxString& params);
 
 523 // wxGridCellRenderer is an ABC, and several derived classes are available.
 
 524 // Classes implemented in Python should be derived from wxPyGridCellRenderer.
 
 526 class wxGridCellRenderer : public wxGridCellWorker
 
 528     virtual void Draw(wxGrid& grid,
 
 529                       wxGridCellAttr& attr,
 
 534     virtual wxSize GetBestSize(wxGrid& grid,
 
 535                                wxGridCellAttr& attr,
 
 538     virtual wxGridCellRenderer *Clone() const;
 
 543 // The C++ version of wxPyGridCellRenderer
 
 545 class wxPyGridCellRenderer : public wxGridCellRenderer
 
 548     wxPyGridCellRenderer() : wxGridCellRenderer() {};
 
 550     // Implement Python callback aware virtual methods
 
 551     void Draw(wxGrid& grid, wxGridCellAttr& attr,
 
 552               wxDC& dc, const wxRect& rect,
 
 553               int row, int col, bool isSelected) {
 
 554         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 555         if (wxPyCBH_findCallback(m_myInst, "Draw")) {
 
 556             PyObject* go = wxPyMake_wxObject(&grid,false);
 
 557             PyObject* dco = wxPyMake_wxObject(&dc,false);
 
 558             PyObject* ao = wxPyMake_wxGridCellAttr(&attr,false);
 
 559             PyObject* ro = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);
 
 561             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOiii)", go, ao, dco, ro,
 
 562                                                          row, col, isSelected));
 
 568         wxPyEndBlockThreads(blocked);
 
 571     wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
 
 574         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 575         if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) {
 
 578             PyObject* go = wxPyMake_wxObject(&grid,false);
 
 579             PyObject* dco = wxPyMake_wxObject(&dc,false);
 
 580             PyObject* ao = wxPyMake_wxGridCellAttr(&attr,false);
 
 582             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOii)",
 
 590                 const char* errmsg = "GetBestSize should return a 2-tuple of integers or a wxSize object.";
 
 591                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) {
 
 594                 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) {
 
 595                     PyObject* o1 = PySequence_GetItem(ro, 0);
 
 596                     PyObject* o2 = PySequence_GetItem(ro, 1);
 
 597                     if (PyNumber_Check(o1) && PyNumber_Check(o2))
 
 598                         rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2));
 
 600                         PyErr_SetString(PyExc_TypeError, errmsg);
 
 605                     PyErr_SetString(PyExc_TypeError, errmsg);
 
 610         wxPyEndBlockThreads(blocked);
 
 615     wxGridCellRenderer *Clone() const {
 
 616         wxGridCellRenderer* rval = NULL;
 
 617         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 618         if (wxPyCBH_findCallback(m_myInst, "Clone")) {
 
 620             wxGridCellRenderer* ptr;
 
 621             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 623                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellRenderer")))
 
 628         wxPyEndBlockThreads(blocked);
 
 632     DEC_PYCALLBACK__STRING(SetParameters);
 
 637 IMP_PYCALLBACK__STRING( wxPyGridCellRenderer, wxGridCellRenderer, SetParameters);
 
 642 // Let SWIG know about it so it can create the Python version
 
 643 class wxPyGridCellRenderer : public wxGridCellRenderer {
 
 645     %pythonAppend wxPyGridCellRenderer  "self._setCallbackInfo(self, PyGridCellRenderer);self._setOORInfo(self)"
 
 647     wxPyGridCellRenderer();
 
 648     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 650     void SetParameters(const wxString& params);
 
 651     %MAKE_BASE_FUNC(PyGridCellRenderer, SetParameters);
 
 654 //---------------------------------------------------------------------------
 
 655 //  Predefined Renderers
 
 657 class wxGridCellStringRenderer : public wxGridCellRenderer
 
 660     %pythonAppend wxGridCellStringRenderer "self._setOORInfo(self)"
 
 661     wxGridCellStringRenderer();
 
 665 class  wxGridCellNumberRenderer : public wxGridCellStringRenderer
 
 668     %pythonAppend wxGridCellNumberRenderer "self._setOORInfo(self)"
 
 669     wxGridCellNumberRenderer();
 
 673 class  wxGridCellFloatRenderer : public wxGridCellStringRenderer
 
 676     %pythonAppend wxGridCellFloatRenderer "self._setOORInfo(self)"
 
 677     wxGridCellFloatRenderer(int width = -1, int precision = -1);
 
 679     int GetWidth() const;
 
 680     void SetWidth(int width);
 
 681     int GetPrecision() const;
 
 682     void SetPrecision(int precision);
 
 686 class  wxGridCellBoolRenderer : public wxGridCellRenderer
 
 689     %pythonAppend wxGridCellBoolRenderer "self._setOORInfo(self)"
 
 690     wxGridCellBoolRenderer();
 
 694 class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
 
 697     %pythonAppend wxGridCellDateTimeRenderer "self._setOORInfo(self)"
 
 698     wxGridCellDateTimeRenderer(wxString outformat = wxPyDefaultDateTimeFormat,
 
 699                                wxString informat =  wxPyDefaultDateTimeFormat);
 
 703 class wxGridCellEnumRenderer : public wxGridCellStringRenderer
 
 706     %pythonAppend wxGridCellEnumRenderer "self._setOORInfo(self)"
 
 707     wxGridCellEnumRenderer( const wxString& choices = wxPyEmptyString );
 
 711 class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
 
 714     %pythonAppend wxGridCellAutoWrapStringRenderer "self._setOORInfo(self)"
 
 715     wxGridCellAutoWrapStringRenderer();
 
 719 //---------------------------------------------------------------------------
 
 720 // wxGridCellEditor is an ABC, and several derived classes are available.
 
 721 // Classes implemented in Python should be derived from wxPyGridCellEditor.
 
 723 class  wxGridCellEditor : public wxGridCellWorker
 
 727     wxControl* GetControl();
 
 728     void SetControl(wxControl* control);
 
 730     wxGridCellAttr* GetCellAttr();
 
 731     void SetCellAttr(wxGridCellAttr* attr);
 
 733     virtual void Create(wxWindow* parent,
 
 735                         wxEvtHandler* evtHandler);
 
 736     virtual void BeginEdit(int row, int col, wxGrid* grid);
 
 737     virtual bool EndEdit(int row, int col, wxGrid* grid);
 
 738     virtual void Reset();
 
 739     virtual wxGridCellEditor *Clone() const;
 
 741     virtual void SetSize(const wxRect& rect);
 
 742     virtual void Show(bool show, wxGridCellAttr *attr = NULL);
 
 743     virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
 
 744     virtual bool IsAcceptedKey(wxKeyEvent& event);
 
 745     virtual void StartingKey(wxKeyEvent& event);
 
 746     virtual void StartingClick();
 
 747     virtual void HandleReturn(wxKeyEvent& event);
 
 749     %pythonAppend Destroy "args[0].thisown = 0"
 
 750     virtual void Destroy();
 
 755 // The C++ version of wxPyGridCellEditor
 
 757 class wxPyGridCellEditor : public wxGridCellEditor
 
 760     wxPyGridCellEditor() : wxGridCellEditor() {}
 
 762     void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
 
 763         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 764         if (wxPyCBH_findCallback(m_myInst, "Create")) {
 
 765             PyObject* po = wxPyMake_wxObject(parent,false);
 
 766             PyObject* eo = wxPyMake_wxObject(evtHandler,false);
 
 768             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", po, id, eo));
 
 772         wxPyEndBlockThreads(blocked);
 
 776     void BeginEdit(int row, int col, wxGrid* grid) {
 
 777         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 778         if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) {
 
 779             PyObject* go = wxPyMake_wxObject(grid,false);
 
 780             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
 
 783         wxPyEndBlockThreads(blocked);
 
 787     bool EndEdit(int row, int col, wxGrid* grid) {
 
 789         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 790         if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
 
 791             PyObject* go = wxPyMake_wxObject(grid,false);
 
 792             rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
 
 795         wxPyEndBlockThreads(blocked);
 
 800     wxGridCellEditor* Clone() const {
 
 801         wxGridCellEditor* rval = NULL;
 
 802         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 803         if (wxPyCBH_findCallback(m_myInst, "Clone")) {
 
 805             wxGridCellEditor* ptr;
 
 806             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 808                 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxGridCellEditor")))
 
 813         wxPyEndBlockThreads(blocked);
 
 818     void Show(bool show, wxGridCellAttr *attr) {
 
 820         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 821         if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) {
 
 822             PyObject* ao = wxPyMake_wxGridCellAttr(attr,false);
 
 823             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", show, ao));
 
 826         wxPyEndBlockThreads(blocked);
 
 828             wxGridCellEditor::Show(show, attr);
 
 832     void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
 
 834         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 835         if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) {
 
 836             PyObject* ao = wxPyMake_wxGridCellAttr(attr,false);
 
 837             PyObject* ro = wxPyConstructObject((void*)&rectCell, wxT("wxRect"), 0);
 
 839             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", ro, ao));
 
 844         wxPyEndBlockThreads(blocked);
 
 846             wxGridCellEditor::PaintBackground(rectCell, attr);
 
 850     DEC_PYCALLBACK___pure(Reset);
 
 851     DEC_PYCALLBACK__constany(SetSize, wxRect);
 
 852     DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent);
 
 853     DEC_PYCALLBACK__any(StartingKey, wxKeyEvent);
 
 854     DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent);
 
 855     DEC_PYCALLBACK__(StartingClick);
 
 856     DEC_PYCALLBACK__(Destroy);
 
 857     DEC_PYCALLBACK__STRING(SetParameters);
 
 858     DEC_PYCALLBACK_STRING__constpure(GetValue);
 
 864 IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters);
 
 865 IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset);
 
 866 IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect);
 
 867 IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent);
 
 868 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent);
 
 869 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent);
 
 870 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick);
 
 871 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, Destroy);
 
 872 IMP_PYCALLBACK_STRING__constpure(wxPyGridCellEditor, wxGridCellEditor, GetValue);
 
 877 // Let SWIG know about it so it can create the Python version
 
 878 class wxPyGridCellEditor : public wxGridCellEditor {
 
 880     %pythonAppend wxPyGridCellEditor  "self._setCallbackInfo(self, PyGridCellEditor);self._setOORInfo(self)"
 
 882     wxPyGridCellEditor();
 
 883     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 885     void SetSize(const wxRect& rect);
 
 886     void Show(bool show, wxGridCellAttr *attr = NULL);
 
 887     void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
 
 888     bool IsAcceptedKey(wxKeyEvent& event);
 
 889     void StartingKey(wxKeyEvent& event);
 
 890     void StartingClick();
 
 891     void HandleReturn(wxKeyEvent& event);
 
 893     void SetParameters(const wxString& params);
 
 895     %MAKE_BASE_FUNC(PyGridCellEditor, SetSize);
 
 896     %MAKE_BASE_FUNC(PyGridCellEditor, Show);
 
 897     %MAKE_BASE_FUNC(PyGridCellEditor, PaintBackground);
 
 898     %MAKE_BASE_FUNC(PyGridCellEditor, IsAcceptedKey);
 
 899     %MAKE_BASE_FUNC(PyGridCellEditor, StartingKey);
 
 900     %MAKE_BASE_FUNC(PyGridCellEditor, StartingClick);
 
 901     %MAKE_BASE_FUNC(PyGridCellEditor, HandleReturn);
 
 902     %MAKE_BASE_FUNC(PyGridCellEditor, Destroy);
 
 903     %MAKE_BASE_FUNC(PyGridCellEditor, SetParameters);
 
 906 //---------------------------------------------------------------------------
 
 907 //  Predefined Editors
 
 909 class wxGridCellTextEditor : public wxGridCellEditor
 
 912     %pythonAppend wxGridCellTextEditor  "self._setOORInfo(self)"
 
 913     wxGridCellTextEditor();
 
 914     virtual wxString GetValue();
 
 918 class wxGridCellNumberEditor : public wxGridCellTextEditor
 
 921     %pythonAppend wxGridCellNumberEditor  "self._setOORInfo(self)"
 
 922     wxGridCellNumberEditor(int min = -1, int max = -1);
 
 923     virtual wxString GetValue();
 
 927 class wxGridCellFloatEditor : public wxGridCellTextEditor
 
 930     %pythonAppend wxGridCellFloatEditor  "self._setOORInfo(self)"
 
 931     wxGridCellFloatEditor(int width = -1, int precision = -1);
 
 932     virtual wxString GetValue();
 
 936 class wxGridCellBoolEditor : public wxGridCellEditor
 
 939     %pythonAppend wxGridCellBoolEditor  "self._setOORInfo(self)"
 
 940     wxGridCellBoolEditor();
 
 941     virtual wxString GetValue();
 
 944 class wxGridCellChoiceEditor : public wxGridCellEditor
 
 947     %pythonAppend wxGridCellChoiceEditor  "self._setOORInfo(self)"
 
 948     wxGridCellChoiceEditor(int choices = 0,
 
 949                            const wxString* choices_array = NULL,
 
 950                            bool allowOthers = false);
 
 951     virtual wxString GetValue();
 
 955 class wxGridCellEnumEditor : public wxGridCellChoiceEditor
 
 958     %pythonAppend wxGridCellEnumEditor  "self._setOORInfo(self)"
 
 959     wxGridCellEnumEditor( const wxString& choices = wxPyEmptyString );
 
 960     virtual wxString GetValue();
 
 964 class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
 
 967     %pythonAppend wxGridCellAutoWrapStringEditor  "self._setOORInfo(self)"
 
 968     wxGridCellAutoWrapStringEditor();
 
 969     virtual wxString GetValue();
 
 974 //---------------------------------------------------------------------------
 
 991         void _setOORInfo(PyObject* _self) {
 
 992             if (!self->GetClientObject())
 
 993                 self->SetClientObject(new wxPyOORClientData(_self));
 
 997     %pythonAppend wxGridCellAttr  "self._setOORInfo(self)"
 
 999     wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
 
1002         // A dummy dtor to shut up SWIG.  (The real one is protected and can
 
1003         // only be called by DecRef)
 
1008     wxGridCellAttr *Clone() const;
 
1009     void MergeWith(wxGridCellAttr *mergefrom);
 
1014     void SetTextColour(const wxColour& colText);
 
1015     void SetBackgroundColour(const wxColour& colBack);
 
1016     void SetFont(const wxFont& font);
 
1017     void SetAlignment(int hAlign, int vAlign);
 
1018     void SetSize(int num_rows, int num_cols);
 
1019     void SetOverflow( bool allow = true );
 
1020     void SetReadOnly(bool isReadOnly = true);
 
1022     void SetRenderer(wxGridCellRenderer *renderer);
 
1023     void SetEditor(wxGridCellEditor* editor);
 
1024     void SetKind(wxAttrKind kind);
 
1026     bool HasTextColour() const;
 
1027     bool HasBackgroundColour() const;
 
1028     bool HasFont() const;
 
1029     bool HasAlignment() const;
 
1030     bool HasRenderer() const;
 
1031     bool HasEditor() const;
 
1032     bool HasReadWriteMode() const;
 
1033     bool HasOverflowMode() const;
 
1035     wxColour GetTextColour() const;
 
1036     wxColour GetBackgroundColour() const;
 
1037     wxFont GetFont() const;
 
1040         void, GetAlignment(int *OUTPUT, int *OUTPUT) const,
 
1041         "GetAlignment() -> (hAlign, vAlign)");
 
1044         void, GetSize(int *OUTPUT, int *OUTPUT) const,
 
1045         "GetSize() -> (num_rows, num_cols)");
 
1047     bool GetOverflow() const;
 
1048     wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
 
1049     wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
 
1051     bool IsReadOnly() const;
 
1052     wxAttrKind GetKind();
 
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             if (!self->GetClientObject())
 
1068                 self->SetClientObject(new wxPyOORClientData(_self));
 
1072     wxGridCellAttr *GetAttr(int row, int col,
 
1073                             wxGridCellAttr::wxAttrKind  kind) const;
 
1074     void SetAttr(wxGridCellAttr *attr, int row, int col);
 
1075     void SetRowAttr(wxGridCellAttr *attr, int row);
 
1076     void SetColAttr(wxGridCellAttr *attr, int col);
 
1078     void UpdateAttrRows( size_t pos, int numRows );
 
1079     void UpdateAttrCols( size_t pos, int numCols );
 
1084 // A Python-aware version
 
1086 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
 
1089     wxPyGridCellAttrProvider() : wxGridCellAttrProvider() {};
 
1091     PYCALLBACK_GCA_INTINTKIND(wxGridCellAttrProvider, GetAttr);
 
1092     PYCALLBACK__GCAINTINT(wxGridCellAttrProvider, SetAttr);
 
1093     PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetRowAttr);
 
1094     PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetColAttr);
 
1101 // The python-aware version get's SWIGified
 
1102 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
 
1105     %pythonAppend wxPyGridCellAttrProvider  "self._setCallbackInfo(self, PyGridCellAttrProvider)"
 
1106     wxPyGridCellAttrProvider();
 
1107     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
1109     wxGridCellAttr *GetAttr(int row, int col,
 
1110                             wxGridCellAttr::wxAttrKind kind);
 
1111     void SetAttr(wxGridCellAttr *attr, int row, int col);
 
1112     void SetRowAttr(wxGridCellAttr *attr, int row);
 
1113     void SetColAttr(wxGridCellAttr *attr, int col);
 
1115     %MAKE_BASE_FUNC(PyGridCellAttrProvider, GetAttr);
 
1116     %MAKE_BASE_FUNC(PyGridCellAttrProvider, SetAttr);
 
1117     %MAKE_BASE_FUNC(PyGridCellAttrProvider, SetRowAttr);
 
1118     %MAKE_BASE_FUNC(PyGridCellAttrProvider, SetColAttr);
 
1122 //---------------------------------------------------------------------------
 
1123 // Grid Table Base class and Python aware version
 
1126 class wxGridTableBase : public wxObject
 
1129     // wxGridTableBase();   This is an ABC
 
1130     //~wxGridTableBase();
 
1133         void _setOORInfo(PyObject* _self) {
 
1134             if (!self->GetClientObject())
 
1135                 self->SetClientObject(new wxPyOORClientData(_self));
 
1139     void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
 
1140     wxGridCellAttrProvider *GetAttrProvider() const;
 
1141     void SetView( wxGrid *grid );
 
1142     wxGrid * GetView() const;
 
1146     virtual int GetNumberRows();
 
1147     virtual int GetNumberCols();
 
1148     virtual bool IsEmptyCell( int row, int col );
 
1149     virtual wxString GetValue( int row, int col );
 
1150     virtual void SetValue( int row, int col, const wxString& value );
 
1152     // virtuals overridable in wxPyGridTableBase
 
1153     virtual wxString GetTypeName( int row, int col );
 
1154     virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
 
1155     virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
 
1156     virtual long GetValueAsLong( int row, int col );
 
1157     virtual double GetValueAsDouble( int row, int col );
 
1158     virtual bool GetValueAsBool( int row, int col );
 
1159     virtual void SetValueAsLong( int row, int col, long value );
 
1160     virtual void SetValueAsDouble( int row, int col, double value );
 
1161     virtual void SetValueAsBool( int row, int col, bool value );
 
1163     //virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
 
1164     //virtual void  SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
 
1167     virtual void Clear();
 
1168     virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
 
1169     virtual bool AppendRows( size_t numRows = 1 );
 
1170     virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
 
1171     virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
 
1172     virtual bool AppendCols( size_t numCols = 1 );
 
1173     virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
 
1175     virtual wxString GetRowLabelValue( int row );
 
1176     virtual wxString GetColLabelValue( int col );
 
1177     virtual void SetRowLabelValue( int row, const wxString& value );
 
1178     virtual void SetColLabelValue( int col, const wxString& value );
 
1180     virtual bool CanHaveAttributes();
 
1182     virtual wxGridCellAttr *GetAttr( int row, int col,
 
1183                                      wxGridCellAttr::wxAttrKind  kind);
 
1184     virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
 
1185     virtual void SetRowAttr(wxGridCellAttr *attr, int row);
 
1186     virtual void SetColAttr(wxGridCellAttr *attr, int col);
 
1192 // Python-aware version
 
1194 class wxPyGridTableBase : public wxGridTableBase
 
1197     wxPyGridTableBase() : wxGridTableBase() {}
 
1199     PYCALLBACK_INT__pure(GetNumberRows);
 
1200     PYCALLBACK_INT__pure(GetNumberCols);
 
1201     PYCALLBACK_BOOL_INTINT_pure(IsEmptyCell);
 
1202     PYCALLBACK_STRING_INTINT(wxGridTableBase, GetTypeName);
 
1203     PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanGetValueAs);
 
1204     PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanSetValueAs);
 
1205     PYCALLBACK__(wxGridTableBase, Clear);
 
1206     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertRows);
 
1207     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteRows);
 
1208     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertCols);
 
1209     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteCols);
 
1210     PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendRows);
 
1211     PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendCols);
 
1212     PYCALLBACK_STRING_INT(wxGridTableBase, GetRowLabelValue);
 
1213     PYCALLBACK_STRING_INT(wxGridTableBase, GetColLabelValue);
 
1214     PYCALLBACK__INTSTRING(wxGridTableBase, SetRowLabelValue);
 
1215     PYCALLBACK__INTSTRING(wxGridTableBase, SetColLabelValue);
 
1216     PYCALLBACK_BOOL_(wxGridTableBase, CanHaveAttributes);
 
1217     PYCALLBACK_GCA_INTINTKIND(wxGridTableBase, GetAttr);
 
1218     PYCALLBACK__GCAINTINT(wxGridTableBase, SetAttr);
 
1219     PYCALLBACK__GCAINT(wxGridTableBase, SetRowAttr);
 
1220     PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
 
1223     wxString GetValue(int row, int col) {
 
1224         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1226         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1228             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
 
1230                 if (!PyString_Check(ro) && !PyUnicode_Check(ro)) {
 
1232                     ro = PyObject_Str(ro);
 
1235                 rval = Py2wxString(ro);
 
1239         wxPyEndBlockThreads(blocked);
 
1243     void SetValue(int row, int col, const wxString& val) {
 
1244         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1245         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1246             PyObject* s = wx2PyString(val);
 
1247             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,s));
 
1250         wxPyEndBlockThreads(blocked);
 
1254     // Map the Get/Set methods for the standard non-string types to
 
1255     // the GetValue and SetValue python methods.
 
1256     long GetValueAsLong( int row, int col ) {
 
1258         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1259         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1262             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
 
1263             if (ro && PyNumber_Check(ro)) {
 
1264                 num = PyNumber_Int(ro);
 
1266                     rval = PyInt_AsLong(num);
 
1272         wxPyEndBlockThreads(blocked);
 
1276     double GetValueAsDouble( int row, int col ) {
 
1278         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1279         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1282             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
 
1283             if (ro && PyNumber_Check(ro)) {
 
1284                 num = PyNumber_Float(ro);
 
1286                     rval = PyFloat_AsDouble(num);
 
1292         wxPyEndBlockThreads(blocked);
 
1296     bool GetValueAsBool( int row, int col ) {
 
1297         return (bool)GetValueAsLong(row, col);
 
1300     void SetValueAsLong( int row, int col, long value ) {
 
1301         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1302         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1303             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value));
 
1305         wxPyEndBlockThreads(blocked);
 
1308     void SetValueAsDouble( int row, int col, double value ) {
 
1309         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
1310         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1311             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value));
 
1313         wxPyEndBlockThreads(blocked);
 
1316     void SetValueAsBool( int row, int col, bool value ) {
 
1317         SetValueAsLong( row, col, (long)value );
 
1326 // The python-aware version get's SWIGified
 
1327 class wxPyGridTableBase : public wxGridTableBase
 
1330     %pythonAppend wxPyGridTableBase "self._setCallbackInfo(self, PyGridTableBase);self._setOORInfo(self)"
 
1331     wxPyGridTableBase();
 
1332     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
1334     %pythonAppend Destroy "args[0].thisown = 0"
 
1335     %extend { void Destroy() { delete self; } }
 
1337     wxString GetTypeName( int row, int col );
 
1338     bool CanGetValueAs( int row, int col, const wxString& typeName );
 
1339     bool CanSetValueAs( int row, int col, const wxString& typeName );
 
1341     bool InsertRows( size_t pos = 0, size_t numRows = 1 );
 
1342     bool AppendRows( size_t numRows = 1 );
 
1343     bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
 
1344     bool InsertCols( size_t pos = 0, size_t numCols = 1 );
 
1345     bool AppendCols( size_t numCols = 1 );
 
1346     bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
 
1347     wxString GetRowLabelValue( int row );
 
1348     wxString GetColLabelValue( int col );
 
1349     void SetRowLabelValue( int row, const wxString& value );
 
1350     void SetColLabelValue( int col, const wxString& value );
 
1351     bool CanHaveAttributes();
 
1352     wxGridCellAttr *GetAttr( int row, int col,
 
1353                                   wxGridCellAttr::wxAttrKind kind );
 
1354     void SetAttr(wxGridCellAttr* attr, int row, int col);
 
1355     void SetRowAttr(wxGridCellAttr *attr, int row);
 
1356     void SetColAttr(wxGridCellAttr *attr, int col);
 
1358     %MAKE_BASE_FUNC(PyGridTableBase, GetTypeName);
 
1359     %MAKE_BASE_FUNC(PyGridTableBase, CanGetValueAs);
 
1360     %MAKE_BASE_FUNC(PyGridTableBase, CanSetValueAs);
 
1361     %MAKE_BASE_FUNC(PyGridTableBase, Clear);
 
1362     %MAKE_BASE_FUNC(PyGridTableBase, InsertRows);
 
1363     %MAKE_BASE_FUNC(PyGridTableBase, AppendRows);
 
1364     %MAKE_BASE_FUNC(PyGridTableBase, DeleteRows);
 
1365     %MAKE_BASE_FUNC(PyGridTableBase, InsertCols);
 
1366     %MAKE_BASE_FUNC(PyGridTableBase, AppendCols);
 
1367     %MAKE_BASE_FUNC(PyGridTableBase, DeleteCols);
 
1368     %MAKE_BASE_FUNC(PyGridTableBase, GetRowLabelValue);
 
1369     %MAKE_BASE_FUNC(PyGridTableBase, GetColLabelValue);
 
1370     %MAKE_BASE_FUNC(PyGridTableBase, SetRowLabelValue);
 
1371     %MAKE_BASE_FUNC(PyGridTableBase, SetColLabelValue);
 
1372     %MAKE_BASE_FUNC(PyGridTableBase, CanHaveAttributes);
 
1373     %MAKE_BASE_FUNC(PyGridTableBase, GetAttr);
 
1374     %MAKE_BASE_FUNC(PyGridTableBase, SetAttr);
 
1375     %MAKE_BASE_FUNC(PyGridTableBase, SetRowAttr);
 
1376     %MAKE_BASE_FUNC(PyGridTableBase, SetColAttr);
 
1380 //---------------------------------------------------------------------------
 
1381 // Predefined Tables
 
1383 class  wxGridStringTable : public wxGridTableBase
 
1386     %pythonAppend wxGridStringTable "self._setOORInfo(self)"
 
1387     wxGridStringTable( int numRows=0, int numCols=0 );
 
1390 //---------------------------------------------------------------------------
 
1391 // The Table can pass messages to the grid to tell it to update itself if
 
1392 // something has changed.
 
1394 enum wxGridTableRequest
 
1396     wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
 
1397     wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
 
1398     wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
 
1399     wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
 
1400     wxGRIDTABLE_NOTIFY_ROWS_DELETED,
 
1401     wxGRIDTABLE_NOTIFY_COLS_INSERTED,
 
1402     wxGRIDTABLE_NOTIFY_COLS_APPENDED,
 
1403     wxGRIDTABLE_NOTIFY_COLS_DELETED
 
1407 class wxGridTableMessage
 
1410     wxGridTableMessage( wxGridTableBase *table, int id,
 
1413     ~wxGridTableMessage();
 
1415     void SetTableObject( wxGridTableBase *table );
 
1416     wxGridTableBase * GetTableObject() const;
 
1417     void SetId( int id );
 
1419     void SetCommandInt( int comInt1 );
 
1420     int  GetCommandInt();
 
1421     void SetCommandInt2( int comInt2 );
 
1422     int  GetCommandInt2();
 
1426 //---------------------------------------------------------------------------
 
1429 // Typemap to allow conversion of sequence objects to wxGridCellCoords...
 
1430 %typemap(in) wxGridCellCoords& (wxGridCellCoords temp) {
 
1432     if (! wxGridCellCoords_helper($input, &$1)) SWIG_fail;
 
1434 %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxGridCellCoords& {
 
1435     $1 = wxGridCellCoords_typecheck($input);
 
1439 // ...and here is the associated helper.
 
1441 bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
 
1443     if (source == Py_None) {
 
1444         **obj = wxGridCellCoords(-1,-1);
 
1448     // If source is an object instance then it may already be the right type
 
1449     if (wxPySwigInstance_Check(source)) {
 
1450         wxGridCellCoords* ptr;
 
1451         if (! wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
 
1456     // otherwise a 2-tuple of integers is expected
 
1457     else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
 
1458         PyObject* o1 = PySequence_GetItem(source, 0);
 
1459         PyObject* o2 = PySequence_GetItem(source, 1);
 
1460         if (!PyNumber_Check(o1) || !PyNumber_Check(o2)) {
 
1465         **obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2));
 
1472     PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object.");
 
1477 bool wxGridCellCoords_typecheck(PyObject* source) {
 
1480     if (wxPySwigInstance_Check(source) &&
 
1481         wxPyConvertSwigPtr(source, (void **)&ptr, wxT("wxGridCellCoords")))
 
1485     if (PySequence_Check(source) && PySequence_Length(source) == 2)
 
1493 // Typemap to convert an array of cells coords to a list of tuples...
 
1494 %typemap(out) wxGridCellCoordsArray {
 
1495     $result = wxGridCellCoordsArray_helper($1);
 
1498 // %typemap(ret) wxGridCellCoordsArray {
 
1503 // ...and the helper function for the above typemap.
 
1505 PyObject* wxGridCellCoordsArray_helper(const wxGridCellCoordsArray& source)
 
1507     PyObject* list = PyList_New(0);
 
1509     for (idx = 0; idx < source.GetCount(); idx += 1) {
 
1510         wxGridCellCoords& coord = source.Item(idx);
 
1511         PyObject* tup = PyTuple_New(2);
 
1512         PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(coord.GetRow()));
 
1513         PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(coord.GetCol()));
 
1514         PyList_Append(list, tup);
 
1525 class wxGridCellCoords
 
1528     wxGridCellCoords( int r=-1, int c=-1 );
 
1529     ~wxGridCellCoords();
 
1532     void SetRow( int n );
 
1534     void SetCol( int n );
 
1535     void Set( int row, int col );
 
1537     bool operator==( const wxGridCellCoords& other ) const;
 
1538     bool operator!=( const wxGridCellCoords& other ) const;
 
1542             PyObject* tup = PyTuple_New(2);
 
1543             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
 
1544             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
 
1549     asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
 
1550     def __str__(self):                   return str(self.Get())
 
1551     def __repr__(self):                  return 'wxGridCellCoords'+str(self.Get())
 
1552     def __len__(self):                   return len(self.Get())
 
1553     def __getitem__(self, index):        return self.asTuple()[index]
 
1554     def __setitem__(self, index, val):
 
1555         if index == 0: self.SetRow(val)
 
1556         elif index == 1: self.SetCol(val)
 
1557         else: raise IndexError
 
1563 //---------------------------------------------------------------------------
 
1564 //---------------------------------------------------------------------------
 
1568 // Fool SWIG into treating this enum as an int
 
1569 typedef int WXGRIDSELECTIONMODES;
 
1571 // but let the C++ code know what it really is.
 
1573 typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES;
 
1578 MustHaveApp(wxGrid);
 
1580 class wxGrid : public wxScrolledWindow
 
1583     %pythonAppend wxGrid "self._setOORInfo(self)"
 
1584     %pythonAppend wxGrid() ""
 
1586     %typemap(out) wxGrid*;    // turn off this typemap
 
1588     wxGrid( wxWindow *parent,
 
1590             const wxPoint& pos = wxDefaultPosition,
 
1591             const wxSize& size = wxDefaultSize,
 
1592             long style = wxWANTS_CHARS,
 
1593             const wxString& name = wxPyPanelNameStr);
 
1595     %RenameCtor(PreGrid,  wxGrid());
 
1598     // Turn it back on again
 
1599     %typemap(out) wxGrid* { $result = wxPyMake_wxObject($1, $owner); }
 
1602     bool Create( wxWindow *parent,
 
1604                  const wxPoint& pos = wxDefaultPosition,
 
1605                  const wxSize& size = wxDefaultSize,
 
1606                  long style = wxWANTS_CHARS,
 
1607                  const wxString& name = wxPyPanelNameStr );
 
1610     enum wxGridSelectionModes {
 
1616         SelectCells =   wxGridSelectCells
 
1617         SelectRows =    wxGridSelectRows
 
1618         SelectColumns = wxGridSelectColumns
 
1621     bool CreateGrid( int numRows, int numCols,
 
1622                      WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells );
 
1623     void SetSelectionMode(WXGRIDSELECTIONMODES selmode);
 
1624     WXGRIDSELECTIONMODES GetSelectionMode();
 
1627     // ------ grid dimensions
 
1629     int      GetNumberRows();
 
1630     int      GetNumberCols();
 
1633     bool ProcessTableMessage( wxGridTableMessage& );
 
1636     wxGridTableBase * GetTable() const;
 
1637     bool SetTable( wxGridTableBase *table, bool takeOwnership=false,
 
1638                    WXGRIDSELECTIONMODES selmode =
 
1639                    wxGrid::wxGridSelectCells );
 
1642     bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=true );
 
1643     bool AppendRows( int numRows = 1, bool updateLabels=true );
 
1644     bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=true );
 
1645     bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=true );
 
1646     bool AppendCols( int numCols = 1, bool updateLabels=true );
 
1647     bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=true );
 
1650     // this function is called when the current cell highlight must be redrawn
 
1651     // and may be overridden by the user
 
1652     virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
 
1655     // ------ Cell text drawing functions
 
1657     void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
 
1658                             int horizontalAlignment = wxLEFT,
 
1659                             int verticalAlignment = wxTOP,
 
1660                             int textOrientation = wxHORIZONTAL );
 
1662 //      // Split a string containing newline chararcters into an array of
 
1663 //      // strings and return the number of lines
 
1665 //      void StringToLines( const wxString& value, wxArrayString& lines );
 
1668         void, GetTextBoxSize( wxDC& dc, wxArrayString& lines,
 
1669                               long *OUTPUT, long *OUTPUT ),
 
1670         "GetTextBoxSize(DC dc, list lines) -> (width, height)");
 
1674     // Code that does a lot of grid modification can be enclosed
 
1675     // between BeginBatch() and EndBatch() calls to avoid screen
 
1680     int      GetBatchCount();
 
1681     void     ForceRefresh();
 
1684     // ------ edit control functions
 
1687     void EnableEditing( bool edit );
 
1689     void EnableCellEditControl( bool enable = true );
 
1690     void DisableCellEditControl();
 
1691     bool CanEnableCellControl() const;
 
1692     bool IsCellEditControlEnabled() const;
 
1693     bool IsCellEditControlShown() const;
 
1695     bool IsCurrentCellReadOnly() const;
 
1697     void ShowCellEditControl();
 
1698     void HideCellEditControl();
 
1699     void SaveEditControlValue();
 
1702     // ------ grid location functions
 
1703     //  Note that all of these functions work with the logical coordinates of
 
1704     //  grid cells and labels so you will need to convert from device
 
1705     //  coordinates for mouse events etc.
 
1708     //void XYToCell( int x, int y, wxGridCellCoords& );
 
1710         wxGridCellCoords XYToCell(int x, int y) {
 
1711             wxGridCellCoords rv;
 
1712             self->XYToCell(x, y, rv);
 
1717     int  YToRow( int y );
 
1718     int  XToCol( int x );
 
1720     int  YToEdgeOfRow( int y );
 
1721     int  XToEdgeOfCol( int x );
 
1723     wxRect CellToRect( int row, int col );
 
1724     // TODO: ??? wxRect CellToRect( const wxGridCellCoords& coords );
 
1727     int  GetGridCursorRow();
 
1728     int  GetGridCursorCol();
 
1730     // check to see if a cell is either wholly visible (the default arg) or
 
1731     // at least partially visible in the grid window
 
1733     bool IsVisible( int row, int col, bool wholeCellVisible = true );
 
1734     // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = true );
 
1735     void MakeCellVisible( int row, int col );
 
1736     // TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords );
 
1739     // ------ grid cursor movement functions
 
1741     void SetGridCursor( int row, int col );
 
1742     bool MoveCursorUp( bool expandSelection );
 
1743     bool MoveCursorDown( bool expandSelection );
 
1744     bool MoveCursorLeft( bool expandSelection );
 
1745     bool MoveCursorRight( bool expandSelection );
 
1746     bool MovePageDown();
 
1748     bool MoveCursorUpBlock( bool expandSelection );
 
1749     bool MoveCursorDownBlock( bool expandSelection );
 
1750     bool MoveCursorLeftBlock( bool expandSelection );
 
1751     bool MoveCursorRightBlock( bool expandSelection );
 
1754     // ------ label and gridline formatting
 
1756     int      GetDefaultRowLabelSize();
 
1757     int      GetRowLabelSize();
 
1758     int      GetDefaultColLabelSize();
 
1759     int      GetColLabelSize();
 
1760     wxColour GetLabelBackgroundColour();
 
1761     wxColour GetLabelTextColour();
 
1762     wxFont   GetLabelFont();
 
1765         void, GetRowLabelAlignment( int *OUTPUT, int *OUTPUT ),
 
1766         "GetRowLabelAlignment() -> (horiz, vert)");
 
1769         void, GetColLabelAlignment( int *OUTPUT, int *OUTPUT ),
 
1770         "GetColLabelAlignment() -> (horiz, vert)");
 
1772     int      GetColLabelTextOrientation();
 
1773     wxString GetRowLabelValue( int row );
 
1774     wxString GetColLabelValue( int col );
 
1775     wxColour GetGridLineColour();
 
1776     wxColour GetCellHighlightColour();
 
1777     int      GetCellHighlightPenWidth();
 
1778     int      GetCellHighlightROPenWidth();
 
1780     void     SetRowLabelSize( int width );
 
1781     void     SetColLabelSize( int height );
 
1782     void     SetLabelBackgroundColour( const wxColour& );
 
1783     void     SetLabelTextColour( const wxColour& );
 
1784     void     SetLabelFont( const wxFont& );
 
1785     void     SetRowLabelAlignment( int horiz, int vert );
 
1786     void     SetColLabelAlignment( int horiz, int vert );
 
1787     void     SetColLabelTextOrientation( int textOrientation );
 
1788     void     SetRowLabelValue( int row, const wxString& );
 
1789     void     SetColLabelValue( int col, const wxString& );
 
1790     void     SetGridLineColour( const wxColour& );
 
1791     void     SetCellHighlightColour( const wxColour& );
 
1792     void     SetCellHighlightPenWidth(int width);
 
1793     void     SetCellHighlightROPenWidth(int width);
 
1795     void     EnableDragRowSize( bool enable = true );
 
1796     void     DisableDragRowSize();
 
1797     bool     CanDragRowSize();
 
1798     void     EnableDragColSize( bool enable = true );
 
1799     void     DisableDragColSize();
 
1800     bool     CanDragColSize();
 
1801     void     EnableDragGridSize(bool enable = true);
 
1802     void     DisableDragGridSize();
 
1803     bool     CanDragGridSize();
 
1805     void     EnableDragCell( bool enable = true );
 
1806     void     DisableDragCell();
 
1809     // this sets the specified attribute for all cells in this row/col
 
1810     void     SetAttr(int row, int col, wxGridCellAttr *attr);
 
1811     void     SetRowAttr(int row, wxGridCellAttr *attr);
 
1812     void     SetColAttr(int col, wxGridCellAttr *attr);
 
1814     // returns the attribute we may modify in place: a new one if this cell
 
1815     // doesn't have any yet or the existing one if it does
 
1817     // DecRef() must be called on the returned pointer, as usual
 
1818     wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
 
1821     // shortcuts for setting the column parameters
 
1823     // set the format for the data in the column: default is string
 
1824     void     SetColFormatBool(int col);
 
1825     void     SetColFormatNumber(int col);
 
1826     void     SetColFormatFloat(int col, int width = -1, int precision = -1);
 
1827     void     SetColFormatCustom(int col, const wxString& typeName);
 
1829     void     EnableGridLines( bool enable = true );
 
1830     bool     GridLinesEnabled();
 
1832     // ------ row and col formatting
 
1834     int      GetDefaultRowSize();
 
1835     int      GetRowSize( int row );
 
1836     int      GetDefaultColSize();
 
1837     int      GetColSize( int col );
 
1838     wxColour GetDefaultCellBackgroundColour();
 
1839     wxColour GetCellBackgroundColour( int row, int col );
 
1840     wxColour GetDefaultCellTextColour();
 
1841     wxColour GetCellTextColour( int row, int col );
 
1842     wxFont   GetDefaultCellFont();
 
1843     wxFont   GetCellFont( int row, int col );
 
1846         void, GetDefaultCellAlignment( int *OUTPUT, int *OUTPUT ),
 
1847         "GetDefaultCellAlignment() -> (horiz, vert)");
 
1850         void, GetCellAlignment( int row, int col, int *OUTPUT, int *OUTPUT ),
 
1851         "GetCellAlignment() -> (horiz, vert)");
 
1853     bool     GetDefaultCellOverflow();
 
1854     bool     GetCellOverflow( int row, int col );
 
1857         void, GetCellSize( int row, int col, int *OUTPUT, int *OUTPUT ),
 
1858         "GetCellSize(int row, int col) -> (num_rows, num_cols)");
 
1860     void     SetDefaultRowSize( int height, bool resizeExistingRows = false );
 
1861     void     SetRowSize( int row, int height );
 
1862     void     SetDefaultColSize( int width, bool resizeExistingCols = false );
 
1864     void     SetColSize( int col, int width );
 
1866     // automatically size the column or row to fit to its contents, if
 
1867     // setAsMin is True, this optimal width will also be set as minimal width
 
1869     void     AutoSizeColumn( int col, bool setAsMin = true );
 
1870     void     AutoSizeRow( int row, bool setAsMin = true );
 
1873     // auto size all columns (very ineffective for big grids!)
 
1874     void     AutoSizeColumns( bool setAsMin = true );
 
1875     void     AutoSizeRows( bool setAsMin = true );
 
1877     // auto size the grid, that is make the columns/rows of the "right" size
 
1878     // and also set the grid size to just fit its contents
 
1881     // autosize row height depending on label text
 
1882     void     AutoSizeRowLabelSize( int row );
 
1884     // autosize column width depending on label text
 
1885     void     AutoSizeColLabelSize( int col );
 
1888     // column won't be resized to be lesser width - this must be called during
 
1889     // the grid creation because it won't resize the column if it's already
 
1890     // narrower than the minimal width
 
1891     void     SetColMinimalWidth( int col, int width );
 
1892     void     SetRowMinimalHeight( int row, int width );
 
1894     void     SetColMinimalAcceptableWidth( int width );
 
1895     void     SetRowMinimalAcceptableHeight( int width );
 
1896     int      GetColMinimalAcceptableWidth() const;
 
1897     int      GetRowMinimalAcceptableHeight() const;
 
1899     void     SetDefaultCellBackgroundColour( const wxColour& );
 
1900     void     SetCellBackgroundColour( int row, int col, const wxColour& );
 
1901     void     SetDefaultCellTextColour( const wxColour& );
 
1903     void     SetCellTextColour( int row, int col, const wxColour& );
 
1904     void     SetDefaultCellFont( const wxFont& );
 
1905     void     SetCellFont( int row, int col, const wxFont& );
 
1906     void     SetDefaultCellAlignment( int horiz, int vert );
 
1907     void     SetCellAlignment( int row, int col, int horiz, int vert );
 
1908     void     SetDefaultCellOverflow( bool allow );
 
1909     void     SetCellOverflow( int row, int col, bool allow );
 
1910     void     SetCellSize( int row, int col, int num_rows, int num_cols );
 
1912     // takes ownership of the pointer
 
1913     void SetDefaultRenderer(wxGridCellRenderer *renderer);
 
1914     void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
 
1915     wxGridCellRenderer *GetDefaultRenderer() const;
 
1916     wxGridCellRenderer* GetCellRenderer(int row, int col);
 
1918     // takes ownership of the pointer
 
1919     void SetDefaultEditor(wxGridCellEditor *editor);
 
1920     void SetCellEditor(int row, int col, wxGridCellEditor *editor);
 
1921     wxGridCellEditor *GetDefaultEditor() const;
 
1922     wxGridCellEditor* GetCellEditor(int row, int col);
 
1926     // ------ cell value accessors
 
1928     wxString GetCellValue( int row, int col );
 
1929     // TODO: ??? wxString GetCellValue( const wxGridCellCoords& coords )
 
1931     void SetCellValue( int row, int col, const wxString& s );
 
1932     // TODO: ??? void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
 
1934     // returns True if the cell can't be edited
 
1935     bool IsReadOnly(int row, int col) const;
 
1937     // make the cell editable/readonly
 
1938     void SetReadOnly(int row, int col, bool isReadOnly = true);
 
1940     // ------ selections of blocks of cells
 
1942     void SelectRow( int row, bool addToSelected = false );
 
1943     void SelectCol( int col, bool addToSelected = false );
 
1945     void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
 
1946                       bool addToSelected = false );
 
1947     // TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft,
 
1948     // TODO: ???                   const wxGridCellCoords& bottomRight )
 
1952     void ClearSelection();
 
1953     bool IsInSelection( int row, int col );
 
1954     // TODO: ??? bool IsInSelection( const wxGridCellCoords& coords )
 
1956     const wxGridCellCoordsArray GetSelectedCells() const;
 
1957     const wxGridCellCoordsArray GetSelectionBlockTopLeft() const;
 
1958     const wxGridCellCoordsArray GetSelectionBlockBottomRight() const;
 
1959     const wxArrayInt GetSelectedRows() const;
 
1960     const wxArrayInt GetSelectedCols() const;
 
1962     void DeselectRow( int row );
 
1963     void DeselectCol( int col );
 
1964     void DeselectCell( int row, int col );
 
1967     // This function returns the rectangle that encloses the block of cells
 
1968     // limited by TopLeft and BottomRight cell in device coords and clipped
 
1969     //  to the client size of the grid window.
 
1971     wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
 
1972                               const wxGridCellCoords & bottomRight );
 
1975     // Access or update the selection fore/back colours
 
1976     wxColour GetSelectionBackground() const;
 
1977     wxColour GetSelectionForeground() const;
 
1979     void SetSelectionBackground(const wxColour& c);
 
1980     void SetSelectionForeground(const wxColour& c);
 
1983     // Methods for a registry for mapping data types to Renderers/Editors
 
1984     void RegisterDataType(const wxString& typeName,
 
1985                           wxGridCellRenderer* renderer,
 
1986                           wxGridCellEditor* editor);
 
1987     wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
 
1988     // TODO: ??? wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
 
1989     wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
 
1990     wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
 
1991     wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
 
1993     // grid may occupy more space than needed for its rows/columns, this
 
1994     // function allows to set how big this extra space is
 
1995     void SetMargins(int extraWidth, int extraHeight);
 
1998     // Accessors for component windows
 
1999     wxWindow* GetGridWindow();
 
2000     wxWindow* GetGridRowLabelWindow();
 
2001     wxWindow* GetGridColLabelWindow();
 
2002     wxWindow* GetGridCornerLabelWindow();
 
2004     // Allow adjustment of scroll increment. The default is (15, 15).
 
2005     void SetScrollLineX(int x);
 
2006     void SetScrollLineY(int y);
 
2007     int GetScrollLineX() const;
 
2008     int GetScrollLineY() const;
 
2010     int GetScrollX(int x) const;
 
2011     int GetScrollY(int y) const;
 
2013     static wxVisualAttributes
 
2014     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
2018 //---------------------------------------------------------------------------
 
2019 //---------------------------------------------------------------------------
 
2020 // Grid events and stuff
 
2024 class wxGridEvent : public wxNotifyEvent
 
2027     wxGridEvent(int id, wxEventType type, wxGrid* obj,
 
2028                 int row=-1, int col=-1, int x=-1, int y=-1, bool sel = true,
 
2029                 bool control=false, bool shift=false, bool alt=false, bool meta=false);
 
2031     virtual int GetRow();
 
2032     virtual int GetCol();
 
2033     wxPoint     GetPosition();
 
2043 class  wxGridSizeEvent : public wxNotifyEvent
 
2046     wxGridSizeEvent(int id, wxEventType type, wxGrid* obj,
 
2047                 int rowOrCol=-1, int x=-1, int y=-1,
 
2048                 bool control=false, bool shift=false, bool alt=false, bool meta=false);
 
2051     wxPoint     GetPosition();
 
2060 class wxGridRangeSelectEvent : public wxNotifyEvent
 
2063     wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj,
 
2064                            const wxGridCellCoords& topLeft,
 
2065                            const wxGridCellCoords& bottomRight,
 
2067                            bool control=false, bool shift=false,
 
2068                            bool alt=false, bool meta=false);
 
2070     wxGridCellCoords GetTopLeftCoords();
 
2071     wxGridCellCoords GetBottomRightCoords();
 
2084 class wxGridEditorCreatedEvent : public wxCommandEvent {
 
2086     wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
 
2087                              int row, int col, wxControl* ctrl);
 
2091     wxControl* GetControl();
 
2092     void SetRow(int row);
 
2093     void SetCol(int col);
 
2094     void SetControl(wxControl* ctrl);
 
2099 %constant wxEventType wxEVT_GRID_CELL_LEFT_CLICK;
 
2100 %constant wxEventType wxEVT_GRID_CELL_RIGHT_CLICK;
 
2101 %constant wxEventType wxEVT_GRID_CELL_LEFT_DCLICK;
 
2102 %constant wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK;
 
2103 %constant wxEventType wxEVT_GRID_LABEL_LEFT_CLICK;
 
2104 %constant wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK;
 
2105 %constant wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK;
 
2106 %constant wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK;
 
2107 %constant wxEventType wxEVT_GRID_ROW_SIZE;
 
2108 %constant wxEventType wxEVT_GRID_COL_SIZE;
 
2109 %constant wxEventType wxEVT_GRID_RANGE_SELECT;
 
2110 %constant wxEventType wxEVT_GRID_CELL_CHANGE;
 
2111 %constant wxEventType wxEVT_GRID_SELECT_CELL;
 
2112 %constant wxEventType wxEVT_GRID_EDITOR_SHOWN;
 
2113 %constant wxEventType wxEVT_GRID_EDITOR_HIDDEN;
 
2114 %constant wxEventType wxEVT_GRID_EDITOR_CREATED;
 
2115 %constant wxEventType wxEVT_GRID_CELL_BEGIN_DRAG;
 
2120 EVT_GRID_CELL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_CLICK )
 
2121 EVT_GRID_CELL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_CLICK )
 
2122 EVT_GRID_CELL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_DCLICK )
 
2123 EVT_GRID_CELL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_DCLICK )
 
2124 EVT_GRID_LABEL_LEFT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_CLICK )
 
2125 EVT_GRID_LABEL_RIGHT_CLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_CLICK )
 
2126 EVT_GRID_LABEL_LEFT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_DCLICK )
 
2127 EVT_GRID_LABEL_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_DCLICK )
 
2128 EVT_GRID_ROW_SIZE = wx.PyEventBinder( wxEVT_GRID_ROW_SIZE )
 
2129 EVT_GRID_COL_SIZE = wx.PyEventBinder( wxEVT_GRID_COL_SIZE )
 
2130 EVT_GRID_RANGE_SELECT = wx.PyEventBinder( wxEVT_GRID_RANGE_SELECT )
 
2131 EVT_GRID_CELL_CHANGE = wx.PyEventBinder( wxEVT_GRID_CELL_CHANGE )
 
2132 EVT_GRID_SELECT_CELL = wx.PyEventBinder( wxEVT_GRID_SELECT_CELL )
 
2133 EVT_GRID_EDITOR_SHOWN = wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN )
 
2134 EVT_GRID_EDITOR_HIDDEN = wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN )
 
2135 EVT_GRID_EDITOR_CREATED = wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED )
 
2136 EVT_GRID_CELL_BEGIN_DRAG = wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG )
 
2139 %# The same as above but with the ability to specify an identifier
 
2140 EVT_GRID_CMD_CELL_LEFT_CLICK =     wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_CLICK,    1 )
 
2141 EVT_GRID_CMD_CELL_RIGHT_CLICK =    wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_CLICK,   1 )
 
2142 EVT_GRID_CMD_CELL_LEFT_DCLICK =    wx.PyEventBinder( wxEVT_GRID_CELL_LEFT_DCLICK,   1 )
 
2143 EVT_GRID_CMD_CELL_RIGHT_DCLICK =   wx.PyEventBinder( wxEVT_GRID_CELL_RIGHT_DCLICK,  1 )
 
2144 EVT_GRID_CMD_LABEL_LEFT_CLICK =    wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_CLICK,   1 )
 
2145 EVT_GRID_CMD_LABEL_RIGHT_CLICK =   wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_CLICK,  1 )
 
2146 EVT_GRID_CMD_LABEL_LEFT_DCLICK =   wx.PyEventBinder( wxEVT_GRID_LABEL_LEFT_DCLICK,  1 )
 
2147 EVT_GRID_CMD_LABEL_RIGHT_DCLICK =  wx.PyEventBinder( wxEVT_GRID_LABEL_RIGHT_DCLICK, 1 )
 
2148 EVT_GRID_CMD_ROW_SIZE =            wx.PyEventBinder( wxEVT_GRID_ROW_SIZE,           1 )
 
2149 EVT_GRID_CMD_COL_SIZE =            wx.PyEventBinder( wxEVT_GRID_COL_SIZE,           1 )
 
2150 EVT_GRID_CMD_RANGE_SELECT =        wx.PyEventBinder( wxEVT_GRID_RANGE_SELECT,       1 )
 
2151 EVT_GRID_CMD_CELL_CHANGE =         wx.PyEventBinder( wxEVT_GRID_CELL_CHANGE,        1 )
 
2152 EVT_GRID_CMD_SELECT_CELL =         wx.PyEventBinder( wxEVT_GRID_SELECT_CELL,        1 )
 
2153 EVT_GRID_CMD_EDITOR_SHOWN =        wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN,       1 )
 
2154 EVT_GRID_CMD_EDITOR_HIDDEN =       wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN,      1 )
 
2155 EVT_GRID_CMD_EDITOR_CREATED =      wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED,     1 )
 
2156 EVT_GRID_CMD_CELL_BEGIN_DRAG =     wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG,    1 )
 
2160 //---------------------------------------------------------------------------
 
2165 //---------------------------------------------------------------------------
 
2166 //---------------------------------------------------------------------------