1 #----------------------------------------------------------------------
2 # Name: wxPython.lib.sizers.border
3 # Purpose: A Sizer that wraps an empty border around its contents
9 # Copyright: (c) 1998 by Total Control Software
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------
13 from sizer
import wxSizer
19 wxALL
= wxNORTH | wxSOUTH | wxEAST | wxWEST
21 #----------------------------------------------------------------------
23 class wxBorderSizer(wxSizer
):
27 This sizer provides an empty buffer on one or more sides of it's
28 contents. It can only hold a single widget, but that can be a
29 sizer containing other items if you wish.
31 The sizer is constructed with a parameter specifying which sides
32 should have the border. You can use a logical OR of the following
33 values to specify the sides:
35 wxNORTH -- the top side
36 wxSOUTH -- the bottom side
37 wxEAST -- the right side
38 wxWEST -- the left side
41 The width in pixels of the border is specified when the child
42 widget is Added to the sizer.
45 def __init__(self
, sides
= wxALL
):
46 wxSizer
.__init
__(self
)
50 def Add(self
, widget
, borderSize
):
52 raise ValueError("wxBorderSizer can only contain one child.")
54 wxSizer
.Add(self
, widget
, borderSize
)
58 isSizer
, widget
, width
, height
, borderSize
= self
.children
[0]
61 width
, height
= widget
.CalcMin()
63 if self
.sides
& wxEAST
:
64 width
= width
+ borderSize
66 if self
.sides
& wxWEST
:
67 width
= width
+ borderSize
69 if self
.sides
& wxNORTH
:
70 height
= height
+ borderSize
72 if self
.sides
& wxSOUTH
:
73 height
= height
+ borderSize
78 def RecalcSizes(self
):
79 isSizer
, widget
, width
, height
, borderSize
= self
.children
[0]
80 width
= self
.size
.width
81 height
= self
.size
.height
85 if self
.sides
& wxWEST
:
86 width
= width
- borderSize
88 if self
.sides
& wxEAST
:
89 width
= width
- borderSize
91 if self
.sides
& wxNORTH
:
92 height
= height
- borderSize
94 if self
.sides
& wxSOUTH
:
95 height
= height
- borderSize
97 widget
.SetDimensions(px
, py
, width
, height
)
100 #----------------------------------------------------------------------
102 # TODO... Make an abstract class wxBorder whose decendants can be added to
103 # a wxBorderSizer to provide drawing for the buffer area. Ideas are
104 # to provide a color border, beveled borders, rounded borders, etc.