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 "InsetCollapsable.h"
19 class InsetBranchParams {
22 explicit InsetBranchParams(docstring const & b = docstring())
25 void write(std::ostream & os) const;
27 void read(Lexer & lex);
33 /////////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////////
39 /// The Branch inset for alternative, conditional output.
41 class InsetBranch : public InsetCollapsable
45 InsetBranch(Buffer *, InsetBranchParams const &);
48 static std::string params2string(InsetBranchParams const &);
50 static void string2params(std::string const &, InsetBranchParams &);
52 docstring branch() const { return params_.branch; }
54 void rename(docstring const & newname) { params_.branch = newname; }
58 InsetCode lyxCode() const { return BRANCH_CODE; }
60 void write(std::ostream &) const;
62 void read(Lexer & lex);
64 docstring const buttonLabel(BufferView const & bv) const;
66 ColorCode backgroundColor(PainterInfo const &) const;
68 void latex(otexstream &, OutputParams const &) const;
70 int plaintext(odocstream &, OutputParams const &) const;
72 int docbook(odocstream &, OutputParams const &) const;
74 docstring xhtml(XHTMLStream &, OutputParams const &) const;
76 void toString(odocstream &) const;
78 void forToc(docstring &, size_t) const;
80 void validate(LaTeXFeatures &) const;
82 std::string contextMenuName() const;
84 void addToToc(DocIterator const &) const;
86 InsetBranchParams const & params() const { return params_; }
88 void setParams(InsetBranchParams const & params) { params_ = params; }
90 /** \returns true if params_.branch is listed as 'selected' in
91 \c buffer. This handles the case of child documents.
93 bool isBranchSelected() const;
95 * Is the content of this inset part of the output document?
97 * Note that Branch insets are only considered part of the
98 * document when they are selected.
100 bool producesOutput() const { return isBranchSelected(); }
102 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
104 bool isMacroScope() const;
106 docstring toolTip(BufferView const & bv, int x, int y) const;
108 bool usePlainLayout() const { return false; }
110 void doDispatch(Cursor & cur, FuncRequest & cmd);
112 docstring layoutName() const { return from_ascii("Branch:") + branch(); }
114 Inset * clone() const { return new InsetBranch(*this); }
117 friend class InsetBranchParams;
119 InsetBranchParams params_;