]> git.lyx.org Git - features.git/blob - src/insets/InsetBranch.h
a2f6c28a20b47fb52094aa068d912aada2fddc75
[features.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 const &, 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 private:
58         ///
59         docstring editMessage() const;
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(odocstream &, 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         virtual bool usePlainLayout() { return false; }
94
95         /** \returns true if params_.branch is listed as 'selected' in
96             \c buffer. This handles the case of child documents.
97          */
98         bool isBranchSelected() const;
99         /*!
100          * Is the content of this inset part of the output document?
101          *
102          * Note that Branch insets are only considered part of the
103          * document when they are selected.
104          */
105         bool producesOutput() const { return isBranchSelected(); }
106         ///
107         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
108         ///
109         bool isMacroScope() const;
110         ///
111         docstring toolTip(BufferView const & bv, int x, int y) const;
112         ///
113         bool usePlainLayout() const { return false; }
114         ///
115         void doDispatch(Cursor & cur, FuncRequest & cmd);
116         ///
117         docstring name() const { return from_ascii("Branch"); }
118         ///
119         Inset * clone() const { return new InsetBranch(*this); }
120
121         ///
122         friend class InsetBranchParams;
123         ///
124         InsetBranchParams params_;
125 };
126
127 } // namespace lyx
128
129 #endif