]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCaption.h
This should be the last of the commits refactoring the InsetLayout code.
[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
17 namespace lyx {
18
19 class TextClass;
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 InsetCode 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 void metrics(MetricsInfo & mi, Dimension & dim) const;
49         ///
50         virtual void draw(PainterInfo & pi, int x, int y) const;
51         ///
52         virtual void edit(Cursor & cur, bool front, EntryDirection entry_from);
53         ///
54         virtual Inset * editXY(Cursor & cur, int x, int y);
55         ///
56         bool insetAllowed(InsetCode code) const;
57         ///
58         virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
59         // Update the counters of this inset and of its contents
60         virtual void updateLabels(Buffer const &, ParIterator const &);
61         ///
62         int latex(Buffer const & buf, odocstream & os,
63                   OutputParams const &) const;
64         ///
65         int plaintext(Buffer const & buf, odocstream & os,
66                       OutputParams const & runparams) const;
67         ///
68         int docbook(Buffer const & buf, odocstream & os,
69                     OutputParams const & runparams) const;
70         /// return the mandatory argument (LaTeX format) only
71         int getArgument(Buffer const & buf, odocstream & os,
72                   OutputParams const &) const;
73         /// return the optional argument(s) only
74         int getOptArg(Buffer const & buf, odocstream & os,
75                   OutputParams const &) const;
76         ///
77         std::string const & type() const { return type_; }
78         ///
79         void setCustomLabel(docstring const & label);
80         ///
81         void addToToc(Buffer const &, ParConstIterator const &) const;
82         /// 
83         virtual bool forceEmptyLayout() const { return true; }
84         /// Captions don't accept alignment, spacing, etc.
85         virtual bool allowParagraphCustomization(idx_type) const { return false; }
86
87 private:
88         ///
89         virtual Inset * clone() const;
90         ///
91         mutable docstring full_label_;
92         ///
93         mutable int labelwidth_;
94         ///
95         std::string type_;
96         ///
97         docstring custom_label_;
98         ///
99         TextClass const & textclass_;
100 };
101
102
103 inline
104 Inset::DisplayType InsetCaption::display() const
105 {
106         return AlignCenter;
107 }
108
109
110 inline
111 InsetCode InsetCaption::lyxCode() const
112 {
113         return CAPTION_CODE;
114 }
115
116
117 } // namespace lyx
118
119 #endif