2011-11-12 09:51:06 +00:00
|
|
|
/**
|
|
|
|
* @file dialog_lib_edit_text.cpp
|
2012-02-21 17:47:30 +00:00
|
|
|
* @brief dialog to editing graphic texts (not fields) in body components.
|
2011-11-12 09:51:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 20011 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2004-2011 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
|
|
|
|
*/
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <class_libentry.h>
|
|
|
|
#include <lib_text.h>
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_lib_edit_text.h>
|
2008-12-28 18:00:37 +00:00
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT( LIB_EDIT_FRAME* aParent, LIB_TEXT* aText ) :
|
2010-11-17 21:47:27 +00:00
|
|
|
DIALOG_LIB_EDIT_TEXT_BASE( aParent )
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2012-02-21 17:47:30 +00:00
|
|
|
m_parent = aParent;
|
|
|
|
m_graphicText = aText;
|
2011-11-12 09:51:06 +00:00
|
|
|
initDlg();
|
|
|
|
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
Centre();
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-12 09:51:06 +00:00
|
|
|
void DIALOG_LIB_EDIT_TEXT::initDlg( )
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2011-11-12 09:51:06 +00:00
|
|
|
m_TextValue->SetFocus();
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
// Disable options for fieldedition, not existing in graphic text
|
|
|
|
m_Invisible->Show(false);
|
|
|
|
|
|
|
|
if ( m_graphicText )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2012-04-13 18:51:24 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_graphicText->m_Size.x );
|
2009-09-04 18:57:37 +00:00
|
|
|
m_TextSize->SetValue( msg );
|
2012-02-21 17:47:30 +00:00
|
|
|
m_TextValue->SetValue( m_graphicText->m_Text );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( m_graphicText->GetUnit() == 0 )
|
2012-01-22 17:20:22 +00:00
|
|
|
m_CommonUnit->SetValue( true );
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( m_graphicText->GetConvert() == 0 )
|
2012-01-22 17:20:22 +00:00
|
|
|
m_CommonConvert->SetValue( true );
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( m_graphicText->m_Orient == TEXT_ORIENT_VERT )
|
2012-01-22 17:20:22 +00:00
|
|
|
m_Orient->SetValue( true );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
|
|
int shape = 0;
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( m_graphicText->m_Italic )
|
2009-09-04 18:57:37 +00:00
|
|
|
shape = 1;
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( m_graphicText->m_Bold )
|
2009-09-04 18:57:37 +00:00
|
|
|
shape |= 2;
|
|
|
|
|
|
|
|
m_TextShapeOpt->SetSelection( shape );
|
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
switch ( m_graphicText->m_HJustify )
|
2009-06-11 14:26:17 +00:00
|
|
|
{
|
|
|
|
case GR_TEXT_HJUSTIFY_LEFT:
|
2010-11-17 21:47:27 +00:00
|
|
|
m_TextHJustificationOpt->SetSelection( 0 );
|
2009-06-11 14:26:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GR_TEXT_HJUSTIFY_CENTER:
|
2010-11-17 21:47:27 +00:00
|
|
|
m_TextHJustificationOpt->SetSelection( 1 );
|
2009-06-11 14:26:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GR_TEXT_HJUSTIFY_RIGHT:
|
2010-11-17 21:47:27 +00:00
|
|
|
m_TextHJustificationOpt->SetSelection( 2 );
|
2009-06-11 14:26:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
switch ( m_graphicText->m_VJustify )
|
2009-06-11 14:26:17 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
case GR_TEXT_VJUSTIFY_BOTTOM:
|
2010-11-17 21:47:27 +00:00
|
|
|
m_TextVJustificationOpt->SetSelection( 0 );
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case GR_TEXT_VJUSTIFY_CENTER:
|
2010-11-17 21:47:27 +00:00
|
|
|
m_TextVJustificationOpt->SetSelection( 1 );
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case GR_TEXT_VJUSTIFY_TOP:
|
2010-11-17 21:47:27 +00:00
|
|
|
m_TextVJustificationOpt->SetSelection( 2 );
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
}
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-13 18:51:24 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_parent->m_textSize );
|
2009-09-04 18:57:37 +00:00
|
|
|
m_TextSize->SetValue( msg );
|
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( ! m_parent->m_drawSpecificUnit )
|
2012-01-22 17:20:22 +00:00
|
|
|
m_CommonUnit->SetValue( true );
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( ! m_parent->m_drawSpecificConvert )
|
2012-01-22 17:20:22 +00:00
|
|
|
m_CommonConvert->SetValue( true );
|
2012-02-21 17:47:30 +00:00
|
|
|
if ( m_parent->m_textOrientation == TEXT_ORIENT_VERT )
|
2012-01-22 17:20:22 +00:00
|
|
|
m_Orient->SetValue( true );
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msg = m_TextSizeText->GetLabel() + ReturnUnitSymbol();
|
|
|
|
m_TextSizeText->SetLabel( msg );
|
|
|
|
|
2011-04-19 16:30:28 +00:00
|
|
|
m_sdbSizerButtonsOK->SetDefault();
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
void DIALOG_LIB_EDIT_TEXT::OnCancelClick( wxCommandEvent& event )
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2010-12-07 11:42:58 +00:00
|
|
|
EndModal(wxID_CANCEL);
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Updates the different parameters for the component being edited */
|
2010-11-17 21:47:27 +00:00
|
|
|
void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
wxString Line;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
Line = m_TextValue->GetValue();
|
2012-02-21 17:47:30 +00:00
|
|
|
m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
|
2009-09-04 18:57:37 +00:00
|
|
|
wxString msg = m_TextSize->GetValue();
|
2012-04-16 17:39:32 +00:00
|
|
|
m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg );
|
2012-02-21 17:47:30 +00:00
|
|
|
m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
|
|
|
|
m_parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
if( m_graphicText )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2010-11-17 21:47:27 +00:00
|
|
|
if( ! Line.IsEmpty() )
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->SetText( Line );
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->SetText( wxT( "[null]" ) );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_Size.x = m_graphicText->m_Size.y = m_parent->m_textSize;
|
|
|
|
m_graphicText->m_Orient = m_parent->m_textOrientation;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
if( m_parent->m_drawSpecificUnit )
|
|
|
|
m_graphicText->SetUnit( m_parent->GetUnit() );
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->SetUnit( 0 );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
if( m_parent->m_drawSpecificConvert )
|
|
|
|
m_graphicText->SetConvert( m_parent->GetConvert() );
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->SetConvert( 0 );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
if( ( m_TextShapeOpt->GetSelection() & 1 ) != 0 )
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_Italic = true;
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_Italic = false;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
if( ( m_TextShapeOpt->GetSelection() & 2 ) != 0 )
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_Bold = true;
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_Bold = false;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
switch( m_TextHJustificationOpt->GetSelection() )
|
2009-06-11 14:26:17 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
case 0:
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 1:
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 2:
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
switch( m_TextVJustificationOpt->GetSelection() )
|
2009-06-11 14:26:17 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
case 0:
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 1:
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 2:
|
2012-02-21 17:47:30 +00:00
|
|
|
m_graphicText->m_VJustify = GR_TEXT_VJUSTIFY_TOP;
|
2009-09-04 18:57:37 +00:00
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
}
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2012-02-21 17:47:30 +00:00
|
|
|
if( m_parent->GetDrawItem() )
|
|
|
|
m_parent->GetDrawItem()->DisplayInfo( m_parent );
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2010-12-07 11:42:58 +00:00
|
|
|
EndModal(wxID_OK);
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|