]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/sizer.h
Bitmap and Image updates
[wxWidgets.git] / include / wx / sizer.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: sizer.h
3// Purpose: provide wxSizer class for layouting
4// Author: Robert Roebling and Robin Dunn
5// Modified by:
6// Created:
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
29class wxStaticBox;
30class wxNotebook;
31
32class wxSizerItem;
33class wxSizer;
34class wxBoxSizer;
35class wxStaticBoxSizer;
36
37//---------------------------------------------------------------------------
38// wxSizerItem
39//---------------------------------------------------------------------------
40
41class WXDLLEXPORT wxSizerItem: public wxObject
42{
43 DECLARE_CLASS(wxSizerItem);
44public:
45 // spacer
46 wxSizerItem( int width, int height, int option, int flag, int border, wxObject* userData);
47
48 // window
49 wxSizerItem( wxWindow *window, int option, int flag, int border, wxObject* userData );
50
51 // subsizer
52 wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxObject* userData );
53
54 ~wxSizerItem();
55
56 virtual wxSize GetSize();
57 virtual wxSize CalcMin();
58 virtual void SetDimension( wxPoint pos, wxSize size );
59
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
69 bool IsWindow();
70 bool IsSizer();
71 bool IsSpacer();
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; }
81
82 wxWindow *GetWindow() const
83 { return m_window; }
84 wxSizer *GetSizer() const
85 { return m_sizer; }
86 int GetOption() const
87 { return m_option; }
88 int GetFlag() const
89 { return m_flag; }
90 int GetBorder() const
91 { return m_border; }
92 wxObject* GetUserData()
93 { return m_userData; }
94
95protected:
96 wxWindow *m_window;
97 wxSizer *m_sizer;
98 wxSize m_size;
99 wxSize m_minSize;
100 int m_option;
101 int m_border;
102 int m_flag;
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;
107 wxObject *m_userData;
108};
109
110//---------------------------------------------------------------------------
111// wxSizer
112//---------------------------------------------------------------------------
113
114class WXDLLEXPORT wxSizer: public wxObject
115{
116 DECLARE_CLASS(wxSizer);
117public:
118 wxSizer();
119 ~wxSizer();
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
129 virtual bool Remove( wxWindow *window );
130 virtual bool Remove( wxSizer *sizer );
131 virtual bool Remove( int pos );
132
133 void SetDimension( int x, int y, int width, int height );
134
135 wxSize GetSize()
136 { return m_size; }
137 wxPoint GetPosition()
138 { return m_position; }
139 wxSize GetMinSize()
140 { return CalcMin(); }
141
142 virtual void RecalcSizes() = 0;
143 virtual wxSize CalcMin() = 0;
144
145 virtual void Layout();
146
147 void Fit( wxWindow *window );
148 void SetSizeHints( wxWindow *window );
149
150 wxList& GetChildren()
151 { return m_children; }
152
153protected:
154 wxSize m_size;
155 wxPoint m_position;
156 wxList m_children;
157
158 wxSize GetMinWindowSize( wxWindow *window );
159};
160
161//---------------------------------------------------------------------------
162// wxBoxSizer
163//---------------------------------------------------------------------------
164
165class WXDLLEXPORT wxBoxSizer: public wxSizer
166{
167 DECLARE_CLASS(wxBoxSizer);
168public:
169 wxBoxSizer( int orient );
170
171 void RecalcSizes();
172 wxSize CalcMin();
173
174 int GetOrientation()
175 { return m_orient; }
176
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};
185
186//---------------------------------------------------------------------------
187// wxStaticBoxSizer
188//---------------------------------------------------------------------------
189
190class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
191{
192 DECLARE_CLASS(wxStaticBoxSizer);
193public:
194 wxStaticBoxSizer( wxStaticBox *box, int orient );
195
196 void RecalcSizes();
197 wxSize CalcMin();
198
199 wxStaticBox *GetStaticBox()
200 { return m_staticBox; }
201
202protected:
203 wxStaticBox *m_staticBox;
204};
205
206//---------------------------------------------------------------------------
207// wxNotebookSizer
208//---------------------------------------------------------------------------
209
210#if wxUSE_NOTEBOOK
211
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
228#endif
229
230
231#endif
232 // __WXSIZER_H__