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 <sch_draw_panel.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( EDA_UNITS_T aUnits )
72  {
73  wxString htmlpage;
74  wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
75  wxColour fgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
76  // for each marker, build a link like:
77  // <A HREF="marker_index">text to click</A>
78  // The "text to click" is the error name (first line of the full error text).
79  wxString marker_text;
80  wxString href;
81 
82  for( unsigned ii = 0; ii < m_MarkerListReferences.size(); ii++ )
83  {
84  href.Printf( wxT( "href='%d'" ), ii );
85  marker_text = m_MarkerListReferences[ii]->GetReporter().ShowHtml( aUnits );
86  marker_text.Replace( wxT( "href=''"), href );
87  htmlpage += marker_text;
88  }
89 
90  SetPage( wxString::Format( wxT( "<html><body bgcolor='%s' text='%s'>%s</body></html>" ),
91  bgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
92  fgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
93  htmlpage ) );
94  }
95 
100  const SCH_MARKER* GetItem( unsigned aIndex )
101  {
102  if( m_MarkerListReferences.size() > aIndex )
103  {
104  return m_MarkerListReferences[ aIndex ];
105  }
106 
107  return NULL;
108  }
109 
110 
116  void ClearList()
117  {
118  m_MarkerListReferences.clear();
119  SetPage( wxEmptyString );
120  }
121 };
122 
123 #endif
124 
125 // DIALOG_ERC_LISTBOX_H
void DisplayList(EDA_UNITS_T aUnits)
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.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class ERC_HTML_LISTFRAME is used to display a DRC_ITEM_LIST.
EDA_UNITS_T
Definition: common.h:159
std::vector< SCH_MARKER * > m_MarkerListReferences