]> git.lyx.org Git - lyx.git/blob - src/insets/InsetListings.h
use bald pointers in clone()
[lyx.git] / src / insets / InsetListings.h
1 // -*- C++ -*-
2 /**
3  * \file InsetListings.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Bo Peng
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETLISTINGS_H
13 #define INSETLISTINGS_H
14
15 #include "LaTeXFeatures.h"
16 #include "InsetERT.h"
17 #include "InsetListingsParams.h"
18 #include "MailInset.h"
19
20
21 namespace lyx {
22
23 /** A collapsable text inset for program listings.
24  */
25
26
27 class InsetListings : public InsetERT {
28 public:
29         ///
30         InsetListings(BufferParams const &, InsetListingsParams const & par = InsetListingsParams());
31         ///
32         ~InsetListings();
33         ///
34         Inset::Code lyxCode() const { return Inset::LISTINGS_CODE; }
35         /// lstinline is inlined, normal listing is displayed
36         virtual DisplayType display() const;
37         ///
38         docstring name() const { return from_ascii("Listings"); }
39         // Update the counters of this inset and of its contents
40         virtual void updateLabels(Buffer const &, ParIterator const &);
41         ///
42         void write(Buffer const & buf, std::ostream & os) const;
43         ///
44         void read(Buffer const & buf, Lexer & lex);
45         ///
46         virtual docstring const editMessage() const;
47         ///
48         int latex(Buffer const &, odocstream &, OutputParams const &) const;
49         ///
50         void validate(LaTeXFeatures &) const;
51         ///
52         bool metrics(MetricsInfo &, Dimension &) const;
53         ///
54         void draw(PainterInfo & pi, int x, int y) const;
55         ///
56         bool showInsetDialog(BufferView *) const;
57         ///
58         void getDrawFont(Font &) const;
59         ///
60         InsetListingsParams const & params() const { return params_; }
61         ///
62         InsetListingsParams & params() { return params_; }
63 protected:
64         InsetListings(InsetListings const &);
65         ///
66         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
67         ///
68         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
69 private:
70         virtual Inset * clone() const;
71         ///
72         void init();
73         ///
74         void setButtonLabel();
75         ///
76         docstring getCaption(Buffer const &, OutputParams const &) const;
77         ///
78         InsetListingsParams params_;
79 };
80
81
82 class InsetListingsMailer : public MailInset {
83 public:
84         ///
85         InsetListingsMailer(InsetListings & inset);
86         ///
87         virtual Inset & inset() const { return inset_; }
88         ///
89         virtual std::string const & name() const { return name_; }
90         ///
91         virtual std::string const inset2string(Buffer const &) const;
92         ///
93         static void string2params(std::string const &,
94                 InsetListingsParams &);
95         ///
96         static std::string const params2string(InsetListingsParams const &);
97 private:
98         ///
99         static std::string const name_;
100         ///
101         InsetListings & inset_;
102 };
103
104
105 } // namespace lyx
106
107 #endif