Added find dialog to report viewer.

Closes #175.
This commit is contained in:
WrinklyNinja
2014-06-23 09:47:18 +01:00
parent bd1a5b9071
commit c9b69e9ebe
2 changed files with 35 additions and 3 deletions
+29 -3
View File
@@ -25,12 +25,11 @@
#include "viewer.h"
#include "../backend/helpers.h"
#include <wx/webview.h>
Viewer::Viewer(wxWindow *parent, const wxString& title, const wxString& url) : wxFrame(parent, wxID_ANY, title) {
wxWebView * web = wxWebView::New(this, wxID_ANY, url);
web = wxWebView::New(this, wxID_ANY, url);
web->Bind(wxEVT_WEBVIEW_NAVIGATING, &Viewer::OnNavigationStart, this);
web->Bind(wxEVT_CHAR_HOOK, &Viewer::OnKeyUp, this);
wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
@@ -45,3 +44,30 @@ void Viewer::OnNavigationStart(wxWebViewEvent& event) {
wxLaunchDefaultBrowser(event.GetURL());
event.Veto();
}
void Viewer::OnKeyUp(wxKeyEvent &event) {
if (event.GetUnicodeKey() != 0x46 || event.GetModifiers() != wxMOD_CONTROL) // "F"
return;
wxFindReplaceDialog * findDia = new wxFindReplaceDialog(this, &data, translate("Find in Page"));
findDia->Bind(wxEVT_FIND, &Viewer::OnFind, this);
findDia->Bind(wxEVT_FIND_NEXT, &Viewer::OnFind, this);
findDia->Show();
}
void Viewer::OnFind(wxFindDialogEvent &event) {
int dialogFlags = event.GetFlags();
int findFlags = wxWEBVIEW_FIND_WRAP | wxWEBVIEW_FIND_HIGHLIGHT_RESULT;
if ((dialogFlags & wxFR_DOWN) == 0)
findFlags = findFlags | wxWEBVIEW_FIND_BACKWARDS;
if (dialogFlags & wxFR_WHOLEWORD)
findFlags = findFlags | wxWEBVIEW_FIND_ENTIRE_WORD;
if (dialogFlags & wxFR_MATCHCASE)
findFlags = findFlags | wxWEBVIEW_FIND_MATCH_CASE;
web->Find(event.GetFindString(), findFlags);
}
+6
View File
@@ -28,12 +28,18 @@
#include "ids.h"
#include <wx/webview.h>
#include <wx/fdrepdlg.h>
class Viewer : public wxFrame {
public:
Viewer(wxWindow *parent, const wxString& title, const wxString& url);
void OnNavigationStart(wxWebViewEvent& event);
void OnKeyUp(wxKeyEvent &event);
void OnFind(wxFindDialogEvent &event);
wxWebView * web;
wxFindReplaceData data;
};
#endif