KiCad PCB EDA Suite
dialog_erc_listbox.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 (C) 1992-2015 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  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef DIALOG_ERC_LISTBOX_H
25 #define DIALOG_ERC_LISTBOX_H
26 
27 #include <vector>
28 
29 #include <fctsys.h>
30 #include <class_drawpanel.h>
31 #include <sch_marker.h>
32 #include <wx/html/htmlwin.h>
33 
38 class ERC_HTML_LISTFRAME : public wxHtmlWindow
39 {
40 private:
41  std::vector<SCH_MARKER*> m_MarkerListReferences; // The pointers to markers shown in list
42 
43 public:
44  ERC_HTML_LISTFRAME( wxWindow* parent, wxWindowID id = wxID_ANY,
45  const wxPoint& pos = wxDefaultPosition,
46  const wxSize& size = wxDefaultSize,
47  long style = 0 ) :
48  wxHtmlWindow( parent, id, pos, size, style | wxHW_NO_SELECTION )
49  {
50  }
51 
53  {
54  }
55 
56 
62  void AppendToList( SCH_MARKER* aMarker )
63  {
64  m_MarkerListReferences.push_back( aMarker );
65  }
66 
71  void DisplayList()
72  {
73  wxString htmlpage;
74 
75  // for each marker, build a link like:
76  // <A HREF="marker_index">text to click</A>
77  // The "text to click" is the error name (first line of the full error text).
78  wxString marker_text;
79 
80  for( unsigned ii = 0; ii < m_MarkerListReferences.size(); ii++ )
81  {
82  marker_text.Printf( wxT( "<A HREF=\"%d\">" ), ii );
83  marker_text << m_MarkerListReferences[ii]->GetReporter().ShowHtml();
84  marker_text.Replace( wxT( "<ul>" ), wxT( "</A><ul>" ), false );
85  htmlpage += marker_text;
86  }
87 
88  SetPage( htmlpage );
89  }
90 
95  const SCH_MARKER* GetItem( unsigned aIndex )
96  {
97  if( m_MarkerListReferences.size() > aIndex )
98  {
99  return m_MarkerListReferences[ aIndex ];
100  }
101 
102  return NULL;
103  }
104 
105 
111  void ClearList()
112  {
113  m_MarkerListReferences.clear();
114  SetPage( wxEmptyString );
115  }
116 };
117 
118 #endif
119 
120 // DIALOG_ERC_LISTBOX_H
void DisplayList()
Function DisplayList(); Build the Html marker list and show it.
ERC_HTML_LISTFRAME(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
void AppendToList(SCH_MARKER *aMarker)
Function AppendToList.
void ClearList()
Function ClearList deletes all items shown in the list.
const SCH_MARKER * GetItem(unsigned aIndex)
Function GetItem returns a requested DRC_ITEM* or NULL.
Class ERC_HTML_LISTFRAME is used to display a DRC_ITEM_LIST.
std::vector< SCH_MARKER * > m_MarkerListReferences