This commit is contained in:
vrd
2022-12-31 18:54:34 +02:00
parent 3f402e058c
commit 1c91d7b775
5 changed files with 43 additions and 29 deletions
+8 -2
View File
@@ -1,4 +1,3 @@
#include <ncursesw/ncurses.h>
#include <iostream>
#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)
+6
View File
@@ -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);
+5
View File
@@ -20,6 +20,11 @@ struct EventTime
I8 minute; //0-59
};
enum {
COLOR_MALE = 1,
COLOR_FEMALE
};
enum {
BOX_HEIGHT = 5,
LINK_HEIGHT = 3
+11
View File
@@ -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
+13 -27
View File
@@ -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<bool> 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<relations[0].gNum(); ++i) */
/* { */
/* if(relations[0][i] == RelType::Son) */
/* { */
/* drawX = drawLineRec(i, drawY, drawX) + 2; */
/* } */
/* } */
/* pnoutrefresh(mother, 0, 0, 1, d */
doupdate();
getch();
char c;
do
{
c = std::tolower(getch());
switch(c)
{
default: break;
}
}
while(c != 'w');
}
void Tree::print() const