X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..0c8b041f147ff9bb6ce38f0e2da1fd82f6484523:/src/msw/mdi.cpp diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 6f14a8a454..5a3fcf83af 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -203,7 +203,7 @@ bool wxMDIParentFrame::Create(wxWindow *parent, if ( parent ) parent->AddChild(this); - if ( id > -1 ) + if ( id != wxID_ANY ) m_windowId = id; else m_windowId = NewControlId(); @@ -234,7 +234,9 @@ wxMDIParentFrame::~wxMDIParentFrame() #if wxUSE_TOOLBAR m_frameToolBar = NULL; #endif +#if wxUSE_STATUSBAR m_frameStatusBar = NULL; +#endif // wxUSE_STATUSBAR DestroyChildren(); @@ -298,6 +300,34 @@ void wxMDIParentFrame::SetWindowMenu(wxMenu* menu) } } +void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu) +{ + wxMDIChildFrame *child = GetActiveChild(); + if ( child ) + { + wxEvtHandler* source = child->GetEventHandler(); + wxMenuBar* bar = child->GetMenuBar(); + + if (menu) + { + menu->UpdateUI(source); + } + else + { + if ( bar != NULL ) + { + int nCount = bar->GetMenuCount(); + for (int n = 0; n < nCount; n++) + bar->GetMenu(n)->UpdateUI(source); + } + } + } + else + { + wxFrameBase::DoMenuUpdates(menu); + } +} + void wxMDIParentFrame::OnSize(wxSizeEvent&) { if ( GetClientWindow() ) @@ -354,10 +384,14 @@ void wxMDIParentFrame::Cascade() ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDICASCADE, 0, 0); } -// TODO: add a direction argument (hor/vert) -void wxMDIParentFrame::Tile() +void wxMDIParentFrame::Tile(wxOrientation orient) { - ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE, MDITILE_HORIZONTAL, 0); + wxASSERT_MSG( orient == wxHORIZONTAL || orient == wxVERTICAL, + _T("invalid orientation value") ); + + ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE, + orient == wxHORIZONTAL ? MDITILE_HORIZONTAL + : MDITILE_VERTICAL, 0); } void wxMDIParentFrame::ArrangeIcons() @@ -456,9 +490,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; } @@ -640,6 +673,7 @@ bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg) void wxMDIChildFrame::Init() { m_needsResize = true; + m_needsInitialShow = true; } bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, @@ -651,9 +685,8 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, const wxString& name) { SetName(name); - wxWindowBase::Show(true); // MDI child frame starts off shown - if ( id > -1 ) + if ( id != wxID_ANY ) m_windowId = id; else m_windowId = (int)NewControlId(); @@ -675,27 +708,27 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, : wxMDIChildFrameClassNameNoRedraw; mcs.szTitle = title; mcs.hOwner = wxGetInstance(); - if (x > -1) + if (x != wxDefaultCoord) mcs.x = x; else mcs.x = CW_USEDEFAULT; - if (y > -1) + if (y != wxDefaultCoord) mcs.y = y; else mcs.y = CW_USEDEFAULT; - if (width > -1) + if (width != wxDefaultCoord) mcs.cx = width; else mcs.cx = CW_USEDEFAULT; - if (height > -1) + if (height != wxDefaultCoord) mcs.cy = height; else mcs.cy = CW_USEDEFAULT; - DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN | WS_VISIBLE ; + DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN; if (style & wxMINIMIZE_BOX) msflags |= WS_MINIMIZEBOX; if (style & wxMAXIMIZE_BOX) @@ -732,7 +765,9 @@ wxMDIChildFrame::~wxMDIChildFrame() #if wxUSE_TOOLBAR m_frameToolBar = NULL; #endif +#if wxUSE_STATUSBAR m_frameStatusBar = NULL; +#endif // wxUSE_STATUSBAR DestroyChildren(); @@ -741,6 +776,12 @@ wxMDIChildFrame::~wxMDIChildFrame() MSWDestroyWindow(); } +bool wxMDIChildFrame::Show(bool show) +{ + m_needsInitialShow = false; + return wxFrame::Show(show); +} + // Set the client size (i.e. leave the calculation of borders etc. // to wxWidgets) void wxMDIChildFrame::DoSetClientSize(int width, int height) @@ -759,12 +800,14 @@ void wxMDIChildFrame::DoSetClientSize(int width, int height) int actual_width = rect2.right - rect2.left - rect.right + width; int actual_height = rect2.bottom - rect2.top - rect.bottom + height; +#if wxUSE_STATUSBAR if (GetStatusBar() && GetStatusBar()->IsShown()) { int sx, sy; GetStatusBar()->GetSize(&sx, &sy); actual_height += sy; } +#endif // wxUSE_STATUSBAR POINT point; point.x = rect2.left; @@ -777,7 +820,8 @@ void wxMDIChildFrame::DoSetClientSize(int width, int height) MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true); - wxSizeEvent event(wxSize(width, height), m_windowId); + wxSize size(width, height); + wxSizeEvent event(size, m_windowId); event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); } @@ -1269,6 +1313,16 @@ void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeF void wxMDIChildFrame::OnIdle(wxIdleEvent& event) { + // wxMSW prior to 2.5.3 created MDI child frames as visible, which resulted + // in flicker e.g. when the frame contained controls with non-trivial + // layout. Since 2.5.3, the frame is created hidden as all other top level + // windows. In order to maintain backward compatibility, the frame is shown + // in OnIdle, unless Show(false) was called by the programmer before. + if ( m_needsInitialShow ) + { + Show(true); + } + // MDI child frames get their WM_SIZE when they're constructed but at this // moment they don't have any children yet so all child windows will be // positioned incorrectly when they are added later - to fix this, we