]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sizer.h
Corrected miniframe.
[wxWidgets.git] / include / wx / sizer.h
CommitLineData
5279a24d
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: sizer.h
0c0d686f 3// Purpose: provide wxSizer class for layouting
5279a24d
RR
4// Author: Robert Roebling and Robin Dunn
5// Modified by:
0c0d686f 6// Created:
5279a24d
RR
7// RCS-ID: $Id$
8// Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __WXSIZER_H__
13#define __WXSIZER_H__
14
15#ifdef __GNUG__
16#pragma interface "sizer.h"
17#endif
18
19#include "wx/defs.h"
20
21#include "wx/window.h"
22#include "wx/frame.h"
23#include "wx/dialog.h"
24
25//---------------------------------------------------------------------------
26// classes
27//---------------------------------------------------------------------------
28
27ea1d8a 29class wxStaticBox;
83edc0a5 30class wxNotebook;
27ea1d8a 31
3417c2cd
RR
32class wxSizerItem;
33class wxSizer;
92afa2b1 34class wxBoxSizer;
27ea1d8a 35class wxStaticBoxSizer;
5279a24d
RR
36
37//---------------------------------------------------------------------------
3417c2cd 38// wxSizerItem
5279a24d
RR
39//---------------------------------------------------------------------------
40
3417c2cd 41class WXDLLEXPORT wxSizerItem: public wxObject
5279a24d 42{
0c0d686f 43 DECLARE_CLASS(wxSizerItem);
5279a24d
RR
44public:
45 // spacer
0c0d686f 46 wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
5279a24d
RR
47
48 // window
0c0d686f 49 wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
5279a24d
RR
50
51 // subsizer
0c0d686f
RD
52 wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
53
54 ~wxSizerItem();
5279a24d 55
c62ac5b6
RR
56 virtual wxSize GetSize();
57 virtual wxSize CalcMin();
58 virtual void SetDimension( wxPoint pos, wxSize size );
0c0d686f 59
be2577e4
RD
60 void SetRatio( int width, int height )
61 // if either of dimensions is zero, ratio is assumed to be 1
62 // to avoid "divide by zero" errors
63 { m_ratio = (width && height) ? ((float) width / (float) height) : 1; }
64 void SetRatio( wxSize size )
65 { m_ratio = (size.x && size.y) ? ((float) size.x / (float) size.y) : 1; }
66 void SetRatio( float ratio ) { m_ratio = ratio; }
67 float GetRatio() const { return m_ratio; }
68
5279a24d 69 bool IsWindow();
3417c2cd 70 bool IsSizer();
5279a24d 71 bool IsSpacer();
aaf6c39a
RR
72
73 void SetInitSize( int x, int y )
74 { m_minSize.x = x; m_minSize.y = y; }
75 void SetOption( int option )
76 { m_option = option; }
77 void SetFlag( int flag )
78 { m_flag = flag; }
79 void SetBorder( int border )
80 { m_border = border; }
0c0d686f
RD
81
82 wxWindow *GetWindow() const
5279a24d 83 { return m_window; }
0c0d686f 84 wxSizer *GetSizer() const
5279a24d
RR
85 { return m_sizer; }
86 int GetOption() const
87 { return m_option; }
d597fcb7
RR
88 int GetFlag() const
89 { return m_flag; }
90 int GetBorder() const
91 { return m_border; }
0c0d686f
RD
92 wxObject* GetUserData()
93 { return m_userData; }
94
c62ac5b6 95protected:
5279a24d 96 wxWindow *m_window;
3417c2cd 97 wxSizer *m_sizer;
d597fcb7 98 wxSize m_size;
5279a24d
RR
99 wxSize m_minSize;
100 int m_option;
d597fcb7
RR
101 int m_border;
102 int m_flag;
be2577e4
RD
103 // als: aspect ratio can always be calculated from m_size,
104 // but this would cause precision loss when the window
105 // is shrinked. it is safer to preserve initial value.
106 float m_ratio;
0c0d686f 107 wxObject *m_userData;
c62ac5b6 108};
5279a24d
RR
109
110//---------------------------------------------------------------------------
3417c2cd 111// wxSizer
5279a24d
RR
112//---------------------------------------------------------------------------
113
3417c2cd 114class WXDLLEXPORT wxSizer: public wxObject
5279a24d 115{
0c0d686f 116 DECLARE_CLASS(wxSizer);
5279a24d 117public:
3417c2cd
RR
118 wxSizer();
119 ~wxSizer();
0c0d686f
RD
120
121 virtual void Add( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
122 virtual void Add( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
123 virtual void Add( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
124
f35aa3da
RR
125 virtual void Insert( int before, wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
126 virtual void Insert( int before, wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
127 virtual void Insert( int before, int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
128
0c0d686f
RD
129 virtual void Prepend( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
130 virtual void Prepend( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
131 virtual void Prepend( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
132
42b4e99e
RR
133 virtual bool Remove( wxWindow *window );
134 virtual bool Remove( wxSizer *sizer );
135 virtual bool Remove( int pos );
0c0d686f 136
c62ac5b6 137 void SetDimension( int x, int y, int width, int height );
0c0d686f 138
5279a24d
RR
139 wxSize GetSize()
140 { return m_size; }
141 wxPoint GetPosition()
142 { return m_position; }
143 wxSize GetMinSize()
144 { return CalcMin(); }
c62ac5b6 145
5279a24d
RR
146 virtual void RecalcSizes() = 0;
147 virtual wxSize CalcMin() = 0;
0c0d686f 148
c62ac5b6 149 virtual void Layout();
5279a24d
RR
150
151 void Fit( wxWindow *window );
152 void SetSizeHints( wxWindow *window );
0c0d686f
RD
153
154 wxList& GetChildren()
155 { return m_children; }
156
c62ac5b6 157protected:
5279a24d
RR
158 wxSize m_size;
159 wxPoint m_position;
160 wxList m_children;
0c0d686f 161
5279a24d 162 wxSize GetMinWindowSize( wxWindow *window );
c62ac5b6
RR
163};
164
165//---------------------------------------------------------------------------
92afa2b1 166// wxBoxSizer
c62ac5b6
RR
167//---------------------------------------------------------------------------
168
92afa2b1 169class WXDLLEXPORT wxBoxSizer: public wxSizer
61d514bb 170{
0c0d686f 171 DECLARE_CLASS(wxBoxSizer);
61d514bb 172public:
92afa2b1 173 wxBoxSizer( int orient );
0c0d686f 174
61d514bb
RR
175 void RecalcSizes();
176 wxSize CalcMin();
0c0d686f 177
61d514bb
RR
178 int GetOrientation()
179 { return m_orient; }
0c0d686f 180
61d514bb
RR
181protected:
182 int m_orient;
183 int m_stretchable;
184 int m_minWidth;
185 int m_minHeight;
186 int m_fixedWidth;
187 int m_fixedHeight;
188};
0c0d686f 189
27ea1d8a
RR
190//---------------------------------------------------------------------------
191// wxStaticBoxSizer
192//---------------------------------------------------------------------------
193
194class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
195{
0c0d686f 196 DECLARE_CLASS(wxStaticBoxSizer);
27ea1d8a
RR
197public:
198 wxStaticBoxSizer( wxStaticBox *box, int orient );
0c0d686f 199
27ea1d8a
RR
200 void RecalcSizes();
201 wxSize CalcMin();
0c0d686f 202
27ea1d8a
RR
203 wxStaticBox *GetStaticBox()
204 { return m_staticBox; }
0c0d686f 205
27ea1d8a
RR
206protected:
207 wxStaticBox *m_staticBox;
208};
209
83edc0a5
RR
210//---------------------------------------------------------------------------
211// wxNotebookSizer
212//---------------------------------------------------------------------------
213
65e4f9b9
VS
214#if wxUSE_NOTEBOOK
215
83edc0a5
RR
216class WXDLLEXPORT wxNotebookSizer: public wxSizer
217{
218 DECLARE_CLASS(wxNotebookSizer);
219public:
220 wxNotebookSizer( wxNotebook *nb );
221
222 void RecalcSizes();
223 wxSize CalcMin();
224
225 wxNotebook *GetNotebook()
226 { return m_notebook; }
227
228protected:
229 wxNotebook *m_notebook;
230};
231
65e4f9b9
VS
232#endif
233
234
5279a24d
RR
235#endif
236 // __WXSIZER_H__