]> git.lyx.org Git - lyx.git/blob - src/insets/insetcaption.h
* In the process of fixing the math background color bug, this commit transfer backgr...
[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 "lyxtextclass.h"
17
18
19 namespace lyx {
20
21 /** A caption inset
22 */
23 class InsetCaption : public InsetText {
24 public:
25         ///
26         InsetCaption(BufferParams const &);
27         ///
28         virtual ~InsetCaption() {}
29         ///
30         void write(Buffer const & buf, std::ostream & os) const;
31         ///
32         void read(Buffer const & buf, LyXLex & lex);
33         ///
34         virtual bool display() const;
35         ///
36         virtual bool neverIndent(Buffer const &) const { return true; }
37         ///
38         virtual InsetBase::Code lyxCode() const;
39         ///
40         virtual docstring const editMessage() const;
41         ///
42         virtual void cursorPos(BufferView const & bv,
43                 CursorSlice const & sl, bool boundary, int & x, int & y) const;
44         ///
45         bool descendable() const { return true; }
46         ///
47         virtual bool metrics(MetricsInfo & mi, Dimension & dim) const;
48         ///
49         virtual void draw(PainterInfo & pi, int x, int y) const;
50         ///
51         void drawSelection(PainterInfo & pi, int x, int y) const;
52         ///
53         virtual void edit(LCursor & cur, bool left);
54         ///
55         virtual InsetBase * editXY(LCursor & cur, int x, int y);
56         ///
57         bool insetAllowed(InsetBase::Code code) const;
58         ///
59         virtual bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
60         ///
61         virtual bool wide() const { return false; }
62         ///
63         int latex(Buffer const & buf, odocstream & os,
64                   OutputParams const &) const;
65         ///
66         int plaintext(Buffer const & buf, odocstream & os,
67                       OutputParams const & runparams) const;
68         ///
69         int docbook(Buffer const & buf, odocstream & os,
70                     OutputParams const & runparams) const;
71         ///
72         void setCount(int c) { counter_ = c; }
73         ///
74         std::string const & type() const { return type_; }
75         ///
76         void setType(std::string const & type) { type_ = type; }
77         ///
78         void setCustomLabel(docstring const & label);
79         ///
80         void addToToc(TocList &, Buffer const &) const;
81         /// Captions don't accept alignment, spacing, etc.
82         bool forceDefaultParagraphs(idx_type) const { return true; }
83
84 private:
85         ///
86         void computeFullLabel() const;
87         ///
88         virtual std::auto_ptr<InsetBase> doClone() const;
89         ///
90         mutable docstring full_label_;
91         ///
92         mutable int labelwidth_;
93         ///
94         std::string type_;
95         ///
96         docstring custom_label_;
97         ///
98         int counter_;
99         ///
100         LyXTextClass const & textclass_;
101 };
102
103
104 inline
105 bool InsetCaption::display() const
106 {
107         return true;
108 }
109
110
111 inline
112 InsetBase::Code InsetCaption::lyxCode() const
113 {
114         return CAPTION_CODE;
115 }
116
117
118 } // namespace lyx
119
120 #endif