Files
Upsilon/apps/regression/store_controller.cpp
Émilie Feral 7406e0d775 [apps][escher] Do not forget to delete dynamic objects when reassigning
then or destructing them

Change-Id: If2b4de460163bf187152389e419d87329b83fc39
2017-03-07 15:03:11 +01:00

46 lines
1.6 KiB
C++

#include "store_controller.h"
#include "app.h"
#include "../apps_container.h"
#include "../constant.h"
#include "../../poincare/src/layout/baseline_relative_layout.h"
#include "../../poincare/src/layout/string_layout.h"
#include <assert.h>
using namespace Poincare;
using namespace Shared;
namespace Regression {
StoreController::StoreController(Responder * parentResponder, Store * store, ButtonRowController * header) :
Shared::StoreController(parentResponder, store, header),
m_titleCells{EvenOddExpressionCell(0.5f, 0.5f), EvenOddExpressionCell(0.5f, 0.5f)}
{
m_titleLayout[0] = new BaselineRelativeLayout(new StringLayout("X", 1, KDText::FontSize::Small), new StringLayout("i", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
m_titleLayout[1] = new BaselineRelativeLayout(new StringLayout("Y", 1, KDText::FontSize::Small), new StringLayout("i", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
}
StoreController::~StoreController() {
for (int i = 0; i < 2; i++) {
if (m_titleLayout[i]) {
delete m_titleLayout[i];
m_titleLayout[i] = nullptr;
}
}
}
void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
::StoreController::willDisplayCellAtLocation(cell, i, j);
if (cellAtLocationIsEditable(i, j)) {
return;
}
EvenOddExpressionCell * mytitleCell = (EvenOddExpressionCell *)cell;
mytitleCell->setExpression(m_titleLayout[i]);
}
HighlightCell * StoreController::titleCells(int index) {
assert(index >= 0 && index < k_numberOfTitleCells);
return &m_titleCells[index];
}
}