]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
Get rid of Qt resources
[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 "InsetCollapsible.h"
16
17 namespace lyx {
18
19 class InsetBranchParams {
20 public:
21         ///
22         explicit InsetBranchParams(docstring const & b = docstring())
23                 : branch(b), inverted(false) {}
24         InsetBranchParams(docstring const & b, bool i)
25                 : branch(b), inverted(i) {}
26         ///
27         void write(std::ostream & os) const;
28         ///
29         void read(Lexer & lex);
30         ///
31         docstring branch;
32         ///
33         bool inverted;
34 };
35
36
37 /////////////////////////////////////////////////////////////////////////
38 //
39 // InsetBranch
40 //
41 /////////////////////////////////////////////////////////////////////////
42
43 /// The Branch inset for alternative, conditional output.
44
45 class InsetBranch : public InsetCollapsible
46 {
47 public:
48         ///
49         InsetBranch(Buffer *, InsetBranchParams const &);
50
51         ///
52         static std::string params2string(InsetBranchParams const &);
53         ///
54         static void string2params(std::string const &, InsetBranchParams &);
55         ///
56         docstring branch() const { return params_.branch; }
57         ///
58         void rename(docstring const & newname) { params_.branch = newname; }
59         ///
60         InsetBranchParams const & params() const { return params_; }
61
62 private:
63         ///
64         InsetCode lyxCode() const { return BRANCH_CODE; }
65         ///
66         void write(std::ostream &) const;
67         ///
68         void read(Lexer & lex);
69         ///
70         docstring const buttonLabel(BufferView const &) const;
71         ///
72         ColorCode backgroundColor(PainterInfo const &) const;
73         ///
74         void latex(otexstream &, OutputParams const &) const;
75         ///
76         int plaintext(odocstringstream & ods, OutputParams const & op,
77                       size_t max_length = INT_MAX) const;
78         ///
79         int docbook(odocstream &, OutputParams const &) const;
80         ///
81         docstring xhtml(XHTMLStream &, OutputParams const &) const;
82         ///
83         void toString(odocstream &) const;
84         ///
85         void forOutliner(docstring &, size_t const, bool const) const;
86         ///
87         void validate(LaTeXFeatures &) const;
88         ///
89         std::string contextMenuName() const;
90         ///
91         void updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted = false);
92
93         /** \returns true if params_.branch is listed as 'selected' in
94                 \c buffer. \p child only checks within child documents.
95          */
96         bool isBranchSelected(bool const child = false) const;
97         /*!
98          * Is the content of this inset part of the output document?
99          *
100          * Note that Branch insets are considered part of the
101          * document when they are selected XOR inverted.
102          */
103         bool producesOutput() const;
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 layoutName() const { return from_ascii("Branch:") + 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