KiCad PCB EDA Suite
Loading...
Searching...
No Matches
webview_panel.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef WEBVIEW_PANEL_H
21#define WEBVIEW_PANEL_H
22
23#include <wx/panel.h>
24#include <wx/webview.h>
25#include <functional>
26#include <map>
27
28class WEBVIEW_PANEL : public wxPanel
29{
30public:
31 using MESSAGE_HANDLER = std::function<void( const wxString& )>;
32
33 explicit WEBVIEW_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize, const int style = 0 );
35 ~WEBVIEW_PANEL() override;
36
37 wxWebView* GetWebView() const { return m_browser; }
38
39 void LoadURL( const wxString& url );
40 void SetPage( const wxString& htmlContent );
41
42 bool AddMessageHandler( const wxString& name, MESSAGE_HANDLER handler );
44
45protected:
46 void OnNavigationRequest( wxWebViewEvent& evt );
47 void OnWebViewLoaded( wxWebViewEvent& evt );
48 void OnNewWindow( wxWebViewEvent& evt );
49 void OnScriptMessage( wxWebViewEvent& evt );
50 void OnScriptResult( wxWebViewEvent& evt );
51 void OnError( wxWebViewEvent& evt );
52
53private:
55 wxWebView* m_browser;
56 std::map<wxString, MESSAGE_HANDLER> m_msgHandlers;
57};
58
59#endif // WEBVIEW_PANEL_H
const char * name
WEBVIEW_PANEL(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const int style=0)
void OnScriptMessage(wxWebViewEvent &evt)
void OnNewWindow(wxWebViewEvent &evt)
std::map< wxString, MESSAGE_HANDLER > m_msgHandlers
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
void OnScriptResult(wxWebViewEvent &evt)
wxWebView * GetWebView() const
void OnError(wxWebViewEvent &evt)
~WEBVIEW_PANEL() override
void LoadURL(const wxString &url)
wxWebView * m_browser