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