1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/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 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
31 #include "wx/statusbr.h"
32 #include "wx/settings.h"
33 #include "wx/toolbar.h"
36 // ============================================================================
38 // ============================================================================
40 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
41 EVT_SIZE(wxFrame::OnSize
)
42 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
45 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 bool wxFrame::Create(wxWindow
*parent
,
53 const wxString
& title
,
59 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
62 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
67 // Responds to colour changes, and passes event on to children.
68 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
70 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
76 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
80 void wxFrame::OnSize(wxSizeEvent
& event
)
87 #endif // wxUSE_STATUSBAR
90 #endif // wxUSE_TOOLBAR
95 void wxFrame::SendSizeEvent()
97 wxSizeEvent
event(GetSize(), GetId());
98 event
.SetEventObject(this);
99 GetEventHandler()->ProcessEvent(event
);
104 void wxFrame::PositionMenuBar()
106 if ( m_frameMenuBar
)
108 // the menubar is positioned above the client size, hence the negative
110 wxCoord heightMbar
= m_frameMenuBar
->GetSize().y
;
112 wxCoord heightTbar
= 0;
115 if ( m_frameToolBar
)
116 heightTbar
= m_frameToolBar
->GetSize().y
;
117 #endif // wxUSE_TOOLBAR
119 m_frameMenuBar
->SetSize(0,
120 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
121 // the rest of the world!!!
122 GetClientSize().y
- heightMbar
- heightTbar
,
124 - (heightMbar
+ heightTbar
),
126 GetClientSize().x
, heightMbar
);
130 void wxFrame::DetachMenuBar()
132 wxFrameBase::DetachMenuBar();
136 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
138 wxFrameBase::AttachMenuBar(menubar
);
142 #endif // wxUSE_MENUS
146 void wxFrame::PositionStatusBar()
148 if ( m_frameStatusBar
)
150 wxSize size
= GetClientSize();
151 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, wxDefaultCoord
);
155 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
156 wxWindowID id
, const wxString
& name
)
158 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
163 #endif // wxUSE_STATUSBAR
167 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
169 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
174 return m_frameToolBar
;
177 void wxFrame::PositionToolBar()
179 if ( m_frameToolBar
)
181 wxSize size
= GetClientSize();
185 m_frameToolBar
->GetSize(&tw
, &th
);
186 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
197 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
200 #endif // wxUSE_TOOLBAR
202 wxPoint
wxFrame::GetClientAreaOrigin() const
204 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
206 #if wxUSE_MENUS && !defined(__WXPM__)
207 if ( m_frameMenuBar
)
209 pt
.y
+= m_frameMenuBar
->GetSize().y
;
211 #endif // wxUSE_MENUS
214 if ( m_frameToolBar
)
216 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
217 pt
.x
+= m_frameToolBar
->GetSize().x
;
219 pt
.y
+= m_frameToolBar
->GetSize().y
;
221 #endif // wxUSE_TOOLBAR
226 void wxFrame::DoGetClientSize(int *width
, int *height
) const
228 wxFrameBase::DoGetClientSize(width
, height
);
231 if ( m_frameMenuBar
&& height
)
233 (*height
) -= m_frameMenuBar
->GetSize().y
;
235 #endif // wxUSE_MENUS
238 if ( m_frameStatusBar
&& height
)
240 (*height
) -= m_frameStatusBar
->GetSize().y
;
242 #endif // wxUSE_STATUSBAR
245 if ( m_frameToolBar
)
247 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
248 (*width
) -= m_frameToolBar
->GetSize().x
;
250 (*height
) -= m_frameToolBar
->GetSize().y
;
252 #endif // wxUSE_TOOLBAR
255 void wxFrame::DoSetClientSize(int width
, int height
)
258 if ( m_frameMenuBar
)
260 height
+= m_frameMenuBar
->GetSize().y
;
262 #endif // wxUSE_MENUS
265 if ( m_frameStatusBar
)
267 height
+= m_frameStatusBar
->GetSize().y
;
269 #endif // wxUSE_STATUSBAR
272 if ( m_frameToolBar
)
275 height
+= m_frameStatusBar
->GetSize().y
;
276 #endif // wxUSE_STATUSBAR
278 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
279 width
+= m_frameToolBar
->GetSize().x
;
281 height
+= m_frameToolBar
->GetSize().y
;
283 #endif // wxUSE_TOOLBAR
285 wxFrameBase::DoSetClientSize(width
, height
);
288 int wxFrame::GetMinWidth() const
291 if ( m_frameMenuBar
)
293 return wxMax(m_frameMenuBar
->GetBestSize().x
, wxFrameBase::GetMinWidth());
296 #endif // wxUSE_MENUS
297 return wxFrameBase::GetMinWidth();
300 int wxFrame::GetMinHeight() const
305 if ( m_frameMenuBar
)
307 height
+= m_frameMenuBar
->GetSize().y
;
309 #endif // wxUSE_MENUS
312 if ( m_frameToolBar
)
314 height
+= m_frameToolBar
->GetSize().y
;
316 #endif // wxUSE_TOOLBAR
319 if ( m_frameStatusBar
)
321 height
+= m_frameStatusBar
->GetSize().y
;
323 #endif // wxUSE_STATUSBAR
326 return height
+ wxMax(0, wxFrameBase::GetMinHeight());
328 return wxFrameBase::GetMinHeight();
331 bool wxFrame::Enable(bool enable
)
333 if (!wxFrameBase::Enable(enable
))
335 #ifdef __WXMICROWIN__
337 m_frameMenuBar
->Enable(enable
);