Added extra information to error and info messages

Optional extra information string which is displayed in a drop-down "details" box
This commit is contained in:
Oliver Walters 2017-07-20 23:03:33 +10:00 committed by Wayne Stambaugh
parent 6d52987928
commit a0a3ca6646
4 changed files with 52 additions and 20 deletions

View File

@ -40,6 +40,8 @@ Mario Luzeiro <mrluzeiro[at]ua-dot-pt>
Mateusz Skowroński <skowri[at]gmail-dot-com>
Cheng Sheng <chengsheng[at]google-dot-com> Google Inc.
Kristoffer Ödmark <kristoffer.odmark90[at]gmail-dot-com>
Oliver Walters <oliver.henry.walters[at]gmail-dot-com>
See also CHANGELOG.txt for contributors.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -28,6 +28,7 @@
*/
#include <wx/stockitem.h>
#include <wx/richmsgdlg.h>
#include <bitmaps.h>
#include <html_messagebox.h>
@ -70,31 +71,47 @@ void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
{
wxMessageDialog* dialog;
if( displaytime > 0 )
dialog = new wxMessageDialog( parent, text, _( "Warning" ),
wxOK | wxCENTRE | wxICON_INFORMATION
| wxRESIZE_BORDER
);
else
dialog = new wxMessageDialog( parent, text, _( "Error" ),
wxOK | wxCENTRE | wxICON_ERROR
| wxRESIZE_BORDER
);
int icon = displaytime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
dialog = new wxMessageDialog( parent, text, _( "Warning" ),
wxOK | wxCENTRE | wxRESIZE_BORDER | icon );
dialog->ShowModal();
dialog->Destroy();
}
void DisplayInfoMessage( wxWindow* parent, const wxString& text, int displaytime )
void DisplayErrorMessage( wxWindow* aParent, const wxString& aText, const wxString aExtraInfo )
{
wxMessageDialog* dialog;
wxRichMessageDialog* dlg;
dialog = new wxMessageDialog( parent, text, _( "Info" ),
wxOK | wxCENTRE | wxICON_INFORMATION );
dlg = new wxRichMessageDialog( aParent, aText, _( "Error" ),
wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_ERROR );
dialog->ShowModal();
dialog->Destroy();
if( !aExtraInfo.IsEmpty() )
{
dlg->ShowDetailedText( aExtraInfo );
}
dlg->ShowModal();
dlg->Destroy();
}
void DisplayInfoMessage( wxWindow* aParent, const wxString& aMessage, const wxString aExtraInfo )
{
wxRichMessageDialog* dlg;
dlg = new wxRichMessageDialog( aParent, aMessage, _( "Info" ),
wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_INFORMATION );
if( !aExtraInfo.IsEmpty() )
{
dlg->ShowDetailedText( aExtraInfo );
}
dlg->ShowModal();
dlg->Destroy();
}

View File

@ -85,7 +85,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
{
wxString msg;
msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
DisplayInfoMessage( NULL, msg, 2 );
DisplayInfoMessage( NULL, msg );
}
}

View File

@ -57,13 +57,26 @@ int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage );
*/
void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
/**
* Function DisplayErrorMessage
* displays an error message with \a aMessage
*
* @param aParent is the parent window
* @param aMessage is the message text to display
* @param aExtraInfo is extra data that can be optionally displayed in a collapsible pane
*/
void DisplayErrorMessage( wxWindow* aParent, const wxString& aMessage, const wxString aExtraInfo = wxEmptyString );
/**
* Function DisplayInfoMessage
* displays an informational message box with \a aMessage.
*
* @warning Setting \a displaytime does not work. Do not use it.
* @param aParent is the parent window
* @param aMessage is the message text to display
* @param aExtraInfo is the extra data that can be optionally displayed in a collapsible pane
*/
void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, const wxString aExtraInfo = wxEmptyString );
/**
* Function IsOK