]> git.saurik.com Git - wxWidgets.git/blob - src/osx/toplevel_osx.cpp
Break implicit dependency of "core" on "adv" via wxXmlResourceHandlerImplBase.
[wxWidgets.git] / src / osx / toplevel_osx.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/toplevel_osx.cpp
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
9 // Licence: wxWindows licence
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
40 #include "wx/tooltip.h"
41 #include "wx/dnd.h"
42
43 #if wxUSE_SYSTEM_OPTIONS
44 #include "wx/sysopt.h"
45 #endif
46
47 // for targeting OSX
48 #include "wx/osx/private.h"
49
50 // ============================================================================
51 // wxTopLevelWindowMac implementation
52 // ============================================================================
53
54 BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase)
55 END_EVENT_TABLE()
56
57 // ----------------------------------------------------------------------------
58 // wxTopLevelWindowMac creation
59 // ----------------------------------------------------------------------------
60
61
62 void wxTopLevelWindowMac::Init()
63 {
64 m_iconized =
65 m_maximizeOnShow = false;
66 }
67
68 bool 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 {
76 if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) )
77 return false;
78
79 wxWindow::SetLabel( title ) ;
80 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
81 wxTopLevelWindows.Append(this);
82
83 return true;
84 }
85
86 bool wxTopLevelWindowMac::Create(wxWindow *parent,
87 WXWindow nativeWindow)
88 {
89 if ( !wxNonOwnedWindow::Create(parent, nativeWindow ) )
90 return false;
91
92 wxTopLevelWindows.Append(this);
93
94 return true;
95 }
96
97 wxTopLevelWindowMac::~wxTopLevelWindowMac()
98 {
99 }
100
101 bool 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
106 if (m_nowpeer && m_nowpeer->GetWXWindow())
107 ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() );
108 #endif
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;
116 }
117
118
119 // ----------------------------------------------------------------------------
120 // wxTopLevelWindowMac maximize/minimize
121 // ----------------------------------------------------------------------------
122
123 void wxTopLevelWindowMac::Maximize(bool maximize)
124 {
125 if ( IsMaximized() != maximize )
126 m_nowpeer->Maximize(maximize);
127 }
128
129 bool wxTopLevelWindowMac::IsMaximized() const
130 {
131 if ( m_nowpeer == NULL )
132 return false;
133
134 return m_nowpeer->IsMaximized();
135 }
136
137 void wxTopLevelWindowMac::Iconize(bool iconize)
138 {
139 if ( IsIconized() != iconize )
140 m_nowpeer->Iconize(iconize);
141 }
142
143 bool wxTopLevelWindowMac::IsIconized() const
144 {
145 if ( m_nowpeer == NULL )
146 return false;
147
148 return m_nowpeer->IsIconized();
149 }
150
151 void wxTopLevelWindowMac::Restore()
152 {
153 if ( IsMaximized() )
154 Maximize(false);
155 else if ( IsIconized() )
156 Iconize(false);
157 }
158
159 // ----------------------------------------------------------------------------
160 // wxTopLevelWindowMac misc
161 // ----------------------------------------------------------------------------
162
163 wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
164 {
165 return wxPoint(0, 0) ;
166 }
167
168 void wxTopLevelWindowMac::SetTitle(const wxString& title)
169 {
170 m_label = title ;
171
172 if ( m_nowpeer )
173 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
174 }
175
176 wxString wxTopLevelWindowMac::GetTitle() const
177 {
178 return wxWindow::GetLabel();
179 }
180
181 void wxTopLevelWindowMac::ShowWithoutActivating()
182 {
183 // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't
184 // call it here.
185 if ( !wxWindow::Show(true) )
186 return;
187
188 m_nowpeer->ShowWithoutActivating();
189
190 // TODO: Should we call EVT_SIZE here?
191 }
192
193 bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
194 {
195 return m_nowpeer->ShowFullScreen(show, style);
196 }
197
198 bool wxTopLevelWindowMac::IsFullScreen() const
199 {
200 return m_nowpeer->IsFullScreen();
201 }
202
203 void wxTopLevelWindowMac::RequestUserAttention(int flags)
204 {
205 return m_nowpeer->RequestUserAttention(flags);
206 }
207
208 bool wxTopLevelWindowMac::IsActive()
209 {
210 return m_nowpeer->IsActive();
211 }
212
213 void wxTopLevelWindowMac::OSXSetModified(bool modified)
214 {
215 m_nowpeer->SetModified(modified);
216 }
217
218 bool wxTopLevelWindowMac::OSXIsModified() const
219 {
220 return m_nowpeer->IsModified();
221 }
222
223 void wxTopLevelWindowMac::SetRepresentedFilename(const wxString& filename)
224 {
225 m_nowpeer->SetRepresentedFilename(filename);
226 }