]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormError.C
try this for distinguishing inner and outer tabs
[lyx.git] / src / frontends / xforms / FormError.C
index 094d7188473c533ae39d09d2a107be76fdb23933..46345e92f4bc674888bf3e6b237a709795361ae0 100644 (file)
 #include "Dialogs.h"
 #include "FormError.h"
 #include "form_error.h"
+#include "insets/inseterror.h"
+#include "support/LAssert.h"
 
-static int minh, minw;
 
 FormError::FormError(LyXView * lv, Dialogs * d)
-       : FormBase(lv, d, _("LaTeX Error")),
-         dialog_(0), ih_(0), message_("")
+       : FormInset( lv, d, _("LaTeX Error"), new OkCancelPolicy),
+         dialog_(0), inset_(0)
 {
+       Assert(lv && d);
        // let the dialog be shown
        // This is a permanent connection so we won't bother
        // storing a copy because we won't be disconnecting.
@@ -38,45 +40,51 @@ FormError::~FormError()
 }
 
 
-void FormError::showInset( InsetError * const inset )
+FL_FORM * FormError::form() const
 {
-       if( dialogIsOpen || inset == 0 ) return;
-
-       ih_ = inset->hide.connect(slot(this, &FormError::hide));
-
-       message_ = inset->getContents();
-       show();
+       if (dialog_) return dialog_->form;
+       return 0;
 }
 
 
-void FormError::update()
+void FormError::disconnect()
 {
-       fl_set_form_minsize(form(), minw, minh);
-       fl_set_object_label(dialog_->message, message_.c_str());
+       inset_ = 0;
+       message_.erase();
+       FormInset::disconnect();
 }
 
 
-void FormError::build()
+void FormError::showInset(InsetError * inset)
 {
-       dialog_ = build_error();
+       if (inset == 0) return; // Is this _really_ allowed? (Lgb)
 
-       // XFORMS bug workaround
-       // Define the min/max dimensions. Actually applied in update()
-       minw = form()->w; minh = form()->h;
+       // If connected to another inset, disconnect from it.
+       if (inset_)
+               ih_.disconnect();
+
+       inset_ = inset;
+       message_ = inset->getContents();
+       ih_ = inset->hideDialog.connect(slot(this, &FormError::hide));
+       show();
 }
 
 
-void FormError::clearStore()
+void FormError::update()
 {
-       ih_.disconnect();
-       message_.empty();
+       fl_set_object_label(dialog_->message, message_.c_str());
 }
 
 
-FL_FORM * const FormError::form() const
+void FormError::build()
 {
-       if( dialog_ ) // no need to test for dialog_->form
-               return dialog_->form;
-       else
-               return 0;
+       dialog_ = build_error();
+
+       // Workaround dumb xforms sizing bug
+       minw_ = form()->w;
+       minh_ = form()->h;
+       
+        // Manage the cancel/close button
+       bc_.setCancel(dialog_->button_cancel);
+       bc_.refresh();
 }