KiCad PCB EDA Suite
colorcode.cpp
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) 2011 jean-pierre.charras
5  * Copyright (C) 2011-2021 Kicad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <wx/app.h>
22 #include "bitmaps/color_code_value_and_name.xpm"
23 #include "bitmaps/color_code_value.xpm"
24 #include "bitmaps/color_code_multiplier.xpm"
25 #include "bitmaps/color_code_tolerance.xpm"
26 #include "pcb_calculator_frame.h"
27 
28 
30 {
31  m_ccValueNamesBitmap = new wxBitmap( color_code_value_and_name_xpm );
32  m_ccValuesBitmap = new wxBitmap( color_code_value_xpm );
33  m_ccMultipliersBitmap = new wxBitmap( color_code_multiplier_xpm );
34  m_ccTolerancesBitmap = new wxBitmap( color_code_tolerance_xpm );
35 }
36 
37 
38 void PCB_CALCULATOR_FRAME::OnToleranceSelection( wxCommandEvent& event )
39 {
40  ToleranceSelection( event.GetSelection() );
41 }
42 
43 
45 {
46  /* For tolerance = 5 or 10 %, there are 3 bands for the value
47  * but for tolerance < 5 %, there are 4 bands
48  */
49  bool show4thBand = aSelection != 0;
50 
51  m_Band4bitmap->Show(show4thBand);
52  m_Band4Label->Show(show4thBand);
53 
54  // m_Band4Label visibility has changed:
55  // The new size must be taken in account
56  m_panelColorCode->GetSizer()->Layout();
57 
58  // All this shouldn't be necessary but if you want the bitmaps to show up on OSX it is.
59  m_Band1bitmap->SetBitmap( *m_ccValueNamesBitmap );
60  m_Band2bitmap->SetBitmap( *m_ccValuesBitmap );
61  m_Band3bitmap->SetBitmap( *m_ccValuesBitmap );
62  m_Band4bitmap->SetBitmap( *m_ccValuesBitmap );
65 
66  m_panelColorCode->Refresh();
67 }
void ToleranceSelection(int aSelection)
Definition: colorcode.cpp:44
void OnToleranceSelection(wxCommandEvent &event) override
Definition: colorcode.cpp:38