From b267ab6fd214d369bd416bacfe0526b26eb1bf9b Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 16 Oct 2000 02:24:01 +0000 Subject: [PATCH] Removed the old python sizers. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8567 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/.cvsignore | 1 + wxPython/CHANGES.txt | 3 + wxPython/MANIFEST.in | 3 +- wxPython/demo/Main.py | 2 +- wxPython/demo/OldSizers.py | 403 ----------------------- wxPython/wxPython/lib/sizers/.cvsignore | 2 - wxPython/wxPython/lib/sizers/__init__.py | 45 --- wxPython/wxPython/lib/sizers/border.py | 109 ------ wxPython/wxPython/lib/sizers/box.py | 137 -------- wxPython/wxPython/lib/sizers/shape.py | 97 ------ wxPython/wxPython/lib/sizers/sizer.py | 112 ------- 11 files changed, 6 insertions(+), 908 deletions(-) delete mode 100644 wxPython/demo/OldSizers.py delete mode 100644 wxPython/wxPython/lib/sizers/.cvsignore delete mode 100644 wxPython/wxPython/lib/sizers/__init__.py delete mode 100644 wxPython/wxPython/lib/sizers/border.py delete mode 100644 wxPython/wxPython/lib/sizers/box.py delete mode 100644 wxPython/wxPython/lib/sizers/shape.py delete mode 100644 wxPython/wxPython/lib/sizers/sizer.py diff --git a/wxPython/.cvsignore b/wxPython/.cvsignore index 2615725bc8..bf3bcde0de 100644 --- a/wxPython/.cvsignore +++ b/wxPython/.cvsignore @@ -4,4 +4,5 @@ build build.local dist licence +temp update.log diff --git a/wxPython/CHANGES.txt b/wxPython/CHANGES.txt index 4f45afa844..17c4aa5d3e 100644 --- a/wxPython/CHANGES.txt +++ b/wxPython/CHANGES.txt @@ -33,6 +33,9 @@ get notified when an asyncronous child process terminates, and also to get input/output streams for the child process's stdout, stderr and stdin. +Removed the old python sizers. + + New in 2.2.1 diff --git a/wxPython/MANIFEST.in b/wxPython/MANIFEST.in index c408c7e0c6..96baad339e 100644 --- a/wxPython/MANIFEST.in +++ b/wxPython/MANIFEST.in @@ -17,11 +17,10 @@ include demo/data/*.bmp include demo/data/*.txt include demo/data/*.i include demo/data/*.h +include demo/data/*.py include wxPython/lib/*.py include wxPython/lib/*.txt -include wxPython/lib/sizers/*.py -include wxPython/lib/sizers/*.txt include wxPython/lib/editor/*.py include wxPython/lib/editor/*.txt diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index d0e3af96a7..f202e14220 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -43,7 +43,7 @@ _treeList = [ 'wxCalendarCtrl', ]), - ('Window Layout', ['wxLayoutConstraints', 'Sizers', 'OldSizers']), + ('Window Layout', ['wxLayoutConstraints', 'Sizers', ]), ('Miscellaneous', [ 'DragAndDrop', 'CustomDragAndDrop', 'FontEnumerator', 'wxTimer', 'wxValidator', 'wxGLCanvas', 'DialogUnits', diff --git a/wxPython/demo/OldSizers.py b/wxPython/demo/OldSizers.py deleted file mode 100644 index cf24093eb7..0000000000 --- a/wxPython/demo/OldSizers.py +++ /dev/null @@ -1,403 +0,0 @@ -#---------------------------------------------------------------------- -# sizer test code -#---------------------------------------------------------------------- - -from wxPython.wx import * -from wxPython.lib.sizers import * - -#---------------------------------------------------------------------- - -def makeSimpleBox1(win): - box = wxBoxSizer(wxHORIZONTAL) - box.Add(wxButton(win, 1010, "one"), 0) - box.Add(wxButton(win, 1010, "two"), 0) - box.Add(wxButton(win, 1010, "three"), 0) - box.Add(wxButton(win, 1010, "four"), 0) - - return box - -#---------------------------------------------------------------------- - -def makeSimpleBox2(win): - box = wxBoxSizer(wxVERTICAL) - box.Add(wxButton(win, 1010, "one"), 0) - box.Add(wxButton(win, 1010, "two"), 0) - box.Add(wxButton(win, 1010, "three"), 0) - box.Add(wxButton(win, 1010, "four"), 0) - - return box - -#---------------------------------------------------------------------- - -def makeSimpleBox3(win): - box = wxBoxSizer(wxHORIZONTAL) - box.Add(wxButton(win, 1010, "one"), 0) - box.Add(wxButton(win, 1010, "two"), 0) - box.Add(wxButton(win, 1010, "three"), 0) - box.Add(wxButton(win, 1010, "four"), 0) - box.Add(wxButton(win, 1010, "five"), 1) - - return box - -#---------------------------------------------------------------------- - -def makeSimpleBox4(win): - box = wxBoxSizer(wxHORIZONTAL) - box.Add(wxButton(win, 1010, "one"), 0) - box.Add(wxButton(win, 1010, "two"), 0) - box.Add(wxButton(win, 1010, "three"), 1) - box.Add(wxButton(win, 1010, "four"), 1) - box.Add(wxButton(win, 1010, "five"), 1) - - return box - -#---------------------------------------------------------------------- - -def makeSimpleBox5(win): - box = wxBoxSizer(wxHORIZONTAL) - box.Add(wxButton(win, 1010, "one"), 0) - box.Add(wxButton(win, 1010, "two"), 0) - box.Add(wxButton(win, 1010, "three"), 3) - box.Add(wxButton(win, 1010, "four"), 1) - box.Add(wxButton(win, 1010, "five"), 1) - - return box - -#---------------------------------------------------------------------- - -def makeSimpleBox6(win): - box = wxBoxSizer(wxHORIZONTAL, wxSize(250, 50)) - box.Add(wxButton(win, 1010, "10"), 10) - box.Add(wxButton(win, 1010, "20"), 20) - box.Add(wxButton(win, 1010, "30"), 30) - box.Add(wxButton(win, 1010, "15"), 15) - box.Add(wxButton(win, 1010, "5"), 5) - - return box - -#---------------------------------------------------------------------- - -def makeSimpleBorder1(win): - bdr = wxBorderSizer(wxALL) - btn = wxButton(win, 1010, "border") - btn.SetSize(wxSize(80, 80)) - bdr.Add(btn, 15) - - return bdr - -#---------------------------------------------------------------------- - -def makeSimpleBorder2(win): - bdr = wxBorderSizer(wxEAST | wxWEST) - btn = wxButton(win, 1010, "border") - btn.SetSize(wxSize(80, 80)) - bdr.Add(btn, 15) - - return bdr - -#---------------------------------------------------------------------- - -def makeSimpleBorder3(win): - bdr = wxBorderSizer(wxNORTH | wxWEST) - btn = wxButton(win, 1010, "border") - btn.SetSize(wxSize(80, 80)) - bdr.Add(btn, 15) - - return bdr - -#---------------------------------------------------------------------- - -def makeShapes(win): - box =wxBoxSizer(wxVERTICAL) - box.Add(wxStaticLine(win, -1), 0) - for line in ( - (wxANCHOR_NW, "NorthWest"), - (wxANCHOR_NORTH, "North"), - (wxANCHOR_NE, "NorthEast") - ), ( - (wxANCHOR_WEST, "West"), - (wxANCHOR_NONE, "Center"), - (wxANCHOR_EAST, "East") - ), ( - (wxANCHOR_SW, "SouthWest"), - (wxANCHOR_SOUTH, "South"), - (wxANCHOR_SE, "SouthEast") - ): - linebox =wxBoxSizer(wxHORIZONTAL) - linebox.Add(wxStaticLine(win, -1, style=wxVERTICAL), 0) - for (anchor, label) in line: - sizer =wxShapeSizer(anchor) - sizer.Add(wxButton(win, -1, label, size=wxSize(100, 50))) - linebox.Add(sizer, 1) - linebox.Add(wxStaticLine(win, -1, style=wxVERTICAL), 0) - box.Add(linebox, 1) - box.Add(wxStaticLine(win, -1), 0) - return box - -#---------------------------------------------------------------------- - -def makeBoxInBox(win): - box = wxBoxSizer(wxVERTICAL) - - box.Add(wxButton(win, 1010, "one")) - - box2 = wxBoxSizer(wxHORIZONTAL) - box2.AddMany([ wxButton(win, 1010, "two"), - wxButton(win, 1010, "three"), - wxButton(win, 1010, "four"), - wxButton(win, 1010, "five"), - ]) - - box3 = wxBoxSizer(wxVERTICAL) - box3.AddMany([ (wxButton(win, 1010, "six"), 0), - (wxButton(win, 1010, "seven"), 2), - (wxButton(win, 1010, "eight"), 1), - (wxButton(win, 1010, "nine"), 1), - ]) - - box2.Add(box3, 1) - box.Add(box2, 1) - - box.Add(wxButton(win, 1010, "ten")) - - return box - -#---------------------------------------------------------------------- - -def makeBoxInBorder(win): - bdr = wxBorderSizer(wxALL) - box = makeSimpleBox3(win) - bdr.Add(box, 15) - - return bdr - -#---------------------------------------------------------------------- - -def makeBorderInBox(win): - insideBox = wxBoxSizer(wxHORIZONTAL) - - box2 = wxBoxSizer(wxHORIZONTAL) - box2.AddMany([ wxButton(win, 1010, "one"), - wxButton(win, 1010, "two"), - wxButton(win, 1010, "three"), - wxButton(win, 1010, "four"), - wxButton(win, 1010, "five"), - ]) - - insideBox.Add(box2, 0) - - bdr = wxBorderSizer(wxALL) - bdr.Add(wxButton(win, 1010, "border"), 20) - insideBox.Add(bdr, 1) - - box3 = wxBoxSizer(wxVERTICAL) - box3.AddMany([ (wxButton(win, 1010, "six"), 0), - (wxButton(win, 1010, "seven"), 2), - (wxButton(win, 1010, "eight"), 1), - (wxButton(win, 1010, "nine"), 1), - ]) - insideBox.Add(box3, 1) - - outsideBox = wxBoxSizer(wxVERTICAL) - outsideBox.Add(wxButton(win, 1010, "top")) - outsideBox.Add(insideBox, 1) - outsideBox.Add(wxButton(win, 1010, "bottom")) - - return outsideBox - - -#---------------------------------------------------------------------- - -theTests = [ - ("Simple horizontal boxes", makeSimpleBox1, - "This is a HORIZONTAL box sizer with four non-stretchable buttons held " - "within it. Notice that the buttons are added and aligned in the horizontal " - "dimension. Also notice that they are fixed size in the horizontal dimension, " - "but will stretch vertically." - ), - - ("Simple vertical boxes", makeSimpleBox2, - "Exactly the same as the previous sample but using a VERTICAL box sizer " - "instead of a HORIZONTAL one." - ), - - ("Add a stretchable", makeSimpleBox3, - "We've added one more button with the strechable flag turned on. Notice " - "how it grows to fill the extra space in the otherwise fixed dimension." - ), - - ("More than one stretchable", makeSimpleBox4, - "Here there are several items that are stretchable, they all divide up the " - "extra space evenly." - ), - - ("Weighting factor", makeSimpleBox5, - "This one shows more than one strechable, but one of them has a weighting " - "factor so it gets more of the free space." - ), - -# ("Percent Sizer", makeSimpleBox6, -# "You can use the wxBoxSizer like a Percent Sizer. Just make sure that all " -# "the weighting factors add up to 100!" -# ), - - ("", None, ""), - - ("Simple border sizer", makeSimpleBorder1, - "The wxBorderSizer leaves empty space around its contents. This one " - "gives a border all the way around." - ), - - ("East and West border", makeSimpleBorder2, - "You can pick and choose which sides have borders." - ), - - ("North and West border", makeSimpleBorder3, - "You can pick and choose which sides have borders." - ), - - ("", None, ""), - - - ("Proportional resize", makeShapes, - "The wxShapeSizer preserves the original proportions of the window." - ), - - ("", None, ""), - - ("Boxes inside of boxes", makeBoxInBox, - "This one shows nesting of boxes within boxes within boxes, using both " - "orientations. Notice also that button seven has a greater weighting " - "factor than its siblings." - ), - - ("Boxes inside a Border", makeBoxInBorder, - "Sizers of different types can be nested withing each other as well. " - "Here is a box sizer with several buttons embedded within a border sizer." - ), - - ("Border in a Box", makeBorderInBox, - "Another nesting example. This one has Boxes and a Border inside another Box." - ), - - ] -#---------------------------------------------------------------------- - -class TestFrame(wxFrame): - def __init__(self, parent, title, sizerFunc): - wxFrame.__init__(self, parent, -1, title) - EVT_BUTTON(self, 1010, self.OnButton) - - self.sizer = sizerFunc(self) - self.CreateStatusBar() - self.SetStatusText("Resize this frame to see how the sizers respond...") - self.sizer.FitWindow(self) - EVT_CLOSE(self, self.OnCloseWindow) - EVT_SIZE(self, self.OnSize) - - - def OnSize(self, event): - size = self.GetClientSize() - self.sizer.Layout(size) - - def OnCloseWindow(self, event): - self.MakeModal(false) - self.Destroy() - - def OnButton(self, event): - self.Close(true) - -#---------------------------------------------------------------------- - - - -class TestSelectionPanel(wxPanel): - def __init__(self, parent, frame=NULL): - wxPanel.__init__(self, parent, -1) - self.frame = frame - - self.list = wxListBox(self, 401, - wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 60), - []) - EVT_LISTBOX(self, 401, self.OnSelect) - EVT_LISTBOX_DCLICK(self, 401, self.OnDClick) - - wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault() - EVT_BUTTON(self, 402, self.OnDClick) - - self.text = wxTextCtrl(self, -1, "", - wxDLG_PNT(self, 10, 80), - wxDLG_SZE(self, 200, 60), - wxTE_MULTILINE | wxTE_READONLY) - - for item in theTests: - self.list.Append(item[0]) - - - - def OnSelect(self, event): - pos = self.list.GetSelection() - self.text.SetValue(theTests[pos][2]) - - - def OnDClick(self, event): - pos = self.list.GetSelection() - title = theTests[pos][0] - func = theTests[pos][1] - - if func: - win = TestFrame(self, title, func) - win.CentreOnParent(wxBOTH) - win.Show(true) - win.MakeModal(true) - -#---------------------------------------------------------------------- - -def runTest(frame, nb, log): - win = TestSelectionPanel(nb, frame) - return win - -overview = wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \ - wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \ - wxBorderSizer.__doc__ - -#---------------------------------------------------------------------- - - - -if __name__ == '__main__': - - class MainFrame(wxFrame): - def __init__(self): - wxFrame.__init__(self, NULL, -1, "Testing...") - - self.CreateStatusBar() - mainmenu = wxMenuBar() - menu = wxMenu() - menu.Append(200, 'E&xit', 'Get the heck outta here!') - mainmenu.Append(menu, "&File") - self.SetMenuBar(mainmenu) - EVT_MENU(self, 200, self.OnExit) - self.panel = TestSelectionPanel(self, self) - self.SetSize(wxSize(400, 380)) - EVT_CLOSE(self, self.OnCloseWindow) - - def OnCloseWindow(self, event): - self.Destroy() - - def OnExit(self, event): - self.Close(true) - - - class TestApp(wxApp): - def OnInit(self): - frame = MainFrame() - frame.Show(true) - self.SetTopWindow(frame) - return true - - app = TestApp(0) - app.MainLoop() - - -#---------------------------------------------------------------------- diff --git a/wxPython/wxPython/lib/sizers/.cvsignore b/wxPython/wxPython/lib/sizers/.cvsignore deleted file mode 100644 index 2f78cf5b66..0000000000 --- a/wxPython/wxPython/lib/sizers/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.pyc - diff --git a/wxPython/wxPython/lib/sizers/__init__.py b/wxPython/wxPython/lib/sizers/__init__.py deleted file mode 100644 index d73718ade5..0000000000 --- a/wxPython/wxPython/lib/sizers/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -#---------------------------------------------------------------------------- -# Name: __init__.py -# Purpose: The presence of this file turns this directory into a -# Python package. -# -# Author: Robin Dunn -# -# Created: 18-May-1999 -# RCS-ID: $Id$ -# Copyright: (c) 1998 by Total Control Software -# Licence: wxWindows license -#---------------------------------------------------------------------------- - -from sizer import * -from box import * -from border import * -from shape import * - -#---------------------------------------------------------------------------- -_msg = """\ -Since the wxWindows library now includes its own sizers, the -classes in wxPython.lib.sizers have been deprecated. Please -see the Reference Manual for details of the new classes. - -To contiunue using wxPython.lib.sizers without this -message you can set the WXP_OLDSIZERS envronment -variable to any value. -""" - - -import os -from wxPython.wx import wxMessageDialog, wxOK, wxICON_EXCLAMATION, wxPlatform - -if not os.environ.has_key('WXP_OLDSIZERS'): - if wxPlatform == '__WXMSW__': - dlg = wxMessageDialog(None, _msg, - "Deprecated Feature", - wxOK | wxICON_EXCLAMATION) - dlg.ShowModal() - dlg.Destroy() - else: - print '\a' - print _msg - -#---------------------------------------------------------------------------- diff --git a/wxPython/wxPython/lib/sizers/border.py b/wxPython/wxPython/lib/sizers/border.py deleted file mode 100644 index fd054c632e..0000000000 --- a/wxPython/wxPython/lib/sizers/border.py +++ /dev/null @@ -1,109 +0,0 @@ -#---------------------------------------------------------------------- -# Name: wxPython.lib.sizers.border -# Purpose: A Sizer that wraps an empty border around its contents -# -# Author: Robin Dunn -# -# Created: 9-June-1999 -# RCS-ID: $Id$ -# Copyright: (c) 1998 by Total Control Software -# Licence: wxWindows license -#---------------------------------------------------------------------- - -from sizer import wxSizer - -wxNORTH = 1 -wxSOUTH = 2 -wxEAST = 4 -wxWEST = 8 -wxALL = wxNORTH | wxSOUTH | wxEAST | wxWEST - -#---------------------------------------------------------------------- - -class wxBorderSizer(wxSizer): - """ - wxBorderSizer - - This sizer provides an empty buffer on one or more sides of it's - contents. It can only hold a single widget, but that can be a - sizer containing other items if you wish. - - The sizer is constructed with a parameter specifying which sides - should have the border. You can use a logical OR of the following - values to specify the sides: - - wxNORTH -- the top side - wxSOUTH -- the bottom side - wxEAST -- the right side - wxWEST -- the left side - wxALL -- all sides - - The width in pixels of the border is specified when the child - widget is Added to the sizer. - - """ - def __init__(self, sides = wxALL): - wxSizer.__init__(self) - self.sides = sides - - - def Add(self, widget, borderSize): - if self.children: - raise ValueError("wxBorderSizer can only contain one child.") - - wxSizer.Add(self, widget, borderSize) - - - def CalcMin(self): - isSizer, widget, width, height, borderSize = self.children[0] - - if isSizer: - width, height = widget.CalcMin() - - if self.sides & wxEAST: - width = width + borderSize - - if self.sides & wxWEST: - width = width + borderSize - - if self.sides & wxNORTH: - height = height + borderSize - - if self.sides & wxSOUTH: - height = height + borderSize - - return width, height - - - def RecalcSizes(self): - isSizer, widget, width, height, borderSize = self.children[0] - width = self.size.width - height = self.size.height - px = self.origin.x - py = self.origin.y - - if self.sides & wxWEST: - width = width - borderSize - px = px + borderSize - if self.sides & wxEAST: - width = width - borderSize - - if self.sides & wxNORTH: - height = height - borderSize - py = py + borderSize - if self.sides & wxSOUTH: - height = height - borderSize - - widget.SetDimensions(px, py, width, height) - - -#---------------------------------------------------------------------- -# -# TODO... Make an abstract class wxBorder whose decendants can be added to -# a wxBorderSizer to provide drawing for the buffer area. Ideas are -# to provide a color border, beveled borders, rounded borders, etc. - - - - - diff --git a/wxPython/wxPython/lib/sizers/box.py b/wxPython/wxPython/lib/sizers/box.py deleted file mode 100644 index 64c9378565..0000000000 --- a/wxPython/wxPython/lib/sizers/box.py +++ /dev/null @@ -1,137 +0,0 @@ -#---------------------------------------------------------------------- -# Name: wxPython.lib.sizers.box -# Purpose: A sizer/layout managers for wxPython that places items in -# a stretchable box -# -# Author: Robin Dunn and Dirk Holtwick -# -# Created: 17-May-1999 -# RCS-ID: $Id$ -# Copyright: (c) 1998 by Total Control Software -# Licence: wxWindows license -#---------------------------------------------------------------------- - -from sizer import wxSizer -from wxPython.wx import wxVERTICAL, wxHORIZONTAL - -#---------------------------------------------------------------------- - - -class wxBoxSizer(wxSizer): - """ - wxBoxSizer - - A Sizer that lays components out in a box, in the order they are - added to the layout manager, with a given orientation. The - orientation is specified in the constructor with either wxVERTICAL - or wxHORIZONTAL. - - The optional parameter to the Add method (for this sizer it's - called the stretch flag) can be used to flag one or more components - as stretchable, meaning that they will expand to fill available - space in the given orientation. The default is zero, or not - stretchable. - - If the stretch flag is non-zero then the widget will stretch. If - the sizer holds more than one item that is stretchable then they - share the available space. - - If the strech flag is greater than 1 then it serves as a weighting - factor. Widgets with a flag of 2 will get twice as much space as - widgets with 1, etc. - """ - def __init__(self, orientation, size = None): - wxSizer.__init__(self, size) - self.orientation = orientation - - - def CalcMin(self): - self.stretchable = 0 # number of stretchable items - self.minWidth = 0 # minimal size - self.minHeight = 0 - self.fixedWidth = 0 # size without stretched widgets - self.fixedHeight = 0 - - # iterate through children - for (isSizer, widget, width, height, stretch) in self.children: - weight = 1 - if stretch: - weight = stretch - - if isSizer: - # let sub-sizers recalc their required space - width, height = widget.CalcMin() - - # minimal size - if self.orientation == wxVERTICAL: - self.minHeight = self.minHeight + (height * weight) - self.minWidth = max(self.minWidth, width) - else: - self.minWidth = self.minWidth + (width * weight) - self.minHeight = max(self.minHeight, height) - - # stretchable items - if stretch: - self.stretchable = self.stretchable + weight - else: - if self.orientation == wxVERTICAL: - self.fixedHeight = self.fixedHeight + height - self.fixedWidth = max(self.fixedWidth, width) - else: - self.fixedWidth = self.fixedWidth + width - self.fixedHeight = max(self.fixedHeight, height) - - return self.minWidth, self.minHeight - - - - def RecalcSizes(self): - # get current dimensions, save for performance - myWidth = self.size.width - myHeight = self.size.height - - # relative recent positions & sizes - px = self.origin.x - py = self.origin.y - newWidth = 0 - newHeight = 0 - - # calculate space for one stretched item - if self.stretchable: - if self.orientation == wxHORIZONTAL: - delta = (myWidth - self.fixedWidth) / self.stretchable - extra = (myWidth - self.fixedWidth) % self.stretchable - else: - delta = (myHeight - self.fixedHeight) / self.stretchable - extra = (myHeight - self.fixedHeight) % self.stretchable - - # iterate children ... - for (isSizer, widget, width, height, stretch) in self.children: - weight = 1 - if stretch: - weight = stretch - - if isSizer: - width, height = widget.CalcMin() - - # ... vertical - if self.orientation == wxVERTICAL: - newHeight = height - if stretch: - newHeight = (delta * weight) + extra # first stretchable gets extra pixels - extra = 0 - widget.SetDimensions(px, py, myWidth, newHeight) - - # ... horizontal - elif self.orientation == wxHORIZONTAL: - newWidth = width - if stretch: - newWidth = (delta * weight) + extra # first stretchable gets extra pixels - extra = 0 - widget.SetDimensions(px, py, newWidth, myHeight) - - px = px + newWidth - py = py + newHeight - - -#---------------------------------------------------------------------- diff --git a/wxPython/wxPython/lib/sizers/shape.py b/wxPython/wxPython/lib/sizers/shape.py deleted file mode 100644 index cd38c23421..0000000000 --- a/wxPython/wxPython/lib/sizers/shape.py +++ /dev/null @@ -1,97 +0,0 @@ -#---------------------------------------------------------------------- -# Name: wxPython.lib.sizers.shape -# Purpose: A Sizer that preserves the shape (proportions) -# of the managed window -# -# Created: 7-October-1999 -# RCS-ID: $Id$ -# Copyright: SIA "ANK" -# Licence: wxWindows license -#---------------------------------------------------------------------- - -from sizer import wxSizer - -wxANCHOR_NONE = 0 -wxANCHOR_NORTH = 1 -wxANCHOR_SOUTH = 2 -wxANCHOR_EAST = 4 -wxANCHOR_WEST = 8 -wxANCHOR_NW = wxANCHOR_NORTH | wxANCHOR_WEST -wxANCHOR_NE = wxANCHOR_NORTH | wxANCHOR_EAST -wxANCHOR_SW = wxANCHOR_SOUTH | wxANCHOR_WEST -wxANCHOR_SE = wxANCHOR_SOUTH | wxANCHOR_EAST - -#---------------------------------------------------------------------- - -class wxShapeSizer(wxSizer): - """ - wxShapeSizer - - This sizer preserves the proportional dimensions of the managed - window, leaving empty space either in horizontal or vertical - dimension. - - By default, the managed window is centered within allowed size. - You may specify an anchor parameter to leave all of the extra - space on one side: wxANCHOR_NORTH and wxANCHOR_SOUTH manage - vertical dimension, leaving extra space on the bottom or top side, - respectively; wxANCHOR_EAST and wxANCHOR_WEST do the same in - horizontal dimension. wxANCHOR_NW, wxANCHOR_NE, wxANCHOR_SW - and wxANCHOR_SE are short-cut names for combinations north+west, - north+east, south+west, south+east. - - If both anchors are specified in either direction, south and east - take precedence over north and west, respectively. (Because of - gravity, widgets tend to fall down.) - """ - def __init__(self, anchor =wxANCHOR_NONE): - wxSizer.__init__(self) - self.anchor =anchor - - def Add(self, widget): - if self.children: - raise ValueError("wxShapeSizer can only contain one child.") - - wxSizer.Add(self, widget) - - def CalcMin(self): - isSizer, widget, width, height, borderSize = self.children[0] - - if isSizer: - width, height = widget.CalcMin() - - return width, height - - def RecalcSizes(self): - isSizer, widget, width, height, borderSize = self.children[0] - width =self.size.width - height =self.size.height - px =self.origin.x - py =self.origin.y - anchor =self.anchor - # get current dimensions of the managed window - w, h =self.CalcMin() - ratio =float(w) /h - # in what direction space should be added: - # -1: horisontal - # 1: vertical - # 0: shape is ok - dir =cmp(ratio /width *height, 1) - if dir <0: - # recalculate width - old_width =width - width =height *ratio - if anchor & wxANCHOR_EAST: - px =px +old_width -width - elif not (anchor & wxANCHOR_WEST): - px =px +(old_width -width) /2 - elif dir >0: - # recalculate height - old_height =height - height =width /ratio - if anchor & wxANCHOR_SOUTH: - py =py +old_height -height - elif not (anchor & wxANCHOR_NORTH): - py =py +(old_height -height) /2 - - widget.SetDimensions(px, py, width, height) diff --git a/wxPython/wxPython/lib/sizers/sizer.py b/wxPython/wxPython/lib/sizers/sizer.py deleted file mode 100644 index 5cca29cbfe..0000000000 --- a/wxPython/wxPython/lib/sizers/sizer.py +++ /dev/null @@ -1,112 +0,0 @@ -#---------------------------------------------------------------------- -# Name: wxPython.lib.sizers.sizer -# Purpose: General purpose sizer/layout managers for wxPython -# -# Author: Robin Dunn and Dirk Holtwick -# -# Created: 17-May-1999 -# RCS-ID: $Id$ -# Copyright: (c) 1998 by Total Control Software -# Licence: wxWindows license -#---------------------------------------------------------------------- - -from wxPython.wx import wxPoint, wxSize - -#---------------------------------------------------------------------- - -class wxSizer: - """ - wxSizer - - An abstract base sizer class. A sizer is able to manage the size and - layout of windows and/or child sizers. - - Derived classes should implement CalcMin, and RecalcSizes. - - A window or sizer is added to this sizer with the Add method: - - def Add(self, widget, opt=0) - - The meaning of the opt parameter is different for each type of - sizer. It may be a single value or a collection of values. - """ - def __init__(self, size = None): - self.children = [] - self.origin = wxPoint(0, 0) - if not size: - size = wxSize(0,0) - self.size = size - - def Add(self, widget, opt=0): - """ - Add a window or a sizer to this sizer. The meaning of the opt - parameter is different for each type of sizer. It may be a single - value or a collection of values. - """ - size = widget.GetSize() - isSizer = isinstance(widget, wxSizer) - self.children.append( (isSizer, widget, size.width, size.height, opt) ) - - - def AddMany(self, widgets): - """ - Add a sequence (list, tuple, etc.) of widgets to this sizer. The - items in the sequence should be tuples containing valid args for - the Add method. - """ - for childinfo in widgets: - if type(childinfo) != type(()): - childinfo = (childinfo, ) - apply(self.Add, childinfo) - - - def SetDimensions(self, x, y, width, height): - self.origin = wxPoint(x, y) - self.size = wxSize(width, height) - self.RecalcSizes() - - def GetSize(self): - return self.size - - def GetPosition(self): - return self.origin - - def CalcMin(self): - raise NotImplementedError("Derived class should implement CalcMin") - - def RecalcSizes(self): - raise NotImplementedError("Derived class should implement RecalcSizes") - - - - def __getMinWindowSize(self, win): - """ - Calculate the best size window to hold this sizer, taking into - account the difference between client size and window size. - """ - min = self.GetMinSize() - a1,a2 = win.GetSizeTuple() - b1,b2 = win.GetClientSizeTuple() - w = min.width + (a1 - b1) - h = min.height + (a2 - b2) - return (w, h) - - - def GetMinSize(self): - minWidth, minHeight = self.CalcMin() - return wxSize(minWidth, minHeight) - - def SetWindowSizeHints(self, win): - w, h = self.__getMinWindowSize(win) - win.SetSizeHints(w,h) - - def FitWindow(self, win): - w, h = self.__getMinWindowSize(win) - win.SetSize(wxSize(w,h)) - - def Layout(self, size): - self.CalcMin() - self.SetDimensions(self.origin.x, self.origin.y, - size.width, size.height) - -#----------------------------------------------------------------------