#ifndef INSETBRANCH_H
#define INSETBRANCH_H
-#include "InsetCollapsable.h"
-#include "MailInset.h"
-
+#include "InsetCollapsible.h"
namespace lyx {
-class Buffer;
-
class InsetBranchParams {
public:
+ ///
explicit InsetBranchParams(docstring const & b = docstring())
- : branch(b) {}
+ : branch(b), inverted(false) {}
+ InsetBranchParams(docstring const & b, bool i)
+ : branch(b), inverted(i) {}
///
void write(std::ostream & os) const;
///
void read(Lexer & lex);
///
docstring branch;
+ ///
+ bool inverted;
};
-/** The Branch inset for alternative, conditional output.
+/////////////////////////////////////////////////////////////////////////
+//
+// InsetBranch
+//
+/////////////////////////////////////////////////////////////////////////
+
+/// The Branch inset for alternative, conditional output.
-*/
-class InsetBranch : public InsetCollapsable {
+class InsetBranch : public InsetCollapsible
+{
public:
///
- InsetBranch(BufferParams const &, InsetBranchParams const &);
+ InsetBranch(Buffer *, InsetBranchParams const &);
+
///
- ~InsetBranch();
+ static std::string params2string(InsetBranchParams const &);
///
- virtual docstring const editMessage() const;
+ static void string2params(std::string const &, InsetBranchParams &);
///
- Inset::Code lyxCode() const { return Inset::BRANCH_CODE; }
+ docstring branch() const { return params_.branch; }
///
- void write(Buffer const &, std::ostream &) const;
+ void rename(docstring const & newname) { params_.branch = newname; }
///
- void read(Buffer const & buf, Lexer & lex);
+ InsetBranchParams const & params() const { return params_; }
+
+private:
///
- void setButtonLabel();
+ InsetCode lyxCode() const { return BRANCH_CODE; }
///
- bool showInsetDialog(BufferView *) const;
+ void write(std::ostream &) const;
///
- int latex(Buffer const &, odocstream &,
- OutputParams const &) const;
+ void read(Lexer & lex);
///
- int plaintext(Buffer const &, odocstream &,
- OutputParams const &) const;
+ docstring const buttonLabel(BufferView const &) const;
///
- int docbook(Buffer const &, odocstream &,
- OutputParams const &) const;
+ ColorCode backgroundColor(PainterInfo const &) const;
///
- void textString(Buffer const & buf, odocstream &) const;
+ void latex(otexstream &, OutputParams const &) const;
///
- void validate(LaTeXFeatures &) const;
+ int plaintext(odocstringstream & ods, OutputParams const & op,
+ size_t max_length = INT_MAX) const;
///
- InsetBranchParams const & params() const { return params_; }
+ void docbook(XMLStream &, OutputParams const &) const;
///
- void setParams(InsetBranchParams const & params) { params_ = params; }
-
- /** \returns true if params_.branch is listed as 'selected' in
- \c buffer. This handles the case of child documents.
- */
- bool isBranchSelected(Buffer const & buffer) const;
+ docstring xhtml(XMLStream &, OutputParams const &) const;
///
- bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
-
-protected:
+ void toString(odocstream &) const;
///
- InsetBranch(InsetBranch const &);
+ void forOutliner(docstring &, size_t const, bool const) const;
///
- virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
+ void validate(LaTeXFeatures &) const;
///
- docstring name() const { return from_ascii("Branch"); }
-private:
- friend class InsetBranchParams;
-
- virtual std::auto_ptr<Inset> doClone() const;
-
- /// used by the constructors
- void init();
+ std::string contextMenuName() const;
///
- InsetBranchParams params_;
-};
+ void updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted = false);
-
-class InsetBranchMailer : public MailInset {
-public:
+ /** \returns true if params_.branch is listed as 'selected' in
+ \c buffer. \p child only checks within child documents.
+ */
+ bool isBranchSelected(bool const child = false) const;
+ /*!
+ * Is the content of this inset part of the output document?
+ *
+ * Note that Branch insets are considered part of the
+ * document when they are selected XOR inverted.
+ */
+ bool producesOutput() const;
///
- InsetBranchMailer(InsetBranch & inset);
+ bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
- virtual Inset & inset() const { return inset_; }
+ bool isMacroScope() const;
///
- virtual std::string const & name() const { return name_; }
+ docstring toolTip(BufferView const & bv, int x, int y) const;
///
- virtual std::string const inset2string(Buffer const &) const;
+ bool usePlainLayout() const { return false; }
///
- static std::string const params2string(InsetBranchParams const &);
+ void doDispatch(Cursor & cur, FuncRequest & cmd);
///
- static void string2params(std::string const &, InsetBranchParams &);
+ docstring layoutName() const { return from_ascii("Branch:") + branch(); }
+ ///
+ Inset * clone() const { return new InsetBranch(*this); }
-private:
///
- static std::string const name_;
+ friend class InsetBranchParams;
///
- InsetBranch & inset_;
+ InsetBranchParams params_;
};
} // namespace lyx