1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/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"
31 #include "wx/statusbr.h"
32 #include "wx/settings.h"
33 #include "wx/toolbar.h"
36 // ============================================================================
38 // ============================================================================
40 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
41 EVT_SIZE(wxFrame::OnSize
)
42 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 bool wxFrame::Create(wxWindow
*parent
,
51 const wxString
& title
,
57 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
60 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
65 // Responds to colour changes, and passes event on to children.
66 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
68 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 void wxFrame::OnSize(wxSizeEvent
& event
)
85 #endif // wxUSE_STATUSBAR
88 #endif // wxUSE_TOOLBAR
95 void wxFrame::PositionMenuBar()
99 // the menubar is positioned above the client size, hence the negative
101 wxCoord heightMbar
= m_frameMenuBar
->GetSize().y
;
103 wxCoord heightTbar
= 0;
106 if ( m_frameToolBar
)
107 heightTbar
= m_frameToolBar
->GetSize().y
;
108 #endif // wxUSE_TOOLBAR
110 m_frameMenuBar
->SetSize(0,
111 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
112 // the rest of the world!!!
113 GetClientSize().y
- heightMbar
- heightTbar
,
115 - (heightMbar
+ heightTbar
),
117 GetClientSize().x
, heightMbar
);
121 void wxFrame::DetachMenuBar()
123 wxFrameBase::DetachMenuBar();
127 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
129 wxFrameBase::AttachMenuBar(menubar
);
133 #endif // wxUSE_MENUS
137 void wxFrame::PositionStatusBar()
139 if ( m_frameStatusBar
)
141 wxSize size
= GetClientSize();
142 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, wxDefaultCoord
);
146 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
147 wxWindowID id
, const wxString
& name
)
149 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
154 #endif // wxUSE_STATUSBAR
158 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
160 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
165 return m_frameToolBar
;
168 void wxFrame::PositionToolBar()
170 if ( m_frameToolBar
)
172 wxSize size
= GetClientSize();
176 m_frameToolBar
->GetSize(&tw
, &th
);
177 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
188 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
191 #endif // wxUSE_TOOLBAR
193 wxPoint
wxFrame::GetClientAreaOrigin() const
195 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
197 #if wxUSE_MENUS && !defined(__WXPM__)
198 if ( m_frameMenuBar
)
200 pt
.y
+= m_frameMenuBar
->GetSize().y
;
202 #endif // wxUSE_MENUS
205 if ( m_frameToolBar
)
207 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
208 pt
.x
+= m_frameToolBar
->GetSize().x
;
210 pt
.y
+= m_frameToolBar
->GetSize().y
;
212 #endif // wxUSE_TOOLBAR
217 void wxFrame::DoGetClientSize(int *width
, int *height
) const
219 wxFrameBase::DoGetClientSize(width
, height
);
222 if ( m_frameMenuBar
&& height
)
224 (*height
) -= m_frameMenuBar
->GetSize().y
;
226 #endif // wxUSE_MENUS
229 if ( m_frameStatusBar
&& height
)
231 (*height
) -= m_frameStatusBar
->GetSize().y
;
233 #endif // wxUSE_STATUSBAR
236 if ( m_frameToolBar
)
238 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
239 (*width
) -= m_frameToolBar
->GetSize().x
;
241 (*height
) -= m_frameToolBar
->GetSize().y
;
243 #endif // wxUSE_TOOLBAR
246 void wxFrame::DoSetClientSize(int width
, int height
)
249 if ( m_frameMenuBar
)
251 height
+= m_frameMenuBar
->GetSize().y
;
253 #endif // wxUSE_MENUS
256 if ( m_frameStatusBar
)
258 height
+= m_frameStatusBar
->GetSize().y
;
260 #endif // wxUSE_STATUSBAR
263 if ( m_frameToolBar
)
266 height
+= m_frameStatusBar
->GetSize().y
;
267 #endif // wxUSE_STATUSBAR
269 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
270 width
+= m_frameToolBar
->GetSize().x
;
272 height
+= m_frameToolBar
->GetSize().y
;
274 #endif // wxUSE_TOOLBAR
276 wxFrameBase::DoSetClientSize(width
, height
);
279 wxSize
wxFrame::GetMinSize() const
281 wxSize size
= wxFrameBase::GetMinSize();
284 if ( m_frameMenuBar
)
286 const wxSize sizeMenu
= m_frameMenuBar
->GetBestSize();
287 if ( sizeMenu
.x
> size
.x
)
289 size
.y
+= sizeMenu
.y
;
291 #endif // wxUSE_MENUS
294 if ( m_frameToolBar
)
296 size
.y
+= m_frameToolBar
->GetSize().y
;
298 #endif // wxUSE_TOOLBAR
301 if ( m_frameStatusBar
)
303 size
.y
+= m_frameStatusBar
->GetSize().y
;
305 #endif // wxUSE_STATUSBAR
310 bool wxFrame::Enable(bool enable
)
312 if (!wxFrameBase::Enable(enable
))
314 #ifdef __WXMICROWIN__
316 m_frameMenuBar
->Enable(enable
);