KiCad PCB EDA Suite
PANEL_LIBEDIT_COLOR_SETTINGS Class Reference

#include <panel_libedit_color_settings.h>

Inheritance diagram for PANEL_LIBEDIT_COLOR_SETTINGS:
PANEL_LIBEDIT_COLOR_SETTINGS_BASE

Public Member Functions

 PANEL_LIBEDIT_COLOR_SETTINGS (LIB_EDIT_FRAME *aFrame, wxWindow *aWindow)
 

Protected Member Functions

void OnUseEeschemaThemeChanged (wxCommandEvent &event) override
 

Protected Attributes

wxCheckBox * m_useEeschemaTheme
 
wxStaticText * m_txtTheme
 
wxChoice * m_themeSelection
 

Private Member Functions

bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 

Private Attributes

LIB_EDIT_FRAMEm_frame
 

Detailed Description

Definition at line 32 of file panel_libedit_color_settings.h.

Constructor & Destructor Documentation

◆ PANEL_LIBEDIT_COLOR_SETTINGS()

PANEL_LIBEDIT_COLOR_SETTINGS::PANEL_LIBEDIT_COLOR_SETTINGS ( LIB_EDIT_FRAME aFrame,
wxWindow *  aWindow 
)

Definition at line 36 of file panel_libedit_color_settings.cpp.

38  : PANEL_LIBEDIT_COLOR_SETTINGS_BASE( aWindow ), m_frame( aFrame )
39 {
40 }
PANEL_LIBEDIT_COLOR_SETTINGS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)

Member Function Documentation

◆ OnUseEeschemaThemeChanged()

void PANEL_LIBEDIT_COLOR_SETTINGS::OnUseEeschemaThemeChanged ( wxCommandEvent &  event)
overrideprotectedvirtual

◆ TransferDataFromWindow()

bool PANEL_LIBEDIT_COLOR_SETTINGS::TransferDataFromWindow ( )
overrideprivate

Definition at line 79 of file panel_libedit_color_settings.cpp.

80 {
81  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
82 
83  auto selected = static_cast<COLOR_SETTINGS*>(
84  m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) );
85 
87 
89 
90  if( !cfg->m_UseEeschemaColorSettings )
91  cfg->m_ColorTheme = selected->GetFilename();
92 
94  {
96  selected = mgr.GetColorSettings( eecfg->m_ColorTheme );
97  }
98 
99  auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings();
100  settings->LoadColors( selected );
101 
102  return true;
103 }
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
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
Function GetAdapter Returns pointer to current settings that are going to be used when drawing items.
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:156

References SETTINGS_MANAGER::GetAppSettings(), SCH_BASE_FRAME::GetCanvas(), SETTINGS_MANAGER::GetColorSettings(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), SCH_DRAW_PANEL::GetView(), KIGFX::RENDER_SETTINGS::LoadColors(), APP_SETTINGS_BASE::m_ColorTheme, m_frame, PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_themeSelection, LIBEDIT_SETTINGS::m_UseEeschemaColorSettings, PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_useEeschemaTheme, and Pgm().

◆ TransferDataToWindow()

bool PANEL_LIBEDIT_COLOR_SETTINGS::TransferDataToWindow ( )
overrideprivate

Definition at line 43 of file panel_libedit_color_settings.cpp.

44 {
45  auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
46 
47  m_useEeschemaTheme->SetValue( cfg->m_UseEeschemaColorSettings );
48 
49  COLOR_SETTINGS* current = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
50 
51  int width = 0;
52  int height = 0;
53  int minwidth = width;
54 
55  m_themeSelection->Clear();
56 
57  for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
58  {
59  int pos = m_themeSelection->Append( settings->GetName(), static_cast<void*>( settings ) );
60 
61  if( settings == current )
62  m_themeSelection->SetSelection( pos );
63 
64  m_themeSelection->GetTextExtent( settings->GetName(), &width, &height );
65  minwidth = std::max( minwidth, width );
66  }
67 
68  m_themeSelection->SetMinSize( wxSize( minwidth + 50, -1 ) );
69 
70  m_txtTheme->Enable( !m_useEeschemaTheme->GetValue() );
71  m_themeSelection->Enable( !m_useEeschemaTheme->GetValue() );
72 
73  Fit();
74 
75  return true;
76 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
SETTINGS_MANAGER * GetSettingsManager()
Color settings are a bit different than most of the settings objects in that there can be more than o...

References GetSettingsManager(), PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_themeSelection, PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_txtTheme, PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_useEeschemaTheme, and Pgm().

Member Data Documentation

◆ m_frame

LIB_EDIT_FRAME* PANEL_LIBEDIT_COLOR_SETTINGS::m_frame
private

Definition at line 34 of file panel_libedit_color_settings.h.

Referenced by TransferDataFromWindow().

◆ m_themeSelection

wxChoice* PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_themeSelection
protectedinherited

◆ m_txtTheme

wxStaticText* PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_txtTheme
protectedinherited

◆ m_useEeschemaTheme

wxCheckBox* PANEL_LIBEDIT_COLOR_SETTINGS_BASE::m_useEeschemaTheme
protectedinherited

The documentation for this class was generated from the following files: