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 class HTML_MESSAGE_BOX;
37 
38 
40 {
41 public:
42  DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem );
44 
45  void SetTitle( const wxString& aTitle ) override
46  {
47  // This class is shared for numerous tasks: a couple of single line labels and
48  // multi-line text fields. Since the desired size of the multi-line text field editor
49  // is often larger, we retain separate sizes based on the dialog titles.
50  switch( m_CurrentText->Type() )
51  {
52  case SCH_GLOBAL_LABEL_T:
53  case SCH_HIER_LABEL_T:
54  case SCH_LABEL_T:
55  // labels can share retained settings probably.
56  break;
57 
58  default:
59  m_hash_key = TO_UTF8( aTitle );
60  m_hash_key += typeid(*this).name();
61  }
62 
63  DIALOG_LABEL_EDITOR_BASE::SetTitle( aTitle );
64  }
65 
66 private:
67  void onScintillaCharAdded( wxStyledTextEvent &aEvent );
68 
69  void OnEnterKey( wxCommandEvent& aEvent ) override;
70  void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override;
71 
72  bool TransferDataToWindow() override;
73  bool TransferDataFromWindow() override;
74 
77  wxWindow* m_activeTextCtrl;
78  wxTextEntry* m_activeTextEntry;
82 
84 };
85 
86 
87 
88 #endif // DIALOG_LABEL_EDITOR_H_
void SetTitle(const wxString &aTitle) override
wxTextEntry * m_activeTextEntry
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.
Class DIALOG_LABEL_EDITOR_BASE.
SCH_EDIT_FRAME * m_Parent
DIALOG_LABEL_EDITOR(SCH_EDIT_FRAME *parent, SCH_TEXT *aTextItem)
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:100
void OnFormattingHelp(wxHyperlinkEvent &aEvent) override
SCH_NETNAME_VALIDATOR m_netNameValidator
Definitions of control validators for schematic dialogs.
SCINTILLA_TRICKS * m_scintillaTricks
HTML_MESSAGE_BOX.
bool TransferDataFromWindow() override
HTML_MESSAGE_BOX * m_helpWindow
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193