]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_sizers.i
sync with CVS updates
[wxWidgets.git] / wxPython / src / _sizers.i
index c7bb1356a6384475137658c24bef222e2dcb1676..d69a2c20a4cd19a25551413b4aab40740b1aa946 100644 (file)
@@ -608,6 +608,7 @@ this sizer.  See `Add` for a description of the parameters.", "");
 //    virtual wxSizerItem* PrependSpacer(int size);
 //    virtual wxSizerItem* PrependStretchSpacer(int prop = 1);
 
+        
         DocAStr(Remove,
                 "Remove(self, item) -> bool",
                 "Removes an item from the sizer and destroys it.  This method does not
@@ -692,6 +693,48 @@ the item to be found.", "");
         }
     }
 
+    
+    %Rename(_ReplaceWin,
+            bool, Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false ));
+    %Rename(_ReplaceSizer,
+            bool, Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false ));
+    %Rename(_ReplaceItem,
+            bool, Replace( size_t index, wxSizerItem *newitem ));
+    %pythoncode {
+        def Replace(self, olditem, item, recursive=False):
+            """
+            Detaches the given ``olditem`` from the sizer and replaces it with
+            ``item`` which can be a window, sizer, or `wx.SizerItem`.  The
+            detached child is destroyed only if it is not a window, (because
+            windows are owned by their parent, not the sizer.)  The
+            ``recursive`` parameter can be used to search for the given
+            element recursivly in subsizers.
+
+            This method does not cause any layout or resizing to take place,
+            call `Layout` to do so.
+
+            Returns ``True`` if the child item was found and removed.
+            """
+            if isinstance(olditem, wx.Window):
+                return self._ReplaceWin(olditem, item, recursive)
+            elif isinstnace(olditem, wx.Sizer):
+                return self._ReplaceSizer(olditem, item, recursive)
+            elif isinstnace(olditem, int):
+                return self._ReplaceItem(olditem, item)
+            else:
+                raise TypeError("Expected Window, Sizer, or integer for first parameter.")
+    }
+    
+    
+    DocDeclStr(
+        void , SetContainingWindow(wxWindow *window),
+        "Set (or unset) the window this sizer is used in.", "");
+    
+    DocDeclStr(
+        wxWindow *, GetContainingWindow() const,
+        "Get the window this sizer is used in.", "");
+        
+
     %pythoncode {
     def SetItemMinSize(self, item, *args):
         """
@@ -746,6 +789,50 @@ the item to be found.", "");
                 item = (item, )
             self.Add(*item)
 
+    def AddSpacer(self, *args, **kw):
+        """AddSpacer(int size) --> SizerItem
+
+        Add a spacer that is (size,size) pixels.
+        """
+        if args and type(args[0]) == int:
+            return self.Add( (args[0],args[0] ), 0)
+        else: %# otherwise stay compatible with old AddSpacer
+            return self.Add(*args, **kw)
+    def PrependSpacer(self, *args, **kw):
+        """PrependSpacer(int size) --> SizerItem
+
+        Prepend a spacer that is (size, size) pixels."""
+        if args and type(args[0]) == int:
+            return self.Prepend( (args[0],args[0] ), 0)
+        else: %# otherwise stay compatible with old PrependSpacer
+            return self.Prepend(*args, **kw)
+    def InsertSpacer(self, index, *args, **kw):
+        """InsertSpacer(int index, int size) --> SizerItem
+
+        Insert a spacer at position index that is (size, size) pixels."""
+        if args and type(args[0]) == int:
+            return self.Insert( index, (args[0],args[0] ), 0)
+        else: %# otherwise stay compatible with old InsertSpacer
+            return self.Insert(index, *args, **kw)
+
+                   
+    def AddStretchSpacer(self, prop=1):
+        """AddStretchSpacer(int prop=1) --> SizerItem
+
+        Add a stretchable spacer."""
+        return self.Add((0,0), prop)
+    def PrependStretchSpacer(self, prop=1):
+        """PrependStretchSpacer(int prop=1) --> SizerItem
+
+        Prepend a stretchable spacer."""
+        return self.Prepend((0,0), prop)
+    def InsertStretchSpacer(self, index, prop=1):
+        """InsertStretchSpacer(int index, int prop=1) --> SizerItem
+
+        Insert a stretchable spacer."""
+        return self.Insert(index, (0,0), prop)
+
+            
     %# for backwards compatibility only, please do not use in new code
     def AddWindow(self, *args, **kw):
         """Compatibility alias for `Add`."""
@@ -753,9 +840,6 @@ the item to be found.", "");
     def AddSizer(self, *args, **kw):
         """Compatibility alias for `Add`."""
         return self.Add(*args, **kw)
-    def AddSpacer(self, *args, **kw):
-        """Compatibility alias for `Add`."""
-        return self.Add(*args, **kw)
 
     def PrependWindow(self, *args, **kw):
         """Compatibility alias for `Prepend`."""
@@ -763,9 +847,6 @@ the item to be found.", "");
     def PrependSizer(self, *args, **kw):
         """Compatibility alias for `Prepend`."""
         return self.Prepend(*args, **kw)
-    def PrependSpacer(self, *args, **kw):
-        """Compatibility alias for `Prepend`."""
-        return self.Prepend(*args, **kw)
 
     def InsertWindow(self, *args, **kw):
         """Compatibility alias for `Insert`."""
@@ -773,9 +854,6 @@ the item to be found.", "");
     def InsertSizer(self, *args, **kw):
         """Compatibility alias for `Insert`."""
         return self.Insert(*args, **kw)
-    def InsertSpacer(self, *args, **kw):
-        """Compatibility alias for `Insert`."""
-        return self.Insert(*args, **kw)
 
     def RemoveWindow(self, *args, **kw):
         """Compatibility alias for `Remove`."""
@@ -1202,6 +1280,11 @@ define extra space between all children.", "");
                 cols = (nitems + rows - 1) / rows
             return (rows, cols)
     }
+    
+    %property(Cols, GetCols, SetCols, doc="See `GetCols` and `SetCols`");
+    %property(HGap, GetHGap, SetHGap, doc="See `GetHGap` and `SetHGap`");
+    %property(Rows, GetRows, SetRows, doc="See `GetRows` and `SetRows`");
+    %property(VGap, GetVGap, SetVGap, doc="See `GetVGap` and `SetVGap`");
 };
 
 //---------------------------------------------------------------------------
@@ -1322,9 +1405,7 @@ previously). Argument *mode* can be one of the following values:
                                 growable or not in the flexbile direction.
     ==========================  =================================================
 
-Note that this method does not trigger relayout.
-
-", "");
+Note that this method does not trigger relayout.", "");
 
     DocDeclStr(
         wxFlexSizerGrowMode , GetNonFlexibleGrowMode(),
@@ -1347,6 +1428,12 @@ rows in the sizer.", "");
         "Returns a list of integers representing the widths of each of the
 columns in the sizer.", "");
 
+
+    %property(ColWidths, GetColWidths, doc="See `GetColWidths`");
+    %property(FlexibleDirection, GetFlexibleDirection, SetFlexibleDirection, doc="See `GetFlexibleDirection` and `SetFlexibleDirection`");
+    %property(NonFlexibleGrowMode, GetNonFlexibleGrowMode, SetNonFlexibleGrowMode, doc="See `GetNonFlexibleGrowMode` and `SetNonFlexibleGrowMode`");
+    %property(RowHeights, GetRowHeights, doc="See `GetRowHeights`");
+    
 };
 
 //---------------------------------------------------------------------------