KiCad PCB EDA Suite
number_badge.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KICAD, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 Kicad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef NUMBER_BADGE_H_
25 #define NUMBER_BADGE_H_
26 
27 #include <widgets/ui_common.h>
28 #include <wx/wx.h>
29 
36 class NUMBER_BADGE : public wxPanel
37 {
38 public:
42  NUMBER_BADGE( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos,
43  const wxSize& aSize, int aStyles );
44 
58  void UpdateNumber( int aNumber, SEVERITY aSeverity );
59 
66  void SetMaximumNumber( int aMax );
67 
73  void SetTextSize( int aSize );
74 
75 protected:
79  void computeSize();
80 
84  void onPaint( wxPaintEvent& aEvt );
85 
86  int m_textSize; // The text size to use
87  int m_maxNumber; // The maximum number allowed to be shown on the badge
88 
89  int m_currentNumber; // The current number to display
90  bool m_showBadge; // If true, displays the actual badge otherwise it is invisible
91  wxColour m_badgeColour; // The color of the badge
92  wxColour m_textColour; // The color of the text on the badge
93 };
94 
95 #endif
void computeSize()
Helper function to compute the size of the badge.
SEVERITY
Definition: ui_common.h:83
void onPaint(wxPaintEvent &aEvt)
Handler that actually paints the badge and the text.
void UpdateNumber(int aNumber, SEVERITY aSeverity)
Update the number displayed on the badge.
int m_currentNumber
Definition: number_badge.h:89
A simple UI element that puts a number on top of a colored rounded rectangle with a fill color that s...
Definition: number_badge.h:36
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.
Functions to provide common constants and other functions to assist in making a consistent UI.
void SetTextSize(int aSize)
Set the text size to use on the badge.
wxColour m_textColour
Definition: number_badge.h:92
wxColour m_badgeColour
Definition: number_badge.h:91
bool m_showBadge
Definition: number_badge.h:90
void SetMaximumNumber(int aMax)
Set the maximum number to be shown on the badge.