diff --git a/main.cpp b/main.cpp index 258d7e3..f58c65e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,3 @@ - #include #include #include "tree.h" @@ -8,11 +7,18 @@ using std::cin; using std::cout; int main() { - setlocale(LC_ALL, ""); + setlocale(LC_ALL, ""); /* TODO: set to utf */ + /* Init ncurses */ initscr(); /* Start curses mode */ noecho(); cbreak(); /* get input instantly */ + start_color(); + use_default_colors(); + /* init_pair(5, COLOR_BLACK, COLOR_BLACK); */ + /* bkgd(COLOR_PAIR(5)); */ + init_pair(COLOR_MALE, COLOR_BLUE, -1); /* -1 means use default */ + init_pair(COLOR_FEMALE, COLOR_RED, -1); wnoutrefresh(stdscr); /* if not present the first real refresh is missed */ Tree test1("Dechkovi"); //addTree Dechkovi addTree Karamanovi load 0 load 1 (to work with these example trees) diff --git a/person.cpp b/person.cpp index 2386e18..0d758d5 100644 --- a/person.cpp +++ b/person.cpp @@ -181,6 +181,10 @@ void Person::draw(I16 drawY, I16 drawX, bool hasSpouse, bool isSpouse, bool hasK U16 width = boxWidth(); WINDOW* pad = newpad(BOX_HEIGHT, width); + auto color_pair = COLOR_PAIR(isMale_ ? COLOR_MALE : COLOR_FEMALE); + wbkgd(pad, color_pair); + /* wattron(pad, color_pair); */ + wborder(pad, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, isSpouse ? ACS_TTEE : ACS_LTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER, hasKids ? ACS_LTEE : ACS_LLCORNER, ACS_LRCORNER ); @@ -190,6 +194,8 @@ void Person::draw(I16 drawY, I16 drawX, bool hasSpouse, bool isSpouse, bool hasK mvwaddstr(pad, 2, 2, name_.data()); + /* wattroff(pad, color_pair); */ + pnoutrefresh(pad, 0, 0, drawY, drawX, drawY + BOX_HEIGHT-1, drawX + width-1); diff --git a/person.h b/person.h index a01b218..7090729 100644 --- a/person.h +++ b/person.h @@ -20,6 +20,11 @@ struct EventTime I8 minute; //0-59 }; +enum { + COLOR_MALE = 1, + COLOR_FEMALE +}; + enum { BOX_HEIGHT = 5, LINK_HEIGHT = 3 diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..235b10e --- /dev/null +++ b/todo.txt @@ -0,0 +1,11 @@ +addPerson add siblings (add relation improve) + +Draw distinct regions of a tree +Draw spouses' relatives if main has none + +Color +Display info + +Partialy visible people +Scrolling +Zooming diff --git a/tree.cpp b/tree.cpp index fd23696..b66e174 100644 --- a/tree.cpp +++ b/tree.cpp @@ -340,7 +340,7 @@ void Tree::removePerson(const unsigned id) --numPeople; } -void Tree::removePerson(const char* personName, const short year, const unsigned char month, const unsigned char day) +void Tree::removePerson(const char* personName, short year, unsigned char month, unsigned char day) { removePerson(findId(personName, year, month, day)); } @@ -371,38 +371,24 @@ void Tree::draw(person_id focused) const { erase(); //Clear the screen wnoutrefresh(stdscr); - /* 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 drawX = (COLS - fw - mw) / 2; */ - /* pnoutrefresh(father, 0, 0, */ - /* 1, drawX, */ - /* 1 +fh-1, drawX + fw-1); */ - - /* const U32 numPpl = people.gNum(); */ - /* std::vector drawn(numPpl, false); */ U16 drawY = 0/* (LINES) / 2 */; U16 drawX = 0/* (COLS) / 2 */; drawLineWithWives(focused, drawY, drawX); - /* people[0].draw(drawY, drawY); */ - /* for(U32 i=0; i