diff --git a/cursor.h b/cursor.h deleted file mode 100644 index d6ab875d5..000000000 --- a/cursor.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CURSOR_H -#define CURSOR_H - -#include "tree_node.h" -#include "tree_reference.h" - -class Cursor { - template - friend class TreeReference; -public: - TreeReference treeReference() { return m_treeReference; } - int treeReferenceIdentifier() { return m_treeReference.identifier(); } - void setTreeReference(TreeReference t) { - m_treeReference = t; - } - void setTreeNode(TreeNode * t) { - m_treeReference = TreeReference(t); - } - bool isDefined() const { return m_treeReference.isDefined(); } -protected: - Cursor(TreeNode * node) : m_treeReference(node) {} - TreeReference m_treeReference; -}; - -#endif diff --git a/layout_cursor.h b/layout_cursor.h index 549f5e63e..e654bd9b9 100644 --- a/layout_cursor.h +++ b/layout_cursor.h @@ -1,12 +1,11 @@ #ifndef LAYOUT_CURSOR_H #define LAYOUT_CURSOR_H -#include "cursor.h" #include "layout_reference.h" #include "layout_node.h" #include -class LayoutCursor : public Cursor { +class LayoutCursor { template friend class LayoutReference; public: @@ -17,7 +16,7 @@ public: /* Debug */ void log() { - printf("Pointed Layout id %d, cursor position ", m_treeReference.identifier()); + printf("Pointed Layout id %d, cursor position ", m_layoutRef.identifier()); if (m_position == Position::Left) { printf("Left"); } else { @@ -26,12 +25,14 @@ public: printf("\n"); } + bool isDefined() const { return m_layoutRef.isDefined(); } + + /* Getters and setters */ - LayoutReference layoutReference() { - return LayoutReference(m_treeReference.node()); - } - //int pointedLayoutIdentifier() const { return m_layoutIdentifier; } - //void setPointedLayoutIdentifier(int layoutID) { m_layoutIdentifier = layoutID; } + LayoutRef layoutReference() { return m_layoutRef; } + int layoutReferenceIdentifier() { return m_layoutRef.identifier(); } + void setLayoutReference(LayoutRef r) { m_layoutRef = r; } + void setLayoutNode(LayoutNode * n) { m_layoutRef = LayoutRef(n); } Position position() const { return m_position; } void setPosition(Position position) { m_position = position; } int cursorHeight() { return 1; } //TODO @@ -49,11 +50,12 @@ public: void moveAbove(bool * shouldRecomputeLayout); void moveUnder(bool * shouldRecomputeLayout); private: - LayoutCursor(TreeNode * node, Position position = Position::Right) : - Cursor(node), + LayoutCursor(LayoutNode * node, Position position = Position::Right) : + m_layoutRef(node), m_position(position) { } + LayoutRef m_layoutRef; Position m_position; }; diff --git a/layout_cursor_reference.h b/layout_cursor_reference.h deleted file mode 100644 index 42b4dec5e..000000000 --- a/layout_cursor_reference.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LAYOUT_CURSOR_REFERENCE_H -#define LAYOUT_CURSOR_REFERENCE_H - -#include "layout_node.h" -#include "layout_reference.h" - -class LayoutCursor; - -template -class LayoutCursorReference : public LayoutReference { -public: - LayoutCursorReference(LayoutReference * r) : - LayoutReference(r->node()) - { - } - - LayoutCursorReference(const LayoutCursorReference & r) : - LayoutReference(r.node()) - { - } - - // Tree navigation - - /* We cannot have LayoutCursor cursorLeftOf(LayoutCursor cursor) because of - * circular header dependency */ - virtual void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { return this->node()->moveCursorLeft(cursor, shouldRecomputeLayout); } - virtual void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { return this->node()->moveCursorRight(cursor, shouldRecomputeLayout); } - virtual void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) {} - virtual void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) {} -}; - -typedef LayoutCursorReference LayoutPointer; - -#endif diff --git a/test.cpp b/test.cpp index d2d9d31f8..1eef0d97c 100644 --- a/test.cpp +++ b/test.cpp @@ -2,7 +2,7 @@ #include "char_layout_node.h" #include "horizontal_layout_node.h" #include "addition_node.h" -#include "cursor.h" +#include "layout_cursor.h" #include AdditionRef buildAddition() { diff --git a/tree_reference.cpp b/tree_reference.cpp deleted file mode 100644 index d497a941d..000000000 --- a/tree_reference.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "tree_reference.h" -#include "char_layout_node.h" -#include "cursor.h" - -template -Cursor TreeReference::treeCursor() { - return Cursor(node()); -} - -template Cursor TreeReference::treeCursor(); -template Cursor TreeReference::treeCursor(); diff --git a/tree_reference.h b/tree_reference.h index e3d035f70..ebfaa7df7 100644 --- a/tree_reference.h +++ b/tree_reference.h @@ -58,8 +58,6 @@ public: int identifier() const { return m_identifier; } - Cursor treeCursor(); - // Hierarchy int numberOfChildren() const { return node()->numberOfChildren();