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"
20 class InsetBranchParams {
23 explicit InsetBranchParams(docstring const & b = docstring())
26 void write(std::ostream & os) const;
28 void read(Lexer & lex);
34 /////////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////////
40 /// The Branch inset for alternative, conditional output.
42 class InsetBranch : public InsetCollapsable
46 InsetBranch(Buffer const &, InsetBranchParams const &);
51 static std::string params2string(InsetBranchParams const &);
53 static void string2params(std::string const &, InsetBranchParams &);
55 docstring branch() const { return params_.branch; }
57 void rename(docstring const & newname) { params_.branch = newname; }
61 docstring editMessage() const;
63 InsetCode lyxCode() const { return BRANCH_CODE; }
65 void write(std::ostream &) const;
67 void read(Lexer & lex);
69 docstring const buttonLabel(BufferView const & bv) const;
71 ColorCode backgroundColor() const;
73 bool showInsetDialog(BufferView *) const;
75 int latex(odocstream &, OutputParams const &) const;
77 int plaintext(odocstream &, OutputParams const &) const;
79 int docbook(odocstream &, OutputParams const &) const;
81 docstring xhtml(odocstream &, OutputParams const &) const;
83 void tocString(odocstream &) const;
85 void validate(LaTeXFeatures &) const;
87 docstring contextMenu(BufferView const &, int, int) const;
89 void addToToc(DocIterator const &);
91 InsetBranchParams const & params() const { return params_; }
93 void setParams(InsetBranchParams const & params) { params_ = params; }
95 /** \returns true if params_.branch is listed as 'selected' in
96 \c buffer. This handles the case of child documents.
98 bool isBranchSelected() const;
100 * Is the content of this inset part of the output document?
102 * Note that Branch insets are only considered part of the
103 * document when they are selected.
105 bool producesOutput() const { return isBranchSelected(); }
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 name() const { return from_ascii("Branch"); }
119 Inset * clone() const { return new InsetBranch(*this); }
122 friend class InsetBranchParams;
124 InsetBranchParams params_;