]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetfloat.C
static_cast-based key/mouse-state. Kill insetKeyPress.
[lyx.git] / src / insets / insetfloat.C
index 7037a3801bc316441cf784cdeb750b190bc2d6a6..cc733c4226cc621de6caceb94f4fec0dee0a9138 100644 (file)
@@ -26,7 +26,7 @@
 #include "debug.h"
 #include "Floating.h"
 #include "buffer.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 #include "frontends/Dialogs.h"
 
 using std::ostream;
@@ -99,11 +99,25 @@ using std::endl;
 //
 // Lgb
 
+namespace {
+
+string floatname(string const & type)
+{
+       FloatList::const_iterator it = floatList[type];
+       if (it == floatList.end())
+               return type;
+
+       return _(it->second.name());
+}
+
+} // namespace anon
+
+
 InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
        : InsetCollapsable(bp), wide_(false)
 {
-       string lab(_("float:"));
-       lab += type;
+       string lab(_("float: "));
+       lab += floatname(type);
        setLabel(lab);
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
@@ -225,18 +239,23 @@ int InsetFloat::latex(Buffer const * buf,
                placement = buf_placement;
        }
 
-       os << "\\begin{" << tmptype << "}";
+       // The \n is used to force \begin{<floatname>} to appear in a new line.
+       // The % is needed to prevent two consecutive \n chars in the case
+       // when the current output line is empty.
+       os << "%\n\\begin{" << tmptype << "}";
        // We only output placement if different from the def_placement.
        if (!placement.empty()) {
                os << "[" << placement << "]";
        }
-
-       os << "%\n";
+       os << "\n";
 
        int const i = inset.latex(buf, os, fragile, fp);
-       os << "\\end{" << tmptype << "}%\n";
 
-       return i + 2;
+       // The \n is used to force \end{<floatname>} to appear in a new line.
+       // In this case, we do not case if the current output line is empty.
+       os << "\n\\end{" << tmptype << "}\n";
+
+       return i + 4;
 }
 
 
@@ -294,16 +313,14 @@ string const & InsetFloat::placement() const
 void InsetFloat::wide(bool w)
 {
        wide_ = w;
-       if (wide_) {
-               string lab(_("float:"));
-               lab += floatType_;
+
+       string lab(_("float:"));
+       lab += floatname(floatType_);
+
+       if (wide_)
                lab += "*";
-               setLabel(lab);
-       } else {
-               string lab(_("float:"));
-               lab += floatType_;
-               setLabel(lab);
-       }
+
+       setLabel(lab);
 }