KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wx_data_view_hyperlink_renderer.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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef WX_DATA_VIEW_HYPERLINK_RENDERER_H
21#define WX_DATA_VIEW_HYPERLINK_RENDERER_H
22
23#include <vector>
24#include <wx/dataview.h>
25#include <wx/dc.h>
26#include <wx/string.h>
27#include <kicommon.h>
28
29
34class KICOMMON_API HYPERLINK_DV_RENDERER : public wxDataViewCustomRenderer
35{
36public:
38
39 bool SetValue( const wxVariant& aValue ) override;
40 bool GetValue( wxVariant& aValue ) const override;
41 wxSize GetSize() const override;
42 bool Render( wxRect aCell, wxDC* aDC, int aState ) override;
43
45 bool HitTestRunsForCell( const wxString& aValue, const wxRect& aCell, const wxPoint& aPoint,
46 wxString* aHref ) const;
47
48 struct RUN
49 {
50 wxString text;
51 wxString href; // empty for plain text
52 wxRect bounds;
53 };
54
56 static void ParseRuns( const wxString& aValue, std::vector<RUN>& aRuns );
57
59 static bool IsSafeUrl( const wxString& aHref );
60
62 static wxString StripMarkup( const wxString& aValue );
63
64private:
65 wxString m_value;
66 std::vector<RUN> m_runs;
68};
69
70#endif // WX_DATA_VIEW_HYPERLINK_RENDERER_H
#define KICOMMON_API
Definition kicommon.h:27