2 #include "../constant.h" 10 m_numberOfParameters(1),
11 m_titleView(
KDText::FontSize::Small,
I18n::Message::ChooseParameters, 0.5f, 0.5f,
Palette::GreyDark,
Palette::WallScreen),
14 m_selectableTableView(selectableTableView)
18 void ParametersController::ContentView::drawRect(
KDContext * ctx,
KDRect rect)
const {
23 MessageTextView * ParametersController::ContentView::parameterDefinitionAtIndex(
int index) {
24 assert(index >= 0 && index < 2);
26 return &m_firstParameterDefinition;
28 return &m_secondParameterDefinition;
31 void ParametersController::ContentView::setNumberOfParameters(
int numberOfParameters) {
32 m_numberOfParameters = numberOfParameters;
35 int ParametersController::ContentView::numberOfSubviews()
const {
36 return m_numberOfParameters+2;
39 View * ParametersController::ContentView::subviewAtIndex(
int index) {
40 assert(index >= 0 && index < 5);
45 return m_selectableTableView;
48 return &m_firstParameterDefinition;
50 return &m_secondParameterDefinition;
53 void ParametersController::ContentView::layoutSubviews() {
55 m_titleView.setFrame(
KDRect(0, 0, bounds().width(), titleHeight));
57 m_selectableTableView->setFrame(
KDRect(0, titleHeight, bounds().width(), tableHeight));
59 KDCoordinate defOrigin = (titleHeight+tableHeight)/2+(bounds().height()-textHeight)/2;
60 m_secondParameterDefinition.setFrame(
KDRectZero);
61 if (m_numberOfParameters == 2) {
62 defOrigin = (titleHeight+tableHeight)/2+(bounds().height()-2*textHeight-k_textMargin)/2;
63 m_secondParameterDefinition.setFrame(
KDRect(0, defOrigin+textHeight+k_textMargin, bounds().width(), textHeight));
65 m_firstParameterDefinition.setFrame(
KDRect(0, defOrigin, bounds().width(), textHeight));
71 FloatParameterController(parentResponder),
72 m_selectableTableView(nullptr),
75 m_calculationController(calculationController)
98 FloatParameterController::didBecomeFirstResponder();
102 FloatParameterController::viewWillAppear();
106 contentView()->layoutSubviews();
122 FloatParameterController::willDisplayCellForIndex(cell, index);
125 HighlightCell * ParametersController::reusableParameterCell(
int index,
int type) {
128 return m_menuListCell[index];
131 int ParametersController::reusableParameterCellCount(
int type) {
135 double ParametersController::parameterAtIndex(
int index) {
139 bool ParametersController::setParameterAtIndex(
int parameterIndex,
double f) {
150 if (FloatParameterController::textFieldDidFinishEditing(textField, text, event)) {
157 void ParametersController::buttonAction() {
162 I18n::Message ParametersController::okButtonText() {
163 return I18n::Message::Next;
166 View * ParametersController::loadView() {
168 for (
int i = 0; i < k_maxNumberOfCells; i++) {
171 ContentView * contentView = (ContentView *)
new ContentView(
this, m_selectableTableView);
176 void ParametersController::unloadView(
View * view) {
177 delete m_selectableTableView;
178 m_selectableTableView =
nullptr;
179 for (
int i = 0; i < k_maxNumberOfCells; i++) {
180 delete m_menuListCell[i];
181 m_menuListCell[i] =
nullptr;
183 FloatParameterController::unloadView(
view);
187 return m_selectableTableView;
190 ParametersController::ContentView * ParametersController::contentView() {
191 return (ContentView *)
view();
bool handleEvent(Ion::Events::Event event) override
virtual I18n::Message parameterNameAtIndex(int index)=0
virtual I18n::Message title()=0
void push(ViewController *vc, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
virtual void setParameterAtIndex(float f, int index)=0
virtual int numberOfParameter()=0
virtual float parameterValueAtIndex(int index)=0
void setCalculationAccordingToIndex(int index, bool forceReinitialisation=false)
void reloadData(bool setFirstResponder=true)
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
StackViewController * stackController()
constexpr KDColor KDColorWhite
static constexpr KDColor SubTab
void displayWarning(I18n::Message warningMessage)
void willDisplayCellForIndex(HighlightCell *cell, int index) override
int numberOfRows() override
ParametersController(Responder *parentResponder, Law *m_law, CalculationController *calculationController)
static constexpr KDCoordinate CommonBottomMargin
constexpr KDColor KDColorBlack
void didBecomeFirstResponder() override
virtual I18n::Message parameterDefinitionAtIndex(int index)=0
static constexpr KDColor WallScreen
const char * title() override
constexpr KDRect KDRectZero
void fillRect(KDRect rect, KDColor color)
void setMessage(I18n::Message message)
static constexpr KDCoordinate CommonTopMargin
static constexpr KDSize charSize(FontSize size=FontSize::Large)
void viewWillAppear() override
void setActivePage(Page activePage)
virtual void setHighlighted(bool highlight)
virtual bool authorizedValueAtIndex(float x, int index) const =0
constexpr KDCoordinate height() const