]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseterror.C
The markDirty() and fitCursor() changes
[lyx.git] / src / insets / inseterror.C
index 767548ffc40c8d23e44e91cd027a9d5dc2fc9c5d..38135356cd1a57c4bf2463967c00f912efdb0567 100644 (file)
@@ -1,41 +1,66 @@
-/* This file is part of
- * ======================================================
- * 
- *           LyX, The Document Processor
- *      
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2000 The LyX Team.
+/**
+ * \file inseterror.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * ====================================================== */
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include "inseterror.h"
 
 #include "BufferView.h"
-#include "font.h"
+#include "funcrequest.h"
 #include "gettext.h"
-#include "inseterror.h"
-#include "LyXView.h"
-#include "Painter.h"
+#include "lyxfont.h"
+
 #include "frontends/Dialogs.h"
+#include "frontends/font_metrics.h"
+#include "frontends/LyXView.h"
+#include "frontends/Painter.h"
+
+#include "support/LAssert.h"
 
 using std::ostream;
 
 /* Error, used for the LaTeX-Error Messages */
 
-InsetError::InsetError(string const & str)
+InsetError::InsetError(string const & str, bool)
        : contents(str)
 {}
 
 
+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;
        efont.setSize(font.size()).decSize();
-       return lyxfont::maxAscent(efont) + 1;
+       return font_metrics::maxAscent(efont) + 1;
 }
 
 
@@ -43,7 +68,7 @@ int InsetError::descent(BufferView *, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return lyxfont::maxDescent(efont) + 1;
+       return font_metrics::maxDescent(efont) + 1;
 }
 
 
@@ -51,18 +76,21 @@ int InsetError::width(BufferView *, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return 6 + lyxfont::width(_("Error"), efont);
+       return 6 + font_metrics::width(_("Error"), efont);
 }
 
 
 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();
        efont.setColor(LColor::error);
-   
+
        // Draw as "Error" in a framed box
        x += 1;
        pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
@@ -79,13 +107,19 @@ void InsetError::draw(BufferView * bv, LyXFont const & font,
 }
 
 
-string const InsetError::EditMessage() const 
+string const InsetError::editMessage() const
 {
        return _("Opened error");
 }
 
 
-void InsetError::Edit(BufferView * bv, int, int, unsigned int)
+void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
+{
+       bv->owner()->getDialogs().show("error", getContents(), this);
+}
+
+
+void InsetError::edit(BufferView * bv, bool)
 {
-       bv->owner()->getDialogs()->showError( this );
+       edit(bv, 0, 0, mouse_button::none);
 }