Editors, Renderers and Attrs need to have a destructor so SWIG won't

complain about it, but since they are protected in C++ we need to give
them a dummy one.  In the future these shoud be changed to use
%ref/%unref and let SWIG manage the refcount for us.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38226 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2006-03-20 18:02:37 +00:00
parent ce1522a1f2
commit 607a3fa066
4 changed files with 36 additions and 16 deletions

View File

@ -104,6 +104,8 @@ typedef unsigned long wxUIntPtr;
#define %disownarg(typespec) %typemap(in) typespec = SWIGTYPE* DISOWN
#define %cleardisown(typespec) %typemap(in) typespec
#define %ref %feature("ref")
#define %unref %feature("unref")
#ifndef %pythoncode

View File

@ -24,6 +24,7 @@
%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;
%rename(GridCellWorker) wxGridCellWorker;
%rename(GridCellRenderer) wxGridCellRenderer;
%rename(PyGridCellRenderer) wxPyGridCellRenderer;
%rename(GridCellStringRenderer) wxGridCellStringRenderer;

View File

@ -491,11 +491,14 @@ enum {
//---------------------------------------------------------------------------
// wxGridCellRenderer is an ABC, and several derived classes are available.
// Classes implemented in Python should be derived from wxPyGridCellRenderer.
// TODO: Use these to have SWIG automatically handle the IncRef/DecRef calls:
//
// %ref wxGridCellWorker "$this->IncRef();";
// %unref wxGridCellWorker "$this->DecRef();";
//
class wxGridCellRenderer
class wxGridCellWorker
{
public:
%extend {
@ -503,12 +506,25 @@ public:
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self));
}
// A dummy dtor to shut up SWIG. (The real one is protected and can
// only be called by DecRef)
~wxGridCellWorker() {
}
}
void SetParameters(const wxString& params);
void IncRef();
void DecRef();
};
// wxGridCellRenderer is an ABC, and several derived classes are available.
// Classes implemented in Python should be derived from wxPyGridCellRenderer.
class wxGridCellRenderer : public wxGridCellWorker
{
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
@ -523,6 +539,7 @@ public:
};
// The C++ version of wxPyGridCellRenderer
%{
class wxPyGridCellRenderer : public wxGridCellRenderer
@ -703,16 +720,9 @@ public:
// wxGridCellEditor is an ABC, and several derived classes are available.
// Classes implemented in Python should be derived from wxPyGridCellEditor.
class wxGridCellEditor
class wxGridCellEditor : public wxGridCellWorker
{
public:
%extend {
void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self));
}
}
bool IsCreated();
wxControl* GetControl();
void SetControl(wxControl* control);
@ -720,10 +730,6 @@ public:
wxGridCellAttr* GetCellAttr();
void SetCellAttr(wxGridCellAttr* attr);
void SetParameters(const wxString& params);
void IncRef();
void DecRef();
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler);
@ -991,11 +997,20 @@ public:
%pythonAppend wxGridCellAttr "self._setOORInfo(self)"
wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
%extend {
// A dummy dtor to shut up SWIG. (The real one is protected and can
// only be called by DecRef)
~wxGridCellAttr() {
}
}
wxGridCellAttr *Clone() const;
void MergeWith(wxGridCellAttr *mergefrom);
void IncRef();
void DecRef();
void SetTextColour(const wxColour& colText);
void SetBackgroundColour(const wxColour& colBack);
void SetFont(const wxFont& font);
@ -1092,7 +1107,7 @@ public:
void _setCallbackInfo(PyObject* self, PyObject* _class);
wxGridCellAttr *GetAttr(int row, int col,
wxGridCellAttr::wxAttrKind kind);
wxGridCellAttr::wxAttrKind kind);
void SetAttr(wxGridCellAttr *attr, int row, int col);
void SetRowAttr(wxGridCellAttr *attr, int row);
void SetColAttr(wxGridCellAttr *attr, int col);

View File

@ -40,6 +40,8 @@ wxGRID_LABEL_EDGE_ZONE = wx.grid.GRID_LABEL_EDGE_ZONE
wxGRID_MIN_ROW_HEIGHT = wx.grid.GRID_MIN_ROW_HEIGHT
wxGRID_MIN_COL_WIDTH = wx.grid.GRID_MIN_COL_WIDTH
wxGRID_DEFAULT_SCROLLBAR_WIDTH = wx.grid.GRID_DEFAULT_SCROLLBAR_WIDTH
wxGridCellWorker = wx.grid.GridCellWorker
wxGridCellWorkerPtr = wx.grid.GridCellWorkerPtr
wxGridCellRenderer = wx.grid.GridCellRenderer
wxGridCellRendererPtr = wx.grid.GridCellRendererPtr
wxPyGridCellRenderer = wx.grid.PyGridCellRenderer