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, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <widgets/unit_binder.h>
24#include <string_utils.h>
26
27class EDA_DRAW_FRAME;
28class wxArrayString;
29
31{
32public:
33 DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent, const wxArrayString& aSymbolNames,
34 const std::function<int( const wxString& aItem )>& aDisplayStyleCallback,
35 const wxString& aInheritFromSymbolName,
36 std::function<bool( const wxString& newName )> aValidator );
37
39
40 void SetName( const wxString& name ) override
41 {
42 m_textName->SetValue( UnescapeString( name ) );
43 }
44
45 wxString GetName() const override
46 {
47 wxString name = EscapeString( m_textName->GetValue(), CTX_LIBID );
48
49 // Currently, symbol names cannot include a space, that breaks libraries:
50 name.Replace( " ", "_" );
51
52 return name;
53 }
54
55 wxString GetParentSymbolName() const
56 {
57 return EscapeString( m_comboInheritanceSelect->GetValue(), CTX_LIBID );
58 }
59
60 void SetReference( const wxString& reference ) { m_textReference->SetValue( reference ); }
61 wxString GetReference() { return m_textReference->GetValue(); }
62
63 void SetPartCount( int count ) { m_spinPartCount->SetValue( count ); }
64 int GetUnitCount() { return m_spinPartCount->GetValue(); }
65
66 void SetAlternateBodyStyle( bool enable ) { m_checkHasAlternateBodyStyle->SetValue( enable ); }
68
69 void SetPowerSymbol( bool enable ) { m_checkIsPowerSymbol->SetValue( enable ); }
70 bool GetPowerSymbol() { return m_checkIsPowerSymbol->GetValue(); }
71
72 void SetUnitsInterchangeable( bool enable ) { m_checkUnitsInterchangeable->SetValue( enable ); }
74
75 void SetIncludeInBom( bool aInclude ) { m_excludeFromBomCheckBox->SetValue( !aInclude ); }
76 bool GetIncludeInBom() const { return !m_excludeFromBomCheckBox->GetValue(); }
77
78 void SetIncludeOnBoard( bool aInclude ) { m_excludeFromBoardCheckBox->SetValue( !aInclude ); }
79 bool GetIncludeOnBoard() const { return !m_excludeFromBoardCheckBox->GetValue(); }
80
81 void SetPinTextPosition( int position ) { m_pinTextPosition.SetValue( position ); }
82 int GetPinTextPosition() { return m_pinTextPosition.GetValue(); }
83
84 void SetKeepDatasheet( bool keep ) { m_checkKeepDatasheet->SetValue( keep ); }
85 bool GetKeepDatasheet() { return m_checkKeepDatasheet->GetValue(); }
86
87 void SetKeepFootprint( bool keep ) { m_checkKeepFootprint->SetValue( keep ); }
88 bool GetKeepFootprint() { return m_checkKeepFootprint->GetValue(); }
89
90 void SetTransferUserFields( bool keep ) { m_checkTransferUserFields->SetValue( keep ); }
91 bool GetTransferUserFields() { return m_checkTransferUserFields->GetValue(); }
92
93 void SetKeepContentUserFields( bool keep ) { m_checkKeepContentUserFields->SetValue( keep ); }
95
96 void SetShowPinNumber( bool show ) { m_checkShowPinNumber->SetValue( show ); }
97 bool GetShowPinNumber() { return m_checkShowPinNumber->GetValue(); }
98
99 void SetShowPinName( bool show ) { m_checkShowPinName->SetValue( show ); }
100 bool GetShowPinName() { return m_checkShowPinName->GetValue(); }
101
102 void SetPinNameInside( bool show ) { m_checkShowPinNameInside->SetValue( show ); }
103 bool GetPinNameInside() { return m_checkShowPinNameInside->GetValue(); }
104
105protected:
106 bool TransferDataToWindow() override;
107 bool TransferDataFromWindow() override;
108
109 virtual void onPowerCheckBox( wxCommandEvent& aEvent ) override;
110 virtual void onCheckTransferUserFields( wxCommandEvent& aEvent ) override;
111
112private:
113 void onParentSymbolSelect( wxCommandEvent& aEvent );
114
115 void syncControls( bool aIsDerivedPart );
116
117private:
119 std::function<bool( const wxString& newName )> m_validator;
122};
const char * name
DIALOG_LIB_NEW_SYMBOL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("New Symbol"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
SYMBOL_FILTER_COMBOBOX * m_comboInheritanceSelect
void SetIncludeOnBoard(bool aInclude)
wxString GetParentSymbolName() const
void SetTransferUserFields(bool keep)
wxString GetName() const override
std::function< bool(const wxString &newName)> m_validator
void SetName(const wxString &name) override
DIALOG_LIB_NEW_SYMBOL(EDA_DRAW_FRAME *aParent, const wxArrayString &aSymbolNames, const std::function< int(const wxString &aItem)> &aDisplayStyleCallback, const wxString &aInheritFromSymbolName, std::function< bool(const wxString &newName)> aValidator)
void syncControls(bool aIsDerivedPart)
void SetPinTextPosition(int position)
void SetIncludeInBom(bool aInclude)
virtual void onCheckTransferUserFields(wxCommandEvent &aEvent) override
virtual void onPowerCheckBox(wxCommandEvent &aEvent) override
void SetReference(const wxString &reference)
void SetAlternateBodyStyle(bool enable)
void SetKeepContentUserFields(bool keep)
void SetUnitsInterchangeable(bool enable)
void onParentSymbolSelect(wxCommandEvent &aEvent)
void SetPowerSymbol(bool enable)
The base class for create windows for drawing purpose.
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