tree.cpp (1130B)
1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us> 2 // See LICENSE for license details. 3 4 #include "tree.h" 5 6 #include "frame.h" 7 8 Tree::Tree(Tree *parent, Rectangle *rect) 9 : Rectangle(*rect) 10 { 11 parent_ = parent; 12 frame_ = 0; 13 first_ = last_ = 0; 14 visits_ = 0; 15 } 16 17 Tree::~Tree() { 18 } 19 20 Tree *Tree::parent() const { 21 return parent_; 22 } 23 24 void Tree::setParent(Tree *tree) { 25 parent_ = tree; 26 } 27 28 void Tree::setFrame(Frame *frame) { 29 frame_ = frame; 30 if (frame_) { 31 frame_->setTree(this); 32 frame_->copy(this); 33 } 34 } 35 36 Frame *Tree::frame() const { 37 return frame_; 38 } 39 40 Tree *Tree::first() const { 41 return first_; 42 } 43 44 Tree *Tree::last() const { 45 return last_; 46 } 47 48 void Tree::setChilds(Tree *first, Tree *last) { 49 first_ = first; 50 last_ = last; 51 if (first_ && last_) { 52 first_->setParent(this); 53 last_->setParent(this); 54 } 55 } 56 57 void Tree::setHoriz(bool horiz) { 58 isHoriz_ = horiz; 59 } 60 61 bool Tree::isHoriz() const { 62 return isHoriz_; 63 } 64 65 unsigned int Tree::visits() const { 66 return visits_; 67 } 68 69 void Tree::setVisit(unsigned int visit) { 70 visits_ = visit; 71 }