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

#define BADGE_FONT_SIZE   10

Definition at line 135 of file wx_html_report_panel.cpp.

Referenced by makeBadge().

#define BADGE_SIZE   20

Definition at line 134 of file wx_html_report_panel.cpp.

Referenced by makeBadge().

Function Documentation

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

Definition at line 137 of file wx_html_report_panel.cpp.

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().

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