]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/toplevel_osx.cpp
guarding open combo box against AppDefined NSEvents issued by wxEventLoop::WakeUp...
[wxWidgets.git] / src / osx / toplevel_osx.cpp
index 0e646c5f697bd1ade572fa674dd47664f3b96cee..be18e7bc1a8ccebe7e378d408bc5dae91d9aa791 100644 (file)
@@ -1,12 +1,12 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        src/osx/toplevel.cpp
+// Name:        src/osx/toplevel_osx.cpp
 // Purpose:     implements wxTopLevelWindow for Mac
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     24.09.01
 // RCS-ID:      $Id$
 // Copyright:   (c) 2001-2004 Stefan Csomor
-// License:     wxWindows licence
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -73,10 +73,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
                                  long style,
                                  const wxString& name)
 {
-    int w = WidthDefault(size.x);
-    int h = HeightDefault(size.y);
-
-    if ( !wxNonOwnedWindow::Create(parent, id, pos, wxSize(w,h), style, name) )
+    if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) )
         return false;
 
     wxWindow::SetLabel( title ) ;
@@ -86,6 +83,17 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
     return true;
 }
 
+bool wxTopLevelWindowMac::Create(wxWindow *parent,
+                                 WXWindow nativeWindow)
+{
+    if ( !wxNonOwnedWindow::Create(parent, nativeWindow ) )
+        return false;
+
+    wxTopLevelWindows.Append(this);
+
+    return true;
+}
+
 wxTopLevelWindowMac::~wxTopLevelWindowMac()
 {
 }
@@ -95,10 +103,16 @@ bool wxTopLevelWindowMac::Destroy()
     // NB: this will get called during destruction if we don't do it now,
     // and may fire a kill focus event on a control being destroyed
 #if wxOSX_USE_CARBON
-    if (m_nowpeer->GetWXWindow())
+    if (m_nowpeer && m_nowpeer->GetWXWindow())
         ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() );
 #endif
-    return wxTopLevelWindowBase::Destroy();
+    // delayed destruction: the tlw will be deleted during the next idle
+    // loop iteration
+    if ( !wxPendingDelete.Member(this) )
+        wxPendingDelete.Append(this);
+    
+    Hide();
+    return true;
 }
 
 
@@ -114,6 +128,9 @@ void wxTopLevelWindowMac::Maximize(bool maximize)
 
 bool wxTopLevelWindowMac::IsMaximized() const
 {
+    if ( m_nowpeer == NULL )
+        return false;
+
     return m_nowpeer->IsMaximized();
 }
 
@@ -125,6 +142,9 @@ void wxTopLevelWindowMac::Iconize(bool iconize)
 
 bool wxTopLevelWindowMac::IsIconized() const
 {
+    if ( m_nowpeer == NULL )
+        return false;
+
     return m_nowpeer->IsIconized();
 }
 
@@ -147,7 +167,8 @@ wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
 
 void wxTopLevelWindowMac::SetTitle(const wxString& title)
 {
-    wxWindow::SetLabel( title ) ;
+    m_label = title ;
+
     if ( m_nowpeer )
         m_nowpeer->SetTitle(title, GetFont().GetEncoding() );
 }
@@ -159,7 +180,15 @@ wxString wxTopLevelWindowMac::GetTitle() const
 
 void wxTopLevelWindowMac::ShowWithoutActivating()
 {
-    return m_nowpeer->ShowWithoutActivating();
+    // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't
+    // call it here.
+    if ( !wxWindow::Show(true) )
+        return;
+
+    m_nowpeer->ShowWithoutActivating();
+
+    // because apps expect a size event to occur at this moment
+    SendSizeEvent();
 }
 
 bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
@@ -181,3 +210,18 @@ bool wxTopLevelWindowMac::IsActive()
 {
     return m_nowpeer->IsActive();
 }
+
+void wxTopLevelWindowMac::OSXSetModified(bool modified)
+{
+    m_nowpeer->SetModified(modified);
+}
+
+bool wxTopLevelWindowMac::OSXIsModified() const
+{
+    return m_nowpeer->IsModified();
+}
+
+void wxTopLevelWindowMac::SetRepresentedFilename(const wxString& filename)
+{
+    m_nowpeer->SetRepresentedFilename(filename);
+}