1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/framuniv.cpp
3 // Purpose: wxFrame class for wxUniversal
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
30 #include "wx/statusbr.h"
31 #include "wx/settings.h"
32 #include "wx/toolbar.h"
35 // ============================================================================
37 // ============================================================================
39 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
40 EVT_SIZE(wxFrame::OnSize
)
41 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 bool wxFrame::Create(wxWindow
*parent
,
50 const wxString
& title
,
56 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
59 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
64 // Responds to colour changes, and passes event on to children.
65 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
67 SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 void wxFrame::OnSize(wxSizeEvent
& event
)
84 #endif // wxUSE_STATUSBAR
87 #endif // wxUSE_TOOLBAR
94 void wxFrame::PositionMenuBar()
98 // the menubar is positioned above the client size, hence the negative
100 wxCoord heightMbar
= m_frameMenuBar
->GetSize().y
;
102 wxCoord heightTbar
= 0;
105 if ( m_frameToolBar
)
106 heightTbar
= m_frameToolBar
->GetSize().y
;
107 #endif // wxUSE_TOOLBAR
109 m_frameMenuBar
->SetSize(0,
110 #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as
111 // the rest of the world!!!
112 GetClientSize().y
- heightMbar
- heightTbar
,
114 - (heightMbar
+ heightTbar
),
116 GetClientSize().x
, heightMbar
);
120 void wxFrame::DetachMenuBar()
122 wxFrameBase::DetachMenuBar();
126 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
128 wxFrameBase::AttachMenuBar(menubar
);
132 #endif // wxUSE_MENUS
136 void wxFrame::PositionStatusBar()
138 if ( m_frameStatusBar
)
140 wxSize size
= GetClientSize();
141 m_frameStatusBar
->SetSize(0, size
.y
, size
.x
, wxDefaultCoord
);
145 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
,
146 wxWindowID id
, const wxString
& name
)
148 wxStatusBar
*bar
= wxFrameBase::CreateStatusBar(number
, style
, id
, name
);
153 #endif // wxUSE_STATUSBAR
157 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
159 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
164 return m_frameToolBar
;
167 void wxFrame::PositionToolBar()
169 if ( m_frameToolBar
)
171 wxSize size
= GetClientSize();
175 m_frameToolBar
->GetSize(&tw
, &th
);
176 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
187 m_frameToolBar
->SetSize(tx
, ty
, tw
, th
);
190 #endif // wxUSE_TOOLBAR
192 wxPoint
wxFrame::GetClientAreaOrigin() const
194 wxPoint pt
= wxFrameBase::GetClientAreaOrigin();
196 #if wxUSE_MENUS && !defined(__WXPM__)
197 if ( m_frameMenuBar
)
199 pt
.y
+= m_frameMenuBar
->GetSize().y
;
201 #endif // wxUSE_MENUS
204 if ( m_frameToolBar
)
206 if ( m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
207 pt
.x
+= m_frameToolBar
->GetSize().x
;
209 pt
.y
+= m_frameToolBar
->GetSize().y
;
211 #endif // wxUSE_TOOLBAR
216 void wxFrame::DoGetClientSize(int *width
, int *height
) const
218 wxFrameBase::DoGetClientSize(width
, height
);
221 if ( m_frameMenuBar
&& height
)
223 (*height
) -= m_frameMenuBar
->GetSize().y
;
225 #endif // wxUSE_MENUS
228 if ( m_frameStatusBar
&& height
)
230 (*height
) -= m_frameStatusBar
->GetSize().y
;
232 #endif // wxUSE_STATUSBAR
235 if ( m_frameToolBar
)
237 if ( width
&& (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
) )
238 (*width
) -= m_frameToolBar
->GetSize().x
;
240 (*height
) -= m_frameToolBar
->GetSize().y
;
242 #endif // wxUSE_TOOLBAR
245 void wxFrame::DoSetClientSize(int width
, int height
)
248 if ( m_frameMenuBar
)
250 height
+= m_frameMenuBar
->GetSize().y
;
252 #endif // wxUSE_MENUS
255 if ( m_frameStatusBar
)
257 height
+= m_frameStatusBar
->GetSize().y
;
259 #endif // wxUSE_STATUSBAR
262 if ( m_frameToolBar
)
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 wxSize
wxFrame::GetMinSize() const
276 wxSize size
= wxFrameBase::GetMinSize();
279 if ( m_frameMenuBar
)
281 const wxSize sizeMenu
= m_frameMenuBar
->GetBestSize();
282 if ( sizeMenu
.x
> size
.x
)
284 size
.y
+= sizeMenu
.y
;
286 #endif // wxUSE_MENUS
289 if ( m_frameToolBar
)
291 size
.y
+= m_frameToolBar
->GetSize().y
;
293 #endif // wxUSE_TOOLBAR
296 if ( m_frameStatusBar
)
298 size
.y
+= m_frameStatusBar
->GetSize().y
;
300 #endif // wxUSE_STATUSBAR
305 bool wxFrame::Enable(bool enable
)
307 if (!wxFrameBase::Enable(enable
))
309 #ifdef __WXMICROWIN__
311 m_frameMenuBar
->Enable(enable
);