4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSETCAPTION_H
13 #define INSETCAPTION_H
15 #include "InsetText.h"
21 class InsetCaption : public InsetText {
24 InsetCaption(Buffer *, std::string const &);
26 std::string const & floattype() const { return floattype_; }
28 docstring layoutName() const override;
29 /// return the mandatory argument (LaTeX format) only
30 void getArgument(otexstream & os, OutputParams const &) const;
31 /// return the caption text
32 int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const;
33 /// write the caption text as DocBook in os
34 void getCaptionAsDocBook(XMLStream & os, OutputParams const &) const;
35 /// return the caption text as HTML
36 docstring getCaptionAsHTML(XMLStream & os, OutputParams const &) const;
38 std::string contextMenuName() const override;
41 void write(std::ostream & os) const override;
43 RowFlags rowFlags() const override { return Display; }
45 bool neverIndent() const override { return true; }
47 bool forceLocalFontSwitch() const override { return true; }
49 InsetCode lyxCode() const override { return CAPTION_CODE; }
51 void cursorPos(BufferView const & bv,
52 CursorSlice const & sl, bool boundary, int & x, int & y) const override;
54 bool descendable(BufferView const &) const override { return true; }
56 void metrics(MetricsInfo & mi, Dimension & dim) const override;
58 void drawBackground(PainterInfo & pi, int x, int y) const override;
60 void draw(PainterInfo & pi, int x, int y) const override;
61 /// Strike out the inset when deleted.
62 bool canPaintChange(BufferView const &) const override { return true; }
64 void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
66 Inset * editXY(Cursor & cur, int x, int y) override;
68 bool insetAllowed(InsetCode code) const override;
70 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
72 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const override;
73 // Update the counters of this inset and of its contents
74 void updateBuffer(ParIterator const &, UpdateType, bool const deleted) override;
76 void latex(otexstream & os, OutputParams const &) const override;
78 int plaintext(odocstringstream & ods, OutputParams const & op,
79 size_t max_length = INT_MAX) const override;
81 void docbook(XMLStream &, OutputParams const &) const override;
83 docstring xhtml(XMLStream & os, OutputParams const & runparams) const override;
85 void addToToc(DocIterator const & di, bool output_active, UpdateType utype,
86 TocBackend & backend) const override;
88 bool forcePlainLayout(idx_type = 0) const override { return true; }
89 /// Captions don't accept alignment, spacing, etc.
90 bool allowParagraphCustomization(idx_type = 0) const override { return false; }
92 Inset * clone() const override { return new InsetCaption(*this); }
95 mutable docstring full_label_;
97 mutable int labelwidth_;
99 std::string floattype_;