KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_lib_new_symbol.h
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 The 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#pragma once
26
27#include <widgets/unit_binder.h>
28#include <string_utils.h>
30
31class EDA_DRAW_FRAME;
32class wxArrayString;
33
35{
36public:
37 DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent, const wxArrayString& aSymbolNames,
38 const wxString& aInheritFromSymbolName,
39 std::function<bool( wxString newName )> aValidator );
40
42
43 void SetName( const wxString& name ) override
44 {
45 m_textName->SetValue( UnescapeString( name ) );
46 }
47
48 wxString GetName() const override
49 {
50 wxString name = EscapeString( m_textName->GetValue(), CTX_LIBID );
51
52 // Currently, symbol names cannot include a space, that breaks libraries:
53 name.Replace( " ", "_" );
54
55 return name;
56 }
57
58 wxString GetParentSymbolName() const
59 {
61 }
62
63 void SetReference( const wxString& reference ) { m_textReference->SetValue( reference ); }
64 wxString GetReference() { return m_textReference->GetValue(); }
65
66 void SetPartCount( int count ) { m_spinPartCount->SetValue( count ); }
67 int GetUnitCount() { return m_spinPartCount->GetValue(); }
68
69 void SetAlternateBodyStyle( bool enable ) { m_checkHasAlternateBodyStyle->SetValue( enable ); }
71
72 void SetPowerSymbol( bool enable ) { m_checkIsPowerSymbol->SetValue( enable ); }
73 bool GetPowerSymbol() { return m_checkIsPowerSymbol->GetValue(); }
74
75 void SetUnitsInterchangeable( bool enable ) { m_checkUnitsInterchangeable->SetValue( enable ); }
77
78 void SetIncludeInBom( bool aInclude ) { m_excludeFromBomCheckBox->SetValue( !aInclude ); }
79 bool GetIncludeInBom() const { return !m_excludeFromBomCheckBox->GetValue(); }
80
81 void SetIncludeOnBoard( bool aInclude ) { m_excludeFromBoardCheckBox->SetValue( !aInclude ); }
82 bool GetIncludeOnBoard() const { return !m_excludeFromBoardCheckBox->GetValue(); }
83
84 void SetPinTextPosition( int position ) { m_pinTextPosition.SetValue( position ); }
86
87 void SetKeepDatasheet( bool keep ) { m_checkKeepDatasheet->SetValue( keep ); }
88 bool GetKeepDatasheet() { return m_checkKeepDatasheet->GetValue(); }
89
90 void SetKeepFootprint( bool keep ) { m_checkKeepFootprint->SetValue( keep ); }
91 bool GetKeepFootprint() { return m_checkKeepFootprint->GetValue(); }
92
93 void SetTransferUserFields( bool keep ) { m_checkTransferUserFields->SetValue( keep ); }
94 bool GetTransferUserFields() { return m_checkTransferUserFields->GetValue(); }
95
96 void SetKeepContentUserFields( bool keep ) { m_checkKeepContentUserFields->SetValue( keep ); }
98
99 void SetShowPinNumber( bool show ) { m_checkShowPinNumber->SetValue( show ); }
100 bool GetShowPinNumber() { return m_checkShowPinNumber->GetValue(); }
101
102 void SetShowPinName( bool show ) { m_checkShowPinName->SetValue( show ); }
103 bool GetShowPinName() { return m_checkShowPinName->GetValue(); }
104
105 void SetPinNameInside( bool show ) { m_checkShowPinNameInside->SetValue( show ); }
106 bool GetPinNameInside() { return m_checkShowPinNameInside->GetValue(); }
107
108protected:
109 bool TransferDataFromWindow() override;
110
111 virtual void onPowerCheckBox( wxCommandEvent& aEvent ) override;
112 virtual void onCheckTransferUserFields( wxCommandEvent& aEvent ) override;
113
114private:
115 void onParentSymbolSelect( wxCommandEvent& aEvent );
116
117 void syncControls( bool aIsDerivedPart );
118
119private:
121 std::function<bool( wxString newName )> m_validator;
123};
const char * name
Definition: DXF_plotter.cpp:62
Class DIALOG_LIB_NEW_SYMBOL_BASE.
SYMBOL_FILTER_COMBOBOX * m_comboInheritanceSelect
void SetIncludeOnBoard(bool aInclude)
wxString GetParentSymbolName() const
void SetPinNameInside(bool show)
void SetTransferUserFields(bool keep)
wxString GetName() const override
void SetName(const wxString &name) override
void syncControls(bool aIsDerivedPart)
bool TransferDataFromWindow() override
void SetPinTextPosition(int position)
std::function< bool(wxString newName)> m_validator
void SetIncludeInBom(bool aInclude)
void SetKeepDatasheet(bool keep)
virtual void onCheckTransferUserFields(wxCommandEvent &aEvent) override
virtual void onPowerCheckBox(wxCommandEvent &aEvent) override
void SetReference(const wxString &reference)
void SetAlternateBodyStyle(bool enable)
void SetShowPinNumber(bool show)
void SetKeepContentUserFields(bool keep)
void SetUnitsInterchangeable(bool enable)
void onParentSymbolSelect(wxCommandEvent &aEvent)
void SetPowerSymbol(bool enable)
void SetKeepFootprint(bool keep)
The base class for create windows for drawing purpose.
wxString GetValue() const override
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:54