Finally make the label color of multiple index entries work.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30533 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-07-13 06:46:52 +00:00
parent c878519ca9
commit bbfc419c10
7 changed files with 38 additions and 12 deletions

View File

@ -2697,8 +2697,8 @@ void GuiDocument::dispatchParams()
IndicesList::const_iterator it = indiceslist.begin();
IndicesList::const_iterator const end = indiceslist.end();
for (; it != end; ++it) {
docstring const & current_index = it->index();
Index const * index = indiceslist.find(current_index);
docstring const & current_index = it->shortcut();
Index const * index = indiceslist.findShortcut(current_index);
string const x11hexname = X11hexname(index->color());
// display the new color
docstring const str = current_index + ' ' + from_ascii(x11hexname);

View File

@ -466,6 +466,12 @@ ColorCode Inset::backgroundColor() const
}
ColorCode Inset::labelColor() const
{
return Color_foreground;
}
void Inset::setPosCache(PainterInfo const & pi, int x, int y) const
{
//LYXERR("Inset: set position cache to " << x << " " << y);

View File

@ -497,6 +497,8 @@ public:
///
virtual ColorCode backgroundColor() const;
///
virtual ColorCode labelColor() const;
///
enum CollapseStatus {
Collapsed,
Open

View File

@ -306,7 +306,9 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
button_dim.y1 = y - dimc.asc;
button_dim.y2 = y + dimc.des;
pi.pain.buttonText(x, y, buttonLabel(bv), getLayout().labelfont(),
FontInfo labelfont = getLayout().labelfont();
labelfont.setColor(labelColor());
pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
mouse_hover_);
} else {
button_dim.x1 = 0;
@ -352,22 +354,22 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
const int xx2 = x + textdim.wid - TEXT_TO_INSET_OFFSET + 1;
pi.pain.line(xx1, y + desc - 4,
xx1, y + desc,
getLayout().labelfont().color());
labelColor());
if (status_ == Open)
pi.pain.line(xx1, y + desc,
xx2, y + desc,
getLayout().labelfont().color());
labelColor());
else {
// Make status_ value visible:
pi.pain.line(xx1, y + desc,
xx1 + 4, y + desc,
getLayout().labelfont().color());
labelColor());
pi.pain.line(xx2 - 4, y + desc,
xx2, y + desc,
getLayout().labelfont().color());
labelColor());
}
pi.pain.line(x + textdim.wid - 3, y + desc, x + textdim.wid - 3,
y + desc - 4, getLayout().labelfont().color());
y + desc - 4, labelColor());
// the label below the text. Can be toggled.
if (geometry(bv) == SubLabel) {
@ -390,12 +392,12 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
if (cur.isInside(this)) {
y -= textdim.asc;
y += 3;
pi.pain.line(xx1, y + 4, xx1, y, getLayout().labelfont().color());
pi.pain.line(xx1 + 4, y, xx1, y, getLayout().labelfont().color());
pi.pain.line(xx1, y + 4, xx1, y, labelColor());
pi.pain.line(xx1 + 4, y, xx1, y, labelColor());
pi.pain.line(xx2, y + 4, xx2, y,
getLayout().labelfont().color());
labelColor());
pi.pain.line(xx2 - 4, y, xx2, y,
getLayout().labelfont().color());
labelColor());
}
break;
}

View File

@ -138,6 +138,8 @@ public:
///
ColorCode backgroundColor() const { return getLayout().bgcolor(); }
///
ColorCode labelColor() const { return getLayout().labelfont().color(); }
///
int latex(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;

View File

@ -254,6 +254,18 @@ docstring const InsetIndex::buttonLabel(BufferView const & bv) const
}
ColorCode InsetIndex::labelColor() const
{
if (params_.index.empty() || params_.index == from_ascii("idx"))
return InsetCollapsable::labelColor();
// FIXME UNICODE
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index));
if (c == Color_none)
c = InsetCollapsable::labelColor();
return c;
}
docstring InsetIndex::toolTip(BufferView const &, int, int) const
{
docstring tip = _("Index Entry");

View File

@ -51,6 +51,8 @@ private:
///
docstring name() const { return from_ascii("Index"); }
///
ColorCode labelColor() const;
///
void write(std::ostream & os) const;
///
void read(Lexer & lex);