6663b6c9
adorian
projet complet av...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <escher/even_odd_expression_cell.h>
#include <assert.h>
using namespace Poincare;
EvenOddExpressionCell::EvenOddExpressionCell(float horizontalAlignment, float verticalAlignment,
KDColor textColor, KDColor backgroundColor) :
EvenOddCell(),
m_expressionView(horizontalAlignment, verticalAlignment, textColor, backgroundColor),
m_leftMargin(0),
m_rightMargin(0)
{
}
void EvenOddExpressionCell::setHighlighted(bool highlight) {
if (highlight != EvenOddCell::isHighlighted()) {
EvenOddCell::setHighlighted(highlight);
m_expressionView.setBackgroundColor(backgroundColor());
}
}
void EvenOddExpressionCell::setEven(bool even) {
EvenOddCell::setEven(even);
m_expressionView.setBackgroundColor(backgroundColor());
}
void EvenOddExpressionCell::setExpressionLayout(ExpressionLayout * expressionLayout) {
m_expressionView.setExpressionLayout(expressionLayout);
}
void EvenOddExpressionCell::setBackgroundColor(KDColor backgroundColor) {
m_expressionView.setBackgroundColor(backgroundColor);
}
void EvenOddExpressionCell::setTextColor(KDColor textColor) {
m_expressionView.setTextColor(textColor);
}
KDSize EvenOddExpressionCell::minimalSizeForOptimalDisplay() const {
KDSize expressionSize = m_expressionView.minimalSizeForOptimalDisplay();
return KDSize(m_leftMargin + expressionSize.width() + m_rightMargin, expressionSize.height());
}
void EvenOddExpressionCell::setLeftMargin(KDCoordinate margin) {
m_leftMargin = margin;
layoutSubviews();
}
void EvenOddExpressionCell::setRightMargin(KDCoordinate margin) {
m_rightMargin = margin;
layoutSubviews();
}
void EvenOddExpressionCell::drawRect(KDContext * ctx, KDRect rect) const {
// Color the margins
ctx->fillRect(KDRect(0, 0, m_leftMargin, bounds().height()), backgroundColor());
ctx->fillRect(KDRect(bounds().width() - m_rightMargin, 0, m_rightMargin, bounds().height()), backgroundColor());
}
int EvenOddExpressionCell::numberOfSubviews() const {
return 1;
}
View * EvenOddExpressionCell::subviewAtIndex(int index) {
assert(index == 0);
return &m_expressionView;
}
void EvenOddExpressionCell::layoutSubviews() {
m_expressionView.setFrame(KDRect(m_leftMargin, 0, bounds().width() - m_leftMargin - m_rightMargin, bounds().height()));
}
|