]> git.lyx.org Git - lyx.git/blob - src/frontends/Alert.C
add missing changelog
[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,
26            string const & b1, string const & b2, string const & b3)
27 {
28         if (lyx_gui::use_gui)
29                 return prompt_pimpl(title, question, default_button, b1, b2, b3);
30
31         lyxerr << title << endl;
32         lyxerr << "----------------------------------------" << endl;
33         lyxerr << question << endl;
34         lyxerr << "Assuming answer is ";
35         switch (default_button) {
36                 case 0: lyxerr << b1 << endl;
37                 case 1: lyxerr << b2 << endl;
38                 case 2: lyxerr << b3 << endl;
39         }
40         return default_button;
41 }
42
43
44 void Alert::warning(string const & title, string const & message)
45 {
46         if (lyx_gui::use_gui)
47                 return warning_pimpl(title, message);
48
49         lyxerr << "Warning: " << title << endl;
50         lyxerr << "----------------------------------------" << endl;
51         lyxerr << message << endl;
52 }
53
54
55 void Alert::error(string const & title, string const & message)
56 {
57         if (lyx_gui::use_gui)
58                 return error_pimpl(title, message);
59
60         lyxerr << "Error: " << title << endl;
61         lyxerr << "----------------------------------------" << endl;
62         lyxerr << message << endl;
63 }
64
65
66 void Alert::information(string const & title, string const & message)
67 {
68         if (lyx_gui::use_gui)
69                 return information_pimpl(title, message);
70
71         lyxerr << title << endl;
72         lyxerr << "----------------------------------------" << endl;
73         lyxerr << message << endl;
74 }
75
76
77 pair<bool, string> const Alert::askForText(string const & msg,
78                                            string const & dflt)
79 {
80         if (!lyx_gui::use_gui) {
81                 lyxerr << "----------------------------------------" << endl
82                        << msg << endl
83                        << "Assuming answer is " << dflt
84                        << "----------------------------------------" << endl;
85                 return make_pair<bool, string>(true, dflt);
86         } else {
87                 return askForText_pimpl(msg, dflt);
88         }
89 }