]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetfloat.C
fix compilation pb ; update eu.po
[lyx.git] / src / insets / insetfloat.C
index fe25dc75b2e8be69ea38c43782fce8d00389613e..029e86c22dee4fdd7a39c778904b2a6a07f571db 100644 (file)
@@ -76,10 +76,27 @@ using std::endl;
 //   \newfloat{algorithm}{htbp}{loa}[<sect>]
 //   \floatname{algorithm}{Algorithm}
 //
+// The intention is that floats should be definable from two places:
+//          - layout files
+//          - the "gui" (i.e. by the user)
+//
+// From layout files.
+// This should only be done for floats defined in a documentclass and that
+// does not need any additional packages. The two most known floats in this
+// category is "table" and "figure". Floats defined in layout files are only
+// stored in lyx files if the user modifies them.
+//
+// By the user.
+// There should be a gui dialog (and also a collection of lyxfuncs) where
+// the user can modify existing floats and/or create new ones.
+//
+// The individual floats will also have some settable
+// variables: wide and placement.
+//
 // Lgb
 
 InsetFloat::InsetFloat(string const & type)
-       : InsetCollapsable()
+       : InsetCollapsable(), wide_(false)
 {
        string lab(_("float:"));
        lab += type;
@@ -92,7 +109,6 @@ InsetFloat::InsetFloat(string const & type)
        setAutoCollapse(false);
        floatType_ = type;
        setInsetName(type);
-       //floatPlacement = "H";
 }
 
 
@@ -116,7 +132,7 @@ void InsetFloat::Read(Buffer const * buf, LyXLex & lex)
 {
        if (lex.IsOK()) {
                lex.next();
-               string token = lex.GetString();
+               string const token = lex.GetString();
                if (token == "placement") {
                        lex.next();
                        floatPlacement_ = lex.GetString();
@@ -138,7 +154,7 @@ void InsetFloat::Validate(LaTeXFeatures & features) const
 Inset * InsetFloat::Clone(Buffer const &) const
 {
        InsetFloat * result = new InsetFloat(floatType_);
-       result->inset->init(inset);
+       result->inset.init(&inset);
 
        result->collapsed = collapsed;
        return result;
@@ -160,13 +176,23 @@ int InsetFloat::Latex(Buffer const * buf,
                os << "[" << floatPlacement_ << "]";
        os << "%\n";
     
-       int const i = inset->Latex(buf, os, fragile, fp);
+       int const i = inset.Latex(buf, os, fragile, fp);
        os << "\\end{" << floatType_ << "}%\n";
        
        return i + 2;
 }
 
 
+int InsetFloat::DocBook(Buffer const * buf, ostream & os) const
+{
+       os << "<" << floatType_ << ">";
+       int const i = inset.DocBook(buf, os);
+       os << "</" << floatType_ << ">";
+
+       return i;
+}
+
+
 bool InsetFloat::InsertInsetAllowed(Inset * in) const
 {
        if ((in->LyxCode() == Inset::FOOT_CODE) ||
@@ -179,7 +205,7 @@ bool InsetFloat::InsertInsetAllowed(Inset * in) const
 
 void InsetFloat::InsetButtonRelease(BufferView * bv, int x, int y, int button)
 {
-       if (x >= 0
+       if (x >= top_x
            && x < button_length
            && y >= button_top_y
            && y < button_bottom_y
@@ -187,6 +213,7 @@ void InsetFloat::InsetButtonRelease(BufferView * bv, int x, int y, int button)
                // This obviously need to change.
                lyxerr << "InsetFloat: Let's edit this floats parameters!"
                       << endl;
+               //bv->owner()->getDialogs()->showFloat(this);
        } else {
                InsetCollapsable::InsetButtonRelease(bv, x, y, button);
        }
@@ -199,6 +226,23 @@ string const & InsetFloat::type() const
 }
 
 
+void InsetFloat::placement(string const & p)
+{
+       // Here we should only allow the placement to be set
+       // if a valid value.
+#ifdef WITH_WARNINGS
+#warning FIX!
+#endif
+       floatPlacement_ = p;
+}
+
+
+string const & InsetFloat::placement() const
+{
+       return floatPlacement_;
+}
+
+
 void InsetFloat::wide(bool w)
 {
        wide_ = w;