]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbutton.C
The markDirty() and fitCursor() changes
[lyx.git] / src / insets / insetbutton.C
index eef13251ef0988e9704ec28d61ffd6ed8bf4d480..53ea6738142499dbaf65642d0ecb4aa797712c6f 100644 (file)
@@ -1,22 +1,22 @@
-/* This file is part of
- * ======================================================
+/**
+ * \file insetbutton.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Asger Alstrup Nielsen
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
  *
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 2000-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "insetbutton.h"
 #include "debug.h"
 #include "BufferView.h"
+#include "frontends/LyXView.h"
 #include "frontends/Painter.h"
 #include "support/LAssert.h"
 #include "lyxfont.h"
@@ -38,7 +38,7 @@ int InsetButton::ascent(BufferView * bv, LyXFont const &) const
        int descent;
        string const s = getScreenLabel(bv->buffer());
 
-        if (editable()) {
+       if (editable()) {
                font_metrics::buttonText(s, font, width, ascent, descent);
        } else {
                font_metrics::rectText(s, font, width, ascent, descent);
@@ -60,7 +60,7 @@ int InsetButton::descent(BufferView * bv, LyXFont const &) const
        int descent;
        string const s = getScreenLabel(bv->buffer());
 
-        if (editable()) {
+       if (editable()) {
                font_metrics::buttonText(s, font, width, ascent, descent);
        } else {
                font_metrics::rectText(s, font, width, ascent, descent);
@@ -82,7 +82,7 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
        int descent;
        string const s = getScreenLabel(bv->buffer());
 
-        if (editable()) {
+       if (editable()) {
                font_metrics::buttonText(s, font, width, ascent, descent);
        } else {
                font_metrics::rectText(s, font, width, ascent, descent);
@@ -93,9 +93,10 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
 
 
 void InsetButton::draw(BufferView * bv, LyXFont const &,
-                       int baseline, float & x, bool) const
+                       int baseline, float & x) const
 {
        lyx::Assert(bv);
+       cache(bv);
 
        Painter & pain = bv->painter();
        // Draw it as a box with the LaTeX text
@@ -113,3 +114,16 @@ void InsetButton::draw(BufferView * bv, LyXFont const &,
 
        x += width(bv, font);
 }
+
+
+void InsetButton::cache(BufferView * bv) const
+{
+       view_ = bv->owner()->view();
+}
+
+
+#warning Shouldnt this really return a shared_ptr<BufferView>? (Lgb)
+BufferView * InsetButton::view() const
+{
+       return view_.lock().get();
+}