]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: sizer.h | |
3 | // Purpose: provide wxSizer class for layounting | |
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 | ||
29 | class wxStaticBox; | |
30 | ||
31 | class wxSizerItem; | |
32 | class wxSizer; | |
33 | class wxBoxSizer; | |
34 | class wxStaticBoxSizer; | |
35 | ||
36 | //--------------------------------------------------------------------------- | |
37 | // wxSizerItem | |
38 | //--------------------------------------------------------------------------- | |
39 | ||
40 | class WXDLLEXPORT wxSizerItem: public wxObject | |
41 | { | |
42 | public: | |
43 | // spacer | |
44 | wxSizerItem( int width, int height, int option, int flag, int border ); | |
45 | ||
46 | // window | |
47 | wxSizerItem( wxWindow *window, int option, int flag, int border ); | |
48 | ||
49 | // subsizer | |
50 | wxSizerItem( wxSizer *sizer, int option, int flag, int border ); | |
51 | ||
52 | virtual wxSize GetSize(); | |
53 | virtual wxSize CalcMin(); | |
54 | virtual void SetDimension( wxPoint pos, wxSize size ); | |
55 | ||
56 | bool IsWindow(); | |
57 | bool IsSizer(); | |
58 | bool IsSpacer(); | |
59 | ||
60 | wxWindow *GetWindow() const | |
61 | { return m_window; } | |
62 | wxSizer *GetSizer() const | |
63 | { return m_sizer; } | |
64 | int GetOption() const | |
65 | { return m_option; } | |
66 | int GetFlag() const | |
67 | { return m_flag; } | |
68 | int GetBorder() const | |
69 | { return m_border; } | |
70 | ||
71 | protected: | |
72 | wxWindow *m_window; | |
73 | wxSizer *m_sizer; | |
74 | wxSize m_size; | |
75 | wxSize m_minSize; | |
76 | int m_option; | |
77 | int m_border; | |
78 | int m_flag; | |
79 | }; | |
80 | ||
81 | //--------------------------------------------------------------------------- | |
82 | // wxSizer | |
83 | //--------------------------------------------------------------------------- | |
84 | ||
85 | class WXDLLEXPORT wxSizer: public wxObject | |
86 | { | |
87 | public: | |
88 | wxSizer(); | |
89 | ~wxSizer(); | |
90 | ||
91 | virtual void Add( wxWindow *window, int option = 0, int flag = 0, int border = 0 ); | |
92 | virtual void Add( wxSizer *sizer, int option = 0, int flag = 0, int border = 0 ); | |
93 | virtual void Add( int width, int height, int option = 0, int flag = 0, int border = 0 ); | |
94 | ||
95 | void SetDimension( int x, int y, int width, int height ); | |
96 | ||
97 | wxSize GetSize() | |
98 | { return m_size; } | |
99 | wxPoint GetPosition() | |
100 | { return m_position; } | |
101 | wxSize GetMinSize() | |
102 | { return CalcMin(); } | |
103 | ||
104 | virtual void RecalcSizes() = 0; | |
105 | virtual wxSize CalcMin() = 0; | |
106 | ||
107 | virtual void Layout(); | |
108 | ||
109 | void Fit( wxWindow *window ); | |
110 | void SetSizeHints( wxWindow *window ); | |
111 | ||
112 | protected: | |
113 | wxSize m_size; | |
114 | wxPoint m_position; | |
115 | wxList m_children; | |
116 | ||
117 | wxSize GetMinWindowSize( wxWindow *window ); | |
118 | }; | |
119 | ||
120 | //--------------------------------------------------------------------------- | |
121 | // wxBoxSizer | |
122 | //--------------------------------------------------------------------------- | |
123 | ||
124 | class WXDLLEXPORT wxBoxSizer: public wxSizer | |
125 | { | |
126 | public: | |
127 | wxBoxSizer( int orient ); | |
128 | ||
129 | void RecalcSizes(); | |
130 | wxSize CalcMin(); | |
131 | ||
132 | int GetOrientation() | |
133 | { return m_orient; } | |
134 | ||
135 | protected: | |
136 | int m_orient; | |
137 | int m_stretchable; | |
138 | int m_minWidth; | |
139 | int m_minHeight; | |
140 | int m_fixedWidth; | |
141 | int m_fixedHeight; | |
142 | }; | |
143 | ||
144 | //--------------------------------------------------------------------------- | |
145 | // wxStaticBoxSizer | |
146 | //--------------------------------------------------------------------------- | |
147 | ||
148 | class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer | |
149 | { | |
150 | public: | |
151 | wxStaticBoxSizer( wxStaticBox *box, int orient ); | |
152 | ||
153 | void RecalcSizes(); | |
154 | wxSize CalcMin(); | |
155 | ||
156 | wxStaticBox *GetStaticBox() | |
157 | { return m_staticBox; } | |
158 | ||
159 | protected: | |
160 | wxStaticBox *m_staticBox; | |
161 | }; | |
162 | ||
163 | #endif | |
164 | // __WXSIZER_H__ |