KiCad PCB EDA Suite
dialog_edit_one_field.h
Go to the documentation of this file.
1 
2 #ifndef DIALOG_EDIT_ONE_FIELD_H_
3 #define DIALOG_EDIT_ONE_FIELD_H_
4 
5 /*
6  * This program source code file is part of KiCad, a free EDA CAD application.
7  *
8  * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
9  * Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com
10  * Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, you may find one here:
24  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25  * or you may search the http://www.gnu.org website for the version 2 license,
26  * or you may write to the Free Software Foundation, Inc.,
27  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28  */
29 
31 #include <widgets/unit_binder.h>
32 #include <lib_field.h>
33 #include <class_libentry.h>
34 #include <template_fieldnames.h>
35 
36 class SCH_BASE_FRAME;
37 class SCH_FIELD;
38 class EDA_TEXT;
39 class SCINTILLA_TRICKS;
40 
41 
52 {
53 public:
54  DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxString& aTitle,
55  const EDA_TEXT* aTextItem );
56 
57  ~DIALOG_EDIT_ONE_FIELD() override;
58 
59  bool TransferDataToWindow() override;
60  bool TransferDataFromWindow() override;
61 
62  SCH_BASE_FRAME* GetParent() { return dynamic_cast< SCH_BASE_FRAME* >( wxDialog::GetParent() ); }
63 
64  const wxString& GetText() const { return m_text; }
65 
66 protected:
67  void init();
68 
69  void updateText( EDA_TEXT* aText );
70 
80  void OnTextValueSelectButtonClick( wxCommandEvent& aEvent ) override;
81 
87  virtual void OnSetFocusText( wxFocusEvent& event ) override;
88 
92 
93  int m_fieldId;
94  bool m_isPower;
95  wxString m_text;
96  bool m_isItalic;
97  bool m_isBold;
98  wxPoint m_position;
99  int m_size;
104 
106 };
107 
108 
117 {
118 public:
119  DIALOG_LIB_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxString& aTitle,
120  const LIB_FIELD* aField );
121 
123 
124  void UpdateField( LIB_FIELD* aField )
125  {
126  aField->SetText( m_text );
127 
128  // VALUE === component name, so update the parent component if it changes.
129  if( aField->GetId() == VALUE_FIELD && aField->GetParent() )
130  aField->GetParent()->SetName( m_text );
131 
132  updateText( aField );
133  }
134 };
135 
136 
145 {
146 public:
147  DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxString& aTitle,
148  const SCH_FIELD* aField );
149 
151 
152  void onScintillaCharAdded( wxStyledTextEvent &aEvent );
153 
154  void UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH* aSheetPath );
155 
156 private:
158 };
159 
160 #endif // DIALOG_EDIT_ONE_FIELD_H_
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
SCINTILLA_TRICKS * m_scintillaTricks
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
SCINTILLA_TRICKS is used to add cut/copy/paste, autocomplete and brace highlighting to a wxStyleTextC...
LIB_PART * GetParent() const
Definition: lib_item.h:183
Field object used in symbol libraries.
Definition: lib_field.h:59
void UpdateField(LIB_FIELD *aField)
void UpdateField(SCH_FIELD *aField, SCH_SHEET_PATH *aSheetPath)
int GetId() const
Definition: lib_field.h:138
DIALOG_EDIT_ONE_FIELD(SCH_BASE_FRAME *aParent, const wxString &aTitle, const EDA_TEXT *aTextItem)
Field Value of part, i.e. "3.3K".
DIALOG_SCH_EDIT_ONE_FIELD(SCH_BASE_FRAME *aParent, const wxString &aTitle, const SCH_FIELD *aField)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:119
DIALOG_LIB_EDIT_ONE_FIELD(SCH_BASE_FRAME *aParent, const wxString &aTitle, const LIB_FIELD *aField)
DIALOG_EDIT_ONE_FIELD is a base class to edit schematic and component library fields.
DIALOG_LIB_EDIT_ONE_FIELD is a the class to handle editing a single component field in the library ed...
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const wxString & GetText() const
DIALOG_SCH_EDIT_ONE_FIELD is a the class to handle editing a single component field in the schematic ...
bool TransferDataToWindow() override
void updateText(EDA_TEXT *aText)
Class DIALOG_LIB_EDIT_TEXT_BASE.
SCH_BASE_FRAME * GetParent()
void OnTextValueSelectButtonClick(wxCommandEvent &aEvent) override
Function OnTextValueSelectButtonClick Handles the select button next to the text value field.
bool TransferDataFromWindow() override
virtual void SetName(const wxString &aName)
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void OnSetFocusText(wxFocusEvent &event) override
Used to select the variant part of some text fields (for instance, the question mark or number in a r...