1. fixed toolbar deletion problem (don't leave hole any longer)
2. tried to fix modal dialog handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -116,8 +116,7 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
|||||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||||
SetName(name);
|
SetName(name);
|
||||||
|
|
||||||
if (!parent)
|
wxTopLevelWindows.Append(this);
|
||||||
wxTopLevelWindows.Append(this);
|
|
||||||
|
|
||||||
// windowFont = wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL);
|
// windowFont = wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL);
|
||||||
|
|
||||||
@@ -324,47 +323,45 @@ bool wxDialog::IsModalShowing() const
|
|||||||
void wxDialog::DoShowModal()
|
void wxDialog::DoShowModal()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
|
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
|
||||||
|
wxCHECK_RET( IsModal(), _T("can't DoShowModal() modeless dialog") );
|
||||||
|
|
||||||
wxModalDialogs.Append(this);
|
wxModalDialogs.Append(this);
|
||||||
|
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
|
|
||||||
// remember where the focus was
|
// inside this block, all app windows are disabled
|
||||||
if ( !m_oldFocus )
|
|
||||||
{
|
{
|
||||||
m_oldFocus = parent;
|
wxWindowDisabler wd(this);
|
||||||
}
|
|
||||||
if ( !m_oldFocus )
|
|
||||||
{
|
|
||||||
m_oldFocus = wxTheApp->GetTopWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable the parent window first
|
// remember where the focus was
|
||||||
HWND hwndParent = parent ? GetHwndOf(parent) : (HWND)NULL;
|
if ( !m_oldFocus )
|
||||||
if ( hwndParent )
|
{
|
||||||
{
|
m_oldFocus = parent;
|
||||||
::EnableWindow(hwndParent, FALSE);
|
}
|
||||||
}
|
if ( !m_oldFocus )
|
||||||
|
{
|
||||||
|
m_oldFocus = wxTheApp->GetTopWindow();
|
||||||
|
}
|
||||||
|
|
||||||
// enter the modal loop
|
// enter the modal loop
|
||||||
while ( IsModalShowing() )
|
while ( IsModalShowing() )
|
||||||
{
|
{
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
wxMutexGuiLeaveOrEnter();
|
wxMutexGuiLeaveOrEnter();
|
||||||
#endif // wxUSE_THREADS
|
#endif // wxUSE_THREADS
|
||||||
|
|
||||||
while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
|
while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
|
||||||
;
|
;
|
||||||
|
|
||||||
// a message came or no more idle processing to do
|
// a message came or no more idle processing to do
|
||||||
wxTheApp->DoMessage();
|
wxTheApp->DoMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reenable the parent window if any
|
#ifdef __WIN32__
|
||||||
if ( hwndParent )
|
if ( parent )
|
||||||
{
|
::SetActiveWindow(GetHwndOf(parent));
|
||||||
::EnableWindow(hwndParent, TRUE);
|
#endif // __WIN32__
|
||||||
}
|
|
||||||
|
|
||||||
// and restore focus
|
// and restore focus
|
||||||
if ( m_oldFocus && (m_oldFocus != this) )
|
if ( m_oldFocus && (m_oldFocus != this) )
|
||||||
@@ -405,6 +402,17 @@ bool wxDialog::Show(bool show)
|
|||||||
{
|
{
|
||||||
if ( show )
|
if ( show )
|
||||||
{
|
{
|
||||||
|
// modal dialog needs a parent window, so try to find one
|
||||||
|
if ( !GetParent() )
|
||||||
|
{
|
||||||
|
wxWindow *parent = wxTheApp->GetTopWindow();
|
||||||
|
if ( parent && parent != this )
|
||||||
|
{
|
||||||
|
// use it
|
||||||
|
m_parent = parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DoShowModal();
|
DoShowModal();
|
||||||
}
|
}
|
||||||
else // end of modal dialog
|
else // end of modal dialog
|
||||||
@@ -418,32 +426,16 @@ bool wxDialog::Show(bool show)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replacement for Show(TRUE) for modal dialogs - returns return code
|
// a special version for Show(TRUE) for modal dialogs which returns return code
|
||||||
int wxDialog::ShowModal()
|
int wxDialog::ShowModal()
|
||||||
{
|
{
|
||||||
// modal dialog needs a parent window, so try to find one
|
if ( !IsModal() )
|
||||||
if ( !GetParent() )
|
|
||||||
{
|
{
|
||||||
wxWindow *parent = wxTheApp->GetTopWindow();
|
SetModal(TRUE);
|
||||||
if ( parent && parent != this )
|
|
||||||
{
|
|
||||||
// use it
|
|
||||||
m_parent = parent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowDisabler *wd = (wxWindowDisabler *)NULL;
|
|
||||||
if ( !GetParent() )
|
|
||||||
{
|
|
||||||
// still no parent? make the dialog app modal by disabling all windows
|
|
||||||
wd = new wxWindowDisabler(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_windowStyle |= wxDIALOG_MODAL;
|
|
||||||
Show(TRUE);
|
Show(TRUE);
|
||||||
|
|
||||||
delete wd;
|
|
||||||
|
|
||||||
return GetReturnCode();
|
return GetReturnCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -163,6 +163,9 @@ wxFrame::~wxFrame()
|
|||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = TRUE;
|
||||||
wxTopLevelWindows.DeleteObject(this);
|
wxTopLevelWindows.DeleteObject(this);
|
||||||
|
|
||||||
|
// the ~wxToolBar() code relies on the previous line to be executed before
|
||||||
|
// this one, i.e. the frame should remove itself from wxTopLevelWindows
|
||||||
|
// before destorying its toolbar
|
||||||
DeleteAllBars();
|
DeleteAllBars();
|
||||||
|
|
||||||
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
||||||
|
@@ -108,6 +108,10 @@
|
|||||||
// private function prototypes
|
// 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);
|
||||||
|
|
||||||
static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
|
static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -258,7 +262,18 @@ bool wxToolBar::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxToolBar::~wxToolBar()
|
wxToolBar::~wxToolBar()
|
||||||
{
|
{
|
||||||
if (m_hBitmap)
|
// we must refresh the frame size when the toolbar is deleted but the frame
|
||||||
|
// is not - otherwise toolbar leaves a hole in the place it used to occupy
|
||||||
|
//
|
||||||
|
// NB: a frame is being deleted only if it is not any longer in
|
||||||
|
// wxTopLevelWindows list
|
||||||
|
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
|
||||||
|
if ( frame && wxTopLevelWindows.Find(frame) )
|
||||||
|
{
|
||||||
|
SendResizeMessage(GetHwndOf(frame));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_hBitmap )
|
||||||
{
|
{
|
||||||
::DeleteObject((HBITMAP) m_hBitmap);
|
::DeleteObject((HBITMAP) m_hBitmap);
|
||||||
}
|
}
|
||||||
@@ -880,15 +895,7 @@ void wxToolBar::UpdateSize()
|
|||||||
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
|
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
|
||||||
if ( frame )
|
if ( frame )
|
||||||
{
|
{
|
||||||
// don't change the size, we just need to generate a WM_SIZE
|
SendResizeMessage(GetHwndOf(frame));
|
||||||
RECT r;
|
|
||||||
if ( !GetWindowRect(GetHwndOf(frame), &r) )
|
|
||||||
{
|
|
||||||
wxLogLastError(_T("GetWindowRect"));
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)::SendMessage(GetHwndOf(frame), WM_SIZE, SIZE_RESTORED,
|
|
||||||
MAKELPARAM(r.right - r.left, r.bottom - r.top));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -998,6 +1005,19 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
// private functions
|
// 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
|
// 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
|
// system colors. Note that they are in BGR format because this is what Windows
|
||||||
// wants (and not RGB)
|
// wants (and not RGB)
|
||||||
|
Reference in New Issue
Block a user