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
 

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
 
wxTextCtrl * m_textEditorPath
 
wxBitmapButton * m_textEditorBtn
 
wxRadioButton * m_defaultPDFViewer
 
wxRadioButton * m_otherPDFViewer
 
wxTextCtrl * m_PDFViewerPath
 
wxBitmapButton * m_pdfViewerBtn
 
wxStaticText * m_staticText1
 
STEPPED_SLIDERm_scaleSlider
 
wxStaticText * m_staticText2
 
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 47 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)
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 161 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().

162 {
163  wxString mask( wxT( "*" ) );
164 
165 #ifdef __WINDOWS__
166  mask += wxT( ".exe" );
167 #endif
168 
169  wxString wildcard = _( "Executable files (" ) + mask + wxT( ")|" ) + mask;
170 
172  wxFileName fn = Pgm().GetPdfBrowserName();
173 
174  wxFileDialog dlg( this, _( "Select Preferred PDF Browser" ), fn.GetPath(), fn.GetFullPath(),
175  wildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
176 
177  if( dlg.ShowModal() == wxID_CANCEL )
178  return;
179 
180  m_otherPDFViewer->SetValue( true );
181  m_PDFViewerPath->SetValue( dlg.GetPath() );
182 }
VTBL_ENTRY const wxString & GetPdfBrowserName() const
Definition: pgm_base.h:219
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 133 of file panel_common_settings.cpp.

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

134 {
135  if( m_scaleAuto->GetValue() )
136  {
137  m_last_scale = m_scaleSlider->GetValue();
138  m_scaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
139  }
140  else
141  {
142  if( m_last_scale >= 0 )
143  m_scaleSlider->SetValue( m_last_scale );
144  }
145 }
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 127 of file panel_common_settings.cpp.

References PANEL_COMMON_SETTINGS_BASE::m_scaleAuto.

128 {
129  m_scaleAuto->SetValue( false );
130 }
void PANEL_COMMON_SETTINGS::OnTextEditorClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_COMMON_SETTINGS_BASE.

Definition at line 148 of file panel_common_settings.cpp.

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

149 {
150  // Ask the user to select a new editor, but suggest the current one as the default.
151  wxString editorname = Pgm().AskUserForPreferredEditor( m_textEditorPath->GetValue() );
152 
153  // If we have a new editor name request it to be copied to m_editor_name and saved
154  // to the preferences file. If the user cancelled the dialog then the previous
155  // value will be retained.
156  if( !editorname.IsEmpty() )
157  m_textEditorPath->SetValue( editorname );
158 }
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:240
bool PANEL_COMMON_SETTINGS::TransferDataFromWindow ( )
overrideprotected

Definition at line 99 of file panel_common_settings.cpp.

References AUTOSAVE_INTERVAL_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_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().

100 {
101  wxConfigBase* commonSettings = Pgm().CommonSettings();
102 
103  commonSettings->Write( AUTOSAVE_INTERVAL_KEY, m_SaveTime->GetValue() * 60 );
104 
105  commonSettings->Write( FILE_HISTORY_SIZE_KEY, m_fileHistorySize->GetValue() );
106 
107  commonSettings->Write( GAL_ANTIALIASING_MODE_KEY, m_antialiasing->GetSelection() );
108 
109  const int scale_fourths = m_scaleAuto->GetValue() ? -1 : m_scaleSlider->GetValue() / 25;
110  commonSettings->Write( ICON_SCALE_KEY, scale_fourths );
111 
112  commonSettings->Write( USE_ICONS_IN_MENUS_KEY, m_checkBoxIconsInMenus->GetValue() );
113  commonSettings->Write( ENBL_ZOOM_NO_CENTER_KEY, !m_ZoomCenterOpt->GetValue() );
114  commonSettings->Write( ENBL_MOUSEWHEEL_PAN_KEY, m_MousewheelPANOpt->GetValue() );
115  commonSettings->Write( ENBL_AUTO_PAN_KEY, m_AutoPANOpt->GetValue() );
116 
117  Pgm().SetEditorName( m_textEditorPath->GetValue() );
118 
119  Pgm().SetPdfBrowserName( m_PDFViewerPath->GetValue() );
122 
123  return true;
124 }
VTBL_ENTRY void SetEditorName(const wxString &aFileName)
Definition: pgm_base.cpp:195
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:238
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:47
#define ENBL_AUTO_PAN_KEY
Definition: pgm_base.h:50
VTBL_ENTRY void SetPdfBrowserName(const wxString &aFileName)
Definition: pgm_base.h:221
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:48
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:51
#define ICON_SCALE_KEY
Definition: pgm_base.h:45
#define AUTOSAVE_INTERVAL_KEY
Definition: pgm_base.h:46
#define GAL_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:53
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:44
bool PANEL_COMMON_SETTINGS::TransferDataToWindow ( )
overrideprotected

Definition at line 44 of file panel_common_settings.cpp.

References AUTOSAVE_INTERVAL_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_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  int scale_fourths;
64  commonSettings->Read( ICON_SCALE_KEY, &scale_fourths );
65 
66  if( scale_fourths <= 0 )
67  {
68  m_scaleAuto->SetValue( true );
69  m_scaleSlider->SetValue( 25 * KiIconScale( GetParent() ) );
70  }
71  else
72  {
73  m_scaleAuto->SetValue( false );
74  m_scaleSlider->SetValue( scale_fourths * 25 );
75  }
76 
77  bool option;
78  commonSettings->Read( USE_ICONS_IN_MENUS_KEY, &option );
79  m_checkBoxIconsInMenus->SetValue( option );
80 
81  commonSettings->Read( ENBL_ZOOM_NO_CENTER_KEY, &option );
82  m_ZoomCenterOpt->SetValue( !option );
83 
84  commonSettings->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
85  m_MousewheelPANOpt->SetValue( option );
86 
87  commonSettings->Read( ENBL_AUTO_PAN_KEY, &option );
88  m_AutoPANOpt->SetValue( option );
89 
90  m_textEditorPath->SetValue( Pgm().GetEditorName( false ) );
91  m_defaultPDFViewer->SetValue( Pgm().UseSystemPdfBrowser() );
92  m_otherPDFViewer->SetValue( !Pgm().UseSystemPdfBrowser() );
93  m_PDFViewerPath->SetValue( Pgm().GetPdfBrowserName() );
94 
95  return true;
96 }
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:47
#define ENBL_AUTO_PAN_KEY
Definition: pgm_base.h:50
#define DEFAULT_FILE_HISTORY_SIZE
The default file history size is 9.
Definition: pgm_base.h:58
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:48
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:51
#define ICON_SCALE_KEY
Definition: pgm_base.h:45
#define AUTOSAVE_INTERVAL_KEY
Definition: pgm_base.h:46
#define GAL_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:53
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:44

Member Data Documentation

wxChoice* PANEL_COMMON_SETTINGS_BASE::m_antialiasing
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 47 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 49 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
wxTextCtrl* PANEL_COMMON_SETTINGS_BASE::m_PDFViewerPath
protectedinherited
wxSpinCtrl* PANEL_COMMON_SETTINGS_BASE::m_SaveTime
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticText1
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticText2
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticTextautosave
protectedinherited
wxStaticText* PANEL_COMMON_SETTINGS_BASE::m_staticTextFileHistorySize
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: