Numworks Epsilon  1.4.1
Graphing Calculator Operating System
sum_graph_controller.h
Go to the documentation of this file.
1 #ifndef SHARED_SUM_GRAPH_CONTROLLER_H
2 #define SHARED_SUM_GRAPH_CONTROLLER_H
3 
4 #include <escher.h>
5 #include "function_graph_view.h"
7 #include "vertical_cursor_view.h"
8 #include "curve_view_cursor.h"
10 #include "function.h"
11 #include "text_field_delegate.h"
12 
13 namespace Shared {
14 
16 public:
18  void viewWillAppear() override;
19  void didEnterResponderChain(Responder * previousFirstResponder) override;
20  bool handleEvent(Ion::Events::Event event) override;
21  void setFunction(Function * function);
22  bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
23  bool textFieldDidAbortEditing(TextField * textField, const char * text) override;
24  bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) override;
25 protected:
26  virtual bool moveCursorHorizontallyToPosition(double position);
27  enum class Step {
28  FirstParameter = 0,
29  SecondParameter = 1,
30  Result = 2
31  };
33  double m_startSum;
34  double m_endSum;
37 private:
38  constexpr static float k_cursorTopMarginRatio = 0.06f; // (cursorHeight/2)/graphViewHeight
39  constexpr static float k_cursorBottomMarginRatio = 0.28f; // (cursorHeight/2+bannerHeigh)/graphViewHeight
40  virtual I18n::Message legendMessageAtStep(Step step) = 0;
41  virtual double cursorNextStep(double position, int direction) = 0;
42  virtual Poincare::ExpressionLayout * createFunctionLayout(const char * functionName) = 0;
43  Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override { return m_graphRange; }
44  Shared::CurveView * curveView() override { return m_graphView; }
45  TextFieldDelegateApp * textFieldDelegateApp() override {
46  return static_cast<TextFieldDelegateApp *>(app());
47  }
48  bool handleEnter() override;
49  class LegendView : public View {
50  public:
51  LegendView(SumGraphController * controller, char sumSymbol);
52  ~LegendView();
53  LegendView(const LegendView& other) = delete;
54  LegendView(LegendView&& other) = delete;
55  LegendView& operator=(const LegendView& other) = delete;
56  LegendView& operator=(LegendView&& other) = delete;
57  TextField * textField() { return &m_editableZone; }
58  KDSize minimalSizeForOptimalDisplay() const override;
59  void drawRect(KDContext * ctx, KDRect rect) const override;
60  void setLegendMessage(I18n::Message message, Step step);
61  void setEditableZone(double d);
62  void setSumSymbol(Step step, double start = NAN, double end = NAN, double result = NAN, Poincare::ExpressionLayout * sequenceName = nullptr);
63  private:
64  constexpr static KDCoordinate k_legendHeight = 35;
65  constexpr static KDCoordinate k_editableZoneWidth = 12*KDText::charSize(KDText::FontSize::Small).width();
66  constexpr static KDCoordinate k_editableZoneHeight = KDText::charSize(KDText::FontSize::Small).height();
67  constexpr static KDCoordinate k_symbolHeightMargin = 8;
68  constexpr static KDCoordinate k_sigmaHeight = 18;
69  int numberOfSubviews() const override;
70  View * subviewAtIndex(int index) override;
71  void layoutSubviews() override;
72  void layoutSubviews(Step step);
73  ExpressionView m_sum;
74  Poincare::ExpressionLayout * m_sumLayout;
75  MessageTextView m_legend;
76  TextField m_editableZone;
77  char m_draftText[TextField::maxBufferSize()];
78  char m_sumSymbol;
79  };
80  FunctionGraphView * m_graphView;
81  LegendView m_legendView;
82  VerticalCursorView m_cursorView;
83 };
84 
85 }
86 
87 #endif
View & operator=(const View &other)=delete
bool textFieldDidFinishEditing(TextField *textField, const char *text, Ion::Events::Event event) override
#define NAN
Definition: math.h:30
static constexpr int maxBufferSize()
Definition: text_field.h:23
int16_t KDCoordinate
Definition: coordinate.h:6
constexpr KDCoordinate width() const
Definition: size.h:10
Responder * parentResponder() const
Definition: responder.cpp:12
Definition: size.h:6
bool textFieldDidAbortEditing(TextField *textField, const char *text) override
void didEnterResponderChain(Responder *previousFirstResponder) override
InteractiveCurveViewRange * m_graphRange
bool textFieldDidReceiveEvent(TextField *textField, Ion::Events::Event event) override
void start()
Definition: rt0.cpp:31
Definition: rect.h:26
Definition: view.h:23
void setFunction(Function *function)
static constexpr KDSize charSize(FontSize size=FontSize::Large)
Definition: text.h:16
App * app()
Definition: responder.cpp:77
bool handleEvent(Ion::Events::Event event) override
virtual bool moveCursorHorizontallyToPosition(double position)
SumGraphController(Responder *parentResponder, FunctionGraphView *curveView, InteractiveCurveViewRange *range, CurveViewCursor *cursor, char sumSymbol)
constexpr KDCoordinate height() const
Definition: size.h:11