]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseterror.C
The markDirty() and fitCursor() changes
[lyx.git] / src / insets / inseterror.C
index 77bcc09dc59f1e067ccb35253415fc878c8f352c..38135356cd1a57c4bf2463967c00f912efdb0567 100644 (file)
@@ -1,27 +1,28 @@
-/* This file is part of
- * ======================================================
+/**
+ * \file inseterror.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Lars Gullik Bjønnes
  *
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include "inseterror.h"
 
 #include "BufferView.h"
-#include "frontends/font_metrics.h"
-#include "lyxfont.h"
+#include "funcrequest.h"
 #include "gettext.h"
-#include "inseterror.h"
+#include "lyxfont.h"
+
+#include "frontends/Dialogs.h"
+#include "frontends/font_metrics.h"
 #include "frontends/LyXView.h"
 #include "frontends/Painter.h"
-#include "frontends/Dialogs.h"
+
+#include "support/LAssert.h"
 
 using std::ostream;
 
@@ -32,6 +33,29 @@ InsetError::InsetError(string const & str, bool)
 {}
 
 
+InsetError::~InsetError()
+{
+       Dialogs::hide("error", this);
+}
+
+
+dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
+{
+       dispatch_result result = UNDISPATCHED;
+
+       switch (cmd.action) {
+       case LFUN_MOUSE_RELEASE:
+               edit(cmd.view(), cmd.x, cmd.y, cmd.button());
+               break;
+
+       default:
+               break;
+       }
+
+       return result;
+}
+
+
 int InsetError::ascent(BufferView *, LyXFont const & font) const
 {
        LyXFont efont;
@@ -57,8 +81,11 @@ int InsetError::width(BufferView *, LyXFont const & font) const
 
 
 void InsetError::draw(BufferView * bv, LyXFont const & font,
-                     int baseline, float & x, bool) const
+                     int baseline, float & x) const
 {
+       lyx::Assert(bv);
+       cache(bv);
+
        Painter & pain = bv->painter();
        LyXFont efont;
        efont.setSize(font.size()).decSize();
@@ -88,7 +115,7 @@ string const InsetError::editMessage() const
 
 void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
 {
-       bv->owner()->getDialogs().showError(this);
+       bv->owner()->getDialogs().show("error", getContents(), this);
 }