]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/grid.i
New SWIG runtime files and api updates for the move to SWIG 1.3.22
[wxWidgets.git] / wxPython / src / grid.i
index 42544af69ce44c9818ad400874affad1a7b3154c..90d185537869269b257116285daaa8a5cd0c86a4 100644 (file)
@@ -63,7 +63,8 @@ PyObject* wxPyMake_##TYPE(TYPE* source, bool setThisOwn) { \
         wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \
         if (data) { \
             target = data->m_obj; \
-            Py_INCREF(target); \
+            if (target) \
+                Py_INCREF(target); \
         } \
         /* Otherwise make a new wrapper for it the old fashioned way and \
            give it the OOR treatment */ \
@@ -521,28 +522,30 @@ const wxRect           wxGridNoCellRect;
 %mutable;
 
 
-%rename(GRID_DEFAULT_NUMBER_ROWS) WXGRID_DEFAULT_NUMBER_ROWS;
-%rename(GRID_DEFAULT_NUMBER_COLS) WXGRID_DEFAULT_NUMBER_COLS;
-%rename(GRID_DEFAULT_ROW_HEIGHT) WXGRID_DEFAULT_ROW_HEIGHT;
-%rename(GRID_DEFAULT_COL_WIDTH) WXGRID_DEFAULT_COL_WIDTH;
-%rename(GRID_DEFAULT_COL_LABEL_HEIGHT) WXGRID_DEFAULT_COL_LABEL_HEIGHT;
-%rename(GRID_DEFAULT_ROW_LABEL_WIDTH) WXGRID_DEFAULT_ROW_LABEL_WIDTH;
-%rename(GRID_LABEL_EDGE_ZONE) WXGRID_LABEL_EDGE_ZONE;
-%rename(GRID_MIN_ROW_HEIGHT) WXGRID_MIN_ROW_HEIGHT;
-%rename(GRID_MIN_COL_WIDTH) WXGRID_MIN_COL_WIDTH;
-%rename(GRID_DEFAULT_SCROLLBAR_WIDTH) WXGRID_DEFAULT_SCROLLBAR_WIDTH;
+%{
+#define wxGRID_DEFAULT_NUMBER_ROWS        WXGRID_DEFAULT_NUMBER_ROWS
+#define wxGRID_DEFAULT_NUMBER_COLS        WXGRID_DEFAULT_NUMBER_COLS
+#define wxGRID_DEFAULT_ROW_HEIGHT         WXGRID_DEFAULT_ROW_HEIGHT
+#define wxGRID_DEFAULT_COL_WIDTH          WXGRID_DEFAULT_COL_WIDTH
+#define wxGRID_DEFAULT_COL_LABEL_HEIGHT   WXGRID_DEFAULT_COL_LABEL_HEIGHT
+#define wxGRID_DEFAULT_ROW_LABEL_WIDTH    WXGRID_DEFAULT_ROW_LABEL_WIDTH
+#define wxGRID_LABEL_EDGE_ZONE            WXGRID_LABEL_EDGE_ZONE
+#define wxGRID_MIN_ROW_HEIGHT             WXGRID_MIN_ROW_HEIGHT
+#define wxGRID_MIN_COL_WIDTH              WXGRID_MIN_COL_WIDTH
+#define wxGRID_DEFAULT_SCROLLBAR_WIDTH    WXGRID_DEFAULT_SCROLLBAR_WIDTH
+%}
 
 enum {
-    WXGRID_DEFAULT_NUMBER_ROWS,
-    WXGRID_DEFAULT_NUMBER_COLS,
-    WXGRID_DEFAULT_ROW_HEIGHT,
-    WXGRID_DEFAULT_COL_WIDTH,
-    WXGRID_DEFAULT_COL_LABEL_HEIGHT,
-    WXGRID_DEFAULT_ROW_LABEL_WIDTH,
-    WXGRID_LABEL_EDGE_ZONE,
-    WXGRID_MIN_ROW_HEIGHT,
-    WXGRID_MIN_COL_WIDTH,
-    WXGRID_DEFAULT_SCROLLBAR_WIDTH
+    wxGRID_DEFAULT_NUMBER_ROWS,
+    wxGRID_DEFAULT_NUMBER_COLS,
+    wxGRID_DEFAULT_ROW_HEIGHT,
+    wxGRID_DEFAULT_COL_WIDTH,
+    wxGRID_DEFAULT_COL_LABEL_HEIGHT,
+    wxGRID_DEFAULT_ROW_LABEL_WIDTH,
+    wxGRID_LABEL_EDGE_ZONE,
+    wxGRID_MIN_ROW_HEIGHT,
+    wxGRID_MIN_COL_WIDTH,
+    wxGRID_DEFAULT_SCROLLBAR_WIDTH
 };
 
 
@@ -556,7 +559,8 @@ class wxGridCellRenderer
 public:
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
@@ -762,7 +766,8 @@ class  wxGridCellEditor
 public:
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
@@ -1030,14 +1035,15 @@ public:
 
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
     %pythonAppend wxGridCellAttr  "self._setOORInfo(self)"
 
     wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
-
+    
     wxGridCellAttr *Clone() const;
     void MergeWith(wxGridCellAttr *mergefrom);
     void IncRef();
@@ -1095,7 +1101,8 @@ public:
 
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
@@ -1156,7 +1163,8 @@ public:
 
     %extend {
         void _setOORInfo(PyObject* _self) {
-            self->SetClientObject(new wxPyOORClientData(_self));
+            if (!self->GetClientObject())
+                self->SetClientObject(new wxPyOORClientData(_self));
         }
     }
 
@@ -1584,6 +1592,7 @@ class wxGrid : public wxScrolledWindow
 {
 public:
     %pythonAppend wxGrid "self._setOORInfo(self)"
+    %typemap(out) wxGrid*;    // turn off this typemap
 
     wxGrid( wxWindow *parent,
             wxWindowID id=-1,
@@ -1594,6 +1603,10 @@ public:
 
     %name(PreGrid) wxGrid();
 
+    
+    // Turn it back on again
+    %typemap(out) wxGrid* { $result = wxPyMake_wxObject($1, $owner); }
+
 
     bool Create( wxWindow *parent,
                  wxWindowID id=-1,
@@ -1798,11 +1811,22 @@ public:
     void     DisableDragGridSize();
     bool     CanDragGridSize();
 
+    void     EnableDragCell( bool enable = True );
+    void     DisableDragCell();
+    bool     CanDragCell();
+
     // this sets the specified attribute for all cells in this row/col
     void     SetAttr(int row, int col, wxGridCellAttr *attr);
     void     SetRowAttr(int row, wxGridCellAttr *attr);
     void     SetColAttr(int col, wxGridCellAttr *attr);
 
+    // returns the attribute we may modify in place: a new one if this cell
+    // doesn't have any yet or the existing one if it does
+    //
+    // DecRef() must be called on the returned pointer, as usual
+    wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const;
+
+    
     // shortcuts for setting the column parameters
 
     // set the format for the data in the column: default is string
@@ -2089,6 +2113,7 @@ public:
 %constant wxEventType wxEVT_GRID_EDITOR_SHOWN;
 %constant wxEventType wxEVT_GRID_EDITOR_HIDDEN;
 %constant wxEventType wxEVT_GRID_EDITOR_CREATED;
+%constant wxEventType wxEVT_GRID_CELL_BEGIN_DRAG;
 
 
 
@@ -2109,6 +2134,7 @@ EVT_GRID_SELECT_CELL = wx.PyEventBinder( wxEVT_GRID_SELECT_CELL )
 EVT_GRID_EDITOR_SHOWN = wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN )
 EVT_GRID_EDITOR_HIDDEN = wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN )
 EVT_GRID_EDITOR_CREATED = wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED )
+EVT_GRID_CELL_BEGIN_DRAG = wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG )
 
 
 %# The same as above but with the ability to specify an identifier
@@ -2128,6 +2154,8 @@ EVT_GRID_CMD_SELECT_CELL =         wx.PyEventBinder( wxEVT_GRID_SELECT_CELL,
 EVT_GRID_CMD_EDITOR_SHOWN =        wx.PyEventBinder( wxEVT_GRID_EDITOR_SHOWN,       1 )
 EVT_GRID_CMD_EDITOR_HIDDEN =       wx.PyEventBinder( wxEVT_GRID_EDITOR_HIDDEN,      1 )
 EVT_GRID_CMD_EDITOR_CREATED =      wx.PyEventBinder( wxEVT_GRID_EDITOR_CREATED,     1 )
+EVT_GRID_CMD_CELL_BEGIN_DRAG =     wx.PyEventBinder( wxEVT_GRID_CELL_BEGIN_DRAG,    1 )
+    
 }
 
 //---------------------------------------------------------------------------