]> git.lyx.org Git - lyx.git/blob - src/insets/InsetListings.h
* src/insets/InsetListings.{cpp,h}:
[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         ///
40         void write(Buffer const & buf, std::ostream & os) const;
41         ///
42         void read(Buffer const & buf, Lexer & lex);
43         ///
44         virtual docstring const editMessage() const;
45         ///
46         int latex(Buffer const &, odocstream &, OutputParams const &) const;
47         ///
48         void validate(LaTeXFeatures &) const;
49         ///
50         bool metrics(MetricsInfo &, Dimension &) const;
51         ///
52         void draw(PainterInfo & pi, int x, int y) const;
53         ///
54         bool showInsetDialog(BufferView *) const;
55         ///
56         void getDrawFont(Font &) const;
57         ///
58         InsetListingsParams const & params() const { return params_; }
59         ///
60         InsetListingsParams & params() { return params_; }
61 protected:
62         InsetListings(InsetListings const &);
63         ///
64         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
65         ///
66         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
67 private:
68         virtual std::auto_ptr<Inset> doClone() const;
69         ///
70         void init();
71         ///
72         void setButtonLabel();
73         ///
74         docstring getCaption(Buffer const &, OutputParams const &) const;
75         ///
76         InsetListingsParams params_;
77 };
78
79
80 class InsetListingsMailer : public MailInset {
81 public:
82         ///
83         InsetListingsMailer(InsetListings & inset);
84         ///
85         virtual Inset & inset() const { return inset_; }
86         ///
87         virtual std::string const & name() const { return name_; }
88         ///
89         virtual std::string const inset2string(Buffer const &) const;
90         ///
91         static void string2params(std::string const &,
92                 InsetListingsParams &);
93         ///
94         static std::string const params2string(InsetListingsParams const &);
95 private:
96         ///
97         static std::string const name_;
98         ///
99         InsetListings & inset_;
100 };
101
102
103 } // namespace lyx
104
105 #endif