X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ecc63060e7f7bbbb60c83fefc0904d2903d705f5..b67397a779eef3fb22ee143c8bd4e027c8c5dfc8:/src/msw/mdi.cpp diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index d3bb9aa47d..6b9cdbcc9a 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -52,9 +52,6 @@ extern wxMenu *wxCurrentPopupMenu; -extern const wxChar *wxMDIFrameClassName; // from app.cpp -extern const wxChar *wxMDIChildFrameClassName; -extern const wxChar *wxMDIChildFrameClassNameNoRedraw; extern void wxRemoveHandleAssociation(wxWindow *win); // --------------------------------------------------------------------------- @@ -140,9 +137,6 @@ END_EVENT_TABLE() wxMDIParentFrame::wxMDIParentFrame() { - m_clientWindow = NULL; - m_currentChild = NULL; - m_windowMenu = NULL; m_parentFrameActive = true; } @@ -154,17 +148,11 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - m_clientWindow = NULL; - m_currentChild = NULL; - // this style can be used to prevent a window from having the standard MDI // "Window" menu - if ( style & wxFRAME_NO_WINDOW_MENU ) - { - m_windowMenu = NULL; - } - else // normal case: we have the window menu, so construct it + if ( !(style & wxFRAME_NO_WINDOW_MENU) ) { + // normal case: we have the window menu, so construct it m_windowMenu = new wxMenu; m_windowMenu->Append(IDM_WINDOWCASCADE, _("&Cascade")); @@ -197,7 +185,7 @@ bool wxMDIParentFrame::Create(wxWindow *parent, msflags &= ~WS_VSCROLL; msflags &= ~WS_HSCROLL; - if ( !wxWindow::MSWCreate(wxMDIFrameClassName, + if ( !wxWindow::MSWCreate(wxApp::GetRegisteredClassName(_T("wxMDIFrame")), title.wx_str(), pos, size, msflags, @@ -226,8 +214,6 @@ wxMDIParentFrame::~wxMDIParentFrame() DestroyChildren(); - delete m_windowMenu; - // the MDI frame menubar is not automatically deleted by Windows unlike for // the normal frames if ( m_hMenu ) @@ -319,20 +305,15 @@ void wxMDIParentFrame::InternalSetMenuBar() void wxMDIParentFrame::SetWindowMenu(wxMenu* menu) { - if (m_windowMenu) - { - RemoveWindowMenu(); + // notice that Remove/AddWindowMenu() are safe to call even when + // m_windowMenu is NULL + RemoveWindowMenu(); - delete m_windowMenu; - m_windowMenu = NULL; - } + delete m_windowMenu; - if (menu) - { - m_windowMenu = menu; + m_windowMenu = menu; - AddWindowMenu(); - } + AddWindowMenu(); } void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu) @@ -411,13 +392,6 @@ wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const return (wxMDIChildFrame *)wxFindWinFromHandle(hWnd); } -// Create the client window class (don't Create the window, just return a new -// class) -wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() -{ - return new wxMDIClientWindow; -} - // Responds to colour changes, and passes event on to children. void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) { @@ -738,6 +712,8 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, long style, const wxString& name) { + m_mdiParent = parent; + SetName(name); if ( id != wxID_ANY ) @@ -757,9 +733,12 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, MDICREATESTRUCT mcs; - mcs.szClass = style & wxFULL_REPAINT_ON_RESIZE - ? wxMDIChildFrameClassName - : wxMDIChildFrameClassNameNoRedraw; + wxString className = + wxApp::GetRegisteredClassName(_T("wxMDIChildFrame"), COLOR_WINDOW); + if ( !(style & wxFULL_REPAINT_ON_RESIZE) ) + className += wxApp::GetNoRedrawClassSuffix(); + + mcs.szClass = className.wx_str(); mcs.szTitle = title.wx_str(); mcs.hOwner = wxGetInstance(); if (x != wxDefaultCoord) @@ -859,7 +838,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 = GetMDIParent(); + wxMDIParentFrame * const parent = GetMDIParent(); MDISetMenu(parent->GetClientWindow(), NULL, NULL); return true; @@ -898,8 +877,8 @@ 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 = GetMDIParent(); - ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point); + wxMDIParentFrame * const mdiParent = GetMDIParent(); + ::ScreenToClient(GetHwndOf(mdiParent->GetClientWindow()), &point); MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true); @@ -934,8 +913,8 @@ 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 = GetMDIParent(); - ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point); + wxMDIParentFrame * const mdiParent = GetMDIParent(); + ::ScreenToClient(GetHwndOf(mdiParent->GetClientWindow()), &point); if (x) *x = point.x; @@ -945,7 +924,7 @@ void wxMDIChildFrame::DoGetPosition(int *x, int *y) const void wxMDIChildFrame::InternalSetMenuBar() { - wxMDIParentFrame *parent = GetMDIParent(); + wxMDIParentFrame * const parent = GetMDIParent(); MDIInsertWindowMenu(parent->GetClientWindow(), m_hMenu, GetMDIWindowMenu(parent)); @@ -971,7 +950,7 @@ WXHICON wxMDIChildFrame::GetDefaultIcon() const void wxMDIChildFrame::Maximize(bool maximize) { - wxMDIParentFrame *parent = GetMDIParent(); + wxMDIParentFrame * const parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), @@ -982,7 +961,7 @@ void wxMDIChildFrame::Maximize(bool maximize) void wxMDIChildFrame::Restore() { - wxMDIParentFrame *parent = GetMDIParent(); + wxMDIParentFrame * const parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE, @@ -992,7 +971,7 @@ void wxMDIChildFrame::Restore() void wxMDIChildFrame::Activate() { - wxMDIParentFrame *parent = GetMDIParent(); + wxMDIParentFrame * const parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE, @@ -1104,7 +1083,7 @@ bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate), WXHWND hwndAct, WXHWND hwndDeact) { - wxMDIParentFrame *parent = GetMDIParent(); + wxMDIParentFrame * const parent = GetMDIParent(); HMENU menuToSet = 0; @@ -1237,7 +1216,7 @@ bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg) void wxMDIChildFrame::MSWDestroyWindow() { - wxMDIParentFrame *parent = GetMDIParent(); + wxMDIParentFrame * const 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 @@ -1264,7 +1243,7 @@ void wxMDIChildFrame::MSWDestroyWindow() bool wxMDIChildFrame::ResetWindowStyle(void *vrect) { RECT *rect = (RECT *)vrect; - wxMDIParentFrame* pFrameWnd = GetMDIParent(); + wxMDIParentFrame * const pFrameWnd = GetMDIParent(); wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild(); if (!pChild || (pChild == this))