]> git.saurik.com Git - wxWidgets.git/blame - src/univ/framuniv.cpp
wxRegion fixes (off by one)
[wxWidgets.git] / src / univ / framuniv.cpp
CommitLineData
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 41BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
1e6feb95
VZ
42 EVT_SIZE(wxFrame::OnSize)
43END_EVENT_TABLE()
44
d9d4df0e 45IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
1e6feb95
VZ
46
47// ----------------------------------------------------------------------------
48// ctors
49// ----------------------------------------------------------------------------
50
d9d4df0e
VS
51bool 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
67void 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
6821401b 79void wxFrame::SendSizeEvent()
71e03035 80{
6821401b
VS
81 wxSizeEvent event(GetSize(), GetId());
82 event.SetEventObject(this);
83 GetEventHandler()->ProcessEvent(event);
84}
85
3379ed37
VZ
86#if wxUSE_MENUS
87
1e6feb95
VZ
88void wxFrame::PositionMenuBar()
89{
1e6feb95
VZ
90 if ( m_frameMenuBar )
91 {
92 // the menubar is positioned above the client size, hence the negative
93 // y coord
75c9da25 94 wxCoord heightMbar = m_frameMenuBar->GetSize().y;
19193a2c
KB
95 m_frameMenuBar->SetSize(0,
96#ifdef __WXPM__
97 GetClientSize().y - heightMbar,
98#else
99 -heightMbar,
100#endif
75c9da25 101 GetClientSize().x, heightMbar);
1e6feb95 102 }
1e6feb95 103}
75c9da25 104
6821401b
VS
105void wxFrame::DetachMenuBar()
106{
107 wxFrameBase::DetachMenuBar();
108 SendSizeEvent();
109}
110
111void wxFrame::AttachMenuBar(wxMenuBar *menubar)
112{
113 wxFrameBase::AttachMenuBar(menubar);
114 SendSizeEvent();
115}
116
3379ed37
VZ
117#endif // wxUSE_MENUS
118
d08e6e59
VS
119#if wxUSE_STATUSBAR
120
121void wxFrame::PositionStatusBar()
122{
123 if ( m_frameStatusBar )
124 {
71e03035
VZ
125 wxSize size = GetClientSize();
126 m_frameStatusBar->SetSize(0, size.y, size.x, -1);
d08e6e59
VS
127 }
128}
129
6821401b
VS
130wxStatusBar* wxFrame::CreateStatusBar(int number, long style,
131 wxWindowID id, const wxString& name)
132{
133 wxStatusBar *bar = wxFrameBase::CreateStatusBar(number, style, id, name);
134 SendSizeEvent();
135 return bar;
136}
137
d08e6e59
VS
138#endif // wxUSE_STATUSBAR
139
1e6feb95
VZ
140wxPoint wxFrame::GetClientAreaOrigin() const
141{
d9d4df0e 142 wxPoint pt = wxFrameBase::GetClientAreaOrigin();
1e6feb95 143
19193a2c 144#if wxUSE_MENUS && !defined(__WXPM__)
1e6feb95
VZ
145 if ( m_frameMenuBar )
146 {
147 pt.y += m_frameMenuBar->GetSize().y;
148 }
149#endif // wxUSE_MENUS
150
151 return pt;
152}
153
a9152a05
VS
154void wxFrame::DoGetClientSize(int *width, int *height) const
155{
156 wxFrameBase::DoGetClientSize(width, height);
d08e6e59 157
a9152a05
VS
158#if wxUSE_MENUS
159 if ( m_frameMenuBar && height )
160 {
161 (*height) -= m_frameMenuBar->GetSize().y;
162 }
163#endif // wxUSE_MENUS
d08e6e59
VS
164
165#if wxUSE_STATUSBAR
166 if ( m_frameStatusBar && height )
167 {
168 (*height) -= m_frameStatusBar->GetSize().y;
169 }
170#endif // wxUSE_STATUSBAR
a9152a05
VS
171}
172
173void wxFrame::DoSetClientSize(int width, int height)
174{
175#if wxUSE_MENUS
176 if ( m_frameMenuBar )
177 {
178 height += m_frameMenuBar->GetSize().y;
179 }
180#endif // wxUSE_MENUS
d08e6e59
VS
181
182#if wxUSE_STATUSBAR
183 if ( m_frameStatusBar )
184 {
185 height += m_frameStatusBar->GetSize().y;
186 }
187#endif // wxUSE_STATUSBAR
188
a9152a05
VS
189 wxFrameBase::DoSetClientSize(width, height);
190}
191
d9d4df0e 192bool wxFrame::Enable(bool enable)
98363307 193{
d9d4df0e 194 if (!wxFrameBase::Enable(enable))
98363307
JS
195 return FALSE;
196#ifdef __WXMICROWIN__
197 if (m_frameMenuBar)
198 m_frameMenuBar->Enable(enable);
199#endif
200 return TRUE;
201}