void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC ) { LIB_ITEM* item = GetDrawItem(); if( item == NULL ) return; SetCursor( wxCURSOR_HAND ); TempCopyComponent(); // For fields only, move the anchor point of the field // to the cursor position to allow user to see the text justification if( item->Type() == LIB_FIELD_T ) item->BeginEdit( IS_MOVED, item->GetPosition() ); else item->BeginEdit( IS_MOVED, GetCrossHairPosition( true ) ); m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, true ); }
void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC ) { LIB_ITEM* item = GetDrawItem(); if( item == NULL ) return; TempCopyComponent(); item->BeginEdit( IS_RESIZED, GetCrossHairPosition( true ) ); m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, true ); }
LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) { LIB_ITEM* item = GetDrawItem(); m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); wxPoint drawPos = GetCrossHairPosition( true ); // no temp copy -> the current version of symbol will be used for Undo // This is normal when adding new items to the current symbol ClearTempCopyComponent(); switch( GetToolId() ) { case ID_LIBEDIT_BODY_ARC_BUTT: item = new LIB_ARC( LibEntry ); break; case ID_LIBEDIT_BODY_CIRCLE_BUTT: item = new LIB_CIRCLE( LibEntry ); break; case ID_LIBEDIT_BODY_RECT_BUTT: item = new LIB_RECTANGLE( LibEntry ); break; case ID_LIBEDIT_BODY_LINE_BUTT: item = new LIB_POLYLINE( LibEntry ); break; case ID_LIBEDIT_BODY_TEXT_BUTT: { LIB_TEXT* text = new LIB_TEXT( LibEntry ); text->SetTextSize( wxSize( m_textSize, m_textSize ) ); text->SetTextAngle( m_current_text_angle ); // Enter the graphic text info m_canvas->SetIgnoreMouseEvents( true ); EditSymbolText( NULL, text ); m_canvas->SetIgnoreMouseEvents( false ); m_canvas->MoveCursorToCrossHair(); if( text->GetText().IsEmpty() ) { delete text; item = NULL; } else { item = text; } } break; default: DisplayError( this, wxT( "LIB_EDIT_FRAME::CreateGraphicItem() error" ) ); return NULL; } if( item ) { item->BeginEdit( IS_NEW, drawPos ); // Don't set line parameters for text objects. if( item->Type() != LIB_TEXT_T ) { item->SetWidth( m_drawLineWidth ); item->SetFillMode( m_drawFillStyle ); } if( m_drawSpecificUnit ) item->SetUnit( m_unit ); if( m_drawSpecificConvert ) item->SetConvert( m_convert ); // Draw initial symbol: m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); } else { m_canvas->EndMouseCapture(); return NULL; } m_canvas->MoveCursorToCrossHair(); m_canvas->SetIgnoreMouseEvents( false ); SetDrawItem( item ); return item; }