]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_gbsizer.i
Better cleanup of circular references.
[wxWidgets.git] / wxPython / src / _gbsizer.i
index 9d375953a867851378378cc333e686031b7504d5..8b79cc4c7d4c7356a882df53293fcd4c39c18512 100644 (file)
@@ -73,7 +73,8 @@ class wxGBPosition
 {
 public:
     wxGBPosition(int row=0, int col=0);
-
+    ~wxGBPosition();
+    
     int GetRow() const;
     int GetCol() const;
     void SetRow(int row);
@@ -94,7 +95,7 @@ public:
         }
         
         PyObject* Get() {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
@@ -143,6 +144,8 @@ public:
 colspan. The default is (1,1). (Meaning that the item occupies one
 cell in each direction.", "");
 
+    ~wxGBSpan();
+
     int GetRowspan() const;
     int GetColspan() const;
     void SetRowspan(int rowspan);
@@ -163,7 +166,7 @@ cell in each direction.", "");
         }
         
         PyObject* Get() {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRowspan()));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetColspan()));
@@ -218,19 +221,23 @@ item can be used in a Sizer.
 You will probably never need to create a wx.GBSizerItem directly as they
 are created automatically when the sizer's Add method is called.", "");
 
+    ~wxGBSizerItem();
+
+    
     %extend {
         DocStr(wxGBSizerItem( wxWindow *window, const wxGBPosition& pos,const wxGBSpan& span,int flag,int border,PyObject* userData=NULL ),
                "Construct a `wx.GBSizerItem` for a window.", "");
-        %name(GBSizerItemWindow) wxGBSizerItem( wxWindow *window,
-                                                const wxGBPosition& pos,
-                                                const wxGBSpan& span,
-                                                int flag,
-                                                int border,
-                                                PyObject* userData=NULL )
+        
+        %RenameCtor(GBSizerItemWindow, wxGBSizerItem( wxWindow *window,
+                                                      const wxGBPosition& pos,
+                                                      const wxGBSpan& span,
+                                                      int flag,
+                                                      int border,
+                                                      PyObject* userData=NULL ))
             {
                 wxPyUserData* data = NULL;
                 if ( userData ) {
-                    bool blocked = wxPyBeginBlockThreads();
+                    wxPyBlock_t blocked = wxPyBeginBlockThreads();
                     data = new wxPyUserData(userData);
                     wxPyEndBlockThreads(blocked);
                 }
@@ -240,36 +247,38 @@ are created automatically when the sizer's Add method is called.", "");
 
         DocStr(wxGBSizerItem( wxSizer *sizer,const wxGBPosition& pos,const wxGBSpan& span,int flag,int border,PyObject* userData=NULL ),
                "Construct a `wx.GBSizerItem` for a sizer", "");
-        %name(GBSizerItemSizer) wxGBSizerItem( wxSizer *sizer,
-                                               const wxGBPosition& pos,
-                                               const wxGBSpan& span,
-                                               int flag,
-                                               int border,
-                                               PyObject* userData=NULL )
+        %disownarg( wxSizer *sizer );
+        %RenameCtor(GBSizerItemSizer, wxGBSizerItem( wxSizer *sizer,
+                                                     const wxGBPosition& pos,
+                                                     const wxGBSpan& span,
+                                                     int flag,
+                                                     int border,
+                                                     PyObject* userData=NULL ))
             {
                 wxPyUserData* data = NULL;
                 if ( userData ) {
-                    bool blocked = wxPyBeginBlockThreads();
+                    wxPyBlock_t blocked = wxPyBeginBlockThreads();
                     data = new wxPyUserData(userData);
                     wxPyEndBlockThreads(blocked);
                 }
                 return new wxGBSizerItem(sizer, pos, span, flag, border, data);
             }
+        %cleardisown( wxSizer *sizer );
 
              
         DocStr(wxGBSizerItem( int width,int height,const wxGBPosition& pos,const wxGBSpan& span,int flag,int border,PyObject* userData=NULL),
                "Construct a `wx.GBSizerItem` for a spacer.", "");
-        %name(GBSizerItemSpacer) wxGBSizerItem( int width,
-                                                int height,
-                                                const wxGBPosition& pos,
-                                                const wxGBSpan& span,
-                                                int flag,
-                                                int border,
-                                                PyObject* userData=NULL)
+        %RenameCtor(GBSizerItemSpacer, wxGBSizerItem( int width,
+                                                      int height,
+                                                      const wxGBPosition& pos,
+                                                      const wxGBSpan& span,
+                                                      int flag,
+                                                      int border,
+                                                      PyObject* userData=NULL))
             {
                 wxPyUserData* data = NULL;
                 if ( userData ) {
-                    bool blocked = wxPyBeginBlockThreads();
+                    wxPyBlock_t blocked = wxPyBeginBlockThreads();
                     data = new wxPyUserData(userData);
                     wxPyEndBlockThreads(blocked);
                 }
@@ -387,10 +396,12 @@ position, False if something was already there.
                             PyObject* userData = NULL ) {
 
             wxPyUserData* data = NULL;
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false);
             if ( userData && (info.window || info.sizer || info.gotSize) )
                 data = new wxPyUserData(userData);
+            if ( info.sizer )
+                PyObject_SetAttrString(item,"thisown",Py_False);
             wxPyEndBlockThreads(blocked);
             
             // Now call the real Add method if a valid item type was found
@@ -404,7 +415,8 @@ position, False if something was already there.
             return NULL;
         }
     }
-    
+
+    %disownarg( wxGBSizerItem *item );
     DocDeclAStrName(
         wxGBSizerItem* , Add( wxGBSizerItem *item ),
         "Add(self, GBSizerItem item) -> wx.GBSizerItem",
@@ -412,6 +424,7 @@ position, False if something was already there.
 the item was successfully placed at its given cell position, False if
 something was already there.", "",
         AddItem);
+    %cleardisown( wxGBSizerItem *item );
 
     DocDeclStr(
         wxSize , GetCellSize(int row, int col) const,