2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
/* EESchema - edition des librairies: Edition des champs ( Fields ) */
|
|
|
|
/*********************************************************************/
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
/* Fichier libfield.cpp */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "drawtxt.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
#include "wx/spinctrl.h"
|
|
|
|
|
|
|
|
/* Routines locales */
|
2009-05-13 10:26:11 +00:00
|
|
|
static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
|
2009-04-14 16:45:22 +00:00
|
|
|
/* if the field is the reference, return reference like schematic, i.e U -> U? or U?A
|
|
|
|
* or the field text for others
|
|
|
|
*/
|
2009-05-13 10:26:11 +00:00
|
|
|
static wxString ReturnFieldFullText( LibDrawField* aField );
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Variables locales */
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
extern int CurrentUnit;
|
2007-06-05 12:10:51 +00:00
|
|
|
static wxPoint StartCursor, LastTextPosition;
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
static void ExitMoveField( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2008-11-24 06:53:43 +00:00
|
|
|
if( CurrentDrawItem == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
wxPoint curpos;
|
2008-04-17 16:25:29 +00:00
|
|
|
curpos = Panel->GetScreen()->m_Curseur;
|
|
|
|
Panel->GetScreen()->m_Curseur = StartCursor;
|
2008-11-24 06:53:43 +00:00
|
|
|
ShowMoveField( Panel, DC, TRUE );
|
2008-04-17 16:25:29 +00:00
|
|
|
Panel->GetScreen()->m_Curseur = curpos;
|
|
|
|
CurrentDrawItem->m_Flags = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
CurrentDrawItem = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LibDrawField* field )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Initialise le deplacement d'un champ ( ref ou Name) */
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
wxPoint startPos;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( (CurrentLibEntry == NULL) || ( field == NULL ) )
|
|
|
|
return;
|
|
|
|
CurrentDrawItem = field;
|
2008-04-17 16:25:29 +00:00
|
|
|
LastTextPosition = field->m_Pos;
|
|
|
|
CurrentDrawItem->m_Flags |= IS_MOVED;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
startPos.x = LastTextPosition.x;
|
|
|
|
startPos.y = -LastTextPosition.y;
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawPanel->CursorOff( DC );
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->m_Curseur = startPos;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawPanel->ManageCurseur = ShowMoveField;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitMoveField;
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
2008-04-17 16:25:29 +00:00
|
|
|
StartCursor = GetScreen()->m_Curseur;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-04-14 16:45:22 +00:00
|
|
|
/* if the field is the reference, return reference like schematic, i.e U -> U? or U?A
|
|
|
|
* or the field text for others
|
|
|
|
*/
|
2009-05-13 10:26:11 +00:00
|
|
|
static wxString ReturnFieldFullText( LibDrawField* aField )
|
2009-04-14 16:45:22 +00:00
|
|
|
{
|
2009-05-13 10:26:11 +00:00
|
|
|
if( aField->m_FieldId != REFERENCE )
|
2009-04-14 16:45:22 +00:00
|
|
|
return aField->m_Text;
|
|
|
|
|
|
|
|
wxString text = aField->m_Text;
|
|
|
|
|
|
|
|
if( CurrentLibEntry->m_UnitCount > 1 )
|
|
|
|
{
|
|
|
|
#if defined(KICAD_GOST)
|
2009-05-13 10:26:11 +00:00
|
|
|
text.Printf( wxT( "%s?.%c" ),
|
|
|
|
aField->m_Text.GetData(), CurrentUnit + '1' - 1 );
|
2009-04-14 16:45:22 +00:00
|
|
|
#else
|
|
|
|
|
2009-05-13 10:26:11 +00:00
|
|
|
text.Printf( wxT( "%s?%c" ),
|
|
|
|
aField->m_Text.GetData(), CurrentUnit + 'A' - 1 );
|
2009-04-14 16:45:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
text << wxT( "?" );
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2009-05-13 10:26:11 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
|
|
|
/* Routine d'affichage du texte 'Field' en cours de deplacement. */
|
|
|
|
/* Routine normalement attachee au curseur */
|
|
|
|
/*****************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
int color;
|
|
|
|
LibDrawField* Field = (LibDrawField*) CurrentDrawItem;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( (CurrentLibEntry == NULL) || (Field == NULL) )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
switch( Field->m_FieldId )
|
|
|
|
{
|
|
|
|
case VALUE:
|
|
|
|
color = ReturnLayerColor( LAYER_VALUEPART );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
case REFERENCE:
|
|
|
|
color = ReturnLayerColor( LAYER_REFERENCEPART );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
default:
|
|
|
|
color = ReturnLayerColor( LAYER_FIELDS );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-14 16:45:22 +00:00
|
|
|
wxString text = ReturnFieldFullText( Field );
|
2008-11-12 17:27:32 +00:00
|
|
|
|
2009-05-13 10:26:11 +00:00
|
|
|
int TransMat[2][2];
|
2008-11-12 17:27:32 +00:00
|
|
|
TransMat[0][0] = 1; TransMat[1][1] = -1;
|
|
|
|
TransMat[1][0] = TransMat[0][1] = 0;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( Field->m_Attributs & TEXT_NO_VISIBLE )
|
|
|
|
color = DARKGRAY;
|
2008-04-17 16:25:29 +00:00
|
|
|
if( erase )
|
2008-11-24 06:53:43 +00:00
|
|
|
Field->Draw( panel, DC, wxPoint( 0, 0 ),
|
2009-05-13 10:26:11 +00:00
|
|
|
color,
|
|
|
|
g_XorMode, &text, TransMat );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
LastTextPosition.x = panel->GetScreen()->m_Curseur.x;
|
2008-11-24 06:53:43 +00:00
|
|
|
LastTextPosition.y = -panel->GetScreen()->m_Curseur.y;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
Field->m_Pos = LastTextPosition;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
Field->Draw( panel, DC, wxPoint( 0, 0 ),
|
2009-05-13 10:26:11 +00:00
|
|
|
color,
|
|
|
|
g_XorMode, &text, TransMat );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LibDrawField* Field )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
EDA_Colors color;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( Field == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
switch( Field->m_FieldId )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
case REFERENCE:
|
|
|
|
color = ReturnLayerColor( LAYER_REFERENCEPART );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
case VALUE:
|
|
|
|
color = ReturnLayerColor( LAYER_VALUEPART );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
default:
|
|
|
|
color = ReturnLayerColor( LAYER_FIELDS );
|
|
|
|
break;
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
Field->m_Flags = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( (Field->m_Attributs & TEXT_NO_VISIBLE) != 0 )
|
|
|
|
color = DARKGRAY;
|
2008-04-17 16:25:29 +00:00
|
|
|
Field->m_Pos.x = GetScreen()->m_Curseur.x;
|
2008-11-24 06:53:43 +00:00
|
|
|
Field->m_Pos.y = -GetScreen()->m_Curseur.y;
|
|
|
|
int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth );
|
|
|
|
DrawPanel->CursorOff( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
|
|
|
|
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
|
2009-05-13 10:26:11 +00:00
|
|
|
color, ReturnFieldFullText( Field ),
|
|
|
|
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
|
|
|
|
Field->m_Size,
|
|
|
|
Field->m_HJustify, Field->m_VJustify, LineWidth );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
CurrentDrawItem = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************************/
|
|
|
|
{
|
2009-05-13 10:26:11 +00:00
|
|
|
wxString Text;
|
|
|
|
wxString title;
|
|
|
|
EDA_Colors color;
|
|
|
|
int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( Field == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
switch( Field->m_FieldId )
|
|
|
|
{
|
|
|
|
case REFERENCE:
|
|
|
|
title = wxT( "Reference:" );
|
|
|
|
color = ReturnLayerColor( LAYER_REFERENCEPART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VALUE:
|
2009-05-13 10:26:11 +00:00
|
|
|
title = wxT( "Component Name / Value:" );
|
2008-11-24 06:53:43 +00:00
|
|
|
color = ReturnLayerColor( LAYER_VALUEPART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
color = ReturnLayerColor( LAYER_FIELDS );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( Field->m_Attributs & TEXT_NO_VISIBLE )
|
|
|
|
color = DARKGRAY;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
Text = Field->m_Text;
|
2008-11-24 06:53:43 +00:00
|
|
|
Get_Message( title, _( "Edit field" ), Text, this );
|
|
|
|
Text.Replace( wxT( " " ), wxT( "_" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-05-13 10:26:11 +00:00
|
|
|
/* If the value is changed, this is equivalent to create a new component from the old one
|
|
|
|
* So we must check for an existing alias of this "new" component
|
|
|
|
* and change the value only if there is no existing alias with the same name
|
|
|
|
* for this component
|
|
|
|
*/
|
|
|
|
if( Field->m_FieldId == VALUE )
|
|
|
|
{
|
|
|
|
/* test for an existing name in alias list: */
|
|
|
|
for( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT )
|
|
|
|
{
|
|
|
|
wxString aliasname = CurrentLibEntry->m_AliasList[ii + ALIAS_NAME];
|
|
|
|
if( Text.CmpNoCase( aliasname ) == 0 )
|
|
|
|
{
|
|
|
|
DisplayError( this,
|
|
|
|
_( "This name is an existing alias of the component\nAborting" ), 10 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
GRSetDrawMode( DC, g_XorMode );
|
|
|
|
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
|
2009-05-13 10:26:11 +00:00
|
|
|
color, ReturnFieldFullText( Field ),
|
|
|
|
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
|
|
|
|
Field->m_Size,
|
|
|
|
Field->m_HJustify, Field->m_VJustify, LineWidth );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( !Text.IsEmpty() )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
SaveCopyInUndoList( CurrentLibEntry );
|
2008-04-17 16:25:29 +00:00
|
|
|
Field->m_Text = Text;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
else
|
|
|
|
DisplayError( this, _( "No new text: no change" ) );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( Field->m_Flags == 0 )
|
|
|
|
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
|
2009-05-13 10:26:11 +00:00
|
|
|
color, ReturnFieldFullText( Field ),
|
|
|
|
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
|
|
|
|
Field->m_Size,
|
|
|
|
Field->m_HJustify, Field->m_VJustify, LineWidth );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( Field->m_FieldId == VALUE )
|
|
|
|
ReCreateHToolbar();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine de modification de l'orientation ( Horiz ou Vert. ) du champ.
|
2009-05-13 10:26:11 +00:00
|
|
|
* si un champ est en cours d'edition, modif de celui ci.
|
|
|
|
* sinon Modif du champ pointe par la souris
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
EDA_Colors color;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( Field == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
switch( Field->m_FieldId )
|
|
|
|
{
|
|
|
|
case REFERENCE:
|
|
|
|
color = ReturnLayerColor( LAYER_REFERENCEPART );
|
|
|
|
break;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
case VALUE:
|
|
|
|
color = ReturnLayerColor( LAYER_VALUEPART );
|
|
|
|
break;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
default:
|
|
|
|
color = ReturnLayerColor( LAYER_FIELDS );
|
|
|
|
break;
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( (Field->m_Attributs & TEXT_NO_VISIBLE) != 0 )
|
|
|
|
color = DARKGRAY;
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, g_XorMode );
|
|
|
|
int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth );
|
|
|
|
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
|
2009-05-13 10:26:11 +00:00
|
|
|
color, ReturnFieldFullText( Field ),
|
|
|
|
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
|
|
|
|
Field->m_Size,
|
|
|
|
Field->m_HJustify, Field->m_VJustify, LineWidth );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
if( Field->m_Orient )
|
|
|
|
Field->m_Orient = 0;
|
|
|
|
else
|
|
|
|
Field->m_Orient = 1;
|
|
|
|
|
|
|
|
if( Field->m_Flags == 0 )
|
|
|
|
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
|
|
|
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
|
2009-05-13 10:26:11 +00:00
|
|
|
color, ReturnFieldFullText( Field ),
|
|
|
|
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
|
|
|
|
Field->m_Size,
|
|
|
|
Field->m_HJustify, Field->m_VJustify, LineWidth );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
LibDrawField* WinEDA_LibeditFrame::LocateField( EDA_LibComponentStruct* LibEntry )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-12 17:27:32 +00:00
|
|
|
/* Locate the component fiels (ref, name or auxiliary fields) under the mouse cursor
|
2009-05-13 10:26:11 +00:00
|
|
|
* return:
|
|
|
|
* pointer on the field (or NULL )
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-11-12 17:27:32 +00:00
|
|
|
wxPoint refpos;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-11-12 17:27:32 +00:00
|
|
|
refpos.x = GetScreen()->m_Curseur.x;
|
2008-11-24 06:53:43 +00:00
|
|
|
refpos.y = -GetScreen()->m_Curseur.y; // Y axis is from bottom to top in library
|
2008-11-12 17:27:32 +00:00
|
|
|
/* Test reference */
|
2008-11-24 06:53:43 +00:00
|
|
|
if( LibEntry->m_Name.HitTest( refpos ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
return &LibEntry->m_Name;
|
|
|
|
|
2008-11-12 17:27:32 +00:00
|
|
|
/* Test Prefix */
|
2008-11-24 06:53:43 +00:00
|
|
|
if( LibEntry->m_Prefix.HitTest( refpos ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
return &LibEntry->m_Prefix;
|
|
|
|
|
|
|
|
/* Localisation des autres fields */
|
2008-12-31 15:01:29 +00:00
|
|
|
for( LibDrawField* field = LibEntry->m_Fields; field; field = field->Next() )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
if( field->m_Text.IsEmpty() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( field->HitTest( refpos ) )
|
|
|
|
return field;
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-12-11 16:41:43 +00:00
|
|
|
/********************************************************************************/
|
|
|
|
LibEDA_BaseStruct* WinEDA_LibeditFrame::LocateItemUsingCursor()
|
|
|
|
/********************************************************************************/
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
LibEDA_BaseStruct* DrawEntry = CurrentDrawItem;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( CurrentLibEntry == NULL )
|
|
|
|
return NULL;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2009-05-13 10:26:11 +00:00
|
|
|
if( (DrawEntry == NULL) || (DrawEntry->m_Flags == 0) ) // Simple localisation des elements
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawEntry = LocatePin(
|
|
|
|
GetScreen()->m_Curseur, CurrentLibEntry, CurrentUnit, CurrentConvert );
|
|
|
|
if( DrawEntry == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) GetScreen(),
|
2009-05-13 10:26:11 +00:00
|
|
|
GetScreen()->m_MousePosition,
|
|
|
|
CurrentLibEntry, CurrentUnit,
|
|
|
|
CurrentConvert, LOCATE_ALL_DRAW_ITEM );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
if( DrawEntry == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawEntry = CurrentDrawItem = LocateDrawItem( (SCH_SCREEN*) GetScreen(),
|
2009-05-13 10:26:11 +00:00
|
|
|
GetScreen()->m_Curseur, CurrentLibEntry,
|
|
|
|
CurrentUnit,
|
|
|
|
CurrentConvert, LOCATE_ALL_DRAW_ITEM );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
if( DrawEntry == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
|
|
|
DrawEntry = CurrentDrawItem = (LibEDA_BaseStruct*)
|
2008-11-24 06:53:43 +00:00
|
|
|
LocateField( CurrentLibEntry );
|
2008-04-17 16:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return DrawEntry;
|
2007-12-11 16:41:43 +00:00
|
|
|
}
|