-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathGenericFindReplaceDialog.cpp
More file actions
52 lines (46 loc) · 2.12 KB
/
GenericFindReplaceDialog.cpp
File metadata and controls
52 lines (46 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <wx/wx.h>
#include <wx/fdrepdlg.h>
#include <wx/generic/fdrepdlg.h>
namespace GenericFindReplaceDialogExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "GenericFindReplaceDialog example"} {
button->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
#if !defined(__WXMSW__)
findReplaceData.SetFlags(wxFR_WHOLEWORD | wxFR_MATCHCASE | wxFR_DOWN);
findReplaceData.SetFindString("Gammasoft");
findReplaceData.SetReplaceString("Gammasoft71");
findReplaceDialog = new wxGenericFindReplaceDialog {this, &findReplaceData, "Find and replace", wxFR_REPLACEDIALOG};
findReplaceDialog->Bind(wxEVT_FIND_CLOSE, [&](wxFindDialogEvent& event) {
findReplaceDialog->Destroy();
});
findReplaceDialog->Bind(wxEVT_FIND, [](wxFindDialogEvent& event) {
wxMessageOutputDebug().Printf("Find {%s}", event.GetFindString());
});
findReplaceDialog->Bind(wxEVT_FIND_NEXT, [](wxFindDialogEvent& event) {
wxMessageOutputDebug().Printf("Find next {%s}", event.GetFindString());
});
findReplaceDialog->Bind(wxEVT_FIND_REPLACE, [](wxFindDialogEvent& event) {
wxMessageOutputDebug().Printf("Find and Replace {%s} by {%s}", event.GetFindString(), event.GetReplaceString());
});
findReplaceDialog->Bind(wxEVT_FIND_REPLACE_ALL, [](wxFindDialogEvent& event) {
wxMessageOutputDebug().Printf("Find and Replace all {%s} by {%s}", event.GetFindString(), event.GetReplaceString());
});
findReplaceDialog->Show();
#else
auto messageDialog = wxMessageDialog {this, "Does not work on Windows!", "Error", wxOK};
messageDialog.ShowModal();
#endif
});
}
private:
wxPanel* panel = new wxPanel {this};
wxButton* button = new wxButton {panel, wxID_ANY, "Find...", {10, 10}};
wxFindReplaceData findReplaceData;
wxGenericFindReplaceDialog* findReplaceDialog;
};
class Application : public wxApp {
auto OnInit() -> bool override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(GenericFindReplaceDialogExample::Application);