]> git.lyx.org Git - lyx.git/blob - src/frontends/Alert.C
If I ever see another licence blurb again, it'll be too soon...
[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 "lyx_gui.h"
17
18 #include "Alert_pimpl.h"
19
20 using std::endl;
21 using std::pair;
22 using std::make_pair;
23
24 int Alert::prompt(string const & title, string const & question,
25            int default_button, int escape_button,
26            string const & b1, string const & b2, string const & b3)
27 {
28         if (lyx_gui::use_gui)
29                 return prompt_pimpl(title, question,
30                         default_button, escape_button, b1, b2, b3);
31
32         lyxerr << title << endl;
33         lyxerr << "----------------------------------------" << endl;
34         lyxerr << question << endl;
35         lyxerr << "Assuming answer is ";
36         switch (default_button) {
37                 case 0: lyxerr << b1 << endl;
38                 case 1: lyxerr << b2 << endl;
39                 case 2: lyxerr << b3 << endl;
40         }
41         return default_button;
42 }
43
44
45 void Alert::warning(string const & title, string const & message)
46 {
47         if (lyx_gui::use_gui)
48                 return warning_pimpl(title, message);
49
50         lyxerr << "Warning: " << title << endl;
51         lyxerr << "----------------------------------------" << endl;
52         lyxerr << message << endl;
53 }
54
55
56 void Alert::error(string const & title, string const & message)
57 {
58         if (lyx_gui::use_gui)
59                 return error_pimpl(title, message);
60
61         lyxerr << "Error: " << title << endl;
62         lyxerr << "----------------------------------------" << endl;
63         lyxerr << message << endl;
64 }
65
66
67 void Alert::information(string const & title, string const & message)
68 {
69         if (lyx_gui::use_gui)
70                 return information_pimpl(title, message);
71
72         lyxerr << title << endl;
73         lyxerr << "----------------------------------------" << endl;
74         lyxerr << message << endl;
75 }
76
77
78 pair<bool, string> const Alert::askForText(string const & msg,
79                                            string const & dflt)
80 {
81         if (!lyx_gui::use_gui) {
82                 lyxerr << "----------------------------------------" << endl
83                        << msg << endl
84                        << "Assuming answer is " << dflt
85                        << "----------------------------------------" << endl;
86                 return make_pair<bool, string>(true, dflt);
87         } else {
88                 return askForText_pimpl(msg, dflt);
89         }
90 }