]> git.lyx.org Git - lyx.git/blob - src/frontends/Alert.C
more Alert:: work
[lyx.git] / src / frontends / Alert.C
1 /**
2  * \file Alert.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.h"
14
15 #include "debug.h"
16 #include "lyxrc.h"
17
18 #include "Alert_pimpl.h"
19
20 using std::endl;
21 using std::pair;
22 using std::make_pair;
23
24 void Alert::alert(string const & s1, string const & s2, string const & s3)
25 {
26         if (!lyxrc.use_gui) {
27                 lyxerr << "------------------------------" << endl
28                        << s1 << endl << s2 << endl << s3 << endl
29                        << "------------------------------" << endl;
30         } else {
31                 alert_pimpl(s1, s2, s3);
32         }
33 }
34
35
36 int Alert::prompt(string const & title, string const & question,
37            int default_button,
38            string const & b1, string const & b2, string const & b3)
39 {
40         if (lyxrc.use_gui)
41                 return prompt_pimpl(title, question, default_button, b1, b2, b3);
42
43         lyxerr << title << endl;
44         lyxerr << "----------------------------------------" << endl;
45         lyxerr << question << endl;
46         lyxerr << "Assuming answer is ";
47         switch (default_button) {
48                 case 0: lyxerr << b1 << endl;
49                 case 1: lyxerr << b2 << endl;
50                 case 2: lyxerr << b3 << endl;
51         }
52         return default_button;
53 }
54
55
56 void Alert::warning(string const & title, string const & message)
57 {
58         if (lyxrc.use_gui)
59                 return warning_pimpl(title, message);
60
61         lyxerr << "Warning: " << title << endl;
62         lyxerr << "----------------------------------------" << endl;
63         lyxerr << message << endl;
64 }
65
66
67 void Alert::error(string const & title, string const & message)
68 {
69         if (lyxrc.use_gui)
70                 return error_pimpl(title, message);
71
72         lyxerr << "Error: " << title << endl;
73         lyxerr << "----------------------------------------" << endl;
74         lyxerr << message << endl;
75 }
76
77
78 void Alert::information(string const & title, string const & message)
79 {
80         if (lyxrc.use_gui)
81                 return information_pimpl(title, message);
82
83         lyxerr << title << endl;
84         lyxerr << "----------------------------------------" << endl;
85         lyxerr << message << endl;
86 }
87
88
89 pair<bool, string> const Alert::askForText(string const & msg,
90                                            string const & dflt)
91 {
92         if (!lyxrc.use_gui) {
93                 lyxerr << "----------------------------------------" << endl
94                        << msg << endl
95                        << "Assuming answer is " << dflt
96                        << "----------------------------------------" << endl;
97                 return make_pair<bool, string>(true, dflt);
98         } else {
99                 return askForText_pimpl(msg, dflt);
100         }
101 }