diff --git a/person.cpp b/person.cpp index 562d246..26833a7 100644 --- a/person.cpp +++ b/person.cpp @@ -169,3 +169,17 @@ WINDOW* Person::createPad()const return pad; } + +void Person::draw(U16 drawY, U16 drawX) const +{ + U16 width = name_.size() + 4; /* TODO: get actual lenght */ + WINDOW* pad = newpad(BOX_HEIGHT, width); + + box(pad, BOX_HEIGHT, width); + mvwaddstr(pad, 2, 2, name_.data()); + + pnoutrefresh(pad, 0, 0, + drawY, drawX, + drawY + BOX_HEIGHT-1, drawX + width-1); + delwin(pad); +} diff --git a/person.h b/person.h index 912384e..911cd78 100644 --- a/person.h +++ b/person.h @@ -20,22 +20,33 @@ struct EventTime I8 minute; //0-59 }; +enum { BOX_HEIGHT = 5 }; + class Person { - public: Person() = default; Person(const char* name, EventTime birth, bool sex, EventTime death); + /* Person(Person&&) = default; */ + /* Person& operator=(Person&&) = default; */ + /* Person& operator=(const Person&) = default; */ bool operator==(const Person &other)const; void save(std::ofstream &file)const;// void load(std::ifstream &file); void rename(const char* newName); - void print()const; + + void print() const; + + /* Draw a Person's box on the terminal + drawY,drawX - the coordinates where to draw + returns the width of the box*/ + void draw(U16 drawY, U16 drawX) const; WINDOW* createPad()const; + /* staitc constexpr U8 BOX_HEIGHT = 5; */ friend class Tree; private: diff --git a/tree.cpp b/tree.cpp index 92aa4b3..a3cf868 100644 --- a/tree.cpp +++ b/tree.cpp @@ -7,11 +7,6 @@ using std::cout; -Tree::Tree() - : treeName("Unnamed") - , numPeople(0) -{} - Tree Tree::operator+ (const Tree& other)// { Tree result(treeName + other.treeName); //The tree resulting from the addition @@ -442,18 +437,21 @@ void Tree::removeRelation(const unsigned firstId, const unsigned secondId) void Tree::draw() const { - WINDOW* father = people[0].createPad(); - WINDOW* mother = people[1].createPad(); + /* WINDOW* father = people[0].createPad(); */ + /* WINDOW* mother = people[1].createPad(); */ - U16 fw = getmaxx(father); /* return size, not coords */ - U16 fh = getmaxy(father); - U16 mw = getmaxx(mother); - U16 mh = getmaxy(mother); + /* U16 fw = getmaxx(father); /\* return size, not coords *\/ */ + /* U16 fh = getmaxy(father); */ + /* U16 mw = getmaxx(mother); */ + /* U16 mh = getmaxy(mother); */ - U16 drawX = (COLS - fw - mw) / 2; - pnoutrefresh(father, 0, 0, - 1, drawX, - 1 +fh-1, drawX + fw-1); + /* U16 drawX = (COLS - fw - mw) / 2; */ + /* pnoutrefresh(father, 0, 0, */ + /* 1, drawX, */ + /* 1 +fh-1, drawX + fw-1); */ + + + people[0].draw(0, 0); /* pnoutrefresh(mother, 0, 0, 1, d */ diff --git a/tree.h b/tree.h index 3d1d354..d762bbc 100644 --- a/tree.h +++ b/tree.h @@ -21,14 +21,14 @@ enum Relation : U8 ExHusband }; -const unsigned Nobody = UINT_MAX; //Òîçè íîìåð ùå áúäå çàïàçeí çà ëèïñà íà âðúçêà/÷îâåê +const U32 Nobody = UINT_MAX; //Òîçè íîìåð ùå áúäå çàïàçeí çà ëèïñà íà âðúçêà/÷îâåê class Tree { public: - Tree(); + Tree() = default; template - Tree(Str&& Name) : treeName(std::forward(Name)), numPeople(0) {} + Tree(Str&& Name) : treeName(std::forward(Name)) {} /*Tree(const Tree&); Tree& operator= (const Tree& other);*/ @@ -67,11 +67,13 @@ public: private: void commonAncestorRec(const unsigned &id, const Array &visited)const; - std::string treeName; - unsigned numPeople; + std::string treeName = "Unnamed"; + unsigned numPeople = 0; Array people; //The data for each member Array> relatives; //The relatives of each member Array> relations; //The type of relation each member has with his relatives + U16 offset = 0; + //Search, ect. };