]> git.lyx.org Git - features.git/blob - src/insets/InsetFloat.h
d0e1afaa8d7de5a89e998c98d86eef70a805fc7f
[features.git] / src / insets / InsetFloat.h
1 // -*- C++ -*-
2 /**
3  * \file InsetFloat.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_FLOAT_H
14 #define INSET_FLOAT_H
15
16 #include "InsetCollapsable.h"
17
18
19 namespace lyx {
20
21 class InsetFloatParams
22 {
23 public:
24         ///
25         InsetFloatParams() : wide(false), sideways(false), subfloat(false) {}
26         ///
27         void write(std::ostream & os) const;
28         ///
29         void read(Lexer & lex);
30         ///
31         std::string type;
32         ///
33         std::string placement;
34         /// span columns
35         bool wide;
36         ///
37         bool sideways;
38         ///
39         bool subfloat;
40 };
41
42
43
44 /////////////////////////////////////////////////////////////////////////
45 //
46 // InsetFloat
47 //
48 /////////////////////////////////////////////////////////////////////////
49
50 /// Used for "floating" objects like tables, figures etc.
51 class InsetFloat : public InsetCollapsable
52 {
53 public:
54         ///
55         InsetFloat(Buffer * buffer, std::string params_str);
56
57         ///
58         static void string2params(std::string const &, InsetFloatParams &);
59         ///
60         static std::string params2string(InsetFloatParams const &);
61         ///
62         void setWide(bool w, bool update_label = true);
63         ///
64         void setSideways(bool s, bool update_label = true);
65         ///
66         void setSubfloat(bool s, bool update_label = true);
67         ///
68         void setNewLabel();
69         ///
70         InsetFloatParams const & params() const { return params_; }
71         ///
72         bool allowsCaptionVariation(std::string const &) const;
73 private:
74         ///
75         docstring layoutName() const;
76         ///
77         docstring toolTip(BufferView const & bv, int x, int y) const;
78         ///
79         void write(std::ostream & os) const;
80         ///
81         void read(Lexer & lex);
82         ///
83         void validate(LaTeXFeatures & features) const;
84         ///
85         InsetCode lyxCode() const { return FLOAT_CODE; }
86         ///
87         void latex(otexstream &, OutputParams const &) const;
88         ///
89         int plaintext(odocstringstream & ods, OutputParams const & op,
90                       size_t max_length = INT_MAX) const;
91         ///
92         int docbook(odocstream &, OutputParams const &) const;
93         ///
94         docstring xhtml(XHTMLStream &, OutputParams const &) const;
95         ///
96         bool insetAllowed(InsetCode) const;
97         /** returns false if, when outputing LaTeX, font changes should
98             be closed before generating this inset. This is needed for
99             insets that may contain several paragraphs */
100         bool inheritFont() const { return false; }
101         ///
102         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
103         ///
104         void addToToc(DocIterator const & di, bool output_active) const;
105         /// Update the counters of this inset and of its contents
106         void updateBuffer(ParIterator const &, UpdateType);
107         ///
108         void doDispatch(Cursor & cur, FuncRequest & cmd);
109         ///
110         Inset * clone() const { return new InsetFloat(*this); }
111         ///
112         docstring getCaption(OutputParams const &) const;
113         ///
114         InsetFloatParams params_;
115 };
116
117
118 } // namespace lyx
119
120 #endif // INSET_FLOAT_H