]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetVSpace.cpp
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[lyx.git] / src / insets / InsetVSpace.cpp
index e109896ed2edc165d0217cf8b26dcabb91a82e83..8c84b8ae3dcfb96cef222e40f7ee240821b3a837 100644 (file)
@@ -4,7 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author various
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "Lexer.h"
-#include "Text.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
+#include "Text.h"
 
-#include "support/lassert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 
 #include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
@@ -66,12 +66,6 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_MOUSE_RELEASE:
-               if (!cur.selection() && cmd.button() == mouse_button::button1)
-                       cur.bv().showDialog("vspace", params2string(space()), 
-                               const_cast<InsetVSpace *>(this));
-               break;
-
        default:
                Inset::doDispatch(cur, cmd);
                break;
@@ -92,16 +86,18 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
                } 
                status.setEnabled(true);
                return true;
+       
        default:
                return Inset::getStatus(cur, cmd, status);
        }
 }
 
 
-void InsetVSpace::edit(Cursor & cur, bool, EntryDirection)
+bool InsetVSpace::showInsetDialog(BufferView * bv) const
 {
-       cur.bv().showDialog("vspace", params2string(space()), 
+       bv->showDialog("vspace", params2string(space()),
                const_cast<InsetVSpace *>(this));
+       return true;
 }
 
 
@@ -130,13 +126,13 @@ docstring const InsetVSpace::label() const
 
 
 namespace {
-int const arrow_size = 4;
+int const vspace_arrow_size = 4;
 }
 
 
 void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       int height = 3 * arrow_size;
+       int height = 3 * vspace_arrow_size;
        if (space_.length().len().value() >= 0.0)
                height = max(height, space_.inPixels(*mi.base.bv));
 
@@ -153,7 +149,7 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 
        dim.asc = height / 2 + (a - d) / 2; // align cursor with the
        dim.des = height - dim.asc;         // label text
-       dim.wid = ADD_TO_VSPACE_WIDTH + 2 * arrow_size + 5 + w;
+       dim.wid = ADD_TO_VSPACE_WIDTH + 2 * vspace_arrow_size + 5 + w;
        // Cache the inset dimension. 
        setDimCache(mi, dim);
 }
@@ -178,14 +174,14 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
                // adding or removing space
                bool const added = space_.kind() != VSpace::LENGTH ||
                                   space_.length().len().value() >= 0.0;
-               ty1 = added ? (start + arrow_size) : start;
-               ty2 = added ? start : (start + arrow_size);
-               by1 = added ? (end - arrow_size) : end;
-               by2 = added ? end : (end - arrow_size);
+               ty1 = added ? (start + vspace_arrow_size) : start;
+               ty2 = added ? start : (start + vspace_arrow_size);
+               by1 = added ? (end - vspace_arrow_size) : end;
+               by2 = added ? end : (end - vspace_arrow_size);
        }
 
-       int const midx = x + arrow_size;
-       int const rightx = midx + arrow_size;
+       int const midx = x + vspace_arrow_size;
+       int const rightx = midx + vspace_arrow_size;
 
        // first the string
        int w = 0;
@@ -199,7 +195,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
        docstring const lab = label();
        theFontMetrics(font).rectText(lab, w, a, d);
 
-       pi.pain.rectText(x + 2 * arrow_size + 5,
+       pi.pain.rectText(x + 2 * vspace_arrow_size + 5,
                         start + (end - start) / 2 + (a - d) / 2,
                         lab, font, Color_none, Color_none);
 
@@ -237,6 +233,18 @@ int InsetVSpace::docbook(odocstream & os, OutputParams const &) const
 }
 
 
+docstring InsetVSpace::xhtml(odocstream & os, OutputParams const &) const
+{
+       string len = space_.asHTMLLength();
+       if (len.empty())
+               // we didn't understand it
+               os << "<br />\n";
+       else
+               os << "<div style='height:" << from_ascii(len) << "'></div>\n";
+       return docstring();
+}
+
+
 docstring InsetVSpace::contextMenu(BufferView const &, int, int) const
 {
        return from_ascii("context-vspace");