KiCad PCB EDA Suite
panel_pl_editor_color_settings.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) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <pgm_base.h>
22#include <pl_editor_settings.h>
24
25
28{
29}
30
31
33{
34 PL_EDITOR_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PL_EDITOR_SETTINGS>();
35
36 COLOR_SETTINGS* current = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
37
38 int width = 0;
39 int height = 0;
40 int minwidth = width;
41
42 m_themes->Clear();
43
44 for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
45 {
46 int pos = m_themes->Append( settings->GetName(), static_cast<void*>( settings ) );
47
48 if( settings == current )
49 m_themes->SetSelection( pos );
50
51 m_themes->GetTextExtent( settings->GetName(), &width, &height );
52 minwidth = std::max( minwidth, width );
53 }
54
55 m_themes->SetMinSize( wxSize( minwidth + 50, -1 ) );
56
57 Fit();
58
59 return true;
60}
61
62
64{
65 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
67 int sel = m_themes->GetSelection();
68 COLOR_SETTINGS* colors = static_cast<COLOR_SETTINGS*>( m_themes->GetClientData( sel ) );
69
70 cfg->m_ColorTheme = colors->GetFilename();
71
72 return true;
73}
74
75
77{
78 m_themes->SetStringSelection( _( "KiCad Default" ) );
79}
80
81
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:187
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxString GetFilename() const
Definition: json_settings.h:73
Class PANEL_PL_EDITOR_COLOR_SETTINGS_BASE.
void ResetPanel() override
Reset the contents of this panel.
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
#define _(s)
SETTINGS_MANAGER * GetSettingsManager()
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111