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