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
This commit is contained in:
Vadim Zeitlin 2008-02-09 23:37:07 +00:00
parent 3ab6b7e64c
commit 55ae15512c
2 changed files with 16 additions and 11 deletions

View File

@ -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);

View File

@ -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))