]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBranch.h
Fix bug #10901.
[lyx.git] / src / insets / InsetBranch.h
index ca24e99980a760c71120b5c292ae85583b886ddf..391f2475f06765971a9d4d69afb324b5bef05943 100644 (file)
@@ -12,8 +12,7 @@
 #ifndef INSETBRANCH_H
 #define INSETBRANCH_H
 
-#include "InsetCollapsable.h"
-
+#include "InsetCollapsible.h"
 
 namespace lyx {
 
@@ -21,13 +20,17 @@ 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;
 };
 
 
@@ -39,22 +42,24 @@ public:
 
 /// The Branch inset for alternative, conditional output.
 
-class InsetBranch : public InsetCollapsable
+class InsetBranch : public InsetCollapsible
 {
 public:
        ///
-       InsetBranch(Buffer const &, InsetBranchParams const &);
-       ///
-       ~InsetBranch();
+       InsetBranch(Buffer *, InsetBranchParams const &);
 
        ///
        static std::string params2string(InsetBranchParams const &);
        ///
        static void string2params(std::string const &, InsetBranchParams &);
+       ///
+       docstring branch() const { return params_.branch; }
+       ///
+       void rename(docstring const & newname) { params_.branch = newname; }
+       ///
+       InsetBranchParams const & params() const { return params_; }
 
 private:
-       ///
-       docstring editMessage() const;
        ///
        InsetCode lyxCode() const { return BRANCH_CODE; }
        ///
@@ -62,44 +67,54 @@ private:
        ///
        void read(Lexer & lex);
        ///
-       void setButtonLabel();
+       docstring const buttonLabel(BufferView const &) const;
        ///
-       ColorCode backgroundColor() const;
+       ColorCode backgroundColor(PainterInfo const &) const;
        ///
-       bool showInsetDialog(BufferView *) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
-       int latex(odocstream &, OutputParams const &) const;
-       ///
-       int plaintext(odocstream &, OutputParams const &) const;
+       int plaintext(odocstringstream & ods, OutputParams const & op,
+                     size_t max_length = INT_MAX) const;
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       void textString(odocstream &) const;
+       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       ///
+       void toString(odocstream &) const;
+       ///
+       void forOutliner(docstring &, size_t const, bool const) const;
        ///
        void validate(LaTeXFeatures &) const;
        ///
-       InsetBranchParams const & params() const { return params_; }
+       std::string contextMenuName() const;
+       ///
+       void updateBuffer(ParIterator const & it, UpdateType utype);
        ///
        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.
+               \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 isBranchSelected() const;
+       bool producesOutput() const;
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
-       void updateLabels(ParIterator const &);
-       ///
        bool isMacroScope() const;
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
        ///
-       bool useEmptyLayout() const { return false; }
+       bool usePlainLayout() const { return false; }
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
-       docstring name() const { return from_ascii("Branch"); }
+       docstring layoutName() const { return from_ascii("Branch:") + branch(); }
        ///
        Inset * clone() const { return new InsetBranch(*this); }