1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG definitions of the wxSizer family of classes
 
   7 // Created:     18-Sept-1999
 
   9 // Copyright:   (c) 1999 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  18 #include <wx/notebook.h>
 
  21 //----------------------------------------------------------------------
 
  24 %include my_typemaps.i
 
  26 // Import some definitions of other classes, etc.
 
  32 %pragma(python) code = "import wx"
 
  33 %pragma(python) code = "import string"
 
  35 //---------------------------------------------------------------------------
 
  38 class wxSizerItem : public wxObject {
 
  40     // No need to ever create one directly in Python...
 
  42     //wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
 
  43     //wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
 
  44     //wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
 
  48     wxPoint GetPosition();
 
  51     void SetDimension( wxPoint pos, wxSize size );
 
  52     %name(SetRatioWH) void SetRatio( int width, int height );
 
  53     %name(SetRatioSize) void SetRatio( wxSize size );
 
  54     void SetRatio( float ratio );
 
  61     wxWindow *GetWindow();
 
  62     void SetWindow( wxWindow *window );
 
  64     void SetSizer( wxSizer *sizer );
 
  69     void SetInitSize( int x, int y );
 
  70     void SetOption( int option );
 
  71     void SetFlag( int flag );
 
  72     void SetBorder( int border );
 
  74     // wxObject* GetUserData();
 
  76         // Assume that the user data is a wxPyUserData object and return the contents
 
  77         PyObject* GetUserData() {
 
  78             wxPyUserData* data = (wxPyUserData*)self->GetUserData();
 
  80                 Py_INCREF(data->m_obj);
 
  91 //---------------------------------------------------------------------------
 
  93 class wxSizer : public wxObject {
 
  95     // wxSizer();      ****  abstract, can't instantiate
 
  99         void _setOORInfo(PyObject* _self) {
 
 100             self->SetClientObject(new wxPyClientData(_self));
 
 105         void Destroy() { delete self; }
 
 107         void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0,
 
 108                        PyObject* userData=NULL) {
 
 109             wxPyUserData* data = NULL;
 
 110             if (userData) data = new wxPyUserData(userData);
 
 111             self->Add(window, option, flag, border, data);
 
 113         void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
 
 114                       PyObject* userData=NULL) {
 
 115             wxPyUserData* data = NULL;
 
 116             if (userData) data = new wxPyUserData(userData);
 
 117             self->Add(sizer, option, flag, border, data);
 
 119         void AddSpacer(int width, int height, int option=0, int flag=0,
 
 120                        int border=0, PyObject* userData=NULL) {
 
 121             wxPyUserData* data = NULL;
 
 122             if (userData) data = new wxPyUserData(userData);
 
 123             self->Add(width, height, option, flag, border, data);
 
 127         void InsertWindow(int before, wxWindow *window, int option=0, int flag=0,
 
 128                           int border=0, PyObject* userData=NULL) {
 
 129             wxPyUserData* data = NULL;
 
 130             if (userData) data = new wxPyUserData(userData);
 
 131             self->Insert(before, window, option, flag, border, data);
 
 133         void InsertSizer(int before, wxSizer *sizer, int option=0, int flag=0,
 
 134                          int border=0, PyObject* userData=NULL) {
 
 135             wxPyUserData* data = NULL;
 
 136             if (userData) data = new wxPyUserData(userData);
 
 137             self->Insert(before, sizer, option, flag, border, data);
 
 139         void InsertSpacer(int before, int width, int height, int option=0, int flag=0,
 
 140                           int border=0, PyObject* userData=NULL) {
 
 141             wxPyUserData* data = NULL;
 
 142             if (userData) data = new wxPyUserData(userData);
 
 143             self->Insert(before, width, height, option, flag, border, data);
 
 147         void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0,
 
 148                            PyObject* userData=NULL) {
 
 149             wxPyUserData* data = NULL;
 
 150             if (userData) data = new wxPyUserData(userData);
 
 151             self->Prepend(window, option, flag, border, data);
 
 153         void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
 
 154                           PyObject* userData=NULL) {
 
 155             wxPyUserData* data = NULL;
 
 156             if (userData) data = new wxPyUserData(userData);
 
 157             self->Prepend(sizer, option, flag, border, data);
 
 159         void PrependSpacer(int width, int height, int option=0, int flag=0,
 
 160                            int border=0, PyObject* userData=NULL) {
 
 161             wxPyUserData* data = NULL;
 
 162             if (userData) data = new wxPyUserData(userData);
 
 163             self->Prepend(width, height, option, flag, border, data);
 
 167     %name(RemoveWindow)bool Remove( wxWindow *window );
 
 168     %name(RemoveSizer)bool Remove( wxSizer *sizer );
 
 169     %name(RemovePos)bool Remove( int pos );
 
 172     %pragma(python) addtoclass = "
 
 173     def Add(self, *args, **kw):
 
 174         if type(args[0]) == type(1):
 
 175             apply(self.AddSpacer, args, kw)
 
 176         elif string.find(args[0].this, 'Sizer') != -1:
 
 177             apply(self.AddSizer, args, kw)
 
 179             apply(self.AddWindow, args, kw)
 
 181     def Insert(self, *args, **kw):
 
 182         if type(args[1]) == type(1):
 
 183             apply(self.InsertSpacer, args, kw)
 
 184         elif string.find(args[1].this, 'Sizer') != -1:
 
 185             apply(self.InsertSizer, args, kw)
 
 187             apply(self.InsertWindow, args, kw)
 
 189     def Prepend(self, *args, **kw):
 
 190         if type(args[0]) == type(1):
 
 191             apply(self.PrependSpacer, args, kw)
 
 192         elif string.find(args[0].this, 'Sizer') != -1:
 
 193             apply(self.PrependSizer, args, kw)
 
 195             apply(self.PrependWindow, args, kw)
 
 197     def Remove(self, *args, **kw):
 
 198         if type(args[0]) == type(1):
 
 199             apply(self.RemovePos, args, kw)
 
 200         elif string.find(args[0].this, 'Sizer') != -1:
 
 201             apply(self.RemoveSizer, args, kw)
 
 203             apply(self.RemoveWindow, args, kw)
 
 205     def AddMany(self, widgets):
 
 206         for childinfo in widgets:
 
 207             if type(childinfo) != type(()):
 
 208                 childinfo = (childinfo, )
 
 209             apply(self.Add, childinfo)
 
 213     void SetDimension( int x, int y, int width, int height );
 
 214     void SetMinSize(wxSize size);
 
 216     %name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, int width, int height);
 
 217     %name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, int width, int height);
 
 218     %name(SetItemMinSizePos) void SetItemMinSize(int pos, int width, int height);
 
 220     %pragma(python) addtoclass = "
 
 221     def SetItemMinSize(self, *args):
 
 222         if type(args[0]) == type(1):
 
 223             apply(self.SetItemMinSizePos, args)
 
 224         elif string.find(args[0].this, 'Sizer') != -1:
 
 225             apply(self.SetItemMinSizeSizer, args)
 
 227             apply(self.SetItemMinSizeWindow, args)
 
 231     wxPoint GetPosition();
 
 234     // void RecalcSizes() = 0;
 
 235     // wxSize CalcMin() = 0;
 
 239     void Fit( wxWindow *window );
 
 240     void SetSizeHints( wxWindow *window );
 
 242     void Clear( bool delete_windows=FALSE );
 
 243     void DeleteWindows();
 
 246     // wxList& GetChildren();
 
 248         PyObject* GetChildren() {
 
 249             wxList& list = self->GetChildren();
 
 250             return wxPy_ConvertList(&list, "wxSizerItem");
 
 256 //---------------------------------------------------------------------------
 
 257 // Use this one for deriving Python classes from
 
 259 class wxPySizer : public wxSizer {
 
 260     DECLARE_DYNAMIC_CLASS(wxPySizer);
 
 262     wxPySizer() : wxSizer() {};
 
 264     DEC_PYCALLBACK___pure(RecalcSizes);
 
 265     DEC_PYCALLBACK_wxSize__pure(CalcMin);
 
 270 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
 
 271 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
 
 273 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
 
 278 class wxPySizer : public wxSizer {
 
 281     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 282     %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPySizer)"
 
 283     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 287 //---------------------------------------------------------------------------
 
 289 class  wxBoxSizer : public wxSizer {
 
 291     wxBoxSizer(int orient = wxHORIZONTAL);
 
 292     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 293     int GetOrientation();
 
 298 //---------------------------------------------------------------------------
 
 300 class  wxStaticBoxSizer : public wxBoxSizer {
 
 302     wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
 
 303     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 304     wxStaticBox *GetStaticBox();
 
 309 //---------------------------------------------------------------------------
 
 311 class wxNotebookSizer: public wxSizer {
 
 313     wxNotebookSizer( wxNotebook *nb );
 
 314     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 317     wxNotebook *GetNotebook();
 
 320 //---------------------------------------------------------------------------
 
 322 class wxGridSizer: public wxSizer
 
 325     wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
 
 326     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 331     void SetCols( int cols );
 
 332     void SetRows( int rows );
 
 333     void SetVGap( int gap );
 
 334     void SetHGap( int gap );
 
 341 //---------------------------------------------------------------------------
 
 343 class wxFlexGridSizer: public wxGridSizer
 
 346     wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
 
 347     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 352     void AddGrowableRow( size_t idx );
 
 353     void RemoveGrowableRow( size_t idx );
 
 354     void AddGrowableCol( size_t idx );
 
 355     void RemoveGrowableCol( size_t idx );
 
 359 //---------------------------------------------------------------------------