X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/467f3bcabe798b584e470038c3169c374874b18b..4b6cd4995469bec2e67deb184cbaff90b6f02416:/nviewer/window.cpp?ds=sidebyside diff --git a/nviewer/window.cpp b/nviewer/window.cpp index a3f3993..c0806ac 100644 --- a/nviewer/window.cpp +++ b/nviewer/window.cpp @@ -3,25 +3,45 @@ Window::Window (const std::string &s, int w, int h, int x, int y, bool use_box) { + parent = NULL; + if (!w) w = COLS; + if (!h) h = LINES; + + width = w; + height = h; + win = newwin (h, w, y, x); + if (use_box == true) { - if (w) w +=2; - if (h) h +=2; + wattron (win, COLOR_PAIR (6)); + box(win, ACS_VLINE, ACS_HLINE); + wattroff (win, COLOR_PAIR (6)); } - if (h) h++; + + title = s; + wattron (win, COLOR_PAIR (1)); + mvwaddstr(win, 0, 1, title.c_str ()); + wattroff (win, COLOR_PAIR (1)); +} + +Window::Window (Window *p, const std::string &s, int w, int h, int x, int y, bool use_box) +{ + parent = p; + if (!w) w = COLS; + if (!h) h = LINES; width = w; height = h; - win = newwin (h, w, y, x); + win = derwin (parent->win, h, w, y, x); if (use_box == true) { - wattron (win, COLOR_PAIR (4)); + wattron (win, COLOR_PAIR (6)); box(win, ACS_VLINE, ACS_HLINE); - wattroff (win, COLOR_PAIR (4)); + wattroff (win, COLOR_PAIR (6)); } title = s; wattron (win, COLOR_PAIR (1)); - mvwaddstr(win, 1, 1, title.c_str ()); + mvwaddstr(win, 0, 1, title.c_str ()); wattroff (win, COLOR_PAIR (1)); } @@ -32,7 +52,7 @@ Window::~Window () void Window::SetText (int x, int y, const std::string &s) { - mvwaddstr (win, y+1, x+1, s.c_str ()); + mvwaddstr (win, y, x, s.c_str ()); wrefresh (win); } @@ -53,8 +73,16 @@ void Window::SetText (int x, int y, uint i) ss >> s; SetText (x, y, s); } + void Window::Show () { + if (parent) + touchwin (parent->win); wrefresh (win); } +int Window::GetChar () +{ + return wgetch (win); +} +