]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/mdig.cpp
removed src/gtk/eggtrayicon.h
[wxWidgets.git] / src / generic / mdig.cpp
index 69445c6b2756c266fd9008d0b9b87dbff2dac310..0e2f44031ca7d278c6877bee3d41899289414798 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     29/07/2002
 // RCS-ID:      $Id$
 // Copyright:   (c) Hans Van Leemputten
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ===========================================================================
@@ -17,7 +17,7 @@
 // headers
 // ---------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "mdig.h"
 #endif
 
 #ifndef WX_PRECOMP
     #include "wx/panel.h"
     #include "wx/menu.h"
+    #include "wx/intl.h"
 #endif //WX_PRECOMP
 
 #include "wx/generic/mdig.h"
 
-enum MDI_MENU_ID 
+enum MDI_MENU_ID
 {
     wxWINDOWCLOSE = 4001,
     wxWINDOWCLOSEALL,
@@ -50,12 +51,14 @@ enum MDI_MENU_ID
 IMPLEMENT_DYNAMIC_CLASS(wxGenericMDIParentFrame, wxFrame)
 
 BEGIN_EVENT_TABLE(wxGenericMDIParentFrame, wxFrame)
-    EVT_MENU (-1, wxGenericMDIParentFrame::DoHandleMenu)
+#if wxUSE_MENUS
+    EVT_MENU (wxID_ANY, wxGenericMDIParentFrame::DoHandleMenu)
+#endif
 END_EVENT_TABLE()
 
-wxGenericMDIParentFrame::wxGenericMDIParentFrame() 
-{ 
-    Init(); 
+wxGenericMDIParentFrame::wxGenericMDIParentFrame()
+{
+    Init();
 }
 
 wxGenericMDIParentFrame::wxGenericMDIParentFrame(wxWindow *parent,
@@ -67,22 +70,22 @@ wxGenericMDIParentFrame::wxGenericMDIParentFrame(wxWindow *parent,
                                    const wxString& name)
 {
     Init();
-    
+
     (void)Create(parent, id, title, pos, size, style, name);
 }
 
 wxGenericMDIParentFrame::~wxGenericMDIParentFrame()
-{    
+{
     // Make sure the client window is destructed before the menu bars are!
     wxDELETE(m_pClientWindow);
 
-#if wxUSE_MENUS  
+#if wxUSE_MENUS
     if (m_pMyMenuBar)
     {
         delete m_pMyMenuBar;
         m_pMyMenuBar = (wxMenuBar *) NULL;
     }
-    
+
     RemoveWindowMenu(GetMenuBar());
 
     if (m_pWindowMenu)
@@ -108,11 +111,11 @@ bool wxGenericMDIParentFrame::Create(wxWindow *parent,
 #if wxUSE_MENUS
       m_pWindowMenu = new wxMenu;
 
-      m_pWindowMenu->Append(wxWINDOWCLOSE,    _T("Cl&ose"));
-      m_pWindowMenu->Append(wxWINDOWCLOSEALL, _T("Close Al&l"));
+      m_pWindowMenu->Append(wxWINDOWCLOSE,    _("Cl&ose"));
+      m_pWindowMenu->Append(wxWINDOWCLOSEALL, _("Close All"));
       m_pWindowMenu->AppendSeparator();
-      m_pWindowMenu->Append(wxWINDOWNEXT,     _T("&Next"));
-      m_pWindowMenu->Append(wxWINDOWPREV,     _T("&Previouse"));
+      m_pWindowMenu->Append(wxWINDOWNEXT,     _("&Next"));
+      m_pWindowMenu->Append(wxWINDOWPREV,     _("&Previous"));
 #endif // wxUSE_MENUS
   }
 
@@ -120,7 +123,7 @@ bool wxGenericMDIParentFrame::Create(wxWindow *parent,
 
   OnCreateClient();
 
-  return TRUE;
+  return true;
 }
 
 #if wxUSE_MENUS
@@ -162,7 +165,7 @@ void wxGenericMDIParentFrame::SetChildMenuBar(wxGenericMDIChildFrame *pChild)
     {
         // No Child, set Our menu bar back.
         SetMenuBar(m_pMyMenuBar);
-        
+
         // Make sure we know our menu bar is in use
         m_pMyMenuBar = (wxMenuBar*) NULL;
     }
@@ -189,17 +192,17 @@ bool wxGenericMDIParentFrame::ProcessEvent(wxEvent& event)
     // Stops the same event being processed repeatedly
     static wxEventType inEvent = wxEVT_NULL;
     if (inEvent == event.GetEventType())
-        return FALSE;
+        return false;
 
     inEvent = event.GetEventType();
 
     // Let the active child (if any) process the event first.
-    bool res = FALSE;
-    if (m_pActiveChild && event.IsKindOf(CLASSINFO(wxCommandEvent)) 
+    bool res = false;
+    if (m_pActiveChild && event.IsKindOf(CLASSINFO(wxCommandEvent))
 #if 0
         /* This is sure to not give problems... */
         && (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED ||
-            event.GetEventType() == wxEVT_UPDATE_UI ))
+            event.GetEventType() == wxEVT_UPDATE_UI )
 #else
         /* This was tested on wxMSW and worked... */
         && event.GetEventObject() != m_pClientWindow
@@ -208,8 +211,9 @@ bool wxGenericMDIParentFrame::ProcessEvent(wxEvent& event)
              event.GetEventType() == wxEVT_KILL_FOCUS ||
              event.GetEventType() == wxEVT_CHILD_FOCUS ||
              event.GetEventType() == wxEVT_COMMAND_SET_FOCUS ||
-             event.GetEventType() == wxEVT_COMMAND_KILL_FOCUS ))
+             event.GetEventType() == wxEVT_COMMAND_KILL_FOCUS )
 #endif
+       )
     {
         res = m_pActiveChild->GetEventHandler()->ProcessEvent(event);
     }
@@ -254,7 +258,7 @@ void wxGenericMDIParentFrame::ActivateNext()
 {
     if (m_pClientWindow && m_pClientWindow->GetSelection() != -1)
     {
-        int active = m_pClientWindow->GetSelection() + 1;
+        size_t active = m_pClientWindow->GetSelection() + 1;
         if (active >= m_pClientWindow->GetPageCount())
             active = 0;
 
@@ -290,7 +294,7 @@ void wxGenericMDIParentFrame::RemoveWindowMenu(wxMenuBar *pMenuBar)
     if (pMenuBar && m_pWindowMenu)
     {
         // Remove old window menu
-        int pos = pMenuBar->FindMenu(_T("&Window"));
+        int pos = pMenuBar->FindMenu(_("&Window"));
         if (pos != wxNOT_FOUND)
         {
             wxASSERT(m_pWindowMenu == pMenuBar->GetMenu(pos)); // DBG:: We're going to delete the wrong menu!!!
@@ -302,15 +306,15 @@ void wxGenericMDIParentFrame::RemoveWindowMenu(wxMenuBar *pMenuBar)
 void wxGenericMDIParentFrame::AddWindowMenu(wxMenuBar *pMenuBar)
 {
     if (pMenuBar && m_pWindowMenu)
-    {           
-        int pos = pMenuBar->FindMenu(_T("Help"));            
+    {
+        int pos = pMenuBar->FindMenu(_("Help"));
         if (pos == wxNOT_FOUND)
         {
-            pMenuBar->Append(m_pWindowMenu, _T("&Window"));
+            pMenuBar->Append(m_pWindowMenu, _("&Window"));
         }
         else
         {
-            pMenuBar->Insert(pos, m_pWindowMenu, _T("&Window"));
+            pMenuBar->Insert(pos, m_pWindowMenu, _("&Window"));
         }
     }
 }
@@ -319,7 +323,7 @@ void wxGenericMDIParentFrame::DoHandleMenu(wxCommandEvent &event)
 {
     switch (event.GetId())
     {
-    case wxWINDOWCLOSE:     
+    case wxWINDOWCLOSE:
         if (m_pActiveChild)
         {
             m_pActiveChild->Close();
@@ -327,7 +331,7 @@ void wxGenericMDIParentFrame::DoHandleMenu(wxCommandEvent &event)
         break;
     case wxWINDOWCLOSEALL:
         {
-#if 0   // code is only needed if next #if is set to 0!        
+#if 0   // code is only needed if next #if is set to 0!
             wxGenericMDIChildFrame *pFirstActiveChild = m_pActiveChild;
 #endif
             while (m_pActiveChild)
@@ -340,7 +344,7 @@ void wxGenericMDIParentFrame::DoHandleMenu(wxCommandEvent &event)
                 {
 #if 1   // What's best? Delayed deleting or immediate deleting?
                     delete m_pActiveChild;
-#else                    
+#else
                     ActivateNext();
 
                     if (pFirstActiveChild == m_pActiveChild)
@@ -404,18 +408,18 @@ wxGenericMDIChildFrame::~wxGenericMDIChildFrame()
 
     if (pParentFrame != NULL)
     {
-        bool bActive = FALSE;
+        bool bActive = false;
         if (pParentFrame->GetActiveChild() == this)
         {
             pParentFrame->SetActiveChild((wxGenericMDIChildFrame*) NULL);
             pParentFrame->SetChildMenuBar((wxGenericMDIChildFrame*) NULL);
-            bActive = TRUE;
+            bActive = true;
         }
 
         wxGenericMDIClientWindow *pClientWindow = pParentFrame->GetClientWindow();
 
         // Remove page if still there
-        int pos;
+        size_t pos;
         for (pos = 0; pos < pClientWindow->GetPageCount(); pos++)
         {
             if (pClientWindow->GetPage(pos) == this)
@@ -425,7 +429,7 @@ wxGenericMDIChildFrame::~wxGenericMDIChildFrame()
                 break;
             }
         }
-        
+
         if (bActive)
         {
             // Set the new selection to the a remaining page
@@ -435,7 +439,7 @@ wxGenericMDIChildFrame::~wxGenericMDIChildFrame()
             }
             else
             {
-                if (pClientWindow->GetPageCount() - 1 >= 0)
+                if ((int)pClientWindow->GetPageCount() - 1 >= 0)
                     pClientWindow->SetSelection(pClientWindow->GetPageCount() - 1);
             }
         }
@@ -453,10 +457,10 @@ bool wxGenericMDIChildFrame::Create( wxGenericMDIParentFrame *parent,
 {
     wxGenericMDIClientWindow* pClientWindow = parent->GetClientWindow();
 
-    wxASSERT_MSG((pClientWindow != (wxWindow*) NULL), "Missing MDI client window.");
+    wxASSERT_MSG((pClientWindow != (wxWindow*) NULL), wxT("Missing MDI client window.") );
 
     wxPanel::Create(pClientWindow, id, wxDefaultPosition, size, style, name);
-    
+
     SetMDIParentFrame(parent);
 
     // This is the currently active child
@@ -464,14 +468,14 @@ bool wxGenericMDIChildFrame::Create( wxGenericMDIParentFrame *parent,
 
     m_Title = title;
 
-    pClientWindow->AddPage(this, title, TRUE);
+    pClientWindow->AddPage(this, title, true);
     ApplyMDIChildFrameRect();   // Ok confirme the size change!
     pClientWindow->Refresh();
 
-    return TRUE;
+    return true;
 }
 
-#if wxUSE_MENUS  
+#if wxUSE_MENUS
 void wxGenericMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
 {
     wxMenuBar *pOldMenuBar = m_pMenuBar;
@@ -480,7 +484,7 @@ void wxGenericMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
     if (m_pMenuBar)
     {
         wxGenericMDIParentFrame *pParentFrame = GetMDIParentFrame();
-        
+
         if (pParentFrame != NULL)
         {
             m_pMenuBar->SetParent(pParentFrame);
@@ -500,21 +504,21 @@ wxMenuBar *wxGenericMDIChildFrame::GetMenuBar() const
 {
     return m_pMenuBar;
 }
-#endif // wxUSE_MENUS  
+#endif // wxUSE_MENUS
 
 void wxGenericMDIChildFrame::SetTitle(const wxString& title)
 {
     m_Title = title;
 
     wxGenericMDIParentFrame *pParentFrame = GetMDIParentFrame();
-    
+
     if (pParentFrame != NULL)
     {
         wxGenericMDIClientWindow * pClientWindow = pParentFrame->GetClientWindow();
-        
+
         if (pClientWindow != NULL)
-        {    
-            int pos;
+        {
+            size_t pos;
             for (pos = 0; pos < pClientWindow->GetPageCount(); pos++)
             {
                 if (pClientWindow->GetPage(pos) == this)
@@ -522,12 +526,12 @@ void wxGenericMDIChildFrame::SetTitle(const wxString& title)
                     pClientWindow->SetPageText(pos, m_Title);
                     break;
                 }
-            }    
+            }
         }
     }
 }
 
-wxString wxGenericMDIChildFrame::GetTitle()
+wxString wxGenericMDIChildFrame::GetTitle() const
 {
     return m_Title;
 }
@@ -542,7 +546,7 @@ void wxGenericMDIChildFrame::Activate()
 
         if (pClientWindow != NULL)
         {
-            int pos;
+            size_t pos;
             for (pos = 0; pos < pClientWindow->GetPageCount(); pos++)
             {
                 if (pClientWindow->GetPage(pos) == this)
@@ -560,14 +564,16 @@ void wxGenericMDIChildFrame::OnMenuHighlight(wxMenuEvent& event)
 #if wxUSE_STATUSBAR
     if ( m_pMDIParentFrame)
     {
-        // we don't have any help text for this item, 
+        // we don't have any help text for this item,
         // but may be the MDI frame does?
         m_pMDIParentFrame->OnMenuHighlight(event);
     }
+#else
+    wxUnusedVar(event);
 #endif // wxUSE_STATUSBAR
 }
 
-void wxGenericMDIChildFrame::OnActivate(wxActivateEvent& event)
+void wxGenericMDIChildFrame::OnActivate(wxActivateEvent& WXUNUSED(event))
 {
     // Do mothing.
 }
@@ -586,7 +592,7 @@ void wxGenericMDIChildFrame::OnSize(wxSizeEvent& WXUNUSED(event))
     {
         // do we have _exactly_ one child?
         wxWindow *child = (wxWindow *)NULL;
-        for ( wxWindowList::Node *node = GetChildren().GetFirst();
+        for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
               node;
               node = node->GetNext() )
         {
@@ -633,14 +639,14 @@ void wxGenericMDIChildFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
     Destroy();
 }
 
-void wxGenericMDIChildFrame::SetMDIParentFrame(wxGenericMDIParentFrame* parentFrame) 
-{ 
-    m_pMDIParentFrame = parentFrame; 
+void wxGenericMDIChildFrame::SetMDIParentFrame(wxGenericMDIParentFrame* parentFrame)
+{
+    m_pMDIParentFrame = parentFrame;
 }
 
-wxGenericMDIParentFrame* wxGenericMDIChildFrame::GetMDIParentFrame() const 
-{ 
-    return m_pMDIParentFrame; 
+wxGenericMDIParentFrame* wxGenericMDIChildFrame::GetMDIParentFrame() const
+{
+    return m_pMDIParentFrame;
 }
 
 void wxGenericMDIChildFrame::Init()
@@ -648,11 +654,11 @@ void wxGenericMDIChildFrame::Init()
     m_pMDIParentFrame = (wxGenericMDIParentFrame *) NULL;
 #if wxUSE_MENUS
     m_pMenuBar = (wxMenuBar *) NULL;
-#endif // wxUSE_MENUS  
+#endif // wxUSE_MENUS
 }
 
 void wxGenericMDIChildFrame::DoMoveWindow(int x, int y, int width, int height)
-{ 
+{
     m_MDIRect = wxRect(x, y, width, height);
 }
 
@@ -704,17 +710,17 @@ bool wxGenericMDIClientWindow::CreateClient( wxGenericMDIParentFrame *parent, lo
         GetTabView()->SetTabSize(120, 18);
         GetTabView()->SetTabSelectionHeight(20);
         */
-        return TRUE;
+        return true;
     }
     else
-        return FALSE;
+        return false;
 }
 
-int wxGenericMDIClientWindow::SetSelection(int nPage)
+int wxGenericMDIClientWindow::SetSelection(size_t nPage)
 {
     int oldSelection = wxNotebook::SetSelection(nPage);
 
-#if !defined(__WXMSW__) // No need to do this for wxMSW as wxNotebook::SetSelection() 
+#if !defined(__WXMSW__) // No need to do this for wxMSW as wxNotebook::SetSelection()
                         // will already cause this to be done!
     // Handle the page change.
     PageChanged(oldSelection, nPage);
@@ -743,7 +749,7 @@ void wxGenericMDIClientWindow::PageChanged(int OldSelection, int newSelection)
         wxGenericMDIChildFrame* oldChild = (wxGenericMDIChildFrame *)GetPage(OldSelection);
         if (oldChild)
         {
-            wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldChild->GetId());
+            wxActivateEvent event(wxEVT_ACTIVATE, false, oldChild->GetId());
             event.SetEventObject( oldChild );
             oldChild->GetEventHandler()->ProcessEvent(event);
         }
@@ -755,7 +761,7 @@ void wxGenericMDIClientWindow::PageChanged(int OldSelection, int newSelection)
         wxGenericMDIChildFrame* activeChild = (wxGenericMDIChildFrame *)GetPage(newSelection);
         if (activeChild)
         {
-            wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
+            wxActivateEvent event(wxEVT_ACTIVATE, true, activeChild->GetId());
             event.SetEventObject( activeChild );
             activeChild->GetEventHandler()->ProcessEvent(event);
 
@@ -779,7 +785,7 @@ void wxGenericMDIClientWindow::OnSize(wxSizeEvent& event)
 {
     wxNotebook::OnSize(event);
 
-    int pos;
+    size_t pos;
     for (pos = 0; pos < GetPageCount(); pos++)
     {
         ((wxGenericMDIChildFrame *)GetPage(pos))->ApplyMDIChildFrameRect();
@@ -793,6 +799,16 @@ void wxGenericMDIClientWindow::OnSize(wxSizeEvent& event)
 
 #if wxUSE_GENERIC_MDI_AS_NATIVE
 
+wxMDIChildFrame * wxMDIParentFrame::GetActiveChild() const
+    {
+        wxGenericMDIChildFrame *pGFrame = wxGenericMDIParentFrame::GetActiveChild();
+        wxMDIChildFrame *pFrame = wxDynamicCast(pGFrame, wxMDIChildFrame);
+
+        wxASSERT_MSG(!(pFrame == NULL && pGFrame != NULL), wxT("Active frame is class not derived from wxMDIChildFrame!"));
+
+        return pFrame;
+    }
+
 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxGenericMDIParentFrame)
 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxGenericMDIChildFrame)
 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxGenericMDIClientWindow)