]>
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 // ---------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 // ----------------------------------------------------------------------------
56 wxFrame::wxFrame(wxWindow
*parent
,
58 const wxString
& title
,
64 Create(parent
, id
, title
, pos
, size
, style
, name
);
67 bool wxFrame::Create(wxWindow
*parent
,
69 const wxString
& title
,
75 return wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
);
79 // ----------------------------------------------------------------------------
81 // ----------------------------------------------------------------------------
83 void wxFrame::OnSize(wxSizeEvent
& event
)
90 #endif // wxUSE_STATUSBAR
93 #endif // wxUSE_TOOLBAR
98 void wxFrame::SendSizeEvent()
100 wxSizeEvent
event(GetSize(), GetId());
101 event
.SetEventObject(this);
102 GetEventHandler()->ProcessEvent(event
);
107 void wxFrame::PositionMenuBar()
109 if ( m_frameMenuBar
)
111 // the menubar is positioned above the client size, hence the negative
113 wxCoord heightMbar
= m_frameMenuBar
->GetSize().y
;
115 wxCoord heightTbar
= 0;
118 if ( m_frameToolBar
)
119 heightTbar
= m_frameToolBar
->GetSize().y
;
120 #endif // wxUSE_TOOLBAR
122 m_frameMenuBar
->SetSize(0,
123 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
124 // the rest of the world!!!
125 GetClientSize().y
- heightMbar
- heightTbar
,
127 - (heightMbar
+ heightTbar
),
129 GetClientSize().x
, heightMbar
);
133 void wxFrame::DetachMenuBar()
135 wxFrameBase::DetachMenuBar();
139 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
141 wxFrameBase::AttachMenuBar(menubar
);
145 #endif // wxUSE_MENUS
149 void wxFrame::PositionStatusBar()
151 if ( m_frameStatusBar
)
153 wxSize size
= GetClientSize();
154 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, -1);
158 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
159 wxWindowID id
, const wxString
& name
)
161 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
166 #endif // wxUSE_STATUSBAR
170 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
172 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
177 return m_frameToolBar
;
180 void wxFrame::PositionToolBar()
182 if ( m_frameToolBar
)
184 wxSize size
= GetClientSize();
188 m_frameToolBar
->GetSize(&tw
, &th
);
189 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
200 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
203 #endif // wxUSE_TOOLBAR
205 wxPoint
wxFrame::GetClientAreaOrigin() const
207 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
209 #if wxUSE_MENUS && !defined(__WXPM__)
210 if ( m_frameMenuBar
)
212 pt
.y
+= m_frameMenuBar
->GetSize().y
;
214 #endif // wxUSE_MENUS
217 if ( m_frameToolBar
)
219 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
220 pt
.x
+= m_frameToolBar
->GetSize().x
;
222 pt
.y
+= m_frameToolBar
->GetSize().y
;
224 #endif // wxUSE_TOOLBAR
229 void wxFrame::DoGetClientSize(int *width
, int *height
) const
231 wxFrameBase::DoGetClientSize(width
, height
);
234 if ( m_frameMenuBar
&& height
)
236 (*height
) -= m_frameMenuBar
->GetSize().y
;
238 #endif // wxUSE_MENUS
241 if ( m_frameStatusBar
&& height
)
243 (*height
) -= m_frameStatusBar
->GetSize().y
;
245 #endif // wxUSE_STATUSBAR
248 if ( m_frameToolBar
)
250 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
251 (*width
) -= m_frameToolBar
->GetSize().x
;
253 (*height
) -= m_frameToolBar
->GetSize().y
;
255 #endif // wxUSE_TOOLBAR
258 void wxFrame::DoSetClientSize(int width
, int height
)
261 if ( m_frameMenuBar
)
263 height
+= m_frameMenuBar
->GetSize().y
;
265 #endif // wxUSE_MENUS
268 if ( m_frameStatusBar
)
270 height
+= m_frameStatusBar
->GetSize().y
;
272 #endif // wxUSE_STATUSBAR
275 if ( m_frameToolBar
)
277 height
+= m_frameStatusBar
->GetSize().y
;
279 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
280 width
+= m_frameToolBar
->GetSize().x
;
282 height
+= m_frameToolBar
->GetSize().y
;
284 #endif // wxUSE_TOOLBAR
286 wxFrameBase::DoSetClientSize(width
, height
);
289 int wxFrame::GetMinWidth() const
292 if ( m_frameMenuBar
)
294 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth());
297 #endif // wxUSE_MENUS
298 return wxFrameBase::GetMinWidth();
301 int wxFrame::GetMinHeight() const
306 if ( m_frameMenuBar
)
308 height
+= m_frameMenuBar
->GetSize().y
;
310 #endif // wxUSE_MENUS
313 if ( m_frameToolBar
)
315 height
+= m_frameToolBar
->GetSize().y
;
317 #endif // wxUSE_TOOLBAR
320 if ( m_frameStatusBar
)
322 height
+= m_frameStatusBar
->GetSize().y
;
324 #endif // wxUSE_STATUSBAR
327 return height
+ wxMax(0, wxFrameBase::GetMinHeight());
329 return wxFrameBase::GetMinHeight();
332 bool wxFrame::Enable(bool enable
)
334 if (!wxFrameBase::Enable(enable
))
336 #ifdef __WXMICROWIN__
338 m_frameMenuBar
->Enable(enable
);