diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index 2fadfdd00..0a037f950 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -31,13 +31,13 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { Shared::ValuesController::willDisplayCellAtLocation(cell, i, j); // The cell is the abscissa title cell: - if (typeAtLocation(i,j) == 0) { + if (typeAtLocation(i,j) == k_abscissaTitleCellType) { EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell; mytitleCell->setMessage(I18n::Message::X); return; } // The cell is a function title cell: - if (typeAtLocation(i,j) == 1) { + if (typeAtLocation(i,j) == k_functionTitleCellType) { Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell; const size_t bufferNameSize = Shared::Function::k_maxNameWithArgumentSize + 1; char bufferName[bufferNameSize]; @@ -75,7 +75,7 @@ Ion::Storage::Record ValuesController::recordAtColumn(int i) { } Ion::Storage::Record ValuesController::recordAtColumn(int i, bool * isDerivative) { - assert(typeAtLocation(i, 0) == 1); + assert(typeAtLocation(i, 0) == k_functionTitleCellType); int plotTypeIndex = 0; while (plotTypeIndex < 3 && i >= m_numberOfColumnsForType[plotTypeIndex]) { i -= m_numberOfColumnsForType[plotTypeIndex++]; diff --git a/apps/sequence/values/values_controller.cpp b/apps/sequence/values/values_controller.cpp index 833913c59..7ec00a2e5 100644 --- a/apps/sequence/values/values_controller.cpp +++ b/apps/sequence/values/values_controller.cpp @@ -28,14 +28,12 @@ ValuesController::ValuesController(Responder * parentResponder,InputEventHandler void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { Shared::ValuesController::willDisplayCellAtLocation(cell, i, j); - // The cell is the abscissa title cell: - if (typeAtLocation(i,j) == 0) { + if (typeAtLocation(i,j) == k_abscissaTitleCellType) { EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell; mytitleCell->setMessage(I18n::Message::N); return; } - // The cell is a function title cell: - if (typeAtLocation(i,j) == 1) { + if (typeAtLocation(i,j) == k_functionTitleCellType) { SequenceTitleCell * myCell = (SequenceTitleCell *)cell; Sequence * sequence = functionStore()->modelForRecord(recordAtColumn(i)); myCell->setLayout(sequence->nameLayout()); diff --git a/apps/shared/values_controller.cpp b/apps/shared/values_controller.cpp index c1f2f842d..941bf1ea4 100644 --- a/apps/shared/values_controller.cpp +++ b/apps/shared/values_controller.cpp @@ -77,7 +77,7 @@ bool ValuesController::handleEvent(Ion::Events::Event event) { } if ((event == Ion::Events::OK || event == Ion::Events::EXE) && selectedRow() == 0) { ViewController * parameterController = nullptr; - if (typeAtLocation(selectedColumn(), 0) == 0) { + if (typeAtLocation(selectedColumn(), 0) == k_abscissaTitleCellType) { m_abscissaParameterController.setPageTitle(valuesParameterControllerPageTitle()); parameterController = &m_abscissaParameterController; } else { @@ -119,7 +119,7 @@ int ValuesController::numberOfButtons(ButtonRowController::Position) const { void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { willDisplayCellAtLocationWithDisplayMode(cell, i, j, Preferences::sharedPreferences()->displayMode()); // The cell is not a title cell and not editable - if (typeAtLocation(i,j) == 3) { + if (typeAtLocation(i,j) == k_notEditableValueCellType) { constexpr int precision = Preferences::LargeNumberOfSignificantDigits; char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(precision)]; // Special case: last row @@ -216,7 +216,7 @@ void ValuesController::viewDidDisappear() { } Ion::Storage::Record ValuesController::recordAtColumn(int i) { - assert(typeAtLocation(i, 0) == 1); + assert(typeAtLocation(i, 0) == k_functionTitleCellType); return functionStore()->activeRecordAtIndex(i-1); } @@ -229,7 +229,7 @@ StackViewController * ValuesController::stackController() const { } bool ValuesController::cellAtLocationIsEditable(int columnIndex, int rowIndex) { - return typeAtLocation(columnIndex, rowIndex) == 2; + return typeAtLocation(columnIndex, rowIndex) == k_editableValueCellType; } bool ValuesController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) { diff --git a/apps/shared/values_controller.h b/apps/shared/values_controller.h index 36c97f899..f36f6201c 100644 --- a/apps/shared/values_controller.h +++ b/apps/shared/values_controller.h @@ -40,7 +40,13 @@ public: static constexpr KDCoordinate k_rightMargin = 15; static constexpr KDCoordinate k_abscissaCellWidth = 100; static constexpr KDCoordinate k_ordinateCellWidth = 100; + protected: + static constexpr int k_abscissaTitleCellType = 0; + static constexpr int k_functionTitleCellType = 1; + static constexpr int k_editableValueCellType = 2; + static constexpr int k_notEditableValueCellType = 3; + static constexpr const KDFont * k_font = KDFont::SmallFont; StackViewController * stackController() const; bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override;