]> git.saurik.com Git - wxWidgets.git/commitdiff
toplevel fixes
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 30 Sep 2001 17:34:51 +0000 (17:34 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 30 Sep 2001 17:34:51 +0000 (17:34 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11746 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mac/dialog.h
src/mac/carbon/dialog.cpp
src/mac/carbon/frame.cpp
src/mac/carbon/toplevel.cpp [new file with mode: 0644]
src/mac/dialog.cpp
src/mac/frame.cpp
src/mac/morefile/MoreExtr.cpp
src/mac/toplevel.cpp [new file with mode: 0644]

index 6ae557e92764c1f65751ba3fe2c359f782f55830..2ba611bf9aff0855b33c7d7fb23164a067cedf16 100644 (file)
@@ -64,7 +64,7 @@ public:
 
     ~wxDialog();
 
-    virtual bool Destroy();
+//    virtual bool Destroy();
     bool Show(bool show);
 
     void SetModal(bool flag);
@@ -87,7 +87,7 @@ public:
     // --------------
 
     // event handlers
-    bool OnClose();
+//    bool OnClose();
     void OnCharHook(wxKeyEvent& event);
     void OnCloseWindow(wxCloseEvent& event);
 
@@ -99,10 +99,6 @@ public:
     // Responds to colour changes
     void OnSysColourChanged(wxSysColourChangedEvent& event);
 
-    // override more base class virtuals
-    virtual void DoGetPosition(int *x, int *y) const;
-    virtual void DoSetClientSize(int width, int height);
-
     // show modal dialog and enter modal loop
     void DoShowModal();
 
index 1490247378e9c89d7e8da9176cbc742a7221d4aa..82752055947f9697b99dfb431b3ce785f3cb232b 100644 (file)
@@ -28,15 +28,17 @@ wxList wxModalDialogs;
 extern wxList wxPendingDelete;
 
 #if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
+IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
 
-BEGIN_EVENT_TABLE(wxDialog, wxPanel)
-       EVT_SIZE(wxDialog::OnSize)
+BEGIN_EVENT_TABLE(wxDialog, wxTopLevelWindow)
   EVT_BUTTON(wxID_OK, wxDialog::OnOK)
   EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
   EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
+
   EVT_CHAR_HOOK(wxDialog::OnCharHook)
+
   EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
+
   EVT_CLOSE(wxDialog::OnCloseWindow)
 END_EVENT_TABLE()
 
@@ -58,15 +60,9 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
 
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
   
-  if (!parent)
-    wxTopLevelWindows.Append(this);
-
-  if (parent) parent->AddChild(this);
 
-  if ( id == -1 )
-       m_windowId = (int)NewControlId();
-  else
-       m_windowId = id;
+  if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
+        return FALSE;
 
        MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style)  , name ) ;
 
@@ -93,29 +89,16 @@ void wxDialog::SetModal(bool flag)
 wxDialog::~wxDialog()
 {
        m_isBeingDeleted = TRUE ;
-    wxTopLevelWindows.DeleteObject(this);
-
-       Show(FALSE);
-
-    if ( !IsModal() )
-       wxModelessWindows.DeleteObject(this);
-
-    // If this is the last top-level window, exit.
-    if (wxTheApp && (wxTopLevelWindows.Number() == 0))
-    {
-      wxTheApp->SetTopWindow(NULL);
-
-      if (wxTheApp->GetExitOnFrameDelete())
-      {
-               wxTheApp->ExitMainLoop() ;
-      }
-    }
+  Show(FALSE);
 }
 
-// By default, pressing escape cancels the dialog
+// By default, pressing escape cancels the dialog , on mac command-stop does the same thing
 void wxDialog::OnCharHook(wxKeyEvent& event)
 {
-  if (event.m_keyCode == WXK_ESCAPE)
+  if (
+    ( event.m_keyCode == WXK_ESCAPE || 
+      ( event.m_keyCode == '.' && event.MetaDown() ) )
+     && FindWindow(wxID_CANCEL) )
   {
                // Behaviour changed in 2.0: we'll send a Cancel message
                // to the dialog instead of Close.
@@ -129,17 +112,6 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
   event.Skip();
 }
 
-
-void wxDialog::DoSetClientSize(int width, int height)
-{
-       wxWindow::DoSetClientSize( width , height ) ;
-}
-
-void wxDialog::DoGetPosition(int *x, int *y) const
-{
-       wxWindow::DoGetPosition( x , y ) ;
-}
-
 bool wxDialog::IsModal() const
 {
     return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
@@ -151,7 +123,6 @@ bool wxDialog::IsModalShowing() const
     return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
 }
 
-
 extern bool s_macIsInModalLoop ;
 
 bool wxDialog::Show(bool show)
@@ -295,16 +266,6 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
     closing.DeleteObject(this);
 }
 
-// Destroy the window (delayed, if a managed window)
-bool wxDialog::Destroy()
-{
-    wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
-                 _T("wxDialog destroyed twice") );
-
-    wxPendingDelete.Append(this);
-  return TRUE;
-}
-
 void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
index 04776b8cb1ee5f1a2e45c679ba72e95941a0be58..f9f0d2bec6c18873146f7bd5bccfb9f0d39aed8d 100644 (file)
@@ -30,7 +30,6 @@ extern wxList wxPendingDelete;
 
 #if !USE_SHARED_LIBRARY
 BEGIN_EVENT_TABLE(wxFrameMac, wxFrameBase)
-//  EVT_SIZE(wxFrameMac::OnSize)
   EVT_ACTIVATE(wxFrameMac::OnActivate)
  // EVT_MENU_HIGHLIGHT_ALL(wxFrameMac::OnMenuHighlight)
   EVT_SYS_COLOUR_CHANGED(wxFrameMac::OnSysColourChanged)
@@ -107,15 +106,8 @@ bool wxFrameMac::Create(wxWindow *parent,
 {
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
 
-  if ( id > -1 )
-    m_windowId = id;
-  else
-    m_windowId = (int)NewControlId();
-
-  if (parent) parent->AddChild(this);
-
-  if (!parent)
-    wxTopLevelWindows.Append(this);
+    if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
+        return FALSE;
 
   MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
   
@@ -129,23 +121,9 @@ bool wxFrameMac::Create(wxWindow *parent,
 wxFrameMac::~wxFrameMac()
 {
   m_isBeingDeleted = TRUE;
-  wxTopLevelWindows.DeleteObject(this);
 
   DeleteAllBars();
 
-/* Check if it's the last top-level window */
-
-  if (wxTheApp && (wxTopLevelWindows.Number() == 0))
-  {
-    wxTheApp->SetTopWindow(NULL);
-
-    if (wxTheApp->GetExitOnFrameDelete())
-    {
-       wxTheApp->ExitMainLoop() ;
-    }
-  }
-
-  wxModelessWindows.DeleteObject(this);
 }
 
 
@@ -216,46 +194,39 @@ void wxFrameMac::OnActivate(wxActivateEvent& event)
 {
     if ( !event.GetActive() )
     {
-       // remember the last focused child
+       // remember the last focused child if it is our child
         m_winLastFocused = FindFocus();
-        while ( m_winLastFocused )
+
+        // so we NULL it out if it's a child from some other frame
+        wxWindow *win = m_winLastFocused;
+        while ( win )
         {
-            if ( GetChildren().Find(m_winLastFocused) )
+            if ( win->IsTopLevel() )
+            {
+                if ( win != this )
+                {
+                    m_winLastFocused = NULL;
+                }
+
                 break;
+            }
 
-            m_winLastFocused = m_winLastFocused->GetParent();
+            win = win->GetParent();
         }
 
         event.Skip();
     }
        else
        {
-/*
-    for ( wxWindowList::Node *node = GetChildren().GetFirst();
-          node;
-          node = node->GetNext() )
-    {
-        // FIXME all this is totally bogus - we need to do the same as wxPanel,
-        //       but how to do it without duplicating the code?
-
-        // restore focus
-        wxWindow *child = node->GetData();
-
-        if ( !child->IsTopLevel() && child->AcceptsFocus()
-#if wxUSE_TOOLBAR
-             && !wxDynamicCast(child, wxToolBar)
-#endif // wxUSE_TOOLBAR
-#if wxUSE_STATUSBAR
-             && !wxDynamicCast(child, wxStatusBar)
-#endif // wxUSE_STATUSBAR
-           )
+        // restore focus to the child which was last focused
+        wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
+                                            : NULL;
+        if ( !parent )
         {
-            child->SetFocus();
-            break;
+            parent = this;
         }
-    }
-   */
-       wxSetFocusToChild(this, &m_winLastFocused);
+
+       wxSetFocusToChild(parent, &m_winLastFocused);
 
            if ( m_frameMenuBar != NULL )
            {
diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp
new file mode 100644 (file)
index 0000000..9e34691
--- /dev/null
@@ -0,0 +1,143 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        mac/toplevel.cpp
+// Purpose:     implements wxTopLevelWindow for MSW
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     24.09.01
+// RCS-ID:      $Id$
+// Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
+// License:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+    #pragma implementation "toplevel.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/toplevel.h"
+    #include "wx/string.h"
+    #include "wx/log.h"
+    #include "wx/intl.h"
+#endif //WX_PRECOMP
+
+// ----------------------------------------------------------------------------
+// globals
+// ----------------------------------------------------------------------------
+
+// list of all frames and modeless dialogs
+wxWindowList wxModelessWindows;
+
+// ============================================================================
+// wxTopLevelWindowMac implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac creation
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Init()
+{
+    m_iconized =
+    m_maximizeOnShow = FALSE;
+}
+
+bool wxTopLevelWindowMac::Create(wxWindow *parent,
+                                 wxWindowID id,
+                                 const wxString& title,
+                                 const wxPoint& pos,
+                                 const wxSize& size,
+                                 long style,
+                                 const wxString& name)
+{
+    // init our fields
+    Init();
+
+    m_windowStyle = style;
+
+    SetName(name);
+
+    m_windowId = id == -1 ? NewControlId() : id;
+
+    wxTopLevelWindows.Append(this);
+
+    if ( parent )
+        parent->AddChild(this);
+
+    return TRUE;
+}
+
+wxTopLevelWindowMac::~wxTopLevelWindowMac()
+{
+    wxTopLevelWindows.DeleteObject(this);
+
+    if ( wxModelessWindows.Find(this) )
+        wxModelessWindows.DeleteObject(this);
+
+    // If this is the last top-level window, exit.
+    if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
+    {
+        wxTheApp->SetTopWindow(NULL);
+
+        if ( wxTheApp->GetExitOnFrameDelete() )
+        {
+          wxTheApp->ExitMainLoop() ;        
+        }
+    }
+}
+
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac maximize/minimize
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Maximize(bool maximize)
+{
+    // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsMaximized() const
+{
+    return false ; 
+}
+
+void wxTopLevelWindowMac::Iconize(bool iconize)
+{
+    // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsIconized() const
+{
+       // mac dialogs cannot be iconized
+    return FALSE;
+}
+
+void wxTopLevelWindowMac::Restore()
+{
+    // not available on mac
+}
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac misc
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
+{
+    // this sets m_icon
+    wxTopLevelWindowBase::SetIcon(icon);
+}
index 1490247378e9c89d7e8da9176cbc742a7221d4aa..82752055947f9697b99dfb431b3ce785f3cb232b 100644 (file)
@@ -28,15 +28,17 @@ wxList wxModalDialogs;
 extern wxList wxPendingDelete;
 
 #if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
+IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
 
-BEGIN_EVENT_TABLE(wxDialog, wxPanel)
-       EVT_SIZE(wxDialog::OnSize)
+BEGIN_EVENT_TABLE(wxDialog, wxTopLevelWindow)
   EVT_BUTTON(wxID_OK, wxDialog::OnOK)
   EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
   EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
+
   EVT_CHAR_HOOK(wxDialog::OnCharHook)
+
   EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
+
   EVT_CLOSE(wxDialog::OnCloseWindow)
 END_EVENT_TABLE()
 
@@ -58,15 +60,9 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
 
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
   
-  if (!parent)
-    wxTopLevelWindows.Append(this);
-
-  if (parent) parent->AddChild(this);
 
-  if ( id == -1 )
-       m_windowId = (int)NewControlId();
-  else
-       m_windowId = id;
+  if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
+        return FALSE;
 
        MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style)  , name ) ;
 
@@ -93,29 +89,16 @@ void wxDialog::SetModal(bool flag)
 wxDialog::~wxDialog()
 {
        m_isBeingDeleted = TRUE ;
-    wxTopLevelWindows.DeleteObject(this);
-
-       Show(FALSE);
-
-    if ( !IsModal() )
-       wxModelessWindows.DeleteObject(this);
-
-    // If this is the last top-level window, exit.
-    if (wxTheApp && (wxTopLevelWindows.Number() == 0))
-    {
-      wxTheApp->SetTopWindow(NULL);
-
-      if (wxTheApp->GetExitOnFrameDelete())
-      {
-               wxTheApp->ExitMainLoop() ;
-      }
-    }
+  Show(FALSE);
 }
 
-// By default, pressing escape cancels the dialog
+// By default, pressing escape cancels the dialog , on mac command-stop does the same thing
 void wxDialog::OnCharHook(wxKeyEvent& event)
 {
-  if (event.m_keyCode == WXK_ESCAPE)
+  if (
+    ( event.m_keyCode == WXK_ESCAPE || 
+      ( event.m_keyCode == '.' && event.MetaDown() ) )
+     && FindWindow(wxID_CANCEL) )
   {
                // Behaviour changed in 2.0: we'll send a Cancel message
                // to the dialog instead of Close.
@@ -129,17 +112,6 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
   event.Skip();
 }
 
-
-void wxDialog::DoSetClientSize(int width, int height)
-{
-       wxWindow::DoSetClientSize( width , height ) ;
-}
-
-void wxDialog::DoGetPosition(int *x, int *y) const
-{
-       wxWindow::DoGetPosition( x , y ) ;
-}
-
 bool wxDialog::IsModal() const
 {
     return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
@@ -151,7 +123,6 @@ bool wxDialog::IsModalShowing() const
     return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
 }
 
-
 extern bool s_macIsInModalLoop ;
 
 bool wxDialog::Show(bool show)
@@ -295,16 +266,6 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
     closing.DeleteObject(this);
 }
 
-// Destroy the window (delayed, if a managed window)
-bool wxDialog::Destroy()
-{
-    wxCHECK_MSG( !wxPendingDelete.Member(this), FALSE,
-                 _T("wxDialog destroyed twice") );
-
-    wxPendingDelete.Append(this);
-  return TRUE;
-}
-
 void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
index 04776b8cb1ee5f1a2e45c679ba72e95941a0be58..f9f0d2bec6c18873146f7bd5bccfb9f0d39aed8d 100644 (file)
@@ -30,7 +30,6 @@ extern wxList wxPendingDelete;
 
 #if !USE_SHARED_LIBRARY
 BEGIN_EVENT_TABLE(wxFrameMac, wxFrameBase)
-//  EVT_SIZE(wxFrameMac::OnSize)
   EVT_ACTIVATE(wxFrameMac::OnActivate)
  // EVT_MENU_HIGHLIGHT_ALL(wxFrameMac::OnMenuHighlight)
   EVT_SYS_COLOUR_CHANGED(wxFrameMac::OnSysColourChanged)
@@ -107,15 +106,8 @@ bool wxFrameMac::Create(wxWindow *parent,
 {
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
 
-  if ( id > -1 )
-    m_windowId = id;
-  else
-    m_windowId = (int)NewControlId();
-
-  if (parent) parent->AddChild(this);
-
-  if (!parent)
-    wxTopLevelWindows.Append(this);
+    if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
+        return FALSE;
 
   MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
   
@@ -129,23 +121,9 @@ bool wxFrameMac::Create(wxWindow *parent,
 wxFrameMac::~wxFrameMac()
 {
   m_isBeingDeleted = TRUE;
-  wxTopLevelWindows.DeleteObject(this);
 
   DeleteAllBars();
 
-/* Check if it's the last top-level window */
-
-  if (wxTheApp && (wxTopLevelWindows.Number() == 0))
-  {
-    wxTheApp->SetTopWindow(NULL);
-
-    if (wxTheApp->GetExitOnFrameDelete())
-    {
-       wxTheApp->ExitMainLoop() ;
-    }
-  }
-
-  wxModelessWindows.DeleteObject(this);
 }
 
 
@@ -216,46 +194,39 @@ void wxFrameMac::OnActivate(wxActivateEvent& event)
 {
     if ( !event.GetActive() )
     {
-       // remember the last focused child
+       // remember the last focused child if it is our child
         m_winLastFocused = FindFocus();
-        while ( m_winLastFocused )
+
+        // so we NULL it out if it's a child from some other frame
+        wxWindow *win = m_winLastFocused;
+        while ( win )
         {
-            if ( GetChildren().Find(m_winLastFocused) )
+            if ( win->IsTopLevel() )
+            {
+                if ( win != this )
+                {
+                    m_winLastFocused = NULL;
+                }
+
                 break;
+            }
 
-            m_winLastFocused = m_winLastFocused->GetParent();
+            win = win->GetParent();
         }
 
         event.Skip();
     }
        else
        {
-/*
-    for ( wxWindowList::Node *node = GetChildren().GetFirst();
-          node;
-          node = node->GetNext() )
-    {
-        // FIXME all this is totally bogus - we need to do the same as wxPanel,
-        //       but how to do it without duplicating the code?
-
-        // restore focus
-        wxWindow *child = node->GetData();
-
-        if ( !child->IsTopLevel() && child->AcceptsFocus()
-#if wxUSE_TOOLBAR
-             && !wxDynamicCast(child, wxToolBar)
-#endif // wxUSE_TOOLBAR
-#if wxUSE_STATUSBAR
-             && !wxDynamicCast(child, wxStatusBar)
-#endif // wxUSE_STATUSBAR
-           )
+        // restore focus to the child which was last focused
+        wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
+                                            : NULL;
+        if ( !parent )
         {
-            child->SetFocus();
-            break;
+            parent = this;
         }
-    }
-   */
-       wxSetFocusToChild(this, &m_winLastFocused);
+
+       wxSetFocusToChild(parent, &m_winLastFocused);
 
            if ( m_frameMenuBar != NULL )
            {
index 26b7c2c3930c30ec03dc384c3a5f178136d220dd..490d6dda270b1d0ba7e96ef2437fa4e9ebc0dc03 100644 (file)
@@ -235,7 +235,7 @@ pascal      OSErr   GetVolumeInfoNoName(ConstStr255Param pathname,
 **     to the local tempPathname).
 */
 
-#if !TARGET_CARBON
+#if TARGET_CARBON
 
 pascal OSErr   XGetVolumeInfoNoName(ConstStr255Param pathname,
                                                                        short vRefNum,
diff --git a/src/mac/toplevel.cpp b/src/mac/toplevel.cpp
new file mode 100644 (file)
index 0000000..9e34691
--- /dev/null
@@ -0,0 +1,143 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        mac/toplevel.cpp
+// Purpose:     implements wxTopLevelWindow for MSW
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     24.09.01
+// RCS-ID:      $Id$
+// Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
+// License:     wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+    #pragma implementation "toplevel.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/toplevel.h"
+    #include "wx/string.h"
+    #include "wx/log.h"
+    #include "wx/intl.h"
+#endif //WX_PRECOMP
+
+// ----------------------------------------------------------------------------
+// globals
+// ----------------------------------------------------------------------------
+
+// list of all frames and modeless dialogs
+wxWindowList wxModelessWindows;
+
+// ============================================================================
+// wxTopLevelWindowMac implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac creation
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Init()
+{
+    m_iconized =
+    m_maximizeOnShow = FALSE;
+}
+
+bool wxTopLevelWindowMac::Create(wxWindow *parent,
+                                 wxWindowID id,
+                                 const wxString& title,
+                                 const wxPoint& pos,
+                                 const wxSize& size,
+                                 long style,
+                                 const wxString& name)
+{
+    // init our fields
+    Init();
+
+    m_windowStyle = style;
+
+    SetName(name);
+
+    m_windowId = id == -1 ? NewControlId() : id;
+
+    wxTopLevelWindows.Append(this);
+
+    if ( parent )
+        parent->AddChild(this);
+
+    return TRUE;
+}
+
+wxTopLevelWindowMac::~wxTopLevelWindowMac()
+{
+    wxTopLevelWindows.DeleteObject(this);
+
+    if ( wxModelessWindows.Find(this) )
+        wxModelessWindows.DeleteObject(this);
+
+    // If this is the last top-level window, exit.
+    if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
+    {
+        wxTheApp->SetTopWindow(NULL);
+
+        if ( wxTheApp->GetExitOnFrameDelete() )
+        {
+          wxTheApp->ExitMainLoop() ;        
+        }
+    }
+}
+
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac maximize/minimize
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::Maximize(bool maximize)
+{
+    // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsMaximized() const
+{
+    return false ; 
+}
+
+void wxTopLevelWindowMac::Iconize(bool iconize)
+{
+    // not available on mac
+}
+
+bool wxTopLevelWindowMac::IsIconized() const
+{
+       // mac dialogs cannot be iconized
+    return FALSE;
+}
+
+void wxTopLevelWindowMac::Restore()
+{
+    // not available on mac
+}
+
+// ----------------------------------------------------------------------------
+// wxTopLevelWindowMac misc
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
+{
+    // this sets m_icon
+    wxTopLevelWindowBase::SetIcon(icon);
+}