2009-11-03 13:26:31 +00:00
|
|
|
/**********************************/
|
|
|
|
/* edit_graphic_bodyitem_text.cpp */
|
|
|
|
/**********************************/
|
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 "program.h"
|
|
|
|
#include "general.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "protos.h"
|
|
|
|
#include "libeditfrm.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
2008-12-28 18:00:37 +00:00
|
|
|
|
|
|
|
#include "dialog_bodygraphictext_properties_base.h"
|
|
|
|
|
|
|
|
|
|
|
|
class Dialog_BodyGraphicText_Properties : public Dialog_BodyGraphicText_Properties_base
|
|
|
|
{
|
|
|
|
private:
|
2009-09-04 18:57:37 +00:00
|
|
|
WinEDA_LibeditFrame * m_Parent;
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_TEXT* m_GraphicText;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
Dialog_BodyGraphicText_Properties( WinEDA_LibeditFrame* aParent,
|
|
|
|
LIB_TEXT* aGraphicText );
|
2009-09-04 18:57:37 +00:00
|
|
|
~Dialog_BodyGraphicText_Properties() {};
|
2008-12-28 18:00:37 +00:00
|
|
|
|
|
|
|
private:
|
2009-09-04 18:57:37 +00:00
|
|
|
void InitDialog( );
|
|
|
|
void OnOkClick( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2008-12-28 18:00:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
Dialog_BodyGraphicText_Properties::Dialog_BodyGraphicText_Properties( WinEDA_LibeditFrame* aParent,
|
|
|
|
LIB_TEXT* aGraphicText ) :
|
|
|
|
Dialog_BodyGraphicText_Properties_base( aParent )
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
m_GraphicText = aGraphicText;
|
2009-06-11 14:26:17 +00:00
|
|
|
InitDialog( );
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
/*****************************************************/
|
|
|
|
void Dialog_BodyGraphicText_Properties::InitDialog( )
|
|
|
|
/*****************************************************/
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
SetFocus();
|
|
|
|
|
|
|
|
if ( m_GraphicText )
|
|
|
|
{
|
|
|
|
msg = ReturnStringFromValue(g_UnitMetric, m_GraphicText->m_Size.x,
|
|
|
|
m_Parent->m_InternalUnits);
|
|
|
|
m_TextSize->SetValue( msg );
|
|
|
|
m_TextValue->SetValue( m_GraphicText->m_Text );
|
|
|
|
|
|
|
|
if ( m_GraphicText->m_Unit == 0 )
|
|
|
|
m_CommonUnit->SetValue( TRUE );
|
|
|
|
if ( m_GraphicText->m_Convert == 0 )
|
|
|
|
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:
|
|
|
|
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_GraphicText->m_VJustify )
|
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
case GR_TEXT_VJUSTIFY_BOTTOM:
|
|
|
|
m_TextVJustificationOpt->SetSelection(0);
|
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case GR_TEXT_VJUSTIFY_CENTER:
|
|
|
|
m_TextVJustificationOpt->SetSelection(1);
|
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
case GR_TEXT_VJUSTIFY_TOP:
|
|
|
|
m_TextVJustificationOpt->SetSelection(2);
|
|
|
|
break;
|
2009-06-11 14:26:17 +00:00
|
|
|
}
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-19 19:00:47 +00:00
|
|
|
msg = ReturnStringFromValue( g_UnitMetric, 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 );
|
|
|
|
|
2008-12-28 18:00:37 +00:00
|
|
|
if (GetSizer())
|
|
|
|
{
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialog_BodyGraphicText_Properties::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
|
|
|
|
/***************************************************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Updates the different parameters for the component being edited */
|
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();
|
2009-10-19 19:00:47 +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();
|
2009-10-19 19:00:47 +00:00
|
|
|
m_Parent->m_textSize = ReturnValueFromString( g_UnitMetric, msg,
|
|
|
|
m_Parent->m_InternalUnits );
|
|
|
|
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
|
|
|
|
|
|
|
if ( m_GraphicText )
|
|
|
|
{
|
|
|
|
if ( ! Line.IsEmpty() )
|
|
|
|
m_GraphicText->m_Text = Line;
|
|
|
|
else
|
|
|
|
m_GraphicText->m_Text = wxT("[null]");
|
|
|
|
|
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 )
|
2009-09-25 18:49:04 +00:00
|
|
|
m_GraphicText->m_Unit = m_Parent->GetUnit();
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
|
|
|
m_GraphicText->m_Unit = 0;
|
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
if( m_Parent->m_drawSpecificConvert )
|
2009-09-25 18:49:04 +00:00
|
|
|
m_GraphicText->m_Convert = m_Parent->GetConvert();
|
2009-09-04 18:57:37 +00:00
|
|
|
else
|
|
|
|
m_GraphicText->m_Convert = 0;
|
|
|
|
|
|
|
|
if ( (m_TextShapeOpt->GetSelection() & 1 ) != 0 )
|
|
|
|
m_GraphicText->m_Italic = true;
|
|
|
|
else
|
|
|
|
m_GraphicText->m_Italic = false;
|
|
|
|
|
|
|
|
if ( (m_TextShapeOpt->GetSelection() & 2 ) != 0 )
|
|
|
|
m_GraphicText->m_Bold = true;
|
|
|
|
else
|
|
|
|
m_GraphicText->m_Bold = false;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
switch ( m_TextHJustificationOpt->GetSelection() )
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +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
|
|
|
}
|
|
|
|
Close();
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if ( m_Parent->GetDrawItem() )
|
|
|
|
m_Parent->GetDrawItem()->DisplayInfo( m_Parent );
|
2009-09-04 18:57:37 +00:00
|
|
|
Close();
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem)
|
2008-12-28 18:00:37 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
int DrawMode = g_XorMode;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if ( ( DrawItem == NULL )
|
|
|
|
|| ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) )
|
|
|
|
return;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Deleting old text. */
|
2009-09-04 18:57:37 +00:00
|
|
|
if( DC)
|
|
|
|
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, DrawMode, NULL,
|
|
|
|
DefaultTransformMatrix );
|
2008-12-28 18:00:37 +00:00
|
|
|
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
Dialog_BodyGraphicText_Properties * frame =
|
|
|
|
new Dialog_BodyGraphicText_Properties( this,
|
2009-10-08 13:19:28 +00:00
|
|
|
(LIB_TEXT*) DrawItem );
|
2009-09-04 18:57:37 +00:00
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
|
|
|
GetScreen()->SetModify();
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Display new text. */
|
2009-09-04 18:57:37 +00:00
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
if ( ( DrawItem->m_Flags & IS_MOVED ) == 0 )
|
|
|
|
DrawMode = GR_DEFAULT_DRAWMODE;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, DrawMode, NULL,
|
|
|
|
DefaultTransformMatrix );
|
|
|
|
}
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************/
|
|
|
|
void WinEDA_LibeditFrame::RotateSymbolText(wxDC * DC)
|
|
|
|
/****************************************************/
|
|
|
|
/*
|
2009-09-04 18:57:37 +00:00
|
|
|
90 deg Graphic text Rotation .
|
2008-12-28 18:00:37 +00:00
|
|
|
*/
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_TEXT* DrawItem = (LIB_TEXT *) m_drawItem;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
if( DrawItem == NULL )
|
|
|
|
return;
|
2008-12-28 18:00:37 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/* Erase drawing (can be within a move command) */
|
|
|
|
if ( DrawPanel->ManageCurseur == NULL)
|
|
|
|
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
|
|
|
|
DefaultTransformMatrix );
|
|
|
|
else
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
|
|
|
if( DrawItem->m_Orient == TEXT_ORIENT_HORIZ )
|
|
|
|
DrawItem->m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
else
|
|
|
|
DrawItem->m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
/* Redraw item with new orient */
|
|
|
|
if ( DrawPanel->ManageCurseur == NULL )
|
|
|
|
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE,
|
|
|
|
NULL, DefaultTransformMatrix );
|
|
|
|
else
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
2008-12-28 18:00:37 +00:00
|
|
|
}
|