2001-11-26 10:19:58 +00:00
|
|
|
/**
|
2002-03-11 22:47:41 +00:00
|
|
|
* \file xforms/Alert_pimpl.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-09-05 14:10:50 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
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-03-21 21:21:28 +00:00
|
|
|
#include "Alert_pimpl.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms_gettext.h"
|
2003-03-29 08:45:28 +00:00
|
|
|
#include "xforms_helpers.h"
|
2002-03-11 17:00:41 +00:00
|
|
|
|
2003-09-04 03:54:04 +00:00
|
|
|
#include "debug.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
#include "gettext.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
2003-03-29 08:45:28 +00:00
|
|
|
#include <boost/tuple/tuple.hpp>
|
2003-09-05 13:15:43 +00:00
|
|
|
|
2003-05-14 09:17:22 +00:00
|
|
|
#include "lyx_forms.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2003-09-05 13:15:43 +00:00
|
|
|
using std::make_pair;
|
|
|
|
using std::pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2003-09-05 13:15:43 +00:00
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
|
2003-03-29 09:02:08 +00:00
|
|
|
void warning_pimpl(string const &, string const & message)
|
|
|
|
{
|
2003-04-01 15:17:26 +00:00
|
|
|
fl_show_messages(formatted(message, 300).c_str());
|
2003-03-29 09:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void error_pimpl(string const &, string const & message)
|
|
|
|
{
|
2003-04-01 15:17:26 +00:00
|
|
|
fl_show_messages(formatted(message, 300).c_str());
|
2003-03-29 09:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void information_pimpl(string const &, string const & message)
|
|
|
|
{
|
2003-04-01 15:17:26 +00:00
|
|
|
fl_show_messages(formatted(message, 300).c_str());
|
2003-03-29 09:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-29 08:45:28 +00:00
|
|
|
int prompt_pimpl(string const &, string const & question,
|
2003-04-27 16:40:50 +00:00
|
|
|
int default_button, int /*escape_button*/,
|
2003-03-29 08:45:28 +00:00
|
|
|
string const & b1, string const & b2, string const & b3)
|
2001-11-26 10:19:58 +00:00
|
|
|
{
|
2003-03-29 08:45:28 +00:00
|
|
|
string b1label, b1sc;
|
|
|
|
string b2label, b2sc;
|
|
|
|
string b3label, b3sc;
|
|
|
|
boost::tie(b1label, b1sc) = parse_shortcut(b1);
|
|
|
|
boost::tie(b2label, b2sc) = parse_shortcut(b2);
|
|
|
|
boost::tie(b3label, b3sc) = parse_shortcut(b3);
|
|
|
|
|
2003-03-29 07:09:13 +00:00
|
|
|
if (b3.empty()) {
|
2003-03-29 08:45:28 +00:00
|
|
|
fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), "");
|
2003-04-01 15:17:26 +00:00
|
|
|
return fl_show_choices(formatted(question, 300).c_str(),
|
2003-03-29 08:45:28 +00:00
|
|
|
2, b1label.c_str(), b2label.c_str(), "", default_button + 1) - 1;
|
2003-03-29 07:09:13 +00:00
|
|
|
} else {
|
2003-03-29 08:45:28 +00:00
|
|
|
fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), b3sc.c_str());
|
2003-04-01 15:17:26 +00:00
|
|
|
return fl_show_choices(formatted(question, 300).c_str(),
|
2003-03-29 08:45:28 +00:00
|
|
|
3, b1label.c_str(), b2label.c_str(), b3label.c_str(),
|
|
|
|
default_button + 1) - 1;
|
2003-03-29 07:09:13 +00:00
|
|
|
}
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
|
|
|
|
{
|
2002-11-29 09:26:53 +00:00
|
|
|
fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")).c_str());
|
2003-02-27 15:53:23 +00:00
|
|
|
fl_set_resource("flInput.ok.label", idex(_("OK|^M")).c_str());
|
|
|
|
fl_set_resource("flInput.clear.label", idex(_("Clear|#C")).c_str());
|
2001-11-26 10:19:58 +00:00
|
|
|
char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
|
|
|
|
if (tmp != 0)
|
2002-03-21 16:59:12 +00:00
|
|
|
return make_pair<bool, string>(true, string(tmp));
|
2001-11-26 10:19:58 +00:00
|
|
|
else
|
2002-03-21 16:59:12 +00:00
|
|
|
return make_pair<bool, string>(false, string());
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|