From fe0102dddd5f24d035663da52460e1b5ed913c07 Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Sun, 13 Apr 2014 23:30:09 +0800 Subject: [PATCH] Added a close button to close find/replace panel when ESC key doesn't work --- src/findreplacepanel.cpp | 20 ++++++++++++++++++++ src/findreplacepanel.h | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/findreplacepanel.cpp b/src/findreplacepanel.cpp index 420baeb..4c814c0 100644 --- a/src/findreplacepanel.cpp +++ b/src/findreplacepanel.cpp @@ -26,7 +26,11 @@ BEGIN_EVENT_TABLE ( FindReplacePanel, wxPanel ) EVT_BUTTON ( ID_FINDREPLACE_FIND_NEXT, FindReplacePanel::OnFindNext ) EVT_BUTTON ( ID_FINDREPLACE_REPLACE, FindReplacePanel::OnReplace ) EVT_BUTTON ( ID_FINDREPLACE_REPLACE_ALL, FindReplacePanel::OnReplaceAll ) +#if !wxCHECK_VERSION(2,9,0) + EVT_BUTTON ( ID_FINDREPLACE_CLOSE, FindReplacePanel::OnClose ) +#else EVT_CHAR_HOOK ( FindReplacePanel::OnCharHook ) +#endif EVT_IDLE ( FindReplacePanel::OnIdle ) END_EVENT_TABLE() @@ -120,6 +124,17 @@ FindReplacePanel::FindReplacePanel ( sizer->Add ( matchCaseBox, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset ); sizer->Add ( regexBox, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset ); +#if !wxCHECK_VERSION(2,9,0) + wxButton *closeButton = new wxButton ( + this, + ID_FINDREPLACE_CLOSE, + _ ( "&Close" ), + wxDefaultPosition, + wxDefaultSize, + wxBU_EXACTFIT | wxNO_BORDER ); + sizer->Add ( closeButton, 0, wxLEFT | wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset ); +#endif + this->SetSizer ( sizer ); sizer->SetSizeHints ( this ); sizer->Layout(); @@ -304,3 +319,8 @@ void FindReplacePanel::OnCharHook ( wxKeyEvent& event ) else event.Skip(); } + +void FindReplacePanel::OnClose ( wxCommandEvent & e ) +{ + ( ( MyFrame* ) GetParent() )->closeFindReplacePane(); +} diff --git a/src/findreplacepanel.h b/src/findreplacepanel.h index 0b07321..c652151 100644 --- a/src/findreplacepanel.h +++ b/src/findreplacepanel.h @@ -32,7 +32,8 @@ enum ID_FINDREPLACE_REPLACE, ID_FINDREPLACE_REPLACE_ALL, ID_FINDREPLACE_MATCH_CASE, - ID_FINDREPLACE_REGEX + ID_FINDREPLACE_REGEX, + ID_FINDREPLACE_CLOSE }; class FindReplacePanel : public wxPanel @@ -48,6 +49,7 @@ class FindReplacePanel : public wxPanel void OnFindNext ( wxCommandEvent& event ); void OnReplace ( wxCommandEvent& event ); void OnReplaceAll ( wxCommandEvent& event ); + void OnClose ( wxCommandEvent& event ); void focusOnFind(); bool getIncrementalFind(); bool getRegex();