KiCad PCB EDA Suite
Loading...
Searching...
No Matches
NUMBER_BADGE Class Reference

A simple UI element that puts a number on top of a colored rounded rectangle with a fill color that shows the severity of the reports the number is counting (e.g. More...

#include <number_badge.h>

Inheritance diagram for NUMBER_BADGE:

Public Member Functions

 NUMBER_BADGE (wxWindow *aParent, wxWindowID aId, const wxPoint &aPos, const wxSize &aSize, int aStyles)
 Create a number badge with 10pt font and a maximum number of 1000.
 
void UpdateNumber (int aNumber, SEVERITY aSeverity)
 Update the number displayed on the badge.
 
void SetMaximumNumber (int aMax)
 Set the maximum number to be shown on the badge.
 
void SetTextSize (int aSize)
 Set the text size to use on the badge.
 

Protected Member Functions

void computeSize ()
 Helper function to compute the size of the badge.
 
void onPaint (wxPaintEvent &aEvt)
 Handler that actually paints the badge and the text.
 

Protected Attributes

int m_textSize
 
int m_maxNumber
 
int m_currentNumber
 
bool m_showBadge
 
wxColour m_badgeColour
 
wxColour m_textColour
 

Detailed Description

A simple UI element that puts a number on top of a colored rounded rectangle with a fill color that shows the severity of the reports the number is counting (e.g.

green, yellow, red). This badge will also automatically truncate the displayed number to the set maximum and display "+" at the end to represent it is truncated.

Definition at line 39 of file number_badge.h.

Constructor & Destructor Documentation

◆ NUMBER_BADGE()

NUMBER_BADGE::NUMBER_BADGE ( wxWindow *  aParent,
wxWindowID  aId,
const wxPoint &  aPos,
const wxSize &  aSize,
int  aStyles 
)

Create a number badge with 10pt font and a maximum number of 1000.

Definition at line 30 of file number_badge.cpp.

References computeSize(), and onPaint().

Member Function Documentation

◆ computeSize()

void NUMBER_BADGE::computeSize ( )
protected

Helper function to compute the size of the badge.

Definition at line 125 of file number_badge.cpp.

References BADGE_FONTWEIGHT, m_currentNumber, m_maxNumber, m_textSize, PLATFORM_FUDGE_X, and PLATFORM_FUDGE_Y.

Referenced by NUMBER_BADGE(), SetTextSize(), and UpdateNumber().

◆ onPaint()

void NUMBER_BADGE::onPaint ( wxPaintEvent &  aEvt)
protected

Handler that actually paints the badge and the text.

Definition at line 151 of file number_badge.cpp.

References BADGE_FONTWEIGHT, m_badgeColour, m_currentNumber, m_maxNumber, m_showBadge, m_textColour, m_textSize, and text.

Referenced by NUMBER_BADGE().

◆ SetMaximumNumber()

void NUMBER_BADGE::SetMaximumNumber ( int  aMax)

Set the maximum number to be shown on the badge.

Any numbers greater than this will be displayed as the maximum number followed by "+".

Parameters
aMaxis the maximum number

Definition at line 100 of file number_badge.cpp.

References m_maxNumber.

Referenced by DIALOG_ERC::DIALOG_ERC(), DIALOG_DRC::updateDisplayedCounts(), and DIALOG_FOOTPRINT_CHECKER::updateDisplayedCounts().

◆ SetTextSize()

void NUMBER_BADGE::SetTextSize ( int  aSize)

Set the text size to use on the badge.

Parameters
aSizeis the text size (in pt) to use on the badge

Definition at line 106 of file number_badge.cpp.

References computeSize(), and m_textSize.

◆ UpdateNumber()

void NUMBER_BADGE::UpdateNumber ( int  aNumber,
SEVERITY  aSeverity 
)

Update the number displayed on the badge.

Severity to badge color mapping:

  • RPT_SEVERITY_ERROR = red badge
  • RPT_SEVERITY_WARNING = yellow badge
  • RPT_SEVERITY_ACTION = green badge
  • RPT_SEVERITY_EXCLUSION = light grey badge
  • RPT_SEVERITY_INFO = light grey badge
Parameters
aNumberis the new number to display.
aSeverityis the new severity of the badge.

Definition at line 43 of file number_badge.cpp.

References computeSize(), GREEN, KIPLATFORM::UI::IsDarkTheme(), m_badgeColour, m_currentNumber, m_showBadge, m_textColour, Refresh(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, RPT_SEVERITY_EXCLUSION, RPT_SEVERITY_INFO, RPT_SEVERITY_WARNING, and KIGFX::COLOR4D::ToColour().

Referenced by WX_HTML_REPORT_PANEL::updateBadges(), DIALOG_ERC::updateDisplayedCounts(), DIALOG_DRC::updateDisplayedCounts(), and DIALOG_FOOTPRINT_CHECKER::updateDisplayedCounts().

Member Data Documentation

◆ m_badgeColour

wxColour NUMBER_BADGE::m_badgeColour
protected

Definition at line 94 of file number_badge.h.

Referenced by onPaint(), and UpdateNumber().

◆ m_currentNumber

int NUMBER_BADGE::m_currentNumber
protected

Definition at line 92 of file number_badge.h.

Referenced by computeSize(), onPaint(), and UpdateNumber().

◆ m_maxNumber

int NUMBER_BADGE::m_maxNumber
protected

Definition at line 90 of file number_badge.h.

Referenced by computeSize(), onPaint(), and SetMaximumNumber().

◆ m_showBadge

bool NUMBER_BADGE::m_showBadge
protected

Definition at line 93 of file number_badge.h.

Referenced by onPaint(), and UpdateNumber().

◆ m_textColour

wxColour NUMBER_BADGE::m_textColour
protected

Definition at line 95 of file number_badge.h.

Referenced by onPaint(), and UpdateNumber().

◆ m_textSize

int NUMBER_BADGE::m_textSize
protected

Definition at line 89 of file number_badge.h.

Referenced by computeSize(), onPaint(), and SetTextSize().


The documentation for this class was generated from the following files: