示例#1
0
// This function is a callback function, called by the mouse cursor movin event
// when an item is currently moved
static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                                     const wxPoint& aPosition, bool aErase )
{
    SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
    SCH_ITEM*   item   = screen->GetCurItem();

    wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );

    SCH_COMPONENT* cmp = NULL;

    if( item->Type() == SCH_COMPONENT_T )
        cmp = static_cast< SCH_COMPONENT* >( item );

#ifndef USE_WX_OVERLAY
    // Erase the current item at its current position.
    if( aErase )
    {
        if( cmp )   // Use fast mode (do not draw pin texts)
            cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
        else
            item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
    }
#endif

    wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
    cpos -= item->GetStoredPos();

    item->SetPosition( cpos );

    // Draw the item item at it's new position.
    item->SetWireImage();  // While moving, the item may choose to render differently

    if( cmp )   // Use fast mode (do not draw pin texts)
        cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
    else
        item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
}