KiCad PCB EDA Suite
PANEL_PL_EDITOR_COLOR_SETTINGS Class Reference

#include <panel_pl_editor_color_settings.h>

Inheritance diagram for PANEL_PL_EDITOR_COLOR_SETTINGS:
PANEL_PL_EDITOR_COLOR_SETTINGS_BASE

Public Member Functions

 PANEL_PL_EDITOR_COLOR_SETTINGS (PL_EDITOR_FRAME *aFrame, wxWindow *aWindow)
 

Protected Attributes

wxStaticText * m_txtTheme
 
wxChoice * m_themeSelection
 

Private Member Functions

bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 

Private Attributes

PL_EDITOR_FRAMEm_frame
 

Detailed Description

Definition at line 27 of file panel_pl_editor_color_settings.h.

Constructor & Destructor Documentation

◆ PANEL_PL_EDITOR_COLOR_SETTINGS()

PANEL_PL_EDITOR_COLOR_SETTINGS::PANEL_PL_EDITOR_COLOR_SETTINGS ( PL_EDITOR_FRAME aFrame,
wxWindow *  aWindow 
)

Definition at line 30 of file panel_pl_editor_color_settings.cpp.

33  m_frame( aFrame )
34 {
35 }
PANEL_PL_EDITOR_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

◆ TransferDataFromWindow()

bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataFromWindow ( )
overrideprivate

Definition at line 69 of file panel_pl_editor_color_settings.cpp.

70 {
71  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
72 
73  auto selected = static_cast<COLOR_SETTINGS*>(
74  m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) );
75 
77 
78  cfg->m_ColorTheme = selected->GetFilename();
79 
80  auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings();
81  settings->LoadColors( selected );
82 
83  return true;
84 }
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
AppSettings * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
virtual RENDER_SETTINGS * GetSettings()=0
Return a 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:184

References SETTINGS_MANAGER::GetAppSettings(), PL_EDITOR_FRAME::GetCanvas(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), EDA_DRAW_PANEL_GAL::GetView(), KIGFX::RENDER_SETTINGS::LoadColors(), APP_SETTINGS_BASE::m_ColorTheme, m_frame, PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::m_themeSelection, and Pgm().

◆ TransferDataToWindow()

bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataToWindow ( )
overrideprivate

Definition at line 38 of file panel_pl_editor_color_settings.cpp.

39 {
40  PL_EDITOR_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PL_EDITOR_SETTINGS>();
41 
42  COLOR_SETTINGS* current = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
43 
44  int width = 0;
45  int height = 0;
46  int minwidth = width;
47 
48  m_themeSelection->Clear();
49 
50  for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
51  {
52  int pos = m_themeSelection->Append( settings->GetName(), static_cast<void*>( settings ) );
53 
54  if( settings == current )
55  m_themeSelection->SetSelection( pos );
56 
57  m_themeSelection->GetTextExtent( settings->GetName(), &width, &height );
58  minwidth = std::max( minwidth, width );
59  }
60 
61  m_themeSelection->SetMinSize( wxSize( minwidth + 50, -1 ) );
62 
63  Fit();
64 
65  return true;
66 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
SETTINGS_MANAGER * GetSettingsManager()
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184

References GetSettingsManager(), APP_SETTINGS_BASE::m_ColorTheme, PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::m_themeSelection, and Pgm().

Member Data Documentation

◆ m_frame

PL_EDITOR_FRAME* PANEL_PL_EDITOR_COLOR_SETTINGS::m_frame
private

Definition at line 37 of file panel_pl_editor_color_settings.h.

Referenced by TransferDataFromWindow().

◆ m_themeSelection

wxChoice* PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::m_themeSelection
protectedinherited

◆ m_txtTheme

wxStaticText* PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::m_txtTheme
protectedinherited

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