KiCad PCB EDA Suite
dialog_lib_new_symbol.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) 2009 Wayne Stambaugh <stambaughw@gmail.com>
5  * Copyright (C) 2016-2021 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 2
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
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <default_values.h>
26 #include <dialog_lib_new_symbol.h>
27 #include <eda_draw_frame.h>
28 #include <sch_validators.h>
29 #include <template_fieldnames.h>
30 
32  const wxArrayString* aRootSymbolNames ) :
33  DIALOG_LIB_NEW_SYMBOL_BASE( dynamic_cast<wxWindow*>( aParent ) ),
34  m_pinTextPosition( aParent, m_staticPinTextPositionLabel, m_textPinTextPosition,
35  m_staticPinTextPositionUnits, true )
36 {
37  if( aRootSymbolNames && aRootSymbolNames->GetCount() )
38  m_comboInheritanceSelect->Append( *aRootSymbolNames );
39 
40  m_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE_FIELD ) );
41  m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE_FIELD ) );
42 
44 
45  // initial focus should be on first editable field.
46  m_textName->SetFocus();
47 
48  // What happens when user presses "Enter"? OK button! OK?
49  m_sdbSizerOK->SetDefault();
50 
51  // Now all widgets have the size fixed, call FinishDialogSettings
53 }
54 
55 
56 void DIALOG_LIB_NEW_SYMBOL::OnParentSymbolSelect( wxCommandEvent& aEvent )
57 {
58  syncControls( !m_comboInheritanceSelect->GetValue().IsEmpty() );
59 }
60 
61 
62 void DIALOG_LIB_NEW_SYMBOL::syncControls( bool aIsDerivedPart )
63 {
64  m_staticTextDes->Enable( !aIsDerivedPart );
65  m_textReference->Enable( !aIsDerivedPart );
66  m_staticTextUnits->Enable( !aIsDerivedPart );
67  m_spinPartCount->Enable( !aIsDerivedPart );
68  m_checkLockItems->Enable( !aIsDerivedPart );
69  m_checkHasConversion->Enable( !aIsDerivedPart );
70  m_checkIsPowerSymbol->Enable( !aIsDerivedPart );
71  m_excludeFromBomCheckBox->Enable( !aIsDerivedPart );
72  m_excludeFromBoardCheckBox->Enable( !aIsDerivedPart );
73  m_staticPinTextPositionLabel->Enable( !aIsDerivedPart );
74  m_textPinTextPosition->Enable( !aIsDerivedPart );
75  m_staticPinTextPositionUnits->Enable( !aIsDerivedPart );
76  m_checkShowPinNumber->Enable( !aIsDerivedPart );
77  m_checkShowPinName->Enable( !aIsDerivedPart );
78  m_checkShowPinNameInside->Enable( !aIsDerivedPart );
79 }
80 
81 
82 void DIALOG_LIB_NEW_SYMBOL::onPowerCheckBox( wxCommandEvent& aEvent )
83 {
84  if( m_checkIsPowerSymbol->IsChecked() )
85  {
86  m_excludeFromBomCheckBox->SetValue( true );
87  m_excludeFromBoardCheckBox->SetValue( true );
88  m_excludeFromBomCheckBox->Enable( false );
89  m_excludeFromBoardCheckBox->Enable( false );
90  }
91  else
92  {
93  m_excludeFromBomCheckBox->Enable( true );
94  m_excludeFromBoardCheckBox->Enable( true );
95  }
96 }
97 
Field Reference of part, i.e. "IC21".
virtual void OnParentSymbolSelect(wxCommandEvent &aEvent) override
DIALOG_LIB_NEW_SYMBOL(EDA_DRAW_FRAME *parent, const wxArrayString *aRootSymbolNames=nullptr)
The base class for create windows for drawing purpose.
Field Value of part, i.e. "3.3K".
virtual void onPowerCheckBox(wxCommandEvent &aEvent) override
Definitions of control validators for schematic dialogs.
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void syncControls(bool aIsDerivedPart)
Class DIALOG_LIB_NEW_SYMBOL_BASE.
A text control validator used for validating the text allowed in library and schematic symbol fields.