diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 6751c95661..8ebcab2027 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -121,17 +121,11 @@ static void RemoveBacktracks( DLIST& aWires ) /** * Mouse capture callback for drawing line segments. */ -static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ) +static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { - SCH_LINE* segment; - if( s_wires.GetCount() == 0 ) return; - segment = (SCH_LINE*) s_wires.begin(); - COLOR4D color = GetLayerColor( segment->GetLayer() ); - SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent(); wxPoint endpos = frame->GetCrossHairPosition(); @@ -141,24 +135,19 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi else ( (SCH_LINE*) s_wires.GetLast() )->SetEndPoint( endpos ); - segment = (SCH_LINE*) s_wires.begin(); - auto view = static_cast( aPanel )->GetView(); view->ClearPreview(); - while( segment ) + for( SCH_LINE* segment = (SCH_LINE*) s_wires.begin(); segment; segment = segment->Next() ) { - if( !segment->IsNull() ) // Redraw if segment length != 0 + if( !segment->IsNull() ) // Add to preview if segment length != 0 view->AddToPreview( segment->Clone() ); - - segment = segment->Next(); } - } -void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) +void SCH_EDIT_FRAME::BeginSegment( int type ) { SCH_LINE* segment; SCH_LINE* nextSegment; @@ -171,10 +160,8 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) if( !segment->GetFlags() || ( segment->Type() != SCH_LINE_T ) ) { if( segment->GetFlags() ) - { - wxLogDebug( wxT( "BeginSegment: item->GetFlags()== %X" ), - segment->GetFlags() ); - } + wxLogDebug( wxT( "BeginSegment: item->GetFlags()== %X" ), segment->GetFlags() ); + // no wire, bus or graphic line in progress segment = NULL; } @@ -240,7 +227,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) return; } - m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); + m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false ); // Terminate the command if the end point is on a pin, junction, or another wire or bus. if( GetScreen()->IsTerminalPoint( cursorpos, segment->GetLayer() ) ) @@ -259,7 +246,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) segment->SetFlags( SELECTED ); nextSegment->SetFlags( IS_NEW ); GetScreen()->SetCurItem( nextSegment ); - m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); + m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false ); } } @@ -456,7 +443,7 @@ static void ComputeBreakPoint( SCH_SCREEN* aScreen, SCH_LINE* aSegment, wxPoint& } -void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC ) +void SCH_EDIT_FRAME::DeleteCurrentSegment() { SCH_SCREEN* screen = GetScreen(); @@ -465,8 +452,6 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC ) if( ( screen->GetCurItem() == NULL ) || !screen->GetCurItem()->IsNew() ) return; - DrawSegment( m_canvas, DC, wxDefaultPosition, false ); - RemoveFromScreen( screen->GetCurItem() ); m_canvas->SetMouseCaptureCallback( NULL ); screen->SetCurItem( NULL ); @@ -853,7 +838,7 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) } -void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) +void SCH_EDIT_FRAME::RepeatDrawItem() { SCH_ITEM* repeater = GetRepeatItem(); @@ -870,13 +855,12 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) // If cloning a component then put into 'move' mode. if( my_clone->Type() == SCH_COMPONENT_T ) { - wxPoint pos = GetCrossHairPosition() - - ( (SCH_COMPONENT*) my_clone )->GetPosition(); + wxPoint pos = GetCrossHairPosition() - ( (SCH_COMPONENT*) my_clone )->GetPosition(); my_clone->SetFlags( IS_NEW ); ( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() ); my_clone->Move( pos ); - PrepareMoveItem( my_clone, DC ); + PrepareMoveItem( my_clone ); } else { diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 89e7e57234..8fca11b0e7 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -63,7 +63,7 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem ) } -SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) +SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType ) { SCH_TEXT* textItem = NULL; @@ -112,14 +112,11 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) lastTextItalic = textItem->IsItalic(); lastTextOrientation = textItem->GetLabelSpinStyle(); - if( ( textItem->Type() == SCH_GLOBAL_LABEL_T ) || - ( textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) ) - { + if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) lastGlobalLabelShape = textItem->GetShape(); - } // Prepare display to move the new item - PrepareMoveItem( (SCH_ITEM*) textItem, nullptr ); + PrepareMoveItem( textItem ); return textItem; } @@ -138,8 +135,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) SCH_SCREEN* screen = GetScreen(); SCH_TEXT* text = (SCH_TEXT*) screen->GetCurItem(); - wxCHECK_RET( (text != NULL) && text->CanIncrementLabel(), - wxT( "Cannot convert text type." ) ); + wxCHECK_RET( (text != NULL) && text->CanIncrementLabel(), "Cannot convert text type." ); KICAD_T type; @@ -162,15 +158,14 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) break; default: - wxFAIL_MSG( wxString::Format( wxT( "Invalid text type command ID %d." ), - aEvent.GetId() ) ); + wxFAIL_MSG( wxString::Format( "Invalid text type command ID %d.", aEvent.GetId() ) ); return; } if( text->Type() == type ) return; - SCH_TEXT* newtext; + SCH_TEXT* newtext = nullptr; const wxPoint &position = text->GetPosition(); const wxString &txt = text->GetText(); @@ -191,11 +186,6 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break; - - default: - newtext = NULL; - wxFAIL_MSG( wxString::Format( wxT( "Cannot convert text type to %d" ), type ) ); - return; } /* Copy the old text item settings to the new one. Justifications are not copied because diff --git a/eeschema/events_called_functions_for_edit.cpp b/eeschema/events_called_functions_for_edit.cpp index 9f568df543..e09bc5529b 100644 --- a/eeschema/events_called_functions_for_edit.cpp +++ b/eeschema/events_called_functions_for_edit.cpp @@ -56,7 +56,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) newitem->ClearAnnotation( NULL ); newitem->SetFlags( IS_NEW ); // Draw the new part, MoveItem() expects it to be already on screen. - PrepareMoveItem( newitem, nullptr ); + PrepareMoveItem( newitem ); } break; @@ -68,7 +68,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone(); newitem->SetFlags( IS_NEW ); // Draw the new item, MoveItem() expects it to be already on screen. - PrepareMoveItem( newitem, nullptr ); + PrepareMoveItem( newitem ); } break; diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index cf6df6604a..d65d7da208 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -211,8 +211,7 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibTree( } -SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC, - const SCHLIB_FILTER* aFilter, +SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( const SCHLIB_FILTER* aFilter, SCH_BASE_FRAME::HISTORY_LIST& aHistoryList, bool aAllowBrowser ) { @@ -291,7 +290,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aD if( m_autoplaceFields ) component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); - PrepareMoveItem( (SCH_ITEM*) component, aDC ); + PrepareMoveItem( component ); return component; } @@ -299,15 +298,11 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aD void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) { - SCH_SCREEN* screen = GetScreen(); - SCH_ITEM* item = screen->GetCurItem(); - - wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T, - wxT( "Cannot change orientation of invalid schematic item." ) ); - + SCH_SCREEN* screen = GetScreen(); + SCH_ITEM* item = screen->GetCurItem(); SCH_COMPONENT* component = (SCH_COMPONENT*) item; - m_canvas->MoveCursorToCrossHair(); + GetCanvas()->MoveCursorToCrossHair(); if( item->GetFlags() == 0 ) SetUndoItem( item ); @@ -322,28 +317,21 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) SchematicCleanUp( true ); } - if( GetScreen()->TestDanglingEnds() ) - m_canvas->Refresh(); + GetScreen()->TestDanglingEnds(); + RefreshItem( item ); OnModify(); } void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) { - SCH_SCREEN* screen = GetScreen(); - SCH_ITEM* item = screen->GetCurItem(); - - wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T, - wxT( "Cannot select unit of invalid schematic item." ) ); - -//fixme-gal - //INSTALL_UNBUFFERED_DC( dc, m_canvas ); - - m_canvas->MoveCursorToCrossHair(); - + SCH_SCREEN* screen = GetScreen(); + SCH_ITEM* item = screen->GetCurItem(); SCH_COMPONENT* component = (SCH_COMPONENT*) item; + GetCanvas()->MoveCursorToCrossHair(); + int unit = aEvent.GetId() + 1 - ID_POPUP_SCH_SELECT_UNIT1; LIB_PART* part = GetLibPart( component->GetLibId() ); @@ -353,10 +341,6 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) int unitCount = part->GetUnitCount(); - wxCHECK_RET( (unit >= 1) && (unit <= unitCount), - wxString::Format( wxT( "Cannot select unit %d from component " ), unit ) + - part->GetName() ); - if( unitCount <= 1 || component->GetUnit() == unit ) return; @@ -368,11 +352,6 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) if( !flags ) // No command in progress: save in undo list SaveCopyInUndoList( component, UR_CHANGED ); - //if( flags ) - //component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); - //else - //component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); - /* Update the unit number. */ component->SetUnitSelection( m_CurrentSheet, unit ); component->SetUnit( unit ); @@ -382,14 +361,14 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) if( m_autoplaceFields ) component->AutoAutoplaceFields( GetScreen() ); - if( screen->TestDanglingEnds() ) - m_canvas->Refresh(); + screen->TestDanglingEnds(); + RefreshItem( component ); OnModify(); } -void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent, wxDC* DC ) +void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent ) { if( !aComponent ) return; @@ -411,11 +390,6 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent, wxDC* DC ) STATUS_FLAGS flags = aComponent->GetFlags(); - if( aComponent->GetFlags() ) - aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); - else - aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode ); - aComponent->SetConvert( aComponent->GetConvert() + 1 ); // ensure m_Convert = 0, 1 or 2 @@ -433,12 +407,7 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent, wxDC* DC ) aComponent->ClearFlags(); aComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert()) - /* Redraw the component in the new position. */ - if( aComponent->IsMoving() ) - aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); - else - aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - + RefreshItem( aComponent ); OnModify(); } } diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index c248411119..2147cf8bc2 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -494,12 +494,12 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, GetEventHandler()->ProcessEvent( cmd ); } else if( notBusy ) - DeleteItemAtCrossHair( aDC ); + DeleteItemAtCrossHair(); break; case HK_REPEAT_LAST: if( notBusy ) - RepeatDrawItem( aDC ); + RepeatDrawItem(); break; case HK_END_CURR_LINEWIREBUS: diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index ff1af0933b..dc9267fd8a 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -179,28 +179,28 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) break; case ID_SCHEMATIC_DELETE_ITEM_BUTT: - DeleteItemAtCrossHair( aDC ); + DeleteItemAtCrossHair(); break; case ID_WIRE_BUTT: - BeginSegment( aDC, LAYER_WIRE ); + BeginSegment( LAYER_WIRE ); m_canvas->SetAutoPanRequest( true ); break; case ID_BUS_BUTT: - BeginSegment( aDC, LAYER_BUS ); + BeginSegment( LAYER_BUS ); m_canvas->SetAutoPanRequest( true ); break; case ID_LINE_COMMENT_BUTT: - BeginSegment( aDC, LAYER_NOTES ); + BeginSegment( LAYER_NOTES ); m_canvas->SetAutoPanRequest( true ); break; case ID_TEXT_COMMENT_BUTT: if( ( item == NULL ) || ( item->GetFlags() == 0 ) ) { - GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_NOTES ) ); + GetScreen()->SetCurItem( CreateNewText( LAYER_NOTES ) ); m_canvas->SetAutoPanRequest( true ); } else @@ -224,7 +224,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_LABEL_BUTT: if( ( item == NULL ) || ( item->GetFlags() == 0 ) ) { - GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_LOCLABEL ) ); + GetScreen()->SetCurItem( CreateNewText( LAYER_LOCLABEL ) ); m_canvas->SetAutoPanRequest( true ); } else @@ -238,10 +238,10 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) if( (item == NULL) || (item->GetFlags() == 0) ) { if( GetToolId() == ID_GLABEL_BUTT ) - GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_GLOBLABEL ) ); + GetScreen()->SetCurItem( CreateNewText( LAYER_GLOBLABEL ) ); if( GetToolId() == ID_HIERLABEL_BUTT ) - GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_HIERLABEL ) ); + GetScreen()->SetCurItem( CreateNewText( LAYER_HIERLABEL ) ); m_canvas->SetAutoPanRequest( true ); } @@ -279,9 +279,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) if( (item->Type() == SCH_SHEET_T) && (item->GetFlags() == 0) ) { if( GetToolId() == ID_IMPORT_HLABEL_BUTT ) - GetScreen()->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, aDC ) ); + GetScreen()->SetCurItem( ImportSheetPin( (SCH_SHEET*) item ) ); else - GetScreen()->SetCurItem( CreateSheetPin( (SCH_SHEET*) item, aDC ) ); + GetScreen()->SetCurItem( CreateSheetPin( (SCH_SHEET*) item ) ); } else if( (item->Type() == SCH_SHEET_PIN_T) && (item->GetFlags() != 0) ) { @@ -294,8 +294,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) { // ERC dialog interferes with moving items so we close it before starting CloseErc(); - GetScreen()->SetCurItem( Load_Component( aDC, NULL, - s_CmpNameList, true ) ); + GetScreen()->SetCurItem( Load_Component( NULL, s_CmpNameList, true ) ); m_canvas->SetAutoPanRequest( true ); } else @@ -309,8 +308,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) { SCHLIB_FILTER filter; filter.FilterPowerParts( true ); - GetScreen()->SetCurItem( Load_Component( aDC, &filter, - s_PowerNameList, false ) ); + GetScreen()->SetCurItem( Load_Component( &filter, s_PowerNameList, false ) ); m_canvas->SetAutoPanRequest( true ); } else @@ -323,7 +321,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_SIM_PROBE: { constexpr KICAD_T wiresAndComponents[] = { SCH_LINE_T, - SCH_COMPONENT_T, SCH_SHEET_PIN_T, EOT }; + SCH_COMPONENT_T, + SCH_SHEET_PIN_T, + EOT }; item = LocateAndShowItem( aPosition, wiresAndComponents ); if( !item ) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 90133537b5..f5cdd27c1e 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1032,16 +1032,14 @@ void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event ) if( create_me.FileExists() ) { - wxString msg = wxString::Format( _( - "Schematic file \"%s\" already exists, use Open instead" ), - GetChars( create_me.GetFullName() ) - ); + wxString msg; + msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() ); DisplayError( this, msg ); return ; } // OpenProjectFiles() requires absolute - wxASSERT_MSG( create_me.IsAbsolute(), wxT( "wxFileDialog returned non-absolute" ) ); + wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" ); OpenProjectFiles( std::vector( 1, create_me.GetFullPath() ), KICTL_CREATE ); m_mruPath = create_me.GetPath(); @@ -1051,7 +1049,6 @@ void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event ) { -// wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); wxString pro_dir = m_mruPath; wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index eb4470c0d0..96922dabe3 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -417,10 +417,9 @@ public: * cross hair position, a context menu is displayed to clarify which item to delete. * See LocateItem() for more information on locating multiple items. * - * @param aDC The device context to update if and item is deleted. * @return True if an item was deleted. */ - bool DeleteItemAtCrossHair( wxDC* aDC ); + bool DeleteItemAtCrossHair(); /** @@ -960,10 +959,10 @@ private: * @param aItem A pointer to an SCH_ITEM to move. * @param aDC The device context to draw \a aItem. */ - void PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC ); + void PrepareMoveItem( SCH_ITEM* aItem ); // Text, label, glabel - SCH_TEXT* CreateNewText( wxDC* aDC, int aType ); + SCH_TEXT* CreateNewText( int aType ); void EditSchematicText( SCH_TEXT* TextStruct ); void ChangeTextOrient( SCH_TEXT* aTextItem ); @@ -982,7 +981,7 @@ private: * and terminates the command. If the end of the current segment is on a pin, terminate * the command. In all other cases starts a new segment. */ - void BeginSegment( wxDC* DC, int type ); + void BeginSegment( int type ); /** * Terminate a bus, wire, or line creation. @@ -992,7 +991,7 @@ private: /** * Erase the last segment at the current mouse position. */ - void DeleteCurrentSegment( wxDC* DC ); + void DeleteCurrentSegment(); void DeleteConnection( bool DeleteFullConnection ); // Images: @@ -1094,10 +1093,9 @@ private: * Create a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position. * * @param aSheet The sheet to add the new sheet pin to. - * @param aDC The device context to draw on. * @return The new sheet pin object created or NULL if the task was aborted by the user. */ - SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC ); + SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet ); /** * Display the dialog for editing the parameters of \a aSheetPin. @@ -1113,10 +1111,9 @@ private: * referenced by \a aSheet. * * @param aSheet The sheet to import the new sheet pin to. - * @param aDC The device context to draw on. * @return The new sheet pin object imported or NULL if the task was aborted by the user. */ - SCH_SHEET_PIN* ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC ); + SCH_SHEET_PIN* ImportSheetPin( SCH_SHEET* aSheet ); public: /** @@ -1163,7 +1160,6 @@ private: * if libname != "", search in lib "libname" * else search in all loaded libs * - * @param aDC is the device context to draw upon. * @param aFilter is a filter to pass the allowed lib names list, or library name * to load the component from and/or some other filters * if NULL, no filtering. @@ -1173,8 +1169,7 @@ private: * (TODO(hzeller): This really should be a class doing history, but didn't * want to change too much while other refactoring is going on) */ - SCH_COMPONENT* Load_Component( wxDC* aDC, - const SCHLIB_FILTER* aFilter, + SCH_COMPONENT* Load_Component( const SCHLIB_FILTER* aFilter, SCH_BASE_FRAME::HISTORY_LIST& aHistoryList, bool aUseLibBrowser ); @@ -1194,8 +1189,7 @@ public: private: void OnSelectUnit( wxCommandEvent& aEvent ); - void ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC ); - void SetInitCmp( SCH_COMPONENT* DrawComponent, wxDC* DC ); + void ConvertPart( SCH_COMPONENT* DrawComponent ); /** * Display the edit field dialog to edit the parameters of \a aField. @@ -1351,7 +1345,7 @@ public: * * Labels that end with a number will be incremented. */ - void RepeatDrawItem( wxDC* DC ); + void RepeatDrawItem(); /** * Clone \a aItem and owns that clone in this container. diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index a397bc0ca3..08d5364d42 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -242,7 +242,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN: if( item != NULL && item->Type() == SCH_SHEET_T ) - screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, nullptr ) ); + screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item ) ); break; case ID_POPUP_SCH_CLEANUP_SHEET: @@ -252,8 +252,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( !sheet->HasUndefinedPins() ) { - DisplayInfoMessage( this, - _( "There are no undefined labels in this sheet to clean up." ) ); + DisplayInfoMessage( this, _( "There are no undefined labels in this sheet to clean up." ) ); return; } @@ -277,7 +276,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( item && item->Type() == SCH_COMPONENT_T ) { m_canvas->MoveCursorToCrossHair(); - ConvertPart( (SCH_COMPONENT*) item, nullptr ); + ConvertPart( (SCH_COMPONENT*) item ); } break; @@ -356,8 +355,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_ADD_LABEL: case ID_POPUP_SCH_ADD_GLABEL: - screen->SetCurItem( CreateNewText( nullptr, id == ID_POPUP_SCH_ADD_LABEL ? - LAYER_LOCLABEL : LAYER_GLOBLABEL ) ); + screen->SetCurItem( CreateNewText( id == ID_POPUP_SCH_ADD_LABEL ? LAYER_LOCLABEL + : LAYER_GLOBLABEL ) ); item = screen->GetCurItem(); if( item ) @@ -372,8 +371,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; default: // Log error: - wxFAIL_MSG( wxString::Format( wxT( "Cannot process command event ID %d" ), - event.GetId() ) ); + wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) ); break; } @@ -431,7 +429,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) case SCH_FIELD_T: case SCH_SHEET_T: case SCH_BITMAP_T: - PrepareMoveItem( item, nullptr ); + PrepareMoveItem( item ); break; /* case SCH_BITMAP_T: @@ -448,8 +446,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) default: // Unknown items cannot be moved - wxFAIL_MSG( wxString::Format( - wxT( "Cannot move item type %d" ), item->Type() ) ); + wxFAIL_MSG( wxString::Format( "Cannot move item type %d", item->Type() ) ); break; } @@ -464,7 +461,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent ) if( screen->IsBlockActive() ) { -// m_canvas->SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() ); + GetCanvas()->SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() ); screen->ClearBlockCommand(); // Stop the current command (if any) but keep the current tool @@ -474,7 +471,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent ) { if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool m_canvas->EndMouseCapture(); - else // Deselect current tool + else // Deselect current tool m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); } @@ -604,12 +601,12 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) #ifdef KICAD_SPICE case ID_SIM_PROBE: SetToolID( id, -1, _( "Add a simulator probe" ) ); - //m_canvas->SetCurrentCursor( CURSOR_PROBE ); + //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_PROBE ); break; case ID_SIM_TUNE: SetToolID( id, -1, _( "Select a value to be tuned" ) ); - //m_canvas->SetCurrentCursor( CURSOR_TUNE ); + //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_TUNE ); break; #endif /* KICAD_SPICE */ @@ -622,10 +619,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) { EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject(); - wxPoint pos = data->GetPosition(); - -// INSTALL_UNBUFFERED_DC( dc, m_canvas ); - OnLeftClick( nullptr, pos ); + OnLeftClick( nullptr, data->GetPosition() ); } } @@ -652,7 +646,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection ) } -bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC ) +bool SCH_EDIT_FRAME::DeleteItemAtCrossHair() { SCH_ITEM* item; SCH_SCREEN* screen = GetScreen(); @@ -667,8 +661,8 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC ) SetRepeatItem( NULL ); DeleteItem( item ); - if( itemHasConnections && screen->TestDanglingEnds() ) - m_canvas->Refresh(); + if( itemHasConnections ) + screen->TestDanglingEnds(); OnModify(); return true; @@ -677,8 +671,7 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC ) return false; } -// This function is a callback function, called by the mouse cursor movin event -// when an item is currently moved +// This function is a callback function, called by the mouse cursor moving event static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { @@ -722,7 +715,6 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) if( item->IsNew() ) { delete item; - item = NULL; } else { @@ -733,13 +725,9 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) // Items that are children of other objects are undone by swapping the contents // of the parent items. if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) ) - { currentItem = (SCH_ITEM*) item->GetParent(); - } else - { currentItem = item; - } wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(), wxT( "Cannot restore undefined or bad last schematic item." ) ); @@ -758,7 +746,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) } -void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC ) +void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem ) { wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) ); @@ -811,6 +799,7 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC ) GetScreen()->SetCurItem( aItem ); m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem ); + m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false ); m_canvas->Refresh(); } diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 9097220131..29379aa646 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -56,6 +56,7 @@ const wxSize &SCH_EDIT_FRAME::GetLastSheetPinTextSize() return m_lastSheetPinTextSize; } + int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw ) { if( aSheetPin == NULL ) @@ -67,13 +68,13 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw ) return wxID_CANCEL; if( aRedraw ) - m_canvas->Refresh(); + RefreshItem( aSheetPin ); return wxID_OK; } -SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) +SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet ) { wxString line; SCH_SHEET_PIN* sheetPin; @@ -95,15 +96,14 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) m_lastSheetPinTextSize = sheetPin->GetTextSize(); sheetPin->SetPosition( GetCrossHairPosition() ); - sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); - PrepareMoveItem( (SCH_ITEM*) sheetPin, aDC ); + PrepareMoveItem( sheetPin ); OnModify(); return sheetPin; } -SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) +SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet ) { EDA_ITEM* item; SCH_SHEET_PIN* sheetPin; @@ -141,8 +141,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) sheetPin->SetShape( label->GetShape() ); sheetPin->SetPosition( GetCrossHairPosition() ); - sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); - PrepareMoveItem( (SCH_ITEM*) sheetPin, aDC ); + PrepareMoveItem( sheetPin ); return sheetPin; } diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 58219c58e9..c73143df84 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -91,7 +91,7 @@ public: void OnSelectSymbol( wxCommandEvent& aEvent ); void OnShowElectricalType( wxCommandEvent& event ); - bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override; + bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey ) override; ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; @@ -104,8 +104,7 @@ public: * case insensitive *

*/ - bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, - EDA_ITEM* aItem = NULL ) override; + bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem ) override; void LoadSettings( wxConfigBase* aCfg ) override; void SaveSettings( wxConfigBase* aCfg ) override;