-
-#include "window.h"
-
-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) {
- wattron (win, COLOR_PAIR (6));
- box(win, ACS_VLINE, ACS_HLINE);
- wattroff (win, COLOR_PAIR (6));
- }
-
- 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 = derwin (parent->win, h, w, y, x);
-
- if (use_box == true) {
- wattron (win, COLOR_PAIR (6));
- box(win, ACS_VLINE, ACS_HLINE);
- wattroff (win, COLOR_PAIR (6));
- }
-
- title = s;
- wattron (win, COLOR_PAIR (1));
- mvwaddstr(win, 0, 1, title.c_str ());
- wattroff (win, COLOR_PAIR (1));
-}
-
-Window::~Window ()
-{
- delwin (win);
-}
-
-void Window::SetText (int x, int y, const std::string &s)
-{
- mvwaddstr (win, y, x, s.c_str ());
- Show ();
-}
-
-void Window::SetText (int x, int y, int i)
-{
- std::stringstream ss;
- std::string s;
- ss << i;
- ss >> s;
- SetText (x, y, s);
-}
-
-void Window::SetText (int x, int y, uint i)
-{
- std::stringstream ss;
- std::string s;
- ss << i;
- ss >> s;
- SetText (x, y, s);
-}
-
-void Window::Show ()
-{
- if (parent)
- touchwin (parent->win);
- wrefresh (win);
-}
-
-int Window::GetChar ()
-{
- return wgetch (win);
-}
-