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 /////////////////////////////////////////////////////////////////////////////
 
  22 //----------------------------------------------------------------------
 
  25 %include my_typemaps.i
 
  27 // Import some definitions of other classes, etc.
 
  35 %pragma(python) code = "import wx"
 
  37 //---------------------------------------------------------------------------
 
  38 //---------------------------------------------------------------------------
 
  39 // Macros, similar to what's in helpers.h, to aid in the creation of
 
  40 // virtual methods that are able to make callbacks to Python.  Many of these
 
  41 // are specific to wxGrid and so are kept here to reduce the mess in helpers.h
 
  46 #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME)                               \
 
  47     wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) {        \
 
  48         wxGridCellAttr* rval = NULL;                                            \
 
  49         bool doSave = wxPyRestoreThread();                                      \
 
  50         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
 
  52             wxGridCellAttr* ptr;                                                \
 
  53             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \
 
  55                 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellAttr_p"))    \
 
  61             rval = PCLASS::CBNAME(a, b, c);                                     \
 
  62         wxPySaveThread(doSave);                                                 \
 
  65     wxGridCellAttr *base_##CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \
 
  66         return PCLASS::CBNAME(a, b, c);                                         \
 
  71 #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME)                           \
 
  72     void CBNAME(wxGridCellAttr *attr, int a, int b) {                   \
 
  73         bool doSave = wxPyRestoreThread();                              \
 
  74         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                           \
 
  75             PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\
 
  76             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b));   \
 
  80             PCLASS::CBNAME(attr, a, b);                                 \
 
  81         wxPySaveThread(doSave);                                         \
 
  83     void base_##CBNAME(wxGridCellAttr *attr, int a, int b) {            \
 
  84         PCLASS::CBNAME(attr, a, b);                                     \
 
  89 #define PYCALLBACK__GCAINT(PCLASS, CBNAME)                              \
 
  90     void CBNAME(wxGridCellAttr *attr, int val) {                        \
 
  91         bool doSave = wxPyRestoreThread();                              \
 
  92         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                           \
 
  93             PyObject* obj = wxPyConstructObject((void*)attr, "wxGridCellAttr", 0);\
 
  94             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val));     \
 
  98             PCLASS::CBNAME(attr, val);                                  \
 
  99         wxPySaveThread(doSave);                                         \
 
 101     void base_##CBNAME(wxGridCellAttr *attr, int val) {                 \
 
 102         PCLASS::CBNAME(attr, val);                                      \
 
 107 #define PYCALLBACK_INT__pure(CBNAME)                                    \
 
 109         bool doSave = wxPyRestoreThread();                              \
 
 111         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 112             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));          \
 
 113         wxPySaveThread(doSave);                                         \
 
 119 #define PYCALLBACK_BOOL_INTINT_pure(CBNAME)                             \
 
 120     bool CBNAME(int a, int b) {                                         \
 
 121         bool doSave = wxPyRestoreThread();                              \
 
 123         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 124             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b));    \
 
 125         wxPySaveThread(doSave);                                         \
 
 131 #define PYCALLBACK_STRING_INTINT_pure(CBNAME)                           \
 
 132     wxString CBNAME(int a, int b) {                                     \
 
 133         bool doSave = wxPyRestoreThread();                              \
 
 135         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                           \
 
 137             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));   \
 
 139                 PyObject* str = PyObject_Str(ro);                       \
 
 140                 rval = PyString_AsString(str);                          \
 
 141                 Py_DECREF(ro);  Py_DECREF(str);                         \
 
 144         wxPySaveThread(doSave);                                         \
 
 150 #define PYCALLBACK__INTINTSTRING_pure(CBNAME)                           \
 
 151     void CBNAME(int a, int b, const wxString& c) {                      \
 
 152         bool doSave = wxPyRestoreThread();                              \
 
 153         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 154             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));    \
 
 155         wxPySaveThread(doSave);                                         \
 
 159 #define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME)                        \
 
 160     wxString CBNAME(int a, int b) {                                     \
 
 161         bool doSave = wxPyRestoreThread();                              \
 
 163         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                           \
 
 165             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));   \
 
 167                 PyObject* str = PyObject_Str(ro);                       \
 
 168                 rval = PyString_AsString(str);                          \
 
 169                 Py_DECREF(ro);  Py_DECREF(str);                         \
 
 172             rval = PCLASS::CBNAME(a, b);                                \
 
 173         wxPySaveThread(doSave);                                         \
 
 176     wxString base_##CBNAME(int a, int b) {                              \
 
 177         return PCLASS::CBNAME(a, b);                                    \
 
 182 #define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME)                    \
 
 183     bool CBNAME(int a, int b, const wxString& c)  {                     \
 
 185         bool doSave = wxPyRestoreThread();                              \
 
 186         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 187             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)", a,b,c.c_str()));   \
 
 189             rval = PCLASS::CBNAME(a,b,c);                               \
 
 190         wxPySaveThread(doSave);                                         \
 
 193     bool base_##CBNAME(int a, int b, const wxString& c) {               \
 
 194         return PCLASS::CBNAME(a,b,c);                                   \
 
 200 #define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME)                          \
 
 201     long CBNAME(int a, int b)  {                                        \
 
 203         bool doSave = wxPyRestoreThread();                              \
 
 204         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 205             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));   \
 
 207             rval = PCLASS::CBNAME(a,b);                                 \
 
 208         wxPySaveThread(doSave);                                         \
 
 211     long base_##CBNAME(int a, int b) {                                  \
 
 212         return PCLASS::CBNAME(a,b);                                     \
 
 217 #define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME)                          \
 
 218     bool CBNAME(int a, int b)  {                                        \
 
 220         bool doSave = wxPyRestoreThread();                              \
 
 221         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 222             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));   \
 
 224             rval = PCLASS::CBNAME(a,b);                                 \
 
 225         wxPySaveThread(doSave);                                         \
 
 228     bool base_##CBNAME(int a, int b) {                                  \
 
 229         return PCLASS::CBNAME(a,b);                                     \
 
 234 #define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME)                        \
 
 235     double CBNAME(int a, int b) {                                       \
 
 236         bool doSave = wxPyRestoreThread();                              \
 
 238         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                           \
 
 240             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b));   \
 
 242                 PyObject* str = PyObject_Str(ro);                       \
 
 243                 rval = PyFloat_AsDouble(str);                           \
 
 244                 Py_DECREF(ro);   Py_DECREF(str);                        \
 
 247             rval = PCLASS::CBNAME(a, b);                                \
 
 248         wxPySaveThread(doSave);                                         \
 
 251     double base_##CBNAME(int a, int b) {                                \
 
 252         return PCLASS::CBNAME(a, b);                                    \
 
 257 #define PYCALLBACK__(PCLASS, CBNAME)                                    \
 
 259         bool doSave = wxPyRestoreThread();                              \
 
 260         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 261             wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));                 \
 
 264         wxPySaveThread(doSave);                                         \
 
 266     void base_##CBNAME() {                                              \
 
 273 #define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME)                      \
 
 274     bool CBNAME(size_t a, size_t b)  {                                  \
 
 276         bool doSave = wxPyRestoreThread();                              \
 
 277         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 278             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));   \
 
 280             rval = PCLASS::CBNAME(a,b);                                 \
 
 281         wxPySaveThread(doSave);                                         \
 
 284     bool base_##CBNAME(size_t a, size_t b) {                            \
 
 285         return PCLASS::CBNAME(a,b);                                     \
 
 290 #define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME)                           \
 
 291     bool CBNAME(size_t a)  {                                            \
 
 293         bool doSave = wxPyRestoreThread();                              \
 
 294         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 295             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));      \
 
 297             rval = PCLASS::CBNAME(a);                                   \
 
 298         wxPySaveThread(doSave);                                         \
 
 301     bool base_##CBNAME(size_t a) {                                      \
 
 302         return PCLASS::CBNAME(a);                                       \
 
 307 #define PYCALLBACK_STRING_INT(PCLASS, CBNAME)                           \
 
 308     wxString CBNAME(int a) {                                            \
 
 309         bool doSave = wxPyRestoreThread();                              \
 
 311         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                           \
 
 313             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a));      \
 
 315                 PyObject* str = PyObject_Str(ro);                       \
 
 316                 rval = PyString_AsString(str);                          \
 
 317                 Py_DECREF(ro);   Py_DECREF(str);                        \
 
 320             rval = PCLASS::CBNAME(a);                                   \
 
 321         wxPySaveThread(doSave);                                         \
 
 324     wxString base_##CBNAME(int a) {                                     \
 
 325         return PCLASS::CBNAME(a);                                       \
 
 330 #define PYCALLBACK__INTSTRING(PCLASS, CBNAME)                           \
 
 331     void CBNAME(int a, const wxString& c)  {                            \
 
 332         bool doSave = wxPyRestoreThread();                              \
 
 333         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 334             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(is)", a,c.c_str()));  \
 
 336             PCLASS::CBNAME(a,c);                                        \
 
 337         wxPySaveThread(doSave);                                         \
 
 339     void base_##CBNAME(int a, const wxString& c) {                      \
 
 340         PCLASS::CBNAME(a,c);                                            \
 
 346 #define PYCALLBACK_BOOL_(PCLASS, CBNAME)                                \
 
 349         bool doSave = wxPyRestoreThread();                              \
 
 350         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 351             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));          \
 
 353             rval = PCLASS::CBNAME();                                    \
 
 354         wxPySaveThread(doSave);                                         \
 
 357     bool base_##CBNAME() {                                              \
 
 358         return PCLASS::CBNAME();                                        \
 
 363 #define PYCALLBACK__SIZETINT(PCLASS, CBNAME)                            \
 
 364     void CBNAME(size_t a, int b)  {                                     \
 
 365         bool doSave = wxPyRestoreThread();                              \
 
 366         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 367             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));          \
 
 369             PCLASS::CBNAME(a,b);                                        \
 
 370         wxPySaveThread(doSave);                                         \
 
 372     void base_##CBNAME(size_t a, int b) {                               \
 
 373         PCLASS::CBNAME(a,b);                                            \
 
 379 #define PYCALLBACK__INTINTLONG(PCLASS, CBNAME)                          \
 
 380     void CBNAME(int a, int b, long c)  {                                \
 
 381         bool doSave = wxPyRestoreThread();                              \
 
 382         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 383             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));       \
 
 385             PCLASS::CBNAME(a,b,c);                                      \
 
 386         wxPySaveThread(doSave);                                         \
 
 388     void base_##CBNAME(int a, int b, long c) {                          \
 
 389         PCLASS::CBNAME(a,b,c);                                          \
 
 395 #define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME)                        \
 
 396     void CBNAME(int a, int b, double c)  {                              \
 
 397         bool doSave = wxPyRestoreThread();                              \
 
 398         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 399             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c));       \
 
 401             PCLASS::CBNAME(a,b,c);                                      \
 
 402         wxPySaveThread(doSave);                                         \
 
 404     void base_##CBNAME(int a, int b, double c) {                        \
 
 405         PCLASS::CBNAME(a,b,c);                                          \
 
 410 #define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME)                          \
 
 411     void CBNAME(int a, int b, bool c)  {                                \
 
 412         bool doSave = wxPyRestoreThread();                              \
 
 413         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                             \
 
 414             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));       \
 
 416             PCLASS::CBNAME(a,b,c);                                      \
 
 417         wxPySaveThread(doSave);                                         \
 
 419     void base_##CBNAME(int a, int b, bool c) {                          \
 
 420         PCLASS::CBNAME(a,b,c);                                          \
 
 428 //---------------------------------------------------------------------------
 
 430 class wxGridCellCoords;
 
 431 class wxGridCellAttr;
 
 435 #define wxGRID_VALUE_STRING     "string"
 
 436 #define wxGRID_VALUE_BOOL       "bool"
 
 437 #define wxGRID_VALUE_NUMBER     "long"
 
 438 #define wxGRID_VALUE_FLOAT      "double"
 
 439 #define wxGRID_VALUE_CHOICE     "choice"
 
 440 #define wxGRID_VALUE_TEXT       "string"
 
 441 #define wxGRID_VALUE_LONG       "long"
 
 444 wxGridCellCoords wxGridNoCellCoords;
 
 445 wxRect           wxGridNoCellRect;
 
 449 //---------------------------------------------------------------------------
 
 450 // wxGridCellRenderer is an ABC, and several derived classes are available.
 
 451 // Classes implemented in Python should be derived from wxPyGridCellRenderer.
 
 454 class wxGridCellRenderer
 
 457     void SetParameters(const wxString& params);
 
 461     virtual void Draw(wxGrid& grid,
 
 462                       wxGridCellAttr& attr,
 
 466                       bool isSelected) = 0;
 
 467     virtual wxSize GetBestSize(wxGrid& grid,
 
 468                                wxGridCellAttr& attr,
 
 470                                int row, int col) = 0;
 
 471     virtual wxGridCellRenderer *Clone() const = 0;
 
 475 // The C++ version of wxPyGridCellRenderer
 
 477 class wxPyGridCellRenderer : public wxGridCellRenderer
 
 480     wxPyGridCellRenderer() : wxGridCellRenderer() {};
 
 482     // Implement Python callback aware virtual methods
 
 483     void Draw(wxGrid& grid, wxGridCellAttr& attr,
 
 484               wxDC& dc, const wxRect& rect,
 
 485               int row, int col, bool isSelected) {
 
 486         bool doSave = wxPyRestoreThread();
 
 487         if (wxPyCBH_findCallback(m_myInst, "Draw")) {
 
 488             wxPyCBH_callCallback(m_myInst,
 
 489                 Py_BuildValue("(OOOOiii)",
 
 490                               wxPyConstructObject((void*)&grid, "wxGrid", 0),
 
 491                               wxPyConstructObject((void*)&attr, "wxGridCellAttr", 0),
 
 492                               wxPyConstructObject((void*)&dc,   "wxDC", 0),
 
 493                               wxPyConstructObject((void*)&rect, "wxRect", 0),
 
 494                               row, col, isSelected));
 
 496         wxPySaveThread(doSave);
 
 499     wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
 
 502         bool doSave = wxPyRestoreThread();
 
 503         if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) {
 
 506             ro = wxPyCBH_callCallbackObj(m_myInst,
 
 507                 Py_BuildValue("(OOOii)",
 
 508                               wxPyConstructObject((void*)&grid, "wxGrid", 0),
 
 509                               wxPyConstructObject((void*)&attr, "wxGridCellAttr", 0),
 
 510                               wxPyConstructObject((void*)&dc,   "wxDC", 0),
 
 513                 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p"))
 
 518         wxPySaveThread(doSave);
 
 523     wxGridCellRenderer *Clone() const {
 
 524         wxGridCellRenderer* rval = NULL;
 
 525         bool doSave = wxPyRestoreThread();
 
 526         if (wxPyCBH_findCallback(m_myInst, "Clone")) {
 
 528             wxGridCellRenderer* ptr;
 
 529             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 531                 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellRenderer_p"))
 
 536         wxPySaveThread(doSave);
 
 540     DEC_PYCALLBACK__STRING(SetParameters);
 
 545 IMP_PYCALLBACK__STRING( wxPyGridCellRenderer, wxGridCellRenderer, SetParameters);
 
 550 // Let SWIG know about it so it can create the Python version
 
 551 class wxPyGridCellRenderer : public wxGridCellRenderer {
 
 553     wxPyGridCellRenderer();
 
 554     void _setSelf(PyObject* self, PyObject* _class);
 
 555     %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyGridCellRenderer)"
 
 557     void base_SetParameters(const wxString& params);
 
 560 //---------------------------------------------------------------------------
 
 561 //  Predefined Renderers
 
 563 class wxGridCellStringRenderer : public wxGridCellRenderer
 
 566     wxGridCellStringRenderer();
 
 570 class  wxGridCellNumberRenderer : public wxGridCellStringRenderer
 
 573     wxGridCellNumberRenderer();
 
 577 class  wxGridCellFloatRenderer : public wxGridCellStringRenderer
 
 580     wxGridCellFloatRenderer(int width = -1, int precision = -1);
 
 582     int GetWidth() const;
 
 583     void SetWidth(int width);
 
 584     int GetPrecision() const;
 
 585     void SetPrecision(int precision);
 
 589 class  wxGridCellBoolRenderer : public wxGridCellRenderer
 
 592     wxGridCellBoolRenderer();
 
 597 //---------------------------------------------------------------------------
 
 598 // wxGridCellEditor is an ABC, and several derived classes are available.
 
 599 // Classes implemented in Python should be derived from wxPyGridCellEditor.
 
 601 class  wxGridCellEditor
 
 605     wxControl* GetControl();
 
 606     void SetControl(wxControl* control);
 
 608     void SetParameters(const wxString& params);
 
 612     virtual void Create(wxWindow* parent,
 
 614                         wxEvtHandler* evtHandler) = 0;
 
 615     virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
 
 616     virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
 
 617     virtual void Reset() = 0;
 
 618     virtual wxGridCellEditor *Clone() const = 0;
 
 620     virtual void SetSize(const wxRect& rect);
 
 621     virtual void Show(bool show, wxGridCellAttr *attr = NULL);
 
 622     virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
 
 623     virtual bool IsAcceptedKey(wxKeyEvent& event);
 
 624     virtual void StartingKey(wxKeyEvent& event);
 
 625     virtual void StartingClick();
 
 626     virtual void HandleReturn(wxKeyEvent& event);
 
 627     virtual void Destroy();
 
 632 // The C++ version of wxPyGridCellEditor
 
 634 class wxPyGridCellEditor : public wxGridCellEditor
 
 637     wxPyGridCellEditor() : wxGridCellEditor() {}
 
 639     void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
 
 640         bool doSave = wxPyRestoreThread();
 
 641         if (wxPyCBH_findCallback(m_myInst, "Create")) {
 
 642             wxPyCBH_callCallback(m_myInst,
 
 643                 Py_BuildValue("(OiO)",
 
 644                               wxPyConstructObject((void*)parent, "wxWindow", 0),
 
 646                               wxPyConstructObject((void*)evtHandler, "wxEvtHandler", 0)));
 
 648         wxPySaveThread(doSave);
 
 652     void BeginEdit(int row, int col, wxGrid* grid) {
 
 653         bool doSave = wxPyRestoreThread();
 
 654         if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) {
 
 655             wxPyCBH_callCallback(m_myInst,
 
 656                 Py_BuildValue("(iiO)", row, col,
 
 657                               wxPyConstructObject((void*)grid, "wxGrid", 0)));
 
 659         wxPySaveThread(doSave);
 
 663     bool EndEdit(int row, int col, wxGrid* grid) {
 
 665         bool doSave = wxPyRestoreThread();
 
 666         if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
 
 667             rv = wxPyCBH_callCallback(m_myInst,
 
 668                 Py_BuildValue("(iiO)", row, col,
 
 669                               wxPyConstructObject((void*)grid, "wxGrid", 0)));
 
 671         wxPySaveThread(doSave);
 
 676     wxGridCellEditor*Clone() const {
 
 677         wxGridCellEditor* rval = NULL;
 
 678         bool doSave = wxPyRestoreThread();
 
 679         if (wxPyCBH_findCallback(m_myInst, "Clone")) {
 
 681             wxGridCellEditor* ptr;
 
 682             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
 
 684                 if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellEditor_p"))
 
 689         wxPySaveThread(doSave);
 
 694     void Show(bool show, wxGridCellAttr *attr) {
 
 695         bool doSave = wxPyRestoreThread();
 
 696         if (wxPyCBH_findCallback(m_myInst, "Show"))
 
 697             wxPyCBH_callCallback(m_myInst,
 
 698                 Py_BuildValue("(iO)", show,
 
 699                               wxPyConstructObject((void*)attr, "wxGridCellAttr", 0)));
 
 701             wxGridCellEditor::Show(show, attr);
 
 702         wxPySaveThread(doSave);
 
 704     void base_Show(bool show, wxGridCellAttr *attr) {
 
 705         wxGridCellEditor::Show(show, attr);
 
 709     void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
 
 710         bool doSave = wxPyRestoreThread();
 
 711         if (wxPyCBH_findCallback(m_myInst, "PaintBackground"))
 
 712             wxPyCBH_callCallback(m_myInst,
 
 713                 Py_BuildValue("(OO)",
 
 714                               wxPyConstructObject((void*)&rectCell, "wxRect", 0),
 
 715                               wxPyConstructObject((void*)attr, "wxGridCellAttr", 0)));
 
 717             wxGridCellEditor::PaintBackground(rectCell, attr);
 
 718         wxPySaveThread(doSave);
 
 720     void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
 
 721         wxGridCellEditor::PaintBackground(rectCell, attr);
 
 725     DEC_PYCALLBACK___pure(Reset);
 
 726     DEC_PYCALLBACK__constany(SetSize, wxRect);
 
 727     DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent);
 
 728     DEC_PYCALLBACK__any(StartingKey, wxKeyEvent);
 
 729     DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent);
 
 730     DEC_PYCALLBACK__(StartingClick);
 
 731     DEC_PYCALLBACK__(Destroy);
 
 732     DEC_PYCALLBACK__STRING(SetParameters);
 
 738 IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters);
 
 739 IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset);
 
 740 IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect);
 
 741 IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent);
 
 742 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent);
 
 743 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent);
 
 744 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick);
 
 745 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, Destroy);
 
 750 // Let SWIG know about it so it can create the Python version
 
 751 class wxPyGridCellEditor : public wxGridCellEditor {
 
 753     wxPyGridCellEditor();
 
 754     void _setSelf(PyObject* self, PyObject* _class);
 
 755     %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyGridCellEditor)"
 
 757     void base_SetSize(const wxRect& rect);
 
 758     void base_Show(bool show, wxGridCellAttr *attr = NULL);
 
 759     void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
 
 760     void base_IsAcceptedKey(wxKeyEvent& event);
 
 761     void base_StartingKey(wxKeyEvent& event);
 
 762     void base_StartingClick();
 
 763     void base_HandleReturn(wxKeyEvent& event);
 
 765     void base_SetParameters(const wxString& params);
 
 768 //---------------------------------------------------------------------------
 
 769 //  Predefined Editors
 
 771 class wxGridCellTextEditor : public wxGridCellEditor
 
 774     wxGridCellTextEditor();
 
 778 class wxGridCellNumberEditor : public wxGridCellTextEditor
 
 781     wxGridCellNumberEditor(int min = -1, int max = -1);
 
 785 class wxGridCellFloatEditor : public wxGridCellTextEditor
 
 788     wxGridCellFloatEditor();
 
 792 class wxGridCellBoolEditor : public wxGridCellEditor
 
 795     wxGridCellBoolEditor();
 
 798 class wxGridCellChoiceEditor : public wxGridCellEditor
 
 801     wxGridCellChoiceEditor(int LCOUNT = 0,
 
 802                            const wxString* choices = NULL,
 
 803                            bool allowOthers = FALSE);
 
 806 //---------------------------------------------------------------------------
 
 824     wxGridCellAttr *Clone() const;
 
 825     void MergeWith(wxGridCellAttr *mergefrom);
 
 828     void SetTextColour(const wxColour& colText);
 
 829     void SetBackgroundColour(const wxColour& colBack);
 
 830     void SetFont(const wxFont& font);
 
 831     void SetAlignment(int hAlign, int vAlign);
 
 832     void SetReadOnly(bool isReadOnly = TRUE);
 
 834     void SetRenderer(wxGridCellRenderer *renderer);
 
 835     void SetEditor(wxGridCellEditor* editor);
 
 836     void SetKind(wxAttrKind kind);
 
 838     bool HasTextColour() const;
 
 839     bool HasBackgroundColour() const;
 
 840     bool HasFont() const;
 
 841     bool HasAlignment() const;
 
 842     bool HasRenderer() const;
 
 843     bool HasEditor() const;
 
 844     bool HasReadWriteMode() const;
 
 846     const wxColour& GetTextColour() const;
 
 847     const wxColour& GetBackgroundColour() const;
 
 848     const wxFont& GetFont() const;
 
 849     void GetAlignment(int *OUTPUT, int *OUTPUT) const;
 
 850     wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
 
 851     wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
 
 853     bool IsReadOnly() const;
 
 854     void SetDefAttr(wxGridCellAttr* defAttr);
 
 857 //---------------------------------------------------------------------------
 
 859 class wxGridCellAttrProvider
 
 862     wxGridCellAttrProvider();
 
 863     // ???? virtual ~wxGridCellAttrProvider();
 
 865     wxGridCellAttr *GetAttr(int row, int col,
 
 866                             wxGridCellAttr::wxAttrKind  kind) const;
 
 867     void SetAttr(wxGridCellAttr *attr, int row, int col);
 
 868     void SetRowAttr(wxGridCellAttr *attr, int row);
 
 869     void SetColAttr(wxGridCellAttr *attr, int col);
 
 871     void UpdateAttrRows( size_t pos, int numRows );
 
 872     void UpdateAttrCols( size_t pos, int numCols );
 
 877 // A Python-aware version
 
 879 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
 
 882     wxPyGridCellAttrProvider() : wxGridCellAttrProvider() {};
 
 884     PYCALLBACK_GCA_INTINTKIND(wxGridCellAttrProvider, GetAttr);
 
 885     PYCALLBACK__GCAINTINT(wxGridCellAttrProvider, SetAttr);
 
 886     PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetRowAttr);
 
 887     PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetColAttr);
 
 894 // The python-aware version get's SWIGified
 
 895 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
 
 898     wxPyGridCellAttrProvider();
 
 899     void _setSelf(PyObject* self, PyObject* _class);
 
 900     %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyGridCellAttrProvider)"
 
 902     wxGridCellAttr *base_GetAttr(int row, int col,
 
 903                                  wxGridCellAttr::wxAttrKind kind);
 
 904     void base_SetAttr(wxGridCellAttr *attr, int row, int col);
 
 905     void base_SetRowAttr(wxGridCellAttr *attr, int row);
 
 906     void base_SetColAttr(wxGridCellAttr *attr, int col);
 
 910 //---------------------------------------------------------------------------
 
 911 // Grid Table Base class and Python aware version
 
 915 class wxGridTableBase : public wxObject
 
 918     // wxGridTableBase();   This is an ABC
 
 919     //~wxGridTableBase();
 
 921     void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
 
 922     wxGridCellAttrProvider *GetAttrProvider() const;
 
 923     void SetView( wxGrid *grid );
 
 924     wxGrid * GetView() const;
 
 928     virtual int GetNumberRows() = 0;
 
 929     virtual int GetNumberCols() = 0;
 
 930     virtual bool IsEmptyCell( int row, int col ) = 0;
 
 931     virtual wxString GetValue( int row, int col ) = 0;
 
 932     virtual void SetValue( int row, int col, const wxString& value ) = 0;
 
 934     // virtuals overridable in wxPyGridTableBase
 
 935     virtual wxString GetTypeName( int row, int col );
 
 936     virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
 
 937     virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
 
 938     virtual long GetValueAsLong( int row, int col );
 
 939     virtual double GetValueAsDouble( int row, int col );
 
 940     virtual bool GetValueAsBool( int row, int col );
 
 941     virtual void SetValueAsLong( int row, int col, long value );
 
 942     virtual void SetValueAsDouble( int row, int col, double value );
 
 943     virtual void SetValueAsBool( int row, int col, bool value );
 
 945     //virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
 
 946     //virtual void  SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
 
 949     virtual void Clear();
 
 950     virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
 
 951     virtual bool AppendRows( size_t numRows = 1 );
 
 952     virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
 
 953     virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
 
 954     virtual bool AppendCols( size_t numCols = 1 );
 
 955     virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
 
 957     virtual wxString GetRowLabelValue( int row );
 
 958     virtual wxString GetColLabelValue( int col );
 
 959     virtual void SetRowLabelValue( int row, const wxString& value );
 
 960     virtual void SetColLabelValue( int col, const wxString& value );
 
 962     virtual bool CanHaveAttributes();
 
 964     virtual wxGridCellAttr *GetAttr( int row, int col,
 
 965                                      wxGridCellAttr::wxAttrKind  kind);
 
 966     virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
 
 967     virtual void SetRowAttr(wxGridCellAttr *attr, int row);
 
 968     virtual void SetColAttr(wxGridCellAttr *attr, int col);
 
 974 // Python-aware version
 
 976 class wxPyGridTableBase : public wxGridTableBase
 
 979     wxPyGridTableBase() : wxGridTableBase() {}
 
 981     PYCALLBACK_INT__pure(GetNumberRows);
 
 982     PYCALLBACK_INT__pure(GetNumberCols);
 
 983     PYCALLBACK_BOOL_INTINT_pure(IsEmptyCell);
 
 984     PYCALLBACK_STRING_INTINT(wxGridTableBase, GetTypeName);
 
 985     PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanGetValueAs);
 
 986     PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanSetValueAs);
 
 987     PYCALLBACK__(wxGridTableBase, Clear);
 
 988     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertRows);
 
 989     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteRows);
 
 990     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertCols);
 
 991     PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteCols);
 
 992     PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendRows);
 
 993     PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendCols);
 
 994     PYCALLBACK_STRING_INT(wxGridTableBase, GetRowLabelValue);
 
 995     PYCALLBACK_STRING_INT(wxGridTableBase, GetColLabelValue);
 
 996     PYCALLBACK__INTSTRING(wxGridTableBase, SetRowLabelValue);
 
 997     PYCALLBACK__INTSTRING(wxGridTableBase, SetColLabelValue);
 
 998     PYCALLBACK_BOOL_(wxGridTableBase, CanHaveAttributes);
 
 999     PYCALLBACK_GCA_INTINTKIND(wxGridTableBase, GetAttr);
 
1000     PYCALLBACK__GCAINTINT(wxGridTableBase, SetAttr);
 
1001     PYCALLBACK__GCAINT(wxGridTableBase, SetRowAttr);
 
1002     PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
 
1005     wxString GetValue(int row, int col) {
 
1006         bool doSave = wxPyRestoreThread();
 
1008         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1010             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
 
1012                 PyObject* str = PyObject_Str(ro);
 
1013                 rval = PyString_AsString(str);
 
1018         wxPySaveThread(doSave);
 
1022     void SetValue(int row, int col, const wxString& val) {
 
1023         bool doSave = wxPyRestoreThread();
 
1024         if (wxPyCBH_findCallback(m_myInst, "SetValue"))
 
1025             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",row,col,val.c_str()));
 
1026         wxPySaveThread(doSave);
 
1030     // Map the Get/Set methods for the standard non-string types to
 
1031     // the GetValue and SetValue python methods.
 
1032     long GetValueAsLong( int row, int col ) {
 
1034         bool doSave = wxPyRestoreThread();
 
1035         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1038             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
 
1039             if (ro && PyNumber_Check(ro)) {
 
1040                 num = PyNumber_Int(ro);
 
1042                     rval = PyInt_AsLong(num);
 
1048         wxPySaveThread(doSave);
 
1052     double GetValueAsDouble( int row, int col ) {
 
1054         bool doSave = wxPyRestoreThread();
 
1055         if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
 
1058             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
 
1059             if (ro && PyNumber_Check(ro)) {
 
1060                 num = PyNumber_Float(ro);
 
1062                     rval = PyFloat_AsDouble(num);
 
1068         wxPySaveThread(doSave);
 
1072     bool GetValueAsBool( int row, int col ) {
 
1073         return (bool)GetValueAsLong(row, col);
 
1076     void SetValueAsLong( int row, int col, long value ) {
 
1077         bool doSave = wxPyRestoreThread();
 
1078         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1079             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value));
 
1081         wxPySaveThread(doSave);
 
1084     void SetValueAsDouble( int row, int col, double value ) {
 
1085         bool doSave = wxPyRestoreThread();
 
1086         if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
 
1087             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value));
 
1089         wxPySaveThread(doSave);
 
1092     void SetValueAsBool( int row, int col, bool value ) {
 
1093         SetValueAsLong( row, col, (long)value );
 
1102 // The python-aware version get's SWIGified
 
1103 class wxPyGridTableBase : public wxGridTableBase
 
1106     wxPyGridTableBase();
 
1107     void _setSelf(PyObject* self, PyObject* _class);
 
1108     %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyGridTableBase)"
 
1110     %addmethods { void Destroy() { delete self; } }
 
1112     wxString base_GetTypeName( int row, int col );
 
1113     bool base_CanGetValueAs( int row, int col, const wxString& typeName );
 
1114     bool base_CanSetValueAs( int row, int col, const wxString& typeName );
 
1116     bool base_InsertRows( size_t pos = 0, size_t numRows = 1 );
 
1117     bool base_AppendRows( size_t numRows = 1 );
 
1118     bool base_DeleteRows( size_t pos = 0, size_t numRows = 1 );
 
1119     bool base_InsertCols( size_t pos = 0, size_t numCols = 1 );
 
1120     bool base_AppendCols( size_t numCols = 1 );
 
1121     bool base_DeleteCols( size_t pos = 0, size_t numCols = 1 );
 
1122     wxString base_GetRowLabelValue( int row );
 
1123     wxString base_GetColLabelValue( int col );
 
1124     void base_SetRowLabelValue( int row, const wxString& value );
 
1125     void base_SetColLabelValue( int col, const wxString& value );
 
1126     bool base_CanHaveAttributes();
 
1127     wxGridCellAttr *base_GetAttr( int row, int col,
 
1128                                   wxGridCellAttr::wxAttrKind kind );
 
1129     void base_SetAttr(wxGridCellAttr* attr, int row, int col);
 
1130     void base_SetRowAttr(wxGridCellAttr *attr, int row);
 
1131     void base_SetColAttr(wxGridCellAttr *attr, int col);
 
1135 //---------------------------------------------------------------------------
 
1136 // Predefined Tables
 
1138 class  wxGridStringTable : public wxGridTableBase
 
1141     wxGridStringTable( int numRows=0, int numCols=0 );
 
1144 //---------------------------------------------------------------------------
 
1145 // The Table can pass messages to the grid to tell it to update itself if
 
1146 // something has changed.
 
1148 enum wxGridTableRequest
 
1150     wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
 
1151     wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
 
1152     wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
 
1153     wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
 
1154     wxGRIDTABLE_NOTIFY_ROWS_DELETED,
 
1155     wxGRIDTABLE_NOTIFY_COLS_INSERTED,
 
1156     wxGRIDTABLE_NOTIFY_COLS_APPENDED,
 
1157     wxGRIDTABLE_NOTIFY_COLS_DELETED
 
1161 class wxGridTableMessage
 
1164     wxGridTableMessage( wxGridTableBase *table, int id,
 
1167     ~wxGridTableMessage();
 
1169     void SetTableObject( wxGridTableBase *table );
 
1170     wxGridTableBase * GetTableObject() const;
 
1171     void SetId( int id );
 
1173     void SetCommandInt( int comInt1 );
 
1174     int  GetCommandInt();
 
1175     void SetCommandInt2( int comInt2 );
 
1176     int  GetCommandInt2();
 
1180 //---------------------------------------------------------------------------
 
1182 class wxGridCellCoords
 
1185     wxGridCellCoords( int r=-1, int c=-1 );
 
1186     ~wxGridCellCoords();
 
1188     int GetRow() const { return m_row; }
 
1189     void SetRow( int n ) { m_row = n; }
 
1190     int GetCol() const { return m_col; }
 
1191     void SetCol( int n ) { m_col = n; }
 
1192     void Set( int row, int col ) { m_row = row; m_col = col; }
 
1195         PyObject* asTuple() {
 
1196             PyObject* tup = PyTuple_New(2);
 
1197             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
 
1198             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
 
1202         int __cmp__( const wxGridCellCoords& other ) {
 
1203             return *self != other;
 
1206     %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
 
1207     %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
 
1210 // Typemap to allow conversion of sequence objects to wxGridCellCoords...
 
1211 %typemap(python,in) wxGridCellCoords& (wxGridCellCoords temp) {
 
1213     if (! wxGridCellCoords_helper($source, &$target))
 
1217 // ...and here is the associated helper.
 
1219 bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
 
1221     // If source is an object instance then it may already be the right type
 
1222     if (PyInstance_Check(source)) {
 
1223         wxGridCellCoords* ptr;
 
1224         if (SWIG_GetPtrObj(source, (void **)&ptr, "_wxGridCellCoords_p"))
 
1229     // otherwise a 2-tuple of integers is expected
 
1230     else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
 
1231         PyObject* o1 = PySequence_GetItem(source, 0);
 
1232         PyObject* o2 = PySequence_GetItem(source, 1);
 
1233         **obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2));
 
1238     PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object.");
 
1243 //---------------------------------------------------------------------------
 
1244 //---------------------------------------------------------------------------
 
1248 // Fool SWIG into treating this enum as an int
 
1249 typedef int WXGRIDSELECTIONMODES;
 
1251 // but let the C++ code know what it really is.
 
1253 typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES;
 
1258 class wxGrid : public wxScrolledWindow
 
1261     wxGrid( wxWindow *parent,
 
1263             const wxPoint& pos = wxDefaultPosition,
 
1264             const wxSize& size = wxDefaultSize,
 
1265             long style = wxWANTS_CHARS,
 
1266             const char* name = wxPanelNameStr );
 
1270     enum wxGridSelectionModes {wxGridSelectCells,
 
1272                                wxGridSelectColumns};
 
1274     bool CreateGrid( int numRows, int numCols,
 
1275                      WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells );
 
1276     void SetSelectionMode(WXGRIDSELECTIONMODES selmode);
 
1279     // ------ grid dimensions
 
1281     int      GetNumberRows();
 
1282     int      GetNumberCols();
 
1286 #ifdef NOTNEEDED // ????
 
1287     // ------ display update functions
 
1289     void CalcRowLabelsExposed( wxRegion& reg );
 
1290     void CalcColLabelsExposed( wxRegion& reg );
 
1291     void CalcCellsExposed( wxRegion& reg );
 
1293     // ------ event handlers
 
1295     void ProcessRowLabelMouseEvent( wxMouseEvent& event );
 
1296     void ProcessColLabelMouseEvent( wxMouseEvent& event );
 
1297     void ProcessCornerLabelMouseEvent( wxMouseEvent& event );
 
1298     void ProcessGridCellMouseEvent( wxMouseEvent& event );
 
1299     void DoEndDragResizeRow();
 
1300     void DoEndDragResizeCol();
 
1303     bool ProcessTableMessage( wxGridTableMessage& );
 
1306     wxGridTableBase * GetTable() const;
 
1307     bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE,
 
1308                    WXGRIDSELECTIONMODES selmode =
 
1309                    wxGrid::wxGridSelectCells );
 
1312     bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
 
1313     bool AppendRows( int numRows = 1, bool updateLabels=TRUE );
 
1314     bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
 
1315     bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
 
1316     bool AppendCols( int numCols = 1, bool updateLabels=TRUE );
 
1317     bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
 
1319 #ifdef NOTNEEDED // ????
 
1320     void DrawGridCellArea( wxDC& dc );
 
1321     void DrawGridSpace( wxDC& dc );
 
1322     void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
 
1323     void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
 
1324     void DrawCell( wxDC& dc, const wxGridCellCoords& );
 
1325     void DrawHighlight(wxDC& dc);
 
1328     // this function is called when the current cell highlight must be redrawn
 
1329     // and may be overridden by the user
 
1330     virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
 
1332 #ifdef NOTNEEDED // ????
 
1333     void DrawRowLabels( wxDC& dc );
 
1334     void DrawRowLabel( wxDC& dc, int row );
 
1336     void DrawColLabels( wxDC& dc );
 
1337     void DrawColLabel( wxDC& dc, int col );
 
1340     // ------ Cell text drawing functions
 
1342     void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
 
1343                             int horizontalAlignment = wxLEFT,
 
1344                             int verticalAlignment = wxTOP );
 
1346     // Split a string containing newline chararcters into an array of
 
1347     // strings and return the number of lines
 
1349     void StringToLines( const wxString& value, wxArrayString& lines );
 
1351     void GetTextBoxSize( wxDC& dc,
 
1352                          wxArrayString& lines,
 
1353                          long *OUTPUT, long *OUTPUT );
 
1357     // Code that does a lot of grid modification can be enclosed
 
1358     // between BeginBatch() and EndBatch() calls to avoid screen
 
1363     int      GetBatchCount();
 
1364     void     ForceRefresh();
 
1367     // ------ edit control functions
 
1369     bool IsEditable() { return m_editable; }
 
1370     void EnableEditing( bool edit );
 
1372     void EnableCellEditControl( bool enable = TRUE );
 
1373     void DisableCellEditControl();
 
1374     bool CanEnableCellControl() const;
 
1375     bool IsCellEditControlEnabled() const;
 
1376     bool IsCellEditControlShown() const;
 
1378     bool IsCurrentCellReadOnly() const;
 
1380     void ShowCellEditControl();
 
1381     void HideCellEditControl();
 
1382     void SaveEditControlValue();
 
1385     // ------ grid location functions
 
1386     //  Note that all of these functions work with the logical coordinates of
 
1387     //  grid cells and labels so you will need to convert from device
 
1388     //  coordinates for mouse events etc.
 
1391     //void XYToCell( int x, int y, wxGridCellCoords& );
 
1393         %new wxGridCellCoords* XYToCell(int x, int y) {
 
1394             wxGridCellCoords rv;
 
1395             self->XYToCell(x, y, rv);
 
1396             return new wxGridCellCoords(rv);
 
1400     int  YToRow( int y );
 
1401     int  XToCol( int x );
 
1403     int  YToEdgeOfRow( int y );
 
1404     int  XToEdgeOfCol( int x );
 
1406     wxRect CellToRect( int row, int col );
 
1407     // TODO: ??? wxRect CellToRect( const wxGridCellCoords& coords );
 
1410     int  GetGridCursorRow();
 
1411     int  GetGridCursorCol();
 
1413     // check to see if a cell is either wholly visible (the default arg) or
 
1414     // at least partially visible in the grid window
 
1416     bool IsVisible( int row, int col, bool wholeCellVisible = TRUE );
 
1417     // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE );
 
1418     void MakeCellVisible( int row, int col );
 
1419     // TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords );
 
1422     // ------ grid cursor movement functions
 
1424     void SetGridCursor( int row, int col );
 
1425     bool MoveCursorUp( bool expandSelection );
 
1426     bool MoveCursorDown( bool expandSelection );
 
1427     bool MoveCursorLeft( bool expandSelection );
 
1428     bool MoveCursorRight( bool expandSelection );
 
1429     bool MovePageDown();
 
1431     bool MoveCursorUpBlock( bool expandSelection );
 
1432     bool MoveCursorDownBlock( bool expandSelection );
 
1433     bool MoveCursorLeftBlock( bool expandSelection );
 
1434     bool MoveCursorRightBlock( bool expandSelection );
 
1437     // ------ label and gridline formatting
 
1439     int      GetDefaultRowLabelSize();
 
1440     int      GetRowLabelSize();
 
1441     int      GetDefaultColLabelSize();
 
1442     int      GetColLabelSize();
 
1443     wxColour GetLabelBackgroundColour();
 
1444     wxColour GetLabelTextColour();
 
1445     wxFont   GetLabelFont();
 
1446     void     GetRowLabelAlignment( int *OUTPUT, int *OUTPUT );
 
1447     void     GetColLabelAlignment( int *OUTPUT, int *OUTPUT );
 
1448     wxString GetRowLabelValue( int row );
 
1449     wxString GetColLabelValue( int col );
 
1450     wxColour GetGridLineColour();
 
1451     wxColour GetCellHighlightColour();
 
1452     int      GetCellHighlightPenWidth();
 
1453     int      GetCellHighlightROPenWidth();
 
1455     void     SetRowLabelSize( int width );
 
1456     void     SetColLabelSize( int height );
 
1457     void     SetLabelBackgroundColour( const wxColour& );
 
1458     void     SetLabelTextColour( const wxColour& );
 
1459     void     SetLabelFont( const wxFont& );
 
1460     void     SetRowLabelAlignment( int horiz, int vert );
 
1461     void     SetColLabelAlignment( int horiz, int vert );
 
1462     void     SetRowLabelValue( int row, const wxString& );
 
1463     void     SetColLabelValue( int col, const wxString& );
 
1464     void     SetGridLineColour( const wxColour& );
 
1465     void     SetCellHighlightColour( const wxColour& );
 
1466     void     SetCellHighlightPenWidth(int width);
 
1467     void     SetCellHighlightROPenWidth(int width);
 
1469     void     EnableDragRowSize( bool enable = TRUE );
 
1470     void     DisableDragRowSize();
 
1471     bool     CanDragRowSize();
 
1472     void     EnableDragColSize( bool enable = TRUE );
 
1473     void     DisableDragColSize();
 
1474     bool     CanDragColSize();
 
1475     void     EnableDragGridSize(bool enable = TRUE);
 
1476     void     DisableDragGridSize();
 
1477     bool     CanDragGridSize();
 
1479     // this sets the specified attribute for all cells in this row/col
 
1480     void     SetRowAttr(int row, wxGridCellAttr *attr);
 
1481     void     SetColAttr(int col, wxGridCellAttr *attr);
 
1483     // shortcuts for setting the column parameters
 
1485     // set the format for the data in the column: default is string
 
1486     void     SetColFormatBool(int col);
 
1487     void     SetColFormatNumber(int col);
 
1488     void     SetColFormatFloat(int col, int width = -1, int precision = -1);
 
1489     void     SetColFormatCustom(int col, const wxString& typeName);
 
1491     void     EnableGridLines( bool enable = TRUE );
 
1492     bool     GridLinesEnabled();
 
1494     // ------ row and col formatting
 
1496     int      GetDefaultRowSize();
 
1497     int      GetRowSize( int row );
 
1498     int      GetDefaultColSize();
 
1499     int      GetColSize( int col );
 
1500     wxColour GetDefaultCellBackgroundColour();
 
1501     wxColour GetCellBackgroundColour( int row, int col );
 
1502     wxColour GetDefaultCellTextColour();
 
1503     wxColour GetCellTextColour( int row, int col );
 
1504     wxFont   GetDefaultCellFont();
 
1505     wxFont   GetCellFont( int row, int col );
 
1506     void     GetDefaultCellAlignment( int *horiz, int *vert );
 
1507     void     GetCellAlignment( int row, int col, int *horiz, int *vert );
 
1509     void     SetDefaultRowSize( int height, bool resizeExistingRows = FALSE );
 
1510     void     SetRowSize( int row, int height );
 
1511     void     SetDefaultColSize( int width, bool resizeExistingCols = FALSE );
 
1513     void     SetColSize( int col, int width );
 
1515     // automatically size the column or row to fit to its contents, if
 
1516     // setAsMin is TRUE, this optimal width will also be set as minimal width
 
1518     void     AutoSizeColumn( int col, bool setAsMin = TRUE );
 
1519     void     AutoSizeRow( int row, bool setAsMin = TRUE );
 
1522     // auto size all columns (very ineffective for big grids!)
 
1523     void     AutoSizeColumns( bool setAsMin = TRUE );
 
1524     void     AutoSizeRows( bool setAsMin = TRUE );
 
1526     // auto size the grid, that is make the columns/rows of the "right" size
 
1527     // and also set the grid size to just fit its contents
 
1530     // column won't be resized to be lesser width - this must be called during
 
1531     // the grid creation because it won't resize the column if it's already
 
1532     // narrower than the minimal width
 
1533     void     SetColMinimalWidth( int col, int width );
 
1534     void     SetRowMinimalHeight( int row, int width );
 
1536     void     SetDefaultCellBackgroundColour( const wxColour& );
 
1537     void     SetCellBackgroundColour( int row, int col, const wxColour& );
 
1538     void     SetDefaultCellTextColour( const wxColour& );
 
1540     void     SetCellTextColour( int row, int col, const wxColour& );
 
1541     void     SetDefaultCellFont( const wxFont& );
 
1542     void     SetCellFont( int row, int col, const wxFont& );
 
1543     void     SetDefaultCellAlignment( int horiz, int vert );
 
1544     void     SetCellAlignment( int row, int col, int horiz, int vert );
 
1546     // takes ownership of the pointer
 
1547     void SetDefaultRenderer(wxGridCellRenderer *renderer);
 
1548     void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
 
1549     wxGridCellRenderer *GetDefaultRenderer() const;
 
1550     wxGridCellRenderer* GetCellRenderer(int row, int col);
 
1552     // takes ownership of the pointer
 
1553     void SetDefaultEditor(wxGridCellEditor *editor);
 
1554     void SetCellEditor(int row, int col, wxGridCellEditor *editor);
 
1555     wxGridCellEditor *GetDefaultEditor() const;
 
1556     wxGridCellEditor* GetCellEditor(int row, int col);
 
1560     // ------ cell value accessors
 
1562     wxString GetCellValue( int row, int col );
 
1563     // TODO: ??? wxString GetCellValue( const wxGridCellCoords& coords )
 
1565     void SetCellValue( int row, int col, const wxString& s );
 
1566     // TODO: ??? void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
 
1568     // returns TRUE if the cell can't be edited
 
1569     bool IsReadOnly(int row, int col) const;
 
1571     // make the cell editable/readonly
 
1572     void SetReadOnly(int row, int col, bool isReadOnly = TRUE);
 
1574     // ------ selections of blocks of cells
 
1576     void SelectRow( int row, bool addToSelected = FALSE );
 
1577     void SelectCol( int col, bool addToSelected = FALSE );
 
1579     void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
 
1580                       bool addToSelected = FALSE );
 
1581     // TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft,
 
1582     // TODO: ???                   const wxGridCellCoords& bottomRight )
 
1586     void ClearSelection();
 
1587     bool IsInSelection( int row, int col );
 
1588     // TODO: ??? bool IsInSelection( const wxGridCellCoords& coords )
 
1591     // This function returns the rectangle that encloses the block of cells
 
1592     // limited by TopLeft and BottomRight cell in device coords and clipped
 
1593     //  to the client size of the grid window.
 
1595     wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
 
1596                               const wxGridCellCoords & bottomRight );
 
1599     // Access or update the selection fore/back colours
 
1600     wxColour GetSelectionBackground() const;
 
1601     wxColour GetSelectionForeground() const;
 
1603     void SetSelectionBackground(const wxColour& c);
 
1604     void SetSelectionForeground(const wxColour& c);
 
1607     // Methods for a registry for mapping data types to Renderers/Editors
 
1608     void RegisterDataType(const wxString& typeName,
 
1609                           wxGridCellRenderer* renderer,
 
1610                           wxGridCellEditor* editor);
 
1611     wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
 
1612     // TODO: ??? wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
 
1613     wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
 
1614     wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
 
1615     wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
 
1617     // grid may occupy more space than needed for its rows/columns, this
 
1618     // function allows to set how big this extra space is
 
1619     void SetMargins(int extraWidth, int extraHeight);
 
1622     // Accessors for component windows
 
1623     wxWindow* GetGridWindow();
 
1624     wxWindow* GetGridRowLabelWindow();
 
1625     wxWindow* GetGridColLabelWindow();
 
1626     wxWindow* GetGridCornerLabelWindow();
 
1632 //---------------------------------------------------------------------------
 
1633 //---------------------------------------------------------------------------
 
1634 // Grid events and stuff
 
1638 class wxGridEvent : public wxNotifyEvent
 
1641     wxGridEvent(int id, wxEventType type, wxGrid* obj,
 
1642                 int row=-1, int col=-1, int x=-1, int y=-1, bool sel = TRUE,
 
1643                 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
 
1645     virtual int GetRow();
 
1646     virtual int GetCol();
 
1647     wxPoint     GetPosition();
 
1657 class  wxGridSizeEvent : public wxNotifyEvent
 
1660     wxGridSizeEvent(int id, wxEventType type, wxGrid* obj,
 
1661                 int rowOrCol=-1, int x=-1, int y=-1,
 
1662                 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
 
1665     wxPoint     GetPosition();
 
1674 class wxGridRangeSelectEvent : public wxNotifyEvent
 
1677     wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj,
 
1678                            const wxGridCellCoords& topLeft,
 
1679                            const wxGridCellCoords& bottomRight,
 
1681                            bool control=FALSE, bool shift=FALSE,
 
1682                            bool alt=FALSE, bool meta=FALSE);
 
1684     wxGridCellCoords GetTopLeftCoords();
 
1685     wxGridCellCoords GetBottomRightCoords();
 
1698 class wxGridEditorCreatedEvent : public wxCommandEvent {
 
1700     wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
 
1701                              int row, int col, wxControl* ctrl);
 
1705     wxControl* GetControl();
 
1706     void SetRow(int row);
 
1707     void SetCol(int col);
 
1708     void SetControl(wxControl* ctrl);
 
1714     wxEVT_GRID_CELL_LEFT_CLICK,
 
1715     wxEVT_GRID_CELL_RIGHT_CLICK,
 
1716     wxEVT_GRID_CELL_LEFT_DCLICK,
 
1717     wxEVT_GRID_CELL_RIGHT_DCLICK,
 
1718     wxEVT_GRID_LABEL_LEFT_CLICK,
 
1719     wxEVT_GRID_LABEL_RIGHT_CLICK,
 
1720     wxEVT_GRID_LABEL_LEFT_DCLICK,
 
1721     wxEVT_GRID_LABEL_RIGHT_DCLICK,
 
1722     wxEVT_GRID_ROW_SIZE,
 
1723     wxEVT_GRID_COL_SIZE,
 
1724     wxEVT_GRID_RANGE_SELECT,
 
1725     wxEVT_GRID_CELL_CHANGE,
 
1726     wxEVT_GRID_SELECT_CELL,
 
1727     wxEVT_GRID_EDITOR_SHOWN,
 
1728     wxEVT_GRID_EDITOR_HIDDEN,
 
1729     wxEVT_GRID_EDITOR_CREATED,
 
1734 %pragma(python) code = "
 
1735 def EVT_GRID_CELL_LEFT_CLICK(win, fn):
 
1736     win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_CLICK, fn)
 
1738 def EVT_GRID_CELL_RIGHT_CLICK(win, fn):
 
1739     win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_CLICK, fn)
 
1741 def EVT_GRID_CELL_LEFT_DCLICK(win, fn):
 
1742     win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_DCLICK, fn)
 
1744 def EVT_GRID_CELL_RIGHT_DCLICK(win, fn):
 
1745     win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_DCLICK, fn)
 
1747 def EVT_GRID_LABEL_LEFT_CLICK(win, fn):
 
1748     win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_CLICK, fn)
 
1750 def EVT_GRID_LABEL_RIGHT_CLICK(win, fn):
 
1751     win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_CLICK, fn)
 
1753 def EVT_GRID_LABEL_LEFT_DCLICK(win, fn):
 
1754     win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_DCLICK, fn)
 
1756 def EVT_GRID_LABEL_RIGHT_DCLICK(win, fn):
 
1757     win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_DCLICK, fn)
 
1759 def EVT_GRID_ROW_SIZE(win, fn):
 
1760     win.Connect(-1, -1, wxEVT_GRID_ROW_SIZE, fn)
 
1762 def EVT_GRID_COL_SIZE(win, fn):
 
1763     win.Connect(-1, -1, wxEVT_GRID_COL_SIZE, fn)
 
1765 def EVT_GRID_RANGE_SELECT(win, fn):
 
1766     win.Connect(-1, -1, wxEVT_GRID_RANGE_SELECT, fn)
 
1768 def EVT_GRID_CELL_CHANGE(win, fn):
 
1769     win.Connect(-1, -1, wxEVT_GRID_CELL_CHANGE, fn)
 
1771 def EVT_GRID_SELECT_CELL(win, fn):
 
1772     win.Connect(-1, -1, wxEVT_GRID_SELECT_CELL, fn)
 
1774 def EVT_GRID_EDITOR_SHOWN(win, fn):
 
1775     win.Connect(-1, -1, wxEVT_GRID_EDITOR_SHOWN, fn)
 
1777 def EVT_GRID_EDITOR_HIDDEN(win, fn):
 
1778     win.Connect(-1, -1, wxEVT_GRID_EDITOR_HIDDEN, fn)
 
1780 def EVT_GRID_EDITOR_CREATED(win, fn):
 
1781     win.Connect(-1, -1, wxEVT_GRID_EDITOR_CREATED, fn)
 
1785 //---------------------------------------------------------------------------
 
1788     wxClassInfo::CleanUpClasses();
 
1789     wxClassInfo::InitializeClasses();
 
1792 //---------------------------------------------------------------------------
 
1794 %pragma(python) include="_gridextras.py";
 
1796 //---------------------------------------------------------------------------