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 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>
29 #include <view/view.h>
30 
32 
33 
35  wxWindow* aWindow )
36  : PANEL_SYM_COLOR_SETTINGS_BASE( aWindow ), m_frame( aFrame )
37 {
38 }
39 
40 
42 {
44 
46 
48 
49  int width = 0;
50  int height = 0;
51  int minwidth = width;
52 
53  m_themeSelection->Clear();
54 
56  {
57  int pos = m_themeSelection->Append( settings->GetName(), static_cast<void*>( settings ) );
58 
59  if( settings == current )
60  m_themeSelection->SetSelection( pos );
61 
62  m_themeSelection->GetTextExtent( settings->GetName(), &width, &height );
63  minwidth = std::max( minwidth, width );
64  }
65 
66  m_themeSelection->SetMinSize( wxSize( minwidth + 50, -1 ) );
67 
68  m_txtTheme->Enable( !m_useEeschemaTheme->GetValue() );
69  m_themeSelection->Enable( !m_useEeschemaTheme->GetValue() );
70 
71  Fit();
72 
73  return true;
74 }
75 
76 
78 {
80 
81  auto selected = static_cast<COLOR_SETTINGS*>(
82  m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) );
83 
85 
87 
88  if( !cfg->m_UseEeschemaColorSettings )
89  cfg->m_ColorTheme = selected->GetFilename();
90 
92  {
94  selected = mgr->GetColorSettings( eecfg->m_ColorTheme );
95  }
96 
97  auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings();
98  settings->LoadColors( selected );
99 
100  return true;
101 }
102 
103 
105 {
106  bool useEeschema = m_useEeschemaTheme->GetValue();
107 
108  m_txtTheme->Enable( !useEeschema );
109  m_themeSelection->Enable( !useEeschema );
110 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
SETTINGS_MANAGER * GetSettingsManager() const
std::vector< COLOR_SETTINGS * > GetColorSettingsList()
SYMBOL_EDITOR_SETTINGS * GetSettings() const
void OnUseEeschemaThemeChanged(wxCommandEvent &event) override
Class PANEL_SYM_COLOR_SETTINGS_BASE.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
AppSettings * 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.