]> git.lyx.org Git - features.git/blob - src/insets/InsetFloat.h
Add support for global float alignment
[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 "InsetCaptionable.h"
17
18
19 namespace lyx {
20
21 struct TexString;
22
23
24 class InsetFloatParams
25 {
26 public:
27         ///
28         InsetFloatParams() : type("senseless"), placement("document"), alignment("document"),
29                 wide(false), sideways(false), subfloat(false) {}
30         ///
31         void write(std::ostream & os) const;
32         ///
33         void read(Lexer & lex);
34         ///
35         std::string type;
36         ///
37         std::string placement;
38         ///
39         std::string alignment;
40         /// span columns
41         bool wide;
42         ///
43         bool sideways;
44         ///
45         bool subfloat;
46 };
47
48
49
50 /////////////////////////////////////////////////////////////////////////
51 //
52 // InsetFloat
53 //
54 /////////////////////////////////////////////////////////////////////////
55
56 /// Used for "floating" objects like tables, figures etc.
57 class InsetFloat : public InsetCaptionable
58 {
59 public:
60         InsetFloat(Buffer * buffer, std::string params_str);
61         ///
62         static void string2params(std::string const &, InsetFloatParams &);
63         ///
64         static std::string params2string(InsetFloatParams const &);
65         ///
66         void setWide(bool w, bool update_label = true);
67         ///
68         void setSideways(bool s, bool update_label = true);
69         ///
70         void setSubfloat(bool s, bool update_label = true);
71         ///
72         void setNewLabel();
73         ///
74         InsetFloatParams const & params() const { return params_; }
75         ///
76         bool allowsCaptionVariation(std::string const &) const;
77 private:
78         ///
79         void setCaptionType(std::string const & type);
80         ///
81         docstring layoutName() const;
82         ///
83         docstring toolTip(BufferView const & bv, int x, int y) const;
84         ///
85         void write(std::ostream & os) const;
86         ///
87         void read(Lexer & lex);
88         ///
89         void validate(LaTeXFeatures & features) const;
90         ///
91         InsetCode lyxCode() const { return FLOAT_CODE; }
92         ///
93         void latex(otexstream &, OutputParams const &) const;
94         ///
95         int plaintext(odocstringstream & ods, OutputParams const & op,
96                       size_t max_length = INT_MAX) const;
97         ///
98         int docbook(odocstream &, OutputParams const &) const;
99         ///
100         docstring xhtml(XHTMLStream &, OutputParams const &) const;
101         ///
102         bool insetAllowed(InsetCode) const;
103         /** returns false if, when outputing LaTeX, font changes should
104             be closed before generating this inset. This is needed for
105             insets that may contain several paragraphs */
106         bool inheritFont() const { return false; }
107         ///
108         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
109         ///
110         bool hasSubCaptions(ParIterator const & it) const;
111         ///
112         void doDispatch(Cursor & cur, FuncRequest & cmd);
113         ///
114         Inset * clone() const { return new InsetFloat(*this); }
115         /// Is the content of this inset part of the immediate (visible) text sequence?
116         bool isPartOfTextSequence() const { return false; }
117         ///
118         TexString getCaption(OutputParams const &) const;
119
120         InsetFloatParams params_;
121 };
122
123
124 } // namespace lyx
125
126 #endif // INSET_FLOAT_H