#include "gettext.h"
#include "lyxfont.h"
#include "BufferView.h"
-#include "Painter.h"
#include "lyxtext.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
#include "FloatList.h"
#include "LaTeXFeatures.h"
#include "debug.h"
+#include "Floating.h"
using std::ostream;
using std::endl;
//
// Lgb
-InsetFloat::InsetFloat() : InsetCollapsable()
+InsetFloat::InsetFloat(string const & type)
+ : InsetCollapsable()
{
- setLabel(_("float"));
- LyXFont font(LyXFont::ALL_SANE);
- font.decSize();
- font.decSize();
- font.setColor(LColor::footnote);
- setLabelFont(font);
- setAutoCollapse(false);
- setInsetName("Float");
- floatType = "table";
- floatPlacement = "H";
+ string lab(_("float:"));
+ lab += type;
+ setLabel(lab);
+ LyXFont font(LyXFont::ALL_SANE);
+ font.decSize();
+ font.decSize();
+ font.setColor(LColor::footnote);
+ setLabelFont(font);
+ setAutoCollapse(false);
+ setInsetName("Float");
+ floatType = type;
+ //floatPlacement = "H";
}
void InsetFloat::Write(Buffer const * buf, ostream & os) const
{
os << getInsetName()
- << "\ntype " << floatType
- << "\nplacement " << floatPlacement << "\n";
+ << " " << floatType
+ << "\nplacement ";
+ if (floatPlacement.empty())
+ os << floatList.getType(floatType).placement << "\n";
+ else
+ os << floatPlacement << "\n";
InsetCollapsable::Write(buf, os);
}
if (lex.IsOK()) {
lex.next();
string token = lex.GetString();
- if (token == "type") {
- lex.next();
- floatType = lex.GetString();
- }
- lex.next();
- token = lex.GetString();
if (token == "placement") {
lex.next();
floatPlacement = lex.GetString();
Inset * InsetFloat::Clone() const
{
- InsetFloat * result = new InsetFloat;
- result->init(this);
+ InsetFloat * result = new InsetFloat(floatType);
+ result->inset->init(inset);
- result->collapsed = collapsed;
- return result;
+ result->collapsed = collapsed;
+ return result;
}
char const * InsetFloat::EditMessage() const
{
- return _("Opened Float Inset");
+ return _("Opened Float Inset");
}
os << "[" << floatPlacement << "]";
os << "%\n";
- int i = InsetText::Latex(buf, os, fragile, fp);
- os << "\\end{" << floatType << "}%\n";
-
- return i + 2;
-}
-
-
-bool InsetFloat::InsertInset(BufferView * bv, Inset * inset)
-{
- if (!InsertInsetAllowed(inset))
- return false;
-
- return InsetText::InsertInset(bv, inset);
-}
-
-
-bool InsetFloat::InsertInsetAllowed(Inset * inset) const
-{
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
- return false;
- }
- return true;
+ int i = inset->Latex(buf, os, fragile, fp);
+ os << "\\end{" << floatType << "}%\n";
+
+ return i + 2;
}
-LyXFont InsetFloat::GetDrawFont(BufferView * bv,
- LyXParagraph * p, int pos) const
+bool InsetFloat::InsertInsetAllowed(Inset * in) const
{
- LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
- fn.decSize().decSize();
- return fn;
+ if ((in->LyxCode() == Inset::FOOT_CODE) ||
+ (in->LyxCode() == Inset::MARGIN_CODE)) {
+ return false;
+ }
+ return true;
}
InsetCollapsable::InsetButtonRelease(bv, x, y, button);
}
}
+
+
+void InsetFloat::wide(bool w)
+{
+ wide_ = w;
+ if (wide_) {
+ string lab(_("float:"));
+ lab += floatType;
+ lab += "*";
+ setLabel(lab);
+ } else {
+ string lab(_("float:"));
+ lab += floatType;
+ setLabel(lab);
+ }
+}
+
+
+bool InsetFloat::wide() const
+{
+ return wide_;
+}