]>
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 // ----------------------------------------------------------------------------
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;
103 if ( m_frameToolBar
)
104 heightTbar
= m_frameToolBar
->GetSize().y
;
105 #endif // wxUSE_TOOLBAR
107 m_frameMenuBar
->SetSize(0,
108 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
109 // the rest of the world!!!
110 GetClientSize().y
- heightMbar
- heightTbar
,
112 - (heightMbar
+ heightTbar
),
114 GetClientSize().x
, heightMbar
);
118 void wxFrame::DetachMenuBar()
120 wxFrameBase::DetachMenuBar();
124 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
126 wxFrameBase::AttachMenuBar(menubar
);
130 #endif // wxUSE_MENUS
134 void wxFrame::PositionStatusBar()
136 if ( m_frameStatusBar
)
138 wxSize size
= GetClientSize();
139 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, -1);
143 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
144 wxWindowID id
, const wxString
& name
)
146 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
151 #endif // wxUSE_STATUSBAR
155 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
157 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
162 return m_frameToolBar
;
165 void wxFrame::PositionToolBar()
167 if ( m_frameToolBar
)
169 wxSize size
= GetClientSize();
173 m_frameToolBar
->GetSize(&tw
, &th
);
174 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
185 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
188 #endif // wxUSE_TOOLBAR
190 wxPoint
wxFrame::GetClientAreaOrigin() const
192 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
194 #if wxUSE_MENUS && !defined(__WXPM__)
195 if ( m_frameMenuBar
)
197 pt
.y
+= m_frameMenuBar
->GetSize().y
;
199 #endif // wxUSE_MENUS
202 if ( m_frameToolBar
)
204 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
205 pt
.x
+= m_frameToolBar
->GetSize().x
;
207 pt
.y
+= m_frameToolBar
->GetSize().y
;
209 #endif // wxUSE_TOOLBAR
214 void wxFrame::DoGetClientSize(int *width
, int *height
) const
216 wxFrameBase::DoGetClientSize(width
, height
);
219 if ( m_frameMenuBar
&& height
)
221 (*height
) -= m_frameMenuBar
->GetSize().y
;
223 #endif // wxUSE_MENUS
226 if ( m_frameStatusBar
&& height
)
228 (*height
) -= m_frameStatusBar
->GetSize().y
;
230 #endif // wxUSE_STATUSBAR
233 if ( m_frameToolBar
)
235 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
236 (*width
) -= m_frameToolBar
->GetSize().x
;
238 (*height
) -= m_frameToolBar
->GetSize().y
;
240 #endif // wxUSE_TOOLBAR
243 void wxFrame::DoSetClientSize(int width
, int height
)
246 if ( m_frameMenuBar
)
248 height
+= m_frameMenuBar
->GetSize().y
;
250 #endif // wxUSE_MENUS
253 if ( m_frameStatusBar
)
255 height
+= m_frameStatusBar
->GetSize().y
;
257 #endif // wxUSE_STATUSBAR
260 if ( m_frameToolBar
)
262 height
+= m_frameStatusBar
->GetSize().y
;
264 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
265 width
+= m_frameToolBar
->GetSize().x
;
267 height
+= m_frameToolBar
->GetSize().y
;
269 #endif // wxUSE_TOOLBAR
271 wxFrameBase::DoSetClientSize(width
, height
);
274 int wxFrame::GetMinWidth() const
277 if ( m_frameMenuBar
)
279 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth());
282 #endif // wxUSE_MENUS
283 return wxFrameBase::GetMinWidth();
286 int wxFrame::GetMinHeight() const
291 if ( m_frameMenuBar
)
293 height
+= m_frameMenuBar
->GetSize().y
;
295 #endif // wxUSE_MENUS
298 if ( m_frameToolBar
)
300 height
+= m_frameToolBar
->GetSize().y
;
302 #endif // wxUSE_TOOLBAR
305 if ( m_frameStatusBar
)
307 height
+= m_frameStatusBar
->GetSize().y
;
309 #endif // wxUSE_STATUSBAR
312 return height
+ wxMax(0, wxFrameBase::GetMinHeight());
314 return wxFrameBase::GetMinHeight();
317 bool wxFrame::Enable(bool enable
)
319 if (!wxFrameBase::Enable(enable
))
321 #ifdef __WXMICROWIN__
323 m_frameMenuBar
->Enable(enable
);