]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormErrorList.C
Change the semantics of 'none' and 'auto' viewers/editors: 'none' means now
[lyx.git] / src / frontends / xforms / FormErrorList.C
index 03deb549e3c1cc3a1df486e662c767a5e1bfcec9..20b6db069b7128b1bde4b408e5822a632eb8cbed 100644 (file)
  *
  * \author Alfredo Braunstein
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-
 #include "FormErrorList.h"
-#include "xformsBC.h"
-#include "xforms_helpers.h"
 #include "ControlErrorList.h"
 #include "forms/form_errorlist.h"
-#include "support/lstrings.h" // frontStrip, strip
-#include "debug.h"
-#include "gettext.h"
-#include "lyx_forms.h"
 
-#include <vector>
-
-using std::vector;
-using std::endl;
+#include "xformsBC.h"
+#include "xforms_helpers.h"
+#include "lyx_forms.h"
 
+namespace lyx {
+namespace frontend {
 
 typedef FormController<ControlErrorList, FormView<FD_errorlist> > base_class;
 
 FormErrorList::FormErrorList(Dialog & parent)
-       : base_class(parent, _("LaTeX error list"))
+       : base_class(parent, "")
 {}
 
 
+int dumb_validator(FL_OBJECT *, const char *, const char *, int)
+{
+       return FL_INVALID;
+}
+
+
 void FormErrorList::build()
 {
        dialog_.reset(build_errorlist(this));
-
-       // Manage the cancel/close button
-       bcview().setCancel(dialog_->button_close);
-       bcview().addReadOnly(dialog_->browser_errors);
+       fl_set_input_filter(dialog_->input_description, dumb_validator);
 }
 
 
 void FormErrorList::update()
 {
+       setTitle(controller().name());
        updateContents();
 }
 
 
 ButtonPolicy::SMInput FormErrorList::input(FL_OBJECT * ob, long)
 {
-       std::vector<ControlErrorList::ErrorItem> const &
-               Errors = controller().ErrorList();
-
        if (ob == dialog_->browser_errors) {
                //xforms return values 1..n
                int const choice = int(fl_get_browser(dialog_->browser_errors)) - 1;
-               if (0 <= choice && choice < int(Errors.size())) {
-                       controller().goTo(choice);
-                       fl_set_input(dialog_->input_description,
-                                    Errors[choice].description.c_str());
-               }
-               return ButtonPolicy::SMI_VALID;
+               goTo(choice);
        }
 
-       updateContents();
-
        return ButtonPolicy::SMI_VALID;
 }
 
 
+void FormErrorList::goTo(int where)
+{
+       ErrorList const & errors = controller().errorList();
+
+       if (0 <= where && where < int(errors.size())) {
+               controller().goTo(where);
+               fl_set_input(dialog_->input_description,
+                            errors[where].description.c_str());
+               fl_set_input_topline(dialog_->input_description, 1);
+       }
+}
+
+
 void FormErrorList::updateContents()
 {
-       std::vector<ControlErrorList::ErrorItem> const &
-               Errors = controller().ErrorList();
+       fl_clear_browser(dialog_->browser_errors);
 
-       if (Errors.empty()) {
-               fl_clear_browser(dialog_->browser_errors);
+       ErrorList const & errors = controller().errorList();
+       if (errors.empty()) {
                fl_add_browser_line(dialog_->browser_errors,
-                                   _("*** No Lists ***"));
+                                   _("*** No Lists ***").c_str());
                setEnabled(dialog_->browser_errors, false);
                return;
        }
 
-       unsigned int const topline =
-               fl_get_browser_topline(dialog_->browser_errors);
-       unsigned int const line = fl_get_browser(dialog_->browser_errors);
-
-       fl_clear_browser(dialog_->browser_errors);
        setEnabled(dialog_->browser_errors, true);
 
-       std::vector<ControlErrorList::ErrorItem>::const_iterator
-               cit = Errors.begin();
-       std::vector<ControlErrorList::ErrorItem>::const_iterator
-               end = Errors.end();
+       ErrorList::const_iterator cit = errors.begin();
+       ErrorList::const_iterator end = errors.end();
 
        for (; cit != end; ++cit) {
                fl_add_browser_line(dialog_->browser_errors,
                                    cit->error.c_str());
        }
 
-       fl_set_browser_topline(dialog_->browser_errors, topline);
-       fl_select_browser_line(dialog_->browser_errors, line);
+       fl_select_browser_line(dialog_->browser_errors, 1);
+       goTo(0);
 }
+
+} // namespace frontend
+} // namespace lyx