]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Alert_pimpl.C
033b1851243c28ac58b7d7fcdd386fd2582b0919
[lyx.git] / src / frontends / xforms / Alert_pimpl.C
1 /**
2  * \file Alert_pimpl.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon, moz@compsoc.man.ac.uk
7  */
8
9 #include <config.h>
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include "Alert.h"
16 #include "Alert_pimpl.h" 
17 #include "xforms_helpers.h"
18 #include "gettext.h"
19
20 #include <algorithm>
21 #include FORMS_H_LOCATION
22  
23 using std::pair;
24 using std::make_pair;
25
26 void alert_pimpl(string const & s1, string const & s2, string const & s3)
27 {
28         fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
29         fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
30 }
31
32
33 bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3)
34 {
35         fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")));
36         fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")));
37         return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
38 }
39
40
41 int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
42 {
43         fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
44                                 scex(_("No|Nn#n")),
45                                 scex(_("Cancel|^[")));
46         return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(), 
47                               3, idex(_("Yes|Yy#y")),
48                               idex(_("No|Nn#n")),
49                               idex(_("Cancel|^[")), 3);
50 }
51
52
53 pair<bool, string> const askForText_pimpl(string const & msg, string const & dflt)
54 {
55         fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")));
56         fl_set_resource("flInput.ok.label", idex(_("OK|#O")));
57         fl_set_resource("flInput.clear.label", idex(_("Clear|#e")));
58         char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
59         if (tmp != 0)
60           return make_pair<bool, string>(true, string(tmp));
61         else
62           return make_pair<bool, string>(false, string());
63 }