fixed "missing" initial resize of wxMDIChildFrame
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7630 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mdi.h
|
||||
// Name: wx/msw/mdi.h
|
||||
// Purpose: MDI (Multiple Document Interface) classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
class WXDLLEXPORT wxMDIChildFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
wxMDIChildFrame();
|
||||
wxMDIChildFrame() { Init(); }
|
||||
wxMDIChildFrame(wxMDIParentFrame *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
@@ -130,6 +130,8 @@ public:
|
||||
long style = wxDEFAULT_FRAME_STYLE,
|
||||
const wxString& name = wxFrameNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, title, pos, size, style, name);
|
||||
}
|
||||
|
||||
@@ -150,8 +152,10 @@ public:
|
||||
virtual void Restore();
|
||||
virtual void Activate();
|
||||
|
||||
// Handlers
|
||||
// Implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// Handlers
|
||||
bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
|
||||
bool HandleWindowPosChanging(void *lpPos);
|
||||
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
|
||||
@@ -162,14 +166,22 @@ public:
|
||||
|
||||
virtual void MSWDestroyWindow();
|
||||
|
||||
// Implementation
|
||||
bool ResetWindowStyle(void *vrect);
|
||||
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
|
||||
protected:
|
||||
virtual void DoGetPosition(int *x, int *y) const;
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
virtual void InternalSetMenuBar();
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
private:
|
||||
bool m_needsResize; // flag which tells us to artificially resize the frame
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
|
||||
};
|
||||
|
||||
@@ -179,8 +191,6 @@ protected:
|
||||
|
||||
class WXDLLEXPORT wxMDIClientWindow : public wxWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
|
||||
|
||||
public:
|
||||
wxMDIClientWindow() { Init(); }
|
||||
wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
|
||||
@@ -207,6 +217,7 @@ protected:
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -161,6 +161,10 @@ public:
|
||||
wxWindow* GetWindowChild1(wxWindowID id);
|
||||
wxWindow* GetWindowChild(wxWindowID id);
|
||||
|
||||
// a MSW only function which sends a size event to the window using its
|
||||
// current size - this has an effect of refreshing the window layout
|
||||
void SendSizeEvent();
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
|
@@ -132,6 +132,10 @@ BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
|
||||
EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
|
||||
EVT_IDLE(wxMDIChildFrame::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
|
||||
EVT_SCROLL(wxMDIClientWindow::OnScroll)
|
||||
END_EVENT_TABLE()
|
||||
@@ -612,8 +616,9 @@ bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg)
|
||||
// wxMDIChildFrame
|
||||
// ===========================================================================
|
||||
|
||||
wxMDIChildFrame::wxMDIChildFrame()
|
||||
void wxMDIChildFrame::Init()
|
||||
{
|
||||
m_needsResize = TRUE;
|
||||
}
|
||||
|
||||
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
|
||||
@@ -1201,6 +1206,22 @@ void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeF
|
||||
}
|
||||
}
|
||||
|
||||
void wxMDIChildFrame::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
// 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
|
||||
// generate an artificial size event here
|
||||
if ( m_needsResize )
|
||||
{
|
||||
m_needsResize = FALSE; // avoid any possibility of recursion
|
||||
|
||||
SendSizeEvent();
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// non member functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@@ -108,10 +108,7 @@
|
||||
// private function prototypes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// send a dummy WM_SIZE to the given window: this is used to relayout the frame
|
||||
// which contains us
|
||||
static void SendResizeMessage(HWND hwnd);
|
||||
|
||||
// adjust toolbar bitmap colours
|
||||
static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -270,7 +267,7 @@ wxToolBar::~wxToolBar()
|
||||
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
|
||||
if ( frame && wxTopLevelWindows.Find(frame) )
|
||||
{
|
||||
SendResizeMessage(GetHwndOf(frame));
|
||||
frame->SendSizeEvent();
|
||||
}
|
||||
|
||||
if ( m_hBitmap )
|
||||
@@ -895,7 +892,7 @@ void wxToolBar::UpdateSize()
|
||||
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
|
||||
if ( frame )
|
||||
{
|
||||
SendResizeMessage(GetHwndOf(frame));
|
||||
frame->SendSizeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,19 +1002,6 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
// private functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static void SendResizeMessage(HWND hwnd)
|
||||
{
|
||||
// don't change the size, we just need to generate a WM_SIZE
|
||||
RECT r;
|
||||
if ( !::GetWindowRect(hwnd, &r) )
|
||||
{
|
||||
wxLogLastError(_T("GetWindowRect"));
|
||||
}
|
||||
|
||||
(void)::PostMessage(hwnd, WM_SIZE, SIZE_RESTORED,
|
||||
MAKELPARAM(r.right - r.left, r.bottom - r.top));
|
||||
}
|
||||
|
||||
// These are the default colors used to map the bitmap colors to the current
|
||||
// system colors. Note that they are in BGR format because this is what Windows
|
||||
// wants (and not RGB)
|
||||
|
@@ -3061,6 +3061,19 @@ bool wxWindow::HandleGetMinMaxInfo(void *mmInfo)
|
||||
return rc;
|
||||
}
|
||||
|
||||
// generate an artificial resize event
|
||||
void wxWindow::SendSizeEvent()
|
||||
{
|
||||
RECT r;
|
||||
if ( !::GetWindowRect(GetHwnd(), &r) )
|
||||
{
|
||||
wxLogLastError(_T("GetWindowRect"));
|
||||
}
|
||||
|
||||
(void)::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED,
|
||||
MAKELPARAM(r.right - r.left, r.bottom - r.top));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// command messages
|
||||
// ---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user