]>
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 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
199 if ( m_frameToolBar
)
201 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
202 pt
.x
+= m_frameToolBar
->GetSize().x
;
204 pt
.y
+= m_frameToolBar
->GetSize().y
;
206 #endif // wxUSE_TOOLBAR
211 void wxFrame::DoGetClientSize(int *width
, int *height
) const
213 wxFrameBase::DoGetClientSize(width
, height
);
216 if ( m_frameMenuBar
&& height
)
218 (*height
) -= m_frameMenuBar
->GetSize().y
;
220 #endif // wxUSE_MENUS
223 if ( m_frameStatusBar
&& height
)
225 (*height
) -= m_frameStatusBar
->GetSize().y
;
227 #endif // wxUSE_STATUSBAR
230 if ( m_frameToolBar
)
232 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
233 (*width
) -= m_frameToolBar
->GetSize().x
;
235 (*height
) -= m_frameToolBar
->GetSize().y
;
237 #endif // wxUSE_TOOLBAR
240 void wxFrame::DoSetClientSize(int width
, int height
)
243 if ( m_frameMenuBar
)
245 height
+= m_frameMenuBar
->GetSize().y
;
247 #endif // wxUSE_MENUS
250 if ( m_frameStatusBar
)
252 height
+= m_frameStatusBar
->GetSize().y
;
254 #endif // wxUSE_STATUSBAR
257 if ( m_frameToolBar
)
259 height
+= m_frameStatusBar
->GetSize().y
;
261 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
262 width
+= m_frameToolBar
->GetSize().x
;
264 height
+= m_frameToolBar
->GetSize().y
;
266 #endif // wxUSE_TOOLBAR
268 wxFrameBase::DoSetClientSize(width
, height
);
271 int wxFrame::GetMinWidth() const
274 if ( m_frameMenuBar
)
276 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth());
279 #endif // wxUSE_MENUS
280 return wxFrameBase::GetMinWidth();
283 int wxFrame::GetMinHeight() const
288 if ( m_frameMenuBar
)
290 height
+= m_frameMenuBar
->GetSize().y
;
292 #endif // wxUSE_MENUS
295 if ( m_frameToolBar
)
297 height
+= m_frameToolBar
->GetSize().y
;
299 #endif // wxUSE_TOOLBAR
302 if ( m_frameStatusBar
)
304 height
+= m_frameStatusBar
->GetSize().y
;
306 #endif // wxUSE_STATUSBAR
309 return height
+ wxMax(0, wxFrameBase::GetMinHeight());
311 return wxFrameBase::GetMinHeight();
314 bool wxFrame::Enable(bool enable
)
316 if (!wxFrameBase::Enable(enable
))
318 #ifdef __WXMICROWIN__
320 m_frameMenuBar
->Enable(enable
);