KiCad PCB EDA Suite
dialog_edit_library_tables.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-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include <wx/statline.h>
21 #include <wx/button.h>
22 
24 
25 
27  const wxString& aTitle ) :
28  DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
29  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
30  m_GlobalTableChanged( false ),
31  m_ProjectTableChanged( false ),
32  m_contentPanel( nullptr )
33 {
34  // Construction delayed until after panel is installed
35 }
36 
37 
39 {
40  m_contentPanel = aPanel;
41 
42  // Now perform the body of the constructor
43  auto mainSizer = new wxBoxSizer( wxVERTICAL );
44  SetSizer( mainSizer );
45 
46  mainSizer->Add( m_contentPanel, 1, wxEXPAND|wxLEFT|wxTOP|wxRIGHT, 5 );
47  m_contentPanel->SetMinSize( wxSize( 1000, 600 ) );
48 
49  auto sdbSizer = new wxStdDialogButtonSizer();
50  auto sdbSizerOK = new wxButton( this, wxID_OK );
51  sdbSizer->AddButton( sdbSizerOK );
52  auto sdbSizerCancel = new wxButton( this, wxID_CANCEL );
53  sdbSizer->AddButton( sdbSizerCancel );
54  sdbSizer->Realize();
55 
56  mainSizer->Add( sdbSizer, 0, wxALL|wxEXPAND, 5 );
57 
58  sdbSizerOK->SetDefault();
59 
61 
62  // On some windows manager (Unity, XFCE), this dialog is not always raised, depending
63  // on how the dialog is run.
64  Raise();
65 }
66 
67 
69 {
70  return m_contentPanel->TransferDataToWindow();
71 }
72 
73 
75 {
76  /* Transfer tables edited in dialog to the global and project tables:
77  * A good way is to use m_contentPanel->TransferDataFromWindow to do that.
78  * But be carefull:
79  * Since wxWidgets 3.1, it is called by wxDialog::TransferDataFromWindow()
80  * Before wxWidgets 3.1, it is *not* called by wxDialog::TransferDataFromWindow()
81  * m_contentPanel->TransferDataFromWindow do not works with two calls.
82  * Therefore *do not* call wxDialog::TransferDataFromWindow(),
83  * because m_contentPanel->TransferDataFromWindow() is called here.
84  */
85  return m_contentPanel->TransferDataFromWindow();
86 }
87 
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
DIALOG_EDIT_LIBRARY_TABLES(wxWindow *aParent, const wxString &aTitle)
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...