KiCad PCB EDA Suite
wx_html_report_panel.cpp File Reference
#include <algorithm>
#include "wx_html_report_panel.h"
#include <wildcards_and_files_ext.h>
#include <gal/color4d.h>
#include <wx/clipbrd.h>

Go to the source code of this file.

Macros

#define BADGE_SIZE   20
 
#define BADGE_FONT_SIZE   10
 

Functions

static wxBitmap makeBadge (REPORTER::SEVERITY aStyle, int aCount, wxWindow *aWindow)
 

Macro Definition Documentation

◆ BADGE_FONT_SIZE

#define BADGE_FONT_SIZE   10

Definition at line 134 of file wx_html_report_panel.cpp.

◆ BADGE_SIZE

#define BADGE_SIZE   20

Definition at line 133 of file wx_html_report_panel.cpp.

Function Documentation

◆ makeBadge()

static wxBitmap makeBadge ( REPORTER::SEVERITY  aStyle,
int  aCount,
wxWindow *  aWindow 
)
static

Definition at line 136 of file wx_html_report_panel.cpp.

137 {
138  wxSize size( BADGE_SIZE, BADGE_SIZE );
139  wxBitmap bitmap( size );
140  wxBrush brush;
141  wxMemoryDC badgeDC;
142  wxColour badgeColour;
143  wxColour textColour;
144  int fontSize = BADGE_FONT_SIZE;
145 
146  if( aCount > 99 )
147  fontSize--;
148 
149  badgeDC.SelectObject( bitmap );
150 
151  brush.SetStyle( wxBRUSHSTYLE_SOLID );
152  // We're one level deep in staticBoxes; each level is darkened by 210
153  brush.SetColour( aWindow->GetParent()->GetBackgroundColour().MakeDisabled( 210 ) );
154  badgeDC.SetBackground( brush );
155  badgeDC.Clear();
156 
157  if( aCount == 0 )
158  return bitmap;
159 
160  switch( aStyle )
161  {
162  case REPORTER::RPT_ERROR:
163  badgeColour = *wxRED;
164  textColour = *wxWHITE;
165  break;
167  badgeColour = wxColour( 235, 120, 80 ); // Orange
168  textColour = *wxWHITE;
169  break;
171  badgeColour = *wxGREEN;
172  textColour = *wxWHITE;
173  break;
174  case REPORTER::RPT_INFO:
175  default:
176  badgeColour = *wxLIGHT_GREY;
177  textColour = *wxBLACK;
178  break;
179  }
180 
181  brush.SetStyle( wxBRUSHSTYLE_SOLID );
182  brush.SetColour( badgeColour );
183  badgeDC.SetBrush( brush );
184  badgeDC.SetPen( wxPen( badgeColour, 0 ) );
185  badgeDC.DrawCircle( size.x / 2 - 1, size.y / 2, ( std::max( size.x, size.y ) / 2 ) - 1 );
186 
187  wxFont font( fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
188  badgeDC.SetFont( font );
189 
190  wxString text = wxString::Format( wxT( "%d" ), aCount );
191  wxSize textExtent = badgeDC.GetTextExtent( text );
192 
193  badgeDC.SetTextForeground( textColour );
194  badgeDC.DrawText( text, size.x / 2 - textExtent.x / 2 - 1, size.y / 2 - textExtent.y / 2 );
195 
196  return bitmap;
197 }
#define BADGE_SIZE
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
#define max(a, b)
Definition: auxiliary.h:86
#define BADGE_FONT_SIZE

References BADGE_FONT_SIZE, BADGE_SIZE, Format(), max, REPORTER::RPT_ACTION, REPORTER::RPT_ERROR, REPORTER::RPT_INFO, and REPORTER::RPT_WARNING.

Referenced by WX_HTML_REPORT_PANEL::updateBadges().