X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0d97c0902355bd73c080ebffa45ec809813df51d..cb0b7b7d811356f729315fc14c7e0d311f43384d:/src/msw/mdi.cpp diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 3c93df9cc9..96677b643c 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -17,10 +17,6 @@ // headers // --------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "mdi.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -31,7 +27,6 @@ #if wxUSE_MDI && !defined(__WXUNIVERSAL__) #ifndef WX_PRECOMP - #include "wx/setup.h" #include "wx/frame.h" #include "wx/menu.h" #include "wx/app.h" @@ -45,6 +40,7 @@ #include "wx/log.h" #endif +#include "wx/stockitem.h" #include "wx/mdi.h" #include "wx/msw/private.h" @@ -76,7 +72,6 @@ static HWND invalidHandle = 0; // constants // --------------------------------------------------------------------------- -static const int IDM_WINDOWTILE = 4001; static const int IDM_WINDOWTILEHOR = 4001; static const int IDM_WINDOWCASCADE = 4002; static const int IDM_WINDOWICONS = 4003; @@ -88,10 +83,6 @@ static const int IDM_WINDOWPREV = 4006; static const int wxFIRST_MDI_CHILD = 4100; static const int wxLAST_MDI_CHILD = 4600; -// Status border dimensions -static const int wxTHICK_LINE_BORDER = 3; -static const int wxTHICK_LINE_WIDTH = 1; - // --------------------------------------------------------------------------- // private functions // --------------------------------------------------------------------------- @@ -138,6 +129,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow) BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame) EVT_SIZE(wxMDIParentFrame::OnSize) + EVT_ICONIZE(wxMDIParentFrame::OnIconized) EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) END_EVENT_TABLE() @@ -222,6 +214,8 @@ bool wxMDIParentFrame::Create(wxWindow *parent, return false; } + SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); + // unlike (almost?) all other windows, frames are created hidden m_isShown = false; @@ -318,7 +312,7 @@ void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu) { int nCount = bar->GetMenuCount(); for (int n = 0; n < nCount; n++) - bar->GetMenu(n)->UpdateUI(source); + bar->GetMenu(n)->UpdateUI(source); } } } @@ -328,7 +322,7 @@ void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu) } } -void wxMDIParentFrame::OnSize(wxSizeEvent&) +void wxMDIParentFrame::UpdateClientSize() { if ( GetClientWindow() ) { @@ -339,6 +333,23 @@ void wxMDIParentFrame::OnSize(wxSizeEvent&) } } +void wxMDIParentFrame::OnSize(wxSizeEvent& WXUNUSED(event)) +{ + UpdateClientSize(); + + // do not call event.Skip() here, it somehow messes up MDI client window +} + +void wxMDIParentFrame::OnIconized(wxIconizeEvent& event) +{ + event.Skip(); + + if ( !event.Iconized() ) + { + UpdateClientSize(); + } +} + // Returns the active MDI child window wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { @@ -490,9 +501,8 @@ WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message, break; case WM_SIZE: - // as we don't (usually) resize the MDI client to exactly fit the - // client area (we put it below the toolbar, above statusbar &c), - // we should not pass this one to DefFrameProc + // though we don't (usually) resize the MDI client to exactly fit the + // client area we need to pass this one to DefFrameProc to allow the children to show break; } @@ -536,6 +546,14 @@ bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) return win->MSWCommand(cmd, id); } + if (wxCurrentPopupMenu) + { + wxMenu *popupMenu = wxCurrentPopupMenu; + wxCurrentPopupMenu = NULL; + if (popupMenu->MSWCommand(cmd, id)) + return true; + } + // is it one of standard MDI commands? WXWPARAM wParam = 0; WXLPARAM lParam = 0; @@ -780,7 +798,22 @@ wxMDIChildFrame::~wxMDIChildFrame() bool wxMDIChildFrame::Show(bool show) { m_needsInitialShow = false; - return wxFrame::Show(show); + + if (!wxFrame::Show(show)) + return false; + + // KH: Without this call, new MDI children do not become active. + // This was added here after the same BringWindowToTop call was + // removed from wxTopLevelWindow::Show (November 2005) + if ( show ) + ::BringWindowToTop(GetHwnd()); + + // we need to refresh the MDI frame window menu to include (or exclude if + // we've been hidden) this frame + wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); + MDISetMenu(parent->GetClientWindow(), NULL, NULL); + + return true; } // Set the client size (i.e. leave the calculation of borders etc. @@ -840,8 +873,10 @@ void wxMDIChildFrame::DoGetPosition(int *x, int *y) const wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent(); ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point); - *x = point.x; - *y = point.y; + if (x) + *x = point.x; + if (y) + *y = point.y; } void wxMDIChildFrame::InternalSetMenuBar() @@ -854,6 +889,12 @@ void wxMDIChildFrame::InternalSetMenuBar() parent->m_parentFrameActive = false; } +void wxMDIChildFrame::DetachMenuBar() +{ + RemoveWindowMenu(NULL, m_hMenu); + wxFrame::DetachMenuBar(); +} + WXHICON wxMDIChildFrame::GetDefaultIcon() const { // we don't have any standard icons (any more) @@ -1057,7 +1098,7 @@ bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate), bool wxMDIChildFrame::HandleWindowPosChanging(void *pos) { WINDOWPOS *lpPos = (WINDOWPOS *)pos; -#if defined(__WIN95__) + if (!(lpPos->flags & SWP_NOSIZE)) { RECT rectClient; @@ -1071,15 +1112,7 @@ bool wxMDIChildFrame::HandleWindowPosChanging(void *pos) lpPos->cx = rectClient.right - rectClient.left; lpPos->cy = rectClient.bottom - rectClient.top; } -#if wxUSE_TOOLBAR - wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent(); - if (pFrameWnd && pFrameWnd->GetToolBar() && pFrameWnd->GetToolBar()->IsShown()) - { - pFrameWnd->GetToolBar()->Refresh(); - } -#endif } -#endif // Win95 return false; } @@ -1097,14 +1130,14 @@ bool wxMDIChildFrame::HandleGetMinMaxInfo(void *mmInfo) minHeight = GetMinHeight(); // but allow GetSizeHints() to set the min size - if ( minWidth != -1 ) + if ( minWidth != wxDefaultCoord ) { info->ptMinTrackSize.x = minWidth; processed = true; } - if ( minHeight != -1 ) + if ( minHeight != wxDefaultCoord ) { info->ptMinTrackSize.y = minHeight; @@ -1126,7 +1159,9 @@ WXLRESULT wxMDIChildFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXL bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg) { - return wxFrame::MSWTranslateMessage(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); } // --------------------------------------------------------------------------- @@ -1165,10 +1200,10 @@ void wxMDIChildFrame::MSWDestroyWindow() // style when a child is maximised (a double border looks silly.) bool wxMDIChildFrame::ResetWindowStyle(void *vrect) { -#if defined(__WIN95__) RECT *rect = (RECT *)vrect; wxMDIParentFrame* pFrameWnd = (wxMDIParentFrame *)GetParent(); wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild(); + if (!pChild || (pChild == this)) { HWND hwndClient = GetWinHwnd(pFrameWnd->GetClientWindow()); @@ -1200,7 +1235,6 @@ bool wxMDIChildFrame::ResetWindowStyle(void *vrect) return true; } } -#endif // Win95 return false; } @@ -1229,11 +1263,7 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) if ( style & wxVSCROLL ) msStyle |= WS_VSCROLL; -#if defined(__WIN95__) DWORD exStyle = WS_EX_CLIENTEDGE; -#else - DWORD exStyle = 0; -#endif wxWindowCreationHook hook(this); m_hWnd = (WXHWND)::CreateWindowEx @@ -1283,11 +1313,11 @@ void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeF // (see OGL studio sample). So check if the position is changed and if so, // redraw the MDI child frames. - wxPoint oldPos = GetPosition(); + const wxPoint oldPos = GetPosition(); - wxWindow::DoSetSize(x, y, width, height, sizeFlags); + wxWindow::DoSetSize(x, y, width, height, sizeFlags | wxSIZE_FORCE); - wxPoint newPos = GetPosition(); + const wxPoint newPos = GetPosition(); if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) { @@ -1344,13 +1374,16 @@ void wxMDIChildFrame::OnIdle(wxIdleEvent& event) static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow) { - ::SendMessage(GetWinHwnd(win), WM_MDISETMENU, -#ifdef __WIN32__ - (WPARAM)hmenuFrame, (LPARAM)hmenuWindow -#else - 0, MAKELPARAM(hmenuFrame, hmenuWindow) -#endif - ); + if ( hmenuFrame || hmenuWindow ) + { + if ( !::SendMessage(GetWinHwnd(win), + WM_MDISETMENU, + (WPARAM)hmenuFrame, + (LPARAM)hmenuWindow) ) + { + wxLogLastError(_T("SendMessage(WM_MDISETMENU)")); + } + } // update menu bar of the parent window wxWindow *parent = win->GetParent(); @@ -1381,7 +1414,8 @@ static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu) continue; } - if ( wxStripMenuCodes(wxString(buf)).IsSameAs(_("Help")) ) + wxString strBuf(buf); + if ( wxStripMenuCodes(strBuf) == wxGetStockLabel(wxID_HELP,false) ) { success = true; ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING, @@ -1450,4 +1484,3 @@ static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam, } #endif // wxUSE_MDI && !defined(__WXUNIVERSAL__) -