2009-11-23 15:16:50 +00:00
|
|
|
/************************/
|
|
|
|
/* Menu "CONFIRMATION" */
|
|
|
|
/* Function get_Message */
|
|
|
|
/* Test requires ESC */
|
|
|
|
/************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
enum id_dialog {
|
2007-12-05 20:54:11 +00:00
|
|
|
ID_TIMOUT = 1500
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
/* Class for displaying messages, similar to wxMessageDialog,
|
|
|
|
* but can be erased after a time out expires.
|
|
|
|
*
|
|
|
|
* @note - Do not use the time feature. It is broken by design because
|
|
|
|
* the dialog is shown as modal and wxWidgets will assert when
|
|
|
|
* compiled in the debug mode. This is because the dialog steals
|
|
|
|
* the event queue when dialog is modal so the timer event never
|
|
|
|
* gets to the dialog event handle. Using dialogs to display
|
|
|
|
* transient is brain dead anyway. Use the message panel or some
|
|
|
|
* other method.
|
2007-12-05 20:54:11 +00:00
|
|
|
*/
|
|
|
|
class WinEDA_MessageDialog : public wxMessageDialog
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
2009-03-22 11:34:14 +00:00
|
|
|
int m_LifeTime;
|
2007-12-05 20:54:11 +00:00
|
|
|
wxTimer m_Timer;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
public:
|
2007-12-05 20:54:11 +00:00
|
|
|
WinEDA_MessageDialog( wxWindow * parent, const wxString &msg,
|
|
|
|
const wxString &title, int style, int lifetime );
|
|
|
|
~WinEDA_MessageDialog() { };
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
void OnTimeOut( wxTimerEvent& event );
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_MessageDialog, wxMessageDialog )
|
2009-05-21 17:42:42 +00:00
|
|
|
EVT_TIMER( ID_TIMOUT, WinEDA_MessageDialog::OnTimeOut )
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
|
|
|
|
WinEDA_MessageDialog::WinEDA_MessageDialog( wxWindow* parent,
|
|
|
|
const wxString& msg,
|
|
|
|
const wxString& title,
|
|
|
|
int style,
|
|
|
|
int lifetime ) :
|
2007-12-05 20:54:11 +00:00
|
|
|
wxMessageDialog( parent, msg, title, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-05 20:54:11 +00:00
|
|
|
m_LifeTime = lifetime;
|
|
|
|
m_Timer.SetOwner( this, ID_TIMOUT );
|
|
|
|
if( m_LifeTime > 0 )
|
2009-11-23 15:16:50 +00:00
|
|
|
m_Timer.Start( 100 * m_LifeTime, wxTIMER_ONE_SHOT );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
|
|
|
|
void WinEDA_MessageDialog::OnTimeOut( wxTimerEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-03-22 11:34:14 +00:00
|
|
|
m_Timer.Stop();
|
2009-11-23 15:16:50 +00:00
|
|
|
EndModal( wxID_YES ); /* Does not work, I do not know why (this
|
|
|
|
* function is correctly called after time out).
|
|
|
|
* See not above as to why this doesn't work. */
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Display an error or warning message.
|
|
|
|
* If display time > 0 the dialog disappears after displayTime 0.1 seconds
|
|
|
|
*
|
2007-12-05 20:54:11 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-05 20:54:11 +00:00
|
|
|
wxMessageDialog* dialog;
|
|
|
|
|
|
|
|
if( displaytime > 0 )
|
2009-05-21 17:42:42 +00:00
|
|
|
dialog = new WinEDA_MessageDialog( parent, text, _( "Warning" ),
|
|
|
|
wxOK | wxICON_INFORMATION,
|
|
|
|
displaytime );
|
2007-12-05 20:54:11 +00:00
|
|
|
else
|
2009-05-21 17:42:42 +00:00
|
|
|
dialog = new WinEDA_MessageDialog( parent, text, _( "Error" ),
|
|
|
|
wxOK | wxICON_ERROR, 0 );
|
2007-12-05 20:54:11 +00:00
|
|
|
|
|
|
|
dialog->ShowModal();
|
|
|
|
dialog->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Display an informational message.
|
2007-12-05 20:54:11 +00:00
|
|
|
*/
|
2009-11-23 15:16:50 +00:00
|
|
|
void DisplayInfoMessage( wxWindow* parent, const wxString& text,
|
|
|
|
int displaytime )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-05 20:54:11 +00:00
|
|
|
wxMessageDialog* dialog;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-03-22 11:34:14 +00:00
|
|
|
dialog = new WinEDA_MessageDialog( parent, text, _( "Info:" ),
|
|
|
|
wxOK | wxICON_INFORMATION, displaytime );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-06 18:54:57 +00:00
|
|
|
dialog->ShowModal();
|
|
|
|
dialog->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
bool IsOK( wxWindow* parent, const wxString& text )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-05 20:54:11 +00:00
|
|
|
int ii;
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
ii = wxMessageBox( text, _( "Confirmation" ),
|
|
|
|
wxYES_NO | wxCENTRE | wxICON_HAND, parent );
|
2007-12-05 20:54:11 +00:00
|
|
|
if( ii == wxYES )
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|