Simplified how the wxSizer methods are wrapped, changed the name of
the "option" parameter to "proportion" ("option" is still accepted for compatibility, but this will go away in a future release,) SetItemMinSize can now take a wxSize (or 2-tuple) parameter, and Spacers can be specified with a wxSize (or 2-tuple) parameter git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20983 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -63,6 +63,12 @@ Added wxPy versions of wxPrintPreview, wxPreviewFrame, and
|
|||||||
wxPreviewControlBar so they can be derived from in Python and be able
|
wxPreviewControlBar so they can be derived from in Python and be able
|
||||||
to override the C++ virtual methods.
|
to override the C++ virtual methods.
|
||||||
|
|
||||||
|
Simplified how the wxSizer methods are wrapped, changed the name of
|
||||||
|
the "option" parameter to "proportion" ("option" is still accepted for
|
||||||
|
compatibility, but this will go away in a future release,)
|
||||||
|
SetItemMinSize can now take a wxSize (or 2-tuple) parameter, and
|
||||||
|
Spacers can be specified with a wxSize (or 2-tuple) parameter
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -105,139 +105,193 @@ public:
|
|||||||
%addmethods {
|
%addmethods {
|
||||||
void Destroy() { delete self; }
|
void Destroy() { delete self; }
|
||||||
|
|
||||||
void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0,
|
|
||||||
PyObject* userData=NULL) {
|
void _Add(PyObject* item, int proportion=0, int flag=0, int border=0,
|
||||||
|
PyObject* userData=NULL, int option=-1) {
|
||||||
|
// The option parameter is only for backwards compatibility
|
||||||
|
// with keyword args, all new code should use "proportion"
|
||||||
|
// instead. This can be removed eventually.
|
||||||
|
if (option != -1) proportion = option;
|
||||||
|
|
||||||
|
wxWindow* window;
|
||||||
|
wxSizer* sizer;
|
||||||
|
wxSize size;
|
||||||
|
wxSize* sizePtr = &size;
|
||||||
wxPyUserData* data = NULL;
|
wxPyUserData* data = NULL;
|
||||||
if (userData) data = new wxPyUserData(userData);
|
if (userData) data = new wxPyUserData(userData);
|
||||||
self->Add(window, option, flag, border, data);
|
|
||||||
|
// Find out what type the item is and call the real Add method
|
||||||
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
|
self->Add(window, proportion, flag, border, data);
|
||||||
|
|
||||||
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
|
self->Add(sizer, proportion, flag, border, data);
|
||||||
|
|
||||||
|
else if (wxSize_helper(item, &sizePtr))
|
||||||
|
self->Add(sizePtr->GetWidth(), sizePtr->GetHeight(),
|
||||||
|
proportion, flag, border, data);
|
||||||
|
else {
|
||||||
|
if (data) delete data;
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"wxWindow, wxSizer, wxSize, or (w,h) expected for item");
|
||||||
}
|
}
|
||||||
void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
|
|
||||||
PyObject* userData=NULL) {
|
|
||||||
wxPyUserData* data = NULL;
|
|
||||||
if (userData) data = new wxPyUserData(userData);
|
|
||||||
self->Add(sizer, option, flag, border, data);
|
|
||||||
}
|
|
||||||
void AddSpacer(int width, int height, int option=0, int flag=0,
|
|
||||||
int border=0, PyObject* userData=NULL) {
|
|
||||||
wxPyUserData* data = NULL;
|
|
||||||
if (userData) data = new wxPyUserData(userData);
|
|
||||||
self->Add(width, height, option, flag, border, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsertWindow(int before, wxWindow *window, int option=0, int flag=0,
|
void _Insert(int before, PyObject* item, int proportion=0, int flag=0,
|
||||||
int border=0, PyObject* userData=NULL) {
|
int border=0, PyObject* userData=NULL, int option=-1) {
|
||||||
|
// The option parameter is only for backwards compatibility
|
||||||
|
// with keyword args, all new code should use "proportion"
|
||||||
|
// instead. This can be removed eventually.
|
||||||
|
if (option != -1) proportion = option;
|
||||||
|
|
||||||
|
wxWindow* window;
|
||||||
|
wxSizer* sizer;
|
||||||
|
wxSize size;
|
||||||
|
wxSize* sizePtr = &size;
|
||||||
wxPyUserData* data = NULL;
|
wxPyUserData* data = NULL;
|
||||||
if (userData) data = new wxPyUserData(userData);
|
if (userData) data = new wxPyUserData(userData);
|
||||||
self->Insert(before, window, option, flag, border, data);
|
|
||||||
|
// Find out what type the item is and call the real Insert method
|
||||||
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
|
self->Insert(before, window, proportion, flag, border, data);
|
||||||
|
|
||||||
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
|
self->Insert(before, sizer, proportion, flag, border, data);
|
||||||
|
|
||||||
|
else if (wxSize_helper(item, &sizePtr))
|
||||||
|
self->Insert(before, sizePtr->GetWidth(), sizePtr->GetHeight(),
|
||||||
|
proportion, flag, border, data);
|
||||||
|
else {
|
||||||
|
if (data) delete data;
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"wxWindow, wxSizer, wxSize, or (w,h) expected for item");
|
||||||
}
|
}
|
||||||
void InsertSizer(int before, wxSizer *sizer, int option=0, int flag=0,
|
|
||||||
int border=0, PyObject* userData=NULL) {
|
|
||||||
wxPyUserData* data = NULL;
|
|
||||||
if (userData) data = new wxPyUserData(userData);
|
|
||||||
self->Insert(before, sizer, option, flag, border, data);
|
|
||||||
}
|
|
||||||
void InsertSpacer(int before, int width, int height, int option=0, int flag=0,
|
|
||||||
int border=0, PyObject* userData=NULL) {
|
|
||||||
wxPyUserData* data = NULL;
|
|
||||||
if (userData) data = new wxPyUserData(userData);
|
|
||||||
self->Insert(before, width, height, option, flag, border, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0,
|
|
||||||
PyObject* userData=NULL) {
|
void _Prepend(PyObject* item, int proportion=0, int flag=0, int border=0,
|
||||||
|
PyObject* userData=NULL, int option=-1) {
|
||||||
|
// The option parameter is only for backwards compatibility
|
||||||
|
// with keyword args, all new code should use "proportion"
|
||||||
|
// instead. This can be removed eventually.
|
||||||
|
if (option != -1) proportion = option;
|
||||||
|
|
||||||
|
wxWindow* window;
|
||||||
|
wxSizer* sizer;
|
||||||
|
wxSize size;
|
||||||
|
wxSize* sizePtr = &size;
|
||||||
wxPyUserData* data = NULL;
|
wxPyUserData* data = NULL;
|
||||||
if (userData) data = new wxPyUserData(userData);
|
if (userData) data = new wxPyUserData(userData);
|
||||||
self->Prepend(window, option, flag, border, data);
|
|
||||||
}
|
// Find out what type the item is and call the real Prepend method
|
||||||
void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
PyObject* userData=NULL) {
|
self->Prepend(window, proportion, flag, border, data);
|
||||||
wxPyUserData* data = NULL;
|
|
||||||
if (userData) data = new wxPyUserData(userData);
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
self->Prepend(sizer, option, flag, border, data);
|
self->Prepend(sizer, proportion, flag, border, data);
|
||||||
}
|
|
||||||
void PrependSpacer(int width, int height, int option=0, int flag=0,
|
else if (wxSize_helper(item, &sizePtr))
|
||||||
int border=0, PyObject* userData=NULL) {
|
self->Prepend(sizePtr->GetWidth(), sizePtr->GetHeight(),
|
||||||
wxPyUserData* data = NULL;
|
proportion, flag, border, data);
|
||||||
if (userData) data = new wxPyUserData(userData);
|
else {
|
||||||
self->Prepend(width, height, option, flag, border, data);
|
if (data) delete data;
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"wxWindow, wxSizer, wxSize, or (w,h) expected for item");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%name(RemoveWindow)bool Remove( wxWindow *window );
|
bool Remove(PyObject* item) {
|
||||||
%name(RemoveSizer)bool Remove( wxSizer *sizer );
|
wxWindow* window;
|
||||||
%name(RemovePos)bool Remove( int pos );
|
wxSizer* sizer;
|
||||||
|
|
||||||
|
// Find out what type the item is and call the real Remove method
|
||||||
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
|
return self->Remove(window);
|
||||||
|
|
||||||
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
|
return self->Remove(sizer);
|
||||||
|
|
||||||
|
else if (PyInt_Check(item)) {
|
||||||
|
int pos = PyInt_AsLong(item);
|
||||||
|
return self->Remove(pos);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"wxWindow, wxSizer or int (position) expected.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _SetItemMinSize(PyObject* item, wxSize size) {
|
||||||
|
wxWindow* window;
|
||||||
|
wxSizer* sizer;
|
||||||
|
|
||||||
|
// Find out what type the item is and call the real Remove method
|
||||||
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
|
self->SetItemMinSize(window, size);
|
||||||
|
|
||||||
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
|
self->SetItemMinSize(sizer, size);
|
||||||
|
|
||||||
|
else if (PyInt_Check(item)) {
|
||||||
|
int pos = PyInt_AsLong(item);
|
||||||
|
self->SetItemMinSize(pos, size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"wxWindow, wxSizer or int (position) expected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
def Add(self, *args, **kw):
|
def Add(self, item, *args, **kw):
|
||||||
if type(args[0]) == type(1):
|
if type(item) == type(1):
|
||||||
self.AddSpacer(*args, **kw)
|
item = (item, args[0]) # backwards compatibility, args are width, height
|
||||||
elif isinstance(args[0], wxSizerPtr):
|
args = args[1:]
|
||||||
self.AddSizer(*args, **kw)
|
self._Add(item, *args, **kw)
|
||||||
elif isinstance(args[0], wxWindowPtr):
|
|
||||||
self.AddWindow(*args, **kw)
|
|
||||||
else:
|
|
||||||
raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
|
|
||||||
|
|
||||||
def Insert(self, *args, **kw):
|
|
||||||
if type(args[1]) == type(1):
|
|
||||||
self.InsertSpacer(*args, **kw)
|
|
||||||
elif isinstance(args[1], wxSizerPtr):
|
|
||||||
self.InsertSizer(*args, **kw)
|
|
||||||
elif isinstance(args[1], wxWindowPtr):
|
|
||||||
self.InsertWindow(*args, **kw)
|
|
||||||
else:
|
|
||||||
raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
|
|
||||||
|
|
||||||
def Prepend(self, *args, **kw):
|
|
||||||
if type(args[0]) == type(1):
|
|
||||||
self.PrependSpacer(*args, **kw)
|
|
||||||
elif isinstance(args[0], wxSizerPtr):
|
|
||||||
self.PrependSizer(*args, **kw)
|
|
||||||
elif isinstance(args[0], wxWindowPtr):
|
|
||||||
self.PrependWindow(*args, **kw)
|
|
||||||
else:
|
|
||||||
raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
|
|
||||||
|
|
||||||
def Remove(self, *args, **kw):
|
|
||||||
if type(args[0]) == type(1):
|
|
||||||
return self.RemovePos(*args, **kw)
|
|
||||||
elif isinstance(args[0], wxSizerPtr):
|
|
||||||
return self.RemoveSizer(*args, **kw)
|
|
||||||
elif isinstance(args[0], wxWindowPtr):
|
|
||||||
return self.RemoveWindow(*args, **kw)
|
|
||||||
else:
|
|
||||||
raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
|
|
||||||
|
|
||||||
def AddMany(self, widgets):
|
def AddMany(self, widgets):
|
||||||
for childinfo in widgets:
|
for childinfo in widgets:
|
||||||
if type(childinfo) != type(()):
|
if type(childinfo) != type(()):
|
||||||
childinfo = (childinfo, )
|
childinfo = (childinfo, )
|
||||||
self.Add(*childinfo)
|
self.Add(*childinfo)
|
||||||
|
|
||||||
|
def Prepend(self, item, *args, **kw):
|
||||||
|
if type(item) == type(1):
|
||||||
|
item = (item, args[0]) # backwards compatibility, args are width, height
|
||||||
|
args = args[1:]
|
||||||
|
self._Prepend(item, *args, **kw)
|
||||||
|
|
||||||
|
def Insert(self, before, item, *args, **kw):
|
||||||
|
if type(item) == type(1):
|
||||||
|
item = (item, args[0]) # backwards compatibility, args are width, height
|
||||||
|
args = args[1:]
|
||||||
|
self._Insert(before, item, *args, **kw)
|
||||||
|
|
||||||
|
|
||||||
|
# for backwards compatibility only
|
||||||
|
AddWindow = AddSizer = AddSpacer = Add
|
||||||
|
PrependWindow = PrependSizer = PrependSpacer = Prepend
|
||||||
|
InsertWindow = InsertSizer = InsertSpacer = Insert
|
||||||
|
RemoveWindow = RemoveSizer = RemovePos = Remove
|
||||||
|
|
||||||
|
|
||||||
|
def SetItemMinSize(self, item, *args):
|
||||||
|
if len(args) == 2:
|
||||||
|
return self._SetItemMinSize(item, args)
|
||||||
|
else:
|
||||||
|
return self._SetItemMinSize(item, args[0])
|
||||||
|
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
||||||
void SetDimension( int x, int y, int width, int height );
|
void SetDimension( int x, int y, int width, int height );
|
||||||
void SetMinSize(wxSize size);
|
void SetMinSize(wxSize size);
|
||||||
|
|
||||||
%name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, int width, int height);
|
|
||||||
%name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, int width, int height);
|
|
||||||
%name(SetItemMinSizePos) void SetItemMinSize(int pos, int width, int height);
|
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
|
||||||
def SetItemMinSize(self, *args):
|
|
||||||
if type(args[0]) == type(1):
|
|
||||||
self.SetItemMinSizePos(*args)
|
|
||||||
elif isinstance(args[0], wxSizerPtr):
|
|
||||||
self.SetItemMinSizeSizer(*args)
|
|
||||||
elif isinstance(args[0], wxWindowPtr):
|
|
||||||
self.SetItemMinSizeWindow(*args)
|
|
||||||
else:
|
|
||||||
raise TypeError, 'Expected int, wxSizer or wxWindow parameter'
|
|
||||||
"
|
|
||||||
|
|
||||||
wxSize GetSize();
|
wxSize GetSize();
|
||||||
wxPoint GetPosition();
|
wxPoint GetPosition();
|
||||||
wxSize GetMinSize();
|
wxSize GetMinSize();
|
||||||
@@ -277,38 +331,47 @@ public:
|
|||||||
|
|
||||||
// Manage whether individual windows or sub-sizers are considered
|
// Manage whether individual windows or sub-sizers are considered
|
||||||
// in the layout calculations or not.
|
// in the layout calculations or not.
|
||||||
%name(ShowWindow)void Show( wxWindow *window, bool show = TRUE );
|
|
||||||
%name(HideWindow)void Hide( wxWindow *window );
|
|
||||||
%name(ShowSizer)void Show( wxSizer *sizer, bool show = TRUE );
|
|
||||||
%name(HideSizer)void Hide( wxSizer *sizer );
|
|
||||||
%name(IsShownWindow)bool IsShown( wxWindow *window );
|
|
||||||
%name(IsShownSizer)bool IsShown( wxSizer *sizer );
|
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
%addmethods {
|
||||||
def Show(self, *args):
|
void Show(PyObject* item, bool show = TRUE) {
|
||||||
if isinstance(args[0], wxSizerPtr):
|
wxWindow* window;
|
||||||
self.ShowSizer(*args)
|
wxSizer* sizer;
|
||||||
elif isinstance(args[0], wxWindowPtr):
|
// Find out what type the item is and call the real method
|
||||||
self.ShowWindow(*args)
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
else:
|
self->Show(window, show);
|
||||||
raise TypeError, 'Expected wxSizer or wxWindow parameter'
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
|
self->Show(sizer, show);
|
||||||
|
else
|
||||||
|
PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected.");
|
||||||
|
}
|
||||||
|
|
||||||
def Hide(self, *args):
|
void Hide(PyObject* item) {
|
||||||
if isinstance(args[0], wxSizerPtr):
|
wxWindow* window;
|
||||||
self.HideSizer(*args)
|
wxSizer* sizer;
|
||||||
elif isinstance(args[0], wxWindowPtr):
|
// Find out what type the item is and call the real method
|
||||||
self.HideWindow(*args)
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
else:
|
self->Hide(window);
|
||||||
raise TypeError, 'Expected wxSizer or wxWindow parameter'
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
|
self->Hide(sizer);
|
||||||
|
else
|
||||||
|
PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsShown(PyObject* item) {
|
||||||
|
wxWindow* window;
|
||||||
|
wxSizer* sizer;
|
||||||
|
// Find out what type the item is and call the real method
|
||||||
|
if (! SWIG_GetPtrObj(item, (void**)&window, "_wxWindow_p"))
|
||||||
|
return self->IsShown(window);
|
||||||
|
else if (!SWIG_GetPtrObj(item, (void**)&sizer, "_wxSizer_p"))
|
||||||
|
return self->IsShown(sizer);
|
||||||
|
else {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "wxWindow or wxSizer expected.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def IsShown(self, *args):
|
|
||||||
if isinstance(args[0], wxSizerPtr):
|
|
||||||
return self.IsShownSizer(*args)
|
|
||||||
elif isinstance(args[0], wxWindowPtr):
|
|
||||||
return self.IsShownWindow(*args)
|
|
||||||
else:
|
|
||||||
raise TypeError, 'Expected wxSizer or wxWindow parameter'
|
|
||||||
"
|
|
||||||
|
|
||||||
// Recursively call wxWindow::Show() on all sizer items.
|
// Recursively call wxWindow::Show() on all sizer items.
|
||||||
void ShowItems(bool show);
|
void ShowItems(bool show);
|
||||||
|
Reference in New Issue
Block a user