KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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
26PANEL_COLOR_CODE::PANEL_COLOR_CODE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
27 const wxSize& size, long style, const wxString& name ) :
28 PANEL_COLOR_CODE_BASE( parent, id, pos, size, style, name )
29{
31
32 // Needed on wxWidgets 3.0 to ensure sizers are correctly set
33 GetSizer()->SetSizeHints( this );
34}
35
36
38{
39}
40
41
43{
44 // Update the bitmaps
45 m_Band1bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value_and_name ) );
46 m_Band2bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value ) );
47 m_Band3bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value ) );
48 m_Band4bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value ) );
49 m_Band_mult_bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_multiplier ) );
50 m_Band_tol_bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_tolerance ) );
51
52 Refresh();
53}
54
55
57{
58 m_rbToleranceSelection->SetSelection( aCfg->m_ColorCodeTolerance );
60}
61
62
64{
65 aCfg->m_ColorCodeTolerance = m_rbToleranceSelection->GetSelection();
66}
67
68
69void PANEL_COLOR_CODE::OnToleranceSelection( wxCommandEvent& event )
70{
71 ToleranceSelection( event.GetSelection() );
72}
73
74
76{
77 /* For tolerance = 5 or 10 %, there are 3 bands for the value
78 * but for tolerance < 5 %, there are 4 bands
79 */
80 bool show4thBand = aSelection != 0;
81
82 m_Band4bitmap->Show(show4thBand);
83 m_staticTextBand4->Show(show4thBand);
84
85 // m_Band4Label visibility has changed:
86 // The new size must be taken in account
87 GetSizer()->Layout();
88
89 // All this shouldn't be necessary but if you want the bitmaps to show up on OSX it is.
90 m_Band1bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value_and_name ) );
91 m_Band2bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value ) );
92 m_Band3bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value ) );
93 m_Band4bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_value ) );
94 m_Band_mult_bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_multiplier ) );
95 m_Band_tol_bitmap->SetBitmap( KiBitmapBundle( BITMAPS::color_code_tolerance ) );
96
97 Refresh();
98}
const char * name
Definition: DXF_plotter.cpp:57
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
Class PANEL_COLOR_CODE_BASE.
wxStaticBitmap * m_Band_tol_bitmap
wxStaticText * m_staticTextBand4
wxStaticBitmap * m_Band2bitmap
wxStaticBitmap * m_Band4bitmap
wxStaticBitmap * m_Band_mult_bitmap
wxStaticBitmap * m_Band1bitmap
wxStaticBitmap * m_Band3bitmap
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 SaveSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Save the settings from the panel.
void ThemeChanged() override
Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appr...
void ToleranceSelection(int aSelection)
void LoadSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Load the settings into the panel.
void OnToleranceSelection(wxCommandEvent &event) override
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...