color
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
@@ -8,11 +7,18 @@ using std::cin;
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, ""); /* TODO: set to utf */
|
||||||
|
|
||||||
|
/* Init ncurses */
|
||||||
initscr(); /* Start curses mode */
|
initscr(); /* Start curses mode */
|
||||||
noecho();
|
noecho();
|
||||||
cbreak(); /* get input instantly */
|
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 */
|
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)
|
Tree test1("Dechkovi"); //addTree Dechkovi addTree Karamanovi load 0 load 1 (to work with these example trees)
|
||||||
|
|||||||
@@ -181,6 +181,10 @@ void Person::draw(I16 drawY, I16 drawX, bool hasSpouse, bool isSpouse, bool hasK
|
|||||||
U16 width = boxWidth();
|
U16 width = boxWidth();
|
||||||
WINDOW* pad = newpad(BOX_HEIGHT, width);
|
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,
|
wborder(pad, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
|
||||||
isSpouse ? ACS_TTEE : ACS_LTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER,
|
isSpouse ? ACS_TTEE : ACS_LTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER,
|
||||||
hasKids ? ACS_LTEE : ACS_LLCORNER, ACS_LRCORNER );
|
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());
|
mvwaddstr(pad, 2, 2, name_.data());
|
||||||
|
|
||||||
|
/* wattroff(pad, color_pair); */
|
||||||
|
|
||||||
pnoutrefresh(pad, 0, 0,
|
pnoutrefresh(pad, 0, 0,
|
||||||
drawY, drawX,
|
drawY, drawX,
|
||||||
drawY + BOX_HEIGHT-1, drawX + width-1);
|
drawY + BOX_HEIGHT-1, drawX + width-1);
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ struct EventTime
|
|||||||
I8 minute; //0-59
|
I8 minute; //0-59
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
COLOR_MALE = 1,
|
||||||
|
COLOR_FEMALE
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BOX_HEIGHT = 5,
|
BOX_HEIGHT = 5,
|
||||||
LINK_HEIGHT = 3
|
LINK_HEIGHT = 3
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -340,7 +340,7 @@ void Tree::removePerson(const unsigned id)
|
|||||||
--numPeople;
|
--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));
|
removePerson(findId(personName, year, month, day));
|
||||||
}
|
}
|
||||||
@@ -371,38 +371,24 @@ void Tree::draw(person_id focused) const
|
|||||||
{
|
{
|
||||||
erase(); //Clear the screen
|
erase(); //Clear the screen
|
||||||
wnoutrefresh(stdscr);
|
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 drawY = 0/* (LINES) / 2 */;
|
||||||
U16 drawX = 0/* (COLS) / 2 */;
|
U16 drawX = 0/* (COLS) / 2 */;
|
||||||
drawLineWithWives(focused, drawY, drawX);
|
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();
|
doupdate();
|
||||||
getch();
|
|
||||||
|
char c;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c = std::tolower(getch());
|
||||||
|
|
||||||
|
switch(c)
|
||||||
|
{
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(c != 'w');
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tree::print() const
|
void Tree::print() const
|
||||||
|
|||||||
Reference in New Issue
Block a user