Numworks Epsilon  1.4.1
Graphing Calculator Operating System
term_sum_controller.cpp
Go to the documentation of this file.
1 #include "term_sum_controller.h"
2 #include "../../shared/text_field_delegate.h"
3 #include "../../../poincare/src/layout/baseline_relative_layout.h"
4 #include "../../../poincare/src/layout/string_layout.h"
5 #include "../app.h"
6 
7 #include <assert.h>
8 #include <cmath>
9 #include <stdlib.h>
10 
11 using namespace Shared;
12 using namespace Poincare;
13 
14 namespace Sequence {
15 
16 TermSumController::TermSumController(Responder * parentResponder, GraphView * graphView, CurveViewRange * graphRange, CurveViewCursor * cursor) :
17  SumGraphController(parentResponder, graphView, graphRange, cursor, Ion::Charset::CapitalSigma)
18 {
19 }
20 
21 const char * TermSumController::title() {
22  return I18n::translate(I18n::Message::TermSum);
23 }
24 
25 bool TermSumController::moveCursorHorizontallyToPosition(double position) {
26  if (position < 0.0) {
27  return false;
28  }
29  return SumGraphController::moveCursorHorizontallyToPosition(std::round(position));
30 }
31 
32 I18n::Message TermSumController::legendMessageAtStep(Step step) {
33  switch(step) {
35  return I18n::Message::SelectFirstTerm;
37  return I18n::Message::SelectLastTerm;
38  default:
39  return I18n::Message::Default;
40  }
41 }
42 
43 double TermSumController::cursorNextStep(double x, int direction) {
44  double delta = direction > 0 ? 1.0 : -1.0;
45  return std::round(m_cursor->x()+delta);
46 }
47 
48 ExpressionLayout * TermSumController::createFunctionLayout(const char * functionName) {
49  return new BaselineRelativeLayout(new StringLayout(functionName, 1, KDText::FontSize::Small), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
50 }
51 
52 }
Charset
Definition: charset.h:6
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition: i18n.cpp:5
#define round(x)
Definition: math.h:192
Definition: app.cpp:7
Definition: backlight.h:6
const char * title() override