2001-11-26 10:19:58 +00:00
|
|
|
/**
|
|
|
|
* \file Alert.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-11-26 10:19:58 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-11-26 10:19:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
#include "Alert.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
#include "Alert_pimpl.h"
|
2002-02-16 15:59:55 +00:00
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
#include "debug.h"
|
2006-10-15 21:47:29 +00:00
|
|
|
#include "lyx_main.h" // for lyx::use_gui
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
using lyx::docstring;
|
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
using std::endl;
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::make_pair;
|
2003-09-05 10:55:42 +00:00
|
|
|
using std::pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2003-09-05 10:55:42 +00:00
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
|
2006-10-07 16:47:54 +00:00
|
|
|
namespace lyx {
|
2006-10-12 14:10:13 +00:00
|
|
|
|
2006-10-07 16:47:54 +00:00
|
|
|
namespace frontend {
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
int Alert::prompt(docstring const & title, docstring const & question,
|
2004-10-05 10:11:42 +00:00
|
|
|
int default_button, int escape_button,
|
2006-09-11 08:54:10 +00:00
|
|
|
docstring const & b1, docstring const & b2, docstring const & b3)
|
2002-02-16 15:59:55 +00:00
|
|
|
{
|
2006-10-12 14:10:13 +00:00
|
|
|
if (!lyx::use_gui || lyxerr.debugging()) {
|
2006-09-11 08:54:10 +00:00
|
|
|
lyxerr << lyx::to_utf8(title) << '\n'
|
2004-05-25 16:27:06 +00:00
|
|
|
<< "----------------------------------------\n"
|
2006-09-11 08:54:10 +00:00
|
|
|
<< lyx::to_utf8(question) << endl;
|
2003-09-02 08:26:20 +00:00
|
|
|
|
|
|
|
lyxerr << "Assuming answer is ";
|
|
|
|
switch (default_button) {
|
2006-09-11 08:54:10 +00:00
|
|
|
case 0: lyxerr << lyx::to_utf8(b1) << endl;
|
|
|
|
case 1: lyxerr << lyx::to_utf8(b2) << endl;
|
|
|
|
case 2: lyxerr << lyx::to_utf8(b3) << endl;
|
2003-09-02 08:26:20 +00:00
|
|
|
}
|
2006-10-12 14:10:13 +00:00
|
|
|
if (!lyx::use_gui)
|
2003-09-02 08:26:20 +00:00
|
|
|
return default_button;
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
2003-09-02 08:26:20 +00:00
|
|
|
|
|
|
|
return prompt_pimpl(title, question,
|
|
|
|
default_button, escape_button, b1, b2, b3);
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
void Alert::warning(docstring const & title, docstring const & message)
|
2003-03-29 09:02:08 +00:00
|
|
|
{
|
2006-10-12 14:10:13 +00:00
|
|
|
if (!lyx::use_gui || lyxerr.debugging())
|
2006-09-11 08:54:10 +00:00
|
|
|
lyxerr << "Warning: " << lyx::to_utf8(title) << '\n'
|
2004-05-25 16:27:06 +00:00
|
|
|
<< "----------------------------------------\n"
|
2006-09-11 08:54:10 +00:00
|
|
|
<< lyx::to_utf8(message) << endl;
|
2006-10-12 14:10:13 +00:00
|
|
|
if (lyx::use_gui)
|
2003-09-02 08:26:20 +00:00
|
|
|
warning_pimpl(title, message);
|
2003-03-29 09:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
void Alert::error(docstring const & title, docstring const & message)
|
2003-03-29 09:02:08 +00:00
|
|
|
{
|
2006-10-12 14:10:13 +00:00
|
|
|
if (!lyx::use_gui || lyxerr.debugging())
|
2006-09-11 08:54:10 +00:00
|
|
|
lyxerr << "Error: " << lyx::to_utf8(title) << '\n'
|
2003-09-02 08:26:20 +00:00
|
|
|
<< "----------------------------------------\n"
|
2006-09-11 08:54:10 +00:00
|
|
|
<< lyx::to_utf8(message) << endl;
|
2003-03-29 09:02:08 +00:00
|
|
|
|
2006-10-12 14:10:13 +00:00
|
|
|
if (lyx::use_gui)
|
2003-09-02 08:26:20 +00:00
|
|
|
error_pimpl(title, message);
|
2003-03-29 09:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
void Alert::information(docstring const & title, docstring const & message)
|
2003-03-29 09:02:08 +00:00
|
|
|
{
|
2006-10-12 14:10:13 +00:00
|
|
|
if (!lyx::use_gui || lyxerr.debugging())
|
2006-09-11 08:54:10 +00:00
|
|
|
lyxerr << lyx::to_utf8(title) << '\n'
|
2004-05-25 16:27:06 +00:00
|
|
|
<< "----------------------------------------\n"
|
2006-09-11 08:54:10 +00:00
|
|
|
<< lyx::to_utf8(message) << endl;
|
2003-03-29 09:02:08 +00:00
|
|
|
|
2006-10-12 14:10:13 +00:00
|
|
|
if (lyx::use_gui)
|
2003-09-02 08:26:20 +00:00
|
|
|
information_pimpl(title, message);
|
2003-03-29 09:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
pair<bool, docstring> const Alert::askForText(docstring const & msg,
|
|
|
|
docstring const & dflt)
|
2002-02-16 15:59:55 +00:00
|
|
|
{
|
2006-10-12 14:10:13 +00:00
|
|
|
if (!lyx::use_gui || lyxerr.debugging()) {
|
2003-09-02 08:26:20 +00:00
|
|
|
lyxerr << "----------------------------------------\n"
|
2006-09-11 08:54:10 +00:00
|
|
|
<< lyx::to_utf8(msg) << '\n'
|
|
|
|
<< "Assuming answer is " << lyx::to_utf8(dflt) << '\n'
|
2002-02-16 15:59:55 +00:00
|
|
|
<< "----------------------------------------" << endl;
|
2006-10-12 14:10:13 +00:00
|
|
|
if (!lyx::use_gui)
|
2006-09-11 08:54:10 +00:00
|
|
|
return make_pair<bool, docstring>(true, dflt);
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
2003-09-02 08:26:20 +00:00
|
|
|
|
|
|
|
return askForText_pimpl(msg, dflt);
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
2006-10-07 16:47:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|