Give classes that need one a destructor wrapper, and set %disown when

another class takes ownership.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-03-10 00:27:37 +00:00
parent d344366c42
commit c5633576a8
5 changed files with 40 additions and 11 deletions

View File

@@ -201,6 +201,7 @@ bitmap. This preserves mask information so that bitmaps and images can
be converted back and forth without loss in that respect.", ""); be converted back and forth without loss in that respect.", "");
DocDeclStr( DocDeclStr(
virtual wxMask* , GetMask() const, virtual wxMask* , GetMask() const,
"Gets the associated mask (if any) which may have been loaded from a "Gets the associated mask (if any) which may have been loaded from a
@@ -211,13 +212,14 @@ file or explpicitly set for the bitmap.
// MSW only? wxBitmap GetMaskBitmap() const; // MSW only? wxBitmap GetMaskBitmap() const;
%disownarg(wxMask*);
DocDeclStr( DocDeclStr(
virtual void , SetMask(wxMask* mask), virtual void , SetMask(wxMask* mask),
"Sets the mask for this bitmap. "Sets the mask for this bitmap.
:see: `GetMask`, `wx.Mask` :see: `GetMask`, `wx.Mask`
", ""); ", "");
%cleardisown(wxMask*);
%extend { %extend {
DocStr(SetMaskColour, DocStr(SetMaskColour,
@@ -338,7 +340,7 @@ passed then BLACK is used.
} }
} }
//~wxMask(); ~wxMask();
}; };
%pythoncode { MaskColour = wx._deprecated(Mask, "wx.MaskColour is deprecated, use `wx.Mask` instead.") } %pythoncode { MaskColour = wx._deprecated(Mask, "wx.MaskColour is deprecated, use `wx.Mask` instead.") }

View File

@@ -233,6 +233,7 @@ button label.", "");
"is not determinable, -1.", ""); "is not determinable, -1.", "");
}; };
DocStr(wxLayoutConstraints, DocStr(wxLayoutConstraints,
"**Note:** constraints are now deprecated and you should use sizers "**Note:** constraints are now deprecated and you should use sizers
instead. instead.
@@ -290,6 +291,8 @@ public:
wxLayoutConstraints(), wxLayoutConstraints(),
"", ""); "", "");
~wxLayoutConstraints();
DocDeclA( DocDeclA(
bool, SatisfyConstraints(wxWindow *win, int *OUTPUT), bool, SatisfyConstraints(wxWindow *win, int *OUTPUT),
"SatisfyConstraints(Window win) -> (areSatisfied, noChanges)"); "SatisfyConstraints(Window win) -> (areSatisfied, noChanges)");

View File

@@ -55,16 +55,21 @@ public:
wxMenu *submenu, wxMenu *submenu,
const wxString& help = wxPyEmptyString)); const wxString& help = wxPyEmptyString));
%disownarg(wxMenuItem*);
// the most generic form of Append() - append anything // the most generic form of Append() - append anything
%Rename(AppendItem, wxMenuItem*, Append(wxMenuItem *item)); %Rename(AppendItem, wxMenuItem*, Append(wxMenuItem *item));
// insert an item before given position
%Rename(InsertItem, wxMenuItem*, Insert(size_t pos, wxMenuItem *item));
// prepend an item to the menu
%Rename(PrependItem, wxMenuItem*, Prepend(wxMenuItem *item));
%cleardisown(wxMenuItem*);
// insert a break in the menu (only works when appending the items, not // insert a break in the menu (only works when appending the items, not
// inserting them) // inserting them)
virtual void Break(); virtual void Break();
// insert an item before given position
%Rename(InsertItem, wxMenuItem*, Insert(size_t pos, wxMenuItem *item));
// insert an item before given position // insert an item before given position
wxMenuItem* Insert(size_t pos, wxMenuItem* Insert(size_t pos,
int id, int id,
@@ -94,9 +99,6 @@ public:
wxMenu *submenu, wxMenu *submenu,
const wxString& help = wxPyEmptyString)); const wxString& help = wxPyEmptyString));
// prepend an item to the menu
%Rename(PrependItem, wxMenuItem*, Prepend(wxMenuItem *item));
// prepend any item to the menu // prepend any item to the menu
wxMenuItem* Prepend(int id, wxMenuItem* Prepend(int id,
const wxString& text, const wxString& text,
@@ -122,9 +124,11 @@ public:
wxMenu *submenu, wxMenu *submenu,
const wxString& help = wxPyEmptyString)); const wxString& help = wxPyEmptyString));
// detach an item from the menu, but don't delete it so that it can be // detach an item from the menu, but don't delete it so that it can be
// added back later (but if it's not, the caller is responsible for // added back later (but if it's not, the caller is responsible for
// deleting it!) // deleting it!)
%newobject Remove;
wxMenuItem *Remove(int id); wxMenuItem *Remove(int id);
%Rename(RemoveItem, wxMenuItem*, Remove(wxMenuItem *item)); %Rename(RemoveItem, wxMenuItem*, Remove(wxMenuItem *item));
@@ -323,6 +327,7 @@ public:
const wxString& help = wxPyEmptyString, const wxString& help = wxPyEmptyString,
wxItemKind kind = wxITEM_NORMAL, wxItemKind kind = wxITEM_NORMAL,
wxMenu* subMenu = NULL); wxMenu* subMenu = NULL);
~wxMenuItem();
// the menu we're in // the menu we're in
wxMenu *GetMenu() const; wxMenu *GetMenu() const;

View File

@@ -341,6 +341,7 @@ public:
bool GetAbort(); bool GetAbort();
static wxPrinterError GetLastError(); static wxPrinterError GetLastError();
}; };
@@ -414,9 +415,13 @@ MustHaveApp(wxPyPrintout);
class wxPyPrintout : public wxObject { class wxPyPrintout : public wxObject {
public: public:
%pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)" %pythonAppend wxPyPrintout "self._setCallbackInfo(self, Printout)"
%typemap(out) wxPyPrintout*; // turn off this typemap
wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr); wxPyPrintout(const wxString& title = wxPyPrintoutTitleStr);
//~wxPyPrintout(); wxPrintPreview object takes ownership... ~wxPyPrintout();
// Turn it back on again
%typemap(out) wxPyPrintout* { $result = wxPyMake_wxObject($1, $owner); }
void _setCallbackInfo(PyObject* self, PyObject* _class); void _setCallbackInfo(PyObject* self, PyObject* _class);
@@ -491,14 +496,17 @@ MustHaveApp(wxPreviewFrame);
class wxPreviewFrame : public wxFrame { class wxPreviewFrame : public wxFrame {
public: public:
%pythonAppend wxPreviewFrame "self._setOORInfo(self)" %disownarg(wxPrintPreview*);
%pythonAppend wxPreviewFrame "self._setOORInfo(self)"
wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title, wxPreviewFrame(wxPrintPreview* preview, wxFrame* parent, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxPyFrameNameStr); const wxString& name = wxPyFrameNameStr);
%cleardisown(wxPrintPreview*);
void Initialize(); void Initialize();
void CreateControlBar(); void CreateControlBar();
void CreateCanvas(); void CreateCanvas();
@@ -562,6 +570,8 @@ MustHaveApp(wxPrintPreview);
class wxPrintPreview : public wxObject { class wxPrintPreview : public wxObject {
public: public:
%disownarg(wxPyPrintout*);
%nokwargs wxPrintPreview; %nokwargs wxPrintPreview;
wxPrintPreview(wxPyPrintout* printout, wxPrintPreview(wxPyPrintout* printout,
wxPyPrintout* printoutForPrinting, wxPyPrintout* printoutForPrinting,
@@ -570,6 +580,8 @@ public:
wxPyPrintout* printoutForPrinting, wxPyPrintout* printoutForPrinting,
wxPrintData* data); wxPrintData* data);
~wxPrintPreview();
virtual bool SetCurrentPage(int pageNum); virtual bool SetCurrentPage(int pageNum);
int GetCurrentPage(); int GetCurrentPage();
@@ -577,6 +589,8 @@ public:
wxPyPrintout *GetPrintout(); wxPyPrintout *GetPrintout();
wxPyPrintout *GetPrintoutForPrinting(); wxPyPrintout *GetPrintoutForPrinting();
%cleardisown(wxPyPrintout*);
void SetFrame(wxFrame *frame); void SetFrame(wxFrame *frame);
void SetCanvas(wxPreviewCanvas *canvas); void SetCanvas(wxPreviewCanvas *canvas);
@@ -695,6 +709,8 @@ MustHaveApp(wxPyPrintPreview);
class wxPyPrintPreview : public wxPrintPreview class wxPyPrintPreview : public wxPrintPreview
{ {
public: public:
%disownarg(wxPyPrintout*);
%pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)" %pythonAppend wxPyPrintPreview "self._setCallbackInfo(self, PyPrintPreview)"
%nokwargs wxPyPrintPreview; %nokwargs wxPyPrintPreview;
wxPyPrintPreview(wxPyPrintout* printout, wxPyPrintPreview(wxPyPrintout* printout,
@@ -704,6 +720,8 @@ public:
wxPyPrintout* printoutForPrinting, wxPyPrintout* printoutForPrinting,
wxPrintData* data); wxPrintData* data);
%cleardisown(wxPyPrintout*);
void _setCallbackInfo(PyObject* self, PyObject* _class); void _setCallbackInfo(PyObject* self, PyObject* _class);
bool SetCurrentPage(int pageNum); bool SetCurrentPage(int pageNum);

View File

@@ -1810,7 +1810,7 @@ Only functional on Windows.", "");
// constraints and sizers // constraints and sizers
// ---------------------- // ----------------------
// set the constraints for this window or retrieve them (may be NULL) %disownarg(wxLayoutConstraints*);
DocDeclStr( DocDeclStr(
void , SetConstraints( wxLayoutConstraints *constraints ), void , SetConstraints( wxLayoutConstraints *constraints ),
"Sets the window to have the given layout constraints. If an existing "Sets the window to have the given layout constraints. If an existing
@@ -1828,6 +1828,7 @@ effect.", "");
wxLayoutConstraints *, GetConstraints() const, wxLayoutConstraints *, GetConstraints() const,
"Returns a pointer to the window's layout constraints, or None if there "Returns a pointer to the window's layout constraints, or None if there
are none.", ""); are none.", "");
%cleardisown(wxLayoutConstraints*);
DocDeclStr( DocDeclStr(