lyx_mirror/src/frontends/Alert.C
John Levon 37a1ffccb9 Big shake up of all Alert::askQuestion/Confirmation into something
hopefully a lot better.

Warning: this may negatively affect your muscle memory :(


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6622 a592a061-630c-0410-9148-cb99ea01b6c8
2003-03-29 07:09:13 +00:00

82 lines
1.8 KiB
C

/**
* \file Alert.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
*
* Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "Alert.h"
#include "debug.h"
#include "lyxrc.h"
#include "Alert_pimpl.h"
#include <cerrno>
#ifndef CXX_GLOBAL_CSTD
using std::strerror;
#endif
using std::endl;
using std::pair;
using std::make_pair;
void Alert::alert(string const & s1, string const & s2, string const & s3)
{
if (!lyxrc.use_gui) {
lyxerr << "------------------------------" << endl
<< s1 << endl << s2 << endl << s3 << endl
<< "------------------------------" << endl;
} else {
alert_pimpl(s1, s2, s3);
}
}
void Alert::err_alert(string const & s1, string const & s2)
{
alert(s1, s2, strerror(errno));
}
int Alert::prompt(string const & title, string const & question,
int default_button,
string const & b1, string const & b2, string const & b3)
{
if (lyxrc.use_gui)
return prompt_pimpl(title, question, default_button, b1, b2, b3);
lyxerr << title << endl;
lyxerr << "----------------------------------------" << endl;
lyxerr << question << endl;
lyxerr << "Assuming answer is ";
switch (default_button) {
case 0: lyxerr << b1 << endl;
case 1: lyxerr << b2 << endl;
case 2: lyxerr << b3 << endl;
}
return default_button;
}
pair<bool, string> const Alert::askForText(string const & msg,
string const & dflt)
{
if (!lyxrc.use_gui) {
lyxerr << "----------------------------------------" << endl
<< msg << endl
<< "Assuming answer is " << dflt
<< "----------------------------------------" << endl;
return make_pair<bool, string>(true, dflt);
} else {
return askForText_pimpl(msg, dflt);
}
}