KiCad PCB EDA Suite
wx_html_report_panel.cpp File Reference

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

109 {
110  wxSize size( aWindow->ConvertDialogToPixels( BADGE_SIZE_DU ) );
111  wxBitmap bitmap( size );
112  wxBrush brush;
113  wxMemoryDC badgeDC;
114  wxColour badgeColour;
115  wxColour textColour;
116  int fontSize = BADGE_FONT_SIZE;
117 
118  if( aCount > 99 )
119  fontSize--;
120 
121  badgeDC.SelectObject( bitmap );
122 
123  brush.SetStyle( wxBRUSHSTYLE_SOLID );
124  // We're one level deep in staticBoxes; each level is darkened by 210
125  brush.SetColour( aWindow->GetParent()->GetBackgroundColour().MakeDisabled( 210 ) );
126  badgeDC.SetBackground( brush );
127  badgeDC.Clear();
128 
129  switch( aStyle )
130  {
131  case REPORTER::RPT_ERROR:
132  badgeColour = *wxRED;
133  textColour = *wxWHITE;
134  break;
136  badgeColour = *wxYELLOW;
137  textColour = *wxBLACK;
138  break;
140  badgeColour = *wxGREEN;
141  textColour = *wxWHITE;
142  break;
143  case REPORTER::RPT_INFO:
144  default:
145  badgeColour = *wxLIGHT_GREY;
146  textColour = *wxBLACK;
147  break;
148  }
149 
150  brush.SetStyle( wxBRUSHSTYLE_SOLID );
151  brush.SetColour( badgeColour );
152  badgeDC.SetBrush( brush );
153  badgeDC.SetPen( wxPen( badgeColour, 0 ) );
154  badgeDC.DrawCircle( size.x / 2 - 1, size.y / 2, ( std::max( size.x, size.y ) / 2 ) - 1 );
155 
156  wxFont font( BADGE_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
157  wxString text = wxString::Format( wxT( "%d" ), aCount );
158  wxSize textExtent = badgeDC.GetTextExtent( text );
159 
160  badgeDC.SetFont( font );
161  badgeDC.SetTextForeground( textColour );
162  badgeDC.DrawText( text, size.x / 2 - textExtent.x / 2, size.y / 2 - textExtent.y / 2 + 2 );
163 
164  return bitmap;
165 }
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 106 of file wx_html_report_panel.cpp.

Referenced by makeBadge().