]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/univ/framuniv.cpp
fixed wxTaskBarIcon compilation
[wxWidgets.git] / src / univ / framuniv.cpp
... / ...
CommitLineData
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$
8// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
20#ifdef __GNUG__
21 #pragma implementation "univframe.h"
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 #include "wx/statusbr.h"
35#endif // WX_PRECOMP
36
37// ============================================================================
38// implementation
39// ============================================================================
40
41BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
42 EVT_SIZE(wxFrame::OnSize)
43END_EVENT_TABLE()
44
45IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
46
47// ----------------------------------------------------------------------------
48// ctors
49// ----------------------------------------------------------------------------
50
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)
58{
59 return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name);
60}
61
62
63// ----------------------------------------------------------------------------
64// menu support
65// ----------------------------------------------------------------------------
66
67void wxFrame::OnSize(wxSizeEvent& event)
68{
69#if wxUSE_MENUS
70 PositionMenuBar();
71#endif // wxUSE_MENUS
72#if wxUSE_STATUSBAR
73 PositionStatusBar();
74#endif // wxUSE_STATUSBAR
75
76 event.Skip();
77}
78
79void wxFrame::SendSizeEvent()
80{
81 wxSizeEvent event(GetSize(), GetId());
82 event.SetEventObject(this);
83 GetEventHandler()->ProcessEvent(event);
84}
85
86#if wxUSE_MENUS
87
88void wxFrame::PositionMenuBar()
89{
90 if ( m_frameMenuBar )
91 {
92 // the menubar is positioned above the client size, hence the negative
93 // y coord
94 wxCoord heightMbar = m_frameMenuBar->GetSize().y;
95 m_frameMenuBar->SetSize(0,
96#ifdef __WXPM__
97 GetClientSize().y - heightMbar,
98#else
99 -heightMbar,
100#endif
101 GetClientSize().x, heightMbar);
102 }
103}
104
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
117#endif // wxUSE_MENUS
118
119#if wxUSE_STATUSBAR
120
121void wxFrame::PositionStatusBar()
122{
123 if ( m_frameStatusBar )
124 {
125 wxSize size = GetClientSize();
126 m_frameStatusBar->SetSize(0, size.y, size.x, -1);
127 }
128}
129
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
138#endif // wxUSE_STATUSBAR
139
140wxPoint wxFrame::GetClientAreaOrigin() const
141{
142 wxPoint pt = wxFrameBase::GetClientAreaOrigin();
143
144#if wxUSE_MENUS && !defined(__WXPM__)
145 if ( m_frameMenuBar )
146 {
147 pt.y += m_frameMenuBar->GetSize().y;
148 }
149#endif // wxUSE_MENUS
150
151 return pt;
152}
153
154void wxFrame::DoGetClientSize(int *width, int *height) const
155{
156 wxFrameBase::DoGetClientSize(width, height);
157
158#if wxUSE_MENUS
159 if ( m_frameMenuBar && height )
160 {
161 (*height) -= m_frameMenuBar->GetSize().y;
162 }
163#endif // wxUSE_MENUS
164
165#if wxUSE_STATUSBAR
166 if ( m_frameStatusBar && height )
167 {
168 (*height) -= m_frameStatusBar->GetSize().y;
169 }
170#endif // wxUSE_STATUSBAR
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
181
182#if wxUSE_STATUSBAR
183 if ( m_frameStatusBar )
184 {
185 height += m_frameStatusBar->GetSize().y;
186 }
187#endif // wxUSE_STATUSBAR
188
189 wxFrameBase::DoSetClientSize(width, height);
190}
191
192bool wxFrame::Enable(bool enable)
193{
194 if (!wxFrameBase::Enable(enable))
195 return FALSE;
196#ifdef __WXMICROWIN__
197 if (m_frameMenuBar)
198 m_frameMenuBar->Enable(enable);
199#endif
200 return TRUE;
201}