From c47871e77580fa3a90af0074561a0731667c5c3e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 4 Dec 2020 14:45:14 +0100 Subject: [PATCH] EDA_BASE_FRAME::ShowInfoBarMsg: add option to show a close button. Same for EDA_BASE_FRAME::ShowInfoBarError and EDA_BASE_FRAME::ShowInfoBarWarning --- common/eda_base_frame.cpp | 18 +++++++++++++--- eeschema/tools/sch_edit_tool.cpp | 2 +- include/eda_base_frame.h | 35 +++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 9966a1ce4d..c3253a5988 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -683,23 +683,35 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text ) } -void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg ) +void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton ) { m_infoBar->RemoveAllButtons(); + + if( aShowCloseButton ) + m_infoBar->AddCloseButton(); + GetInfoBar()->ShowMessageFor( aErrorMsg, 8000, wxICON_ERROR ); } -void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg ) +void EDA_BASE_FRAME::ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton ) { m_infoBar->RemoveAllButtons(); + + if( aShowCloseButton ) + m_infoBar->AddCloseButton(); + GetInfoBar()->ShowMessageFor( aWarningMsg, 8000, wxICON_WARNING ); } -void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg ) +void EDA_BASE_FRAME::ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton ) { m_infoBar->RemoveAllButtons(); + + if( aShowCloseButton ) + m_infoBar->AddCloseButton(); + GetInfoBar()->ShowMessageFor( aMsg, 10000, wxICON_INFORMATION ); } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 015c133856..c69a10c5fd 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -908,7 +908,7 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent ) // If incrementing tries to go below zero, tell user why the value is repeated if( !text->IncrementLabel( cfg->m_Drawing.repeat_label_increment ) ) - m_frame->ShowInfoBarMsg( _( "Label value cannot go below zero" ) ); + m_frame->ShowInfoBarWarning( _( "Label value cannot go below zero" ), true ); } newItem->Move( wxPoint( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ), diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index aebfcc5ec2..cc0c87d927 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -330,11 +330,40 @@ public: void PrintMsg( const wxString& text ); + /** + * @return the WX_INFOBAR that can be displayed on the top of the canvas + */ WX_INFOBAR* GetInfoBar() { return m_infoBar; } - void ShowInfoBarError( const wxString& aErrorMsg ); - void ShowInfoBarWarning( const wxString& aWarningMsg ); - void ShowInfoBarMsg( const wxString& aMsg ); + /** + * Show the WX_INFOBAR displayed on the top of the canvas with a message + * and a Error icon on the left of the infobar. The infobar will be closed + * after a timeaout + * @param aErrorMsg is the message to display + * @param aShowCloseButton = true to show a close button on the right of the + * WX_INFOBAR + */ + void ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton = false ); + + /** + * Show the WX_INFOBAR displayed on the top of the canvas with a message + * and a Warning icon on the left of the infobar. The infobar will be closed + * after a timeaout + * @param aErrorMsg is the message to display + * @param aShowCloseButton = true to show a close button on the right of the + * WX_INFOBAR + */ + void ShowInfoBarWarning( const wxString& aWarningMsg, bool aShowCloseButton = false ); + + /** + * Show the WX_INFOBAR displayed on the top of the canvas with a message + * and a Info icon on the left of the infobar. The infobar will be closed + * after a timeaout + * @param aErrorMsg is the message to display + * @param aShowCloseButton = true to show a close button on the right of the + * WX_INFOBAR + */ + void ShowInfoBarMsg( const wxString& aMsg, bool aShowCloseButton = false ); /** * Returns the settings object used in SaveSettings(), and is overloaded in