]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetFloat.h
Do not repeatedly call main_font_encoding()
[lyx.git] / src / insets / InsetFloat.h
index d56ededc5dcf09c4d5b22df5752f59d83345b8b1..9d20a486cf0329a77d553ac0a5074e71d97f89ff 100644 (file)
@@ -4,26 +4,29 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Jürgen Vigna
- * \author Lars Gullik Bjønnes
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
  *
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef INSETFLOAT_H
-#define INSETFLOAT_H
+#ifndef INSET_FLOAT_H
+#define INSET_FLOAT_H
 
-#include "InsetCollapsable.h"
-#include "MailInset.h"
+#include "InsetCaptionable.h"
 
 
 namespace lyx {
 
+struct TexString;
 
-class InsetFloatParams {
+
+class InsetFloatParams
+{
 public:
        ///
-       InsetFloatParams() : wide(false), sideways(false) {}
+       InsetFloatParams() : type("senseless"), placement("document"), alignment("document"),
+               wide(false), sideways(false), subfloat(false) {}
        ///
        void write(std::ostream & os) const;
        ///
@@ -33,96 +36,97 @@ public:
        ///
        std::string placement;
        ///
+       std::string alignment;
+       /// span columns
        bool wide;
        ///
        bool sideways;
+       ///
+       bool subfloat;
 };
 
 
-/** The float inset
 
-*/
-class InsetFloat : public InsetCollapsable {
+/////////////////////////////////////////////////////////////////////////
+//
+// InsetFloat
+//
+/////////////////////////////////////////////////////////////////////////
+
+/// Used for "floating" objects like tables, figures etc.
+class InsetFloat : public InsetCaptionable
+{
 public:
+       InsetFloat(Buffer * buffer, std::string const & params_str);
        ///
-       InsetFloat(BufferParams const &, std::string const &);
+       static void string2params(std::string const &, InsetFloatParams &);
        ///
-       ~InsetFloat();
+       static std::string params2string(InsetFloatParams const &);
        ///
-       docstring name() const { return name_; }
+       void setWide(bool w, bool update_label = true);
        ///
-       void write(Buffer const & buf, std::ostream & os) const;
+       void setSideways(bool s, bool update_label = true);
        ///
-       void read(Buffer const & buf, Lexer & lex);
+       void setSubfloat(bool s, bool update_label = true);
        ///
-       void validate(LaTeXFeatures & features) const;
+       void setNewLabel();
        ///
-       Inset::Code lyxCode() const { return Inset::FLOAT_CODE; }
+       InsetFloatParams const & params() const { return params_; }
        ///
-       virtual bool wide() const { return false; }
+       bool allowsCaptionVariation(std::string const &) const override;
        ///
-       int latex(Buffer const &, odocstream &,
-                 OutputParams const &) const;
+       LyXAlignment contentAlignment() const override;
        ///
-       int plaintext(Buffer const &, odocstream &,
-                     OutputParams const &) const;
+       bool forceParDirectionSwitch() const override { return true; }
+private:
        ///
-       int docbook(Buffer const &, odocstream &,
-                   OutputParams const &) const;
+       void setCaptionType(std::string const & type) override;
        ///
-       virtual docstring const editMessage() const;
+       docstring layoutName() const override;
        ///
-       bool insetAllowed(Inset::Code) const;
-       /** returns true if, when outputing LaTeX, font changes should
-           be closed before generating this inset. This is needed for
-           insets that may contain several paragraphs */
-       bool noFontChange() const { return true; }
+       docstring toolTip(BufferView const & bv, int x, int y) const override;
        ///
-       void wide(bool w, BufferParams const &);
+       void write(std::ostream & os) const override;
        ///
-       void sideways(bool s, BufferParams const &);
+       void read(Lexer & lex) override;
        ///
-       bool  showInsetDialog(BufferView *) const;
+       void validate(LaTeXFeatures & features) const override;
        ///
-       InsetFloatParams const & params() const { return params_; }
+       InsetCode lyxCode() const override { return FLOAT_CODE; }
        ///
-       bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
-       // Update the counters of this inset and of its contents
-       virtual void updateLabels(Buffer const &, ParIterator const &);
-protected:
-       virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
-private:
+       void latex(otexstream &, OutputParams const &) const override;
        ///
-       virtual std::auto_ptr<Inset> doClone() const;
+       int plaintext(odocstringstream & ods, OutputParams const & op,
+                     size_t max_length = INT_MAX) const override;
        ///
-       InsetFloatParams params_;
+       void docbook(XMLStream &, OutputParams const &) const override;
        ///
-       docstring name_;
-};
-
-
-class InsetFloatMailer : public MailInset {
-public:
+       docstring xhtml(XMLStream &, OutputParams const &) const override;
        ///
-       InsetFloatMailer(InsetFloat & inset);
+       bool insetAllowed(InsetCode) const override;
        ///
-       virtual Inset & inset() const { return inset_; }
+       bool inheritFont() const override { return false; }
        ///
-       virtual std::string const & name() const { return name_; }
+       bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
        ///
-       virtual std::string const inset2string(Buffer const &) const;
+       bool hasSubCaptions(ParIterator const & it) const override;
        ///
-       static void string2params(std::string const &, InsetFloatParams &);
+       void doDispatch(Cursor & cur, FuncRequest & cmd) override;
        ///
-       static std::string const params2string(InsetFloatParams const &);
-private:
+       Inset * clone() const override { return new InsetFloat(*this); }
+       /// Is the content of this inset part of the immediate (visible) text sequence?
+       bool isPartOfTextSequence() const override { return false; }
+       ///
+       TexString getCaption(OutputParams const &) const;
        ///
-       static std::string const name_;
+       std::string getAlignment() const;
        ///
-       InsetFloat & inset_;
+       CtObject getCtObject(OutputParams const &) const override;
+
+       InsetFloatParams params_;
 };
 
 
 } // namespace lyx
 
-#endif
+#endif // INSET_FLOAT_H