KiCad PCB EDA Suite
PANEL_COMMON_SETTINGS Class Reference

#include <panel_common_settings.h>

Inheritance diagram for PANEL_COMMON_SETTINGS:
PANEL_COMMON_SETTINGS_BASE

Public Member Functions

 PANEL_COMMON_SETTINGS (DIALOG_SHIM *aDialog, wxWindow *aParent)
 

Protected Types

enum  { wxID_AUTOPAN = 1000 }
 

Protected Member Functions

bool TransferDataFromWindow () override
 
bool TransferDataToWindow () override
 
void OnScaleSlider (wxScrollEvent &aEvent) override
 
void OnScaleAuto (wxCommandEvent &aEvent) override
 
void OnTextEditorClick (wxCommandEvent &event) override
 
void OnPDFViewerClick (wxCommandEvent &event) override
 
void onUpdateUIPdfPath (wxUpdateUIEvent &event) override
 

Protected Attributes

DIALOG_SHIMm_dialog
 
int m_last_scale
 saved icon scale when Auto selected More...
 
wxStaticText * m_staticTextautosave
 
wxSpinCtrl * m_SaveTime
 
wxStaticText * m_staticTextFileHistorySize
 
wxSpinCtrl * m_fileHistorySize
 
wxChoice * m_antialiasing
 
wxChoice * m_antialiasingFallback
 
wxTextCtrl * m_textEditorPath
 
wxBitmapButton * m_textEditorBtn
 
wxRadioButton * m_defaultPDFViewer
 
wxRadioButton * m_otherPDFViewer
 
wxTextCtrl * m_PDFViewerPath
 
wxBitmapButton * m_pdfViewerBtn
 
wxStaticText * m_staticTexticonscale
 
STEPPED_SLIDERm_scaleSlider
 
wxStaticText * m_staticTextPerCent
 
wxCheckBox * m_scaleAuto
 
wxCheckBox * m_checkBoxIconsInMenus
 
wxCheckBox * m_ZoomCenterOpt
 
wxCheckBox * m_MousewheelPANOpt
 
wxCheckBox * m_AutoPANOpt
 

Detailed Description

Definition at line 33 of file panel_common_settings.h.

Member Enumeration Documentation

anonymous enum
protectedinherited
Enumerator
wxID_AUTOPAN 

Definition at line 46 of file panel_common_settings_base.h.

Constructor & Destructor Documentation

PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS ( DIALOG_SHIM aDialog,
wxWindow *  aParent 
)

Definition at line 32 of file panel_common_settings.cpp.

References KiBitmap(), PANEL_COMMON_SETTINGS_BASE::m_pdfViewerBtn, PANEL_COMMON_SETTINGS_BASE::m_scaleSlider, PANEL_COMMON_SETTINGS_BASE::m_textEditorBtn, and STEPPED_SLIDER::SetStep().

32  :
33  PANEL_COMMON_SETTINGS_BASE( aParent ),
34  m_dialog( aDialog ),
35  m_last_scale( -1 )
36 {
37  m_scaleSlider->SetStep( 25 );
38 
39  m_textEditorBtn->SetBitmap( KiBitmap( folder_xpm ) );
40  m_pdfViewerBtn->SetBitmap( KiBitmap( folder_xpm ) );
41 }
PANEL_COMMON_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)
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
int m_last_scale
saved icon scale when Auto selected
void SetStep(int aSize)
Set the step size.

Member Function Documentation

void PANEL_COMMON_SETTINGS::OnPDFViewerClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_COMMON_SETTINGS_BASE.

Definition at line 166 of file panel_common_settings.cpp.

References PGM_BASE::GetPdfBrowserName(), PANEL_COMMON_SETTINGS_BASE::m_otherPDFViewer, PANEL_COMMON_SETTINGS_BASE::m_PDFViewerPath, Pgm(), and PGM_BASE::ReadPdfBrowserInfos().

167 {
168  wxString mask( wxT( "*" ) );
169 
170 #ifdef __WINDOWS__
171  mask += wxT( ".exe" );
172 #endif
173 
174  wxString wildcard = _( "Executable files (" ) + mask + wxT( ")|" ) + mask;
175 
177  wxFileName fn = Pgm().GetPdfBrowserName();
178 
179  wxFileDialog dlg( this, _( "Select Preferred PDF Browser" ), fn.GetPath(), fn.GetFullPath(),
180  wildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
181 
182  if( dlg.ShowModal() == wxID_CANCEL )
183  return;
184 
185  m_otherPDFViewer->SetValue( true );
186  m_PDFViewerPath->SetValue( dlg.GetPath() );
187 }
VTBL_ENTRY const wxString & GetPdfBrowserName() const
Definition: pgm_base.h:221
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY void ReadPdfBrowserInfos()
Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.
Definition: eda_doc.cpp:42
void PANEL_COMMON_SETTINGS::OnScaleAuto ( wxCommandEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from PANEL_COMMON_SETTINGS_BASE.

Definition at line 138 of file panel_common_settings.cpp.

References KiIconScale(), m_last_scale, PANEL_COMMON_SETTINGS_BASE::m_scaleAuto, and PANEL_COMMON_SETTINGS_BASE::m_scaleSlider.

139 {
140  if( m_scaleAuto->GetValue() )
141  {
142  m_last_scale = m_scaleSlider->GetValue();
143  m_scaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
144  }
145  else
146  {
147  if( m_last_scale >= 0 )
148  m_scaleSlider->SetValue( m_last_scale );
149  }
150 }
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
Definition: bitmap.cpp:89
int m_last_scale
saved icon scale when Auto selected
void PANEL_COMMON_SETTINGS::OnScaleSlider ( wxScrollEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from PANEL_COMMON_SETTINGS_BASE.

Definition at line 132 of file panel_common_settings.cpp.

References PANEL_COMMON_SETTINGS_BASE::m_scaleAuto.

133 {
134  m_scaleAuto->SetValue( false );
135 }
void PANEL_COMMON_SETTINGS::OnTextEditorClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_COMMON_SETTINGS_BASE.

Definition at line 153 of file panel_common_settings.cpp.

References PGM_BASE::AskUserForPreferredEditor(), PANEL_COMMON_SETTINGS_BASE::m_textEditorPath, and Pgm().

154 {
155  // Ask the user to select a new editor, but suggest the current one as the default.
156  wxString editorname = Pgm().AskUserForPreferredEditor( m_textEditorPath->GetValue() );
157 
158  // If we have a new editor name request it to be copied to m_editor_name and saved
159  // to the preferences file. If the user cancelled the dialog then the previous
160  // value will be retained.
161  if( !editorname.IsEmpty() )
162  m_textEditorPath->SetValue( editorname );
163 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY const wxString AskUserForPreferredEditor(const wxString &aDefaultEditor=wxEmptyString)
Shows a dialog that instructs the user to select a new preferred editor.
Definition: pgm_base.cpp:237
void PANEL_COMMON_SETTINGS::onUpdateUIPdfPath ( wxUpdateUIEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_COMMON_SETTINGS_BASE.

Definition at line 190 of file panel_common_settings.cpp.

References PANEL_COMMON_SETTINGS_BASE::m_otherPDFViewer, PANEL_COMMON_SETTINGS_BASE::m_pdfViewerBtn, and PANEL_COMMON_SETTINGS_BASE::m_PDFViewerPath.

191 {
192  bool enabled = m_otherPDFViewer->GetValue();
193  m_PDFViewerPath->Enable( enabled );
194  m_pdfViewerBtn->Enable( enabled );
195 }
bool PANEL_COMMON_SETTINGS::TransferDataFromWindow ( )
overrideprotected

Definition at line 102 of file panel_common_settings.cpp.

References AUTOSAVE_INTERVAL_KEY, CAIRO_ANTIALIASING_MODE_KEY, PGM_BASE::CommonSettings(), ENBL_AUTO_PAN_KEY, ENBL_MOUSEWHEEL_PAN_KEY, ENBL_ZOOM_NO_CENTER_KEY, FILE_HISTORY_SIZE_KEY, PGM_BASE::ForceSystemPdfBrowser(), GAL_ANTIALIASING_MODE_KEY, ICON_SCALE_KEY, PANEL_COMMON_SETTINGS_BASE::m_antialiasing, PANEL_COMMON_SETTINGS_BASE::m_antialiasingFallback, PANEL_COMMON_SETTINGS_BASE::m_AutoPANOpt, PANEL_COMMON_SETTINGS_BASE::m_checkBoxIconsInMenus, PANEL_COMMON_SETTINGS_BASE::m_defaultPDFViewer, PANEL_COMMON_SETTINGS_BASE::m_fileHistorySize, PANEL_COMMON_SETTINGS_BASE::m_MousewheelPANOpt, PANEL_COMMON_SETTINGS_BASE::m_PDFViewerPath, PANEL_COMMON_SETTINGS_BASE::m_SaveTime, PANEL_COMMON_SETTINGS_BASE::m_scaleAuto, PANEL_COMMON_SETTINGS_BASE::m_scaleSlider, PANEL_COMMON_SETTINGS_BASE::m_textEditorPath, PANEL_COMMON_SETTINGS_BASE::m_ZoomCenterOpt, Pgm(), PGM_BASE::SetEditorName(), PGM_BASE::SetPdfBrowserName(), USE_ICONS_IN_MENUS_KEY, and PGM_BASE::WritePdfBrowserInfos().

103 {
104  wxConfigBase* commonSettings = Pgm().CommonSettings();
105 
106  commonSettings->Write( AUTOSAVE_INTERVAL_KEY, m_SaveTime->GetValue() * 60 );
107 
108  commonSettings->Write( FILE_HISTORY_SIZE_KEY, m_fileHistorySize->GetValue() );
109 
110  commonSettings->Write( GAL_ANTIALIASING_MODE_KEY, m_antialiasing->GetSelection() );
111 
112  commonSettings->Write( CAIRO_ANTIALIASING_MODE_KEY, m_antialiasingFallback->GetSelection() );
113 
114  const int scale_fourths = m_scaleAuto->GetValue() ? -1 : m_scaleSlider->GetValue() / 25;
115  commonSettings->Write( ICON_SCALE_KEY, scale_fourths );
116 
117  commonSettings->Write( USE_ICONS_IN_MENUS_KEY, m_checkBoxIconsInMenus->GetValue() );
118  commonSettings->Write( ENBL_ZOOM_NO_CENTER_KEY, !m_ZoomCenterOpt->GetValue() );
119  commonSettings->Write( ENBL_MOUSEWHEEL_PAN_KEY, m_MousewheelPANOpt->GetValue() );
120  commonSettings->Write( ENBL_AUTO_PAN_KEY, m_AutoPANOpt->GetValue() );
121 
122  Pgm().SetEditorName( m_textEditorPath->GetValue() );
123 
124  Pgm().SetPdfBrowserName( m_PDFViewerPath->GetValue() );
127 
128  return true;
129 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:192
VTBL_ENTRY void ForceSystemPdfBrowser(bool aFlg)
Function ForceSystemPdfBrowser forces the use of system PDF browser, even if a preferred PDF browser ...
Definition: pgm_base.h:240
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY void WritePdfBrowserInfos()
Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration.
Definition: eda_doc.cpp:55
#define ENBL_ZOOM_NO_CENTER_KEY
Definition: pgm_base.h:48
#define ENBL_AUTO_PAN_KEY
Definition: pgm_base.h:51
VTBL_ENTRY void SetPdfBrowserName(const wxString &aFileName)
Definition: pgm_base.h:223
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:49
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:52
#define ICON_SCALE_KEY
Definition: pgm_base.h:46
#define AUTOSAVE_INTERVAL_KEY
Definition: pgm_base.h:47
#define GAL_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:54
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:189
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:45
#define CAIRO_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:55
bool PANEL_COMMON_SETTINGS::TransferDataToWindow ( )
overrideprotected

Definition at line 44 of file panel_common_settings.cpp.

References AUTOSAVE_INTERVAL_KEY, CAIRO_ANTIALIASING_MODE_KEY, PGM_BASE::CommonSettings(), DEFAULT_FILE_HISTORY_SIZE, ENBL_AUTO_PAN_KEY, ENBL_MOUSEWHEEL_PAN_KEY, ENBL_ZOOM_NO_CENTER_KEY, FILE_HISTORY_SIZE_KEY, GAL_ANTIALIASING_MODE_KEY, ICON_SCALE_KEY, KiIconScale(), PANEL_COMMON_SETTINGS_BASE::m_antialiasing, PANEL_COMMON_SETTINGS_BASE::m_antialiasingFallback, PANEL_COMMON_SETTINGS_BASE::m_AutoPANOpt, PANEL_COMMON_SETTINGS_BASE::m_checkBoxIconsInMenus, PANEL_COMMON_SETTINGS_BASE::m_defaultPDFViewer, PANEL_COMMON_SETTINGS_BASE::m_fileHistorySize, PANEL_COMMON_SETTINGS_BASE::m_MousewheelPANOpt, PANEL_COMMON_SETTINGS_BASE::m_otherPDFViewer, PANEL_COMMON_SETTINGS_BASE::m_PDFViewerPath, PANEL_COMMON_SETTINGS_BASE::m_SaveTime, PANEL_COMMON_SETTINGS_BASE::m_scaleAuto, PANEL_COMMON_SETTINGS_BASE::m_scaleSlider, PANEL_COMMON_SETTINGS_BASE::m_textEditorPath, PANEL_COMMON_SETTINGS_BASE::m_ZoomCenterOpt, Pgm(), and USE_ICONS_IN_MENUS_KEY.

45 {
46  wxConfigBase* commonSettings = Pgm().CommonSettings();
47 
48  int timevalue;
49  wxString msg;
50 
51  commonSettings->Read( AUTOSAVE_INTERVAL_KEY, &timevalue );
52  msg << timevalue / 60;
53  m_SaveTime->SetValue( msg );
54 
55  int fileHistorySize;
56  commonSettings->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize, DEFAULT_FILE_HISTORY_SIZE );
57  m_fileHistorySize->SetValue( fileHistorySize );
58 
59  int antialiasingMode;
60  commonSettings->Read( GAL_ANTIALIASING_MODE_KEY, &antialiasingMode, 0 );
61  m_antialiasing->SetSelection( antialiasingMode );
62 
63  commonSettings->Read( CAIRO_ANTIALIASING_MODE_KEY, &antialiasingMode, 0 );
64  m_antialiasingFallback->SetSelection( antialiasingMode );
65 
66  int scale_fourths;
67  commonSettings->Read( ICON_SCALE_KEY, &scale_fourths );
68 
69  if( scale_fourths <= 0 )
70  {
71  m_scaleAuto->SetValue( true );
72  m_scaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
73  }
74  else
75  {
76  m_scaleAuto->SetValue( false );
77  m_scaleSlider->SetValue( scale_fourths * 25 );
78  }
79 
80  bool option;
81  commonSettings->Read( USE_ICONS_IN_MENUS_KEY, &option );
82  m_checkBoxIconsInMenus->SetValue( option );
83 
84  commonSettings->Read( ENBL_ZOOM_NO_CENTER_KEY, &option );
85  m_ZoomCenterOpt->SetValue( !option );
86 
87  commonSettings->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
88  m_MousewheelPANOpt->SetValue( option );
89 
90  commonSettings->Read( ENBL_AUTO_PAN_KEY, &option );
91  m_AutoPANOpt->SetValue( option );
92 
93  m_textEditorPath->SetValue( Pgm().GetEditorName( false ) );
94  m_defaultPDFViewer->SetValue( Pgm().UseSystemPdfBrowser() );
95  m_otherPDFViewer->SetValue( !Pgm().UseSystemPdfBrowser() );
96  m_PDFViewerPath->SetValue( Pgm().GetPdfBrowserName() );
97 
98  return true;
99 }
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
Definition: bitmap.cpp:89
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
#define ENBL_ZOOM_NO_CENTER_KEY
Definition: pgm_base.h:48
#define ENBL_AUTO_PAN_KEY
Definition: pgm_base.h:51
#define DEFAULT_FILE_HISTORY_SIZE
The default file history size is 9.
Definition: pgm_base.h:60
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:49
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:52
#define ICON_SCALE_KEY
Definition: pgm_base.h:46
#define AUTOSAVE_INTERVAL_KEY
Definition: pgm_base.h:47
#define GAL_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:54
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:189
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:45
#define CAIRO_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:55

Member Data Documentation

wxChoice* PANEL_COMMON_SETTINGS_BASE::m_antialiasing
protectedinherited
wxChoice* PANEL_COMMON_SETTINGS_BASE::m_antialiasingFallback
protectedinherited
wxCheckBox* PANEL_COMMON_SETTINGS_BASE::m_AutoPANOpt
protectedinherited
wxCheckBox* PANEL_COMMON_SETTINGS_BASE::m_checkBoxIconsInMenus
protectedinherited
wxRadioButton* PANEL_COMMON_SETTINGS_BASE::m_defaultPDFViewer
protectedinherited
DIALOG_SHIM* PANEL_COMMON_SETTINGS::m_dialog
protected

Definition at line 48 of file panel_common_settings.h.

wxSpinCtrl* PANEL_COMMON_SETTINGS_BASE::m_fileHistorySize
protectedinherited
int PANEL_COMMON_SETTINGS::m_last_scale
protected

saved icon scale when Auto selected

Definition at line 50 of file panel_common_settings.h.

Referenced by OnScaleAuto().

wxCheckBox* PANEL_COMMON_SETTINGS_BASE::m_MousewheelPANOpt
protectedinherited
wxRadioButton* PANEL_COMMON_SETTINGS_BASE::m_otherPDFViewer
protectedinherited
wxBitmapButton* PANEL_COMMON_SETTINGS_BASE::m_pdfViewerBtn
protectedinherited
wxSpinCtrl* PANEL_COMMON_SETTINGS_BASE::m_SaveTime
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticTextautosave
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticTextFileHistorySize
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticTexticonscale
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticTextPerCent
protectedinherited
wxBitmapButton* PANEL_COMMON_SETTINGS_BASE::m_textEditorBtn
protectedinherited
wxTextCtrl* PANEL_COMMON_SETTINGS_BASE::m_textEditorPath
protectedinherited
wxCheckBox* PANEL_COMMON_SETTINGS_BASE::m_ZoomCenterOpt
protectedinherited

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