]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBranch.cpp
Use home made code for the bool facet.
[lyx.git] / src / insets / InsetBranch.cpp
index 3251090ff56c749c0bcab42b8f06c91597408bf9..62f6a57dbca5944e9bb44445382871a831c82462 100644 (file)
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BranchList.h"
-#include "LCursor.h"
+#include "Cursor.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "gettext.h"
-#include "LColor.h"
+#include "Color.h"
 #include "Lexer.h"
-#include "Paragraph.h"
 #include "OutputParams.h"
 
 #include <sstream>
@@ -39,7 +38,6 @@ using std::ostringstream;
 
 void InsetBranch::init()
 {
-       setInsetName(from_utf8("Branch"));
        setButtonLabel();
 }
 
@@ -65,9 +63,9 @@ InsetBranch::~InsetBranch()
 }
 
 
-auto_ptr<InsetBase> InsetBranch::doClone() const
+auto_ptr<Inset> InsetBranch::doClone() const
 {
-       return auto_ptr<InsetBase>(new InsetBranch(*this));
+       return auto_ptr<Inset>(new InsetBranch(*this));
 }
 
 
@@ -94,27 +92,38 @@ void InsetBranch::read(Buffer const & buf, Lexer & lex)
 
 void InsetBranch::setButtonLabel()
 {
-       LyXFont font(LyXFont::ALL_SANE);
+       Font font(Font::ALL_SANE);
        font.decSize();
        font.decSize();
 
        docstring s = _("Branch: ") + params_.branch;
-       font.setColor(LColor::foreground);
        if (!params_.branch.empty()) {
                // FIXME UNICODE
-               LColor_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
-               if (c == LColor::none) {
-                       c = LColor::error;
+               Color_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
+               if (c == Color::none) {
                        s = _("Undef: ") + s;
                }
-               setBackgroundColor(c);
-       } else
-               setBackgroundColor(LColor::background);
+       }
+       font.setColor(Color::foreground);
        setLabel(isOpen() ? s : getNewLabel(s) );
        setLabelFont(font);
 }
 
 
+Color_color InsetBranch::backgroundColor() const
+{
+       if (!params_.branch.empty()) {
+               // FIXME UNICODE
+               Color_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
+               if (c == Color::none) {
+                       c = Color::error;
+               }
+               return c;
+       } else
+               return Inset::backgroundColor();
+}
+
+
 bool InsetBranch::showInsetDialog(BufferView * bv) const
 {
        InsetBranchMailer(const_cast<InsetBranch &>(*this)).showDialog(bv);
@@ -122,7 +131,7 @@ bool InsetBranch::showInsetDialog(BufferView * bv) const
 }
 
 
-void InsetBranch::doDispatch(LCursor & cur, FuncRequest & cmd)
+void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
@@ -153,7 +162,7 @@ void InsetBranch::doDispatch(LCursor & cur, FuncRequest & cmd)
 
 
        case LFUN_INSET_TOGGLE:
-               if (cmd.argument() == "assign" || cmd.argument().empty()) {
+               if (cmd.argument() == "assign") {
                        // The branch inset uses "assign".
                        if (isBranchSelected(cur.buffer())) {
                                if (status() != Open)
@@ -178,7 +187,7 @@ void InsetBranch::doDispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
-bool InsetBranch::getStatus(LCursor & cur, FuncRequest const & cmd,
+bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
        switch (cmd.action) {
@@ -223,7 +232,7 @@ bool InsetBranch::isBranchSelected(Buffer const & buffer) const
 
 
 int InsetBranch::latex(Buffer const & buf, odocstream & os,
-                       OutputParams const & runparams) const
+                      OutputParams const & runparams) const
 {
        return isBranchSelected(buf) ?
                InsetText::latex(buf, os, runparams) : 0;
@@ -231,12 +240,12 @@ int InsetBranch::latex(Buffer const & buf, odocstream & os,
 
 
 int InsetBranch::plaintext(Buffer const & buf, odocstream & os,
-                           OutputParams const & runparams) const
+                          OutputParams const & runparams) const
 {
        if (!isBranchSelected(buf))
                return 0;
 
-       os << '[' << _("branch") << ' ' << params_.branch << ":\n";
+       os << '[' << buf.B_("branch") << ' ' << params_.branch << ":\n";
        InsetText::plaintext(buf, os, runparams);
        os << "\n]";
 
@@ -245,7 +254,7 @@ int InsetBranch::plaintext(Buffer const & buf, odocstream & os,
 
 
 int InsetBranch::docbook(Buffer const & buf, odocstream & os,
-                         OutputParams const & runparams) const
+                        OutputParams const & runparams) const
 {
        return isBranchSelected(buf) ?
                InsetText::docbook(buf, os, runparams) : 0;
@@ -305,7 +314,7 @@ void InsetBranchMailer::string2params(string const & in,
                return print_mailer_error("InsetBranchMailer", in, 1, name_);
 
        // This is part of the inset proper that is usually swallowed
-       // by LyXText::readInset
+       // by Text::readInset
        string id;
        lex >> id;
        if (!lex || id != "Branch")