]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Alert_pimpl.C
Make shortcuts consistent with the rest of LyX.
[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
19 #include <algorithm>
20 #include FORMS_H_LOCATION
21
22 using std::pair;
23 using std::make_pair;
24
25 void alert_pimpl(string const & s1, string const & s2, string const & s3)
26 {
27         fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
28         fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
29 }
30
31
32 bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
33 {
34         fl_set_resource("flQuestion.yes.label", idex(_("Yes|#y")).c_str());
35         fl_set_resource("flQuestion.no.label", idex(_("No|#n")).c_str());
36         return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
37 }
38
39
40 int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
41 {
42         string const yes    = _("Yes|#Y");
43         string const no     = _("No|#N");
44         string const cancel = _("Cancel|^[");
45         
46         fl_set_choices_shortcut(scex(yes).c_str(), scex(no).c_str(),
47                                 scex(cancel).c_str());
48         return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(),
49                               3, idex(yes).c_str(), idex(no).c_str(),
50                               idex(cancel).c_str(), 3);
51 }
52
53
54 pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
55 {
56         fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")).c_str());
57         fl_set_resource("flInput.ok.label", idex(_("OK|^M")).c_str());
58         fl_set_resource("flInput.clear.label", idex(_("Clear|#C")).c_str());
59         char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
60         if (tmp != 0)
61                 return make_pair<bool, string>(true, string(tmp));
62         else
63                 return make_pair<bool, string>(false, string());
64 }