#include "Buffer.h"
#include "BufferParams.h"
#include "BranchList.h"
+#include "Counters.h"
#include "Cursor.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "gettext.h"
#include "Color.h"
#include "Lexer.h"
-#include "Paragraph.h"
#include "OutputParams.h"
#include <sstream>
namespace lyx {
using std::string;
-using std::auto_ptr;
using std::istringstream;
using std::ostream;
using std::ostringstream;
InsetBranchParams const & params)
: InsetCollapsable(bp), params_(params)
{
+ setLayout(bp);
init();
}
}
-auto_ptr<Inset> InsetBranch::doClone() const
+Inset * InsetBranch::clone() const
{
- return auto_ptr<Inset>(new InsetBranch(*this));
+ return new InsetBranch(*this);
}
{
params_.read(lex);
InsetCollapsable::read(buf, lex);
+ setLayout(buf.params());
setButtonLabel();
}
void InsetBranch::setButtonLabel()
{
- Font font(Font::ALL_SANE);
- font.decSize();
- font.decSize();
-
docstring s = _("Branch: ") + params_.branch;
- font.setColor(Color::foreground);
if (!params_.branch.empty()) {
// FIXME UNICODE
Color_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
if (c == Color::none) {
- c = Color::error;
s = _("Undef: ") + s;
}
- setBackgroundColor(c);
+ }
+ if (decoration() == Classic)
+ setLabel(isOpen() ? s : getNewLabel(s) );
+ else
+ setLabel(params_.branch + ": " + getNewLabel(s));
+}
+
+
+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
- setBackgroundColor(Color::background);
- setLabel(isOpen() ? s : getNewLabel(s) );
- setLabelFont(font);
+ return Inset::backgroundColor();
}
InsetBranchParams params;
InsetBranchMailer::string2params(to_utf8(cmd.argument()), params);
params_.branch = params.branch;
+ setLayout(cur.buffer().params());
setButtonLabel();
break;
}
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)
}
+void InsetBranch::updateLabels(Buffer const & buf, ParIterator const & it)
+{
+ if (isBranchSelected(buf))
+ InsetCollapsable::updateLabels(buf, it);
+ else {
+ TextClass const & tclass = buf.params().getTextClass();
+ Counters savecnt = tclass.counters();
+ InsetCollapsable::updateLabels(buf, it);
+ tclass.counters() = savecnt;
+ }
+}
+
+
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;
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]";
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;