diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index a2a169a1de..d8280119a5 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -50,6 +50,7 @@ set(EESCHEMA_SRCS dialogs/dialog_edit_label_base.cpp dialogs/dialog_edit_libentry_fields_in_lib.cpp dialogs/dialog_edit_libentry_fields_in_lib_base.cpp + dialogs/dialog_lib_edit_one_field.cpp dialogs/dialog_eeschema_config.cpp dialogs/dialog_eeschema_config_fbp.cpp dialogs/dialog_eeschema_options_base.cpp diff --git a/eeschema/dialogs/dialog_lib_edit_one_field.cpp b/eeschema/dialogs/dialog_lib_edit_one_field.cpp new file mode 100644 index 0000000000..212bc75315 --- /dev/null +++ b/eeschema/dialogs/dialog_lib_edit_one_field.cpp @@ -0,0 +1,208 @@ +/** + * @file dialog_lib_edit_one_field.cpp + * @brief dialog to editing fields ( not graphic texts) in components. + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + + +DIALOG_LIB_EDIT_ONE_FIELD::DIALOG_LIB_EDIT_ONE_FIELD( LIB_EDIT_FRAME* aParent, + const wxString& aTitle, + LIB_FIELD* aField ) : + DIALOG_LIB_EDIT_TEXT_BASE( aParent ) +{ + m_parent = aParent; + m_field = aField; + SetTitle( aTitle ); + initDlg(); + + GetSizer()->SetSizeHints(this); + Centre(); +} + + +void DIALOG_LIB_EDIT_ONE_FIELD::initDlg( ) +{ + wxString msg; + + m_TextValue->SetFocus(); + + // Disable options for graphic text edition, not existing in fields + m_CommonConvert->Show(false); + m_CommonUnit->Show(false); + + if ( m_field ) + { + msg = ReturnStringFromValue( g_UserUnit, m_field->m_Size.x, + m_parent->GetInternalUnits() ); + m_TextSize->SetValue( msg ); + m_TextValue->SetValue( m_field->m_Text ); + + if( m_field->GetOrientation() == TEXT_ORIENT_VERT ) + m_Orient->SetValue( true ); + + if( m_field->GetOrientation() == TEXT_ORIENT_VERT ) + m_Orient->SetValue( true ); + + m_Invisible->SetValue( m_field->IsVisible() ? false : true); + + int shape = 0; + if( m_field->m_Italic ) + shape = 1; + if( m_field->m_Bold ) + shape |= 2; + + m_TextShapeOpt->SetSelection( shape ); + + switch ( m_field->m_HJustify ) + { + case GR_TEXT_HJUSTIFY_LEFT: + m_TextHJustificationOpt->SetSelection( 0 ); + break; + + case GR_TEXT_HJUSTIFY_CENTER: + m_TextHJustificationOpt->SetSelection( 1 ); + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + m_TextHJustificationOpt->SetSelection( 2 ); + break; + + } + + switch ( m_field->m_VJustify ) + { + case GR_TEXT_VJUSTIFY_BOTTOM: + m_TextVJustificationOpt->SetSelection( 0 ); + break; + + case GR_TEXT_VJUSTIFY_CENTER: + m_TextVJustificationOpt->SetSelection( 1 ); + break; + + case GR_TEXT_VJUSTIFY_TOP: + m_TextVJustificationOpt->SetSelection( 2 ); + break; + } + } + + msg = m_TextSizeText->GetLabel() + ReturnUnitSymbol(); + m_TextSizeText->SetLabel( msg ); + + m_sdbSizerButtonsOK->SetDefault(); +} + + +void DIALOG_LIB_EDIT_ONE_FIELD::OnCancelClick( wxCommandEvent& event ) +{ + EndModal(wxID_CANCEL); +} + + +/* Updates the different parameters for the component being edited */ +void DIALOG_LIB_EDIT_ONE_FIELD::OnOkClick( wxCommandEvent& event ) +{ + EndModal(wxID_OK); +} + +wxString DIALOG_LIB_EDIT_ONE_FIELD::GetTextField() +{ + wxString line = m_TextValue->GetValue(); + line.Replace( wxT( " " ), wxT( "_" ) ); + return line; +}; + +void DIALOG_LIB_EDIT_ONE_FIELD::TransfertDataToField() +{ + + int orientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; + wxString msg = m_TextSize->GetValue(); + int textSize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + + if( m_field ) + { + m_field->SetText( GetTextField() ); + + m_field->m_Size.x = m_field->m_Size.y = textSize; + m_field->m_Orient = orientation; + + if( m_Invisible->GetValue() ) + m_field->m_Attributs |= TEXT_NO_VISIBLE; + else + m_field->m_Attributs &= ~TEXT_NO_VISIBLE; + + if( ( m_TextShapeOpt->GetSelection() & 1 ) != 0 ) + m_field->m_Italic = true; + else + m_field->m_Italic = false; + + if( ( m_TextShapeOpt->GetSelection() & 2 ) != 0 ) + m_field->m_Bold = true; + else + m_field->m_Bold = false; + + switch( m_TextHJustificationOpt->GetSelection() ) + { + case 0: + m_field->m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + break; + + case 1: + m_field->m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + break; + + case 2: + m_field->m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + break; + } + + switch( m_TextVJustificationOpt->GetSelection() ) + { + case 0: + m_field->m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + + case 1: + m_field->m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + break; + + case 2: + m_field->m_VJustify = GR_TEXT_VJUSTIFY_TOP; + break; + } + } +} diff --git a/eeschema/dialogs/dialog_lib_edit_one_field.h b/eeschema/dialogs/dialog_lib_edit_one_field.h new file mode 100644 index 0000000000..2d68a408a5 --- /dev/null +++ b/eeschema/dialogs/dialog_lib_edit_one_field.h @@ -0,0 +1,32 @@ + +#ifndef _DIALOG_LIB_EDIT_ONE_FIELD_H_ +#define _DIALOG_LIB_EDIT_ONE_FIELD_H_ + + +#include + + +class LIB_EDIT_FRAME; +class LIB_FIELD; + + +class DIALOG_LIB_EDIT_ONE_FIELD : public DIALOG_LIB_EDIT_TEXT_BASE +{ +private: + LIB_EDIT_FRAME* m_parent; + LIB_FIELD* m_field; + +public: + DIALOG_LIB_EDIT_ONE_FIELD( LIB_EDIT_FRAME* aParent, const wxString& aTitle, LIB_FIELD* aField ); + ~DIALOG_LIB_EDIT_ONE_FIELD() {}; + void TransfertDataToField(); + wxString GetTextField(); + +private: + void initDlg( ); + void OnOkClick( wxCommandEvent& aEvent ); + void OnCancelClick( wxCommandEvent& aEvent ); +}; + + +#endif // _DIALOG_LIB_EDIT_ONE_FIELD_H_ diff --git a/eeschema/dialogs/dialog_lib_edit_text.cpp b/eeschema/dialogs/dialog_lib_edit_text.cpp index aedd4825fa..b2cc18c6d1 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text.cpp @@ -1,6 +1,6 @@ /** * @file dialog_lib_edit_text.cpp - * @brief dialog to editing graphic texts (not fields) in bodu components. + * @brief dialog to editing graphic texts (not fields) in body components. */ /* @@ -43,8 +43,8 @@ DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT( LIB_EDIT_FRAME* aParent, LIB_TEXT* aText ) : DIALOG_LIB_EDIT_TEXT_BASE( aParent ) { - m_Parent = aParent; - m_GraphicText = aText; + m_parent = aParent; + m_graphicText = aText; initDlg(); GetSizer()->SetSizeHints(this); @@ -58,29 +58,32 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( ) m_TextValue->SetFocus(); - if ( m_GraphicText ) - { - msg = ReturnStringFromValue( g_UserUnit, m_GraphicText->m_Size.x, - m_Parent->GetInternalUnits() ); - m_TextSize->SetValue( msg ); - m_TextValue->SetValue( m_GraphicText->m_Text ); + // Disable options for fieldedition, not existing in graphic text + m_Invisible->Show(false); - if ( m_GraphicText->GetUnit() == 0 ) + if ( m_graphicText ) + { + msg = ReturnStringFromValue( g_UserUnit, m_graphicText->m_Size.x, + m_parent->GetInternalUnits() ); + m_TextSize->SetValue( msg ); + m_TextValue->SetValue( m_graphicText->m_Text ); + + if ( m_graphicText->GetUnit() == 0 ) m_CommonUnit->SetValue( true ); - if ( m_GraphicText->GetConvert() == 0 ) + if ( m_graphicText->GetConvert() == 0 ) m_CommonConvert->SetValue( true ); - if ( m_GraphicText->m_Orient == TEXT_ORIENT_VERT ) + if ( m_graphicText->m_Orient == TEXT_ORIENT_VERT ) m_Orient->SetValue( true ); int shape = 0; - if ( m_GraphicText->m_Italic ) + if ( m_graphicText->m_Italic ) shape = 1; - if ( m_GraphicText->m_Bold ) + if ( m_graphicText->m_Bold ) shape |= 2; m_TextShapeOpt->SetSelection( shape ); - switch ( m_GraphicText->m_HJustify ) + switch ( m_graphicText->m_HJustify ) { case GR_TEXT_HJUSTIFY_LEFT: m_TextHJustificationOpt->SetSelection( 0 ); @@ -96,7 +99,7 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( ) } - switch ( m_GraphicText->m_VJustify ) + switch ( m_graphicText->m_VJustify ) { case GR_TEXT_VJUSTIFY_BOTTOM: m_TextVJustificationOpt->SetSelection( 0 ); @@ -113,15 +116,15 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( ) } else { - msg = ReturnStringFromValue( g_UserUnit, m_Parent->m_textSize, - m_Parent->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, m_parent->m_textSize, + m_parent->GetInternalUnits() ); m_TextSize->SetValue( msg ); - if ( ! m_Parent->m_drawSpecificUnit ) + if ( ! m_parent->m_drawSpecificUnit ) m_CommonUnit->SetValue( true ); - if ( ! m_Parent->m_drawSpecificConvert ) + if ( ! m_parent->m_drawSpecificConvert ) m_CommonConvert->SetValue( true ); - if ( m_Parent->m_textOrientation == TEXT_ORIENT_VERT ) + if ( m_parent->m_textOrientation == TEXT_ORIENT_VERT ) m_Orient->SetValue( true ); } @@ -144,75 +147,75 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event ) wxString Line; Line = m_TextValue->GetValue(); - m_Parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; + m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; wxString msg = m_TextSize->GetValue(); - m_Parent->m_textSize = ReturnValueFromString( g_UserUnit, msg, m_Parent->GetInternalUnits() ); - m_Parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; - m_Parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true; + m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ); + m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; + m_parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true; - if( m_GraphicText ) + if( m_graphicText ) { if( ! Line.IsEmpty() ) - m_GraphicText->SetText( Line ); + m_graphicText->SetText( Line ); else - m_GraphicText->SetText( wxT( "[null]" ) ); + m_graphicText->SetText( wxT( "[null]" ) ); - m_GraphicText->m_Size.x = m_GraphicText->m_Size.y = m_Parent->m_textSize; - m_GraphicText->m_Orient = m_Parent->m_textOrientation; + m_graphicText->m_Size.x = m_graphicText->m_Size.y = m_parent->m_textSize; + m_graphicText->m_Orient = m_parent->m_textOrientation; - if( m_Parent->m_drawSpecificUnit ) - m_GraphicText->SetUnit( m_Parent->GetUnit() ); + if( m_parent->m_drawSpecificUnit ) + m_graphicText->SetUnit( m_parent->GetUnit() ); else - m_GraphicText->SetUnit( 0 ); + m_graphicText->SetUnit( 0 ); - if( m_Parent->m_drawSpecificConvert ) - m_GraphicText->SetConvert( m_Parent->GetConvert() ); + if( m_parent->m_drawSpecificConvert ) + m_graphicText->SetConvert( m_parent->GetConvert() ); else - m_GraphicText->SetConvert( 0 ); + m_graphicText->SetConvert( 0 ); if( ( m_TextShapeOpt->GetSelection() & 1 ) != 0 ) - m_GraphicText->m_Italic = true; + m_graphicText->m_Italic = true; else - m_GraphicText->m_Italic = false; + m_graphicText->m_Italic = false; if( ( m_TextShapeOpt->GetSelection() & 2 ) != 0 ) - m_GraphicText->m_Bold = true; + m_graphicText->m_Bold = true; else - m_GraphicText->m_Bold = false; + m_graphicText->m_Bold = false; switch( m_TextHJustificationOpt->GetSelection() ) { case 0: - m_GraphicText->m_HJustify = GR_TEXT_HJUSTIFY_LEFT; + m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_LEFT; break; case 1: - m_GraphicText->m_HJustify = GR_TEXT_HJUSTIFY_CENTER; + m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_CENTER; break; case 2: - m_GraphicText->m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; break; } switch( m_TextVJustificationOpt->GetSelection() ) { case 0: - m_GraphicText->m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; + m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; break; case 1: - m_GraphicText->m_VJustify = GR_TEXT_VJUSTIFY_CENTER; + m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_CENTER; break; case 2: - m_GraphicText->m_VJustify = GR_TEXT_VJUSTIFY_TOP; + m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_TOP; break; } } - if( m_Parent->GetDrawItem() ) - m_Parent->GetDrawItem()->DisplayInfo( m_Parent ); + if( m_parent->GetDrawItem() ) + m_parent->GetDrawItem()->DisplayInfo( m_parent ); EndModal(wxID_OK); } diff --git a/eeschema/dialogs/dialog_lib_edit_text.h b/eeschema/dialogs/dialog_lib_edit_text.h index 774e26ddff..6fe9a7de7b 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.h +++ b/eeschema/dialogs/dialog_lib_edit_text.h @@ -13,8 +13,8 @@ class LIB_TEXT; class DIALOG_LIB_EDIT_TEXT : public DIALOG_LIB_EDIT_TEXT_BASE { private: - LIB_EDIT_FRAME* m_Parent; - LIB_TEXT* m_GraphicText; + LIB_EDIT_FRAME* m_parent; + LIB_TEXT* m_graphicText; public: DIALOG_LIB_EDIT_TEXT( LIB_EDIT_FRAME* aParent, LIB_TEXT* aText ); diff --git a/eeschema/dialogs/dialog_lib_edit_text_base.cpp b/eeschema/dialogs/dialog_lib_edit_text_base.cpp index e412e96a40..98c2f02c4c 100644 --- a/eeschema/dialogs/dialog_lib_edit_text_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 17 2010) +// C++ code generated with wxFormBuilder (version Jun 30 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -68,6 +68,9 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to convert"), wxDefaultPosition, wxDefaultSize, 0 ); sOptionsSizer->Add( m_CommonConvert, 0, wxALL|wxEXPAND, 5 ); + m_Invisible = new wxCheckBox( this, wxID_ANY, _("Invisible"), wxDefaultPosition, wxDefaultSize, 0 ); + sOptionsSizer->Add( m_Invisible, 0, wxALL, 5 ); + bBottomtBoxSizer->Add( sOptionsSizer, 0, wxALL|wxEXPAND, 5 ); wxString m_TextShapeOptChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") }; diff --git a/eeschema/dialogs/dialog_lib_edit_text_base.fbp b/eeschema/dialogs/dialog_lib_edit_text_base.fbp index f89979b0dc..4432364728 100644 --- a/eeschema/dialogs/dialog_lib_edit_text_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_text_base.fbp @@ -7,6 +7,7 @@ 1 source_name 0 + res UTF-8 connect dialog_lib_edit_text_base @@ -28,6 +29,7 @@ 1 0 + 1 @@ -50,8 +52,10 @@ 0 wxID_ANY + 0 + 0 1 @@ -80,6 +84,12 @@ + + + + + + @@ -150,6 +160,7 @@ 1 1 + 1 @@ -170,8 +181,10 @@ wxID_ANY Text: + 0 + 0 1 @@ -234,6 +247,7 @@ 1 1 + 1 @@ -253,9 +267,11 @@ 0 wxID_ANY + 0 0 + 0 200,-1 1 @@ -333,6 +349,7 @@ 1 1 + 1 @@ -353,8 +370,10 @@ wxID_ANY Size + 0 + 0 1 @@ -417,6 +436,7 @@ 1 1 + 1 @@ -436,9 +456,11 @@ 0 wxID_ANY + 0 0 + 0 1 @@ -530,6 +552,7 @@ 1 1 + 1 @@ -551,8 +574,10 @@ wxID_ANY Vertical + 0 + 0 1 @@ -615,6 +640,7 @@ 1 1 + 1 @@ -634,8 +660,10 @@ 0 wxID_ANY + 0 + 0 1 @@ -697,6 +725,7 @@ 1 1 + 1 @@ -718,8 +747,10 @@ wxID_ANY Common to Units + 0 + 0 1 @@ -782,6 +813,7 @@ 1 1 + 1 @@ -803,8 +835,10 @@ wxID_ANY Common to convert + 0 + 0 1 @@ -857,6 +891,94 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Invisible + + + 0 + + + 0 + + 1 + m_Invisible + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -869,6 +991,7 @@ 1 1 + 1 @@ -891,8 +1014,10 @@ Text Shape: 1 + 0 + 0 1 @@ -956,6 +1081,7 @@ 1 1 + 1 @@ -978,8 +1104,10 @@ Horiz. Justify 1 + 0 + 0 1 @@ -1043,6 +1171,7 @@ 1 1 + 1 @@ -1065,8 +1194,10 @@ Vert. Justify 1 + 0 + 0 1 diff --git a/eeschema/dialogs/dialog_lib_edit_text_base.h b/eeschema/dialogs/dialog_lib_edit_text_base.h index 493ee1bc28..d234ac2657 100644 --- a/eeschema/dialogs/dialog_lib_edit_text_base.h +++ b/eeschema/dialogs/dialog_lib_edit_text_base.h @@ -1,15 +1,16 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 17 2010) +// C++ code generated with wxFormBuilder (version Jun 30 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __dialog_lib_edit_text_base__ -#define __dialog_lib_edit_text_base__ +#ifndef __DIALOG_LIB_EDIT_TEXT_BASE_H__ +#define __DIALOG_LIB_EDIT_TEXT_BASE_H__ +#include +#include #include - #include #include #include @@ -43,6 +44,7 @@ class DIALOG_LIB_EDIT_TEXT_BASE : public wxDialog wxStaticLine* m_staticline1; wxCheckBox* m_CommonUnit; wxCheckBox* m_CommonConvert; + wxCheckBox* m_Invisible; wxRadioBox* m_TextShapeOpt; wxRadioBox* m_TextHJustificationOpt; wxRadioBox* m_TextVJustificationOpt; @@ -62,4 +64,4 @@ class DIALOG_LIB_EDIT_TEXT_BASE : public wxDialog }; -#endif //__dialog_lib_edit_text_base__ +#endif //__DIALOG_LIB_EDIT_TEXT_BASE_H__ diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index a4fd1ba319..7d8f161d96 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -206,7 +206,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition ) case LIB_FIELD_T: if( m_drawItem->GetFlags() == 0 ) { - EditField( DC, (LIB_FIELD*) m_drawItem ); + EditField( (LIB_FIELD*) m_drawItem ); } break; diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 7d12b81505..c0b4d2c69d 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -775,7 +775,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( m_drawItem->Type() == LIB_FIELD_T ) { - EditField( &dc, (LIB_FIELD*) m_drawItem ); + EditField( (LIB_FIELD*) m_drawItem ); } m_canvas->MoveCursorToCrossHair(); @@ -992,7 +992,7 @@ void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event ) INSTALL_UNBUFFERED_DC( dc, m_canvas ); m_canvas->CrossHairOff( &dc ); - EditField( &dc, &m_component->GetValueField() ); + EditField( &m_component->GetValueField() ); m_canvas->MoveCursorToCrossHair(); m_canvas->CrossHairOn( &dc ); } diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index a6c63da557..3841c47e01 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -515,7 +515,7 @@ private: void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem ); LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition, const KICAD_T aFilterList[] = LIB_COLLECTOR::AllItems ); - void EditField( wxDC* DC, LIB_FIELD* Field ); + void EditField( LIB_FIELD* Field ); public: /** diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index 1aa7e32184..dc50df4935 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -13,9 +13,10 @@ #include #include #include +#include -void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField ) +void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) { wxString text; wxString title; @@ -36,19 +37,17 @@ void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField ) } else { - caption = _( "Edit Field" ); + caption.Printf( _( "Edit Field %s" ), GetChars( aField->GetName() ) ); title.Printf( _( "Enter a new value for the %s field." ), GetChars( aField->GetName().Lower() ) ); } - wxTextEntryDialog dlg( this, title, caption, aField->m_Text ); + DIALOG_LIB_EDIT_ONE_FIELD dlg( this, caption, aField ); - if( dlg.ShowModal() != wxID_OK || dlg.GetValue() == aField->m_Text ) + if( dlg.ShowModal() != wxID_OK ) return; - text = dlg.GetValue(); - - text.Replace( wxT( " " ), wxT( "_" ) ); + text = dlg.GetTextField(); // Perform some controls: if( ( aField->GetId() == REFERENCE || aField->GetId() == VALUE ) && text.IsEmpty ( ) ) @@ -72,7 +71,7 @@ void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField ) * the old one. Rename the component and remove any conflicting aliases to prevent name * errors when updating the library. */ - if( aField->GetId() == VALUE ) + if( (aField->GetId() == VALUE) && ( text != aField->m_Text ) ) { wxString msg; @@ -142,19 +141,12 @@ this component?" ), } if( !aField->InEditMode() ) - { SaveCopyInUndoList( parent ); - ( (LIB_ITEM*) aField )->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, g_XorMode, - &fieldText, DefaultTransform ); - } + // Update field + dlg.TransfertDataToField(); - if( !aField->InEditMode() ) - { - fieldText = aField->GetFullText( m_unit ); - ( (LIB_ITEM*) aField )->Draw( m_canvas, DC, wxPoint( 0, 0 ), -1, g_XorMode, - &fieldText, DefaultTransform ); - } + m_canvas->Refresh(); OnModify(); UpdateAliasSelectList();