Files
Upsilon/apps/graph/list/function_name_view.cpp
Émilie Feral c3524fa287 [apps/graph/list] make the class function cell inherits from even odd cell class
Change-Id: I8c786d76c7be726b2672713a5150dce5abb12061
2016-10-11 10:31:50 +02:00

27 lines
1.3 KiB
C++

#include "function_name_view.h"
FunctionNameView::FunctionNameView() :
FunctionCell()
{
}
void FunctionNameView::drawRect(KDContext * ctx, KDRect rect) const {
EvenOddCell::drawRect(ctx, rect);
// First color the color indicator
KDCoordinate height = bounds().height();
KDColor functionColor = m_function->color();
ctx->fillRect(KDRect(0, 0, k_colorIndicatorThickness, height), functionColor);
// Select function name color and the text color according to the state of the function
bool active = m_function->isActive();
KDColor textColor = active ? KDColorBlack : FunctionCell::k_desactiveTextColor;
KDColor functionNameColor = active ? functionColor : FunctionCell::k_desactiveTextColor;
// Select the background color according to the even line and the cursor selection
KDColor background = backgroundColor();
// Position the name of the function
const char * functionName = m_function->name();
KDCoordinate baseline = m_function->layout()->baseline();
KDSize nameSize = KDText::stringSize(functionName);
ctx->drawString(functionName, KDPoint(k_colorIndicatorThickness, baseline-nameSize.height()), functionNameColor, background);
ctx->drawString("(x)", KDPoint(k_colorIndicatorThickness+nameSize.width(), baseline-nameSize.height()), textColor, background);
}