1 #############################################################################
3 ## Purpose: XS for Wx::Sizer and derived classes
4 ## Author: Mattia Barbon
7 ## RCS-ID: $Id: Sizer.xs 2393 2008-05-14 20:54:52Z mbarbon $
8 ## Copyright: (c) 2000-2003, 2005-2008 Mattia Barbon
9 ## Licence: This program is free software; you can redistribute it and/or
10 ## modify it under the same terms as Perl itself
11 #############################################################################
15 #include <wx/statbox.h>
16 #include "cpp/sizer.h"
21 %typemap{wxFlexSizerGrowMode}{simple};
22 %typemap{wxSizerItem*}{simple};
23 %typemap{Wx_UserDataO*}{simple};
24 %typemap{wxStdDialogButtonSizer*}{simple};
25 %typemap{wxWrapSizer*}{simple};
26 %typemap{wxButton*}{simple};
28 %name{Wx::Sizer} class wxSizer
30 #if WXPERL_W_VERSION_GE( 2, 5, 4 )
31 %name{AddWindow} wxSizerItem* Add( wxWindow* window, int option = 0,
32 int flag = 0, int border = 0,
33 Wx_UserDataO* data = NULL );
34 %name{AddSizer} wxSizerItem* Add( wxSizer* sizer, int option = 0,
35 int flag = 0, int border = 0,
36 Wx_UserDataO* data = NULL );
37 %name{AddSpace} wxSizerItem* Add( int width, int height, int option = 0,
38 int flag = 0, int border = 0,
39 Wx_UserDataO* data = NULL );
41 %name{PrependWindow} wxSizerItem* Prepend( wxWindow* window,
42 int option = 0, int flag = 0,
44 Wx_UserDataO* data = NULL );
45 %name{PrependSizer} wxSizerItem* Prepend( wxSizer* sizer, int option = 0,
46 int flag = 0, int border = 0,
47 Wx_UserDataO* data = NULL );
48 %name{PrependSpace} wxSizerItem* Prepend( int width, int height,
50 int flag = 0, int border = 0,
51 Wx_UserDataO* data = NULL );
53 %name{InsertWindow} wxSizerItem* Insert( int pos, wxWindow* window,
54 int option = 0, int flag = 0,
56 Wx_UserDataO* data = NULL );
57 %name{InsertSizer} wxSizerItem* Insert( int pos, wxSizer* sizer,
59 int flag = 0, int border = 0,
60 Wx_UserDataO* data = NULL );
61 %name{InsertSpace} wxSizerItem* Insert( int pos, int width, int height,
63 int flag = 0, int border = 0,
64 Wx_UserDataO* data = NULL );
66 %name{AddWindow} void Add( wxWindow* window, int option = 0,
67 int flag = 0, int border = 0,
68 Wx_UserDataO* data = NULL );
69 %name{AddSizer} void Add( wxSizer* sizer, int option = 0,
70 int flag = 0, int border = 0,
71 Wx_UserDataO* data = NULL );
72 %name{AddSpace} void Add( int width, int height, int option = 0,
73 int flag = 0, int border = 0,
74 Wx_UserDataO* data = NULL );
76 %name{PrependWindow} void Prepend( wxWindow* window,
77 int option = 0, int flag = 0,
79 Wx_UserDataO* data = NULL );
80 %name{PrependSizer} void Prepend( wxSizer* sizer, int option = 0,
81 int flag = 0, int border = 0,
82 Wx_UserDataO* data = NULL );
83 %name{PrependSpace} void Prepend( int width, int height,
85 int flag = 0, int border = 0,
86 Wx_UserDataO* data = NULL );
88 %name{InsertWindow} void Insert( int pos, wxWindow* window,
89 int option = 0, int flag = 0,
91 Wx_UserDataO* data = NULL );
92 %name{InsertSizer} void Insert( int pos, wxSizer* sizer,
94 int flag = 0, int border = 0,
95 Wx_UserDataO* data = NULL );
96 %name{InsertSpace} void Insert( int pos, int width, int height,
98 int flag = 0, int border = 0,
99 Wx_UserDataO* data = NULL );
101 #if WXPERL_W_VERSION_GE( 2, 5, 4 )
102 %name{GetItemWindow} wxSizerItem* GetItem( wxWindow* window,
103 bool recursive = false );
104 %name{GetItemSizer} wxSizerItem* GetItem( wxSizer* sizer,
105 bool recursive = false );
106 %name{GetItemNth} wxSizerItem* GetItem( size_t index );
110 wxSizer::GetItemNth( index )
113 RETVAL = index >= THIS->GetChildren().GetCount() ? NULL :
114 THIS->GetChildren().Item( index )->GetData();
118 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
119 wxSizerItem* GetItemById( int id, bool recursive = false );
122 %name{HideSizer} bool Hide( wxSizer *sizer, bool recursive = false );
123 %name{HideWindow} bool Hide( wxWindow *window, bool recursive = false );
124 %name{HideIndex} bool Hide( size_t index );
130 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wwin_b, HideWindow, 1 )
131 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wszr_b, HideSizer, 1 )
132 MATCH_REDISP( wxPliOvl_n, HideIndex )
133 END_OVERLOAD( Wx::Sizer::Hide )
136 %name{IsShownWindow} bool IsShown( wxWindow *window ) const;
137 %name{IsShownSizer} bool IsShown( wxSizer *sizer ) const;
138 %name{IsShownIndex} bool IsShown( size_t index ) const;
141 wxSizer::IsShown( ... )
144 MATCH_REDISP( wxPliOvl_wwin, IsShownWindow )
145 MATCH_REDISP( wxPliOvl_wszr, IsShownSizer )
146 MATCH_REDISP( wxPliOvl_n, IsShownIndex )
147 END_OVERLOAD( Wx::Sizer::IsShown )
150 # DECLARE_OVERLOAD( wszi, Wx::SizerItem )
152 #if WXPERL_W_VERSION_GE( 2, 7, 2 )
154 %name{ReplaceWindow} bool Replace( wxWindow *oldwin, wxWindow *newwin,
155 bool recursive = false );
156 %name{ReplaceSizer} bool Replace( wxSizer *oldsz, wxSizer *newsz,
157 bool recursive = false );
158 %name{ReplaceIndex} bool Replace( size_t index, wxSizerItem *newitem );
161 wxSizer::Replace( ... )
164 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wwin_wwin_b, ReplaceWindow, 2 )
165 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wszr_wszr_b, ReplaceSizer, 2 )
166 MATCH_REDISP( wxPliOvl_n_wszi, ReplaceIndex )
167 END_OVERLOAD( Wx::Sizer::Replace )
173 void Clear( bool deleteWindows = false );
174 void DeleteWindows();
176 wxSize Fit( wxWindow* window );
177 void FitInside( wxWindow* window );
179 wxPoint GetPosition();
183 #if WXPERL_W_VERSION_LT( 2, 7, 0 ) || WXWIN_COMPATIBILITY_2_6
184 %name{RemoveWindow} bool Remove( wxWindow* window );
186 %name{RemoveSizer} bool Remove( wxSizer* window );
187 %name{RemoveNth} bool Remove( int nth );
189 #if WXPERL_W_VERSION_GE( 2, 5, 3 )
190 %name{DetachWindow} bool Detach( wxWindow* window );
191 %name{DetachSizer} bool Detach( wxSizer* window );
192 %name{DetachNth} bool Detach( int nth );
195 #if WXPERL_W_VERSION_GE( 2, 7, 1 )
196 wxWindow* GetContainingWindow();
197 void SetContainingWindow( wxWindow* window );
200 void SetDimension( int x, int y, int width, int height );
202 %name{SetItemMinSizeWindow}
203 void SetItemMinSize( wxWindow* window, int width, int height );
204 %name{SetItemMinSizeSizer}
205 void SetItemMinSize( wxSizer* window, int width, int height );
206 %name{SetItemMinSizeNth}
207 void SetItemMinSize( int pos, int width, int height );
209 %name{SetMinSizeSize} void SetMinSize( wxSize size );
210 %name{SetMinSizeXY} void SetMinSize( int x, int y );
212 void SetSizeHints( wxWindow* window );
214 #if WXPERL_W_VERSION_LT( 2, 9, 0 )
215 void SetVirtualSizeHints( wxWindow* window );
218 #if WXPERL_W_VERSION_GE( 2, 6, 2 )
219 %name{ShowWindow} bool Show( wxWindow* window, bool show = true, bool recursive = false );
220 %name{ShowSizer} bool Show( wxSizer* sizer, bool show = true, bool recursive = false );
221 %name{ShowIndex} bool Show( size_t index, bool show = true );
223 #if WXPERL_W_VERSION_GE( 2, 5, 3 )
224 %name{ShowWindow} bool Show( wxWindow* window, bool show = true );
225 %name{ShowSizer} bool Show( wxSizer* sizer, bool show = true );
226 %name{ShowIndex} bool Show( size_t index, bool show = true );
228 %name{ShowWindow} void Show( wxWindow* window, bool show = true );
229 %name{ShowSizer} void Show( wxSizer* sizer, bool show = true );
233 #if WXPERL_W_VERSION_GE( 2, 5, 4 )
234 wxSizerItem* AddSpacer( int size );
235 wxSizerItem* AddStretchSpacer( int prop = 1 );
237 wxSizerItem* InsertSpacer( size_t index, int size );
238 wxSizerItem* InsertStretchSpacer( size_t index, int prop = 1 );
240 wxSizerItem* PrependSpacer( int size );
241 wxSizerItem* PrependStretchSpacer( int prop = 1 );
243 #if WXPERL_W_VERSION_GE( 2, 5, 3 )
244 void AddSpacer( int size );
245 void AddStretchSpacer( int prop = 1 );
247 void InsertSpacer( size_t index, int size );
248 void InsertStretchSpacer( size_t index, int prop = 1 );
250 void PrependSpacer( int size );
251 void PrependStretchSpacer( int prop = 1 );
256 %name{Wx::FlexGridSizer} class wxFlexGridSizer
258 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
259 void AddGrowableCol( size_t index, int proportion = 0 );
260 void AddGrowableRow( size_t index, int proportion = 0 );
262 void SetFlexibleDirection( int direction );
263 int GetFlexibleDirection();
265 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode);
266 wxFlexSizerGrowMode GetNonFlexibleGrowMode();
268 void AddGrowableCol( size_t index );
269 void AddGrowableRow( size_t index );
273 %name{Wx::SizerItem} class wxSizerItem
275 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
276 %name{GetOption} int GetProportion();
277 %name{SetOption} void SetProportion( int option );
279 void SetProportion( int proportion );
281 %name{GetProportion} int GetOption();
282 %name{SetProportion} void SetOption( int proportion );
284 void SetOption( int option );
286 #if WXPERL_W_VERSION_GE( 2, 5, 3 )
287 %name{SetMinSizeWH} void SetMinSize( int x, int y );
288 %name{SetMinSizeSize} void SetMinSize( wxSize size );
290 void DeleteWindows();
292 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
293 void SetId( int id );
296 #if WXPERL_W_VERSION_GE( 2, 6, 0 )
297 const wxRect& GetRect();
299 void Show( bool show );
300 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
301 void AssignSpacer( int width, int height );
303 #if WXPERL_W_VERSION_GE( 2, 6, 0 )
304 void SetSpacer( int width, int height );
307 wxSize GetSpacer() const;
310 #if WXPERL_W_VERSION_GE( 2, 6, 1 )
312 #include <wx/button.h>
314 %name{Wx::StdDialogButtonSizer} class wxStdDialogButtonSizer
316 wxStdDialogButtonSizer();
318 void AddButton( wxButton* button );
320 void SetAffirmativeButton( wxButton* button );
321 void SetNegativeButton( wxButton* button );
322 void SetCancelButton( wxButton* button );
326 wxButton *GetAffirmativeButton() const;
327 wxButton *GetApplyButton() const;
328 wxButton *GetNegativeButton() const;
329 wxButton *GetCancelButton() const;
330 wxButton *GetHelpButton() const;
335 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
337 #include <wx/wrapsizer.h>
339 %name{Wx::WrapSizer} class wxWrapSizer
341 wxWrapSizer( int orient = wxHORIZONTAL,
342 int flags = wxEXTEND_LAST_ON_EACH_LINE );
344 bool InformFirstDirection( int direction, int size,
345 int availableOtherDir );
351 MODULE=Wx PACKAGE=Wx::Sizer
357 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wwin_b, ShowWindow, 1 )
358 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wszr_b, ShowSizer, 1 )
359 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_b, ShowIndex, 1 )
360 END_OVERLOAD( Wx::Sizer::Show )
371 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wwin_n_n_n_s, AddWindow, 1 )
372 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wszr_n_n_n_s, AddSizer, 1 )
373 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_n_n_n_n_s, AddSpace, 2 )
374 END_OVERLOAD( Wx::Sizer::Add )
377 wxSizer::GetChildren()
379 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
380 wxSizerItemList::compatibility_iterator node;
381 const wxSizerItemList& list
383 wxList::compatibility_iterator node;
386 = THIS->GetChildren();
388 EXTEND( SP, (IV) list.GetCount() );
390 for( node = list.GetFirst(); node; node = node->GetNext() )
391 PUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(), node->GetData() ) );
394 wxSizer::Insert( ... )
397 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_wwin_n_n_n_s, InsertWindow, 2 )
398 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_wszr_n_n_n_s, InsertSizer, 2 )
399 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_n_n_n_n_n_s, InsertSpace, 3 )
400 END_OVERLOAD( "Wx::Sizer::Insert" )
403 wxSizer::Prepend( ... )
406 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wwin_n_n_n_s, PrependWindow, 1 )
407 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wszr_n_n_n_s, PrependSizer, 1 )
408 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_n_n_n_n_s, PrependSpace, 2 )
409 END_OVERLOAD( "Wx::Sizer::Prepend" )
412 wxSizer::Remove( ... )
415 #if WXPERL_W_VERSION_LT( 2, 7, 0 )|| WXWIN_COMPATIBILITY_2_6
416 MATCH_REDISP( wxPliOvl_wwin, RemoveWindow )
418 MATCH_REDISP( wxPliOvl_wszr, RemoveSizer )
419 MATCH_REDISP( wxPliOvl_n, RemoveNth )
420 END_OVERLOAD( Wx::Sizer::Remove )
423 wxSizer::Detach( ... )
426 MATCH_REDISP( wxPliOvl_wwin, DetachWindow )
427 MATCH_REDISP( wxPliOvl_wszr, DetachSizer )
428 MATCH_REDISP( wxPliOvl_n, DetachNth )
429 END_OVERLOAD( Wx::Sizer::Detach )
432 wxSizer::GetItem( ... )
435 #if WXPERL_W_VERSION_GE( 2, 5, 4 )
436 MATCH_REDISP( wxPliOvl_wwin_s, GetItemWindow )
437 MATCH_REDISP( wxPliOvl_wszr_s, GetItemSizer )
439 MATCH_REDISP( wxPliOvl_n, GetItemNth )
440 END_OVERLOAD( Wx::Sizer::GetItem )
443 wxSizer::SetItemMinSize( ... )
446 MATCH_REDISP( wxPliOvl_wwin_n_n, SetItemMinSizeWindow )
447 MATCH_REDISP( wxPliOvl_wszr_n_n, SetItemMinSizeSizer )
448 MATCH_REDISP( wxPliOvl_n_n_n, SetItemMinSizeNth )
449 END_OVERLOAD( Wx::Sizer::SetItemMinSize )
452 wxSizer::SetMinSize( ... )
455 MATCH_REDISP( wxPliOvl_n_n, SetMinSizeXY )
456 MATCH_REDISP( wxPliOvl_wsiz, SetMinSizeSize )
457 END_OVERLOAD( Wx::Sizer::SetMinSize )
459 MODULE=Wx PACKAGE=Wx::BoxSizer
462 wxBoxSizer::new( orientation )
466 wxBoxSizer::GetOrientation()
468 MODULE=Wx PACKAGE=Wx::StaticBoxSizer
471 wxStaticBoxSizer::new( box, orient )
476 wxStaticBoxSizer::GetStaticBox()
478 MODULE=Wx PACKAGE=Wx::NotebookSizer
480 #include <wx/notebook.h>
483 wxNotebookSizer::new( notebook )
487 wxNotebookSizer::GetNotebook()
489 MODULE=Wx PACKAGE=Wx::GridSizer
492 wxGridSizer::new( rows, cols, vgap = 0, hgap = 0 )
499 wxGridSizer::GetCols()
502 wxGridSizer::GetHGap()
505 wxGridSizer::GetRows()
508 wxGridSizer::GetVGap()
511 wxGridSizer::SetCols( cols )
515 wxGridSizer::SetHGap( gap )
519 wxGridSizer::SetRows( rows )
523 wxGridSizer::SetVGap( gap )
526 MODULE=Wx PACKAGE=Wx::FlexGridSizer
529 wxFlexGridSizer::new( rows, cols, vgap = 0, hgap = 0 )
536 wxFlexGridSizer::RemoveGrowableCol( index )
540 wxFlexGridSizer::RemoveGrowableRow( index )
543 MODULE=Wx PACKAGE=Wx::SizerItem
546 wxSizerItem::GetSize()
548 RETVAL = new wxSize( THIS->GetSize() );
553 wxSizerItem::CalcMin()
555 RETVAL = new wxSize( THIS->GetSize() );
560 wxSizerItem::SetDimension( pos, size )
565 wxSizerItem::GetMinSize()
567 RETVAL = new wxSize( THIS->GetMinSize() );
572 wxSizerItem::SetRatio( ... )
575 MATCH_REDISP_COUNT( wxPliOvl_n, SetRatioFloat, 1 )
576 MATCH_REDISP_COUNT( wxPliOvl_n_n, SetRatioWH, 2 )
577 MATCH_REDISP_COUNT( wxPliOvl_wsiz, SetRatioSize, 1 )
578 END_OVERLOAD( Wx::SizerItem::SetRatio )
581 wxSizerItem::SetRatioWH( width, height )
585 THIS->SetRatio( width, height );
588 wxSizerItem::SetRatioSize( size )
591 THIS->SetRatio( size );
594 wxSizerItem::SetRatioFloat( ratio )
597 THIS->SetRatio( ratio );
600 wxSizerItem::GetRatio()
603 wxSizerItem::IsWindow()
606 wxSizerItem::IsShown()
609 wxSizerItem::IsSizer()
612 wxSizerItem::IsSpacer()
615 wxSizerItem::SetInitSize( x, y )
620 wxSizerItem::SetFlag( flag )
624 wxSizerItem::SetBorder( border )
628 wxSizerItem::GetWindow()
630 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
633 wxSizerItem::AssignWindow( window )
639 wxSizerItem::SetWindow( window )
645 wxSizerItem::GetSizer()
647 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
650 wxSizerItem::AssignSizer( sizer )
656 wxSizerItem::SetSizer( sizer )
662 wxSizerItem::GetFlag()
665 wxSizerItem::GetBorder()
668 wxSizerItem::GetPosition()
670 RETVAL = new wxPoint( THIS->GetPosition() );
675 wxSizerItem::GetUserData()
677 RETVAL = (Wx_UserDataO*) THIS->GetUserData();
681 #if WXPERL_W_VERSION_GE( 2, 6, 3 )
684 wxSizerItem::SetUserData( data )
690 wxSizerItem::SetMinSize( ... )
693 MATCH_REDISP_COUNT( wxPliOvl_n_n, SetMinSizeWH, 2 )
694 MATCH_REDISP_COUNT( wxPliOvl_wsiz, SetMinSizeSize, 1 )
695 END_OVERLOAD( Wx::SizerItem::SetMinSize )
698 MODULE=Wx PACKAGE=Wx::PlSizer
703 RETVAL = new wxPlSizer( CLASS );