]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCaption.h
9a95c9f378473d501af9a74b7c423150cf582df0
[lyx.git] / src / insets / InsetCaption.h
1 // -*- C++ -*-
2 /**
3  * \file InsetCaption.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETCAPTION_H
13 #define INSETCAPTION_H
14
15 #include "InsetText.h"
16 #include "TextClass.h"
17
18
19 namespace lyx {
20
21 /** A caption inset
22 */
23 class InsetCaption : public InsetText {
24 public:
25         ///
26         InsetCaption(InsetCaption const &);
27         InsetCaption(BufferParams const &);
28         ///
29         virtual ~InsetCaption() {}
30         ///
31         void write(Buffer const & buf, std::ostream & os) const;
32         ///
33         void read(Buffer const & buf, Lexer & lex);
34         ///
35         virtual DisplayType display() const;
36         ///
37         virtual bool neverIndent(Buffer const &) const { return true; }
38         ///
39         virtual Inset::Code lyxCode() const;
40         ///
41         virtual docstring const editMessage() const;
42         ///
43         virtual void cursorPos(BufferView const & bv,
44                 CursorSlice const & sl, bool boundary, int & x, int & y) const;
45         ///
46         bool descendable() const { return true; }
47         ///
48         virtual bool metrics(MetricsInfo & mi, Dimension & dim) const;
49         ///
50         virtual void draw(PainterInfo & pi, int x, int y) const;
51         ///
52         void drawSelection(PainterInfo & pi, int x, int y) const;
53         ///
54         virtual void edit(Cursor & cur, bool left);
55         ///
56         virtual Inset * editXY(Cursor & cur, int x, int y);
57         ///
58         bool insetAllowed(Inset::Code code) const;
59         ///
60         virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
61         // Update the counters of this inset and of its contents
62         virtual void updateLabels(Buffer const &, ParIterator const &);
63         ///
64         int latex(Buffer const & buf, odocstream & os,
65                   OutputParams const &) const;
66         ///
67         int plaintext(Buffer const & buf, odocstream & os,
68                       OutputParams const & runparams) const;
69         ///
70         int docbook(Buffer const & buf, odocstream & os,
71                     OutputParams const & runparams) const;
72         /// return the mandatory argument (LaTeX format) only
73         int getArgument(Buffer const & buf, odocstream & os,
74                   OutputParams const &) const;
75         /// return the optional argument(s) only
76         int getOptArg(Buffer const & buf, odocstream & os,
77                   OutputParams const &) const;
78         ///
79         std::string const & type() const { return type_; }
80         ///
81         void setType(std::string const & type) { type_ = type; }
82         ///
83         void setCustomLabel(docstring const & label);
84         ///
85         void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
86         /// Captions don't accept alignment, spacing, etc.
87         bool forceDefaultParagraphs(idx_type) const { return true; }
88
89 private:
90         ///
91         virtual std::auto_ptr<Inset> doClone() const;
92         ///
93         mutable docstring full_label_;
94         ///
95         mutable int labelwidth_;
96         ///
97         std::string type_;
98         ///
99         docstring custom_label_;
100         ///
101         TextClass const & textclass_;
102 };
103
104
105 inline
106 Inset::DisplayType InsetCaption::display() const
107 {
108         return AlignCenter;
109 }
110
111
112 inline
113 Inset::Code InsetCaption::lyxCode() const
114 {
115         return CAPTION_CODE;
116 }
117
118
119 } // namespace lyx
120
121 #endif