]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/sizer.h
removed wxITALIC/wxSLANT stuff from wxHTML (no longer neccessary, we have intelligent...
[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 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
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
133 virtual bool Remove( wxWindow *window );
134 virtual bool Remove( wxSizer *sizer );
135 virtual bool Remove( int pos );
136
137 void SetDimension( int x, int y, int width, int height );
138
139 wxSize GetSize()
140 { return m_size; }
141 wxPoint GetPosition()
142 { return m_position; }
143 wxSize GetMinSize()
144 { return CalcMin(); }
145
146 virtual void RecalcSizes() = 0;
147 virtual wxSize CalcMin() = 0;
148
149 virtual void Layout();
150
151 void Fit( wxWindow *window );
152 void SetSizeHints( wxWindow *window );
153
154 wxList& GetChildren()
155 { return m_children; }
156
157protected:
158 wxSize m_size;
159 wxPoint m_position;
160 wxList m_children;
161
162 wxSize GetMinWindowSize( wxWindow *window );
163};
164
165//---------------------------------------------------------------------------
166// wxBoxSizer
167//---------------------------------------------------------------------------
168
169class WXDLLEXPORT wxBoxSizer: public wxSizer
170{
171 DECLARE_CLASS(wxBoxSizer);
172public:
173 wxBoxSizer( int orient );
174
175 void RecalcSizes();
176 wxSize CalcMin();
177
178 int GetOrientation()
179 { return m_orient; }
180
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};
189
190//---------------------------------------------------------------------------
191// wxStaticBoxSizer
192//---------------------------------------------------------------------------
193
194class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
195{
196 DECLARE_CLASS(wxStaticBoxSizer);
197public:
198 wxStaticBoxSizer( wxStaticBox *box, int orient );
199
200 void RecalcSizes();
201 wxSize CalcMin();
202
203 wxStaticBox *GetStaticBox()
204 { return m_staticBox; }
205
206protected:
207 wxStaticBox *m_staticBox;
208};
209
210//---------------------------------------------------------------------------
211// wxNotebookSizer
212//---------------------------------------------------------------------------
213
214#if wxUSE_NOTEBOOK
215
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
232#endif
233
234
235#endif
236 // __WXSIZER_H__