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 // ---------------------------------------------------------------------------
21 #pragma implementation "univframe.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/statusbr.h"
35 #include "wx/toolbar.h"
38 // ============================================================================
40 // ============================================================================
42 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
43 EVT_SIZE(wxFrame
::OnSize
)
46 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 bool wxFrame
::Create(wxWindow
*parent
,
54 const wxString
& title
,
60 return wxTopLevelWindow
::Create(parent
, id
, title
, pos
, size
, style
, name
);
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 void wxFrame
::OnSize(wxSizeEvent
& event
)
75 #endif // wxUSE_STATUSBAR
78 #endif // wxUSE_TOOLBAR
83 void wxFrame
::SendSizeEvent()
85 wxSizeEvent
event(GetSize(), GetId());
86 event
.SetEventObject(this);
87 GetEventHandler()->ProcessEvent(event
);
92 void wxFrame
::PositionMenuBar()
96 // the menubar is positioned above the client size, hence the negative
98 wxCoord heightMbar
= m_frameMenuBar
->GetSize().y
;
100 wxCoord heightTbar
= 0;
101 // In between sits the toolbar
103 heightTbar
= m_frameToolBar
->GetSize().y
;
105 m_frameMenuBar
->SetSize(0,
106 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
107 // the rest of the world!!!
108 GetClientSize().y
- heightMbar
,
110 - heightMbar
- heightTbar
,
112 GetClientSize().x
, heightMbar
);
116 void wxFrame
::DetachMenuBar()
118 wxFrameBase
::DetachMenuBar();
122 void wxFrame
::AttachMenuBar(wxMenuBar
*menubar
)
124 wxFrameBase
::AttachMenuBar(menubar
);
128 #endif // wxUSE_MENUS
132 void wxFrame
::PositionStatusBar()
134 if ( m_frameStatusBar
)
136 wxSize size
= GetClientSize();
137 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, -1);
141 wxStatusBar
* wxFrame
::CreateStatusBar(int number
, long style
,
142 wxWindowID id
, const wxString
& name
)
144 wxStatusBar
*bar
= wxFrameBase
::CreateStatusBar(number
, style
, id
, name
);
149 #endif // wxUSE_STATUSBAR
153 wxToolBar
* wxFrame
::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
155 if ( wxFrameBase
::CreateToolBar(style
, id
, name
) )
160 return m_frameToolBar
;
163 void wxFrame
::PositionToolBar()
165 if ( m_frameToolBar
)
167 wxSize size
= GetClientSize();
171 m_frameToolBar
->GetSize(&tw
, &th
);
172 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
183 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
186 #endif // wxUSE_TOOLBAR
188 wxPoint wxFrame
::GetClientAreaOrigin() const
190 wxPoint pt
= wxFrameBase
::GetClientAreaOrigin();
192 #if wxUSE_MENUS && !defined(__WXPM__)
193 if ( m_frameMenuBar
)
195 pt
.y
+= m_frameMenuBar
->GetSize().y
;
197 #endif // wxUSE_MENUS
199 // This is done in wxFrameBase already
200 #if 0 // wxUSE_TOOLBAR
201 if ( m_frameToolBar
)
203 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
204 pt
.x
+= m_frameToolBar
->GetSize().x
;
206 pt
.y
+= m_frameToolBar
->GetSize().y
;
208 #endif // wxUSE_TOOLBAR
213 void wxFrame
::DoGetClientSize(int *width
, int *height
) const
215 wxFrameBase
::DoGetClientSize(width
, height
);
218 if ( m_frameMenuBar
&& height
)
220 (*height
) -= m_frameMenuBar
->GetSize().y
;
222 #endif // wxUSE_MENUS
225 if ( m_frameStatusBar
&& height
)
227 (*height
) -= m_frameStatusBar
->GetSize().y
;
229 #endif // wxUSE_STATUSBAR
232 if ( m_frameToolBar
)
234 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
235 (*width
) -= m_frameToolBar
->GetSize().x
;
237 (*height
) -= m_frameToolBar
->GetSize().y
;
239 #endif // wxUSE_TOOLBAR
242 void wxFrame
::DoSetClientSize(int width
, int height
)
245 if ( m_frameMenuBar
)
247 height
+= m_frameMenuBar
->GetSize().y
;
249 #endif // wxUSE_MENUS
252 if ( m_frameStatusBar
)
254 height
+= m_frameStatusBar
->GetSize().y
;
256 #endif // wxUSE_STATUSBAR
259 if ( m_frameToolBar
)
261 height
+= m_frameStatusBar
->GetSize().y
;
263 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
264 width
+= m_frameToolBar
->GetSize().x
;
266 height
+= m_frameToolBar
->GetSize().y
;
268 #endif // wxUSE_TOOLBAR
270 wxFrameBase
::DoSetClientSize(width
, height
);
273 int wxFrame
::GetMinWidth() const
276 if ( m_frameMenuBar
)
278 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase
::GetMinWidth());
281 #endif // wxUSE_MENUS
282 return wxFrameBase
::GetMinWidth();
285 int wxFrame
::GetMinHeight() const
290 if ( m_frameMenuBar
)
292 height
+= m_frameMenuBar
->GetSize().y
;
294 #endif // wxUSE_MENUS
297 if ( m_frameToolBar
)
299 height
+= m_frameToolBar
->GetSize().y
;
301 #endif // wxUSE_TOOLBAR
304 if ( m_frameStatusBar
)
306 height
+= m_frameStatusBar
->GetSize().y
;
308 #endif // wxUSE_STATUSBAR
311 return height
+ wxMax(0, wxFrameBase
::GetMinHeight());
313 return wxFrameBase
::GetMinHeight();
316 bool wxFrame
::Enable(bool enable
)
318 if (!wxFrameBase
::Enable(enable
))
320 #ifdef __WXMICROWIN__
322 m_frameMenuBar
->Enable(enable
);