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 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 
23 
24 
26  const wxString& aTitle ) :
27  DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
28  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
29  m_GlobalTableChanged( false ),
30  m_ProjectTableChanged( false ),
31  m_contentPanel( nullptr )
32 {
33  // Construction delayed until after panel is installed
34 }
35 
36 
38 {
39  m_contentPanel = aPanel;
40 
41  // Now perform the body of the constructor
42  auto mainSizer = new wxBoxSizer( wxVERTICAL );
43  SetSizer( mainSizer );
44 
45  mainSizer->Add( m_contentPanel, 1, wxEXPAND|wxLEFT|wxTOP|wxRIGHT, 5 );
46  m_contentPanel->SetMinSize( wxSize( 1000, 600 ) );
47 
48  auto sdbSizer = new wxStdDialogButtonSizer();
49  auto sdbSizerOK = new wxButton( this, wxID_OK );
50  sdbSizer->AddButton( sdbSizerOK );
51  auto sdbSizerCancel = new wxButton( this, wxID_CANCEL );
52  sdbSizer->AddButton( sdbSizerCancel );
53  sdbSizer->Realize();
54 
55  mainSizer->Add( sdbSizer, 0, wxALL|wxEXPAND, 5 );
56 
57  sdbSizerOK->SetDefault();
58 
60 
61  // On some windows manager (Unity, XFCE), this dialog is not always raised, depending
62  // on how the dialog is run.
63  Raise();
64 }
65 
66 
68 {
69  return m_contentPanel->TransferDataToWindow();
70 }
71 
72 
74 {
75  /* Transfer tables edited in dialog to the global and project tables:
76  * A good way is to use m_contentPanel->TransferDataFromWindow to do that.
77  * But be carefull:
78  * Since wxWidgets 3.1, it is called by wxDialog::TransferDataFromWindow()
79  * Before wxWidgets 3.1, it is *not* called by wxDialog::TransferDataFromWindow()
80  * m_contentPanel->TransferDataFromWindow do not works with two calls.
81  * Therefore *do not* call wxDialog::TransferDataFromWindow(),
82  * because m_contentPanel->TransferDataFromWindow() is called here.
83  */
84  return m_contentPanel->TransferDataFromWindow();
85 }
86 
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:84
DIALOG_EDIT_LIBRARY_TABLES(wxWindow *aParent, const wxString &aTitle)