]> git.saurik.com Git - wxWidgets.git/blame - src/osx/toplevel_osx.cpp
No real changes, just use AllocExclusive() in wxOSX wxRegion.
[wxWidgets.git] / src / osx / toplevel_osx.cpp
CommitLineData
489468fe 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/toplevel_osx.cpp
489468fe
SC
3// Purpose: implements wxTopLevelWindow for Mac
4// Author: Stefan Csomor
5// Modified by:
6// Created: 24.09.01
7// RCS-ID: $Id$
8// Copyright: (c) 2001-2004 Stefan Csomor
526954c5 9// Licence: wxWindows licence
489468fe
SC
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#include "wx/toplevel.h"
28
29#ifndef WX_PRECOMP
30 #include "wx/app.h"
31 #include "wx/frame.h"
32 #include "wx/string.h"
33 #include "wx/log.h"
34 #include "wx/intl.h"
35 #include "wx/settings.h"
36 #include "wx/strconv.h"
37 #include "wx/control.h"
38#endif //WX_PRECOMP
39
489468fe
SC
40#include "wx/tooltip.h"
41#include "wx/dnd.h"
42
43#if wxUSE_SYSTEM_OPTIONS
44 #include "wx/sysopt.h"
45#endif
46
489468fe 47// for targeting OSX
1f0c8f31 48#include "wx/osx/private.h"
489468fe
SC
49
50// ============================================================================
51// wxTopLevelWindowMac implementation
52// ============================================================================
53
54BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase)
55END_EVENT_TABLE()
56
57// ----------------------------------------------------------------------------
58// wxTopLevelWindowMac creation
59// ----------------------------------------------------------------------------
60
489468fe
SC
61
62void wxTopLevelWindowMac::Init()
63{
64 m_iconized =
65 m_maximizeOnShow = false;
489468fe
SC
66}
67
68bool wxTopLevelWindowMac::Create(wxWindow *parent,
69 wxWindowID id,
70 const wxString& title,
71 const wxPoint& pos,
72 const wxSize& size,
73 long style,
74 const wxString& name)
75{
e08b4823 76 if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) )
489468fe
SC
77 return false;
78
79 wxWindow::SetLabel( title ) ;
b2680ced 80 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
489468fe
SC
81 wxTopLevelWindows.Append(this);
82
83 return true;
84}
85
638b3cd7
SC
86bool wxTopLevelWindowMac::Create(wxWindow *parent,
87 WXWindow nativeWindow)
88{
89 if ( !wxNonOwnedWindow::Create(parent, nativeWindow ) )
90 return false;
ce00f59b 91
638b3cd7 92 wxTopLevelWindows.Append(this);
ce00f59b 93
638b3cd7
SC
94 return true;
95}
96
489468fe
SC
97wxTopLevelWindowMac::~wxTopLevelWindowMac()
98{
489468fe
SC
99}
100
c9f9deab
KO
101bool wxTopLevelWindowMac::Destroy()
102{
103 // NB: this will get called during destruction if we don't do it now,
104 // and may fire a kill focus event on a control being destroyed
105#if wxOSX_USE_CARBON
d4d799e9 106 if (m_nowpeer && m_nowpeer->GetWXWindow())
c9f9deab
KO
107 ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() );
108#endif
109 return wxTopLevelWindowBase::Destroy();
110}
111
489468fe
SC
112
113// ----------------------------------------------------------------------------
114// wxTopLevelWindowMac maximize/minimize
115// ----------------------------------------------------------------------------
116
117void wxTopLevelWindowMac::Maximize(bool maximize)
118{
b2680ced
SC
119 if ( IsMaximized() != maximize )
120 m_nowpeer->Maximize(maximize);
489468fe
SC
121}
122
123bool wxTopLevelWindowMac::IsMaximized() const
124{
aa47eebb
SC
125 if ( m_nowpeer == NULL )
126 return false;
ce00f59b 127
b2680ced 128 return m_nowpeer->IsMaximized();
489468fe
SC
129}
130
131void wxTopLevelWindowMac::Iconize(bool iconize)
132{
b2680ced
SC
133 if ( IsIconized() != iconize )
134 m_nowpeer->Iconize(iconize);
489468fe
SC
135}
136
137bool wxTopLevelWindowMac::IsIconized() const
138{
aa47eebb
SC
139 if ( m_nowpeer == NULL )
140 return false;
141
b2680ced 142 return m_nowpeer->IsIconized();
489468fe
SC
143}
144
145void wxTopLevelWindowMac::Restore()
146{
147 if ( IsMaximized() )
148 Maximize(false);
149 else if ( IsIconized() )
150 Iconize(false);
151}
152
153// ----------------------------------------------------------------------------
154// wxTopLevelWindowMac misc
155// ----------------------------------------------------------------------------
156
157wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
158{
159 return wxPoint(0, 0) ;
160}
161
162void wxTopLevelWindowMac::SetTitle(const wxString& title)
163{
8ec413ce
SC
164 m_label = title ;
165
cd0d451b
SC
166 if ( m_nowpeer )
167 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
489468fe
SC
168}
169
170wxString wxTopLevelWindowMac::GetTitle() const
171{
172 return wxWindow::GetLabel();
173}
174
dbc7ceb9
KO
175void wxTopLevelWindowMac::ShowWithoutActivating()
176{
598ad2b9
KO
177 // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't
178 // call it here.
179 if ( !wxWindow::Show(true) )
b487746a
KO
180 return;
181
182 m_nowpeer->ShowWithoutActivating();
ce00f59b 183
b487746a 184 // TODO: Should we call EVT_SIZE here?
dbc7ceb9
KO
185}
186
489468fe
SC
187bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
188{
b2680ced 189 return m_nowpeer->ShowFullScreen(show, style);
489468fe
SC
190}
191
192bool wxTopLevelWindowMac::IsFullScreen() const
193{
b2680ced 194 return m_nowpeer->IsFullScreen();
489468fe
SC
195}
196
b2680ced 197void wxTopLevelWindowMac::RequestUserAttention(int flags)
489468fe 198{
b2680ced 199 return m_nowpeer->RequestUserAttention(flags);
489468fe 200}
dbc7ceb9
KO
201
202bool wxTopLevelWindowMac::IsActive()
203{
204 return m_nowpeer->IsActive();
205}
efb2fa41 206
ebf7d5c4 207void wxTopLevelWindowMac::OSXSetModified(bool modified)
efb2fa41
KO
208{
209 m_nowpeer->SetModified(modified);
210}
211
ebf7d5c4 212bool wxTopLevelWindowMac::OSXIsModified() const
efb2fa41 213{
ebf7d5c4
KO
214 return m_nowpeer->IsModified();
215}