KiCad PCB EDA Suite
dialog_edit_label.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) 2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef DIALOG_LABEL_EDITOR_H_
25 #define DIALOG_LABEL_EDITOR_H_
26 
27 #include <widgets/unit_binder.h>
28 #include <sch_text.h>
29 #include <sch_validators.h>
30 #include <dialog_edit_label_base.h>
31 
32 
33 class SCH_EDIT_FRAME;
34 class SCH_TEXT;
35 class SCINTILLA_TRICKS;
36 
37 
39 {
40 public:
41  DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem );
43 
44  void SetTitle( const wxString& aTitle ) override
45  {
46  // This class is shared for numerous tasks: a couple of single line labels and
47  // multi-line text fields. Since the desired size of the multi-line text field editor
48  // is often larger, we retain separate sizes based on the dialog titles.
49  switch( m_CurrentText->Type() )
50  {
51  case SCH_GLOBAL_LABEL_T:
52  case SCH_HIER_LABEL_T:
53  case SCH_LABEL_T:
54  // labels can share retained settings probably.
55  break;
56 
57  default:
58  m_hash_key = TO_UTF8( aTitle );
59  m_hash_key += typeid(*this).name();
60  }
61 
62  DIALOG_LABEL_EDITOR_BASE::SetTitle( aTitle );
63  }
64 
65 private:
66  void onScintillaCharAdded( wxStyledTextEvent &aEvent );
67 
68  void OnEnterKey( wxCommandEvent& aEvent ) override;
69  void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override;
70 
71  bool TransferDataToWindow() override;
72  bool TransferDataFromWindow() override;
73 
74  wxString convertKIIDsToReferences( const wxString& aSource ) const;
75 
76  wxString convertReferencesToKIIDs( const wxString& aSource ) const;
77 
80  wxWindow* m_activeTextCtrl;
81  wxTextEntry* m_activeTextEntry;
85 };
86 
87 
88 
89 #endif // DIALOG_LABEL_EDITOR_H_
void SetTitle(const wxString &aTitle) override
wxTextEntry * m_activeTextEntry
wxString convertKIIDsToReferences(const wxString &aSource) const
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
std::string m_hash_key
Definition: dialog_shim.h:198
SCINTILLA_TRICKS is used to add cut/copy/paste, autocomplete and brace highlighting to a wxStyleTextC...
void OnEnterKey(wxCommandEvent &aEvent) override
bool TransferDataToWindow() override
Schematic editor (Eeschema) main window.
wxString convertReferencesToKIIDs(const wxString &aSource) const
Class DIALOG_LABEL_EDITOR_BASE.
SCH_EDIT_FRAME * m_Parent
DIALOG_LABEL_EDITOR(SCH_EDIT_FRAME *parent, SCH_TEXT *aTextItem)
void OnFormattingHelp(wxHyperlinkEvent &aEvent) override
SCH_NETNAME_VALIDATOR m_netNameValidator
Definitions of control validators for schematic dialogs.
SCINTILLA_TRICKS * m_scintillaTricks
bool TransferDataFromWindow() override
#define TO_UTF8(wxstring)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193