2009-11-03 13:26:31 +00:00
|
|
|
/**********************************/
|
2010-12-07 11:42:58 +00:00
|
|
|
/* dialog_lib_edit_text.cpp */
|
2009-11-03 13:26:31 +00:00
|
|
|
/**********************************/
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Code for editing component library text items, not fields. */
|
2008-12-28 18:00:37 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2008-12-28 18:00:37 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
2008-12-28 18:00:37 +00:00
|
|
|
#include "general.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_text.h"
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2010-11-17 21:47:27 +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
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
m_Parent = aParent;
|
2010-11-17 21:47:27 +00:00
|
|
|
m_GraphicText = aText;
|
|
|
|
InitDialog();
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
void DIALOG_LIB_EDIT_TEXT::InitDialog( )
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
SetFocus();
|
|
|
|
|
|
|
|
if ( m_GraphicText )
|
|
|
|
{
|
2010-11-19 16:28:46 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_GraphicText->m_Size.x,
|
|
|
|
m_Parent->m_InternalUnits );
|
2009-09-04 18:57:37 +00:00
|
|
|
m_TextSize->SetValue( msg );
|
|
|
|
m_TextValue->SetValue( m_GraphicText->m_Text );
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
if ( m_GraphicText->GetUnit() == 0 )
|
2009-09-04 18:57:37 +00:00
|
|
|
m_CommonUnit->SetValue( TRUE );
|
2010-10-25 15:43:42 +00:00
|
|
|
if ( m_GraphicText->GetConvert() == 0 )
|
2009-09-04 18:57:37 +00:00
|
|
|
m_CommonConvert->SetValue( TRUE );
|
|
|
|
if ( m_GraphicText->m_Orient == TEXT_ORIENT_VERT )
|
|
|
|
m_Orient->SetValue( TRUE );
|
|
|
|
|
|
|
|
int shape = 0;
|
|
|
|
if ( m_GraphicText->m_Italic )
|
|
|
|
shape = 1;
|
|
|
|
if ( m_GraphicText->m_Bold )
|
|
|
|
shape |= 2;
|
|
|
|
|
|
|
|
m_TextShapeOpt->SetSelection( shape );
|
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
switch ( m_GraphicText->m_HJustify )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( m_GraphicText->m_VJustify )
|
|
|
|
{
|
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
|
|
|
|
{
|
2010-07-12 14:07:09 +00:00
|
|
|
msg = ReturnStringFromValue( g_UserUnit, m_Parent->m_textSize,
|
2009-09-04 18:57:37 +00:00
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
m_TextSize->SetValue( msg );
|
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
if ( ! m_Parent->m_drawSpecificUnit )
|
2009-09-04 18:57:37 +00:00
|
|
|
m_CommonUnit->SetValue( TRUE );
|
2009-10-19 19:00:47 +00:00
|
|
|
if ( ! m_Parent->m_drawSpecificConvert )
|
2009-09-04 18:57:37 +00:00
|
|
|
m_CommonConvert->SetValue( TRUE );
|
2009-10-19 19:00:47 +00:00
|
|
|
if ( m_Parent->m_textOrientation == TEXT_ORIENT_VERT )
|
2009-09-04 18:57:37 +00:00
|
|
|
m_Orient->SetValue( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = m_TextSizeText->GetLabel() + ReturnUnitSymbol();
|
|
|
|
m_TextSizeText->SetLabel( msg );
|
|
|
|
|
2011-04-19 16:30:28 +00:00
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
|
|
|
|
Centre();
|
2010-11-17 21:47:27 +00:00
|
|
|
|
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();
|
2010-10-22 12:11:52 +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();
|
2010-10-22 12:11:52 +00:00
|
|
|
m_Parent->m_textSize = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
|
2009-10-19 19:00:47 +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
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
if( m_GraphicText )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2010-11-17 21:47:27 +00:00
|
|
|
if( ! Line.IsEmpty() )
|
2010-10-22 12:11:52 +00:00
|
|
|
m_GraphicText->SetText( Line );
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2010-10-22 12:11:52 +00:00
|
|
|
m_GraphicText->SetText( wxT( "[null]" ) );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-19 19:00:47 +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
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
if( m_Parent->m_drawSpecificUnit )
|
2010-10-25 15:43:42 +00:00
|
|
|
m_GraphicText->SetUnit( m_Parent->GetUnit() );
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +00:00
|
|
|
m_GraphicText->SetUnit( 0 );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
if( m_Parent->m_drawSpecificConvert )
|
2010-10-25 15:43:42 +00:00
|
|
|
m_GraphicText->SetConvert( m_Parent->GetConvert() );
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +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 )
|
2009-09-04 18:57:37 +00:00
|
|
|
m_GraphicText->m_Italic = true;
|
|
|
|
else
|
|
|
|
m_GraphicText->m_Italic = false;
|
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
if( ( m_TextShapeOpt->GetSelection() & 2 ) != 0 )
|
2009-09-04 18:57:37 +00:00
|
|
|
m_GraphicText->m_Bold = true;
|
|
|
|
else
|
|
|
|
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:
|
|
|
|
m_GraphicText->m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 1:
|
|
|
|
m_GraphicText->m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
|
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 2:
|
|
|
|
m_GraphicText->m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
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:
|
|
|
|
m_GraphicText->m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 1:
|
|
|
|
m_GraphicText->m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case 2:
|
|
|
|
m_GraphicText->m_VJustify = GR_TEXT_VJUSTIFY_TOP;
|
|
|
|
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
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
if( m_Parent->GetDrawItem() )
|
2009-09-25 18:49:04 +00:00
|
|
|
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
|
|
|
}
|