10 #include "images/binomial_icon.h" 11 #include "images/exponential_icon.h" 12 #include "images/normal_icon.h" 13 #include "images/poisson_icon.h" 14 #include "images/uniform_icon.h" 15 #include "images/focused_binomial_icon.h" 16 #include "images/focused_exponential_icon.h" 17 #include "images/focused_normal_icon.h" 18 #include "images/focused_poisson_icon.h" 19 #include "images/focused_uniform_icon.h" 25 m_selectableTableView(selectableTableView)
29 int LawController::ContentView::numberOfSubviews()
const {
33 View * LawController::ContentView::subviewAtIndex(
int index) {
34 assert(index >= 0 && index < 2);
38 return m_selectableTableView;
41 void LawController::ContentView::layoutSubviews() {
43 m_titleView.setFrame(
KDRect(0, 0, bounds().width(), titleHeight));
44 m_selectableTableView->setFrame(
KDRect(0, titleHeight, bounds().width(), bounds().height()-titleHeight));
47 static I18n::Message sMessages[] = {
48 I18n::Message::Binomial,
49 I18n::Message::Uniforme,
51 I18n::Message::Normal,
52 I18n::Message::Poisson
57 m_selectableTableView(this),
58 m_contentView(&m_selectableTableView),
60 m_parametersController(parametersController)
63 m_messages = sMessages;
68 return &m_contentView;
72 selectRow((
int)m_law->type());
78 if (selectedRow() == -1) {
79 selectCellAtLocation(0, 0);
81 selectCellAtLocation(selectedColumn(), selectedRow());
83 app()->setFirstResponder(&m_selectableTableView);
89 setLawAccordingToIndex(selectedRow());
97 return k_totalNumberOfModels;
102 assert(index < k_totalNumberOfModels);
103 return &m_cells[index];
107 return k_totalNumberOfModels;
112 myCell->
setLabel(m_messages[index]);
113 const Image * images[5] = {ImageStore::BinomialIcon, ImageStore::UniformIcon, ImageStore::ExponentialIcon,
114 ImageStore::NormalIcon, ImageStore::PoissonIcon};
115 const Image * focusedImages[5] = {ImageStore::FocusedBinomialIcon, ImageStore::FocusedUniformIcon, ImageStore::FocusedExponentialIcon,
116 ImageStore::FocusedNormalIcon, ImageStore::FocusedPoissonIcon};
117 myCell->
setImage(images[index], focusedImages[index]);
125 void Probability::LawController::setLawAccordingToIndex(
int index) {
126 if ((
int)m_law->type() == index) {
132 new(m_law) BinomialLaw();
135 new(m_law) UniformLaw();
138 new(m_law) ExponentialLaw();
141 new(m_law) NormalLaw();
144 new(m_law) PoissonLaw();
149 m_parametersController->reinitCalculation();
KDCoordinate cellHeight() override
static constexpr KDColor PurpleBright
LawController(Responder *parentResponder, Law *m_law, ParametersController *parametersController)
void push(ViewController *vc, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
void didBecomeFirstResponder() override
bool handleEvent(Ion::Events::Event event) override
int numberOfRows() override
void reloadCell() override
constexpr KDColor KDColorWhite
int reusableCellCount() override
void setImage(const Image *image, const Image *focusedImage)
void setLabel(I18n::Message message)
void willDisplayCellForIndex(HighlightCell *cell, int index) override
static constexpr KDCoordinate ParameterCellHeight
HighlightCell * reusableCell(int index) override
void viewWillAppear() override
static constexpr KDCoordinate CommonTopMargin
static constexpr KDSize charSize(FontSize size=FontSize::Large)
void setActivePage(Page activePage)
constexpr KDCoordinate height() const