1. corrected problem with label updating in wxProgressDialog
2. optical fix in wxTipDlg: use wxTE_RICH control to avoid vert scrollbar 3. put wxProgressDialog demo into dialogs sample, seems more appropriate 4. fixed a serious bug in wxProgressDialog when its parent was not a top level window (as in controls sample) 5. fixes in BringWindowToTop() usage in msw/dialog.cpp 6. fixed another serious bug in wxProgressDialog::OnClose() 7. wxDialog restores focus to previously focused window once again 8. attempts at fixing wxBusyCursor with modal dialogs problem - unsuccessful git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6273 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
488fe1feb6
commit
abceee76ea
@ -23,6 +23,7 @@
|
|||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
|
|
||||||
class WXDLLEXPORT wxButton;
|
class WXDLLEXPORT wxButton;
|
||||||
|
class WXDLLEXPORT wxGauge;
|
||||||
class WXDLLEXPORT wxStaticText;
|
class WXDLLEXPORT wxStaticText;
|
||||||
|
|
||||||
/* Progress dialog which shows a moving progress bar.
|
/* Progress dialog which shows a moving progress bar.
|
||||||
@ -75,21 +76,19 @@ private:
|
|||||||
wxStaticText *CreateLabel(const wxString& text, wxWindow **lastWindow);
|
wxStaticText *CreateLabel(const wxString& text, wxWindow **lastWindow);
|
||||||
|
|
||||||
// the status bar
|
// the status bar
|
||||||
class wxGauge *m_gauge;
|
wxGauge *m_gauge;
|
||||||
// the message displayed
|
// the message displayed
|
||||||
class wxStaticText *m_msg;
|
wxStaticText *m_msg;
|
||||||
// disable all or parent window only
|
|
||||||
bool m_disableParentOnly;
|
|
||||||
// auto-hide?
|
|
||||||
bool m_AutoHide;
|
|
||||||
// displayed elapsed, estimated, remaining time
|
// displayed elapsed, estimated, remaining time
|
||||||
class wxStaticText *m_elapsed,
|
class wxStaticText *m_elapsed,
|
||||||
*m_estimated,
|
*m_estimated,
|
||||||
*m_remaining;
|
*m_remaining;
|
||||||
// time when the dialog was created
|
// time when the dialog was created
|
||||||
unsigned long m_timeStart;
|
unsigned long m_timeStart;
|
||||||
// parent window
|
|
||||||
wxWindow *m_parent;
|
// parent top level window (may be NULL)
|
||||||
|
wxWindow *m_parentTop;
|
||||||
|
|
||||||
// continue processing or not (return value for Update())
|
// continue processing or not (return value for Update())
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -395,7 +395,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
|||||||
wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
|
wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
|
||||||
m_text->SetBackgroundColour("wheat");
|
m_text->SetBackgroundColour("wheat");
|
||||||
|
|
||||||
// wxLog::AddTraceMask(_T("focus"));
|
if ( 0 )
|
||||||
|
wxLog::AddTraceMask(_T("focus"));
|
||||||
m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
|
m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
|
||||||
|
|
||||||
m_notebook = new wxNotebook(this, ID_NOTEBOOK);
|
m_notebook = new wxNotebook(this, ID_NOTEBOOK);
|
||||||
@ -1146,16 +1147,16 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
|
|||||||
|
|
||||||
|
|
||||||
bool cont = TRUE;
|
bool cont = TRUE;
|
||||||
for ( int i = 0; i < max && cont; i++ )
|
for ( int i = 0; i <= max && cont; i++ )
|
||||||
{
|
{
|
||||||
wxSleep(1);
|
wxSleep(1);
|
||||||
if ( i == max - 1 )
|
if ( i == max )
|
||||||
{
|
{
|
||||||
cont = dialog.Update(i, "That's all, folks!");
|
cont = dialog.Update(i, "That's all, folks!");
|
||||||
}
|
}
|
||||||
else if ( i == max / 2 )
|
else if ( i == max / 2 )
|
||||||
{
|
{
|
||||||
cont = dialog.Update(i, "Only a half left!");
|
cont = dialog.Update(i, "Only a half left (very long message)!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1219,12 +1220,15 @@ void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
|
|||||||
|
|
||||||
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxBeginBusyCursor();
|
wxBusyCursor bc;
|
||||||
|
|
||||||
|
#if 0 // VZ: my temp test code, will remove
|
||||||
|
wxGetTextFromUser("msg", "caption", "val", this);
|
||||||
|
return;
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK );
|
wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK );
|
||||||
dialog.ShowModal();
|
dialog.ShowModal();
|
||||||
|
|
||||||
wxEndBusyCursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "wx/fontdlg.h"
|
#include "wx/fontdlg.h"
|
||||||
#include "wx/choicdlg.h"
|
#include "wx/choicdlg.h"
|
||||||
#include "wx/tipdlg.h"
|
#include "wx/tipdlg.h"
|
||||||
|
#include "wx/progdlg.h"
|
||||||
|
|
||||||
#define wxTEST_GENERIC_DIALOGS_IN_MSW 0
|
#define wxTEST_GENERIC_DIALOGS_IN_MSW 0
|
||||||
|
|
||||||
@ -65,11 +66,19 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
|
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
|
||||||
EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
|
EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric)
|
||||||
EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
|
EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric)
|
||||||
|
#endif
|
||||||
|
#if wxUSE_PROGRESSDLG
|
||||||
|
EVT_MENU(DIALOGS_PROGRESS, MyFrame::ShowProgress)
|
||||||
#endif
|
#endif
|
||||||
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
|
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
|
||||||
|
|
||||||
EVT_BUTTON(DIALOGS_MODELESS_BTN, MyFrame::OnButton)
|
EVT_BUTTON(DIALOGS_MODELESS_BTN, MyFrame::OnButton)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(MyModelessDialog, wxDialog)
|
||||||
|
EVT_CLOSE(MyModelessDialog::OnClose)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
MyCanvas *myCanvas = (MyCanvas *) NULL;
|
MyCanvas *myCanvas = (MyCanvas *) NULL;
|
||||||
|
|
||||||
// `Main program' equivalent, creating windows and returning main app frame
|
// `Main program' equivalent, creating windows and returning main app frame
|
||||||
@ -116,6 +125,9 @@ bool MyApp::OnInit()
|
|||||||
file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S");
|
file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S");
|
||||||
file_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D");
|
file_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D");
|
||||||
file_menu->AppendSeparator();
|
file_menu->AppendSeparator();
|
||||||
|
#if wxUSE_PROGRESSDLG
|
||||||
|
file_menu->Append(DIALOGS_PROGRESS, "Pro&gress dialog\tCtrl-G");
|
||||||
|
#endif // wxUSE_PROGRESSDLG
|
||||||
file_menu->Append(DIALOGS_MODELESS, "Modeless &dialog\tCtrl-Z", "", TRUE);
|
file_menu->Append(DIALOGS_MODELESS, "Modeless &dialog\tCtrl-Z", "", TRUE);
|
||||||
file_menu->AppendSeparator();
|
file_menu->AppendSeparator();
|
||||||
file_menu->Append(wxID_EXIT, "E&xit\tAlt-X");
|
file_menu->Append(wxID_EXIT, "E&xit\tAlt-X");
|
||||||
@ -453,6 +465,56 @@ void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) )
|
|||||||
Close(TRUE);
|
Close(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_PROGRESSDLG
|
||||||
|
|
||||||
|
void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
|
||||||
|
{
|
||||||
|
static const int max = 10;
|
||||||
|
|
||||||
|
wxProgressDialog dialog("Progress dialog example",
|
||||||
|
"An informative message",
|
||||||
|
max, // range
|
||||||
|
this, // parent
|
||||||
|
wxPD_CAN_ABORT |
|
||||||
|
wxPD_APP_MODAL |
|
||||||
|
wxPD_ELAPSED_TIME |
|
||||||
|
wxPD_ESTIMATED_TIME |
|
||||||
|
wxPD_REMAINING_TIME);
|
||||||
|
|
||||||
|
bool cont = TRUE;
|
||||||
|
for ( int i = 0; i <= max && cont; i++ )
|
||||||
|
{
|
||||||
|
wxSleep(1);
|
||||||
|
if ( i == max )
|
||||||
|
{
|
||||||
|
cont = dialog.Update(i, "That's all, folks!");
|
||||||
|
}
|
||||||
|
else if ( i == max / 2 )
|
||||||
|
{
|
||||||
|
cont = dialog.Update(i, "Only a half left (very long message)!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cont = dialog.Update(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !cont )
|
||||||
|
{
|
||||||
|
wxLogStatus("Progress dialog aborted!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogStatus("Countdown from %d finished", max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_PROGRESSDLG
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// MyCanvas
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
|
void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
@ -473,3 +535,16 @@ MyModelessDialog::MyModelessDialog(wxWindow *parent)
|
|||||||
Fit();
|
Fit();
|
||||||
Centre();
|
Centre();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyModelessDialog::OnClose(wxCloseEvent& event)
|
||||||
|
{
|
||||||
|
if ( event.CanVeto() )
|
||||||
|
{
|
||||||
|
wxMessageBox("Use the menu item to close this dialog",
|
||||||
|
"Modeless dialog",
|
||||||
|
wxOK | wxICON_INFORMATION, this);
|
||||||
|
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,11 @@ class MyModelessDialog : public wxDialog
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyModelessDialog(wxWindow *parent);
|
MyModelessDialog(wxWindow *parent);
|
||||||
|
|
||||||
|
void OnClose(wxCloseEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define a new frame type
|
// Define a new frame type
|
||||||
@ -50,6 +55,7 @@ public:
|
|||||||
void DirChoose(wxCommandEvent& event);
|
void DirChoose(wxCommandEvent& event);
|
||||||
void ShowTip(wxCommandEvent& event);
|
void ShowTip(wxCommandEvent& event);
|
||||||
void ModelessDlg(wxCommandEvent& event);
|
void ModelessDlg(wxCommandEvent& event);
|
||||||
|
void ShowProgress(wxCommandEvent& event);
|
||||||
|
|
||||||
#if !defined(__WXMSW__) || wxTEST_GENERIC_DIALOGS_IN_MSW
|
#if !defined(__WXMSW__) || wxTEST_GENERIC_DIALOGS_IN_MSW
|
||||||
void ChooseColourGeneric(wxCommandEvent& event);
|
void ChooseColourGeneric(wxCommandEvent& event);
|
||||||
@ -96,7 +102,8 @@ enum
|
|||||||
DIALOGS_NUM_ENTRY,
|
DIALOGS_NUM_ENTRY,
|
||||||
DIALOGS_LOG_DIALOG,
|
DIALOGS_LOG_DIALOG,
|
||||||
DIALOGS_MODELESS,
|
DIALOGS_MODELESS,
|
||||||
DIALOGS_MODELESS_BTN
|
DIALOGS_MODELESS_BTN,
|
||||||
|
DIALOGS_PROGRESS
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -88,11 +88,14 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
|
|||||||
{
|
{
|
||||||
bool hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
|
bool hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
|
||||||
m_state = hasAbortButton ? Continue : Uncancelable;
|
m_state = hasAbortButton ? Continue : Uncancelable;
|
||||||
m_disableParentOnly = (style & wxPD_APP_MODAL) == 0;
|
|
||||||
m_AutoHide = (style & wxPD_AUTO_HIDE) != 0;
|
|
||||||
m_parent = parent;
|
|
||||||
m_maximum = maximum;
|
m_maximum = maximum;
|
||||||
|
|
||||||
|
m_parentTop = parent;
|
||||||
|
while ( m_parentTop && m_parentTop->GetParent() )
|
||||||
|
{
|
||||||
|
m_parentTop = m_parentTop->GetParent();
|
||||||
|
}
|
||||||
|
|
||||||
wxLayoutConstraints *c;
|
wxLayoutConstraints *c;
|
||||||
|
|
||||||
wxClientDC dc(this);
|
wxClientDC dc(this);
|
||||||
@ -209,10 +212,10 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
|
|||||||
|
|
||||||
Centre(wxCENTER_FRAME | wxBOTH);
|
Centre(wxCENTER_FRAME | wxBOTH);
|
||||||
|
|
||||||
if ( m_disableParentOnly )
|
if ( !(style & wxPD_APP_MODAL) )
|
||||||
{
|
{
|
||||||
if ( m_parent )
|
if ( m_parentTop )
|
||||||
m_parent->Enable(FALSE);
|
m_parentTop->Enable(FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -269,13 +272,22 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
|
|||||||
wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
|
wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
|
||||||
wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
|
wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
|
||||||
|
|
||||||
|
|
||||||
if ( m_gauge )
|
if ( m_gauge )
|
||||||
m_gauge->SetValue(value + 1);
|
m_gauge->SetValue(value + 1);
|
||||||
|
|
||||||
if ( !newmsg.IsEmpty() )
|
if ( !newmsg.IsEmpty() )
|
||||||
|
{
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// this seems to be necessary or garbage is left when the new label is
|
||||||
|
// longer than the old one
|
||||||
|
m_msg->SetLabel(wxEmptyString);
|
||||||
|
#endif // MSW
|
||||||
|
|
||||||
m_msg->SetLabel(newmsg);
|
m_msg->SetLabel(newmsg);
|
||||||
|
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
|
if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
|
||||||
{
|
{
|
||||||
unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
|
unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
|
||||||
@ -287,7 +299,7 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
|
|||||||
SetTimeLabel(remaining, m_remaining);
|
SetTimeLabel(remaining, m_remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (value == m_maximum ) && !m_AutoHide )
|
if ( (value == m_maximum ) && !(GetWindowStyle() & wxPD_AUTO_HIDE) )
|
||||||
{
|
{
|
||||||
if ( m_btnAbort )
|
if ( m_btnAbort )
|
||||||
{
|
{
|
||||||
@ -349,10 +361,21 @@ void wxProgressDialog::OnCancel(wxCommandEvent& event)
|
|||||||
void wxProgressDialog::OnClose(wxCloseEvent& event)
|
void wxProgressDialog::OnClose(wxCloseEvent& event)
|
||||||
{
|
{
|
||||||
if ( m_state == Uncancelable )
|
if ( m_state == Uncancelable )
|
||||||
|
{
|
||||||
|
// can't close this dialog
|
||||||
event.Veto(TRUE);
|
event.Veto(TRUE);
|
||||||
|
}
|
||||||
|
else if ( m_state == Finished )
|
||||||
|
{
|
||||||
|
// let the default handler close the window as we already terminated
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// next Update() will notice it
|
||||||
m_state = Canceled;
|
m_state = Canceled;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// destruction
|
// destruction
|
||||||
@ -360,10 +383,10 @@ void wxProgressDialog::OnClose(wxCloseEvent& event)
|
|||||||
|
|
||||||
wxProgressDialog::~wxProgressDialog()
|
wxProgressDialog::~wxProgressDialog()
|
||||||
{
|
{
|
||||||
if ( m_disableParentOnly )
|
if ( !(GetWindowStyle() & wxPD_APP_MODAL) )
|
||||||
{
|
{
|
||||||
if ( m_parent )
|
if ( m_parentTop )
|
||||||
m_parent->Enable(TRUE);
|
m_parentTop->Enable(TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
// Empty implementation for now to keep the linker happy
|
// Empty implementation for now to keep the linker happy
|
||||||
wxString wxRegTipProvider::GetTip()
|
wxString wxRegTipProvider::GetTip()
|
||||||
{
|
{
|
||||||
return "";
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __WIN32__
|
#endif // __WIN32__
|
||||||
@ -185,7 +185,10 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
|
|||||||
|
|
||||||
m_text = new wxTextCtrl(this, -1, wxT(""),
|
m_text = new wxTextCtrl(this, -1, wxT(""),
|
||||||
wxDefaultPosition, wxSize(200, 160),
|
wxDefaultPosition, wxSize(200, 160),
|
||||||
wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER);
|
wxTE_MULTILINE |
|
||||||
|
wxTE_READONLY |
|
||||||
|
wxTE_RICH | // a hack to get rid of vert scrollbar
|
||||||
|
wxSUNKEN_BORDER);
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
m_text->SetFont(wxFont(12, wxROMAN, wxNORMAL, wxNORMAL));
|
m_text->SetFont(wxFont(12, wxROMAN, wxNORMAL, wxNORMAL));
|
||||||
#else
|
#else
|
||||||
|
@ -70,6 +70,8 @@ wxWindowList wxModelessWindows;
|
|||||||
// all modal dialogs currently shown
|
// all modal dialogs currently shown
|
||||||
static wxWindowList wxModalDialogs;
|
static wxWindowList wxModalDialogs;
|
||||||
|
|
||||||
|
static wxWindow *m_oldFocus;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxWin macros
|
// wxWin macros
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -110,6 +112,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
|
m_oldFocus = FindFocus();
|
||||||
|
|
||||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||||
SetName(name);
|
SetName(name);
|
||||||
|
|
||||||
@ -206,26 +210,10 @@ wxDialog::~wxDialog()
|
|||||||
|
|
||||||
wxTopLevelWindows.DeleteObject(this);
|
wxTopLevelWindows.DeleteObject(this);
|
||||||
|
|
||||||
|
// this will call BringWindowToTop() if necessary to bring back our parent
|
||||||
|
// window to top
|
||||||
Show(FALSE);
|
Show(FALSE);
|
||||||
|
|
||||||
// VZ: this is bogus and breaks focus handling - it won't be returned to
|
|
||||||
// the window which had it previosuly if we do this
|
|
||||||
#if 0
|
|
||||||
if (m_modalShowing)
|
|
||||||
{
|
|
||||||
// For some reason, wxWindows can activate another task altogether
|
|
||||||
// when a frame is destroyed after a modal dialog has been invoked.
|
|
||||||
// Try to bring the parent to the top.
|
|
||||||
// dfgg: I moved this following line from end of function -
|
|
||||||
// must not call if another window is on top!!
|
|
||||||
// This can often happen with Close() and delayed deleting
|
|
||||||
if (GetParent() && GetParent()->GetHWND())
|
|
||||||
::BringWindowToTop((HWND) GetParent()->GetHWND());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_modalShowing = FALSE;
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
if ( !IsModal() )
|
if ( !IsModal() )
|
||||||
wxModelessWindows.DeleteObject(this);
|
wxModelessWindows.DeleteObject(this);
|
||||||
|
|
||||||
@ -327,194 +315,6 @@ bool wxDialog::IsModal() const
|
|||||||
return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
|
return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VZ: this is the old version unchanged (reindented only), it will be removed
|
|
||||||
// as soon as we're sure the new one works correctly
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
bool wxDialog::Show(bool show)
|
|
||||||
{
|
|
||||||
m_isShown = show;
|
|
||||||
|
|
||||||
if (show)
|
|
||||||
InitDialog();
|
|
||||||
|
|
||||||
bool modal = IsModal();
|
|
||||||
|
|
||||||
if (modal)
|
|
||||||
{
|
|
||||||
if (show)
|
|
||||||
{
|
|
||||||
// find the top level window which had focus before - we will restore
|
|
||||||
// focus to it later
|
|
||||||
m_hwndOldFocus = 0;
|
|
||||||
for ( HWND hwnd = ::GetFocus(); hwnd; hwnd = ::GetParent(hwnd) )
|
|
||||||
{
|
|
||||||
m_hwndOldFocus = (WXHWND)hwnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_modalShowing)
|
|
||||||
{
|
|
||||||
BringWindowToTop((HWND) GetHWND());
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_modalShowing = TRUE;
|
|
||||||
wxNode *node = wxModalDialogs.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxDialog *box = (wxDialog *)node->Data();
|
|
||||||
if (box != this)
|
|
||||||
::EnableWindow((HWND) box->GetHWND(), FALSE);
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we don't do it, some window might be deleted while we have pointers
|
|
||||||
// to them in our disabledWindows list and the program will crash when it
|
|
||||||
// will try to reenable them after the modal dialog end
|
|
||||||
wxTheApp->DeletePendingObjects();
|
|
||||||
wxList disabledWindows;
|
|
||||||
|
|
||||||
node = wxModelessWindows.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxWindow *win = (wxWindow *)node->Data();
|
|
||||||
if (::IsWindowEnabled((HWND) win->GetHWND()))
|
|
||||||
{
|
|
||||||
::EnableWindow((HWND) win->GetHWND(), FALSE);
|
|
||||||
disabledWindows.Append(win);
|
|
||||||
}
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowWindow((HWND) GetHWND(), SW_SHOW);
|
|
||||||
EnableWindow((HWND) GetHWND(), TRUE);
|
|
||||||
BringWindowToTop((HWND) GetHWND());
|
|
||||||
|
|
||||||
if ( !wxModalDialogs.Find(this) )
|
|
||||||
wxModalDialogs.Append(this);
|
|
||||||
|
|
||||||
MSG msg;
|
|
||||||
// Must test whether this dialog still exists: we may not process
|
|
||||||
// a message before the deletion.
|
|
||||||
while (wxModalDialogs.Find(this) && m_modalShowing && GetMessage(&msg, NULL, 0, 0))
|
|
||||||
{
|
|
||||||
if ( m_acceleratorTable.Ok() &&
|
|
||||||
::TranslateAccelerator((HWND)GetHWND(),
|
|
||||||
(HACCEL)m_acceleratorTable.GetHACCEL(),
|
|
||||||
&msg) )
|
|
||||||
{
|
|
||||||
// Have processed the message
|
|
||||||
}
|
|
||||||
else if ( !wxTheApp->ProcessMessage((WXMSG *)&msg) )
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get crashes (as per George Tasker's message) with nested modal dialogs,
|
|
||||||
// we should try removing the m_modalShowing test
|
|
||||||
|
|
||||||
if (m_modalShowing && !::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE))
|
|
||||||
// dfgg: NB MUST test m_modalShowing again as the message loop could have triggered
|
|
||||||
// a Show(FALSE) in the mean time!!!
|
|
||||||
// Without the test, we might delete the dialog before the end of modal showing.
|
|
||||||
{
|
|
||||||
while (wxTheApp->ProcessIdle() && m_modalShowing)
|
|
||||||
{
|
|
||||||
// Keep going until we decide we've done enough
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// dfgg: now must specifically re-enable all other app windows that we disabled earlier
|
|
||||||
node=disabledWindows.First();
|
|
||||||
while(node) {
|
|
||||||
wxWindow* win = (wxWindow*) node->Data();
|
|
||||||
if (wxModalDialogs.Find(win) || wxModelessWindows.Find(win))
|
|
||||||
{
|
|
||||||
HWND hWnd = (HWND) win->GetHWND();
|
|
||||||
if (::IsWindow(hWnd))
|
|
||||||
::EnableWindow(hWnd,TRUE);
|
|
||||||
}
|
|
||||||
node=node->Next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // !show
|
|
||||||
{
|
|
||||||
::SetFocus((HWND)m_hwndOldFocus);
|
|
||||||
|
|
||||||
wxModalDialogs.DeleteObject(this);
|
|
||||||
|
|
||||||
wxNode *last = wxModalDialogs.Last();
|
|
||||||
|
|
||||||
// If there's still a modal dialog active, we
|
|
||||||
// enable it, else we enable all modeless windows
|
|
||||||
if (last)
|
|
||||||
{
|
|
||||||
// VZ: I don't understand what this is supposed to do, so I'll leave
|
|
||||||
// it out for now and look for horrible consequences
|
|
||||||
wxDialog *box = (wxDialog *)last->Data();
|
|
||||||
HWND hwnd = (HWND) box->GetHWND();
|
|
||||||
#if 0
|
|
||||||
if (box->IsUserEnabled())
|
|
||||||
#endif // 0
|
|
||||||
EnableWindow(hwnd, TRUE);
|
|
||||||
BringWindowToTop(hwnd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxNode *node = wxModelessWindows.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxWindow *win = (wxWindow *)node->Data();
|
|
||||||
HWND hwnd = (HWND) win->GetHWND();
|
|
||||||
// Only enable again if not user-disabled.
|
|
||||||
#if 0
|
|
||||||
if (win->IsUserEnabled())
|
|
||||||
#endif // 0
|
|
||||||
EnableWindow(hwnd, TRUE);
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Try to highlight the correct window (the parent)
|
|
||||||
HWND hWndParent = 0;
|
|
||||||
if (GetParent())
|
|
||||||
{
|
|
||||||
hWndParent = (HWND) GetParent()->GetHWND();
|
|
||||||
if (hWndParent)
|
|
||||||
::BringWindowToTop(hWndParent);
|
|
||||||
}
|
|
||||||
ShowWindow((HWND) GetHWND(), SW_HIDE);
|
|
||||||
m_modalShowing = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // !modal
|
|
||||||
{
|
|
||||||
if (show)
|
|
||||||
{
|
|
||||||
ShowWindow((HWND) GetHWND(), SW_SHOW);
|
|
||||||
BringWindowToTop((HWND) GetHWND());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Try to highlight the correct window (the parent)
|
|
||||||
HWND hWndParent = 0;
|
|
||||||
if (GetParent())
|
|
||||||
{
|
|
||||||
hWndParent = (HWND) GetParent()->GetHWND();
|
|
||||||
if (hWndParent)
|
|
||||||
::BringWindowToTop(hWndParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_hWnd )
|
|
||||||
ShowWindow((HWND) GetHWND(), SW_HIDE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // 1
|
|
||||||
|
|
||||||
bool wxDialog::IsModalShowing() const
|
bool wxDialog::IsModalShowing() const
|
||||||
{
|
{
|
||||||
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
|
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
|
||||||
@ -529,14 +329,13 @@ void wxDialog::DoShowModal()
|
|||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
|
|
||||||
// remember where the focus was
|
// remember where the focus was
|
||||||
wxWindow *winFocus = FindFocus();
|
if ( !m_oldFocus )
|
||||||
if ( !winFocus )
|
|
||||||
{
|
{
|
||||||
winFocus = parent;
|
m_oldFocus = parent;
|
||||||
}
|
}
|
||||||
if ( !winFocus )
|
if ( !m_oldFocus )
|
||||||
{
|
{
|
||||||
winFocus = wxTheApp->GetTopWindow();
|
m_oldFocus = wxTheApp->GetTopWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable the parent window first
|
// disable the parent window first
|
||||||
@ -567,27 +366,29 @@ void wxDialog::DoShowModal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// and restore focus
|
// and restore focus
|
||||||
if ( winFocus && (winFocus != this) )
|
if ( m_oldFocus && (m_oldFocus != this) )
|
||||||
{
|
{
|
||||||
winFocus->SetFocus();
|
m_oldFocus->SetFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDialog::Show(bool show)
|
bool wxDialog::Show(bool show)
|
||||||
{
|
{
|
||||||
// The following is required when the parent has been disabled,
|
// The following is required when the parent has been disabled, (modal
|
||||||
// (modal dialogs, or modeless dialogs with disabling such as wxProgressDialog).
|
// dialogs, or modeless dialogs with disabling such as wxProgressDialog).
|
||||||
// Otherwise the parent disappears behind other windows when the dialog is hidden.
|
// Otherwise the parent disappears behind other windows when the dialog is
|
||||||
|
// hidden.
|
||||||
if ( !show )
|
if ( !show )
|
||||||
{
|
{
|
||||||
HWND hwndParent = GetParent() ? (HWND) GetParent()->GetHWND() : (HWND)NULL;
|
wxWindow *parent = GetParent();
|
||||||
if ( hwndParent )
|
if ( parent )
|
||||||
{
|
{
|
||||||
::BringWindowToTop(hwndParent);
|
::BringWindowToTop(GetHwndOf(parent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !wxDialogBase::Show(show) )
|
// ShowModal() may be called for already shown dialog
|
||||||
|
if ( !wxDialogBase::Show(show) && !(show && IsModal()) )
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -616,8 +417,6 @@ bool wxDialog::Show(bool show)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // 0/1
|
|
||||||
|
|
||||||
// Replacement for Show(TRUE) for modal dialogs - returns return code
|
// Replacement for Show(TRUE) for modal dialogs - returns return code
|
||||||
int wxDialog::ShowModal()
|
int wxDialog::ShowModal()
|
||||||
{
|
{
|
||||||
@ -728,6 +527,17 @@ long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
// message - otherwise it would close us
|
// message - otherwise it would close us
|
||||||
processed = !Close();
|
processed = !Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_SETCURSOR:
|
||||||
|
// we want to override the busy cursor for modal dialogs:
|
||||||
|
// typically, wxBeginBusyCursor() is called and then a modal dialog
|
||||||
|
// is shown, but the modal dialog shouldn't have this cursor
|
||||||
|
if ( wxIsBusy() )
|
||||||
|
{
|
||||||
|
rc = TRUE;
|
||||||
|
|
||||||
|
processed = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !processed )
|
if ( !processed )
|
||||||
|
Loading…
Reference in New Issue
Block a user