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(odocstringstream & ods, OutputParams const & op,
71 size_t max_length = INT_MAX) const;
73 int docbook(odocstream &, OutputParams const &) const;
75 docstring xhtml(XHTMLStream &, OutputParams const &) const;
77 void toString(odocstream &) const;
79 void forToc(docstring &, size_t) const;
81 void validate(LaTeXFeatures &) const;
83 std::string contextMenuName() const;
85 void addToToc(DocIterator const & di, bool output_active) const;
87 InsetBranchParams const & params() const { return params_; }
89 void setParams(InsetBranchParams const & params) { params_ = params; }
91 /** \returns true if params_.branch is listed as 'selected' in
92 \c buffer. \p child only checks within child documents.
94 bool isBranchSelected(bool const child = false) const;
96 * Is the content of this inset part of the output document?
98 * Note that Branch insets are only considered part of the
99 * document when they are selected.
101 bool producesOutput() const { return isBranchSelected(); }
103 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
105 bool isMacroScope() const;
107 docstring toolTip(BufferView const & bv, int x, int y) const;
109 bool usePlainLayout() const { return false; }
111 void doDispatch(Cursor & cur, FuncRequest & cmd);
113 docstring layoutName() const { return from_ascii("Branch:") + branch(); }
115 Inset * clone() const { return new InsetBranch(*this); }
118 friend class InsetBranchParams;
120 InsetBranchParams params_;