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 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 bool wxFrame::Create(wxWindow
*parent
,
53 const wxString
& title
,
59 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
62 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
67 // Responds to colour changes, and passes event on to children.
68 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
70 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
76 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
80 void wxFrame::OnSize(wxSizeEvent
& event
)
87 #endif // wxUSE_STATUSBAR
90 #endif // wxUSE_TOOLBAR
97 void wxFrame::PositionMenuBar()
101 // the menubar is positioned above the client size, hence the negative
103 wxCoord heightMbar
= m_frameMenuBar
->GetSize().y
;
105 wxCoord heightTbar
= 0;
108 if ( m_frameToolBar
)
109 heightTbar
= m_frameToolBar
->GetSize().y
;
110 #endif // wxUSE_TOOLBAR
112 m_frameMenuBar
->SetSize(0,
113 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
114 // the rest of the world!!!
115 GetClientSize().y
- heightMbar
- heightTbar
,
117 - (heightMbar
+ heightTbar
),
119 GetClientSize().x
, heightMbar
);
123 void wxFrame::DetachMenuBar()
125 wxFrameBase::DetachMenuBar();
129 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
131 wxFrameBase::AttachMenuBar(menubar
);
135 #endif // wxUSE_MENUS
139 void wxFrame::PositionStatusBar()
141 if ( m_frameStatusBar
)
143 wxSize size
= GetClientSize();
144 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, wxDefaultCoord
);
148 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
149 wxWindowID id
, const wxString
& name
)
151 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
156 #endif // wxUSE_STATUSBAR
160 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
162 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
167 return m_frameToolBar
;
170 void wxFrame::PositionToolBar()
172 if ( m_frameToolBar
)
174 wxSize size
= GetClientSize();
178 m_frameToolBar
->GetSize(&tw
, &th
);
179 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
190 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
193 #endif // wxUSE_TOOLBAR
195 wxPoint
wxFrame::GetClientAreaOrigin() const
197 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
199 #if wxUSE_MENUS && !defined(__WXPM__)
200 if ( m_frameMenuBar
)
202 pt
.y
+= m_frameMenuBar
->GetSize().y
;
204 #endif // wxUSE_MENUS
207 if ( m_frameToolBar
)
209 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
210 pt
.x
+= m_frameToolBar
->GetSize().x
;
212 pt
.y
+= m_frameToolBar
->GetSize().y
;
214 #endif // wxUSE_TOOLBAR
219 void wxFrame::DoGetClientSize(int *width
, int *height
) const
221 wxFrameBase::DoGetClientSize(width
, height
);
224 if ( m_frameMenuBar
&& height
)
226 (*height
) -= m_frameMenuBar
->GetSize().y
;
228 #endif // wxUSE_MENUS
231 if ( m_frameStatusBar
&& height
)
233 (*height
) -= m_frameStatusBar
->GetSize().y
;
235 #endif // wxUSE_STATUSBAR
238 if ( m_frameToolBar
)
240 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
241 (*width
) -= m_frameToolBar
->GetSize().x
;
243 (*height
) -= m_frameToolBar
->GetSize().y
;
245 #endif // wxUSE_TOOLBAR
248 void wxFrame::DoSetClientSize(int width
, int height
)
251 if ( m_frameMenuBar
)
253 height
+= m_frameMenuBar
->GetSize().y
;
255 #endif // wxUSE_MENUS
258 if ( m_frameStatusBar
)
260 height
+= m_frameStatusBar
->GetSize().y
;
262 #endif // wxUSE_STATUSBAR
265 if ( m_frameToolBar
)
268 height
+= m_frameStatusBar
->GetSize().y
;
269 #endif // wxUSE_STATUSBAR
271 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
272 width
+= m_frameToolBar
->GetSize().x
;
274 height
+= m_frameToolBar
->GetSize().y
;
276 #endif // wxUSE_TOOLBAR
278 wxFrameBase::DoSetClientSize(width
, height
);
281 wxSize
wxFrame::GetMinSize() const
283 wxSize size
= wxFrameBase::GetMinSize();
286 if ( m_frameMenuBar
)
288 const wxSize sizeMenu
= m_frameMenuBar
->GetBestSize();
289 if ( sizeMenu
.x
> size
.x
)
291 size
.y
+= sizeMenu
.y
;
293 #endif // wxUSE_MENUS
296 if ( m_frameToolBar
)
298 size
.y
+= m_frameToolBar
->GetSize().y
;
300 #endif // wxUSE_TOOLBAR
303 if ( m_frameStatusBar
)
305 size
.y
+= m_frameStatusBar
->GetSize().y
;
307 #endif // wxUSE_STATUSBAR
312 bool wxFrame::Enable(bool enable
)
314 if (!wxFrameBase::Enable(enable
))
316 #ifdef __WXMICROWIN__
318 m_frameMenuBar
->Enable(enable
);