Commit 61cf3762 authored by Alain Portal's avatar Alain Portal Committed by Wayne Stambaugh
Browse files

Apply patch from Alain Portal to fix bug 570074 and other minor updates.

* Removed redundant empty string test, thanks again Alain.
* Minor code cleaning.
parent 762e625c
Loading
Loading
Loading
Loading
+32 −48
Original line number Original line Diff line number Diff line
@@ -18,12 +18,12 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC );
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );




/******************************************************************************/
void WinEDA_SchematicFrame::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC )
{
/******************************************************************************/
/******************************************************************************/
/* Prepare the displacement of the text being edited.
/* Prepare the displacement of the text being edited.
 */
 */
/******************************************************************************/
void WinEDA_SchematicFrame::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC )
{
    LIB_COMPONENT* Entry;
    LIB_COMPONENT* Entry;


    SetCurrentField( aField );
    SetCurrentField( aField );
@@ -81,11 +81,11 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC )
}
}




/******************************************************************************/
/* Edit the field Field (text, size)  */
/******************************************************************************/
/******************************************************************************/
void WinEDA_SchematicFrame::EditCmpFieldText( SCH_FIELD* Field, wxDC* DC )
void WinEDA_SchematicFrame::EditCmpFieldText( SCH_FIELD* Field, wxDC* DC )
{
{
/******************************************************************************/
/* Edit the field Field (text, size)  */
    int            fieldNdx, flag;
    int            fieldNdx, flag;
    LIB_COMPONENT* Entry;
    LIB_COMPONENT* Entry;


@@ -122,7 +122,6 @@ modified!\nYou must create a new power" ) );
        }
        }
    }
    }



    /* save old cmp in undo list if not already in edit, or moving ... */
    /* save old cmp in undo list if not already in edit, or moving ... */
    if( Field->m_Flags == 0 )
    if( Field->m_Flags == 0 )
        SaveCopyInUndoList( Cmp, UR_CHANGED );
        SaveCopyInUndoList( Cmp, UR_CHANGED );
@@ -171,12 +170,11 @@ modified!\nYou must create a new power" ) );
}
}




/************************************************************************/
/*
 * Move standard text field.  This routine is normally attached to the cursor.
 */
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
{
/************************************************************************/
/* Move standard text field.  This routine is normally attached to the cursor.
 **/
    wxPoint pos;
    wxPoint pos;
    int x1, y1;
    int x1, y1;
    int fieldNdx;
    int fieldNdx;
@@ -211,10 +209,8 @@ static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
}
}




/******************************************************************/
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
{
{
/******************************************************************/
    Panel->ForceCloseManageCurseur = NULL;
    Panel->ForceCloseManageCurseur = NULL;
    Panel->ManageCurseur = NULL;
    Panel->ManageCurseur = NULL;


@@ -236,10 +232,8 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
}
}




/*********************************************************************************/
void WinEDA_SchematicFrame::RotateCmpField( SCH_FIELD* Field, wxDC* DC )
void WinEDA_SchematicFrame::RotateCmpField( SCH_FIELD* Field, wxDC* DC )
{
{
/*********************************************************************************/
    int            fieldNdx, flag;
    int            fieldNdx, flag;
    LIB_COMPONENT* Entry;
    LIB_COMPONENT* Entry;


@@ -281,12 +275,11 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_FIELD* Field, wxDC* DC )
}
}




/****************************************************************************/
void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp,
                                                    wxDC*          DC )
{
/****************************************************************************/
/****************************************************************************/
/* Edit the component text reference*/
/* Edit the component text reference*/
/****************************************************************************/
void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC )
{
    LIB_COMPONENT* Entry;
    LIB_COMPONENT* Entry;
    int            flag = 0;
    int            flag = 0;


@@ -312,25 +305,22 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp,
        Cmp->SetRef( GetSheet(), ref );
        Cmp->SetRef( GetSheet(), ref );


        Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
        Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
        Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0,
        Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
                                                                  0 ),
                                          g_XorMode );
        Cmp->SetRef( GetSheet(), ref );
        Cmp->SetRef( GetSheet(), ref );
        Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0,
        Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
                                                                  0 ),
                                          Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
                                          Cmp->m_Flags ? g_XorMode :
                                          GR_DEFAULT_DRAWMODE );
        OnModify();
        OnModify();
    }
    }

    Cmp->DisplayInfo( this );
    Cmp->DisplayInfo( this );
}
}




/*****************************************************************************/
/* Routine to change the selected text */
/*****************************************************************************/
/*****************************************************************************/
void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
{
{
/*****************************************************************************/
/* Routine to change the selected text */
    wxString       message;
    wxString       message;
    LIB_COMPONENT* Entry;
    LIB_COMPONENT* Entry;


@@ -348,7 +338,7 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
    if( Get_Message( _( "Value" ), _( "Component value" ), message, this ) )
    if( Get_Message( _( "Value" ), _( "Component value" ), message, this ) )
        message.Empty();  //allow the user to remove the value.
        message.Empty();  //allow the user to remove the value.


    if( !message.IsEmpty() && !message.IsEmpty() )
    if( !message.IsEmpty() )
    {
    {
        /* save old cmp in undo list if not already in edit, or moving ... */
        /* save old cmp in undo list if not already in edit, or moving ... */
        if( Cmp->m_Flags == 0 )
        if( Cmp->m_Flags == 0 )
@@ -365,11 +355,8 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
}
}




/*****************************************************************************/
void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC )
void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp,
                                                    wxDC*          DC )
{
{
/*****************************************************************************/
    wxString       message;
    wxString       message;
    LIB_COMPONENT* Entry;
    LIB_COMPONENT* Entry;
    bool           wasEmpty = false;
    bool           wasEmpty = false;
@@ -388,15 +375,13 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp,
    if( message.IsEmpty() )
    if( message.IsEmpty() )
        wasEmpty = true;
        wasEmpty = true;


    if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message,
    if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message, this ) )
                     this ) )
        message.Empty();    // allow the user to remove the value.
        message.Empty();    // allow the user to remove the value.


    // save old cmp in undo list if not already in edit, or moving ...
    // save old cmp in undo list if not already in edit, or moving ...
    if( Cmp->m_Flags == 0 )
    if( Cmp->m_Flags == 0 )
        SaveCopyInUndoList( Cmp, UR_CHANGED );
        SaveCopyInUndoList( Cmp, UR_CHANGED );
    Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0,
    Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
                                                              0 ), g_XorMode );


    // move the field if it was new.
    // move the field if it was new.
    if( wasEmpty && !message.IsEmpty() )
    if( wasEmpty && !message.IsEmpty() )
@@ -414,15 +399,14 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp,
            ( Cmp->GetField( REFERENCE )->m_Size.y ) :
            ( Cmp->GetField( REFERENCE )->m_Size.y ) :
            ( -1 * Cmp->GetField( REFERENCE )->m_Size.y );
            ( -1 * Cmp->GetField( REFERENCE )->m_Size.y );


        Cmp->GetField( FOOTPRINT )->m_Orient =
        Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField( REFERENCE )->m_Orient;
            Cmp->GetField( REFERENCE )->m_Orient;

    }
        TextField->m_Text = message;
        TextField->m_Text = message;


        Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
        Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
                                      Cmp->m_Flags ? g_XorMode :
                                          Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
                                      GR_DEFAULT_DRAWMODE );
        OnModify();
        OnModify();
    }


    Cmp->DisplayInfo( this );
    Cmp->DisplayInfo( this );
}
}