]> git.lyx.org Git - lyx.git/blob - src/insets/InsetListings.h
Cleanup mouse/selection/context-menu interactions.
[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 InsetCollapsable {
28 public:
29         ///
30         InsetListings(Buffer const &, InsetListingsParams const & par = InsetListingsParams());
31         ///
32         ~InsetListings();
33         ///
34         bool isLabeled() const { return true; }
35         ///
36         InsetCode lyxCode() const { return LISTINGS_CODE; }
37         /// lstinline is inlined, normal listing is displayed
38         DisplayType display() const;
39         ///
40         docstring name() const { return from_ascii("Listings"); }
41         // Update the counters of this inset and of its contents
42         void updateLabels(ParIterator const &);
43         ///
44         void write(std::ostream & os) const;
45         ///
46         void read(Lexer & lex);
47         ///
48         docstring editMessage() const;
49         ///
50         int latex(odocstream &, OutputParams const &) const;
51         ///
52         void validate(LaTeXFeatures &) const;
53         ///
54         bool showInsetDialog(BufferView *) const;
55         ///
56         InsetListingsParams const & params() const { return params_; }
57         ///
58         InsetListingsParams & params() { return params_; }
59         ///
60         docstring contextMenu(BufferView const & bv, int x, int y) const;
61
62 private:
63         ///
64         void doDispatch(Cursor & cur, FuncRequest & cmd);
65         ///
66         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
67         ///
68         Inset * clone() const { return new InsetListings(*this); }
69         ///
70         void setButtonLabel();
71         ///
72         docstring getCaption(OutputParams const &) const;
73         ///
74         InsetListingsParams params_;
75 };
76
77
78 class InsetListingsMailer : public MailInset {
79 public:
80         ///
81         InsetListingsMailer(InsetListings & inset);
82         ///
83         virtual Inset & inset() const { return inset_; }
84         ///
85         virtual std::string const & name() const { return name_; }
86         ///
87         virtual std::string const inset2string(Buffer const &) const;
88         ///
89         static void string2params(std::string const &,
90                 InsetListingsParams &);
91         ///
92         static std::string const params2string(InsetListingsParams const &);
93 private:
94         ///
95         static std::string const name_;
96         ///
97         InsetListings & inset_;
98 };
99
100
101 } // namespace lyx
102
103 #endif