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.

Functions

static const wxSize BADGE_SIZE_DU (9, 9)
 
static wxBitmap makeBadge (REPORTER::SEVERITY aStyle, int aCount, wxWindow *aWindow)
 

Variables

static const int BADGE_FONT_SIZE = 9
 

Function Documentation

static const wxSize BADGE_SIZE_DU ( ,
 
)
static
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_DU(), 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( aWindow->ConvertDialogToPixels( BADGE_SIZE_DU ) );
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  switch( aStyle )
159  {
160  case REPORTER::RPT_ERROR:
161  badgeColour = *wxRED;
162  textColour = *wxWHITE;
163  break;
165  badgeColour = *wxYELLOW;
166  textColour = *wxBLACK;
167  break;
169  badgeColour = *wxGREEN;
170  textColour = *wxWHITE;
171  break;
172  case REPORTER::RPT_INFO:
173  default:
174  badgeColour = *wxLIGHT_GREY;
175  textColour = *wxBLACK;
176  break;
177  }
178 
179  brush.SetStyle( wxBRUSHSTYLE_SOLID );
180  brush.SetColour( badgeColour );
181  badgeDC.SetBrush( brush );
182  badgeDC.SetPen( wxPen( badgeColour, 0 ) );
183  badgeDC.DrawCircle( size.x / 2 - 1, size.y / 2, ( std::max( size.x, size.y ) / 2 ) - 1 );
184 
185  wxFont font( BADGE_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
186  wxString text = wxString::Format( wxT( "%d" ), aCount );
187  wxSize textExtent = badgeDC.GetTextExtent( text );
188 
189  badgeDC.SetFont( font );
190  badgeDC.SetTextForeground( textColour );
191  badgeDC.DrawText( text, size.x / 2 - textExtent.x / 2, size.y / 2 - textExtent.y / 2 + 2 );
192 
193  return bitmap;
194 }
static const int BADGE_FONT_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
static const wxSize BADGE_SIZE_DU(9, 9)

Variable Documentation

const int BADGE_FONT_SIZE = 9
static

Definition at line 135 of file wx_html_report_panel.cpp.

Referenced by makeBadge().