mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 18:20:14 +01:00
[escher] create class expression view
Change-Id: I16ddd22318ad120d736ad7f10bb2800a13c2b005
This commit is contained in:
37
escher/src/expression_view.cpp
Normal file
37
escher/src/expression_view.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <escher/expression_view.h>
|
||||
|
||||
ExpressionView::ExpressionView() :
|
||||
m_expressionLayout(nullptr),
|
||||
m_textColor(KDColorBlack),
|
||||
m_backgroundColor(KDColorWhite)
|
||||
{
|
||||
}
|
||||
|
||||
void ExpressionView::setExpression(ExpressionLayout * expressionLayout) {
|
||||
m_expressionLayout = expressionLayout;
|
||||
}
|
||||
|
||||
void ExpressionView::setBackgroundColor(KDColor backgroundColor) {
|
||||
m_backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
void ExpressionView::setTextColor(KDColor textColor) {
|
||||
m_textColor = textColor;
|
||||
}
|
||||
|
||||
KDSize ExpressionView::minimalSizeForOptimalDisplay() {
|
||||
if (m_expressionLayout == nullptr) {
|
||||
return KDSizeZero;
|
||||
}
|
||||
return m_expressionLayout->size();
|
||||
}
|
||||
|
||||
void ExpressionView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(rect, m_backgroundColor);
|
||||
if (m_expressionLayout != nullptr) {
|
||||
//Position the origin of expression
|
||||
KDSize expressionSize = m_expressionLayout->size();
|
||||
KDPoint origin(0, 0.5f*(m_frame.height() - expressionSize.height()));
|
||||
m_expressionLayout->draw(ctx, origin, m_textColor, m_backgroundColor);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user