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/dcclient.h>
29 #include <wx/panel.h>
30 
31 
38 class NUMBER_BADGE : public wxPanel
39 {
40 public:
44  NUMBER_BADGE( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos,
45  const wxSize& aSize, int aStyles );
46 
60  void UpdateNumber( int aNumber, SEVERITY aSeverity );
61 
68  void SetMaximumNumber( int aMax );
69 
75  void SetTextSize( int aSize );
76 
77 protected:
81  void computeSize();
82 
86  void onPaint( wxPaintEvent& aEvt );
87 
88  int m_textSize; // The text size to use
89  int m_maxNumber; // The maximum number allowed to be shown on the badge
90 
91  int m_currentNumber; // The current number to display
92  bool m_showBadge; // If true, displays the actual badge otherwise it is invisible
93  wxColour m_badgeColour; // The color of the badge
94  wxColour m_textColour; // The color of the text on the badge
95 };
96 
97 #endif
void computeSize()
Helper function to compute the size of the badge.
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:91
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:38
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.
SEVERITY
wxColour m_textColour
Definition: number_badge.h:94
wxColour m_badgeColour
Definition: number_badge.h:93
bool m_showBadge
Definition: number_badge.h:92
void SetMaximumNumber(int aMax)
Set the maximum number to be shown on the badge.