KiCad PCB EDA Suite
Loading...
Searching...
No Matches
webview_panel.h
Go to the documentation of this file.
1#ifndef WEBVIEW_PANEL_H
2#define WEBVIEW_PANEL_H
3
4#include <wx/panel.h>
5#include <wx/webview.h>
6#include <functional>
7#include <map>
8
9class WEBVIEW_PANEL : public wxPanel
10{
11public:
12 using MESSAGE_HANDLER = std::function<void( const wxString& )>;
13
14 explicit WEBVIEW_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
15 const wxSize& size = wxDefaultSize, const int style = 0 );
16 ~WEBVIEW_PANEL() override;
17
18 wxWebView* GetWebView() const { return m_browser; }
19
20 void LoadURL( const wxString& url );
21 void SetPage( const wxString& htmlContent );
22
23 bool AddMessageHandler( const wxString& name, MESSAGE_HANDLER handler );
25
26protected:
27 void OnNavigationRequest( wxWebViewEvent& evt );
28 void OnWebViewLoaded( wxWebViewEvent& evt );
29 void OnNewWindow( wxWebViewEvent& evt );
30 void OnScriptMessage( wxWebViewEvent& evt );
31 void OnScriptResult( wxWebViewEvent& evt );
32 void OnError( wxWebViewEvent& evt );
33
34private:
36 wxWebView* m_browser;
37 std::map<wxString, MESSAGE_HANDLER> m_msgHandlers;
38};
39
40#endif // WEBVIEW_PANEL_H
const char * name
Definition: DXF_plotter.cpp:62
void OnScriptMessage(wxWebViewEvent &evt)
void OnNewWindow(wxWebViewEvent &evt)
std::map< wxString, MESSAGE_HANDLER > m_msgHandlers
Definition: webview_panel.h:37
void SetPage(const wxString &htmlContent)
void OnWebViewLoaded(wxWebViewEvent &evt)
void OnNavigationRequest(wxWebViewEvent &evt)
void ClearMessageHandlers()
bool AddMessageHandler(const wxString &name, MESSAGE_HANDLER handler)
std::function< void(const wxString &)> MESSAGE_HANDLER
Definition: webview_panel.h:12
void OnScriptResult(wxWebViewEvent &evt)
wxWebView * GetWebView() const
Definition: webview_panel.h:18
void OnError(wxWebViewEvent &evt)
~WEBVIEW_PANEL() override
void LoadURL(const wxString &url)
wxWebView * m_browser
Definition: webview_panel.h:36