Numworks Epsilon  1.4.1
Graphing Calculator Operating System
list_parameter_controller.cpp
Go to the documentation of this file.
2 #include <assert.h>
3 
4 namespace Shared {
5 
6 ListParameterController::ListParameterController(Responder * parentResponder, FunctionStore * functionStore, I18n::Message functionColorMessage, I18n::Message deleteFunctionMessage, SelectableTableViewDelegate * tableDelegate) :
7  ViewController(parentResponder),
8  m_selectableTableView(this, this, this, tableDelegate),
9  m_functionStore(functionStore),
10  m_function(nullptr),
11 #if FUNCTION_COLOR_CHOICE
12  m_colorCell(functionColorMessage),
13 #endif
14  m_enableCell(I18n::Message::ActivateDesactivate),
15  m_deleteCell(deleteFunctionMessage)
16 {
17 }
18 
20  return I18n::translate(I18n::Message::FunctionOptions);
21 }
22 
24  return &m_selectableTableView;
25 }
26 
29 }
30 
33  if (selectedRow() == -1) {
35  } else {
37  }
39 }
40 
42  if (cell == &m_enableCell) {
43  SwitchView * switchView = (SwitchView *)m_enableCell.accessoryView();
44  switchView->setState(m_function->isActive());
45  }
46 }
47 
49  m_function = function;
51 }
52 
54  if (event == Ion::Events::OK || event == Ion::Events::EXE) {
55  return handleEnterOnRow(selectedRow());
56  }
57  return false;
58 }
59 
61  return k_totalNumberOfCell;
62 };
63 
65  assert(index >= 0);
66  assert(index < k_totalNumberOfCell);
67 #if FUNCTION_COLOR_CHOICE
68  HighlightCell * cells[] = {&m_colorCell, &m_enableCell, &m_deleteCell};
69 #else
70  HighlightCell * cells[] = {&m_enableCell, &m_deleteCell};
71 #endif
72  return cells[index];
73 }
74 
76  return k_totalNumberOfCell;
77 }
78 
81 }
82 
84  switch (rowIndex) {
85 #if FUNCTION_COLOR_CHOICE
86  case 0:
87  /* TODO: implement function color choice */
88  return true;
89  case 1:
90 #else
91  case 0:
92 #endif
95  return true;
96 #if FUNCTION_COLOR_CHOICE
97  case 2:
98 #else
99  case 1:
100 #endif
101  {
102  if (m_functionStore->numberOfFunctions() > 1) {
105  stack->pop();
106  return true;
107  } else {
110  f->setContent("");
112  stack->pop();
113  return true;
114  }
115  app()->displayWarning(I18n::Message::NoFunctionToDelete);
116  return true;
117  }
118  }
119  default:
120  return false;
121  }
122 }
123 
124 }
virtual void setContent(const char *c)
Definition: function.cpp:37
Definition: i18n.h:6
#define assert(e)
Definition: assert.h:9
HighlightCell * reusableCell(int index) override
constexpr Event EXE
Definition: events.h:114
int16_t KDCoordinate
Definition: coordinate.h:6
Responder * parentResponder() const
Definition: responder.cpp:12
ListParameterController(Responder *parentResponder, FunctionStore *functionStore, I18n::Message functionColorMessage, I18n::Message deleteFunctionMessage, SelectableTableViewDelegate *tableDelegate=nullptr)
void reloadData(bool setFirstResponder=true)
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition: i18n.cpp:5
void setActive(bool active)
Definition: function.cpp:98
virtual Function * definedFunctionAtIndex(int i)
void displayWarning(I18n::Message warningMessage)
Definition: app.cpp:97
virtual void viewWillAppear()
static constexpr KDCoordinate ParameterCellHeight
Definition: metric.h:15
void willDisplayCellForIndex(HighlightCell *cell, int index) override
void setFirstResponder(Responder *responder)
Definition: app.cpp:62
Definition: view.h:23
App * app()
Definition: responder.cpp:77
constexpr Event OK
Definition: events.h:65
void setState(bool state)
Definition: switch_view.cpp:45
bool handleEvent(Ion::Events::Event event) override
virtual void removeFunction(Function *f)=0
virtual void setFunction(Function *function)