]> git.lyx.org Git - lyx.git/blob - src/insets/InsetFloat.h
50c698a43e1410b5b6ee8065ee5c69d84afaa6d8
[lyx.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 const & 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 override;
77         ///
78         LyXAlignment contentAlignment() const override;
79         ///
80         bool forceParDirectionSwitch() const override { return true; }
81 private:
82         ///
83         void setCaptionType(std::string const & type) override;
84         ///
85         docstring layoutName() const override;
86         ///
87         docstring toolTip(BufferView const & bv, int x, int y) const override;
88         ///
89         void write(std::ostream & os) const override;
90         ///
91         void read(Lexer & lex) override;
92         ///
93         void validate(LaTeXFeatures & features) const override;
94         ///
95         InsetCode lyxCode() const override { return FLOAT_CODE; }
96         ///
97         void latex(otexstream &, OutputParams const &) const override;
98         ///
99         int plaintext(odocstringstream & ods, OutputParams const & op,
100                       size_t max_length = INT_MAX) const override;
101         ///
102         void docbook(XMLStream &, OutputParams const &) const override;
103         ///
104         docstring xhtml(XMLStream &, OutputParams const &) const override;
105         ///
106         bool insetAllowed(InsetCode) const override;
107         ///
108         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
109         ///
110         bool hasSubCaptions(ParIterator const & it) const override;
111         ///
112         void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false) override;
113         ///
114         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
115         ///
116         Inset * clone() const override { return new InsetFloat(*this); }
117         /// Is the content of this inset part of the immediate (visible) text sequence?
118         bool isPartOfTextSequence() const override { return false; }
119         ///
120         TexString getCaption(OutputParams const &) const;
121         ///
122         std::string getAlignment() const;
123         ///
124         CtObject getCtObject(OutputParams const &) const override;
125
126         InsetFloatParams params_;
127 };
128
129
130 } // namespace lyx
131
132 #endif // INSET_FLOAT_H