]> git.saurik.com Git - wxWidgets.git/blob - src/osx/toplevel_osx.cpp
The alignment controls are now left-aligned if the floating controls are not shown.
[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 // Copyright: (c) 2001-2004 Stefan Csomor
8 // Licence: wxWindows licence
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
39 #include "wx/tooltip.h"
40 #include "wx/dnd.h"
41
42 #if wxUSE_SYSTEM_OPTIONS
43 #include "wx/sysopt.h"
44 #endif
45
46 // for targeting OSX
47 #include "wx/osx/private.h"
48
49 // ============================================================================
50 // wxTopLevelWindowMac implementation
51 // ============================================================================
52
53 BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase)
54 END_EVENT_TABLE()
55
56 // ----------------------------------------------------------------------------
57 // wxTopLevelWindowMac creation
58 // ----------------------------------------------------------------------------
59
60
61 void wxTopLevelWindowMac::Init()
62 {
63 m_iconized =
64 m_maximizeOnShow = false;
65 }
66
67 bool 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 {
75 if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) )
76 return false;
77
78 wxWindow::SetLabel( title ) ;
79 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
80 wxTopLevelWindows.Append(this);
81
82 return true;
83 }
84
85 bool wxTopLevelWindowMac::Create(wxWindow *parent,
86 WXWindow nativeWindow)
87 {
88 if ( !wxNonOwnedWindow::Create(parent, nativeWindow ) )
89 return false;
90
91 wxTopLevelWindows.Append(this);
92
93 return true;
94 }
95
96 wxTopLevelWindowMac::~wxTopLevelWindowMac()
97 {
98 }
99
100 bool 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
105 if (m_nowpeer && m_nowpeer->GetWXWindow())
106 ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() );
107 #endif
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;
115 }
116
117
118 // ----------------------------------------------------------------------------
119 // wxTopLevelWindowMac maximize/minimize
120 // ----------------------------------------------------------------------------
121
122 void wxTopLevelWindowMac::Maximize(bool maximize)
123 {
124 if ( IsMaximized() != maximize )
125 m_nowpeer->Maximize(maximize);
126 }
127
128 bool wxTopLevelWindowMac::IsMaximized() const
129 {
130 if ( m_nowpeer == NULL )
131 return false;
132
133 return m_nowpeer->IsMaximized();
134 }
135
136 void wxTopLevelWindowMac::Iconize(bool iconize)
137 {
138 if ( IsIconized() != iconize )
139 m_nowpeer->Iconize(iconize);
140 }
141
142 bool wxTopLevelWindowMac::IsIconized() const
143 {
144 if ( m_nowpeer == NULL )
145 return false;
146
147 return m_nowpeer->IsIconized();
148 }
149
150 void wxTopLevelWindowMac::Restore()
151 {
152 if ( IsMaximized() )
153 Maximize(false);
154 else if ( IsIconized() )
155 Iconize(false);
156 }
157
158 // ----------------------------------------------------------------------------
159 // wxTopLevelWindowMac misc
160 // ----------------------------------------------------------------------------
161
162 wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
163 {
164 return wxPoint(0, 0) ;
165 }
166
167 void wxTopLevelWindowMac::SetTitle(const wxString& title)
168 {
169 m_label = title ;
170
171 if ( m_nowpeer )
172 m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
173 }
174
175 wxString wxTopLevelWindowMac::GetTitle() const
176 {
177 return wxWindow::GetLabel();
178 }
179
180 void wxTopLevelWindowMac::ShowWithoutActivating()
181 {
182 // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't
183 // call it here.
184 if ( !wxWindow::Show(true) )
185 return;
186
187 m_nowpeer->ShowWithoutActivating();
188
189 // because apps expect a size event to occur at this moment
190 SendSizeEvent();
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 }