#include "Buffer.h"
#include "BufferParams.h"
#include "BranchList.h"
+#include "Color.h"
+#include "Counters.h"
#include "Cursor.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
-#include "gettext.h"
-#include "Color.h"
+#include "support/gettext.h"
#include "Lexer.h"
-#include "Paragraph.h"
#include "OutputParams.h"
+#include "TextClass.h"
#include <sstream>
+using namespace std;
namespace lyx {
-using std::string;
-using std::auto_ptr;
-using std::istringstream;
-using std::ostream;
-using std::ostringstream;
-
-
-void InsetBranch::init()
-{
- setButtonLabel();
-}
-
InsetBranch::InsetBranch(BufferParams const & bp,
InsetBranchParams const & params)
: InsetCollapsable(bp), params_(params)
-{
- init();
-}
+{}
InsetBranch::InsetBranch(InsetBranch const & in)
: InsetCollapsable(in), params_(in.params_)
-{
- init();
-}
+{}
InsetBranch::~InsetBranch()
}
-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);
- 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;
+ ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
+ if (c == Color_none) {
s = _("Undef: ") + s;
}
- setBackgroundColor(c);
+ }
+ if (decoration() == Classic)
+ setLabel(isOpen() ? s : getNewLabel(s) );
+ else
+ setLabel(params_.branch + ": " + getNewLabel(s));
+}
+
+
+ColorCode InsetBranch::backgroundColor() const
+{
+ if (!params_.branch.empty()) {
+ // FIXME UNICODE
+ ColorCode 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;
- setButtonLabel();
+ setLayout(cur.buffer().params());
break;
}
bool InsetBranch::isBranchSelected(Buffer const & buffer) const
{
- Buffer const & realbuffer = *buffer.getMasterBuffer();
+ Buffer const & realbuffer = *buffer.masterBuffer();
BranchList const & branchlist = realbuffer.params().branchlist();
BranchList::const_iterator const end = branchlist.end();
BranchList::const_iterator it =
- std::find_if(branchlist.begin(), end,
+ find_if(branchlist.begin(), end,
BranchNamesEqual(params_.branch));
if (it == end)
return false;
}
+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
{
}
+bool InsetBranch::isMacroScope(Buffer const & buf) const
+{
+ // Its own scope if not selected by buffer
+ return !isBranchSelected(buf);
+}
+
string const InsetBranchMailer::name_("branch");