Added a close button to close find/replace panel when ESC key doesn't work

This commit is contained in:
Zane U. Ji 2014-04-13 23:30:09 +08:00
parent 57dacdc0a8
commit fe0102dddd
2 changed files with 23 additions and 1 deletions

View File

@ -26,7 +26,11 @@ BEGIN_EVENT_TABLE ( FindReplacePanel, wxPanel )
EVT_BUTTON ( ID_FINDREPLACE_FIND_NEXT, FindReplacePanel::OnFindNext ) EVT_BUTTON ( ID_FINDREPLACE_FIND_NEXT, FindReplacePanel::OnFindNext )
EVT_BUTTON ( ID_FINDREPLACE_REPLACE, FindReplacePanel::OnReplace ) EVT_BUTTON ( ID_FINDREPLACE_REPLACE, FindReplacePanel::OnReplace )
EVT_BUTTON ( ID_FINDREPLACE_REPLACE_ALL, FindReplacePanel::OnReplaceAll ) 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 ) EVT_CHAR_HOOK ( FindReplacePanel::OnCharHook )
#endif
EVT_IDLE ( FindReplacePanel::OnIdle ) EVT_IDLE ( FindReplacePanel::OnIdle )
END_EVENT_TABLE() END_EVENT_TABLE()
@ -120,6 +124,17 @@ FindReplacePanel::FindReplacePanel (
sizer->Add ( matchCaseBox, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset ); sizer->Add ( matchCaseBox, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
sizer->Add ( regexBox, 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 ); this->SetSizer ( sizer );
sizer->SetSizeHints ( this ); sizer->SetSizeHints ( this );
sizer->Layout(); sizer->Layout();
@ -304,3 +319,8 @@ void FindReplacePanel::OnCharHook ( wxKeyEvent& event )
else else
event.Skip(); event.Skip();
} }
void FindReplacePanel::OnClose ( wxCommandEvent & e )
{
( ( MyFrame* ) GetParent() )->closeFindReplacePane();
}

View File

@ -32,7 +32,8 @@ enum
ID_FINDREPLACE_REPLACE, ID_FINDREPLACE_REPLACE,
ID_FINDREPLACE_REPLACE_ALL, ID_FINDREPLACE_REPLACE_ALL,
ID_FINDREPLACE_MATCH_CASE, ID_FINDREPLACE_MATCH_CASE,
ID_FINDREPLACE_REGEX ID_FINDREPLACE_REGEX,
ID_FINDREPLACE_CLOSE
}; };
class FindReplacePanel : public wxPanel class FindReplacePanel : public wxPanel
@ -48,6 +49,7 @@ class FindReplacePanel : public wxPanel
void OnFindNext ( wxCommandEvent& event ); void OnFindNext ( wxCommandEvent& event );
void OnReplace ( wxCommandEvent& event ); void OnReplace ( wxCommandEvent& event );
void OnReplaceAll ( wxCommandEvent& event ); void OnReplaceAll ( wxCommandEvent& event );
void OnClose ( wxCommandEvent& event );
void focusOnFind(); void focusOnFind();
bool getIncrementalFind(); bool getIncrementalFind();
bool getRegex(); bool getRegex();