]> git.saurik.com Git - wxWidgets.git/blobdiff - src/aui/tabmdi.cpp
Override GetPixelSize on OS X as the base impl creates a wxScreenDC each time, which...
[wxWidgets.git] / src / aui / tabmdi.cpp
index 4f054a3d4eb8ac291a8f7fc3ff102cd7ad7cb978..71f53429d48b23a3c35b42c2761f8f52b32eb003 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        src/generic/mdig.cpp
+// Name:        src/aui/tabmdi.cpp
 // Purpose:     Generic MDI (Multiple Document Interface) classes
 // Author:      Hans Van Leemputten
 // Modified by: Benjamin I. Williams / Kirix Corporation
@@ -24,9 +24,9 @@
     #pragma hdrstop
 #endif
 
+#if wxUSE_AUI
 #if wxUSE_MDI
 
-#include "wx/settings.h"
 #include "wx/aui/tabmdi.h"
 
 #ifndef WX_PRECOMP
@@ -34,6 +34,7 @@
     #include "wx/menu.h"
     #include "wx/intl.h"
     #include "wx/log.h"
+    #include "wx/settings.h"
 #endif //WX_PRECOMP
 
 #include "wx/stockitem.h"
@@ -132,14 +133,14 @@ void wxTabMDIParentFrame::SetWindowMenu(wxMenu* pMenu)
     }
 }
 
-void wxTabMDIParentFrame::SetMenuBar(wxMenuBar *pMenuBar)
+void wxTabMDIParentFrame::SetMenuBar(wxMenuBarpMenuBar)
 {
     // Remove the Window menu from the old menu bar
     RemoveWindowMenu(GetMenuBar());
-    
+
     // Add the Window menu to the new menu bar.
     AddWindowMenu(pMenuBar);
-    
+
     wxFrame::SetMenuBar(pMenuBar);
     m_pMyMenuBar = GetMenuBar();
 }
@@ -154,7 +155,7 @@ void wxTabMDIParentFrame::SetChildMenuBar(wxTabMDIChildFrame* pChild)
         SetMenuBar(m_pMyMenuBar);
 
         // Make sure we know our menu bar is in use
-        m_pMyMenuBar = NULL;
+        //m_pMyMenuBar = NULL;
     }
      else
     {
@@ -230,7 +231,7 @@ wxTabMDIClientWindow *wxTabMDIParentFrame::OnCreateClient()
 
 void wxTabMDIParentFrame::ActivateNext()
 {
-    if (m_pClientWindow && m_pClientWindow->GetSelection() != -1)
+    if (m_pClientWindow && m_pClientWindow->GetSelection() != wxNOT_FOUND)
     {
         size_t active = m_pClientWindow->GetSelection() + 1;
         if (active >= m_pClientWindow->GetPageCount())
@@ -242,7 +243,7 @@ void wxTabMDIParentFrame::ActivateNext()
 
 void wxTabMDIParentFrame::ActivatePrevious()
 {
-    if (m_pClientWindow && m_pClientWindow->GetSelection() != -1)
+    if (m_pClientWindow && m_pClientWindow->GetSelection() != wxNOT_FOUND)
     {
         int active = m_pClientWindow->GetSelection() - 1;
         if (active < 0)
@@ -282,7 +283,7 @@ void wxTabMDIParentFrame::AddWindowMenu(wxMenuBar *pMenuBar)
 {
     if (pMenuBar && m_pWindowMenu)
     {
-        int pos = pMenuBar->FindMenu(wxGetStockLabel(wxID_HELP,false));
+        int pos = pMenuBar->FindMenu(wxGetStockLabel(wxID_HELP,wxSTOCK_NOFLAGS));
         if (pos == wxNOT_FOUND)
             pMenuBar->Append(m_pWindowMenu, _("&Window"));
              else
@@ -395,10 +396,10 @@ bool wxTabMDIChildFrame::Destroy()
 {
     wxTabMDIParentFrame* pParentFrame = GetMDIParentFrame();
     wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame"));
-    
+
     wxTabMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow();
     wxASSERT_MSG(pClientWindow, wxT("Missing MDI Client Window"));
-    
+
     bool bActive = false;
     if (pParentFrame->GetActiveChild() == this)
     {
@@ -406,66 +407,17 @@ bool wxTabMDIChildFrame::Destroy()
         pParentFrame->SetChildMenuBar(NULL);
         bActive = true;
     }
-    
+
     size_t pos, page_count = pClientWindow->GetPageCount();
     for (pos = 0; pos < page_count; pos++)
     {
         if (pClientWindow->GetPage(pos) == this)
             return pClientWindow->DeletePage(pos);
     }
-    
+
     return false;
 }
 
-/*
-    wxTabMDIParentFrame* pParentFrame = GetMDIParentFrame();
-    wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame"));
-    
-    bool bActive = false;
-    if (pParentFrame->GetActiveChild() == this)
-    {
-        pParentFrame->SetActiveChild(NULL);
-        pParentFrame->SetChildMenuBar(NULL);
-        bActive = true;
-    }
-
-    wxTabMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow();
-
-    // remove page if it is still there
-    size_t pos;
-    for (pos = 0; pos < pClientWindow->GetPageCount(); pos++)
-    {
-        if (pClientWindow->GetPage(pos) == this)
-        {
-            if (pClientWindow->RemovePage(pos))
-                pClientWindow->Refresh();
-            break;
-        }
-    }
-
-    if (bActive)
-    {
-        // Set the new selection to the a remaining page
-        if (pos < pClientWindow->GetPageCount())
-        {
-            pClientWindow->SetSelection(pos);
-        }
-         else
-        {
-            if (pClientWindow->GetPageCount() >= 1)
-                pClientWindow->SetSelection(pClientWindow->GetPageCount() - 1);
-        }
-    }
-
-    // delete the child frame with pending delete, as is
-    // customary with frame windows
-    if (!wxPendingDelete.Member(this))
-        wxPendingDelete.Append(this);
-        
-    return true;
-*/
-
-
 #if wxUSE_MENUS
 void wxTabMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
 {
@@ -595,9 +547,14 @@ void wxTabMDIChildFrame::DoShow(bool show)
     wxWindow::Show(show);
 }
 
-void wxTabMDIChildFrame::DoSetSize(int x, int y, int width, int height, int WXUNUSED(sizeFlags))
+void wxTabMDIChildFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags)
 {
     m_mdi_newrect = wxRect(x, y, width, height);
+#ifdef __WXGTK__
+    wxPanel::DoSetSize(x,y,width, height, sizeFlags);
+#else
+    wxUnusedVar(sizeFlags);
+#endif
 }
 
 void wxTabMDIChildFrame::DoMoveWindow(int x, int y, int width, int height)
@@ -623,7 +580,7 @@ void wxTabMDIChildFrame::ApplyMDIChildFrameRect()
 IMPLEMENT_DYNAMIC_CLASS(wxTabMDIClientWindow, wxAuiMultiNotebook)
 
 BEGIN_EVENT_TABLE(wxTabMDIClientWindow, wxAuiMultiNotebook)
-    EVT_AUINOTEBOOK_PAGE_CHANGED(-1, wxTabMDIClientWindow::OnPageChanged)
+    EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, wxTabMDIClientWindow::OnPageChanged)
     EVT_SIZE(wxTabMDIClientWindow::OnSize)
 END_EVENT_TABLE()
 
@@ -646,19 +603,19 @@ bool wxTabMDIClientWindow::CreateClient(wxTabMDIParentFrame* parent, long style)
     SetWindowStyleFlag(style);
 
     if (!wxAuiMultiNotebook::Create(parent,
-                                    -1,
+                                    wxID_ANY,
                                     wxPoint(0,0),
                                     wxSize(100, 100),
                                     wxNO_BORDER))
     {
         return false;
     }
-    
+
     wxColour bkcolour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
     SetBackgroundColour(bkcolour);
-    
+
     m_mgr.GetArtProvider()->SetColour(wxAUI_ART_BACKGROUND_COLOUR, bkcolour);
-    
+
     return true;
 }
 
@@ -672,7 +629,7 @@ void wxTabMDIClientWindow::PageChanged(int old_selection, int new_selection)
     // don't do anything if the page doesn't actually change
     if (old_selection == new_selection)
         return;
-        
+
     // don't do anything if the new page is already active
     if (new_selection != -1)
     {
@@ -686,7 +643,7 @@ void wxTabMDIClientWindow::PageChanged(int old_selection, int new_selection)
     {
         wxTabMDIChildFrame* old_child = (wxTabMDIChildFrame*)GetPage(old_selection);
         wxASSERT_MSG(old_child, wxT("wxTabMDIClientWindow::PageChanged - null page pointer"));
-        
+
         wxActivateEvent event(wxEVT_ACTIVATE, false, old_child->GetId());
         event.SetEventObject(old_child);
         old_child->GetEventHandler()->ProcessEvent(event);
@@ -697,7 +654,7 @@ void wxTabMDIClientWindow::PageChanged(int old_selection, int new_selection)
     {
         wxTabMDIChildFrame* active_child = (wxTabMDIChildFrame*)GetPage(new_selection);
         wxASSERT_MSG(active_child, wxT("wxTabMDIClientWindow::PageChanged - null page pointer"));
-        
+
         wxActivateEvent event(wxEVT_ACTIVATE, true, active_child->GetId());
         event.SetEventObject(active_child);
         active_child->GetEventHandler()->ProcessEvent(event);
@@ -717,11 +674,12 @@ void wxTabMDIClientWindow::OnPageChanged(wxAuiNotebookEvent& evt)
 }
 
 void wxTabMDIClientWindow::OnSize(wxSizeEvent& evt)
-{  
+{
     wxAuiMultiNotebook::OnSize(evt);
 
     for (size_t pos = 0; pos < GetPageCount(); pos++)
         ((wxTabMDIChildFrame *)GetPage(pos))->ApplyMDIChildFrameRect();
 }
 
+#endif //wxUSE_AUI
 #endif // wxUSE_MDI