]>
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
;
99 m_frameMenuBar
->SetSize(0,
100 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
101 // the rest of the world!!!
102 GetClientSize().y
- heightMbar
,
106 GetClientSize().x
, heightMbar
);
110 void wxFrame::DetachMenuBar()
112 wxFrameBase::DetachMenuBar();
116 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
118 wxFrameBase::AttachMenuBar(menubar
);
122 #endif // wxUSE_MENUS
126 void wxFrame::PositionStatusBar()
128 if ( m_frameStatusBar
)
130 wxSize size
= GetClientSize();
131 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, -1);
135 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
136 wxWindowID id
, const wxString
& name
)
138 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
143 #endif // wxUSE_STATUSBAR
147 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
149 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
154 return m_frameToolBar
;
157 void wxFrame::PositionToolBar()
159 if ( m_frameToolBar
)
161 wxSize size
= GetClientSize();
165 m_frameToolBar
->GetSize(&tw
, &th
);
166 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
177 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
180 #endif // wxUSE_TOOLBAR
182 wxPoint
wxFrame::GetClientAreaOrigin() const
184 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
186 #if wxUSE_MENUS && !defined(__WXPM__)
187 if ( m_frameMenuBar
)
189 pt
.y
+= m_frameMenuBar
->GetSize().y
;
191 #endif // wxUSE_MENUS
194 if ( m_frameToolBar
)
196 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
197 pt
.x
+= m_frameToolBar
->GetSize().x
;
199 pt
.y
+= m_frameToolBar
->GetSize().y
;
201 #endif // wxUSE_TOOLBAR
206 void wxFrame::DoGetClientSize(int *width
, int *height
) const
208 wxFrameBase::DoGetClientSize(width
, height
);
211 if ( m_frameMenuBar
&& height
)
213 (*height
) -= m_frameMenuBar
->GetSize().y
;
215 #endif // wxUSE_MENUS
218 if ( m_frameStatusBar
&& height
)
220 (*height
) -= m_frameStatusBar
->GetSize().y
;
222 #endif // wxUSE_STATUSBAR
225 if ( m_frameToolBar
)
227 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
228 (*width
) -= m_frameToolBar
->GetSize().x
;
230 (*height
) -= m_frameToolBar
->GetSize().y
;
232 #endif // wxUSE_TOOLBAR
235 void wxFrame::DoSetClientSize(int width
, int height
)
238 if ( m_frameMenuBar
)
240 height
+= m_frameMenuBar
->GetSize().y
;
242 #endif // wxUSE_MENUS
245 if ( m_frameStatusBar
)
247 height
+= m_frameStatusBar
->GetSize().y
;
249 #endif // wxUSE_STATUSBAR
252 if ( m_frameToolBar
)
254 height
+= m_frameStatusBar
->GetSize().y
;
256 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
257 width
+= m_frameToolBar
->GetSize().x
;
259 height
+= m_frameToolBar
->GetSize().y
;
261 #endif // wxUSE_TOOLBAR
263 wxFrameBase::DoSetClientSize(width
, height
);
266 bool wxFrame::Enable(bool enable
)
268 if (!wxFrameBase::Enable(enable
))
270 #ifdef __WXMICROWIN__
272 m_frameMenuBar
->Enable(enable
);