]> git.saurik.com Git - wxWidgets.git/blame - src/univ/framuniv.cpp
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / src / univ / framuniv.cpp
CommitLineData
1e6feb95 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/univ/framuniv.cpp
1e6feb95
VZ
3// Purpose: wxFrame class for wxUniversal
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 19.05.01
442b35b5 7// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 8// Licence: wxWindows licence
1e6feb95
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11// ===========================================================================
12// declarations
13// ===========================================================================
14
15// ---------------------------------------------------------------------------
16// headers
17// ---------------------------------------------------------------------------
18
1e6feb95
VZ
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
76b49cf4
WS
26#include "wx/frame.h"
27
1e6feb95 28#ifndef WX_PRECOMP
76b49cf4 29 #include "wx/menu.h"
d08e6e59 30 #include "wx/statusbr.h"
afad4a88 31 #include "wx/settings.h"
443aec6f 32 #include "wx/toolbar.h"
1e6feb95
VZ
33#endif // WX_PRECOMP
34
35// ============================================================================
36// implementation
37// ============================================================================
38
d9d4df0e 39BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
1e6feb95 40 EVT_SIZE(wxFrame::OnSize)
afad4a88 41 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
1e6feb95
VZ
42END_EVENT_TABLE()
43
1e6feb95
VZ
44// ----------------------------------------------------------------------------
45// ctors
46// ----------------------------------------------------------------------------
47
d9d4df0e 48bool wxFrame::Create(wxWindow *parent,
9a6384ca
WS
49 wxWindowID id,
50 const wxString& title,
51 const wxPoint& pos,
52 const wxSize& size,
53 long style,
54 const wxString& name)
1e6feb95 55{
afad4a88
VZ
56 if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
57 return false;
58
59 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
60
61 return true;
1e6feb95
VZ
62}
63
afad4a88
VZ
64// Responds to colour changes, and passes event on to children.
65void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
66{
67 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
68 Refresh();
69
70 event.Skip();
71}
d9d4df0e 72
1e6feb95 73// ----------------------------------------------------------------------------
3379ed37 74// menu support
1e6feb95
VZ
75// ----------------------------------------------------------------------------
76
77void wxFrame::OnSize(wxSizeEvent& event)
78{
3379ed37 79#if wxUSE_MENUS
1e6feb95 80 PositionMenuBar();
54800df8 81#endif // wxUSE_MENUS
d08e6e59
VS
82#if wxUSE_STATUSBAR
83 PositionStatusBar();
84#endif // wxUSE_STATUSBAR
443aec6f
VS
85#if wxUSE_TOOLBAR
86 PositionToolBar();
87#endif // wxUSE_TOOLBAR
1e6feb95
VZ
88
89 event.Skip();
90}
91
3379ed37
VZ
92#if wxUSE_MENUS
93
1e6feb95
VZ
94void wxFrame::PositionMenuBar()
95{
1e6feb95
VZ
96 if ( m_frameMenuBar )
97 {
98 // the menubar is positioned above the client size, hence the negative
99 // y coord
75c9da25 100 wxCoord heightMbar = m_frameMenuBar->GetSize().y;
16c9a425 101
d1017acf 102 wxCoord heightTbar = 0;
6a317e61
VZ
103
104#if wxUSE_TOOLBAR
105 if ( m_frameToolBar )
d1017acf 106 heightTbar = m_frameToolBar->GetSize().y;
6a317e61 107#endif // wxUSE_TOOLBAR
e5053ade 108
6a317e61 109 m_frameMenuBar->SetSize(0,
a290fa5a 110#ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
443aec6f 111 // the rest of the world!!!
16c9a425 112 GetClientSize().y - heightMbar - heightTbar,
19193a2c 113#else
16c9a425 114 - (heightMbar + heightTbar),
6a317e61 115#endif
75c9da25 116 GetClientSize().x, heightMbar);
1e6feb95 117 }
1e6feb95 118}
75c9da25 119
6821401b
VS
120void wxFrame::DetachMenuBar()
121{
122 wxFrameBase::DetachMenuBar();
123 SendSizeEvent();
124}
125
126void wxFrame::AttachMenuBar(wxMenuBar *menubar)
127{
128 wxFrameBase::AttachMenuBar(menubar);
129 SendSizeEvent();
130}
131
3379ed37
VZ
132#endif // wxUSE_MENUS
133
d08e6e59
VS
134#if wxUSE_STATUSBAR
135
136void wxFrame::PositionStatusBar()
137{
138 if ( m_frameStatusBar )
139 {
71e03035 140 wxSize size = GetClientSize();
a290fa5a 141 m_frameStatusBar->SetSize(0, size.y, size.x, wxDefaultCoord);
d08e6e59
VS
142 }
143}
144
6821401b
VS
145wxStatusBar* wxFrame::CreateStatusBar(int number, long style,
146 wxWindowID id, const wxString& name)
147{
148 wxStatusBar *bar = wxFrameBase::CreateStatusBar(number, style, id, name);
149 SendSizeEvent();
150 return bar;
151}
152
d08e6e59
VS
153#endif // wxUSE_STATUSBAR
154
443aec6f
VS
155#if wxUSE_TOOLBAR
156
157wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
158{
159 if ( wxFrameBase::CreateToolBar(style, id, name) )
160 {
161 PositionToolBar();
162 }
163
164 return m_frameToolBar;
165}
166
167void wxFrame::PositionToolBar()
168{
169 if ( m_frameToolBar )
170 {
171 wxSize size = GetClientSize();
172 int tw, th, tx, ty;
173
174 tx = ty = 0;
175 m_frameToolBar->GetSize(&tw, &th);
176 if ( m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL )
177 {
178 tx = -tw;
179 th = size.y;
180 }
181 else
182 {
183 ty = -th;
184 tw = size.x;
185 }
186
187 m_frameToolBar->SetSize(tx, ty, tw, th);
188 }
189}
190#endif // wxUSE_TOOLBAR
191
1e6feb95
VZ
192wxPoint wxFrame::GetClientAreaOrigin() const
193{
d9d4df0e 194 wxPoint pt = wxFrameBase::GetClientAreaOrigin();
1e6feb95 195
19193a2c 196#if wxUSE_MENUS && !defined(__WXPM__)
1e6feb95
VZ
197 if ( m_frameMenuBar )
198 {
199 pt.y += m_frameMenuBar->GetSize().y;
200 }
201#endif // wxUSE_MENUS
202
5e885a58 203#if wxUSE_TOOLBAR
443aec6f
VS
204 if ( m_frameToolBar )
205 {
206 if ( m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL )
207 pt.x += m_frameToolBar->GetSize().x;
208 else
209 pt.y += m_frameToolBar->GetSize().y;
210 }
211#endif // wxUSE_TOOLBAR
212
1e6feb95
VZ
213 return pt;
214}
215
a9152a05
VS
216void wxFrame::DoGetClientSize(int *width, int *height) const
217{
218 wxFrameBase::DoGetClientSize(width, height);
d08e6e59 219
a9152a05
VS
220#if wxUSE_MENUS
221 if ( m_frameMenuBar && height )
222 {
223 (*height) -= m_frameMenuBar->GetSize().y;
224 }
225#endif // wxUSE_MENUS
d08e6e59
VS
226
227#if wxUSE_STATUSBAR
228 if ( m_frameStatusBar && height )
229 {
230 (*height) -= m_frameStatusBar->GetSize().y;
231 }
232#endif // wxUSE_STATUSBAR
443aec6f
VS
233
234#if wxUSE_TOOLBAR
235 if ( m_frameToolBar )
236 {
237 if ( width && (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) )
238 (*width) -= m_frameToolBar->GetSize().x;
239 else if ( height )
240 (*height) -= m_frameToolBar->GetSize().y;
241 }
242#endif // wxUSE_TOOLBAR
a9152a05
VS
243}
244
245void wxFrame::DoSetClientSize(int width, int height)
246{
247#if wxUSE_MENUS
248 if ( m_frameMenuBar )
249 {
250 height += m_frameMenuBar->GetSize().y;
251 }
252#endif // wxUSE_MENUS
d08e6e59
VS
253
254#if wxUSE_STATUSBAR
255 if ( m_frameStatusBar )
256 {
257 height += m_frameStatusBar->GetSize().y;
258 }
259#endif // wxUSE_STATUSBAR
260
443aec6f
VS
261#if wxUSE_TOOLBAR
262 if ( m_frameToolBar )
263 {
443aec6f
VS
264 if ( m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL )
265 width += m_frameToolBar->GetSize().x;
266 else
267 height += m_frameToolBar->GetSize().y;
268 }
269#endif // wxUSE_TOOLBAR
270
a9152a05
VS
271 wxFrameBase::DoSetClientSize(width, height);
272}
273
894057d1 274wxSize wxFrame::GetMinSize() const
e7dda1ff 275{
894057d1 276 wxSize size = wxFrameBase::GetMinSize();
e7dda1ff
VS
277
278#if wxUSE_MENUS
279 if ( m_frameMenuBar )
280 {
894057d1
VZ
281 const wxSize sizeMenu = m_frameMenuBar->GetBestSize();
282 if ( sizeMenu.x > size.x )
283 size.x = sizeMenu.x;
284 size.y += sizeMenu.y;
e7dda1ff
VS
285 }
286#endif // wxUSE_MENUS
287
288#if wxUSE_TOOLBAR
289 if ( m_frameToolBar )
290 {
894057d1 291 size.y += m_frameToolBar->GetSize().y;
e7dda1ff
VS
292 }
293#endif // wxUSE_TOOLBAR
294
295#if wxUSE_STATUSBAR
296 if ( m_frameStatusBar )
297 {
894057d1 298 size.y += m_frameStatusBar->GetSize().y;
e7dda1ff
VS
299 }
300#endif // wxUSE_STATUSBAR
6a317e61 301
894057d1 302 return size;
e7dda1ff
VS
303}
304
d9d4df0e 305bool wxFrame::Enable(bool enable)
98363307 306{
d9d4df0e 307 if (!wxFrameBase::Enable(enable))
a290fa5a 308 return false;
98363307
JS
309#ifdef __WXMICROWIN__
310 if (m_frameMenuBar)
311 m_frameMenuBar->Enable(enable);
312#endif
a290fa5a 313 return true;
98363307 314}