diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index f15d5a973..12089f392 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -41,6 +41,16 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle m_selectableTableView.setDelegate(this); } +Shared::Hideable * ValuesController::hideableCellFromType(HighlightCell * cell, int type) { + if (type == k_notEditableValueCellType) { + Shared::HideableEvenOddBufferTextCell * myCell = static_cast(cell); + return static_cast(myCell); + } + assert(type == k_editableValueCellType); + Shared::StoreCell * myCell = static_cast(cell); + return static_cast(myCell); +} + void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { // Handle hidden cells int typeAtLoc = typeAtLocation(i,j); @@ -51,38 +61,27 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in const int numberOfElementsInCol = numberOfElementsInColumn(i); if (j > numberOfElementsInCol + 1) { - if (typeAtLoc == k_notEditableValueCellType) { - Shared::HideableEvenOddBufferTextCell * myCell = static_cast(cell); - myCell->setHide(true); - myCell->setText(""); - } else if (typeAtLoc == k_editableValueCellType) { - StoreCell * myCell = static_cast(cell); - myCell->editableTextCell()->textField()->setText(""); - myCell->setHide(true); + if (typeAtLoc == k_notEditableValueCellType || typeAtLoc == k_editableValueCellType) { + Shared::Hideable * hideableCell = hideableCellFromType(cell, typeAtLoc); + hideableCell->setHide(true); + hideableCell->reinit(); } return; } else { - if (typeAtLoc == k_notEditableValueCellType) { - Shared::Hideable * myCell = static_cast(static_cast(cell)); - myCell->setHide(false); - } else if (typeAtLoc == k_editableValueCellType) { - StoreCell * myCell = static_cast(cell); - myCell->setHide(false); + if (typeAtLoc == k_notEditableValueCellType || typeAtLoc == k_editableValueCellType) { + hideableCellFromType(cell, typeAtLoc)->setHide(false); } } if (j == numberOfElementsInCol+1) { static_cast(cell)->setEven(j%2 == 0); - if (typeAtLoc == k_notEditableValueCellType) { - Shared::HideableEvenOddBufferTextCell * myCell = static_cast(cell); - myCell->setText(""); - } else if (typeAtLoc == k_editableValueCellType) { - StoreCell * myCell = static_cast(cell); - myCell->editableTextCell()->textField()->setText(""); + if (typeAtLoc == k_notEditableValueCellType || typeAtLoc == k_editableValueCellType) { + hideableCellFromType(cell, typeAtLoc)->reinit(); } return; } Shared::ValuesController::willDisplayCellAtLocation(cell, i, j); + if (typeAtLoc == k_abscissaTitleCellType) { AbscissaTitleCell * myTitleCell = (AbscissaTitleCell *)cell; myTitleCell->setMessage(valuesParameterMessageAtColumn(i)); diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index a51f0d554..4bdf23357 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -48,6 +48,7 @@ private: int maxNumberOfCells() override; int maxNumberOfFunctions() override; double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) override; + Shared::Hideable * hideableCellFromType(HighlightCell * cell, int type); ContinuousFunctionStore * functionStore() const override { return static_cast(Shared::ValuesController::functionStore()); } Shared::BufferFunctionTitleCell * functionTitleCells(int j) override; EvenOddBufferTextCell * floatCells(int j) override; diff --git a/apps/shared/hideable.h b/apps/shared/hideable.h index bf71cc740..94ff3b998 100644 --- a/apps/shared/hideable.h +++ b/apps/shared/hideable.h @@ -13,6 +13,7 @@ public: static KDColor hideColor() { return Palette::WallScreenDark; } bool hidden() const { return m_hide; } virtual void setHide(bool hide) { m_hide = hide; } + virtual void reinit() {} private: bool m_hide; }; diff --git a/apps/shared/hideable_even_odd_buffer_text_cell.h b/apps/shared/hideable_even_odd_buffer_text_cell.h index 4585c6538..9ea96fe69 100644 --- a/apps/shared/hideable_even_odd_buffer_text_cell.h +++ b/apps/shared/hideable_even_odd_buffer_text_cell.h @@ -15,6 +15,7 @@ public: {} KDColor backgroundColor() const override; void setHide(bool hide) override; + void reinit() override { setText(""); } }; } diff --git a/apps/shared/hideable_even_odd_editable_text_cell.h b/apps/shared/hideable_even_odd_editable_text_cell.h index 3509e5620..e3e686a89 100644 --- a/apps/shared/hideable_even_odd_editable_text_cell.h +++ b/apps/shared/hideable_even_odd_editable_text_cell.h @@ -15,6 +15,7 @@ public: {} KDColor backgroundColor() const override; void setHide(bool hide) override; + void reinit() override { editableTextCell()->textField()->setText(""); } }; }