]> git.lyx.org Git - lyx.git/blobdiff - src/BranchList.C
* Painter.h:
[lyx.git] / src / BranchList.C
index 6d89551b74c9c8235155327d46d387c744d63bac..90aabdc0350638b90d47aa66871d685af470f37a 100644 (file)
 #include <config.h>
 
 #include "BranchList.h"
+#include "LColor.h"
+
+#include "frontends/Application.h"
+
 #include <algorithm>
 
+
+namespace lyx {
+
 using std::string;
 
 
+Branch::Branch()
+{
+       theApp->getRgbColor(LColor::background, color_);
+}
+
+
 string const & Branch::getBranch() const
 {
        return branch_;
@@ -43,18 +56,28 @@ bool Branch::setSelected(bool b)
 }
 
 
-string const & Branch::getColor() const
+RGBColor const & Branch::getColor() const
 {
        return color_;
 }
 
 
-void Branch::setColor(string const & c)
+void Branch::setColor(RGBColor const & c)
 {
        color_ = c;
 }
 
 
+void Branch::setColor(string const & c)
+{
+       if (c.size() == 7 && c[0] == '#')
+               color_ = RGBColor(c);
+       else
+               // no color set or invalid color - use normal background
+               theApp->getRgbColor(LColor::background, color_);
+}
+
+
 Branch * BranchList::find(std::string const & name)
 {
        List::iterator it =
@@ -91,7 +114,6 @@ bool BranchList::add(string const & s)
                        Branch br;
                        br.setBranch(name);
                        br.setSelected(false);
-                       br.setColor("none");
                        list.push_back(br);
                }
                if (j == string::npos)
@@ -104,7 +126,10 @@ bool BranchList::add(string const & s)
 
 bool BranchList::remove(string const & s)
 {
-       List::size_type const size = list.size();
+       size_t const size = list.size();
        list.remove_if(BranchNamesEqual(s));
        return size != list.size();
 }
+
+
+} // namespace lyx