]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: univ/frame.cpp | |
3 | // Purpose: wxFrame class for wxUniversal | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 19.05.01 | |
7 | // RCS-ID: $Id$ | |
442b35b5 | 8 | // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) |
1e6feb95 VZ |
9 | // Licence: wxWindows licence |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // =========================================================================== | |
13 | // declarations | |
14 | // =========================================================================== | |
15 | ||
16 | // --------------------------------------------------------------------------- | |
17 | // headers | |
18 | // --------------------------------------------------------------------------- | |
19 | ||
20 | #ifdef __GNUG__ | |
a3870b2f | 21 | #pragma implementation "univframe.h" |
1e6feb95 VZ |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
28 | #pragma hdrstop | |
29 | #endif | |
30 | ||
31 | #include "wx/menu.h" | |
32 | #ifndef WX_PRECOMP | |
33 | #include "wx/frame.h" | |
34 | #endif // WX_PRECOMP | |
35 | ||
36 | // ============================================================================ | |
37 | // implementation | |
38 | // ============================================================================ | |
39 | ||
d9d4df0e | 40 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) |
1e6feb95 VZ |
41 | EVT_SIZE(wxFrame::OnSize) |
42 | END_EVENT_TABLE() | |
43 | ||
d9d4df0e | 44 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) |
1e6feb95 VZ |
45 | |
46 | // ---------------------------------------------------------------------------- | |
47 | // ctors | |
48 | // ---------------------------------------------------------------------------- | |
49 | ||
d9d4df0e VS |
50 | bool wxFrame::Create(wxWindow *parent, |
51 | wxWindowID id, | |
52 | const wxString& title, | |
53 | const wxPoint& pos, | |
54 | const wxSize& size, | |
55 | long style, | |
56 | const wxString& name) | |
1e6feb95 | 57 | { |
d9d4df0e | 58 | return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name); |
1e6feb95 VZ |
59 | } |
60 | ||
d9d4df0e | 61 | |
1e6feb95 | 62 | // ---------------------------------------------------------------------------- |
3379ed37 | 63 | // menu support |
1e6feb95 VZ |
64 | // ---------------------------------------------------------------------------- |
65 | ||
66 | void wxFrame::OnSize(wxSizeEvent& event) | |
67 | { | |
3379ed37 | 68 | #if wxUSE_MENUS |
1e6feb95 | 69 | PositionMenuBar(); |
54800df8 | 70 | #endif // wxUSE_MENUS |
1e6feb95 VZ |
71 | |
72 | event.Skip(); | |
73 | } | |
74 | ||
3379ed37 VZ |
75 | #if wxUSE_MENUS |
76 | ||
1e6feb95 VZ |
77 | void wxFrame::PositionMenuBar() |
78 | { | |
1e6feb95 VZ |
79 | if ( m_frameMenuBar ) |
80 | { | |
81 | // the menubar is positioned above the client size, hence the negative | |
82 | // y coord | |
75c9da25 | 83 | wxCoord heightMbar = m_frameMenuBar->GetSize().y; |
d9d4df0e | 84 | m_frameMenuBar->SetSize(0, -heightMbar, |
75c9da25 | 85 | GetClientSize().x, heightMbar); |
1e6feb95 | 86 | } |
1e6feb95 | 87 | } |
75c9da25 | 88 | |
3379ed37 VZ |
89 | #endif // wxUSE_MENUS |
90 | ||
1e6feb95 VZ |
91 | wxPoint wxFrame::GetClientAreaOrigin() const |
92 | { | |
d9d4df0e | 93 | wxPoint pt = wxFrameBase::GetClientAreaOrigin(); |
1e6feb95 VZ |
94 | |
95 | #if wxUSE_MENUS | |
96 | if ( m_frameMenuBar ) | |
97 | { | |
98 | pt.y += m_frameMenuBar->GetSize().y; | |
99 | } | |
100 | #endif // wxUSE_MENUS | |
101 | ||
102 | return pt; | |
103 | } | |
104 | ||
a9152a05 VS |
105 | void wxFrame::DoGetClientSize(int *width, int *height) const |
106 | { | |
107 | wxFrameBase::DoGetClientSize(width, height); | |
108 | #if wxUSE_MENUS | |
109 | if ( m_frameMenuBar && height ) | |
110 | { | |
111 | (*height) -= m_frameMenuBar->GetSize().y; | |
112 | } | |
113 | #endif // wxUSE_MENUS | |
114 | } | |
115 | ||
116 | void wxFrame::DoSetClientSize(int width, int height) | |
117 | { | |
118 | #if wxUSE_MENUS | |
119 | if ( m_frameMenuBar ) | |
120 | { | |
121 | height += m_frameMenuBar->GetSize().y; | |
122 | } | |
123 | #endif // wxUSE_MENUS | |
124 | wxFrameBase::DoSetClientSize(width, height); | |
125 | } | |
126 | ||
d9d4df0e | 127 | bool wxFrame::Enable(bool enable) |
98363307 | 128 | { |
d9d4df0e | 129 | if (!wxFrameBase::Enable(enable)) |
98363307 JS |
130 | return FALSE; |
131 | #ifdef __WXMICROWIN__ | |
132 | if (m_frameMenuBar) | |
133 | m_frameMenuBar->Enable(enable); | |
134 | #endif | |
135 | return TRUE; | |
136 | } |