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