]>
git.saurik.com Git - wxWidgets.git/blob - src/univ/framuniv.cpp
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 m_frameMenuBar
->SetSize(0,
101 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
102 // the rest of the world!!!
103 GetClientSize().y
- heightMbar
,
107 GetClientSize().x
, heightMbar
);
111 void wxFrame::DetachMenuBar()
113 wxFrameBase::DetachMenuBar();
117 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
119 wxFrameBase::AttachMenuBar(menubar
);
123 #endif // wxUSE_MENUS
127 void wxFrame::PositionStatusBar()
129 if ( m_frameStatusBar
)
131 wxSize size
= GetClientSize();
132 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, -1);
136 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
137 wxWindowID id
, const wxString
& name
)
139 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
144 #endif // wxUSE_STATUSBAR
148 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
150 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
155 return m_frameToolBar
;
158 void wxFrame::PositionToolBar()
160 if ( m_frameToolBar
)
162 wxSize size
= GetClientSize();
166 m_frameToolBar
->GetSize(&tw
, &th
);
167 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
178 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
181 #endif // wxUSE_TOOLBAR
183 wxPoint
wxFrame::GetClientAreaOrigin() const
185 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
187 #if wxUSE_MENUS && !defined(__WXPM__)
188 if ( m_frameMenuBar
)
190 pt
.y
+= m_frameMenuBar
->GetSize().y
;
192 #endif // wxUSE_MENUS
195 if ( m_frameToolBar
)
197 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
198 pt
.x
+= m_frameToolBar
->GetSize().x
;
200 pt
.y
+= m_frameToolBar
->GetSize().y
;
202 #endif // wxUSE_TOOLBAR
207 void wxFrame::DoGetClientSize(int *width
, int *height
) const
209 wxFrameBase::DoGetClientSize(width
, height
);
212 if ( m_frameMenuBar
&& height
)
214 (*height
) -= m_frameMenuBar
->GetSize().y
;
216 #endif // wxUSE_MENUS
219 if ( m_frameStatusBar
&& height
)
221 (*height
) -= m_frameStatusBar
->GetSize().y
;
223 #endif // wxUSE_STATUSBAR
226 if ( m_frameToolBar
)
228 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
229 (*width
) -= m_frameToolBar
->GetSize().x
;
231 (*height
) -= m_frameToolBar
->GetSize().y
;
233 #endif // wxUSE_TOOLBAR
236 void wxFrame::DoSetClientSize(int width
, int height
)
239 if ( m_frameMenuBar
)
241 height
+= m_frameMenuBar
->GetSize().y
;
243 #endif // wxUSE_MENUS
246 if ( m_frameStatusBar
)
248 height
+= m_frameStatusBar
->GetSize().y
;
250 #endif // wxUSE_STATUSBAR
253 if ( m_frameToolBar
)
255 height
+= m_frameStatusBar
->GetSize().y
;
257 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
258 width
+= m_frameToolBar
->GetSize().x
;
260 height
+= m_frameToolBar
->GetSize().y
;
262 #endif // wxUSE_TOOLBAR
264 wxFrameBase::DoSetClientSize(width
, height
);
267 int wxFrame::GetMinWidth() const
270 if ( m_frameMenuBar
)
272 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth());
275 #endif // wxUSE_MENUS
276 return wxFrameBase::GetMinWidth();
279 int wxFrame::GetMinHeight() const
284 if ( m_frameMenuBar
)
286 height
+= m_frameMenuBar
->GetSize().y
;
288 #endif // wxUSE_MENUS
291 if ( m_frameToolBar
)
293 height
+= m_frameToolBar
->GetSize().y
;
295 #endif // wxUSE_TOOLBAR
298 if ( m_frameStatusBar
)
300 height
+= m_frameStatusBar
->GetSize().y
;
302 #endif // wxUSE_STATUSBAR
305 return height
+ wxMax(0, wxFrameBase::GetMinHeight());
307 return wxFrameBase::GetMinHeight();
310 bool wxFrame::Enable(bool enable
)
312 if (!wxFrameBase::Enable(enable
))
314 #ifdef __WXMICROWIN__
316 m_frameMenuBar
->Enable(enable
);