-// -*- C++ -*-
-/* This file is part of
+/*
+ * \file FormError.C
+ * This file is part of
* ======================================================
*
* LyX, The Document Processor
*
- * Copyright 2000 The LyX Team.
+ * Copyright 2000-2001 The LyX Team.
*
* ======================================================
+ *
+ * \author Angus Leeming, a.leeming@.ac.uk
*/
-#include <config.h>
-
#ifdef __GNUG__
#pragma implementation
#endif
-#include "Dialogs.h"
+#include <config.h>
+
+#include "xformsBC.h"
+#include "ControlError.h"
#include "FormError.h"
#include "form_error.h"
+#include "xforms_helpers.h" // formatted
-static int minh, minw;
-
-FormError::FormError(LyXView * lv, Dialogs * d)
- : FormBase(lv, d, _("LaTeX Error")),
- dialog_(0), ih_(0), message_("")
-{
- // let the dialog be shown
- // This is a permanent connection so we won't bother
- // storing a copy because we won't be disconnecting.
- d->showError.connect(slot(this, &FormError::showInset));
-}
-
+typedef FormCB<ControlError, FormDB<FD_form_error> > base_class;
-FormError::~FormError()
-{
- delete dialog_;
-}
-
-
-void FormError::showInset( InsetError * const inset )
-{
- if( dialogIsOpen || inset == 0 ) return;
-
- ih_ = inset->hide.connect(slot(this, &FormError::hide));
-
- message_ = inset->getContents();
- show();
-}
-
-
-void FormError::update()
-{
- fl_set_form_minsize(form(), minw, minh);
- fl_set_object_label(dialog_->message, message_.c_str());
-}
+FormError::FormError(ControlError & c)
+ : base_class(c, _("LaTeX Error"))
+{}
void FormError::build()
{
- dialog_ = build_error();
-
- // XFORMS bug workaround
- // Define the min/max dimensions. Actually applied in update()
- minw = form()->w; minh = form()->h;
-}
+ dialog_.reset(build_error());
-
-void FormError::clearStore()
-{
- ih_.disconnect();
- message_.empty();
+ // Manage the cancel/close button
+ bc().setCancel(dialog_->button_cancel);
}
-FL_FORM * const FormError::form() const
+void FormError::update()
{
- if( dialog_ ) // no need to test for dialog_->form
- return dialog_->form;
- else
- return 0;
+ string const txt = formatted(controller().params(),
+ dialog_->message->w - 10);
+ fl_set_object_label(dialog_->message, txt.c_str());
}