1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: univ/frame.cpp
3 // Purpose: wxFrame class for wxUniversal
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
30 #include "wx/statusbr.h"
31 #include "wx/settings.h"
32 #include "wx/toolbar.h"
35 // ============================================================================
37 // ============================================================================
39 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
40 EVT_SIZE(wxFrame::OnSize
)
41 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
44 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
50 bool wxFrame::Create(wxWindow
*parent
,
52 const wxString
& title
,
58 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
61 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
66 // Responds to colour changes, and passes event on to children.
67 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
69 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
75 // ----------------------------------------------------------------------------
77 // ----------------------------------------------------------------------------
79 void wxFrame::OnSize(wxSizeEvent
& event
)
86 #endif // wxUSE_STATUSBAR
89 #endif // wxUSE_TOOLBAR
94 void wxFrame::SendSizeEvent()
96 wxSizeEvent
event(GetSize(), GetId());
97 event
.SetEventObject(this);
98 GetEventHandler()->ProcessEvent(event
);
103 void wxFrame::PositionMenuBar()
105 if ( m_frameMenuBar
)
107 // the menubar is positioned above the client size, hence the negative
109 wxCoord heightMbar
= m_frameMenuBar
->GetSize().y
;
111 wxCoord heightTbar
= 0;
114 if ( m_frameToolBar
)
115 heightTbar
= m_frameToolBar
->GetSize().y
;
116 #endif // wxUSE_TOOLBAR
118 m_frameMenuBar
->SetSize(0,
119 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
120 // the rest of the world!!!
121 GetClientSize().y
- heightMbar
- heightTbar
,
123 - (heightMbar
+ heightTbar
),
125 GetClientSize().x
, heightMbar
);
129 void wxFrame::DetachMenuBar()
131 wxFrameBase::DetachMenuBar();
135 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
137 wxFrameBase::AttachMenuBar(menubar
);
141 #endif // wxUSE_MENUS
145 void wxFrame::PositionStatusBar()
147 if ( m_frameStatusBar
)
149 wxSize size
= GetClientSize();
150 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, wxDefaultCoord
);
154 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
155 wxWindowID id
, const wxString
& name
)
157 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
162 #endif // wxUSE_STATUSBAR
166 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
168 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
173 return m_frameToolBar
;
176 void wxFrame::PositionToolBar()
178 if ( m_frameToolBar
)
180 wxSize size
= GetClientSize();
184 m_frameToolBar
->GetSize(&tw
, &th
);
185 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
196 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
199 #endif // wxUSE_TOOLBAR
201 wxPoint
wxFrame::GetClientAreaOrigin() const
203 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
205 #if wxUSE_MENUS && !defined(__WXPM__)
206 if ( m_frameMenuBar
)
208 pt
.y
+= m_frameMenuBar
->GetSize().y
;
210 #endif // wxUSE_MENUS
213 if ( m_frameToolBar
)
215 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
216 pt
.x
+= m_frameToolBar
->GetSize().x
;
218 pt
.y
+= m_frameToolBar
->GetSize().y
;
220 #endif // wxUSE_TOOLBAR
225 void wxFrame::DoGetClientSize(int *width
, int *height
) const
227 wxFrameBase::DoGetClientSize(width
, height
);
230 if ( m_frameMenuBar
&& height
)
232 (*height
) -= m_frameMenuBar
->GetSize().y
;
234 #endif // wxUSE_MENUS
237 if ( m_frameStatusBar
&& height
)
239 (*height
) -= m_frameStatusBar
->GetSize().y
;
241 #endif // wxUSE_STATUSBAR
244 if ( m_frameToolBar
)
246 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
247 (*width
) -= m_frameToolBar
->GetSize().x
;
249 (*height
) -= m_frameToolBar
->GetSize().y
;
251 #endif // wxUSE_TOOLBAR
254 void wxFrame::DoSetClientSize(int width
, int height
)
257 if ( m_frameMenuBar
)
259 height
+= m_frameMenuBar
->GetSize().y
;
261 #endif // wxUSE_MENUS
264 if ( m_frameStatusBar
)
266 height
+= m_frameStatusBar
->GetSize().y
;
268 #endif // wxUSE_STATUSBAR
271 if ( m_frameToolBar
)
274 height
+= m_frameStatusBar
->GetSize().y
;
275 #endif // wxUSE_STATUSBAR
277 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
278 width
+= m_frameToolBar
->GetSize().x
;
280 height
+= m_frameToolBar
->GetSize().y
;
282 #endif // wxUSE_TOOLBAR
284 wxFrameBase::DoSetClientSize(width
, height
);
287 int wxFrame::GetMinWidth() const
290 if ( m_frameMenuBar
)
292 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth());
295 #endif // wxUSE_MENUS
296 return wxFrameBase::GetMinWidth();
299 int wxFrame::GetMinHeight() const
304 if ( m_frameMenuBar
)
306 height
+= m_frameMenuBar
->GetSize().y
;
308 #endif // wxUSE_MENUS
311 if ( m_frameToolBar
)
313 height
+= m_frameToolBar
->GetSize().y
;
315 #endif // wxUSE_TOOLBAR
318 if ( m_frameStatusBar
)
320 height
+= m_frameStatusBar
->GetSize().y
;
322 #endif // wxUSE_STATUSBAR
325 return height
+ wxMax(0, wxFrameBase::GetMinHeight());
327 return wxFrameBase::GetMinHeight();
330 bool wxFrame::Enable(bool enable
)
332 if (!wxFrameBase::Enable(enable
))
334 #ifdef __WXMICROWIN__
336 m_frameMenuBar
->Enable(enable
);