From 55ae15512cbb4a36648fcd7543c6f816105b6228 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 9 Feb 2008 23:37:07 +0000 Subject: [PATCH] add GetMDIParent() and use it to reduce the number of casts in the MDI code (patch 1885462) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51622 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/mdi.h | 5 +++++ src/msw/mdi.cpp | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/wx/msw/mdi.h b/include/wx/msw/mdi.h index 93cede426a..66d9b4c33d 100644 --- a/include/wx/msw/mdi.h +++ b/include/wx/msw/mdi.h @@ -162,6 +162,11 @@ public: // Implementation only from now on // ------------------------------- + wxMDIParentFrame* GetMDIParent() const + { + return wxStaticCast(wxFrame::GetParent(), wxMDIParentFrame); + } + // Handlers bool HandleMDIActivate(long bActivate, WXHWND, WXHWND); bool HandleWindowPosChanging(void *lpPos); diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index e4f5961386..25ff340af8 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -806,7 +806,7 @@ bool wxMDIChildFrame::Show(bool show) // we need to refresh the MDI frame window menu to include (or exclude if // we've been hidden) this frame - wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *parent = GetMDIParent(); MDISetMenu(parent->GetClientWindow(), NULL, NULL); return true; @@ -845,7 +845,7 @@ void wxMDIChildFrame::DoSetClientSize(int width, int height) // If there's an MDI parent, must subtract the parent's top left corner // since MoveWindow moves relative to the parent - wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *mdiParent = GetMDIParent(); ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point); MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true); @@ -881,7 +881,7 @@ void wxMDIChildFrame::DoGetPosition(int *x, int *y) const // Since we now have the absolute screen coords, // if there's a parent we must subtract its top left corner - wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *mdiParent = GetMDIParent(); ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point); if (x) @@ -892,7 +892,7 @@ void wxMDIChildFrame::DoGetPosition(int *x, int *y) const void wxMDIChildFrame::InternalSetMenuBar() { - wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *parent = GetMDIParent(); InsertWindowMenu(parent->GetClientWindow(), m_hMenu, GetMDIWindowMenu(parent)); @@ -918,7 +918,7 @@ WXHICON wxMDIChildFrame::GetDefaultIcon() const void wxMDIChildFrame::Maximize(bool maximize) { - wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), @@ -929,7 +929,7 @@ void wxMDIChildFrame::Maximize(bool maximize) void wxMDIChildFrame::Restore() { - wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE, @@ -939,7 +939,7 @@ void wxMDIChildFrame::Restore() void wxMDIChildFrame::Activate() { - wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE, @@ -1048,7 +1048,7 @@ bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate), WXHWND hwndAct, WXHWND hwndDeact) { - wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *parent = GetMDIParent(); HMENU menuToSet = 0; @@ -1172,7 +1172,7 @@ bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg) { // we must pass the parent frame to ::TranslateAccelerator(), otherwise it // doesn't do its job correctly for MDI child menus - return MSWDoTranslateMessage((wxMDIChildFrame *)GetParent(), msg); + return MSWDoTranslateMessage(GetMDIParent(), msg); } // --------------------------------------------------------------------------- @@ -1181,7 +1181,7 @@ bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg) void wxMDIChildFrame::MSWDestroyWindow() { - wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame *parent = GetMDIParent(); // Must make sure this handle is invalidated (set to NULL) since all sorts // of things could happen after the child client is destroyed, but before @@ -1208,7 +1208,7 @@ void wxMDIChildFrame::MSWDestroyWindow() bool wxMDIChildFrame::ResetWindowStyle(void *vrect) { RECT *rect = (RECT *)vrect; - wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent(); + wxMDIParentFrame* pFrameWnd = GetMDIParent(); wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild(); if (!pChild || (pChild == this)) -- 2.45.2