Avoid using the OOR typemap in the constructors

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28291 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2004-07-17 22:51:01 +00:00
parent 14885f0910
commit b39c3fa09a
23 changed files with 131 additions and 12 deletions

View File

@ -82,15 +82,18 @@ public:
class wxPyShapeEvtHandler : public wxObject {
public:
%pythonAppend wxPyShapeEvtHandler "self._setOORandCallbackInfo(PyShapeEvtHandler)"
%typemap(out) wxPyShapeEvtHandler*; // turn off this typemap
wxPyShapeEvtHandler(wxPyShapeEvtHandler *prev = NULL,
wxPyShape *shape = NULL);
%typemap(out) wxPyShapeEvtHandler* { $result = wxPyMake_wxShapeEvtHandler($1, $owner); }
void _setCallbackInfo(PyObject* self, PyObject* _class);
%extend {
void _setOORInfo(PyObject* _self) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self));
self->SetClientObject(new wxPyOORClientData(_self));
}
}
%pythoncode {
@ -147,9 +150,12 @@ public:
class wxPyShape : public wxPyShapeEvtHandler {
public:
%pythonAppend wxPyShape "self._setOORandCallbackInfo(PyShape)"
%typemap(out) wxPyShape*; // turn off this typemap
wxPyShape(wxPyShapeCanvas *can = NULL);
%typemap(out) wxPyShape* { $result = wxPyMake_wxShapeEvtHandler($1, $owner); }
void _setCallbackInfo(PyObject* self, PyObject* _class);
void GetBoundingBoxMax(double *OUTPUT, double *OUTPUT);

View File

@ -104,13 +104,16 @@ MustHaveApp(wxPyShapeCanvas);
class wxPyShapeCanvas : public wxScrolledWindow {
public:
%pythonAppend wxPyShapeCanvas "self._setOORandCallbackInfo(PyShapeCanvas)"
%typemap(out) wxPyShapeCanvas*; // turn off this typemap
wxPyShapeCanvas(wxWindow* parent = NULL, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER,
const wxString& name = wxPyShapeCanvasNameStr);
%typemap(out) wxPyShapeCanvas* { $result = wxPyMake_wxObject($1, $owner); }
void _setCallbackInfo(PyObject* self, PyObject* _class);
%pythoncode {
def _setOORandCallbackInfo(self, _class):

View File

@ -538,9 +538,12 @@ public:
class wxPyDivisionShape : public wxPyCompositeShape {
public:
%pythonAppend wxPyDivisionShape "self._setOORandCallbackInfo(PyDivisionShape)"
%typemap(out) wxPyDivisionShape*; // turn off this typemap
wxPyDivisionShape();
%typemap(out) wxPyDivisionShape* { $result = wxPyMake_wxShapeEvtHandler($1, $owner); }
void _setCallbackInfo(PyObject* self, PyObject* _class);
void AdjustBottom(double bottom, bool test);

View File

@ -50,6 +50,7 @@ public:
%pythonAppend wxPyApp
"self._setCallbackInfo(self, PyApp)
self._setOORInfo(self)";
%typemap(out) wxPyApp*; // turn off this typemap
DocStr(wxPyApp,
"Create a new application object, starting the bootstrap process.", "");
@ -62,6 +63,10 @@ public:
~wxPyApp();
// Turn it back on again
%typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); }
void _setCallbackInfo(PyObject* self, PyObject* _class);

View File

@ -65,6 +65,7 @@ class wxButton : public wxControl
public:
%pythonAppend wxButton "self._setOORInfo(self)"
%pythonAppend wxButton() ""
%typemap(out) wxButton*; // turn off this typemap
DocCtorStr(
@ -82,6 +83,10 @@ public:
"Precreate a Button for 2-phase creation.", "",
PreButton);
// Turn it back on again
%typemap(out) wxButton* { $result = wxPyMake_wxObject($1, $owner); }
DocDeclStr(
bool , Create(wxWindow* parent, wxWindowID id=-1,
const wxString& label=wxPyEmptyString,
@ -154,6 +159,7 @@ class wxBitmapButton : public wxButton
public:
%pythonAppend wxBitmapButton "self._setOORInfo(self)"
%pythonAppend wxBitmapButton() ""
%typemap(out) wxBitmapButton*; // turn off this typemap
DocCtorStr(
wxBitmapButton(wxWindow* parent, wxWindowID id=-1,
@ -170,6 +176,10 @@ public:
"Precreate a BitmapButton for 2-phase creation.", "",
PreBitmapButton);
// Turn it back on again
%typemap(out) wxBitmapButton* { $result = wxPyMake_wxObject($1, $owner); }
DocDeclStr(
bool , Create(wxWindow* parent, wxWindowID id=-1,
const wxBitmap& bitmap = wxNullBitmap,

View File

@ -34,6 +34,7 @@ class wxControl : public wxWindow
public:
%pythonAppend wxControl "self._setOORInfo(self)"
%pythonAppend wxControl() ""
%typemap(out) wxControl*; // turn off this typemap
DocCtorStr(
wxControl(wxWindow *parent,
@ -51,6 +52,10 @@ __init__ as a plain old wx.Control is not very useful.", "");
"Precreate a Control control for 2-phase creation", "",
PreControl);
// Turn it back on again
%typemap(out) wxControl* { $result = wxPyMake_wxObject($1, $owner); }
DocDeclStr(
bool , Create(wxWindow *parent,
wxWindowID id=-1,

View File

@ -19,8 +19,14 @@
// wxEvtHandler: the base class for all objects handling wxWindows events
class wxEvtHandler : public wxObject {
public:
// turn off this typemap
%typemap(out) wxEvtHandler*;
wxEvtHandler();
// Turn it back on again
%typemap(out) wxEvtHandler* { $result = wxPyMake_wxObject($1, $owner); }
wxEvtHandler* GetNextHandler();
wxEvtHandler* GetPreviousHandler();
void SetNextHandler(wxEvtHandler* handler);
@ -69,8 +75,7 @@ public:
%extend {
void _setOORInfo(PyObject* _self) {
if (_self && _self != Py_None) {
if (!self->GetClientObject())
self->SetClientObject(new wxPyOORClientData(_self));
self->SetClientObject(new wxPyOORClientData(_self));
}
else {
wxPyOORClientData* data = (wxPyOORClientData*)self->GetClientObject();

View File

@ -86,6 +86,7 @@ class wxMDIChildFrame : public wxFrame {
public:
%pythonAppend wxMDIChildFrame "self._setOORInfo(self)"
%pythonAppend wxMDIChildFrame() ""
%typemap(out) wxMDIChildFrame*; // turn off this typemap
wxMDIChildFrame(wxMDIParentFrame* parent,
const wxWindowID id=-1,
@ -96,6 +97,9 @@ public:
const wxString& name = wxPyFrameNameStr);
%name(PreMDIChildFrame)wxMDIChildFrame();
// Turn it back on again
%typemap(out) wxMDIChildFrame* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxMDIParentFrame* parent,
const wxWindowID id=-1,
const wxString& title = wxPyEmptyString,
@ -119,10 +123,14 @@ class wxMDIClientWindow : public wxWindow {
public:
%pythonAppend wxMDIClientWindow "self._setOORInfo(self)"
%pythonAppend wxMDIClientWindow() ""
%typemap(out) wxMDIClientWindow*; // turn off this typemap
wxMDIClientWindow(wxMDIParentFrame* parent, long style = 0);
%name(PreMDIClientWindow)wxMDIClientWindow();
// Turn it back on again
%typemap(out) wxMDIClientWindow* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxMDIParentFrame* parent, long style = 0);
};

View File

@ -23,9 +23,14 @@ class wxMenu : public wxEvtHandler
{
public:
%pythonAppend wxMenu "self._setOORInfo(self)"
%typemap(out) wxMenu*; // turn off this typemap
wxMenu(const wxString& title = wxPyEmptyString, long style = 0);
// Turn it back on again
%typemap(out) wxMenu* { $result = wxPyMake_wxObject($1, $owner); }
// append any kind of item (normal/check/radio/separator)
wxMenuItem* Append(int id,
const wxString& text,
@ -211,8 +216,12 @@ class wxMenuBar : public wxWindow
{
public:
%pythonAppend wxMenuBar "self._setOORInfo(self)"
%typemap(out) wxMenuBar*; // turn off this typemap
wxMenuBar(long style = 0);
// Turn it back on again
%typemap(out) wxMenuBar* { $result = wxPyMake_wxObject($1, $owner); }
// append a menu to the end of menubar, return True if ok
virtual bool Append(wxMenu *menu, const wxString& title);

View File

@ -168,6 +168,7 @@ class wxNotebook : public wxBookCtrl {
public:
%pythonAppend wxNotebook "self._setOORInfo(self)"
%pythonAppend wxNotebook() ""
%typemap(out) wxNotebook*; // turn off this typemap
wxNotebook(wxWindow *parent,
wxWindowID id=-1,
@ -177,6 +178,9 @@ public:
const wxString& name = wxPyNOTEBOOK_NAME);
%name(PreNotebook)wxNotebook();
// Turn it back on again
%typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow *parent,
wxWindowID id=-1,
const wxPoint& pos = wxDefaultPosition,

View File

@ -29,6 +29,7 @@ class wxPanel : public wxWindow
public:
%pythonAppend wxPanel "self._setOORInfo(self)"
%pythonAppend wxPanel() ""
%typemap(out) wxPanel*; // turn off this typemap
wxPanel(wxWindow* parent,
const wxWindowID id=-1,
@ -38,6 +39,9 @@ public:
const wxString& name = wxPyPanelNameStr);
%name(PrePanel)wxPanel();
// Turn it back on again
%typemap(out) wxPanel* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent,
const wxWindowID id=-1,
const wxPoint& pos = wxDefaultPosition,
@ -66,6 +70,7 @@ class wxScrolledWindow : public wxPanel
public:
%pythonAppend wxScrolledWindow "self._setOORInfo(self)"
%pythonAppend wxScrolledWindow() ""
%typemap(out) wxScrolledWindow*; // turn off this typemap
wxScrolledWindow(wxWindow* parent,
const wxWindowID id = -1,
@ -75,6 +80,9 @@ public:
const wxString& name = wxPyPanelNameStr);
%name(PreScrolledWindow)wxScrolledWindow();
// Turn it back on again
%typemap(out) wxScrolledWindow* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent,
const wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,

View File

@ -29,6 +29,7 @@ class wxStaticBox : public wxControl {
public:
%pythonAppend wxStaticBox "self._setOORInfo(self)"
%pythonAppend wxStaticBox() ""
%typemap(out) wxStaticBox*; // turn off this typemap
wxStaticBox(wxWindow* parent, wxWindowID id=-1,
const wxString& label = wxPyEmptyString,
@ -38,6 +39,9 @@ public:
const wxString& name = wxPyStaticBoxNameStr);
%name(PreStaticBox)wxStaticBox();
// Turn it back on again
%typemap(out) wxStaticBox* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent, wxWindowID id=-1,
const wxString& label = wxPyEmptyString,
const wxPoint& pos = wxDefaultPosition,

View File

@ -30,12 +30,16 @@ class wxStatusBar : public wxWindow
public:
%pythonAppend wxStatusBar "self._setOORInfo(self)"
%pythonAppend wxStatusBar() ""
%typemap(out) wxStatusBar*; // turn off this typemap
wxStatusBar(wxWindow* parent, wxWindowID id = -1,
long style = wxDEFAULT_STATUSBAR_STYLE,
const wxString& name = wxPyStatusLineNameStr);
%name(PreStatusBar)wxStatusBar();
// Turn it back on again
%typemap(out) wxStatusBar* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent, wxWindowID id=-1,
long style = wxST_SIZEGRIP,
const wxString& name = wxPyStatusLineNameStr);

View File

@ -165,6 +165,7 @@ class wxTextCtrl : public wxControl
public:
%pythonAppend wxTextCtrl "self._setOORInfo(self)"
%pythonAppend wxTextCtrl() ""
%typemap(out) wxTextCtrl*; // turn off this typemap
wxTextCtrl(wxWindow* parent, wxWindowID id=-1,
const wxString& value = wxPyEmptyString,
@ -175,6 +176,9 @@ public:
const wxString& name = wxPyTextCtrlNameStr);
%name(PreTextCtrl)wxTextCtrl();
// Turn it back on again
%typemap(out) wxTextCtrl* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent, wxWindowID id=-1,
const wxString& value = wxPyEmptyString,
const wxPoint& pos = wxDefaultPosition,

View File

@ -391,7 +391,8 @@ class wxToolBar : public wxToolBarBase {
public:
%pythonAppend wxToolBar "self._setOORInfo(self)"
%pythonAppend wxToolBar() ""
%typemap(out) wxToolBar*; // turn off this typemap
wxToolBar(wxWindow *parent,
wxWindowID id=-1,
const wxPoint& pos = wxDefaultPosition,
@ -400,6 +401,9 @@ public:
const wxString& name = wxPyToolBarNameStr);
%name(PreToolBar)wxToolBar();
// Turn it back on again
%typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow *parent,
wxWindowID id=-1,
const wxPoint& pos = wxDefaultPosition,

View File

@ -151,6 +151,7 @@ class wxFrame : public wxTopLevelWindow {
public:
%pythonAppend wxFrame "self._setOORInfo(self)"
%pythonAppend wxFrame() ""
%typemap(out) wxFrame*; // turn off this typemap
wxFrame(wxWindow* parent, const wxWindowID id=-1,
const wxString& title = wxPyEmptyString,
@ -160,6 +161,10 @@ public:
const wxString& name = wxPyFrameNameStr);
%name(PreFrame)wxFrame();
// Turn it back on again
%typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent, const wxWindowID id=-1,
const wxString& title = wxPyEmptyString,
const wxPoint& pos = wxDefaultPosition,
@ -265,6 +270,7 @@ class wxDialog : public wxTopLevelWindow {
public:
%pythonAppend wxDialog "self._setOORInfo(self)"
%pythonAppend wxDialog() ""
%typemap(out) wxDialog*; // turn off this typemap
wxDialog(wxWindow* parent,
const wxWindowID id=-1,
@ -275,6 +281,9 @@ public:
const wxString& name = wxPyDialogNameStr);
%name(PreDialog)wxDialog();
// Turn it back on again
%typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow* parent,
const wxWindowID id=-1,
const wxString& title = wxPyEmptyString,

View File

@ -315,6 +315,7 @@ MustHaveApp(wxPyTreeCtrl);
public:
%pythonAppend wxPyTreeCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeCtrl)"
%pythonAppend wxPyTreeCtrl() ""
%typemap(out) wxPyTreeCtrl*; // turn off this typemap
wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
@ -324,6 +325,9 @@ public:
const wxString& name = wxPyTreeCtrlNameStr);
%name(PreTreeCtrl)wxPyTreeCtrl();
// Turn it back on again
%typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,

View File

@ -33,10 +33,15 @@ class wxValidator : public wxEvtHandler
{
public:
%pythonAppend wxValidator "self._setOORInfo(self)"
%typemap(out) wxValidator*; // turn off this typemap
wxValidator();
//~wxValidator();
// Turn it back on again
%typemap(out) wxValidator* { $result = wxPyMake_wxObject($1, $owner); }
// Make a clone of this validator (or return NULL)
wxValidator* Clone();

View File

@ -199,6 +199,7 @@ class wxWindow : public wxEvtHandler
public:
%pythonAppend wxWindow "self._setOORInfo(self)"
%pythonAppend wxWindow() ""
%typemap(out) wxWindow*; // turn off this typemap
DocCtorStr(
wxWindow(wxWindow* parent, const wxWindowID id=-1,
@ -213,7 +214,10 @@ public:
"Precreate a Window for 2-phase creation.", "",
PreWindow);
// Turn it back on again
%typemap(out) wxWindow* { $result = wxPyMake_wxObject($1, $owner); }
DocDeclStr(
bool , Create(wxWindow* parent, const wxWindowID id=-1,
const wxPoint& pos = wxDefaultPosition,

View File

@ -1592,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,
@ -1602,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,

View File

@ -791,6 +791,7 @@ MustHaveApp(wxPyHtmlWindow);
public:
%pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)"
%pythonAppend wxPyHtmlWindow() ""
%typemap(out) wxPyHtmlWindow*; // turn off this typemap
wxPyHtmlWindow(wxWindow *parent, int id = -1,
const wxPoint& pos = wxDefaultPosition,
@ -799,6 +800,9 @@ public:
const wxString& name = wxPyHtmlWindowNameStr);
%name(PreHtmlWindow)wxPyHtmlWindow();
// Turn it back on again
%typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
bool Create(wxWindow *parent, int id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,

View File

@ -340,6 +340,9 @@ SWIG_AsDouble(PyObject *obj)
// to the real derived type, if possible. See wxPyMake_wxObject in
// helpers.cpp
// NOTE: For those classes that also call _setOORInfo these typemaps should be
// disabled for the constructor.
%typemap(out) wxEvtHandler* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMenu* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxValidator* { $result = wxPyMake_wxObject($1, $owner); }
@ -349,7 +352,6 @@ SWIG_AsDouble(PyObject *obj)
%typemap(out) wxDC* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxFSFile* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxFileSystem* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxGridTableBase* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxImageList* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxListItem* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMenuItem* { $result = wxPyMake_wxObject($1, $owner); }
@ -365,7 +367,7 @@ SWIG_AsDouble(PyObject *obj)
%typemap(out) wxControl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxGrid* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxListCtrl* { $result = wxPyMake_wxObject($1, $owner); }
//%typemap(out) wxListCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMDIChildFrame* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMDIClientWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxMenuBar* { $result = wxPyMake_wxObject($1, $owner); }
@ -375,12 +377,12 @@ SWIG_AsDouble(PyObject *obj)
%typemap(out) wxTextCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxToolBarBase* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
//%typemap(out) wxTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPyWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxPanel* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
%typemap(out) wxScrolledWindow* { $result = wxPyMake_wxObject($1, $owner); }

View File

@ -207,6 +207,7 @@ public:
%pythonAppend wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
%pythonAppend wxPyWizardPage() ""
%typemap(out) wxPyWizardPage*; // turn off this typemap
// ctor accepts an optional bitmap which will be used for this page instead
// of the default one for this wizard (should be of the same size). Notice
@ -225,6 +226,9 @@ public:
%name(PrePyWizardPage)wxPyWizardPage();
// Turn it back on again
%typemap(out) wxPyWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
%extend {
bool Create(wxWizard *parent,
const wxBitmap& bitmap = wxNullBitmap,