Numworks Epsilon  1.4.1
Graphing Calculator Operating System
expression_view.h
Go to the documentation of this file.
1 #ifndef ESCHER_EXPRESSION_VIEW_H
2 #define ESCHER_EXPRESSION_VIEW_H
3 
4 #include <escher/view.h>
5 #include <kandinsky/color.h>
7 
8 /* This class does not handle the expression layout as the size of the layout is
9  * needed to compute the size of table cells hosting the expression. As the size
10  * of this cell is determined before we set the expression in the expression
11  * view, we cannot use minimalSizeForOptimalDisplay to assess the required
12  * size. */
13 
14 class ExpressionView : public View {
15 public:
16  ExpressionView(float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f,
17  KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite);
20  void drawRect(KDContext * ctx, KDRect rect) const override;
21  void setBackgroundColor(KDColor backgroundColor);
22  void setTextColor(KDColor textColor);
23  void setAlignment(float horizontalAlignment, float verticalAlignment);
24  KDSize minimalSizeForOptimalDisplay() const override;
25 private:
26  /* Warning: we do not need to delete the previous expression layout when
27  * deleting object or setting a new expression layout. Indeed, the expression
28  * layout is always possessed by a controller which only gives a pointer to
29  * the expression view (without cloning it). The named controller is then
30  * responsible for freeing the expression layout when required. */
31  Poincare::ExpressionLayout * m_expressionLayout;
32  float m_horizontalAlignment;
33  float m_verticalAlignment;
34  KDColor m_textColor;
35  KDColor m_backgroundColor;
36 };
37 
38 #endif
void setBackgroundColor(KDColor backgroundColor)
void setExpression(Poincare::ExpressionLayout *expressionLayout)
KDSize minimalSizeForOptimalDisplay() const override
void setAlignment(float horizontalAlignment, float verticalAlignment)
Definition: size.h:6
constexpr KDColor KDColorWhite
Definition: color.h:42
ExpressionView(float horizontalAlignment=0.0f, float verticalAlignment=0.5f, KDColor textColor=KDColorBlack, KDColor backgroundColor=KDColorWhite)
Poincare::ExpressionLayout * expressionLayout() const
constexpr KDColor KDColorBlack
Definition: color.h:41
void setTextColor(KDColor textColor)
Definition: rect.h:26
Definition: color.h:6
void drawRect(KDContext *ctx, KDRect rect) const override
Definition: view.h:23