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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 */
20
21#ifndef WX_DATA_VIEW_HYPERLINK_RENDERER_H
22#define WX_DATA_VIEW_HYPERLINK_RENDERER_H
23
24#include <vector>
25#include <wx/dataview.h>
26#include <wx/dc.h>
27#include <wx/string.h>
28#include <kicommon.h>
29
30
35class KICOMMON_API HYPERLINK_DV_RENDERER : public wxDataViewCustomRenderer
36{
37public:
39
40 bool SetValue( const wxVariant& aValue ) override;
41 bool GetValue( wxVariant& aValue ) const override;
42 wxSize GetSize() const override;
43 bool Render( wxRect aCell, wxDC* aDC, int aState ) override;
44
46 bool HitTestRunsForCell( const wxString& aValue, const wxRect& aCell, const wxPoint& aPoint,
47 wxString* aHref ) const;
48
49 struct RUN
50 {
51 wxString text;
52 wxString href; // empty for plain text
53 wxRect bounds;
54 };
55
57 static void ParseRuns( const wxString& aValue, std::vector<RUN>& aRuns );
58
60 static bool IsSafeUrl( const wxString& aHref );
61
63 static wxString StripMarkup( const wxString& aValue );
64
65private:
66 wxString m_value;
67 std::vector<RUN> m_runs;
69};
70
71#endif // WX_DATA_VIEW_HYPERLINK_RENDERER_H
#define KICOMMON_API
Definition kicommon.h:27