1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for Mac
4 // Author: Stefan Csomor
8 // Copyright: (c) 2001-2004 Stefan Csomor
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/toplevel.h"
32 #include "wx/string.h"
35 #include "wx/settings.h"
36 #include "wx/strconv.h"
37 #include "wx/control.h"
40 #include "wx/tooltip.h"
43 #if wxUSE_SYSTEM_OPTIONS
44 #include "wx/sysopt.h"
48 #include "wx/osx/private.h"
50 // ============================================================================
51 // wxTopLevelWindowMac implementation
52 // ============================================================================
54 BEGIN_EVENT_TABLE(wxTopLevelWindowMac
, wxTopLevelWindowBase
)
57 // ----------------------------------------------------------------------------
58 // wxTopLevelWindowMac creation
59 // ----------------------------------------------------------------------------
62 void wxTopLevelWindowMac
::Init()
65 m_maximizeOnShow
= false;
68 bool wxTopLevelWindowMac
::Create(wxWindow
*parent
,
70 const wxString
& title
,
76 int w
= WidthDefault(size
.x
);
77 int h
= HeightDefault(size
.y
);
79 if ( !wxNonOwnedWindow
::Create(parent
, id
, pos
, wxSize(w
,h
), style
, name
) )
82 wxWindow
::SetLabel( title
) ;
83 m_nowpeer
->SetTitle(title
, GetFont().GetEncoding() );
84 wxTopLevelWindows
.Append(this);
89 bool wxTopLevelWindowMac
::Create(wxWindow
*parent
,
90 WXWindow nativeWindow
)
92 if ( !wxNonOwnedWindow
::Create(parent
, nativeWindow
) )
95 wxTopLevelWindows
.Append(this);
100 wxTopLevelWindowMac
::~wxTopLevelWindowMac()
104 bool wxTopLevelWindowMac
::Destroy()
106 // NB: this will get called during destruction if we don't do it now,
107 // and may fire a kill focus event on a control being destroyed
109 if (m_nowpeer
&& m_nowpeer
->GetWXWindow())
110 ClearKeyboardFocus( (WindowRef
)m_nowpeer
->GetWXWindow() );
112 return wxTopLevelWindowBase
::Destroy();
116 // ----------------------------------------------------------------------------
117 // wxTopLevelWindowMac maximize/minimize
118 // ----------------------------------------------------------------------------
120 void wxTopLevelWindowMac
::Maximize(bool maximize
)
122 if ( IsMaximized() != maximize
)
123 m_nowpeer
->Maximize(maximize
);
126 bool wxTopLevelWindowMac
::IsMaximized() const
128 if ( m_nowpeer
== NULL
)
131 return m_nowpeer
->IsMaximized();
134 void wxTopLevelWindowMac
::Iconize(bool iconize
)
136 if ( IsIconized() != iconize
)
137 m_nowpeer
->Iconize(iconize
);
140 bool wxTopLevelWindowMac
::IsIconized() const
142 if ( m_nowpeer
== NULL
)
145 return m_nowpeer
->IsIconized();
148 void wxTopLevelWindowMac
::Restore()
152 else if ( IsIconized() )
156 // ----------------------------------------------------------------------------
157 // wxTopLevelWindowMac misc
158 // ----------------------------------------------------------------------------
160 wxPoint wxTopLevelWindowMac
::GetClientAreaOrigin() const
162 return wxPoint(0, 0) ;
165 void wxTopLevelWindowMac
::SetTitle(const wxString
& title
)
167 wxWindow
::SetLabel( title
) ;
169 m_nowpeer
->SetTitle(title
, GetFont().GetEncoding() );
172 wxString wxTopLevelWindowMac
::GetTitle() const
174 return wxWindow
::GetLabel();
177 void wxTopLevelWindowMac
::ShowWithoutActivating()
179 // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't
181 if ( !wxWindow
::Show(true) )
184 m_nowpeer
->ShowWithoutActivating();
186 // TODO: Should we call EVT_SIZE here?
189 bool wxTopLevelWindowMac
::ShowFullScreen(bool show
, long style
)
191 return m_nowpeer
->ShowFullScreen(show
, style
);
194 bool wxTopLevelWindowMac
::IsFullScreen() const
196 return m_nowpeer
->IsFullScreen();
199 void wxTopLevelWindowMac
::RequestUserAttention(int flags
)
201 return m_nowpeer
->RequestUserAttention(flags
);
204 bool wxTopLevelWindowMac
::IsActive()
206 return m_nowpeer
->IsActive();
209 void wxTopLevelWindowMac
::OSXSetModified(bool modified
)
211 m_nowpeer
->SetModified(modified
);
214 bool wxTopLevelWindowMac
::OSXIsModified() const
216 return m_nowpeer
->IsModified();