]>
git.saurik.com Git - wxWidgets.git/blob - src/univ/framuniv.cpp
5ee90213f6bf01d01da5ac5a9d2d258db4e28a9b
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;
102 heightTbar
= m_frameToolBar
->GetSize().y
;
104 m_frameMenuBar
->SetSize(0,
105 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
106 // the rest of the world!!!
107 GetClientSize().y
- heightMbar
- heightTbar
,
109 - (heightMbar
+ heightTbar
),
111 GetClientSize().x
, heightMbar
);
115 void wxFrame::DetachMenuBar()
117 wxFrameBase::DetachMenuBar();
121 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
123 wxFrameBase::AttachMenuBar(menubar
);
127 #endif // wxUSE_MENUS
131 void wxFrame::PositionStatusBar()
133 if ( m_frameStatusBar
)
135 wxSize size
= GetClientSize();
136 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, -1);
140 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
141 wxWindowID id
, const wxString
& name
)
143 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
148 #endif // wxUSE_STATUSBAR
152 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
154 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
159 return m_frameToolBar
;
162 void wxFrame::PositionToolBar()
164 if ( m_frameToolBar
)
166 wxSize size
= GetClientSize();
170 m_frameToolBar
->GetSize(&tw
, &th
);
171 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
182 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
185 #endif // wxUSE_TOOLBAR
187 wxPoint
wxFrame::GetClientAreaOrigin() const
189 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
191 #if wxUSE_MENUS && !defined(__WXPM__)
192 if ( m_frameMenuBar
)
194 pt
.y
+= m_frameMenuBar
->GetSize().y
;
196 #endif // wxUSE_MENUS
198 // This is done in wxFrameBase already
199 #if 0 // wxUSE_TOOLBAR
200 if ( m_frameToolBar
)
202 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
203 pt
.x
+= m_frameToolBar
->GetSize().x
;
205 pt
.y
+= m_frameToolBar
->GetSize().y
;
207 #endif // wxUSE_TOOLBAR
212 void wxFrame::DoGetClientSize(int *width
, int *height
) const
214 wxFrameBase::DoGetClientSize(width
, height
);
217 if ( m_frameMenuBar
&& height
)
219 (*height
) -= m_frameMenuBar
->GetSize().y
;
221 #endif // wxUSE_MENUS
224 if ( m_frameStatusBar
&& height
)
226 (*height
) -= m_frameStatusBar
->GetSize().y
;
228 #endif // wxUSE_STATUSBAR
231 if ( m_frameToolBar
)
233 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
234 (*width
) -= m_frameToolBar
->GetSize().x
;
236 (*height
) -= m_frameToolBar
->GetSize().y
;
238 #endif // wxUSE_TOOLBAR
241 void wxFrame::DoSetClientSize(int width
, int height
)
244 if ( m_frameMenuBar
)
246 height
+= m_frameMenuBar
->GetSize().y
;
248 #endif // wxUSE_MENUS
251 if ( m_frameStatusBar
)
253 height
+= m_frameStatusBar
->GetSize().y
;
255 #endif // wxUSE_STATUSBAR
258 if ( m_frameToolBar
)
260 height
+= m_frameStatusBar
->GetSize().y
;
262 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
263 width
+= m_frameToolBar
->GetSize().x
;
265 height
+= m_frameToolBar
->GetSize().y
;
267 #endif // wxUSE_TOOLBAR
269 wxFrameBase::DoSetClientSize(width
, height
);
272 int wxFrame::GetMinWidth() const
275 if ( m_frameMenuBar
)
277 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth());
280 #endif // wxUSE_MENUS
281 return wxFrameBase::GetMinWidth();
284 int wxFrame::GetMinHeight() const
289 if ( m_frameMenuBar
)
291 height
+= m_frameMenuBar
->GetSize().y
;
293 #endif // wxUSE_MENUS
296 if ( m_frameToolBar
)
298 height
+= m_frameToolBar
->GetSize().y
;
300 #endif // wxUSE_TOOLBAR
303 if ( m_frameStatusBar
)
305 height
+= m_frameStatusBar
->GetSize().y
;
307 #endif // wxUSE_STATUSBAR
310 return height
+ wxMax(0, wxFrameBase::GetMinHeight());
312 return wxFrameBase::GetMinHeight();
315 bool wxFrame::Enable(bool enable
)
317 if (!wxFrameBase::Enable(enable
))
319 #ifdef __WXMICROWIN__
321 m_frameMenuBar
->Enable(enable
);