KiCad PCB EDA Suite
dialog_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) 2018 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 <pcb_edit_frame.h>
26 #include <class_board.h>
28 #include <confirm.h>
29 
30 #include <dialog_import_settings.h>
31 
32 
33 wxString DIALOG_IMPORT_SETTINGS::m_filePath; // remember for session
34 
35 
37  DIALOG_IMPORT_SETTINGS_BASE( aParent ),
38  m_frame( aFrame )
39 {
40  m_browseButton->SetBitmap( KiBitmap( folder_xpm ) );
41 
42  m_sdbSizer1OK->SetLabel( _( "Import Settings" ) );
43  m_buttonsSizer->Layout();
44 
45  m_sdbSizer1OK->SetDefault();
46 }
47 
48 
50 {
51  m_filePathCtrl->SetValue( m_filePath );
52  return true;
53 }
54 
55 
56 void DIALOG_IMPORT_SETTINGS::OnBrowseClicked( wxCommandEvent& event )
57 {
58  wxFileName fn = m_frame->GetBoard()->GetFileName();
59  fn.SetExt( ProjectFileExtension );
60 
61  wxFileDialog dlg( this, _( "Import Settings From" ), fn.GetPath(), fn.GetFullName(),
62  ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
63 
64  if( dlg.ShowModal() == wxID_OK )
65  m_filePathCtrl->SetValue( dlg.GetPath() );
66 }
67 
68 
70 {
71  if( !wxFileExists( m_filePathCtrl->GetValue() ) )
72  {
73  DisplayError( this, wxString::Format( _( "File not found." ) ) );
74  m_filePathCtrl->SetFocus();
75  return false;
76  }
77 
78  m_filePath = m_filePathCtrl->GetValue();
79  return true;
80 }
81 
82 
83 void DIALOG_IMPORT_SETTINGS::OnSelectAll( wxCommandEvent& event )
84 {
85  m_LayersOpt->SetValue( true );
86  m_TextAndGraphicsOpt->SetValue( true );
87  m_ConstraintsOpt->SetValue( true );
88  m_NetclassesOpt->SetValue( true );
89  m_MaskAndPasteOpt->SetValue( true );
90 }
This file is part of the common library.
const std::string ProjectFileExtension
Class BOARD to handle a board.
BOARD * GetBoard() const
void OnSelectAll(wxCommandEvent &event) override
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
const wxString & GetFileName() const
Definition: class_board.h:237
DIALOG_IMPORT_SETTINGS(wxWindow *aParent, PCB_EDIT_FRAME *aFrame)
The common library.
wxString ProjectFileWildcard()
Class DIALOG_IMPORT_SETTINGS_BASE.
bool TransferDataFromWindow() override
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
void OnBrowseClicked(wxCommandEvent &event) override
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245