]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/grid.i
fixes to wint_t and wchar_t handling in unichar.h (fixes FreeBSD compilation and...
[wxWidgets.git] / wxPython / src / grid.i
index 0c7718da11945f8c9793e5da2a56ec277fd61634..8b90576987123d9377373ae9ecf6195bb4e85953 100644 (file)
@@ -455,6 +455,20 @@ class wxGridCellAttr;
 #define wxGRID_VALUE_DATETIME   "datetime"
 
 
+// magic constant which tells (to some functions) to automatically calculate
+// the appropriate size
+enum { wxGRID_AUTOSIZE };
+
+
+// many wxGrid methods work either with columns or rows, this enum is used for
+// the parameter indicating which one should it be
+enum wxGridDirection
+{
+    wxGRID_COLUMN,
+    wxGRID_ROW
+};
+
+
 %immutable;
 const wxGridCellCoords wxGridNoCellCoords;
 const wxRect           wxGridNoCellRect;
@@ -523,16 +537,19 @@ public:
 
 class wxGridCellRenderer : public wxGridCellWorker
 {
+public:
     virtual void Draw(wxGrid& grid,
                       wxGridCellAttr& attr,
                       wxDC& dc,
                       const wxRect& rect,
                       int row, int col,
                       bool isSelected);
+    
     virtual wxSize GetBestSize(wxGrid& grid,
                                wxGridCellAttr& attr,
                                wxDC& dc,
                                int row, int col);
+    
     virtual wxGridCellRenderer *Clone() const;
 };
 
@@ -590,6 +607,7 @@ public:
                     rval = *ptr;
                 }
                 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) {
+                    PyErr_Clear();  // Clear the exception left over from wxPyConvertSwigPtr
                     PyObject* o1 = PySequence_GetItem(ro, 0);
                     PyObject* o2 = PySequence_GetItem(ro, 1);
                     if (PyNumber_Check(o1) && PyNumber_Check(o2))
@@ -640,7 +658,7 @@ IMP_PYCALLBACK__STRING( wxPyGridCellRenderer, wxGridCellRenderer, SetParameters)
 // Let SWIG know about it so it can create the Python version
 class wxPyGridCellRenderer : public wxGridCellRenderer {
 public:
-    %pythonAppend wxPyGridCellRenderer  "self._setCallbackInfo(self, PyGridCellRenderer);self._setOORInfo(self)"
+    %pythonAppend wxPyGridCellRenderer  "self._setOORInfo(self);"  setCallbackInfo(PyGridCellRenderer);
 
     wxPyGridCellRenderer();
     void _setCallbackInfo(PyObject* self, PyObject* _class);
@@ -747,7 +765,7 @@ public:
     virtual void StartingClick();
     virtual void HandleReturn(wxKeyEvent& event);
 
-    %pythonAppend Destroy "args[0].thisown = 0"
+    %pythonPrepend Destroy "args[0].this.own(False)"
     virtual void Destroy();
 
     %property(CellAttr, GetCellAttr, SetCellAttr, doc="See `GetCellAttr` and `SetCellAttr`");
@@ -835,7 +853,7 @@ public:
     void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) {
         bool found;
         wxPyBlock_t blocked = wxPyBeginBlockThreads();
-        if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) {
+        if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground"))) {
             PyObject* ao = wxPyMake_wxGridCellAttr(attr,false);
             PyObject* ro = wxPyConstructObject((void*)&rectCell, wxT("wxRect"), 0);
 
@@ -880,7 +898,7 @@ IMP_PYCALLBACK_STRING__constpure(wxPyGridCellEditor, wxGridCellEditor, GetValue)
 // Let SWIG know about it so it can create the Python version
 class wxPyGridCellEditor : public wxGridCellEditor {
 public:
-    %pythonAppend wxPyGridCellEditor  "self._setCallbackInfo(self, PyGridCellEditor);self._setOORInfo(self)"
+    %pythonAppend wxPyGridCellEditor  "self._setOORInfo(self);" setCallbackInfo(PyGridCellEditor)
 
     wxPyGridCellEditor();
     void _setCallbackInfo(PyObject* self, PyObject* _class);
@@ -936,11 +954,22 @@ public:
 };
 
 
+MAKE_CONST_WXSTRING2(OneString, _T("1"));
 class wxGridCellBoolEditor : public wxGridCellEditor
 {
 public:
     %pythonAppend wxGridCellBoolEditor  "self._setOORInfo(self)"
     wxGridCellBoolEditor();
+
+    // set the string values returned by GetValue() for the true and false
+    // states, respectively
+    static void UseStringValues(const wxString& valueTrue = wxPyOneString,
+                                const wxString& valueFalse = wxPyEmptyString);
+
+    // return true if the given string is equal to the string representation of
+    // true value which we currently use
+    static bool IsTrueValue(const wxString& value);
+
 };
 
 class wxGridCellChoiceEditor : public wxGridCellEditor
@@ -1109,7 +1138,7 @@ public:
 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
 {
 public:
-    %pythonAppend wxPyGridCellAttrProvider  "self._setCallbackInfo(self, PyGridCellAttrProvider)"
+    %pythonAppend wxPyGridCellAttrProvider  setCallbackInfo(PyGridCellAttrProvider)
     wxPyGridCellAttrProvider();
     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
@@ -1338,11 +1367,11 @@ public:
 class wxPyGridTableBase : public wxGridTableBase
 {
 public:
-    %pythonAppend wxPyGridTableBase "self._setCallbackInfo(self, PyGridTableBase);self._setOORInfo(self)"
+    %pythonAppend wxPyGridTableBase  "self._setOORInfo(self);"  setCallbackInfo(PyGridTableBase)
     wxPyGridTableBase();
     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
-    %pythonAppend Destroy "args[0].thisown = 0"
+    %pythonPrepend Destroy "args[0].this.own(False)"
     %extend { void Destroy() { delete self; } }
 
     wxString GetTypeName( int row, int col );
@@ -1591,7 +1620,7 @@ public:
     def __str__(self):                   return str(self.Get())
     def __repr__(self):                  return 'wxGridCellCoords'+str(self.Get())
     def __len__(self):                   return len(self.Get())
-    def __getitem__(self, index):        return self.asTuple()[index]
+    def __getitem__(self, index):        return self.Get()[index]
     def __setitem__(self, index, val):
         if index == 0: self.SetRow(val)
         elif index == 1: self.SetCol(val)
@@ -2128,6 +2157,23 @@ public:
 };
 
 
+// ----------------------------------------------------------------------------
+// wxGridUpdateLocker prevents updates to a grid during its lifetime
+// ----------------------------------------------------------------------------
+
+class wxGridUpdateLocker
+{
+public:
+    // if the pointer is NULL, Create() can be called later
+    wxGridUpdateLocker(wxGrid *grid = NULL);
+    ~wxGridUpdateLocker();
+
+    // can be called if ctor was used with a NULL pointer, must not be called
+    // more than once
+    void Create(wxGrid *grid);
+    
+};
+
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 // Grid events and stuff