]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
Restore XHTML output for InsetListings.
[lyx.git] / src / insets / InsetBranch.h
1 // -*- C++ -*-
2 /**
3  * \file InsetBranch.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Martin Vermeer
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETBRANCH_H
13 #define INSETBRANCH_H
14
15 #include "InsetCollapsable.h"
16
17
18 namespace lyx {
19
20 class InsetBranchParams {
21 public:
22         ///
23         explicit InsetBranchParams(docstring const & b = docstring())
24                 : branch(b) {}
25         ///
26         void write(std::ostream & os) const;
27         ///
28         void read(Lexer & lex);
29         ///
30         docstring branch;
31 };
32
33
34 /////////////////////////////////////////////////////////////////////////
35 //
36 // InsetBranch
37 //
38 /////////////////////////////////////////////////////////////////////////
39
40 /// The Branch inset for alternative, conditional output.
41
42 class InsetBranch : public InsetCollapsable
43 {
44 public:
45         ///
46         InsetBranch(Buffer *, InsetBranchParams const &);
47         ///
48         ~InsetBranch();
49
50         ///
51         static std::string params2string(InsetBranchParams const &);
52         ///
53         static void string2params(std::string const &, InsetBranchParams &);
54         ///
55         docstring branch() const { return params_.branch; }
56         ///
57         void rename(docstring const & newname) { params_.branch = newname; }
58
59 private:
60         ///
61         InsetCode lyxCode() const { return BRANCH_CODE; }
62         ///
63         void write(std::ostream &) const;
64         ///
65         void read(Lexer & lex);
66         ///
67         docstring const buttonLabel(BufferView const & bv) const;
68         ///
69         ColorCode backgroundColor() const;
70         ///
71         bool showInsetDialog(BufferView *) const;
72         ///
73         int latex(odocstream &, OutputParams const &) const;
74         ///
75         int plaintext(odocstream &, OutputParams const &) const;
76         ///
77         int docbook(odocstream &, OutputParams const &) const;
78         ///
79         docstring xhtml(XHTMLStream &, OutputParams const &) const;
80         ///
81         void tocString(odocstream &) const;
82         ///
83         void validate(LaTeXFeatures &) const;
84         ///
85         docstring contextMenu(BufferView const &, int, int) const;
86         ///
87         void addToToc(DocIterator const &);
88         ///
89         InsetBranchParams const & params() const { return params_; }
90         ///
91         void setParams(InsetBranchParams const & params) { params_ = params; }
92
93         /** \returns true if params_.branch is listed as 'selected' in
94             \c buffer. This handles the case of child documents.
95          */
96         bool isBranchSelected() const;
97         /*!
98          * Is the content of this inset part of the output document?
99          *
100          * Note that Branch insets are only considered part of the
101          * document when they are selected.
102          */
103         bool producesOutput() const { return isBranchSelected(); }
104         ///
105         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
106         ///
107         bool isMacroScope() const;
108         ///
109         docstring toolTip(BufferView const & bv, int x, int y) const;
110         ///
111         bool usePlainLayout() const { return false; }
112         ///
113         void doDispatch(Cursor & cur, FuncRequest & cmd);
114         ///
115         docstring name() const { return from_ascii("Branch"); }
116         ///
117         Inset * clone() const { return new InsetBranch(*this); }
118
119         ///
120         friend class InsetBranchParams;
121         ///
122         InsetBranchParams params_;
123 };
124
125 } // namespace lyx
126
127 #endif