]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Alert_pimpl.C
remove defaults stuff, let Qt handle no toolbar
[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
14 #include "Alert.h"
15 #include "Alert_pimpl.h"
16 #include "forms_gettext.h"
17 #include "gettext.h"
18 #include "xforms_helpers.h"
19
20 #include <algorithm>
21 #include <boost/tuple/tuple.hpp>
22 #include FORMS_H_LOCATION
23
24 using std::pair;
25 using std::make_pair;
26 using std::endl;
27
28 void warning_pimpl(string const &, string const & message)
29 {
30         fl_show_messages(formatted(message, 300).c_str());
31 }
32
33
34 void error_pimpl(string const &, string const & message)
35 {
36         fl_show_messages(formatted(message, 300).c_str());
37 }
38
39
40 void information_pimpl(string const &, string const & message)
41 {
42         fl_show_messages(formatted(message, 300).c_str());
43 }
44
45
46 int prompt_pimpl(string const &, string const & question,
47            int default_button,
48            string const & b1, string const & b2, string const & b3)
49 {
50         string b1label, b1sc;
51         string b2label, b2sc;
52         string b3label, b3sc;
53         boost::tie(b1label, b1sc) = parse_shortcut(b1);
54         boost::tie(b2label, b2sc) = parse_shortcut(b2);
55         boost::tie(b3label, b3sc) = parse_shortcut(b3);
56
57         if (b3.empty()) {
58                 fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), "");
59                 return fl_show_choices(formatted(question, 300).c_str(),
60                         2, b1label.c_str(), b2label.c_str(), "", default_button + 1) - 1;
61         } else {
62                 fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), b3sc.c_str());
63                 return fl_show_choices(formatted(question, 300).c_str(),
64                         3, b1label.c_str(), b2label.c_str(), b3label.c_str(),
65                         default_button + 1) - 1;
66         }
67 }
68
69
70 pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
71 {
72         fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")).c_str());
73         fl_set_resource("flInput.ok.label", idex(_("OK|^M")).c_str());
74         fl_set_resource("flInput.clear.label", idex(_("Clear|#C")).c_str());
75         char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
76         if (tmp != 0)
77                 return make_pair<bool, string>(true, string(tmp));
78         else
79                 return make_pair<bool, string>(false, string());
80 }