Eeschema: Add better dialog to edit an existing field of the current edited component.
This commit is contained in:
parent
718b25656c
commit
0a68744e2d
|
@ -50,7 +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_edit_one_field.cpp
|
||||
dialogs/dialog_eeschema_config.cpp
|
||||
dialogs/dialog_eeschema_config_fbp.cpp
|
||||
dialogs/dialog_eeschema_options_base.cpp
|
||||
|
|
|
@ -0,0 +1,252 @@
|
|||
/**
|
||||
* @file dialog_lib_edit_one_field.cpp
|
||||
* @brief dialog to editing a field ( not a graphic text) in current component.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Jean-Pierre Charras, jean-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 <fctsys.h>
|
||||
#include <common.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <sch_base_frame.h>
|
||||
#include <sch_component.h>
|
||||
#include <template_fieldnames.h>
|
||||
#include <class_libentry.h>
|
||||
#include <lib_field.h>
|
||||
#include <sch_component.h>
|
||||
#include <template_fieldnames.h>
|
||||
|
||||
#include <dialog_edit_one_field.h>
|
||||
|
||||
|
||||
void DIALOG_EDIT_ONE_FIELD::initDlg_base( )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
m_TextValue->SetFocus();
|
||||
|
||||
// Disable options for graphic text edition, not existing in fields
|
||||
m_CommonConvert->Show(false);
|
||||
m_CommonUnit->Show(false);
|
||||
|
||||
msg = ReturnStringFromValue( g_UserUnit, m_textsize,
|
||||
m_parent->GetInternalUnits() );
|
||||
m_TextSize->SetValue( msg );
|
||||
|
||||
if( m_textorient == TEXT_ORIENT_VERT )
|
||||
m_Orient->SetValue( true );
|
||||
|
||||
m_Invisible->SetValue( m_text_invisible );
|
||||
m_TextShapeOpt->SetSelection( m_textshape );
|
||||
|
||||
switch ( m_textHjustify )
|
||||
{
|
||||
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_textVjustify )
|
||||
{
|
||||
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::initDlg( )
|
||||
{
|
||||
m_textsize = m_field->m_Size.x;
|
||||
m_TextValue->SetValue( m_field->m_Text );
|
||||
|
||||
m_textorient = m_field->GetOrientation();
|
||||
|
||||
m_text_invisible = m_field->IsVisible() ? false : true;
|
||||
|
||||
m_textshape = 0;
|
||||
if( m_field->m_Italic )
|
||||
m_textshape = 1;
|
||||
if( m_field->m_Bold )
|
||||
m_textshape |= 2;
|
||||
|
||||
m_textHjustify = m_field->m_HJustify;
|
||||
m_textVjustify = m_field->m_VJustify;
|
||||
|
||||
initDlg_base( );
|
||||
}
|
||||
|
||||
wxString DIALOG_LIB_EDIT_ONE_FIELD::GetTextField()
|
||||
{
|
||||
wxString line = m_TextValue->GetValue();
|
||||
// Spaces are not allowed in fields, so replace them by '_'
|
||||
line.Replace( wxT( " " ), wxT( "_" ) );
|
||||
return line;
|
||||
};
|
||||
|
||||
void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
|
||||
{
|
||||
m_textorient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
|
||||
wxString msg = m_TextSize->GetValue();
|
||||
m_textsize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
|
||||
|
||||
switch( m_TextHJustificationOpt->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
m_textHjustify = GR_TEXT_HJUSTIFY_LEFT;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_textHjustify = GR_TEXT_HJUSTIFY_CENTER;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
m_textHjustify = GR_TEXT_HJUSTIFY_RIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
switch( m_TextVJustificationOpt->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
m_textVjustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_textVjustify = GR_TEXT_VJUSTIFY_CENTER;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
m_textVjustify = GR_TEXT_VJUSTIFY_TOP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DIALOG_LIB_EDIT_ONE_FIELD::TransfertDataToField()
|
||||
{
|
||||
DIALOG_EDIT_ONE_FIELD::TransfertDataToField();
|
||||
|
||||
m_field->SetText( GetTextField() );
|
||||
|
||||
m_field->m_Size.x = m_field->m_Size.y = m_textsize;
|
||||
m_field->m_Orient = m_textorient;
|
||||
|
||||
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;
|
||||
|
||||
m_field->m_HJustify = m_textHjustify;
|
||||
m_field->m_VJustify = m_textVjustify;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SCH_EDIT_ONE_FIELD::initDlg( )
|
||||
{
|
||||
m_textsize = m_field->m_Size.x;
|
||||
m_TextValue->SetValue( m_field->m_Text );
|
||||
m_textorient = m_field->GetOrientation();
|
||||
m_text_invisible = m_field->IsVisible() ? false : true;
|
||||
|
||||
m_textshape = 0;
|
||||
if( m_field->m_Italic )
|
||||
m_textshape = 1;
|
||||
if( m_field->m_Bold )
|
||||
m_textshape |= 2;
|
||||
|
||||
m_textHjustify = m_field->m_HJustify;
|
||||
m_textVjustify = m_field->m_VJustify;
|
||||
|
||||
initDlg_base( );
|
||||
}
|
||||
|
||||
|
||||
wxString DIALOG_SCH_EDIT_ONE_FIELD::GetTextField()
|
||||
{
|
||||
wxString line = m_TextValue->GetValue();
|
||||
line.Trim( true );
|
||||
line.Trim( false );
|
||||
return line;
|
||||
};
|
||||
|
||||
void DIALOG_SCH_EDIT_ONE_FIELD::TransfertDataToField()
|
||||
{
|
||||
DIALOG_EDIT_ONE_FIELD::TransfertDataToField();
|
||||
|
||||
m_field->SetText( GetTextField() );
|
||||
|
||||
m_field->m_Size.x = m_field->m_Size.y = m_textsize;
|
||||
m_field->m_Orient = m_textorient;
|
||||
|
||||
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;
|
||||
|
||||
m_field->m_HJustify = m_textHjustify;
|
||||
m_field->m_VJustify = m_textVjustify;
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
|
||||
#ifndef _DIALOG_EDIT_ONE_FIELD_H_
|
||||
#define _DIALOG_EDIT_ONE_FIELD_H_
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Jean-Pierre Charras, jean-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 <dialog_lib_edit_text_base.h>
|
||||
|
||||
|
||||
class SCH_BASE_FRAME;
|
||||
class LIB_FIELD;
|
||||
class SCH_FIELD;
|
||||
|
||||
// Basic class to edit a field: a schematic or a lib component field
|
||||
class DIALOG_EDIT_ONE_FIELD : public DIALOG_LIB_EDIT_TEXT_BASE
|
||||
{
|
||||
protected:
|
||||
SCH_BASE_FRAME* m_parent;
|
||||
int m_textshape;
|
||||
int m_textsize;
|
||||
int m_textorient;
|
||||
EDA_TEXT_HJUSTIFY_T m_textHjustify;
|
||||
EDA_TEXT_VJUSTIFY_T m_textVjustify;
|
||||
bool m_text_invisible;
|
||||
|
||||
public:
|
||||
DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxString& aTitle ):
|
||||
DIALOG_LIB_EDIT_TEXT_BASE( aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
SetTitle( aTitle );
|
||||
}
|
||||
|
||||
~DIALOG_EDIT_ONE_FIELD() {};
|
||||
virtual void TransfertDataToField();
|
||||
|
||||
void SetTextField( const wxString& aText )
|
||||
{
|
||||
m_TextValue->SetValue( aText );
|
||||
}
|
||||
|
||||
protected:
|
||||
void initDlg_base( );
|
||||
void OnOkClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
void OnCancelClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Class to edit a lib component field
|
||||
class DIALOG_LIB_EDIT_ONE_FIELD : public DIALOG_EDIT_ONE_FIELD
|
||||
{
|
||||
private:
|
||||
LIB_FIELD* m_field;
|
||||
|
||||
public:
|
||||
DIALOG_LIB_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
||||
LIB_FIELD* aField ):
|
||||
DIALOG_EDIT_ONE_FIELD( aParent, aTitle )
|
||||
{
|
||||
m_field = aField;
|
||||
initDlg();
|
||||
GetSizer()->SetSizeHints(this);
|
||||
Centre();
|
||||
}
|
||||
|
||||
~DIALOG_LIB_EDIT_ONE_FIELD() {};
|
||||
|
||||
void TransfertDataToField();
|
||||
wxString GetTextField();
|
||||
|
||||
private:
|
||||
void initDlg( );
|
||||
};
|
||||
|
||||
// Class to edit a schematic component field
|
||||
class DIALOG_SCH_EDIT_ONE_FIELD : public DIALOG_EDIT_ONE_FIELD
|
||||
{
|
||||
private:
|
||||
SCH_FIELD* m_field;
|
||||
|
||||
public:
|
||||
DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent,
|
||||
const wxString& aTitle, SCH_FIELD* aField ):
|
||||
DIALOG_EDIT_ONE_FIELD( aParent, aTitle )
|
||||
{
|
||||
m_field = aField;
|
||||
initDlg();
|
||||
GetSizer()->SetSizeHints(this);
|
||||
Centre();
|
||||
}
|
||||
~DIALOG_SCH_EDIT_ONE_FIELD() {};
|
||||
|
||||
void TransfertDataToField();
|
||||
wxString GetTextField();
|
||||
|
||||
private:
|
||||
void initDlg( );
|
||||
};
|
||||
|
||||
|
||||
#endif // _DIALOG_EDIT_ONE_FIELD_H_
|
|
@ -1,208 +0,0 @@
|
|||
/**
|
||||
* @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 <fctsys.h>
|
||||
#include <common.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <libeditframe.h>
|
||||
#include <sch_component.h>
|
||||
#include <template_fieldnames.h>
|
||||
#include <class_libentry.h>
|
||||
#include <lib_field.h>
|
||||
|
||||
#include <dialog_lib_edit_one_field.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
|
||||
#ifndef _DIALOG_LIB_EDIT_ONE_FIELD_H_
|
||||
#define _DIALOG_LIB_EDIT_ONE_FIELD_H_
|
||||
|
||||
|
||||
#include <dialog_lib_edit_text_base.h>
|
||||
|
||||
|
||||
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_
|
|
@ -39,6 +39,8 @@
|
|||
#include <class_library.h>
|
||||
#include <sch_component.h>
|
||||
|
||||
#include <dialog_edit_one_field.h>
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField, wxDC* aDC )
|
||||
{
|
||||
|
@ -79,65 +81,68 @@ create a new power component with the new value." ), GetChars( entry->GetName()
|
|||
wxString title;
|
||||
title.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) );
|
||||
|
||||
wxTextEntryDialog dlg( this, wxEmptyString , title, newtext );
|
||||
// wxTextEntryDialog dlg( this, wxEmptyString , title, newtext );
|
||||
if( aField->GetText().IsEmpty() ) // Means the field was not already in use
|
||||
{
|
||||
aField->m_Pos = component->GetPosition();
|
||||
aField->m_Size.x = aField->m_Size.y = m_TextFieldSize;
|
||||
}
|
||||
DIALOG_SCH_EDIT_ONE_FIELD dlg( this, title, aField );
|
||||
|
||||
int response = dlg.ShowModal();
|
||||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
m_canvas->SetIgnoreMouseEvents( false );
|
||||
newtext = dlg.GetValue( );
|
||||
newtext.Trim( true );
|
||||
newtext.Trim( false );
|
||||
newtext = dlg.GetTextField( );
|
||||
|
||||
if ( response != wxID_OK || newtext == aField->GetText() )
|
||||
if ( response != wxID_OK )
|
||||
return; // canceled by user
|
||||
|
||||
aField->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
// make some tests
|
||||
bool can_update = true;
|
||||
if( !newtext.IsEmpty() )
|
||||
{
|
||||
if( aField->GetText().IsEmpty() ) // Means the field was not already in use
|
||||
{
|
||||
aField->m_Pos = component->GetPosition();
|
||||
aField->m_Size.x = aField->m_Size.y = m_TextFieldSize;
|
||||
}
|
||||
|
||||
if( fieldNdx == REFERENCE )
|
||||
{
|
||||
// Test is reference is acceptable:
|
||||
if( SCH_COMPONENT::IsReferenceStringValid( newtext ) )
|
||||
{
|
||||
component->SetRef( m_CurrentSheet, newtext );
|
||||
aField->SetText( newtext );
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayError( this, _( "Illegal reference string! No change" ) );
|
||||
can_update = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aField->m_Text = newtext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fieldNdx == REFERENCE )
|
||||
{
|
||||
DisplayError( this, _( "The reference field cannot be empty! No change" ) );
|
||||
can_update = false;
|
||||
}
|
||||
else if( fieldNdx == VALUE )
|
||||
{
|
||||
DisplayError( this, _( "The value field cannot be empty! No change" ) );
|
||||
can_update = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
aField->m_Text = wxT( "~" );
|
||||
dlg.SetTextField( wxT( "~" ) );
|
||||
}
|
||||
}
|
||||
|
||||
aField->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
if( can_update )
|
||||
{
|
||||
aField->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
dlg.TransfertDataToField();
|
||||
aField->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
OnModify();
|
||||
}
|
||||
|
||||
component->DisplayInfo( this );
|
||||
OnModify();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <libeditframe.h>
|
||||
#include <class_library.h>
|
||||
#include <template_fieldnames.h>
|
||||
#include <dialog_lib_edit_one_field.h>
|
||||
#include <dialog_edit_one_field.h>
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
|
||||
|
|
Loading…
Reference in New Issue