KiCad PCB EDA Suite
panel_sym_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
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 #include <eeschema_settings.h>
25 #include <symbol_edit_frame.h>
26 #include <symbol_editor_settings.h>
27 #include <sch_painter.h>
30 
31 
33  wxWindow* aWindow )
34  : PANEL_SYM_COLOR_SETTINGS_BASE( aWindow ), m_frame( aFrame )
35 {
36 }
37 
38 
40 {
42 
44  m_eeschemaRB->SetValue( true );
45  else
46  m_themeRB->SetValue( true );
47 
49 
50  int width = 0;
51  int height = 0;
52  int minwidth = width;
53 
54  m_themes->Clear();
55 
57  {
58  int pos = m_themes->Append( settings->GetName(), static_cast<void*>( settings ) );
59 
60  if( settings == current )
61  m_themes->SetSelection( pos );
62 
63  m_themes->GetTextExtent( settings->GetName(), &width, &height );
64  minwidth = std::max( minwidth, width );
65  }
66 
67  m_themes->SetMinSize( wxSize( minwidth + 50, -1 ) );
68 
69  Fit();
70 
71  return true;
72 }
73 
74 
76 {
78  int sel = m_themes->GetSelection();
79  COLOR_SETTINGS* colors = static_cast<COLOR_SETTINGS*>( m_themes->GetClientData( sel ) );
80 
82  cfg->m_UseEeschemaColorSettings = m_eeschemaRB->GetValue();
83 
84  if( cfg->m_UseEeschemaColorSettings )
85  {
87  colors = mgr->GetColorSettings( eecfg->m_ColorTheme );
88  }
89  else
90  {
91  cfg->m_ColorTheme = colors->GetFilename();
92  }
93 
95  settings->LoadColors( colors );
96 
97  return true;
98 }
99 
100 
101 void PANEL_SYM_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
102 {
103  m_themeRB->SetValue( true );
104 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void OnThemeChanged(wxCommandEvent &event) override
SETTINGS_MANAGER * GetSettingsManager() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
std::vector< COLOR_SETTINGS * > GetColorSettingsList()
SYMBOL_EDITOR_SETTINGS * GetSettings() const
wxString GetFilename() const
Definition: json_settings.h:72
Class PANEL_SYM_COLOR_SETTINGS_BASE.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Color settings are a bit different than most of the settings objects in that there can be more than o...
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
PANEL_SYM_COLOR_SETTINGS(SYMBOL_EDIT_FRAME *aFrame, wxWindow *aWindow)
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184
The symbol library editor main window.