X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c09245191c60d23115eb213ed7c5a52bcb97539b..b719fd8d8140a0ce8ada03cbf1144c7793dffd90:/src/generic/mdig.cpp diff --git a/src/generic/mdig.cpp b/src/generic/mdig.cpp index e86ba99ee9..b1e79b5969 100644 --- a/src/generic/mdig.cpp +++ b/src/generic/mdig.cpp @@ -6,7 +6,7 @@ // Created: 29/07/2002 // RCS-ID: $Id$ // Copyright: (c) Hans Van Leemputten -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // =========================================================================== @@ -17,10 +17,6 @@ // headers // --------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "mdig.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -31,9 +27,11 @@ #ifndef WX_PRECOMP #include "wx/panel.h" #include "wx/menu.h" + #include "wx/intl.h" #endif //WX_PRECOMP #include "wx/generic/mdig.h" +#include "wx/stockitem.h" enum MDI_MENU_ID { @@ -50,7 +48,9 @@ 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() @@ -108,11 +108,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 +120,7 @@ bool wxGenericMDIParentFrame::Create(wxWindow *parent, OnCreateClient(); - return TRUE; + return true; } #if wxUSE_MENUS @@ -189,17 +189,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; + 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 +208,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 +255,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 +291,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!!! @@ -303,14 +304,14 @@ void wxGenericMDIParentFrame::AddWindowMenu(wxMenuBar *pMenuBar) { if (pMenuBar && m_pWindowMenu) { - int pos = pMenuBar->FindMenu(_T("Help")); + int pos = pMenuBar->FindMenu(wxGetStockLabel(wxID_HELP,false)); 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")); } } } @@ -340,6 +341,7 @@ void wxGenericMDIParentFrame::DoHandleMenu(wxCommandEvent &event) { #if 1 // What's best? Delayed deleting or immediate deleting? delete m_pActiveChild; + m_pActiveChild = NULL; #else ActivateNext(); @@ -404,18 +406,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) @@ -435,7 +437,7 @@ wxGenericMDIChildFrame::~wxGenericMDIChildFrame() } else { - if (pClientWindow->GetPageCount() - 1 >= 0) + if ((int)pClientWindow->GetPageCount() - 1 >= 0) pClientWindow->SetSelection(pClientWindow->GetPageCount() - 1); } } @@ -453,7 +455,7 @@ 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); @@ -464,11 +466,11 @@ 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 @@ -514,7 +516,7 @@ void wxGenericMDIChildFrame::SetTitle(const wxString& title) if (pClientWindow != NULL) { - int pos; + size_t pos; for (pos = 0; pos < pClientWindow->GetPageCount(); pos++) { if (pClientWindow->GetPage(pos) == this) @@ -542,7 +544,7 @@ void wxGenericMDIChildFrame::Activate() if (pClientWindow != NULL) { - int pos; + size_t pos; for (pos = 0; pos < pClientWindow->GetPageCount(); pos++) { if (pClientWindow->GetPage(pos) == this) @@ -564,10 +566,12 @@ void wxGenericMDIChildFrame::OnMenuHighlight(wxMenuEvent& event) // 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 +590,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() ) { @@ -693,7 +697,7 @@ bool wxGenericMDIClientWindow::CreateClient( wxGenericMDIParentFrame *parent, lo { SetWindowStyleFlag(style); - bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0); + bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0,0), wxSize(100, 100), 0); if (success) { /* @@ -704,13 +708,13 @@ 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); @@ -743,7 +747,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 +759,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 +783,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 +797,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)