diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index a4f2143d20..dc600d61b6 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -699,6 +700,24 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text ) } +void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg ) +{ + GetInfoBar()->ShowMessageFor( aErrorMsg, 5000, wxICON_ERROR ); +} + + +void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg ) +{ + GetInfoBar()->ShowMessageFor( aWarningMsg, 5000, wxICON_WARNING ); +} + + +void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg ) +{ + GetInfoBar()->ShowMessageFor( aMsg, 10000, wxICON_INFORMATION ); +} + + void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, FILE_HISTORY* aFileHistory ) { if( !aFileHistory ) diff --git a/eeschema/libedit/lib_export.cpp b/eeschema/libedit/lib_export.cpp index d431706dc9..1c9690ec5c 100644 --- a/eeschema/libedit/lib_export.cpp +++ b/eeschema/libedit/lib_export.cpp @@ -111,7 +111,7 @@ void LIB_EDIT_FRAME::ExportPart() if( !part ) { - DisplayError( this, _( "There is no symbol selected to save." ) ); + ShowInfoBarError( _( "There is no symbol selected to save." ) ); return; } diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index 75147ee9d7..248572fa90 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -79,7 +79,7 @@ wxString LIB_EDIT_FRAME::SelectLibraryFromList() if( prj.SchSymbolLibTable()->IsEmpty() ) { - DisplayError( this, _( "No symbol libraries are loaded." ) ); + ShowInfoBarError( _( "No symbol libraries are loaded." ) ); return wxEmptyString; } @@ -481,7 +481,7 @@ void LIB_EDIT_FRAME::savePartAs() if( new_name.IsEmpty() ) { - DisplayError( this, _( "No symbol name specified. Symbol could not be saved." ) ); + // This is effectively a cancel. No need to nag the user about it. return; } @@ -796,7 +796,7 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile ) if( !aNewFile && ( aLibrary.empty() || !prj.SchSymbolLibTable()->HasLibrary( aLibrary ) ) ) { - DisplayError( this, _( "No library specified." ) ); + ShowInfoBarError( _( "No library specified." ) ); return false; } diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 804cdad1c3..ac067a62a4 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -612,7 +612,7 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType break; default: - DisplayError( m_frame, wxT( "SCH_EDIT_FRAME::CreateNewText() Internal error" ) ); + wxFAIL_MSG( "SCH_EDIT_FRAME::CreateNewText() unknown layer type" ); return nullptr; } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index afccb22a81..36b3279690 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -916,7 +917,7 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent ) if( conn->Name( true ).IsEmpty() ) { - DisplayError( m_frame, _( "Net must be labelled to assign a netclass." ) ); + m_frame->ShowInfoBarError( _( "Net must be labelled to assign a netclass." ) ); highlightNet( m_toolMgr, CLEAR ); return 0; } diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index df9e45acab..242adda288 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -261,8 +261,8 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) if( !success ) { delete drill_layer; - msg.Printf( _( "File %s not found" ), aFullFileName ); - DisplayError( this, msg ); + msg.Printf( _( "File %s not found." ), aFullFileName ); + ShowInfoBarError( msg ); return false; } @@ -271,7 +271,7 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) if( layerId < 0 ) { delete drill_layer; - DisplayError( this, _( "No room to load file" ) ); + ShowInfoBarError( _( "No empty layers to load file into." ) ); return false; } diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 43d759d09e..45e5ded388 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -257,7 +257,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLa if( m_fp == NULL ) { wxString msg; - msg.Printf( _( "Cannot create file \"%s\"" ), GetChars( m_pcb_file_name ) ); + msg.Printf( _( "Cannot create file \"%s\"" ), m_pcb_file_name ); DisplayError( m_gerbview_frame, msg ); return false; } diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 7bbbe65aae..9bf127f707 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -60,7 +60,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName ) { delete gerber; msg.Printf( _( "File \"%s\" not found" ), GERBER_FullFileName ); - DisplayError( this, msg, 10 ); + ShowInfoBarError( msg ); return false; } diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 5e4ced4bff..9da058c522 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -343,6 +343,10 @@ public: WX_INFOBAR* GetInfoBar() { return m_infoBar; } + void ShowInfoBarError( const wxString& aErrorMsg ); + void ShowInfoBarWarning( const wxString& aWarningMsg ); + void ShowInfoBarMsg( const wxString& aMsg ); + /** * Returns the settings object used in SaveSettings(), and is overloaded in * KICAD_MANAGER_FRAME diff --git a/pcbnew/build_BOM_from_board.cpp b/pcbnew/build_BOM_from_board.cpp index 9eaa44e320..fce0b23e3b 100644 --- a/pcbnew/build_BOM_from_board.cpp +++ b/pcbnew/build_BOM_from_board.cpp @@ -77,7 +77,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent ) if( GetBoard()->Modules().empty() ) { - DisplayError( this, _( "Cannot export BOM: there are no footprints in the PCB" ) ); + ShowInfoBarError( _( "Cannot export BOM: there are no footprints on the PCB." ) ); return; } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 9a916472d8..9a1be08c6b 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -1000,7 +1000,7 @@ void MODULE::RunOnChildren( const std::function& aFunction ) } catch( std::bad_function_call& ) { - DisplayError( NULL, wxT( "Error running MODULE::RunOnChildren" ) ); + wxFAIL_MSG( "Error running MODULE::RunOnChildren" ); } } diff --git a/pcbnew/class_pcb_group.cpp b/pcbnew/class_pcb_group.cpp index ec3ba765bf..8b28078416 100644 --- a/pcbnew/class_pcb_group.cpp +++ b/pcbnew/class_pcb_group.cpp @@ -294,7 +294,7 @@ void PCB_GROUP::RunOnChildren( const std::function& aFuncti } catch( std::bad_function_call& ) { - DisplayError( NULL, wxT( "Error running PCB_GROUP::RunOnChildren" ) ); + wxFAIL_MSG( "Error running PCB_GROUP::RunOnChildren" ); } } @@ -312,6 +312,6 @@ void PCB_GROUP::RunOnDescendants( const std::function& aFun } catch( std::bad_function_call& ) { - DisplayError( NULL, wxT( "Error running PCB_GROUP::RunOnDescendants" ) ); + wxFAIL_MSG( "Error running PCB_GROUP::RunOnDescendants" ); } } diff --git a/pcbnew/dialogs/dialog_find.cpp b/pcbnew/dialogs/dialog_find.cpp index e402e753de..b2d4d6f0e1 100644 --- a/pcbnew/dialogs/dialog_find.cpp +++ b/pcbnew/dialogs/dialog_find.cpp @@ -299,7 +299,7 @@ void DIALOG_FIND::search( bool aDirection ) else { m_frame->SetStatusText( wxEmptyString ); - DisplayError( this, _( "No more item to show" ), 10 ); + m_frame->ShowInfoBarMsg( _( "No more item to show" ) ); return; } } @@ -315,7 +315,7 @@ void DIALOG_FIND::search( bool aDirection ) else { m_frame->SetStatusText( wxEmptyString ); - DisplayError( this, _( "No more item to show" ), 10 ); + m_frame->ShowInfoBarMsg( _( "No more item to show" ) ); return; } } @@ -342,7 +342,7 @@ void DIALOG_FIND::search( bool aDirection ) m_frame->SetStatusText( wxEmptyString ); msg.Printf( _( "\"%s\" not found" ), searchString ); - DisplayError( this, msg, 10 ); + m_frame->ShowInfoBarMsg( msg ); m_status->SetLabel( _( "No hits" ) ); } diff --git a/pcbnew/dialogs/dialog_keepout_area_properties.cpp b/pcbnew/dialogs/dialog_keepout_area_properties.cpp index c9d44ecfea..4f949ca2bf 100644 --- a/pcbnew/dialogs/dialog_keepout_area_properties.cpp +++ b/pcbnew/dialogs/dialog_keepout_area_properties.cpp @@ -154,7 +154,7 @@ bool DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataFromWindow() ! m_zonesettings.GetDoNotAllowFootprints() && ! m_zonesettings.GetDoNotAllowCopperPour() ) { - DisplayError( NULL, _("Tracks, vias, and pads are allowed. The keepout will have no effect." ) ); + DisplayError( NULL, _("No items are disallowed. The keepout will have no effect." ) ); return false; } diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 8e248438e7..2ccf045a42 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -1745,7 +1745,7 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) break; default: - DisplayError( NULL, wxT( "Error: unknown pad type" ) ); + wxFAIL_MSG( "DIALOG_PAD_PROPERTIES::transferDataToPad: unknown pad type" ); break; } diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 2049f60ca6..d400091a15 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -1252,7 +1252,8 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module, const wxString& aS break; default: - DisplayError( NULL, wxString::Format( "Type Edge Module %d invalid.", PtStruct->Type() ) ); + wxFAIL_MSG( wxString::Format( "Type Edge Module %d invalid.", + PtStruct->Type() ) ); break; } } diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index a44f099e4f..61ed6ecba0 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -435,9 +435,8 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary( const wxString& aLibName, { if( !writable ) { - wxString msg = wxString::Format( _( "Library \"%s\" is read only, not writable" ), - libPath ); - DisplayError( this, msg ); + wxString msg = wxString::Format( _( "Library \"%s\" is read only." ), libPath ); + ShowInfoBarError( msg ); return wxEmptyString; } else @@ -586,8 +585,8 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aC if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) ) { - wxString msg = wxString::Format( _( "Library '%s' is read only" ), nickname ); - DisplayError( this, msg ); + wxString msg = wxString::Format( _( "Library '%s' is read only." ), nickname ); + ShowInfoBarError( msg ); return false; } @@ -779,7 +778,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew ) if( pcbframe == NULL ) // happens when the board editor is not active (or closed) { - DisplayErrorMessage( this, _( "No board currently open." ) ); + ShowInfoBarError( _( "No board currently open." ) ); return false; } diff --git a/pcbnew/microwave/microwave_inductor.cpp b/pcbnew/microwave/microwave_inductor.cpp index e94af080cf..754ca76598 100644 --- a/pcbnew/microwave/microwave_inductor.cpp +++ b/pcbnew/microwave/microwave_inductor.cpp @@ -310,7 +310,7 @@ void MICROWAVE_TOOL::createInductorBetween( const VECTOR2I& aStart, const VECTOR if ( !inductorModule || !errorMessage.IsEmpty() ) { if ( !errorMessage.IsEmpty() ) - DisplayError( &editFrame, errorMessage ); + editFrame.ShowInfoBarError( errorMessage ); } else { diff --git a/pcbnew/microwave/microwave_polygon.cpp b/pcbnew/microwave/microwave_polygon.cpp index 9dc24811c1..2a5d99cd39 100644 --- a/pcbnew/microwave/microwave_polygon.cpp +++ b/pcbnew/microwave/microwave_polygon.cpp @@ -266,13 +266,13 @@ MODULE* MICROWAVE_TOOL::createPolygonShape() if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) ) { - DisplayError( &editFrame, _( "Shape has a null size!" ) ); + editFrame.ShowInfoBarError( _( "Shape has a null size!" ) ); return NULL; } if( PolyEdges.size() == 0 ) { - DisplayError( &editFrame, _( "Shape has no points!" ) ); + editFrame.ShowInfoBarError( _( "Shape has no points!" ) ); return NULL; } diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index acf755b982..cfe574bb32 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -728,22 +728,22 @@ int ROUTER_TOOL::onViaCommand( const TOOL_EVENT& aEvent ) // Cannot place microvias or blind vias if not allowed (obvious) if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) ) { - DisplayError( frame(), - _( "Blind/buried vias have to be enabled in Board Setup > Design Rules > Constraints." ) ); + frame()->ShowInfoBarError( _( "Blind/buried vias have to be enabled in " + "Board Setup > Design Rules > Constraints." ) ); return false; } if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) ) { - DisplayError( frame(), - _( "Microvias have to be enabled in Board Setup > Design Rules > Constraints." ) ); + frame()->ShowInfoBarError( _( "Microvias have to be enabled in " + "Board Setup > Design Rules > Constraints." ) ); return false; } // Can only place through vias on 2-layer boards if( ( viaType != VIATYPE::THROUGH ) && ( layerCount <= 2 ) ) { - DisplayError( frame(), _( "Only through vias are allowed on 2 layer boards." ) ); + frame()->ShowInfoBarError( _( "Only through vias are allowed on 2 layer boards." ) ); return false; } @@ -751,8 +751,8 @@ int ROUTER_TOOL::onViaCommand( const TOOL_EVENT& aEvent ) if( ( viaType == VIATYPE::MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount - 2 ) ) { - DisplayError( frame(), _( "Microvias can be placed only between the outer layers " - "(F.Cu/B.Cu) and the ones directly adjacent to them." ) ); + frame()->ShowInfoBarError( _( "Microvias can only be placed between the outer layers " + "(F.Cu/B.Cu) and the ones directly adjacent to them." ) ); return false; } } @@ -860,7 +860,7 @@ bool ROUTER_TOOL::prepareInteractive() if( !IsCopperLayer( routingLayer ) ) { - DisplayError( frame(), _( "Tracks on Copper layers only" ) ); + frame()->ShowInfoBarError( _( "Tracks on Copper layers only" ) ); return false; } diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index 480ffd05e2..7bb01b760b 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -59,16 +59,8 @@ using P_S_C = PCB_SELECTION_CONDITIONS; bool CONVERT_TOOL::Init() { - m_selectionTool = - static_cast( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) ); - - if( !m_selectionTool ) - { - DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) ); - return false; - } - - m_frame = getEditFrame(); + m_selectionTool = m_toolMgr->GetTool(); + m_frame = getEditFrame(); // Create a context menu and make it available through selection tool m_menu = new CONDITIONAL_MENU( this );