KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_regulator_form.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) 1992-2011 jean-pierre.charras
5 * Copyright (C) 1992-2024 Kicad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <wx/msgdlg.h>
22
27
28
29extern double DoubleFromString( const wxString& TextValue );
30
31DIALOG_REGULATOR_FORM::DIALOG_REGULATOR_FORM( wxWindow* parent, const wxString& aRegName ) :
33{
34 m_textCtrlName->SetValue( aRegName );
35 m_textCtrlName->Enable( aRegName.IsEmpty() );
37
39
40 // Now all widgets have the size fixed, call FinishDialogSettings
42}
43
45{
46}
47
48
50{
51 if( !wxDialog::TransferDataFromWindow() )
52 return false;
53
54 bool success = true;
55
56 if( m_textCtrlName->GetValue().IsEmpty() )
57 success = false;
58
59 if( m_textCtrlVref->GetValue().IsEmpty() )
60 {
61 success = false;
62 }
63 else
64 {
65 double vref = DoubleFromString( m_textCtrlVref->GetValue() );
66
67 if( fabs( vref ) < 0.01 )
68 success = false;
69 }
70
71 if( m_choiceRegType->GetSelection() == 1 )
72 {
73 if( m_RegulIadjValue->GetValue().IsEmpty() )
74 success = false;
75 }
76
77 return success;
78}
79
80
82{
83 bool enbl = m_choiceRegType->GetSelection() == 1;
84 m_RegulIadjValue->Enable( enbl );
85}
86
87
89{
90 m_textCtrlName->SetValue( aItem->m_Name );
91 wxString value;
92 value.Printf( wxT( "%g" ), aItem->m_Vref );
93 m_textCtrlVref->SetValue( value );
94 value.Printf( wxT( "%g" ), aItem->m_Iadj );
95 m_RegulIadjValue->SetValue( value );
96 m_choiceRegType->SetSelection( aItem->m_Type );
98}
99
100
102{
103 double vref = DoubleFromString( m_textCtrlVref->GetValue() );
104 double iadj = DoubleFromString( m_RegulIadjValue->GetValue() );
105 int type = m_choiceRegType->GetSelection();
106
107 if( type != 1 )
108 iadj = 0.0;
109
110 REGULATOR_DATA* item = new REGULATOR_DATA( m_textCtrlName->GetValue(), vref, type, iadj );
111 return item;
112}
Class DIALOG_REGULATOR_FORM_BASE.
void UpdateDialog()
Enable/disable Iadj related widgets, according to the regulator type.
REGULATOR_DATA * BuildRegulatorFromData()
Create a new REGULATOR_DATA from dialog data.
void CopyRegulatorDataToDialog(REGULATOR_DATA *aItem)
Transfer data from dialog to aItem.
DIALOG_REGULATOR_FORM(wxWindow *parent, const wxString &aRegName)
bool TransferDataFromWindow() override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Contains structures for storage of regulator data.
double DoubleFromString(const wxString &TextValue)
double DoubleFromString(const wxString &TextValue)