2007-09-13 11:28:58 +00:00
|
|
|
/*********************************************************************/
|
2009-06-26 12:52:24 +00:00
|
|
|
/* EESchema */
|
2007-09-13 11:28:58 +00:00
|
|
|
/* edit_label.cpp: label, global label and text creation or edition */
|
|
|
|
/*********************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-05-30 16:06:01 +00:00
|
|
|
#include "base_struct.h"
|
|
|
|
#include "drawtxt.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "dialog_edit_label.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Fonctions locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Variables locales */
|
|
|
|
static wxPoint ItemInitialPosition;
|
2007-08-20 01:20:48 +00:00
|
|
|
static int OldOrient;
|
|
|
|
static wxSize OldSize;
|
|
|
|
static int s_DefaultShapeGLabel = (int) NET_INPUT;
|
|
|
|
static int s_DefaultOrientGLabel = 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2008-12-19 20:40:08 +00:00
|
|
|
void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString text;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
/* save old text in undo list if not already in edit */
|
|
|
|
if( m_CurrentText->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
text = m_TextLabel->GetValue();
|
|
|
|
if( !text.IsEmpty() )
|
|
|
|
m_CurrentText->m_Text = text;
|
|
|
|
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
|
|
|
|
DisplayError( this, _( "Empty Text!" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
|
2007-08-20 01:20:48 +00:00
|
|
|
text = m_TextSize->GetValue();
|
|
|
|
value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits );
|
|
|
|
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
|
|
|
|
if( m_TextShape )
|
|
|
|
m_CurrentText->m_Shape = m_TextShape->GetSelection();
|
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
int style = m_TextStyle->GetSelection();
|
2009-06-26 12:52:24 +00:00
|
|
|
if( ( style & 1 ) )
|
2008-12-19 20:40:08 +00:00
|
|
|
m_CurrentText->m_Italic = 1;
|
|
|
|
else
|
|
|
|
m_CurrentText->m_Italic = 0;
|
|
|
|
|
2009-06-26 12:52:24 +00:00
|
|
|
if( ( style & 2 ) )
|
2009-05-30 16:06:01 +00:00
|
|
|
{
|
2009-06-26 12:52:24 +00:00
|
|
|
m_CurrentText->m_Bold = true;
|
2009-05-30 16:06:01 +00:00
|
|
|
m_CurrentText->m_Width = GetPenSizeForBold( m_CurrentText->m_Size.x );
|
|
|
|
}
|
2008-12-19 20:40:08 +00:00
|
|
|
else
|
2009-05-30 16:06:01 +00:00
|
|
|
{
|
2009-06-26 12:52:24 +00:00
|
|
|
m_CurrentText->m_Bold = false;
|
2009-05-30 16:06:01 +00:00
|
|
|
m_CurrentText->m_Width = 0;
|
|
|
|
}
|
2008-12-19 20:40:08 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Parent->GetScreen()->SetModify();
|
|
|
|
|
|
|
|
/* Make the text size as new default size if it is a new text */
|
|
|
|
if( (m_CurrentText->m_Flags & IS_NEW) != 0 )
|
|
|
|
g_DefaultTextLabelSize = m_CurrentText->m_Size.x;
|
|
|
|
|
2007-11-07 04:24:25 +00:00
|
|
|
m_Parent->DrawPanel->MouseToCursorSchema();
|
|
|
|
EndModal( 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( TextStruct == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
|
|
|
|
if( (TextStruct->m_Flags & IS_NEW) == 0 )
|
|
|
|
{
|
|
|
|
delete g_ItemToUndoCopy;
|
|
|
|
g_ItemToUndoCopy = TextStruct->GenCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStruct->m_Flags |= IS_MOVED;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( TextStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_TEXT:
|
2007-08-20 01:20:48 +00:00
|
|
|
ItemInitialPosition = TextStruct->m_Pos;
|
|
|
|
OldSize = TextStruct->m_Size;
|
2009-05-12 12:12:34 +00:00
|
|
|
OldOrient = TextStruct->GetSchematicTextOrientation();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->m_Curseur = ItemInitialPosition;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
DrawPanel->ManageCurseur = ShowWhileMoving;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitMoveTexte;
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->SetCurItem( TextStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct,
|
2008-04-14 19:22:48 +00:00
|
|
|
wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
/* Edit the properties of the text (Label, Global label, graphic text).. )
|
2007-08-20 01:20:48 +00:00
|
|
|
* pointed by "TextStruct"
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( TextStruct == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-10 20:02:51 +00:00
|
|
|
DialogLabelEditor::ShowModally( this, TextStruct );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE );
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( TextStruct == NULL )
|
2008-03-20 01:50:21 +00:00
|
|
|
TextStruct = (SCH_TEXT*) PickStruct( GetScreen()->m_Curseur,
|
2009-06-26 12:52:24 +00:00
|
|
|
GetScreen(), TEXTITEM | LABELITEM );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( TextStruct == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* save old text in undo list if is not already in edit */
|
|
|
|
if( TextStruct->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( TextStruct, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Effacement du texte en cours */
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
|
|
|
|
|
|
|
|
/* Rotation du texte */
|
2009-05-12 12:12:34 +00:00
|
|
|
int orient;
|
2009-06-26 12:52:24 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( TextStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_TEXT:
|
2009-06-26 12:52:24 +00:00
|
|
|
orient = TextStruct->GetSchematicTextOrientation() + 1;
|
2009-05-12 12:12:34 +00:00
|
|
|
orient &= 3;
|
|
|
|
TextStruct->SetSchematicTextOrientation( orient );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
/* Reaffichage */
|
|
|
|
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Routine to create new text struct (GraphicText, label or Glabel).
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT* NewText = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
|
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
case LAYER_NOTES:
|
2008-03-20 01:50:21 +00:00
|
|
|
NewText = new SCH_TEXT( GetScreen()->m_Curseur );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_LOCLABEL:
|
2008-03-20 01:50:21 +00:00
|
|
|
NewText = new SCH_LABEL( GetScreen()->m_Curseur );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case LAYER_HIERLABEL:
|
2008-04-14 19:22:48 +00:00
|
|
|
NewText = new SCH_HIERLABEL( GetScreen()->m_Curseur );
|
2009-06-26 12:52:24 +00:00
|
|
|
NewText->m_Shape = s_DefaultShapeGLabel;
|
2009-05-12 12:12:34 +00:00
|
|
|
NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
|
2008-02-12 21:12:46 +00:00
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case LAYER_GLOBLABEL:
|
2008-04-14 19:22:48 +00:00
|
|
|
NewText = new SCH_GLOBALLABEL( GetScreen()->m_Curseur );
|
2009-06-26 12:52:24 +00:00
|
|
|
NewText->m_Shape = s_DefaultShapeGLabel;
|
2009-05-12 12:12:34 +00:00
|
|
|
NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-09-13 11:28:58 +00:00
|
|
|
DisplayError( this, wxT( "WinEDA_SchematicFrame::CreateNewText() Internal error" ) );
|
|
|
|
return NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
|
|
|
|
NewText->m_Flags = IS_NEW | IS_MOVED;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, NewText, g_XorMode );
|
|
|
|
EditSchematicText( NewText, DC );
|
|
|
|
|
|
|
|
if( NewText->m_Text.IsEmpty() )
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SAFE_DELETE( NewText );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
s_DefaultShapeGLabel = NewText->m_Shape;
|
2009-05-12 12:12:34 +00:00
|
|
|
s_DefaultOrientGLabel = NewText->GetSchematicTextOrientation();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE );
|
|
|
|
DrawPanel->ManageCurseur = ShowWhileMoving;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitMoveTexte;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->SetCurItem( NewText );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
return NewText;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/************************************/
|
2007-09-19 15:29:50 +00:00
|
|
|
/* Redraw a Text while moving */
|
2007-09-13 11:28:58 +00:00
|
|
|
/************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* TextStruct = (SCH_ITEM*) panel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* "Undraw" the current text at its old position*/
|
2007-08-20 01:20:48 +00:00
|
|
|
if( erase )
|
|
|
|
RedrawOneStruct( panel, DC, TextStruct, g_XorMode );
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* redraw the text */
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( TextStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
( (SCH_TEXT*) TextStruct )->m_Pos = panel->GetScreen()->m_Curseur;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RedrawOneStruct( panel, DC, TextStruct, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************/
|
2007-09-19 15:29:50 +00:00
|
|
|
/* Abort function for the command move text */
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-06-26 12:52:24 +00:00
|
|
|
BASE_SCREEN* screen = Panel->GetScreen();
|
|
|
|
SCH_ITEM* Struct = (SCH_ITEM*) screen->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
if( Struct == NULL ) /* no current item */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* "Undraw" the text, and delete it if new (i.e. it was beiing just created)*/
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( Panel, DC, Struct, g_XorMode );
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
if( Struct->m_Flags & IS_NEW )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SAFE_DELETE( Struct );
|
2007-08-20 01:20:48 +00:00
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
}
|
2007-09-19 15:29:50 +00:00
|
|
|
else /* this was a move command on an "old" text: restore its old settings. */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Struct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_TEXT:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT* Text = (SCH_TEXT*) Struct;
|
2009-06-26 12:52:24 +00:00
|
|
|
Text->m_Pos = ItemInitialPosition;
|
|
|
|
Text->m_Size = OldSize;
|
2009-05-12 12:12:34 +00:00
|
|
|
Text->SetSchematicTextOrientation( OldOrient );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-06-26 12:52:24 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RedrawOneStruct( Panel, DC, Struct, GR_DEFAULT_DRAWMODE );
|
|
|
|
Struct->m_Flags = 0;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
|
2007-08-20 01:20:48 +00:00
|
|
|
wxDC* DC, int newtype )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine to change a text type to an other one (GraphicText, label or Glabel).
|
2008-02-21 12:21:01 +00:00
|
|
|
* A new test, label or hierarchical or global label is created from the old text.
|
2007-09-13 11:28:58 +00:00
|
|
|
* the old text is deleted
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT* newtext;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
switch( newtype )
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
newtext = new SCH_LABEL( Text->m_Pos, Text->m_Text );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
2008-04-14 19:22:48 +00:00
|
|
|
newtext = new SCH_GLOBALLABEL( Text->m_Pos, Text->m_Text );
|
2008-03-20 01:50:21 +00:00
|
|
|
break;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_HIERLABEL:
|
2008-04-14 19:22:48 +00:00
|
|
|
newtext = new SCH_HIERLABEL( Text->m_Pos, Text->m_Text );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
newtext = new SCH_TEXT( Text->m_Pos, Text->m_Text );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-09-13 11:28:58 +00:00
|
|
|
newtext = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, wxT( "ConvertTextType: Internal error" ) );
|
2007-09-13 11:28:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-26 12:52:24 +00:00
|
|
|
/* copy the old text settings
|
|
|
|
* Justifications are not copied because they are not used in labels,
|
|
|
|
* and can be used in texts
|
|
|
|
* So they will be set to default in conversion.
|
|
|
|
*/
|
|
|
|
newtext->m_Shape = Text->m_Shape;
|
2009-05-12 12:12:34 +00:00
|
|
|
newtext->SetSchematicTextOrientation( Text->GetSchematicTextOrientation() );
|
2009-06-26 12:52:24 +00:00
|
|
|
newtext->m_Size = Text->m_Size;
|
|
|
|
newtext->m_Width = Text->m_Width;
|
|
|
|
newtext->m_Italic = Text->m_Italic;
|
|
|
|
newtext->m_Bold = Text->m_Bold;
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
|
|
|
// save current text flag:
|
|
|
|
int flags = Text->m_Flags;
|
|
|
|
|
|
|
|
/* add the new text in linked list if old text is in list */
|
|
|
|
if( (flags & IS_NEW) == 0 )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
newtext->SetNext( GetScreen()->EEDrawList );
|
2007-09-13 11:28:58 +00:00
|
|
|
GetScreen()->EEDrawList = newtext;
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now delete the old text
|
|
|
|
* If it is a text flagged IS_NEW it will be deleted by ForceCloseManageCurseur()
|
|
|
|
* If not, we must delete it.
|
|
|
|
*/
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
|
|
|
|
}
|
2008-02-21 12:21:01 +00:00
|
|
|
if( (flags & IS_NEW) == 0 ) // Remove old text from current list and save it in undo list
|
2007-09-13 11:28:58 +00:00
|
|
|
{
|
|
|
|
Text->m_Flags = 0;
|
2008-02-21 12:21:01 +00:00
|
|
|
DeleteStruct( DrawPanel, DC, Text ); // old text is really saved in undo list
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-09-13 11:28:58 +00:00
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
}
|
2008-02-21 15:50:35 +00:00
|
|
|
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-09-13 11:28:58 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
2007-09-13 11:28:58 +00:00
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
|
|
|
|
|
|
|
/* Save the new text in undo list if the old text was not itself a "new created text"
|
|
|
|
* In this case, the old text is already in undo list as a deleted item
|
|
|
|
* Of course if the old text was a "new created text" the new text will be put in undo list
|
|
|
|
* later, at the end of the current command (if not aborted)
|
|
|
|
*/
|
|
|
|
if( (flags & IS_NEW) == 0 )
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( newtext, UR_NEW );
|
2007-09-13 11:28:58 +00:00
|
|
|
}
|
|
|
|
else
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
|
|
|
GetScreen()->SetCurItem( newtext );
|
2007-09-13 11:28:58 +00:00
|
|
|
newtext->m_Flags = IS_NEW;
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
2007-09-13 11:28:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
if( (flags & IS_MOVED) != 0 )
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->SetCurItem( newtext );
|
2007-09-13 11:28:58 +00:00
|
|
|
StartMoveTexte( newtext, DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
RedrawOneStruct( DrawPanel, DC, newtext, GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOn( DC ); // redraw schematic cursor
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|