]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sizer.h
Bitmap and Image updates
[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
125 virtual void Prepend( wxWindow *window, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
126 virtual void Prepend( wxSizer *sizer, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
127 virtual void Prepend( int width, int height, int option = 0, int flag = 0, int border = 0, wxObject* userData = NULL );
128
42b4e99e
RR
129 virtual bool Remove( wxWindow *window );
130 virtual bool Remove( wxSizer *sizer );
131 virtual bool Remove( int pos );
0c0d686f 132
c62ac5b6 133 void SetDimension( int x, int y, int width, int height );
0c0d686f 134
5279a24d
RR
135 wxSize GetSize()
136 { return m_size; }
137 wxPoint GetPosition()
138 { return m_position; }
139 wxSize GetMinSize()
140 { return CalcMin(); }
c62ac5b6 141
5279a24d
RR
142 virtual void RecalcSizes() = 0;
143 virtual wxSize CalcMin() = 0;
0c0d686f 144
c62ac5b6 145 virtual void Layout();
5279a24d
RR
146
147 void Fit( wxWindow *window );
148 void SetSizeHints( wxWindow *window );
0c0d686f
RD
149
150 wxList& GetChildren()
151 { return m_children; }
152
c62ac5b6 153protected:
5279a24d
RR
154 wxSize m_size;
155 wxPoint m_position;
156 wxList m_children;
0c0d686f 157
5279a24d 158 wxSize GetMinWindowSize( wxWindow *window );
c62ac5b6
RR
159};
160
161//---------------------------------------------------------------------------
92afa2b1 162// wxBoxSizer
c62ac5b6
RR
163//---------------------------------------------------------------------------
164
92afa2b1 165class WXDLLEXPORT wxBoxSizer: public wxSizer
61d514bb 166{
0c0d686f 167 DECLARE_CLASS(wxBoxSizer);
61d514bb 168public:
92afa2b1 169 wxBoxSizer( int orient );
0c0d686f 170
61d514bb
RR
171 void RecalcSizes();
172 wxSize CalcMin();
0c0d686f 173
61d514bb
RR
174 int GetOrientation()
175 { return m_orient; }
0c0d686f 176
61d514bb
RR
177protected:
178 int m_orient;
179 int m_stretchable;
180 int m_minWidth;
181 int m_minHeight;
182 int m_fixedWidth;
183 int m_fixedHeight;
184};
0c0d686f 185
27ea1d8a
RR
186//---------------------------------------------------------------------------
187// wxStaticBoxSizer
188//---------------------------------------------------------------------------
189
190class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
191{
0c0d686f 192 DECLARE_CLASS(wxStaticBoxSizer);
27ea1d8a
RR
193public:
194 wxStaticBoxSizer( wxStaticBox *box, int orient );
0c0d686f 195
27ea1d8a
RR
196 void RecalcSizes();
197 wxSize CalcMin();
0c0d686f 198
27ea1d8a
RR
199 wxStaticBox *GetStaticBox()
200 { return m_staticBox; }
0c0d686f 201
27ea1d8a
RR
202protected:
203 wxStaticBox *m_staticBox;
204};
205
83edc0a5
RR
206//---------------------------------------------------------------------------
207// wxNotebookSizer
208//---------------------------------------------------------------------------
209
65e4f9b9
VS
210#if wxUSE_NOTEBOOK
211
83edc0a5
RR
212class WXDLLEXPORT wxNotebookSizer: public wxSizer
213{
214 DECLARE_CLASS(wxNotebookSizer);
215public:
216 wxNotebookSizer( wxNotebook *nb );
217
218 void RecalcSizes();
219 wxSize CalcMin();
220
221 wxNotebook *GetNotebook()
222 { return m_notebook; }
223
224protected:
225 wxNotebook *m_notebook;
226};
227
65e4f9b9
VS
228#endif
229
230
5279a24d
RR
231#endif
232 // __WXSIZER_H__