KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
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>
27#include <eda_draw_frame.h>
28#include <sch_validators.h>
29#include <template_fieldnames.h>
30
32 const wxString& message,
33 const wxArrayString* aRootSymbolNames,
34 const wxString& inheritFromSymbolName ) :
35 DIALOG_LIB_NEW_SYMBOL_BASE( dynamic_cast<wxWindow*>( aParent ) ),
36 m_pinTextPosition( aParent, m_staticPinTextPositionLabel, m_textPinTextPosition,
37 m_staticPinTextPositionUnits, true )
38{
39 if( aRootSymbolNames && aRootSymbolNames->GetCount() )
40 {
41 wxArrayString escapedNames;
42
43 for( const wxString& name : *aRootSymbolNames )
44 escapedNames.Add( UnescapeString( name ) );
45
46 m_comboInheritanceSelect->Append( escapedNames );
47
48 if( !inheritFromSymbolName.IsEmpty() )
49 {
50 m_comboInheritanceSelect->SetStringSelection( inheritFromSymbolName );
51 syncControls( !m_comboInheritanceSelect->GetValue().IsEmpty() );
52 }
53 }
54
55 if( !message.IsEmpty() )
56 {
58 m_infoBar->ShowMessage( message );
59 }
60
61 m_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE_FIELD ) );
62 m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE_FIELD ) );
63
65
66 // initial focus should be on first editable field.
67 m_textName->SetFocus();
68
70
71 // Now all widgets have the size fixed, call FinishDialogSettings
73}
74
75
76void DIALOG_LIB_NEW_SYMBOL::OnParentSymbolSelect( wxCommandEvent& aEvent )
77{
78 syncControls( !m_comboInheritanceSelect->GetValue().IsEmpty() );
79}
80
81
82void DIALOG_LIB_NEW_SYMBOL::syncControls( bool aIsDerivedPart )
83{
84 m_staticTextDes->Enable( !aIsDerivedPart );
85 m_textReference->Enable( !aIsDerivedPart );
86 m_staticTextUnits->Enable( !aIsDerivedPart );
87 m_spinPartCount->Enable( !aIsDerivedPart );
88 m_checkUnitsInterchangeable->Enable( !aIsDerivedPart );
89 m_checkHasConversion->Enable( !aIsDerivedPart );
90 m_checkIsPowerSymbol->Enable( !aIsDerivedPart );
91 m_excludeFromBomCheckBox->Enable( !aIsDerivedPart );
92 m_excludeFromBoardCheckBox->Enable( !aIsDerivedPart );
93 m_staticPinTextPositionLabel->Enable( !aIsDerivedPart );
94 m_textPinTextPosition->Enable( !aIsDerivedPart );
95 m_staticPinTextPositionUnits->Enable( !aIsDerivedPart );
96 m_checkShowPinNumber->Enable( !aIsDerivedPart );
97 m_checkShowPinName->Enable( !aIsDerivedPart );
98 m_checkShowPinNameInside->Enable( !aIsDerivedPart );
99}
100
101
102void DIALOG_LIB_NEW_SYMBOL::onPowerCheckBox( wxCommandEvent& aEvent )
103{
104 if( m_checkIsPowerSymbol->IsChecked() )
105 {
106 m_excludeFromBomCheckBox->SetValue( true );
107 m_excludeFromBoardCheckBox->SetValue( true );
108 m_excludeFromBomCheckBox->Enable( false );
109 m_excludeFromBoardCheckBox->Enable( false );
110 }
111 else
112 {
113 m_excludeFromBomCheckBox->Enable( true );
114 m_excludeFromBoardCheckBox->Enable( true );
115 }
116}
117
const char * name
Definition: DXF_plotter.cpp:56
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
Class DIALOG_LIB_NEW_SYMBOL_BASE.
DIALOG_LIB_NEW_SYMBOL(EDA_DRAW_FRAME *parent, const wxString &message, const wxArrayString *aRootSymbolNames=nullptr, const wxString &inheritFromSymbolName=wxEmptyString)
virtual void OnParentSymbolSelect(wxCommandEvent &aEvent) override
void syncControls(bool aIsDerivedPart)
virtual void onPowerCheckBox(wxCommandEvent &aEvent) 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...
The base class for create windows for drawing purpose.
A text control validator used for validating the text allowed in library and schematic symbol fields.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:301
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: wx_infobar.cpp:154
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
Definitions of control validators for schematic dialogs.
wxString UnescapeString(const wxString &aSource)
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".