DocStr(wxSizerItem,
"The wx.SizerItem class is used to track the position, size and other
-attributes of each item managed by a `wx.Sizer`. In normal usage user
-code should never need to deal directly with a wx.SizerItem, but
-custom classes derived from `wx.PySizer` will probably need to use the
-collection of wx.SizerItems held by wx.Sizer when calculating layout.
+attributes of each item managed by a `wx.Sizer`. It is not usually
+necessary to use this class because the sizer elements can also be
+identified by their positions or window or sizer references but
+sometimes it may be more convenient to use wx.SizerItem directly.
+Also, custom classes derived from `wx.PySizer` will probably need to
+use the collection of wx.SizerItems held by wx.Sizer when calculating
+layout.
:see: `wx.Sizer`, `wx.GBSizerItem`", "");
:see: `wx.SizerItemSpacer`, `wx.SizerItemWindow`, `wx.SizerItemSizer`", "");
-
+ ~wxSizerItem();
+
+
%extend {
DocStr(
wxSizerItem( wxWindow *window, int proportion, int flag,
int border, PyObject* userData=NULL ),
- "Constructs a `wx.SizerItem` for tracking a window.", "");
-
- %name(SizerItemWindow) wxSizerItem( wxWindow *window, int proportion, int flag,
- int border, PyObject* userData=NULL ) {
+ "Constructs a `wx.SizerItem` for tracking a window.", "");
+
+ %RenameCtor(SizerItemWindow, wxSizerItem( wxWindow *window, int proportion, 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 wxSizerItem(window, proportion, flag, border, data);
}
-
+
DocStr(
wxSizerItem( int width, int height, int proportion, int flag,
int border, PyObject* userData=NULL),
"Constructs a `wx.SizerItem` for tracking a spacer.", "");
- %name(SizerItemSpacer) wxSizerItem( int width, int height, int proportion, int flag,
- int border, PyObject* userData=NULL) {
+
+ %RenameCtor(SizerItemSpacer, wxSizerItem( int width, int height, int proportion, 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 wxSizerItem(width, height, proportion, flag, border, data);
}
-
+
DocStr(
wxSizerItem( wxSizer *sizer, int proportion, int flag,
int border, PyObject* userData=NULL ),
- "Constructs a `wx.SizerItem` for tracking a subsizer", "");
- %name(SizerItemSizer) wxSizerItem( wxSizer *sizer, int proportion, int flag,
- int border, PyObject* userData=NULL ) {
+ "Constructs a `wx.SizerItem` for tracking a subsizer", "");
+
+ %disownarg( wxSizer *sizer );
+ %RenameCtor(SizerItemSizer, wxSizerItem( wxSizer *sizer, int proportion, 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 wxSizerItem(sizer, proportion, flag, border, data);
}
+ %cleardisown( wxSizer *sizer );
}
-
+
DocDeclStr(
void , DeleteWindows(),
"Destroy the window or the windows in a subsizer, depending on the type
of item.", "");
-
+
DocDeclStr(
void , DetachSizer(),
"Enable deleting the SizerItem without destroying the contained sizer.", "");
-
+
DocDeclStr(
wxSize , GetSize(),
"Get the current size of the item, as set in the last Layout.", "");
-
+
DocDeclStr(
wxSize , CalcMin(),
"Calculates the minimum desired size for the item, including any space
needed by borders.", "");
-
+
DocDeclStr(
- void , SetDimension( wxPoint pos, wxSize size ),
+ void , SetDimension( const wxPoint& pos, const wxSize& size ),
"Set the position and size of the space allocated for this item by the
sizer, and adjust the position and size of the item (window or
subsizer) to be within that space taking alignment and borders into
account.", "");
-
+
DocDeclStr(
wxSize , GetMinSize(),
"Get the minimum size needed for the item.", "");
-
+
+ DocDeclStr(
+ wxSize , GetMinSizeWithBorder() const,
+ "Get the minimum size needed for the item with space for the borders
+added, if needed.", "");
+
DocDeclStr(
void , SetInitSize( int x, int y ),
"", "");
-
+
DocStr(SetRatio,
"Set the ratio item attribute.", "");
- %name(SetRatioWH) void SetRatio( int width, int height );
- %name(SetRatioSize) void SetRatio( wxSize size );
+ %Rename(SetRatioWH, void, SetRatio( int width, int height ));
+ %Rename(SetRatioSize, void, SetRatio( const wxSize& size ));
void SetRatio( float ratio );
-
+
DocDeclStr(
float , GetRatio(),
"Set the ratio item attribute.", "");
-
+
+ DocDeclStr(
+ wxRect , GetRect(),
+ "Returns the rectangle that the sizer item should occupy", "");
+
DocDeclStr(
bool , IsWindow(),
"Is this sizer item a window?", "");
-
+
DocDeclStr(
bool , IsSizer(),
"Is this sizer item a subsizer?", "");
-
+
DocDeclStr(
bool , IsSpacer(),
"Is this sizer item a spacer?", "");
-
+
DocDeclStr(
void , SetProportion( int proportion ),
"Set the proportion value for this item.", "");
-
+
DocDeclStr(
int , GetProportion(),
"Get the proportion value for this item.", "");
-
+
%pythoncode { SetOption = wx._deprecated(SetProportion, "Please use `SetProportion` instead.") }
%pythoncode { GetOption = wx._deprecated(GetProportion, "Please use `GetProportion` instead.") }
-
+
DocDeclStr(
void , SetFlag( int flag ),
"Set the flag value for this item.", "");
-
+
DocDeclStr(
int , GetFlag(),
"Get the flag value for this item.", "");
-
-
+
+
DocDeclStr(
void , SetBorder( int border ),
"Set the border value for this item.", "");
-
+
DocDeclStr(
int , GetBorder(),
"Get the border value for this item.", "");
-
-
+
+
DocDeclStr(
wxWindow *, GetWindow(),
"Get the window (if any) that is managed by this sizer item.", "");
-
+
DocDeclStr(
void , SetWindow( wxWindow *window ),
"Set the window to be managed by this sizer item.", "");
-
-
+
+
DocDeclStr(
wxSizer *, GetSizer(),
"Get the subsizer (if any) that is managed by this sizer item.", "");
-
+
+ %disownarg( wxSizer *sizer );
DocDeclStr(
void , SetSizer( wxSizer *sizer ),
"Set the subsizer to be managed by this sizer item.", "");
-
-
+ %cleardisown( wxSizer *sizer );
+
+
DocDeclStr(
- const wxSize& , GetSpacer(),
+ wxSize , GetSpacer(),
"Get the size of the spacer managed by this sizer item.", "");
-
+
DocDeclStr(
void , SetSpacer( const wxSize &size ),
"Set the size of the spacer to be managed by this sizer item.", "");
-
+
DocDeclStr(
void , Show( bool show ),
"Set the show item attribute, which sizers use to determine if the item
is to be made part of the layout or not. If the item is tracking a
window then it is shown or hidden as needed.", "");
-
+
DocDeclStr(
bool , IsShown(),
"Is the item to be shown in the layout?", "");
-
+
DocDeclStr(
wxPoint , GetPosition(),
"Returns the current position of the item, as set in the last Layout.", "");
-
+
// wxObject* GetUserData();
%extend {
return Py_None;
}
}
+
+ DocStr(SetUserData,
+ "Associate a Python object with this sizer item.", "");
+ void SetUserData(PyObject* userData) {
+ wxPyUserData* data = NULL;
+ if ( userData ) {
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
+ data = new wxPyUserData(userData);
+ wxPyEndBlockThreads(blocked);
+ }
+ self->SetUserData(data);
+ }
}
+
+ %property(Border, GetBorder, SetBorder, doc="See `GetBorder` and `SetBorder`");
+ %property(Flag, GetFlag, SetFlag, doc="See `GetFlag` and `SetFlag`");
+ %property(MinSize, GetMinSize, doc="See `GetMinSize`");
+ %property(MinSizeWithBorder, GetMinSizeWithBorder, doc="See `GetMinSizeWithBorder`");
+ %property(Position, GetPosition, doc="See `GetPosition`");
+ %property(Proportion, GetProportion, SetProportion, doc="See `GetProportion` and `SetProportion`");
+ %property(Ratio, GetRatio, SetRatio, doc="See `GetRatio` and `SetRatio`");
+ %property(Rect, GetRect, doc="See `GetRect`");
+ %property(Size, GetSize, doc="See `GetSize`");
+ %property(Sizer, GetSizer, SetSizer, doc="See `GetSizer` and `SetSizer`");
+ %property(Spacer, GetSpacer, SetSpacer, doc="See `GetSpacer` and `SetSpacer`");
+ %property(UserData, GetUserData, SetUserData, doc="See `GetUserData` and `SetUserData`");
+ %property(Window, GetWindow, SetWindow, doc="See `GetWindow` and `SetWindow`");
};
struct wxPySizerItemInfo {
wxPySizerItemInfo()
- : window(NULL), sizer(NULL), gotSize(False),
- size(wxDefaultSize), gotPos(False), pos(-1)
+ : window(NULL), sizer(NULL), gotSize(false),
+ size(wxDefaultSize), gotPos(false), pos(-1)
{}
-
+
wxWindow* window;
wxSizer* sizer;
bool gotSize;
bool gotPos;
int pos;
};
-
+
static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, bool checkIdx ) {
wxPySizerItemInfo info;
if ( ! wxPyConvertSwigPtr(item, (void**)&info.window, wxT("wxWindow")) ) {
PyErr_Clear();
info.window = NULL;
-
+
// try wxSizer
if ( ! wxPyConvertSwigPtr(item, (void**)&info.sizer, wxT("wxSizer")) ) {
PyErr_Clear();
info.sizer = NULL;
-
+
// try wxSize or (w,h)
if ( checkSize && wxSize_helper(item, &sizePtr)) {
info.size = *sizePtr;
- info.gotSize = True;
+ info.gotSize = true;
}
// or a single int
if (checkIdx && PyInt_Check(item)) {
info.pos = PyInt_AsLong(item);
- info.gotPos = True;
+ info.gotPos = true;
}
}
}
if ( !(info.window || info.sizer || (checkSize && info.gotSize) || (checkIdx && info.gotPos)) ) {
// no expected type, figure out what kind of error message to generate
if ( !checkSize && !checkIdx )
- PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected for item");
+ PyErr_SetString(PyExc_TypeError, "wx.Window or wx.Sizer expected for item");
else if ( checkSize && !checkIdx )
- PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) expected for item");
+ PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item");
else if ( !checkSize && checkIdx)
- PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer or int (position) expected for item");
+ PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer or int (position) expected for item");
else
// can this one happen?
- PyErr_SetString(PyExc_TypeError, "wxWindow, wxSizer, wxSize, or (w,h) or int (position) expected for item");
+ PyErr_SetString(PyExc_TypeError, "wx.Window, wx.Sizer, wx.Size, or (w,h) or int (position) expected for item");
}
return info;
"wx.Sizer is the abstract base class used for laying out subwindows in
a window. You cannot use wx.Sizer directly; instead, you will have to
use one of the sizer classes derived from it such as `wx.BoxSizer`,
-`wx.StaticBoxSizer`, `wx.NotebookSizer`, `wx.GridSizer`, `wx.FlexGridSizer`
-and `wx.GridBagSizer`.
+`wx.StaticBoxSizer`, `wx.GridSizer`, `wx.FlexGridSizer` and
+`wx.GridBagSizer`.
The concept implemented by sizers in wxWidgets is closely related to
layout tools in other GUI toolkits, such as Java's AWT, the GTK
more space than on Windows, then the initial size of a dialog using a
sizer will automatically be bigger on Mac than on Windows.", "
+Sizers may also be used to control the layout of custom drawn items on
+the window. The `Add`, `Insert`, and `Prepend` functions return a
+pointer to the newly added `wx.SizerItem`. Just add empty space of the
+desired size and attributes, and then use the `wx.SizerItem.GetRect`
+method to determine where the drawing operations should take place.
+
:note: If you wish to create a custom sizer class in wxPython you
should derive the class from `wx.PySizer` in order to get
Python-aware capabilities for the various virtual methods.
class wxSizer : public wxObject {
public:
// wxSizer(); **** abstract, can't instantiate
- // ~wxSizer();
+
+ ~wxSizer();
%extend {
void _setOORInfo(PyObject* _self) {
- self->SetClientObject(new wxPyOORClientData(_self));
+ if (!self->GetClientObject())
+ self->SetClientObject(new wxPyOORClientData(_self));
}
DocAStr(Add,
"Add(self, item, int proportion=0, int flag=0, int border=0,
- PyObject userData=None)",
+ PyObject userData=None) -> wx.SizerItem",
"Appends a child item to the sizer.", "
|- wx.ALL | |
| | |
+----------------------------+------------------------------------------+
- |- wx.EXAPAND |The item will be expanded to fill |
+ |- wx.EXPAND |The item will be expanded to fill |
| |the space allotted to the item. |
+----------------------------+------------------------------------------+
|- wx.SHAPED |The item will be expanded as much as |
is more complex than the *proportion* and *flag* will allow for.
");
- void Add(PyObject* item, int proportion=0, int flag=0, int border=0,
- PyObject* userData=NULL) {
-
+ wxSizerItem* Add(PyObject* item, int proportion=0, int flag=0, int border=0,
+ PyObject* userData=NULL) {
+
wxPyUserData* data = NULL;
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False);
+ 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
if ( info.window )
- self->Add(info.window, proportion, flag, border, data);
+ return self->Add(info.window, proportion, flag, border, data);
else if ( info.sizer )
- self->Add(info.sizer, proportion, flag, border, data);
+ return self->Add(info.sizer, proportion, flag, border, data);
else if (info.gotSize)
- self->Add(info.size.GetWidth(), info.size.GetHeight(),
- proportion, flag, border, data);
+ return self->Add(info.size.GetWidth(), info.size.GetHeight(),
+ proportion, flag, border, data);
+ else
+ return NULL;
}
+// virtual wxSizerItem* AddSpacer(int size);
+// virtual wxSizerItem* AddStretchSpacer(int prop = 1);
DocAStr(Insert,
"Insert(self, int before, item, int proportion=0, int flag=0, int border=0,
- PyObject userData=None)",
+ PyObject userData=None) -> wx.SizerItem",
"Inserts a new item into the list of items managed by this sizer before
the item at index *before*. See `Add` for a description of the parameters.", "");
- void Insert(int before, PyObject* item, int proportion=0, int flag=0,
- int border=0, PyObject* userData=NULL) {
+ wxSizerItem* Insert(int before, PyObject* item, int proportion=0, int flag=0,
+ int border=0, PyObject* userData=NULL) {
wxPyUserData* data = NULL;
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False);
+ 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 Insert method if a valid item type was found
if ( info.window )
- self->Insert(before, info.window, proportion, flag, border, data);
+ return self->Insert(before, info.window, proportion, flag, border, data);
else if ( info.sizer )
- self->Insert(before, info.sizer, proportion, flag, border, data);
+ return self->Insert(before, info.sizer, proportion, flag, border, data);
else if (info.gotSize)
- self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
- proportion, flag, border, data);
+ return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(),
+ proportion, flag, border, data);
+ else
+ return NULL;
}
-
+// virtual wxSizerItem* InsertSpacer(size_t index, int size);
+// virtual wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
+
DocAStr(Prepend,
"Prepend(self, item, int proportion=0, int flag=0, int border=0,
- PyObject userData=None)",
+ PyObject userData=None) -> wx.SizerItem",
"Adds a new item to the begining of the list of sizer items managed by
this sizer. See `Add` for a description of the parameters.", "");
- void Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
- PyObject* userData=NULL) {
+ wxSizerItem* Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
+ PyObject* userData=NULL) {
wxPyUserData* data = NULL;
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False);
+ 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 Prepend method if a valid item type was found
if ( info.window )
- self->Prepend(info.window, proportion, flag, border, data);
+ return self->Prepend(info.window, proportion, flag, border, data);
else if ( info.sizer )
- self->Prepend(info.sizer, proportion, flag, border, data);
+ return self->Prepend(info.sizer, proportion, flag, border, data);
else if (info.gotSize)
- self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
- proportion, flag, border, data);
+ return self->Prepend(info.size.GetWidth(), info.size.GetHeight(),
+ proportion, flag, border, data);
+ else
+ return NULL;
}
+// 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
instead.
");
bool Remove(PyObject* item) {
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
+ wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
wxPyEndBlockThreads(blocked);
if ( info.window )
return self->Remove(info.window);
return self->Remove(info.sizer);
else if ( info.gotPos )
return self->Remove(info.pos);
- else
- return False;
+ else
+ return false;
}
zero-based index of the item to be detached. Returns True if the child item
was found and detached.", "");
bool Detach(PyObject* item) {
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
+ wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
wxPyEndBlockThreads(blocked);
if ( info.window )
return self->Detach(info.window);
return self->Detach(info.sizer);
else if ( info.gotPos )
return self->Detach(info.pos);
- else
- return False;
+ else
+ return false;
}
-
+
+ DocAStr(GetItem,
+ "GetItem(self, item) -> wx.SizerItem",
+ "Returns the `wx.SizerItem` which holds the *item* given. The *item*
+parameter can be either a window, a sizer, or the zero-based index of
+the item to be found.", "");
+ wxSizerItem* GetItem(PyObject* item) {
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
+ wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
+ wxPyEndBlockThreads(blocked);
+ if ( info.window )
+ return self->GetItem(info.window);
+ else if ( info.sizer )
+ return self->GetItem(info.sizer);
+ else if ( info.gotPos )
+ return self->GetItem(info.pos);
+ else
+ return NULL;
+ }
+
+
void _SetItemMinSize(PyObject* item, const wxSize& size) {
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
+ wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
wxPyEndBlockThreads(blocked);
if ( info.window )
self->SetItemMinSize(info.window, size);
}
}
+
+ %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):
"""
else:
return self._SetItemMinSize(item, args[0])
}
-
+
+
+ %disownarg( wxSizerItem *item );
+
DocDeclAStrName(
- void , Add( wxSizerItem *item ),
+ wxSizerItem* , Add( wxSizerItem *item ),
"AddItem(self, SizerItem item)",
"Adds a `wx.SizerItem` to the sizer.", "",
AddItem);
-
+
DocDeclAStrName(
- void , Insert( size_t index, wxSizerItem *item ),
+ wxSizerItem* , Insert( size_t index, wxSizerItem *item ),
"InsertItem(self, int index, SizerItem item)",
"Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "",
InsertItem);
-
+
DocDeclAStrName(
- void , Prepend( wxSizerItem *item ),
+ wxSizerItem* , Prepend( wxSizerItem *item ),
"PrependItem(self, SizerItem item)",
"Prepends a `wx.SizerItem` to the sizer.", "",
PrependItem);
-
+
+ %cleardisown( wxSizerItem *item );
%pythoncode {
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
- AddWindow = wx._deprecated(Add, "AddWindow is deprecated, use `Add` instead.")
- AddSizer = wx._deprecated(Add, "AddSizer is deprecated, use `Add` instead.")
- AddSpacer = wx._deprecated(Add, "AddSpacer is deprecated, use `Add` instead.")
- PrependWindow = wx._deprecated(Prepend, "PrependWindow is deprecated, use `Prepend` instead.")
- PrependSizer = wx._deprecated(Prepend, "PrependSizer is deprecated, use `Prepend` instead.")
- PrependSpacer = wx._deprecated(Prepend, "PrependSpacer is deprecated, use `Prepend` instead.")
- InsertWindow = wx._deprecated(Insert, "InsertWindow is deprecated, use `Insert` instead.")
- InsertSizer = wx._deprecated(Insert, "InsertSizer is deprecated, use `Insert` instead.")
- InsertSpacer = wx._deprecated(Insert, "InsertSpacer is deprecated, use `Insert` instead.")
- RemoveWindow = wx._deprecated(Remove, "RemoveWindow is deprecated, use `Remove` instead.")
- RemoveSizer = wx._deprecated(Remove, "RemoveSizer is deprecated, use `Remove` instead.")
- RemovePos = wx._deprecated(Remove, "RemovePos is deprecated, use `Remove` instead.")
+ def AddWindow(self, *args, **kw):
+ """Compatibility alias for `Add`."""
+ return self.Add(*args, **kw)
+ def AddSizer(self, *args, **kw):
+ """Compatibility alias for `Add`."""
+ return self.Add(*args, **kw)
+
+ def PrependWindow(self, *args, **kw):
+ """Compatibility alias for `Prepend`."""
+ return self.Prepend(*args, **kw)
+ def PrependSizer(self, *args, **kw):
+ """Compatibility alias for `Prepend`."""
+ return self.Prepend(*args, **kw)
+
+ def InsertWindow(self, *args, **kw):
+ """Compatibility alias for `Insert`."""
+ return self.Insert(*args, **kw)
+ def InsertSizer(self, *args, **kw):
+ """Compatibility alias for `Insert`."""
+ return self.Insert(*args, **kw)
+
+ def RemoveWindow(self, *args, **kw):
+ """Compatibility alias for `Remove`."""
+ return self.Remove(*args, **kw)
+ def RemoveSizer(self, *args, **kw):
+ """Compatibility alias for `Remove`."""
+ return self.Remove(*args, **kw)
+ def RemovePos(self, *args, **kw):
+ """Compatibility alias for `Remove`."""
+ return self.Remove(*args, **kw)
}
force the items owned by the sizer to resize themselves according to
the rules defined by the parameter in the `Add`, `Insert` or `Prepend`
methods.", "");
-
+
DocDeclStr(
void , SetMinSize( const wxSize &size ),
"Call this to give the sizer a minimal size. Normally, the sizer will
need. After calling this method `GetMinSize` will return either the
minimal size as requested by its children or the minimal size set
here, depending on which is bigger.", "");
-
+
DocDeclStr(
wxSize , GetSize(),
"Returns the current size of the space managed by the sizer.", "");
-
+
DocDeclStr(
wxPoint , GetPosition(),
"Returns the current position of the sizer's managed space.", "");
-
+
DocDeclStr(
wxSize , GetMinSize(),
"Returns the minimal size of the sizer. This is either the combined
minimal size of all the children and their borders or the minimal size
set by SetMinSize, depending on which is bigger.", "");
-
+
%pythoncode {
def GetSizeTuple(self):
"Using the sizes calculated by `CalcMin` reposition and resize all the
items managed by this sizer. You should not need to call this directly as
it is called by `Layout`.", "");
-
+
DocDeclStr(
virtual wxSize , CalcMin(),
"This method is where the sizer will do the actual calculation of its
children's minimal sizes. You should not need to call this directly as
it is called by `Layout`.", "");
-
+
DocDeclStr(
void , Layout(),
EVT_SIZE handler, but it is also useful to call it from user code when
one of the items in a sizer change size, or items are added or
removed.", "");
-
+
DocDeclStr(
wxSize , Fit( wxWindow *window ),
determined by the sizer. Returns the new size.
For a top level window this is the total window size, not the client size.", "");
-
+
DocDeclStr(
void , FitInside( wxWindow *window ),
"Tell the sizer to resize the *virtual size* of the *window* to match the
:see: `wx.ScrolledWindow.SetScrollbars`, `SetVirtualSizeHints`
", "");
-
+
DocDeclStr(
void , SetSizeHints( wxWindow *window ),
many dialogs under Unix and frames on probably all platforms) in order
to prevent the window from being sized smaller than the minimal size
required by the sizer.", "");
-
+
DocDeclStr(
void , SetVirtualSizeHints( wxWindow *window ),
"Tell the sizer to set the minimal size of the window virtual area to
:see: `wx.ScrolledWindow.SetScrollbars`
", "");
-
+
DocDeclStr(
- void , Clear( bool deleteWindows=False ),
+ void , Clear( bool deleteWindows=false ),
"Clear all items from the sizer, optionally destroying the window items
as well.", "");
-
+
DocDeclStr(
void , DeleteWindows(),
"Destroy all windows managed by the sizer.", "");
-
+
// wxList& GetChildren();
%extend {
DocAStr(GetChildren,
- "GetChildren(sefl) -> list",
+ "GetChildren(self) -> list",
"Returns a list of all the `wx.SizerItem` objects managed by the sizer.", "");
PyObject* GetChildren() {
wxSizerItemList& list = self->GetChildren();
%extend {
DocAStr(Show,
- "Show(self, item, bool show=True)",
+ "Show(self, item, bool show=True, bool recursive=false) -> bool",
"Shows or hides an item managed by the sizer. To make a sizer item
disappear or reappear, use Show followed by `Layout`. The *item*
parameter can be either a window, a sizer, or the zero-based index of
-the item.", "");
- void Show(PyObject* item, bool show = True) {
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True);
+the item. Use the recursive parameter to show or hide an item in a
+subsizer. Returns True if the item was found.", "");
+ bool Show(PyObject* item, bool show = true, bool recursive=false) {
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
+ wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true);
wxPyEndBlockThreads(blocked);
if ( info.window )
- self->Show(info.window, show);
+ return self->Show(info.window, show, recursive);
else if ( info.sizer )
- self->Show(info.sizer, show);
+ return self->Show(info.sizer, show, recursive);
else if ( info.gotPos )
- self->Show(info.pos, show);
+ return self->Show(info.pos, show);
+ else
+ return false;
}
-
+
DocAStr(IsShown,
"IsShown(self, item)",
- "Determines if the item is currently shown. sizer. To make a sizer
+ "Determines if the item is currently shown. To make a sizer
item disappear or reappear, use Show followed by `Layout`. The *item*
parameter can be either a window, a sizer, or the zero-based index of
the item.", "");
bool IsShown(PyObject* item) {
- bool blocked = wxPyBeginBlockThreads();
- wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, False);
+ wxPyBlock_t blocked = wxPyBeginBlockThreads();
+ wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false);
wxPyEndBlockThreads(blocked);
- if ( info.window )
+ if ( info.window )
return self->IsShown(info.window);
- else if ( info.sizer )
+ else if ( info.sizer )
return self->IsShown(info.sizer);
else if ( info.gotPos )
return self->IsShown(info.pos);
else
- return False;
+ return false;
}
}
%pythoncode {
- def Hide(self, item):
+ def Hide(self, item, recursive=False):
"""
- A convenience method for Show(item, False).
+ A convenience method for `Show` (item, False, recursive).
"""
- self.Show(item, False)
+ return self.Show(item, False, recursive)
}
-
+
DocDeclStr(
void , ShowItems(bool show),
- "Recursively call `wx.Window.Show` on all sizer items.", "");
-
+ "Recursively call `wx.SizerItem.Show` on all sizer items.", "");
+
+ %property(Children, GetChildren, doc="See `GetChildren`");
+ %property(ContainingWindow, GetContainingWindow, SetContainingWindow, doc="See `GetContainingWindow` and `SetContainingWindow`");
+ %property(MinSize, GetMinSize, SetMinSize, doc="See `GetMinSize` and `SetMinSize`");
+ %property(Position, GetPosition, doc="See `GetPosition`");
+ %property(Size, GetSize, doc="See `GetSize`");
};
//---------------------------------------------------------------------------
// Use this one for deriving Python classes from
%{
-// See pyclasses.h
+// See pyclasses.h
IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
When `Layout` is called it first calls `CalcMin` followed by
`RecalcSizes` so you can optimize a bit by saving the results of
-`CalcMin` and resuing them in `RecalcSizes`.
+`CalcMin` and reusing them in `RecalcSizes`.
:see: `wx.SizerItem`, `wx.Sizer.GetChildren`
wxPySizer(),
"Creates a wx.PySizer. Must be called from the __init__ in the derived
class.", "");
-
+
void _setCallbackInfo(PyObject* self, PyObject* _class);
};
or ``wx.HORIZONTAL`` for creating either a column sizer or a row
sizer.", "");
-
+
DocDeclStr(
int , GetOrientation(),
"Returns the current orientation of the sizer.", "");
-
+
DocDeclStr(
void , SetOrientation(int orient),
"Resets the orientation of the sizer.", "");
-
+
+ %property(Orientation, GetOrientation, SetOrientation, doc="See `GetOrientation` and `SetOrientation`");
};
//---------------------------------------------------------------------------
"Constructor. It takes an associated static box and the orientation
*orient* as parameters - orient can be either of ``wx.VERTICAL`` or
``wx.HORIZONTAL``.", "");
-
- DocDeclStr(
- wxStaticBox *, GetStaticBox(),
- "Returns the static box associated with this sizer.", "");
-
+
+ // TODO: wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
+
+ DocDeclStr(
+ wxStaticBox *, GetStaticBox(),
+ "Returns the static box associated with this sizer.", "");
+
+ %property(StaticBox, GetStaticBox, doc="See `GetStaticBox`");
};
//---------------------------------------------------------------------------
DocDeclStr(
void , SetCols( int cols ),
"Sets the number of columns in the sizer.", "");
-
+
DocDeclStr(
void , SetRows( int rows ),
"Sets the number of rows in the sizer.", "");
-
+
DocDeclStr(
void , SetVGap( int gap ),
"Sets the vertical gap (in pixels) between the cells in the sizer.", "");
-
+
DocDeclStr(
void , SetHGap( int gap ),
"Sets the horizontal gap (in pixels) between cells in the sizer", "");
-
+
DocDeclStr(
int , GetCols(),
"Returns the number of columns in the sizer.", "");
-
+
DocDeclStr(
int , GetRows(),
"Returns the number of rows in the sizer.", "");
-
+
DocDeclStr(
int , GetVGap(),
"Returns the vertical gap (in pixels) between the cells in the sizer.", "");
-
+
DocDeclStr(
int , GetHGap(),
"Returns the horizontal gap (in pixels) between cells in the sizer.", "");
+
+ %pythoncode {
+ def CalcRowsCols(self):
+ """
+ CalcRowsCols() -> (rows, cols)
+
+ Calculates how many rows and columns will be in the sizer based
+ on the current number of items and also the rows, cols specified
+ in the constructor.
+ """
+ nitems = len(self.GetChildren())
+ rows = self.GetRows()
+ cols = self.GetCols()
+ assert rows != 0 or cols != 0, "Grid sizer must have either rows or columns fixed"
+ if cols != 0:
+ rows = (nitems + cols - 1) / cols
+ elif rows != 0:
+ 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`");
};
//---------------------------------------------------------------------------
is zero, it will be calculated to from the total number of children in
the sizer, thus making the sizer grow dynamically. *vgap* and *hgap*
define extra space between all children.", "");
-
+
DocDeclStr(
void , AddGrowableRow( size_t idx, int proportion = 0 ),
The *proportion* parameter has the same meaning as the stretch factor
for the box sizers except that if all proportions are 0, then all
columns are resized equally (instead of not being resized at all).", "");
-
+
DocDeclStr(
void , RemoveGrowableRow( size_t idx ),
"Specifies that row *idx* is no longer growable.", "");
-
+
DocDeclStr(
void , AddGrowableCol( size_t idx, int proportion = 0 ),
"Specifies that column *idx* (starting from zero) should be grown if
The *proportion* parameter has the same meaning as the stretch factor
for the box sizers except that if all proportions are 0, then all
columns are resized equally (instead of not being resized at all).", "");
-
+
DocDeclStr(
void , RemoveGrowableCol( size_t idx ),
"Specifies that column *idx* is no longer growable.", "");
-
+
DocDeclStr(
void , SetFlexibleDirection(int direction),
Note that this method does not trigger relayout.
", "");
-
+
DocDeclStr(
int , GetFlexibleDirection(),
"Returns a value that specifies whether the sizer
:see: `SetFlexibleDirection`", "");
-
+
DocDeclStr(
void , SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode),
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(),
"Returns the value that specifies how the sizer grows in the
non-flexible direction if there is one.
:see: `SetNonFlexibleGrowMode`", "");
-
+
// Read-only access to the row heights and col widths arrays
DocDeclAStr(
"GetRowHeights(self) -> list",
"Returns a list of integers representing the heights of each of the
rows in the sizer.", "");
-
+
DocDeclAStr(
const wxArrayInt& , GetColWidths() const,
"GetColWidths(self) -> list",
"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`");
};
+//---------------------------------------------------------------------------
+
+DocStr(wxStdDialogButtonSizer,
+"A special sizer that knows how to order and position standard buttons
+in order to conform to the current platform's standards. You simply
+need to add each `wx.Button` to the sizer, and be sure to create the
+buttons using the standard ID's. Then call `Realize` and the sizer
+will take care of the rest.
+", "");
+
+class wxStdDialogButtonSizer: public wxBoxSizer
+{
+public:
+ DocCtorStr(
+ wxStdDialogButtonSizer(),
+ "", "");
+
+ DocDeclStr(
+ void , AddButton(wxButton *button),
+ "Use this to add the buttons to this sizer. Do not use the `Add`
+method in the base class.", "");
+
+ DocDeclStr(
+ void , Realize(),
+ "This funciton needs to be called after all the buttons have been added
+to the sizer. It will reorder them and position them in a platform
+specifc manner.", "");
+
+ void SetAffirmativeButton( wxButton *button );
+ void SetNegativeButton( wxButton *button );
+ void SetCancelButton( wxButton *button );
+
+ wxButton* GetAffirmativeButton() const;
+ wxButton* GetApplyButton() const;
+ wxButton* GetNegativeButton() const;
+ wxButton* GetCancelButton() const;
+ wxButton* GetHelpButton() const;
+
+ %property(AffirmativeButton, GetAffirmativeButton, SetAffirmativeButton, doc="See `GetAffirmativeButton` and `SetAffirmativeButton`");
+ %property(ApplyButton, GetApplyButton, doc="See `GetApplyButton`");
+ %property(CancelButton, GetCancelButton, SetCancelButton, doc="See `GetCancelButton` and `SetCancelButton`");
+ %property(HelpButton, GetHelpButton, doc="See `GetHelpButton`");
+ %property(NegativeButton, GetNegativeButton, SetNegativeButton, doc="See `GetNegativeButton` and `SetNegativeButton`");
+};
+
+
//---------------------------------------------------------------------------