KiCad PCB EDA Suite
panel_color_code.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) 1992-2011 jean-pierre.charras
5  * Copyright (C) 1992-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 <bitmaps.h>
24 
25 
26 PANEL_COLOR_CODE::PANEL_COLOR_CODE( wxWindow* parent, wxWindowID id,
27  const wxPoint& pos, const wxSize& size,
28  long style, const wxString& name ) :
29  PANEL_COLOR_CODE_BASE( parent, id, pos, size, style, name )
30 {
31  ToleranceSelection( m_rbToleranceSelection->GetSelection() );
32 
33  // Needed on wxWidgets 3.0 to ensure sizers are correctly set
34  GetSizer()->SetSizeHints( this );
35 }
36 
37 
39 {
40 }
41 
42 
44 {
45  // Update the bitmaps
52 
53  Refresh();
54 }
55 
56 
58 {
59  m_rbToleranceSelection->SetSelection( aCfg->m_ColorCodeTolerance );
60  ToleranceSelection( m_rbToleranceSelection->GetSelection() );
61 }
62 
63 
65 {
66  aCfg->m_ColorCodeTolerance = m_rbToleranceSelection->GetSelection();
67 }
68 
69 
70 void PANEL_COLOR_CODE::OnToleranceSelection( wxCommandEvent& event )
71 {
72  ToleranceSelection( event.GetSelection() );
73 }
74 
75 
77 {
78  /* For tolerance = 5 or 10 %, there are 3 bands for the value
79  * but for tolerance < 5 %, there are 4 bands
80  */
81  bool show4thBand = aSelection != 0;
82 
83  m_Band4bitmap->Show(show4thBand);
84  m_staticTextBand4->Show(show4thBand);
85 
86  // m_Band4Label visibility has changed:
87  // The new size must be taken in account
88  GetSizer()->Layout();
89 
90  // All this shouldn't be necessary but if you want the bitmaps to show up on OSX it is.
97 
98  Refresh();
99 }
void OnToleranceSelection(wxCommandEvent &event) override
void SaveSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Save the settings from the panel.
void ToleranceSelection(int aSelection)
wxStaticBitmap * m_Band4bitmap
wxStaticBitmap * m_Band1bitmap
PANEL_COLOR_CODE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
wxStaticBitmap * m_Band_tol_bitmap
void ThemeChanged() override
Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appr...
wxStaticBitmap * m_Band2bitmap
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
wxStaticBitmap * m_Band_mult_bitmap
wxStaticText * m_staticTextBand4
const char * name
Definition: DXF_plotter.cpp:56
Class PANEL_COLOR_CODE_BASE.
void LoadSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Load the settings into the panel.
wxStaticBitmap * m_Band3bitmap