X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..3ad70d312ed44871daaaa97be0ebcebadd9ae6ce:/src/msw/mdi.cpp diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 210013f15f..be4d08a41b 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // =========================================================================== @@ -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() ) @@ -640,6 +670,7 @@ bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg) void wxMDIChildFrame::Init() { m_needsResize = true; + m_needsInitialShow = true; } bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, @@ -651,9 +682,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 +705,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 +762,9 @@ wxMDIChildFrame::~wxMDIChildFrame() #if wxUSE_TOOLBAR m_frameToolBar = NULL; #endif +#if wxUSE_STATUSBAR m_frameStatusBar = NULL; +#endif // wxUSE_STATUSBAR DestroyChildren(); @@ -741,6 +773,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 +797,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 +817,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 +1310,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