Change the layout creation.

The father now sets itself as teh father of its children.
ExpressionLayout do not know anything about expressions now.

Change-Id: I28954c78f3102eec056ebbc3c52ccd862a5ab8fd
This commit is contained in:
Felix Raimundo
2016-03-25 12:10:33 +01:00
parent 2744d942e1
commit 3710103f40
35 changed files with 108 additions and 165 deletions

View File

@@ -2,7 +2,8 @@ extern "C" {
#include <stdlib.h>
}
#include <poincare/function.h>
#include "layout/function_layout.h"
#include "layout/horizontal_layout.h"
#include "layout/string_layout.h"
Function::Function(Expression * arg, char* function_name, bool clone_operands) {
m_arg = (Expression *)malloc(sizeof(Expression));
@@ -18,8 +19,15 @@ Function::~Function() {
delete m_arg;
}
ExpressionLayout * Function::createLayout(ExpressionLayout * parent) {
return new FunctionLayout(parent, m_function_name, m_arg);
ExpressionLayout * Function::createLayout() {
ExpressionLayout** children_layouts = (ExpressionLayout **)malloc(4*sizeof(ExpressionLayout *));
children_layouts[0] = new StringLayout(m_function_name, strlen(m_function_name));
char string[2] = {'-', '\0'};
children_layouts[1] = new StringLayout(string, 1);
children_layouts[2] = m_arg->createLayout();
string[0] = ')';
children_layouts[3] = new StringLayout(string, 1);
return new HorizontalLayout(children_layouts, 4);
}
Expression * Function::operand(int i) {