]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Alert_pimpl.C
Strip out another 180 #includes.
[lyx.git] / src / frontends / xforms / Alert_pimpl.C
1 /**
2  * \file xforms/Alert_pimpl.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Alert_pimpl.h"
14
15 #include "forms_gettext.h"
16 #include "xforms_helpers.h"
17
18 #include "debug.h"
19 #include "gettext.h"
20
21 #include <boost/tuple/tuple.hpp>
22
23 #include "lyx_forms.h"
24
25 using std::endl;
26 using std::make_pair;
27 using std::pair;
28
29
30 void warning_pimpl(string const &, string const & message)
31 {
32         fl_show_messages(formatted(message, 300).c_str());
33 }
34
35
36 void error_pimpl(string const &, string const & message)
37 {
38         fl_show_messages(formatted(message, 300).c_str());
39 }
40
41
42 void information_pimpl(string const &, string const & message)
43 {
44         fl_show_messages(formatted(message, 300).c_str());
45 }
46
47
48 int prompt_pimpl(string const &, string const & question,
49            int default_button, int /*escape_button*/,
50            string const & b1, string const & b2, string const & b3)
51 {
52         string b1label, b1sc;
53         string b2label, b2sc;
54         string b3label, b3sc;
55         boost::tie(b1label, b1sc) = parse_shortcut(b1);
56         boost::tie(b2label, b2sc) = parse_shortcut(b2);
57         boost::tie(b3label, b3sc) = parse_shortcut(b3);
58
59         if (b3.empty()) {
60                 fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), "");
61                 return fl_show_choices(formatted(question, 300).c_str(),
62                         2, b1label.c_str(), b2label.c_str(), "", default_button + 1) - 1;
63         } else {
64                 fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), b3sc.c_str());
65                 return fl_show_choices(formatted(question, 300).c_str(),
66                         3, b1label.c_str(), b2label.c_str(), b3label.c_str(),
67                         default_button + 1) - 1;
68         }
69 }
70
71
72 pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
73 {
74         fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")).c_str());
75         fl_set_resource("flInput.ok.label", idex(_("OK|^M")).c_str());
76         fl_set_resource("flInput.clear.label", idex(_("Clear|#C")).c_str());
77         char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
78         if (tmp != 0)
79                 return make_pair<bool, string>(true, string(tmp));
80         else
81                 return make_pair<bool, string>(false, string());
82 }