]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormErrorList.C
Change the semantics of 'none' and 'auto' viewers/editors: 'none' means now
[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 #include "FormErrorList.h"
14 #include "ControlErrorList.h"
15 #include "forms/form_errorlist.h"
16
17 #include "xformsBC.h"
18 #include "xforms_helpers.h"
19 #include "lyx_forms.h"
20
21 namespace lyx {
22 namespace frontend {
23
24 typedef FormController<ControlErrorList, FormView<FD_errorlist> > base_class;
25
26 FormErrorList::FormErrorList(Dialog & parent)
27         : base_class(parent, "")
28 {}
29
30
31 int dumb_validator(FL_OBJECT *, const char *, const char *, int)
32 {
33         return FL_INVALID;
34 }
35
36
37 void FormErrorList::build()
38 {
39         dialog_.reset(build_errorlist(this));
40         fl_set_input_filter(dialog_->input_description, dumb_validator);
41 }
42
43
44 void FormErrorList::update()
45 {
46         setTitle(controller().name());
47         updateContents();
48 }
49
50
51 ButtonPolicy::SMInput FormErrorList::input(FL_OBJECT * ob, long)
52 {
53         if (ob == dialog_->browser_errors) {
54                 //xforms return values 1..n
55                 int const choice = int(fl_get_browser(dialog_->browser_errors)) - 1;
56                 goTo(choice);
57         }
58
59         return ButtonPolicy::SMI_VALID;
60 }
61
62
63 void FormErrorList::goTo(int where)
64 {
65         ErrorList const & errors = controller().errorList();
66
67         if (0 <= where && where < int(errors.size())) {
68                 controller().goTo(where);
69                 fl_set_input(dialog_->input_description,
70                              errors[where].description.c_str());
71                 fl_set_input_topline(dialog_->input_description, 1);
72         }
73 }
74
75
76 void FormErrorList::updateContents()
77 {
78         fl_clear_browser(dialog_->browser_errors);
79
80         ErrorList const & errors = controller().errorList();
81         if (errors.empty()) {
82                 fl_add_browser_line(dialog_->browser_errors,
83                                     _("*** No Lists ***").c_str());
84                 setEnabled(dialog_->browser_errors, false);
85                 return;
86         }
87
88         setEnabled(dialog_->browser_errors, true);
89
90         ErrorList::const_iterator cit = errors.begin();
91         ErrorList::const_iterator end = errors.end();
92
93         for (; cit != end; ++cit) {
94                 fl_add_browser_line(dialog_->browser_errors,
95                                     cit->error.c_str());
96         }
97
98         fl_select_browser_line(dialog_->browser_errors, 1);
99         goTo(0);
100 }
101
102 } // namespace frontend
103 } // namespace lyx