]>
git.saurik.com Git - wxWidgets.git/blob - src/common/sizer.cpp
541fcf3fb2b1161e6998971a5c19173378c39ad5
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: provide wxSizer class for layounting
4 // Author: Robert Roebling and Robin Dunn
8 // Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WXSIZERS_H__
13 #define __WXSIZERS_H__
16 #pragma interface "sizers.h"
22 //---------------------------------------------------------------------------
24 //---------------------------------------------------------------------------
26 wxSizerItem::wxSizerItem( int width
, int height
, int option
)
28 m_window
= (wxWindow
*) NULL
;
29 m_sizer
= (wxSizer
*) NULL
;
35 wxSizerItem::wxSizerItem( wxWindow
*window
, int option
)
38 m_sizer
= (wxSizer
*) NULL
;
39 m_minSize
= window
->GetSize();
43 wxSizerItem::wxSizerItem( wxSizer
*sizer
, int option
)
45 m_window
= (wxWindow
*) NULL
;
52 wxSize
wxSizerItem::GetMinSize()
55 return m_sizer
->GetMinSize();
60 bool wxSizerItem::IsWindow()
62 return (m_window
!= NULL
);
65 bool wxSizerItem::IsSizer()
67 return (m_sizer
!= NULL
);
70 bool wxSizerItem::IsSpacer()
72 return (m_window
== NULL
) && (m_sizer
== NULL
);
75 //---------------------------------------------------------------------------
77 //---------------------------------------------------------------------------
81 m_children
.DeleteContents( TRUE
);
88 void wxSizer::Add( wxWindow
*window
, int option
)
90 m_children
.Append( new wxSizerItem( window
, option
) );
93 void wxSizer::Add( wxSizer
*sizer
, int option
)
95 m_children
.Append( new wxSizerItem( sizer
, option
) );
98 void wxSizer::Add( int width
, int height
, int option
)
100 m_children
.Append( new wxSizerItem( width
, height
, option
) );
103 void wxSizer::Fit( wxWindow
*window
);
105 window
->SetSize( GetMinWindowSize( window
) );
108 void wxSizer::SetSizeHints( wxWindow
*window
);
110 wxSize
size( GetMinWindowSize( window
) );
111 window
->SetSizeHints( size
.x
, size
.y
);
114 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
116 wxSize
min( GetMinSize() );
117 wxSize
size( window
->GetSize() );
118 wxSize
client_size( window
->GetClientSize() );
119 return wxSize( min
.x
+size
.x
-client_size
.x
, min
.y
+size
.y
-client_size
.y
);
122 void wxSizer::DoSetDimension( int x
, int y
, int width
, int height
)