diff --git a/apps/statistics/Makefile b/apps/statistics/Makefile index 6ae268ba0..051026456 100644 --- a/apps/statistics/Makefile +++ b/apps/statistics/Makefile @@ -5,6 +5,7 @@ app_objs += $(addprefix apps/statistics/,\ data.o\ data_controller.o\ histogram_controller.o\ + histogram_parameter_controller.o\ histogram_view.o\ ) diff --git a/apps/statistics/histogram_parameter_controller.cpp b/apps/statistics/histogram_parameter_controller.cpp new file mode 100644 index 000000000..3610120d6 --- /dev/null +++ b/apps/statistics/histogram_parameter_controller.cpp @@ -0,0 +1,57 @@ +#include "histogram_parameter_controller.h" +#include "app.h" +#include + +namespace Statistics { + +HistogramParameterController::HistogramParameterController(Responder * parentResponder, Data * data) : + FloatParameterController(parentResponder), + m_binWidthCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Largeur des rectanges : ")), + m_minValueCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Debut de la serie : ")), + m_data(data) +{ +} + +ExpressionTextFieldDelegate * HistogramParameterController::textFieldDelegate() { + ExpressionTextFieldDelegate * myApp = (ExpressionTextFieldDelegate *)app(); + return myApp; +} + +const char * HistogramParameterController::title() const { + return "Histogramme"; +} + +float HistogramParameterController::parameterAtIndex(int index) { + assert(index >= 0 && index < 2); + if (index == 0) { + return m_data->binWidth(); + } + return m_data->minValue(); +} + +void HistogramParameterController::setParameterAtIndex(int parameterIndex, float f) { + assert(parameterIndex >= 0 && parameterIndex < 2); + if (parameterIndex == 0) { + m_data->setBinWidth(f); + } else { + m_data->setMinValue(f); + } +} + +int HistogramParameterController::numberOfRows() { + return 2; +}; + +TableViewCell * HistogramParameterController::reusableCell(int index) { + assert(index >= 0 && index < 2); + if (index == 0) { + return &m_binWidthCell; + } + return &m_minValueCell; +} + +int HistogramParameterController::reusableCellCount() { + return 2; +} + +} diff --git a/apps/statistics/histogram_parameter_controller.h b/apps/statistics/histogram_parameter_controller.h new file mode 100644 index 000000000..785a37bd4 --- /dev/null +++ b/apps/statistics/histogram_parameter_controller.h @@ -0,0 +1,30 @@ +#ifndef STATISTICS_HISTOGRAM_PARAMETER_CONTROLLER_H +#define STATISTICS_HISTOGRAM_PARAMETER_CONTROLLER_H + +#include +#include "../float_parameter_controller.h" +#include "data.h" + +namespace Statistics { + +class HistogramParameterController : public FloatParameterController { +public: + HistogramParameterController(Responder * parentResponder, Data * data); + ExpressionTextFieldDelegate * textFieldDelegate() override; + const char * title() const override; + int numberOfRows() override; + TableViewCell * reusableCell(int index) override; + int reusableCellCount() override; + void setFunction(Function * function); +private: + float parameterAtIndex(int index) override; + void setParameterAtIndex(int parameterIndex, float f) override; + char m_draftTextBuffer[EditableTextMenuListCell::k_bufferLength]; + EditableTextMenuListCell m_binWidthCell; + EditableTextMenuListCell m_minValueCell; + Data * m_data; +}; + +} + +#endif