]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBox.cpp
Pure HTML output for math macros.
[lyx.git] / src / insets / InsetBox.cpp
index cc45619e0c25f4f038967923e667fd2b9b8fba31..3b7dec3e19a9ffe49e03f82a10025d903bf88b3c 100644 (file)
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
+#include "output_xhtml.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
+#include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
@@ -95,23 +97,11 @@ BoxTranslatorLoc const & boxtranslator_loc()
 //
 /////////////////////////////////////////////////////////////////////////
 
-InsetBox::InsetBox(Buffer const & buffer, string const & label)
+InsetBox::InsetBox(Buffer * buffer, string const & label)
        : InsetCollapsable(buffer), params_(label)
 {}
 
 
-InsetBox::~InsetBox()
-{
-       hideDialogs("box", this);
-}
-
-
-docstring InsetBox::editMessage() const
-{
-       return _("Opened Box Inset");
-}
-
-
 docstring InsetBox::name() const 
 {
        // FIXME: UNICODE
@@ -194,14 +184,6 @@ bool InsetBox::forcePlainLayout(idx_type) const
 }
 
 
-bool InsetBox::showInsetDialog(BufferView * bv) const
-{
-       bv->showDialog("box", params2string(params_),
-               const_cast<InsetBox *>(this));
-       return true;
-}
-
-
 void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
@@ -212,14 +194,10 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
                        params_.type = cmd.getArg(1);
                else
                        string2params(to_utf8(cmd.argument()), params_);
-               setLayout(cur.buffer()->params());
+               setButtonLabel();
                break;
        }
 
-       case LFUN_INSET_DIALOG_UPDATE:
-               cur.bv().updateDialog("box", params2string(params_));
-               break;
-
        default:
                InsetCollapsable::doDispatch(cur, cmd);
                break;
@@ -484,6 +462,28 @@ int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
+docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
+{
+       // construct attributes
+       string attrs = "class='" + params_.type + "'";
+       string style;
+       if (!params_.width.empty())
+               style += ("width: " + params_.width.asHTMLString() + "; ");
+       // The special heights don't really mean anything for us.
+       if (!params_.height.empty() && params_.height_special == "none")
+               style += ("height: " + params_.height.asHTMLString() + "; ");
+       if (!style.empty())
+               attrs += " style='" + style + "'";
+
+       xs << html::StartTag("div", attrs);
+       XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
+       docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
+       xs << html::EndTag("div");
+       xs << defer;
+       return docstring();
+}
+
+
 void InsetBox::validate(LaTeXFeatures & features) const
 {
        BoxType btype = boxtranslator().find(params_.type);
@@ -508,7 +508,7 @@ void InsetBox::validate(LaTeXFeatures & features) const
                features.require("framed");
                break;
        }
-       InsetText::validate(features);
+       InsetCollapsable::validate(features);
 }