]>
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" | |
d08e6e59 | 34 | #include "wx/statusbr.h" |
1e6feb95 VZ |
35 | #endif // WX_PRECOMP |
36 | ||
37 | // ============================================================================ | |
38 | // implementation | |
39 | // ============================================================================ | |
40 | ||
d9d4df0e | 41 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) |
1e6feb95 VZ |
42 | EVT_SIZE(wxFrame::OnSize) |
43 | END_EVENT_TABLE() | |
44 | ||
d9d4df0e | 45 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) |
1e6feb95 VZ |
46 | |
47 | // ---------------------------------------------------------------------------- | |
48 | // ctors | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
d9d4df0e VS |
51 | bool wxFrame::Create(wxWindow *parent, |
52 | wxWindowID id, | |
53 | const wxString& title, | |
54 | const wxPoint& pos, | |
55 | const wxSize& size, | |
56 | long style, | |
57 | const wxString& name) | |
1e6feb95 | 58 | { |
d9d4df0e | 59 | return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name); |
1e6feb95 VZ |
60 | } |
61 | ||
d9d4df0e | 62 | |
1e6feb95 | 63 | // ---------------------------------------------------------------------------- |
3379ed37 | 64 | // menu support |
1e6feb95 VZ |
65 | // ---------------------------------------------------------------------------- |
66 | ||
67 | void wxFrame::OnSize(wxSizeEvent& event) | |
68 | { | |
3379ed37 | 69 | #if wxUSE_MENUS |
1e6feb95 | 70 | PositionMenuBar(); |
54800df8 | 71 | #endif // wxUSE_MENUS |
d08e6e59 VS |
72 | #if wxUSE_STATUSBAR |
73 | PositionStatusBar(); | |
74 | #endif // wxUSE_STATUSBAR | |
1e6feb95 VZ |
75 | |
76 | event.Skip(); | |
77 | } | |
78 | ||
3379ed37 VZ |
79 | #if wxUSE_MENUS |
80 | ||
1e6feb95 VZ |
81 | void wxFrame::PositionMenuBar() |
82 | { | |
1e6feb95 VZ |
83 | if ( m_frameMenuBar ) |
84 | { | |
85 | // the menubar is positioned above the client size, hence the negative | |
86 | // y coord | |
75c9da25 | 87 | wxCoord heightMbar = m_frameMenuBar->GetSize().y; |
d9d4df0e | 88 | m_frameMenuBar->SetSize(0, -heightMbar, |
75c9da25 | 89 | GetClientSize().x, heightMbar); |
1e6feb95 | 90 | } |
1e6feb95 | 91 | } |
75c9da25 | 92 | |
3379ed37 VZ |
93 | #endif // wxUSE_MENUS |
94 | ||
d08e6e59 VS |
95 | #if wxUSE_STATUSBAR |
96 | ||
97 | void wxFrame::PositionStatusBar() | |
98 | { | |
99 | if ( m_frameStatusBar ) | |
100 | { | |
101 | wxCoord heightBar = m_frameStatusBar->GetSize().y; | |
102 | m_frameStatusBar->SetSize(0, GetClientSize().y, | |
103 | GetClientSize().x, heightBar); | |
104 | } | |
105 | } | |
106 | ||
107 | #endif // wxUSE_STATUSBAR | |
108 | ||
1e6feb95 VZ |
109 | wxPoint wxFrame::GetClientAreaOrigin() const |
110 | { | |
d9d4df0e | 111 | wxPoint pt = wxFrameBase::GetClientAreaOrigin(); |
1e6feb95 VZ |
112 | |
113 | #if wxUSE_MENUS | |
114 | if ( m_frameMenuBar ) | |
115 | { | |
116 | pt.y += m_frameMenuBar->GetSize().y; | |
117 | } | |
118 | #endif // wxUSE_MENUS | |
119 | ||
120 | return pt; | |
121 | } | |
122 | ||
a9152a05 VS |
123 | void wxFrame::DoGetClientSize(int *width, int *height) const |
124 | { | |
125 | wxFrameBase::DoGetClientSize(width, height); | |
d08e6e59 | 126 | |
a9152a05 VS |
127 | #if wxUSE_MENUS |
128 | if ( m_frameMenuBar && height ) | |
129 | { | |
130 | (*height) -= m_frameMenuBar->GetSize().y; | |
131 | } | |
132 | #endif // wxUSE_MENUS | |
d08e6e59 VS |
133 | |
134 | #if wxUSE_STATUSBAR | |
135 | if ( m_frameStatusBar && height ) | |
136 | { | |
137 | (*height) -= m_frameStatusBar->GetSize().y; | |
138 | } | |
139 | #endif // wxUSE_STATUSBAR | |
a9152a05 VS |
140 | } |
141 | ||
142 | void wxFrame::DoSetClientSize(int width, int height) | |
143 | { | |
144 | #if wxUSE_MENUS | |
145 | if ( m_frameMenuBar ) | |
146 | { | |
147 | height += m_frameMenuBar->GetSize().y; | |
148 | } | |
149 | #endif // wxUSE_MENUS | |
d08e6e59 VS |
150 | |
151 | #if wxUSE_STATUSBAR | |
152 | if ( m_frameStatusBar ) | |
153 | { | |
154 | height += m_frameStatusBar->GetSize().y; | |
155 | } | |
156 | #endif // wxUSE_STATUSBAR | |
157 | ||
a9152a05 VS |
158 | wxFrameBase::DoSetClientSize(width, height); |
159 | } | |
160 | ||
d9d4df0e | 161 | bool wxFrame::Enable(bool enable) |
98363307 | 162 | { |
d9d4df0e | 163 | if (!wxFrameBase::Enable(enable)) |
98363307 JS |
164 | return FALSE; |
165 | #ifdef __WXMICROWIN__ | |
166 | if (m_frameMenuBar) | |
167 | m_frameMenuBar->Enable(enable); | |
168 | #endif | |
169 | return TRUE; | |
170 | } |