KiCad PCB EDA Suite
dialog_sch_import_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 <bitmaps.h>
25 #include <sch_edit_frame.h>
27 #include <confirm.h>
28 #include <schematic.h>
29 #include <wx/filedlg.h>
30 
32 
33 
34 wxString DIALOG_SCH_IMPORT_SETTINGS::m_filePath; // remember for session
35 
36 
39  m_frame( aFrame )
40 {
42 
43  m_sdbSizer1OK->SetLabel( _( "Import Settings" ) );
44  m_buttonsSizer->Layout();
45 
46  m_sdbSizer1OK->SetDefault();
47 }
48 
49 
51 {
52  m_filePathCtrl->SetValue( m_filePath );
53  return true;
54 }
55 
56 
57 void DIALOG_SCH_IMPORT_SETTINGS::OnBrowseClicked( wxCommandEvent& event )
58 {
59  wxFileName fn = m_frame->Schematic().Root().GetFileName();
60  fn.SetExt( ProjectFileExtension );
61 
62  wxFileDialog dlg( this, _( "Import Settings From" ), fn.GetPath(), fn.GetFullName(),
63  ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
64 
65  if( dlg.ShowModal() == wxID_OK )
66  m_filePathCtrl->SetValue( dlg.GetPath() );
67 }
68 
69 
71 {
72  if( !wxFileExists( m_filePathCtrl->GetValue() ) )
73  {
74  DisplayError( this, wxString::Format( _( "File not found." ) ) );
75  m_filePathCtrl->SetFocus();
76  return false;
77  }
78 
79  m_filePath = m_filePathCtrl->GetValue();
80  return true;
81 }
82 
83 
84 void DIALOG_SCH_IMPORT_SETTINGS::OnSelectAll( wxCommandEvent& event )
85 {
86  m_FormattingOpt->SetValue( true );
87  m_FieldNameTemplatesOpt->SetValue( true );
88  m_PinMapOpt->SetValue( true );
89  m_SeveritiesOpt->SetValue( true );
90  m_NetClassesOpt->SetValue( true );
91 }
Class DIALOG_SCH_IMPORT_SETTINGS_BASE.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:271
This file is part of the common library.
const std::string ProjectFileExtension
Schematic editor (Eeschema) main window.
DIALOG_SCH_IMPORT_SETTINGS(wxWindow *aParent, SCH_EDIT_FRAME *aFrame)
void OnSelectAll(wxCommandEvent &event) override
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
#define _(s)
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:315
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
wxString ProjectFileWildcard()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
SCH_SHEET & Root() const
Definition: schematic.h:92
void OnBrowseClicked(wxCommandEvent &event) override