KiCad PCB EDA Suite
wx_html_report_panel.cpp File Reference
#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 111 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().

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

Referenced by makeBadge().