]> git.saurik.com Git - wxWidgets.git/blame - src/osx/toplevel_osx.cpp
Implement setFont on the iOS port of wxStaticText.
[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
489468fe 7// Copyright: (c) 2001-2004 Stefan Csomor
526954c5 8// Licence: wxWindows licence
489468fe
SC
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#include "wx/toplevel.h"
27
28#ifndef WX_PRECOMP
29 #include "wx/app.h"
30 #include "wx/frame.h"
31 #include "wx/string.h"
32 #include "wx/log.h"
33 #include "wx/intl.h"
34 #include "wx/settings.h"
35 #include "wx/strconv.h"
36 #include "wx/control.h"
37#endif //WX_PRECOMP
38
489468fe
SC
39#include "wx/tooltip.h"
40#include "wx/dnd.h"
41
42#if wxUSE_SYSTEM_OPTIONS
43 #include "wx/sysopt.h"
44#endif
45
489468fe 46// for targeting OSX
1f0c8f31 47#include "wx/osx/private.h"
489468fe
SC
48
49// ============================================================================
50// wxTopLevelWindowMac implementation
51// ============================================================================
52
53BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase)
54END_EVENT_TABLE()
55
56// ----------------------------------------------------------------------------
57// wxTopLevelWindowMac creation
58// ----------------------------------------------------------------------------
59
489468fe
SC
60
61void wxTopLevelWindowMac::Init()
62{
63 m_iconized =
64 m_maximizeOnShow = false;
489468fe
SC
65}
66
67bool wxTopLevelWindowMac::Create(wxWindow *parent,
68 wxWindowID id,
69 const wxString& title,
70 const wxPoint& pos,
71 const wxSize& size,
72 long style,
73 const wxString& name)
74{
e08b4823 75 if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) )
489468fe
SC
76 return false;
77
78 wxWindow::SetLabel( title ) ;
b2680ced 79 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
489468fe
SC
80 wxTopLevelWindows.Append(this);
81
82 return true;
83}
84
638b3cd7
SC
85bool wxTopLevelWindowMac::Create(wxWindow *parent,
86 WXWindow nativeWindow)
87{
88 if ( !wxNonOwnedWindow::Create(parent, nativeWindow ) )
89 return false;
ce00f59b 90
638b3cd7 91 wxTopLevelWindows.Append(this);
ce00f59b 92
638b3cd7
SC
93 return true;
94}
95
489468fe
SC
96wxTopLevelWindowMac::~wxTopLevelWindowMac()
97{
489468fe
SC
98}
99
c9f9deab
KO
100bool wxTopLevelWindowMac::Destroy()
101{
102 // NB: this will get called during destruction if we don't do it now,
103 // and may fire a kill focus event on a control being destroyed
104#if wxOSX_USE_CARBON
d4d799e9 105 if (m_nowpeer && m_nowpeer->GetWXWindow())
c9f9deab
KO
106 ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() );
107#endif
eebddb37
SC
108 // delayed destruction: the tlw will be deleted during the next idle
109 // loop iteration
110 if ( !wxPendingDelete.Member(this) )
111 wxPendingDelete.Append(this);
112
113 Hide();
114 return true;
c9f9deab
KO
115}
116
489468fe
SC
117
118// ----------------------------------------------------------------------------
119// wxTopLevelWindowMac maximize/minimize
120// ----------------------------------------------------------------------------
121
122void wxTopLevelWindowMac::Maximize(bool maximize)
123{
b2680ced
SC
124 if ( IsMaximized() != maximize )
125 m_nowpeer->Maximize(maximize);
489468fe
SC
126}
127
128bool wxTopLevelWindowMac::IsMaximized() const
129{
aa47eebb
SC
130 if ( m_nowpeer == NULL )
131 return false;
ce00f59b 132
b2680ced 133 return m_nowpeer->IsMaximized();
489468fe
SC
134}
135
136void wxTopLevelWindowMac::Iconize(bool iconize)
137{
b2680ced
SC
138 if ( IsIconized() != iconize )
139 m_nowpeer->Iconize(iconize);
489468fe
SC
140}
141
142bool wxTopLevelWindowMac::IsIconized() const
143{
aa47eebb
SC
144 if ( m_nowpeer == NULL )
145 return false;
146
b2680ced 147 return m_nowpeer->IsIconized();
489468fe
SC
148}
149
150void wxTopLevelWindowMac::Restore()
151{
152 if ( IsMaximized() )
153 Maximize(false);
154 else if ( IsIconized() )
155 Iconize(false);
156}
157
158// ----------------------------------------------------------------------------
159// wxTopLevelWindowMac misc
160// ----------------------------------------------------------------------------
161
162wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
163{
164 return wxPoint(0, 0) ;
165}
166
167void wxTopLevelWindowMac::SetTitle(const wxString& title)
168{
8ec413ce
SC
169 m_label = title ;
170
cd0d451b
SC
171 if ( m_nowpeer )
172 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
489468fe
SC
173}
174
175wxString wxTopLevelWindowMac::GetTitle() const
176{
177 return wxWindow::GetLabel();
178}
179
dbc7ceb9
KO
180void wxTopLevelWindowMac::ShowWithoutActivating()
181{
598ad2b9
KO
182 // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't
183 // call it here.
184 if ( !wxWindow::Show(true) )
b487746a
KO
185 return;
186
187 m_nowpeer->ShowWithoutActivating();
ce00f59b 188
c609b780
SC
189 // because apps expect a size event to occur at this moment
190 SendSizeEvent();
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}