This commit is contained in:
vrd
2023-03-06 10:24:32 +02:00
parent cc7a689dc1
commit 9ef74b8283
5 changed files with 70 additions and 28 deletions
+31 -8
View File
@@ -7,6 +7,7 @@
#include "utils.hpp"
using std::cout;
using std::string;
static WINDOW* info_tab;
@@ -141,10 +142,10 @@ static U16 strUtf8Symbols(const std::string& str)
return num;
}
U16 Person::boxWidth() const
{
return strUtf8Symbols(name) + 4;
}
/* U16 Person::boxWidth() const */
/* { */
/* return strUtf8Symbols(name) + 4; */
/* } */
/* WINDOW* Person::createPad()const */
@@ -158,9 +159,30 @@ U16 Person::boxWidth() const
/* return pad; */
/* } */
void Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse, bool isSpouse, bool hasKids) const
U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse,
bool hasParents, bool hasKids, bool wholeName) const
{
const U16 width = boxWidth(); /* pad width */
string display_name; /* todo remove? */
if(wholeName)
{
display_name = name;
}
else
{
size_t space = name.find(' ');
if(space != string::npos)
{
/* name[space] = '\0'; */
display_name = name.substr(0, space);
/* name[space] = ' '; */
}
else
{
display_name = name;
}
}
const U16 width = strUtf8Symbols(display_name) + 4; /* pad width */
if(willBeVisible(drawY, drawX, BOX_HEIGHT, width))
{
@@ -173,14 +195,15 @@ void Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpous
/* wattron(pad, color_pair); */
wborder(pad, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
isSpouse ? ACS_TTEE : ACS_LTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER,
hasParents ? ACS_LTEE : ACS_TTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER,
hasKids ? ACS_LTEE : ACS_LLCORNER, ACS_LRCORNER );
mvwaddstr(pad, 2, 2, name.data());
mvwaddstr(pad, 2, 2, display_name.data());
/* wattroff(pad, color_pair); */
drawpad(pad, drawY, drawX);
delwin(pad);
}
return width;
}