]> git.saurik.com Git - wxWidgets.git/blame - src/osx/toplevel_osx.cpp
attempt to get the 'new focus' window parameter of a focus kill event set correctly
[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
eebddb37
SC
109 // delayed destruction: the tlw will be deleted during the next idle
110 // loop iteration
111 if ( !wxPendingDelete.Member(this) )
112 wxPendingDelete.Append(this);
113
114 Hide();
115 return true;
c9f9deab
KO
116}
117
489468fe
SC
118
119// ----------------------------------------------------------------------------
120// wxTopLevelWindowMac maximize/minimize
121// ----------------------------------------------------------------------------
122
123void wxTopLevelWindowMac::Maximize(bool maximize)
124{
b2680ced
SC
125 if ( IsMaximized() != maximize )
126 m_nowpeer->Maximize(maximize);
489468fe
SC
127}
128
129bool wxTopLevelWindowMac::IsMaximized() const
130{
aa47eebb
SC
131 if ( m_nowpeer == NULL )
132 return false;
ce00f59b 133
b2680ced 134 return m_nowpeer->IsMaximized();
489468fe
SC
135}
136
137void wxTopLevelWindowMac::Iconize(bool iconize)
138{
b2680ced
SC
139 if ( IsIconized() != iconize )
140 m_nowpeer->Iconize(iconize);
489468fe
SC
141}
142
143bool wxTopLevelWindowMac::IsIconized() const
144{
aa47eebb
SC
145 if ( m_nowpeer == NULL )
146 return false;
147
b2680ced 148 return m_nowpeer->IsIconized();
489468fe
SC
149}
150
151void wxTopLevelWindowMac::Restore()
152{
153 if ( IsMaximized() )
154 Maximize(false);
155 else if ( IsIconized() )
156 Iconize(false);
157}
158
159// ----------------------------------------------------------------------------
160// wxTopLevelWindowMac misc
161// ----------------------------------------------------------------------------
162
163wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
164{
165 return wxPoint(0, 0) ;
166}
167
168void wxTopLevelWindowMac::SetTitle(const wxString& title)
169{
8ec413ce
SC
170 m_label = title ;
171
cd0d451b
SC
172 if ( m_nowpeer )
173 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
489468fe
SC
174}
175
176wxString wxTopLevelWindowMac::GetTitle() const
177{
178 return wxWindow::GetLabel();
179}
180
dbc7ceb9
KO
181void wxTopLevelWindowMac::ShowWithoutActivating()
182{
598ad2b9
KO
183 // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't
184 // call it here.
185 if ( !wxWindow::Show(true) )
b487746a
KO
186 return;
187
188 m_nowpeer->ShowWithoutActivating();
ce00f59b 189
b487746a 190 // TODO: Should we call EVT_SIZE here?
dbc7ceb9
KO
191}
192
489468fe
SC
193bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
194{
b2680ced 195 return m_nowpeer->ShowFullScreen(show, style);
489468fe
SC
196}
197
198bool wxTopLevelWindowMac::IsFullScreen() const
199{
b2680ced 200 return m_nowpeer->IsFullScreen();
489468fe
SC
201}
202
b2680ced 203void wxTopLevelWindowMac::RequestUserAttention(int flags)
489468fe 204{
b2680ced 205 return m_nowpeer->RequestUserAttention(flags);
489468fe 206}
dbc7ceb9
KO
207
208bool wxTopLevelWindowMac::IsActive()
209{
210 return m_nowpeer->IsActive();
211}
efb2fa41 212
ebf7d5c4 213void wxTopLevelWindowMac::OSXSetModified(bool modified)
efb2fa41
KO
214{
215 m_nowpeer->SetModified(modified);
216}
217
ebf7d5c4 218bool wxTopLevelWindowMac::OSXIsModified() const
efb2fa41 219{
ebf7d5c4
KO
220 return m_nowpeer->IsModified();
221}
6a0e4ead
VZ
222
223void wxTopLevelWindowMac::SetRepresentedFilename(const wxString& filename)
224{
225 m_nowpeer->SetRepresentedFilename(filename);
226}