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));
}
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);
}
ss >> s;
SetText (x, y, s);
}
+
void Window::Show ()
{
+ if (parent)
+ touchwin (parent->win);
wrefresh (win);
}
+int Window::GetChar ()
+{
+ return wgetch (win);
+}
+