4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Martin Vermeer
9 * Full author contact details are available in file CREDITS.
15 #include "InsetCollapsible.h"
19 class InsetBranchParams {
22 explicit InsetBranchParams(docstring const & b = docstring())
23 : branch(b), inverted(false) {}
24 InsetBranchParams(docstring const & b, bool i)
25 : branch(b), inverted(i) {}
27 void write(std::ostream & os) const;
29 void read(Lexer & lex);
37 /////////////////////////////////////////////////////////////////////////
41 /////////////////////////////////////////////////////////////////////////
43 /// The Branch inset for alternative, conditional output.
45 class InsetBranch : public InsetCollapsible
49 InsetBranch(Buffer *, InsetBranchParams const &);
52 static std::string params2string(InsetBranchParams const &);
54 static void string2params(std::string const &, InsetBranchParams &);
56 docstring branch() const { return params_.branch; }
58 void rename(docstring const & newname) { params_.branch = newname; }
60 InsetBranchParams const & params() const { return params_; }
64 InsetCode lyxCode() const { return BRANCH_CODE; }
66 void write(std::ostream &) const;
68 void read(Lexer & lex);
70 docstring const buttonLabel(BufferView const &) const;
72 ColorCode backgroundColor(PainterInfo const &) const;
74 void latex(otexstream &, OutputParams const &) const;
76 int plaintext(odocstringstream & ods, OutputParams const & op,
77 size_t max_length = INT_MAX) const;
79 int docbook(odocstream &, OutputParams const &) const;
81 docstring xhtml(XHTMLStream &, OutputParams const &) const;
83 void toString(odocstream &) const;
85 void forOutliner(docstring &, size_t const, bool const) const;
87 void validate(LaTeXFeatures &) const;
89 std::string contextMenuName() const;
91 void updateBuffer(ParIterator const & it, UpdateType utype);
93 void setParams(InsetBranchParams const & params) { params_ = params; }
95 /** \returns true if params_.branch is listed as 'selected' in
96 \c buffer. \p child only checks within child documents.
98 bool isBranchSelected(bool const child = false) const;
100 * Is the content of this inset part of the output document?
102 * Note that Branch insets are considered part of the
103 * document when they are selected XOR inverted.
105 bool producesOutput() const;
107 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
109 bool isMacroScope() const;
111 docstring toolTip(BufferView const & bv, int x, int y) const;
113 bool usePlainLayout() const { return false; }
115 void doDispatch(Cursor & cur, FuncRequest & cmd);
117 docstring layoutName() const { return from_ascii("Branch:") + branch(); }
119 Inset * clone() const { return new InsetBranch(*this); }
122 friend class InsetBranchParams;
124 InsetBranchParams params_;