Files
Upsilon/apps/graph/even_odd_cell.cpp
Émilie Feral 02857d499d [apps/graph] create a class of even odd cell
Change-Id: Ie39168a0b298e67bfff39a35cac4f0804cae16ab
2016-10-07 14:23:24 +02:00

44 lines
1.3 KiB
C++

#include "even_odd_cell.h"
constexpr KDColor EvenOddCell::k_evenLineBackgroundColor;
constexpr KDColor EvenOddCell::k_oddLineBackgroundColor;
constexpr KDColor EvenOddCell::k_selectedLineBackgroundColor;
EvenOddCell::EvenOddCell(float horizontalAlignment, float verticalAlignement) :
ChildlessView(),
m_horizontalAlignment(horizontalAlignment),
m_verticalAlignment(verticalAlignement),
m_highlighted(false),
m_even(false)
{
}
void EvenOddCell::setEven(bool even) {
m_even = even;
markRectAsDirty(bounds());
}
void EvenOddCell::setHighlighted(bool highlight) {
m_highlighted = highlight;
markRectAsDirty(bounds());
}
void EvenOddCell::reloadCell() {
markRectAsDirty(bounds());
}
KDColor EvenOddCell::backgroundColor() const {
// Select the background color according to the even line and the cursor selection
KDColor background = m_even ? EvenOddCell::k_evenLineBackgroundColor : EvenOddCell::k_oddLineBackgroundColor;
background = m_highlighted ? EvenOddCell::k_selectedLineBackgroundColor : background;
return background;
}
void EvenOddCell::drawRect(KDContext * ctx, KDRect rect) const {
// Select the background color according to the even line and the cursor selection
KDColor background = backgroundColor();
ctx->fillRect(rect, background);
}