]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormErrorList.C
Get rid of "char const * _(char const *)".
[lyx.git] / src / frontends / xforms / FormErrorList.C
1 /**
2  * \file FormErrorList.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alfredo Braunstein
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13
14 #include "FormErrorList.h"
15 #include "xformsBC.h"
16 #include "xforms_helpers.h"
17 #include "ControlErrorList.h"
18 #include "forms/form_errorlist.h"
19 #include "support/lstrings.h" // frontStrip, strip
20 #include "debug.h"
21 #include "gettext.h"
22 #include "lyx_forms.h"
23
24 #include <vector>
25
26 using std::vector;
27 using std::endl;
28
29
30 typedef FormController<ControlErrorList, FormView<FD_errorlist> > base_class;
31
32 FormErrorList::FormErrorList(Dialog & parent)
33         : base_class(parent, _("LaTeX error list"))
34 {}
35
36
37 void FormErrorList::build()
38 {
39         dialog_.reset(build_errorlist(this));
40
41         // Manage the cancel/close button
42         bcview().setCancel(dialog_->button_close);
43         bcview().addReadOnly(dialog_->browser_errors);
44 }
45
46
47 void FormErrorList::update()
48 {
49         updateContents();
50 }
51
52
53 ButtonPolicy::SMInput FormErrorList::input(FL_OBJECT * ob, long)
54 {
55         std::vector<ControlErrorList::ErrorItem> const &
56                 Errors = controller().ErrorList();
57
58         if (ob == dialog_->browser_errors) {
59                 //xforms return values 1..n
60                 int const choice = int(fl_get_browser(dialog_->browser_errors)) - 1;
61                 if (0 <= choice && choice < int(Errors.size())) {
62                         controller().goTo(choice);
63                         fl_set_input(dialog_->input_description,
64                                      Errors[choice].description.c_str());
65                 }
66                 return ButtonPolicy::SMI_VALID;
67         }
68
69         updateContents();
70
71         return ButtonPolicy::SMI_VALID;
72 }
73
74
75 void FormErrorList::updateContents()
76 {
77         std::vector<ControlErrorList::ErrorItem> const &
78                 Errors = controller().ErrorList();
79
80         if (Errors.empty()) {
81                 fl_clear_browser(dialog_->browser_errors);
82                 fl_add_browser_line(dialog_->browser_errors,
83                                     _("*** No Lists ***").c_str());
84                 setEnabled(dialog_->browser_errors, false);
85                 return;
86         }
87
88         unsigned int const topline =
89                 fl_get_browser_topline(dialog_->browser_errors);
90         unsigned int const line = fl_get_browser(dialog_->browser_errors);
91
92         fl_clear_browser(dialog_->browser_errors);
93         setEnabled(dialog_->browser_errors, true);
94
95         std::vector<ControlErrorList::ErrorItem>::const_iterator
96                 cit = Errors.begin();
97         std::vector<ControlErrorList::ErrorItem>::const_iterator
98                 end = Errors.end();
99
100         for (; cit != end; ++cit) {
101                 fl_add_browser_line(dialog_->browser_errors,
102                                     cit->error.c_str());
103         }
104
105         fl_set_browser_topline(dialog_->browser_errors, topline);
106         fl_select_browser_line(dialog_->browser_errors, line);
107 }