Files
Upsilon/apps/graph/list/function_expression_view.cpp
Émilie Feral 1f7ba888c9 [apps/graph] add an attribute "activate" to functions
Change-Id: I1a1f548c540a6e31fe9ce1aeb742bf6a6292362c
2016-09-20 11:12:46 +02:00

58 lines
1.6 KiB
C++

#include "function_expression_view.h"
#include "function_cell.h"
#include <poincare.h>
FunctionExpressionView::FunctionExpressionView(Responder * parentResponder) :
ChildlessView(),
Responder(parentResponder),
m_focused(false)
{
}
void FunctionExpressionView::drawRect(KDContext * ctx, KDRect rect) const {
bool evenLine = isEven();
KDColor background = evenLine ? KDColor(0xEEEEEE) : KDColor(0x777777);
ctx->fillRect(rect, background);
bool active = function()->isActive();
KDColor text = active ? KDColorGreen : KDColorRed;
KDColor textBackground = m_focused ? KDColorWhite : KDColorBlack;
Graph::Function * function = FunctionExpressionView::function();
ctx->drawString(function->text(), KDPointZero, text, textBackground);
// m_function->layout()->draw(ctx, KDPointZero);
}
void FunctionExpressionView::didBecomeFirstResponder() {
m_focused = true;
markRectAsDirty(bounds());
}
void FunctionExpressionView::didResignFirstResponder() {
m_focused = false;
markRectAsDirty(bounds());
}
bool FunctionExpressionView::isFocused() const {
return m_focused;
}
Graph::Function * FunctionExpressionView::function() const{
FunctionCell * parentCell = (FunctionCell *) parentResponder();
return parentCell->function();
}
bool FunctionExpressionView::isEven() const {
FunctionCell * parentCell = (FunctionCell *) parentResponder();
return parentCell->isEven();
}
bool FunctionExpressionView::handleEvent(Ion::Events::Event event) {
switch (event) {
case Ion::Events::Event::ENTER:
// afficher un champs texte
return true;
default:
return false;
}
}