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 /////////////////////////////////////////////////////////////////////////////
 
  19 //----------------------------------------------------------------------
 
  22 %include my_typemaps.i
 
  24 // Import some definitions of other classes, etc.
 
  30 %pragma(python) code = "import wx"
 
  31 %pragma(python) code = "import string"
 
  33 //---------------------------------------------------------------------------
 
  38     // No need to ever create one directly in Python...
 
  40     //wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
 
  41     //wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
 
  42     //wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
 
  46     void SetDimension( wxPoint pos, wxSize size );
 
  47     %name(SetRatioWH) void SetRatio( int width, int height );
 
  48     %name(SetRatioSize) void SetRatio( wxSize size );
 
  49     void SetRatio( float ratio );
 
  56     wxWindow *GetWindow();
 
  57     void SetWindow( wxWindow *window );
 
  59     void SetSizer( wxSizer *sizer );
 
  64     void SetInitSize( int x, int y );
 
  65     void SetOption( int option );
 
  66     void SetFlag( int flag );
 
  67     void SetBorder( int border );
 
  69     // wxObject* GetUserData();
 
  71         // Assume that the user data is a wxPyUserData object and return the contents
 
  72         PyObject* GetUserData() {
 
  73             wxPyUserData* data = (wxPyUserData*)self->GetUserData();
 
  75                 Py_INCREF(data->m_obj);
 
  86 //---------------------------------------------------------------------------
 
  90     // wxSizer();      ****  abstract, can't instantiate
 
  94         void Destroy() { delete self; }
 
  96         void AddWindow(wxWindow *window, int option=0, int flag=0, int border=0,
 
  97                        PyObject* userData=NULL) {
 
  98             wxPyUserData* data = NULL;
 
  99             if (userData) data = new wxPyUserData(userData);
 
 100             self->Add(window, option, flag, border, data);
 
 102         void AddSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
 
 103                       PyObject* userData=NULL) {
 
 104             wxPyUserData* data = NULL;
 
 105             if (userData) data = new wxPyUserData(userData);
 
 106             self->Add(sizer, option, flag, border, data);
 
 108         void AddSpacer(int width, int height, int option=0, int flag=0,
 
 109                        int border=0, PyObject* userData=NULL) {
 
 110             wxPyUserData* data = NULL;
 
 111             if (userData) data = new wxPyUserData(userData);
 
 112             self->Add(width, height, option, flag, border, data);
 
 116         void InsertWindow(int before, wxWindow *window, int option=0, int flag=0,
 
 117                           int border=0, PyObject* userData=NULL) {
 
 118             wxPyUserData* data = NULL;
 
 119             if (userData) data = new wxPyUserData(userData);
 
 120             self->Insert(before, window, option, flag, border, data);
 
 122         void InsertSizer(int before, wxSizer *sizer, int option=0, int flag=0,
 
 123                          int border=0, PyObject* userData=NULL) {
 
 124             wxPyUserData* data = NULL;
 
 125             if (userData) data = new wxPyUserData(userData);
 
 126             self->Insert(before, sizer, option, flag, border, data);
 
 128         void InsertSpacer(int before, int width, int height, int option=0, int flag=0,
 
 129                           int border=0, PyObject* userData=NULL) {
 
 130             wxPyUserData* data = NULL;
 
 131             if (userData) data = new wxPyUserData(userData);
 
 132             self->Insert(before, width, height, option, flag, border, data);
 
 136         void PrependWindow(wxWindow *window, int option=0, int flag=0, int border=0,
 
 137                            PyObject* userData=NULL) {
 
 138             wxPyUserData* data = NULL;
 
 139             if (userData) data = new wxPyUserData(userData);
 
 140             self->Prepend(window, option, flag, border, data);
 
 142         void PrependSizer(wxSizer *sizer, int option=0, int flag=0, int border=0,
 
 143                           PyObject* userData=NULL) {
 
 144             wxPyUserData* data = NULL;
 
 145             if (userData) data = new wxPyUserData(userData);
 
 146             self->Prepend(sizer, option, flag, border, data);
 
 148         void PrependSpacer(int width, int height, int option=0, int flag=0,
 
 149                            int border=0, PyObject* userData=NULL) {
 
 150             wxPyUserData* data = NULL;
 
 151             if (userData) data = new wxPyUserData(userData);
 
 152             self->Prepend(width, height, option, flag, border, data);
 
 156     %name(RemoveWindow)bool Remove( wxWindow *window );
 
 157     %name(RemoveSizer)bool Remove( wxSizer *sizer );
 
 158     %name(RemovePos)bool Remove( int pos );
 
 161     %pragma(python) addtoclass = "
 
 162     def Add(self, *args):
 
 163         if type(args[0]) == type(1):
 
 164             apply(self.AddSpacer, args)
 
 165         elif string.find(args[0].this, 'Sizer') != -1:
 
 166             apply(self.AddSizer, args)
 
 168             apply(self.AddWindow, args)
 
 170     def Insert(self, *args):
 
 171         if type(args[1]) == type(1):
 
 172             apply(self.InsertSpacer, args)
 
 173         elif string.find(args[1].this, 'Sizer') != -1:
 
 174             apply(self.InsertSizer, args)
 
 176             apply(self.InsertWindow, args)
 
 178     def Prepend(self, *args):
 
 179         if type(args[0]) == type(1):
 
 180             apply(self.PrependSpacer, args)
 
 181         elif string.find(args[0].this, 'Sizer') != -1:
 
 182             apply(self.PrependSizer, args)
 
 184             apply(self.PrependWindow, args)
 
 186     def Remove(self, *args):
 
 187         if type(args[0]) == type(1):
 
 188             apply(self.RemovePos, args)
 
 189         elif string.find(args[0].this, 'Sizer') != -1:
 
 190             apply(self.RemoveSizer, args)
 
 192             apply(self.RemoveWindow, args)
 
 194     def AddMany(self, widgets):
 
 195         for childinfo in widgets:
 
 196             if type(childinfo) != type(()):
 
 197                 childinfo = (childinfo, )
 
 198             apply(self.Add, childinfo)
 
 202     void SetDimension( int x, int y, int width, int height );
 
 203     void SetMinSize(wxSize size);
 
 205     %name(SetItemMinSizeWindow) void SetItemMinSize(wxWindow* window, int width, int height);
 
 206     %name(SetItemMinSizeSizer) void SetItemMinSize(wxSizer* sizer, int width, int height);
 
 207     %name(SetItemMinSizePos) void SetItemMinSize(int pos, int width, int height);
 
 209     %pragma(python) addtoclass = "
 
 210     def SetItemMinSize(self, *args):
 
 211         if type(args[0]) == type(1):
 
 212             apply(self.SetItemMinSizePos, args)
 
 213         elif string.find(args[0].this, 'Sizer') != -1:
 
 214             apply(self.SetItemMinSizeSizer, args)
 
 216             apply(self.SetItemMinSizeWindow, args)
 
 220     wxPoint GetPosition();
 
 223     // void RecalcSizes() = 0;
 
 224     // wxSize CalcMin() = 0;
 
 228     void Fit( wxWindow *window );
 
 229     void SetSizeHints( wxWindow *window );
 
 231     // wxList& GetChildren();
 
 233         PyObject* GetChildren() {
 
 234             wxList& list = self->GetChildren();
 
 235             return wxPy_ConvertList(&list, "wxSizerItem");
 
 241 //---------------------------------------------------------------------------
 
 242 // Use this one for deriving Python classes from
 
 244 class wxPySizer : public wxSizer {
 
 245     DECLARE_DYNAMIC_CLASS(wxPySizer);
 
 247     wxPySizer() : wxSizer() {};
 
 249     DEC_PYCALLBACK___pure(RecalcSizes);
 
 250     DEC_PYCALLBACK_wxSize__pure(CalcMin);
 
 255 IMP_PYCALLBACK___pure(wxPySizer, wxSizer, RecalcSizes);
 
 256 IMP_PYCALLBACK_wxSize__pure(wxPySizer, wxSizer, CalcMin);
 
 258 IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer);
 
 263 class wxPySizer : public wxSizer {
 
 266     void _setSelf(PyObject* self, PyObject* _class);
 
 267     %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPySizer)"
 
 271 //---------------------------------------------------------------------------
 
 273 class  wxBoxSizer : public wxSizer {
 
 275     wxBoxSizer(int orient = wxHORIZONTAL);
 
 276     int GetOrientation();
 
 281 //---------------------------------------------------------------------------
 
 283 class  wxStaticBoxSizer : public wxBoxSizer {
 
 285     wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL);
 
 286     wxStaticBox *GetStaticBox();
 
 291 //---------------------------------------------------------------------------
 
 293 class wxNotebookSizer: public wxSizer {
 
 295     wxNotebookSizer( wxNotebook *nb );
 
 300     wxNotebook *GetNotebook();
 
 303 //---------------------------------------------------------------------------
 
 305 class wxGridSizer: public wxSizer
 
 308     wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
 
 313     void SetCols( int cols );
 
 314     void SetRows( int rows );
 
 315     void SetVGap( int gap );
 
 316     void SetHGap( int gap );
 
 323 //---------------------------------------------------------------------------
 
 325 class wxFlexGridSizer: public wxGridSizer
 
 328     wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 );
 
 333     void AddGrowableRow( size_t idx );
 
 334     void RemoveGrowableRow( size_t idx );
 
 335     void AddGrowableCol( size_t idx );
 
 336     void RemoveGrowableCol( size_t idx );
 
 340 //---------------------------------------------------------------------------