fixes for programmatically deleting the find/replace dialog

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12481 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-11-18 23:06:43 +00:00
parent 01f944e67e
commit 14fca7389a
3 changed files with 92 additions and 22 deletions

View File

@@ -165,8 +165,8 @@ bool MyApp::OnInit()
file_menu->Append(DIALOGS_BUSYINFO, "&Busy info dialog\tCtrl-B");
#endif // wxUSE_BUSYINFO
#if wxUSE_FINDREPLDLG
file_menu->Append(DIALOGS_FIND, "&Find dialog\tCtrl-F");
file_menu->Append(DIALOGS_REPLACE, "Find and &replace dialog\tShift-Ctrl-F");
file_menu->Append(DIALOGS_FIND, "&Find dialog\tCtrl-F", "", TRUE);
file_menu->Append(DIALOGS_REPLACE, "Find and &replace dialog\tShift-Ctrl-F", "", TRUE);
#endif // wxUSE_FINDREPLDLG
file_menu->AppendSeparator();
file_menu->Append(DIALOGS_MODAL, "Mo&dal dialog\tCtrl-D");
@@ -199,6 +199,9 @@ MyFrame::MyFrame(wxWindow *parent,
{
m_dialog = (MyModelessDialog *)NULL;
m_dlgFind =
m_dlgReplace = NULL;
CreateStatusBar();
}
@@ -658,27 +661,45 @@ void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
{
wxFindReplaceDialog *dialog = new wxFindReplaceDialog
(
this,
&m_findData,
"Find and replace dialog",
wxFR_REPLACEDIALOG
);
dialog->Show(TRUE);
if ( m_dlgReplace )
{
delete m_dlgReplace;
m_dlgReplace = NULL;
}
else
{
m_dlgReplace = new wxFindReplaceDialog
(
this,
&m_findData,
"Find and replace dialog",
wxFR_REPLACEDIALOG
);
m_dlgReplace->Show(TRUE);
}
}
void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
{
wxFindReplaceDialog *dialog = new wxFindReplaceDialog
(
this,
&m_findData,
"Find dialog",
// just for testing
wxFR_NOWHOLEWORD
);
dialog->Show(TRUE);
if ( m_dlgFind )
{
delete m_dlgFind;
m_dlgFind = NULL;
}
else
{
m_dlgFind = new wxFindReplaceDialog
(
this,
&m_findData,
"Find dialog",
// just for testing
wxFR_NOWHOLEWORD
);
m_dlgFind->Show(TRUE);
}
}
static wxString DecodeFindDialogEventFlags(int flags)
@@ -714,9 +735,29 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
}
else if ( type == wxEVT_COMMAND_FIND_CLOSE )
{
wxLogMessage(wxT("Find dialog is being closed."));
wxFindReplaceDialog *dlg = event.GetDialog();
event.GetDialog()->Destroy();
const wxChar *txt;
if ( dlg == m_dlgFind )
{
txt = _T("Find");
m_dlgFind = NULL;
}
else if ( dlg == m_dlgReplace )
{
txt = _T("Replace");
m_dlgReplace = NULL;
}
else
{
txt = _T("Unknown");
wxFAIL_MSG( _T("unexecpted event") );
}
wxLogMessage(wxT("%s dialog is being closed."), txt),
dlg->Destroy();
}
else
{