#ifndef _CursesWindow_h #define _CursesWindow_h /////// File CursesWindow.h /////// //// curses.h header defined by C++ #include // C++ class for C-based curses windows class CursesWindow { public: CursesWindow(WINDOW* &window); // useful only for stdscr CursesWindow(int lines, // number of lines int cols, // number of columns int begin_y, // line origin int begin_x); // col origin CursesWindow(CursesWindow* par, // parent window int lines, // number of lines int cols, // number of columns int by, // absolute or relative int bx, // origins: char absrel = 'a'); // if `a', by & bx are // absolute screen pos, // else if `r', they are // relative to par origin ~CursesWindow(); // window status int Height(); // number of lines in this window int Width(); // number of cols in this window int Begy(){ return w->_begy;}; // smallest y coord in window int Begx(){ return w->_begx; }; // smallest x coord in window // window positioning int Move(int y, int x); // coordinate positioning void Getyx(int& y, int& x); int Mvcur(int sy, int ey, int sx, int ex); // reading int Getch(); int Getstr(char * str); int Scanw(const char *, ...); // reading + positioning int Mvgetch(int y, int x); int Mvgetstr(int y, int x, char * str); int Mvscanw(int, int, const char*, ...); // writing int Addch(const char ch); int Addstr(char * str); int Printw(const char * fmt, ...); int Inch(); int Insch(char c); int Insertln(); // writing + positioning int Mvaddch(int y, int x, char ch); int Mvaddstr(int y, int x, char * str); int Mvprintw(int y, int x, const char * fmt, ...); int Mvinch(int y, int x); int Mvinsch(int y, int x, char ch); // borders int Box(char vert, char hor); // erasure int Erase(); int Clear(); int Clearok(bool bf); int Clrtobot(); int Clrtoeol(); int Delch(); int Mvdelch(int y, int x); int Deleteln(); // screen control int Scroll(); int Scrollok(bool bf); int Touchwin(); void Refresh(); // display host window int Leaveok(bool bf); int Flushok(bool bf); int Standout(); int Standend(); // multiple window control int Overlay(CursesWindow &win); int Overwrite(CursesWindow &win); // traversal support CursesWindow* Child(); CursesWindow* Sibling(); CursesWindow* Parent(); protected: static int count; // count of all active windows: // We rely on the c++ promise that // all otherwise uninitialized // static class vars are set to 0 WINDOW * w; // the curses WINDOW int alloced; // true if we own the WINDOW CursesWindow* par; // parent, if subwindow CursesWindow* subwins; // head of subwindows list CursesWindow* sib; // next subwindow of parent void kill_subwindows(); // disable all subwindows }; // two standard global windows extern CursesWindow std_win; // global object encapsulates stdscr extern CursesWindow cur_win; // global object encapsulates curscr // most member functions are inline inline int CursesWindow::Height() { return w->_maxy; } inline int CursesWindow::Width() { return w->_maxx; // unfortunate naming in curses } inline int CursesWindow::Box(char vert, char hor) { return ::box(w, vert, hor); } inline int CursesWindow::Overlay(CursesWindow &win) { return ::overlay(w, win.w); } inline int CursesWindow::Overwrite(CursesWindow &win) { return ::overwrite(w, win.w); } inline int CursesWindow::Scroll() { return ::scroll(w); } inline int CursesWindow::Touchwin() { return ::touchwin(w); } inline int CursesWindow::Addch(const char ch) { return ::waddch(w, ch); } inline int CursesWindow::Addstr(char * str) { return ::waddstr(w, str); } inline int CursesWindow::Clear() { return ::wclear(w); } inline int CursesWindow::Clrtobot() { return ::wclrtobot(w); } inline int CursesWindow::Clrtoeol() { return ::wclrtoeol(w); } inline int CursesWindow::Delch() { return ::wdelch(w); } inline int CursesWindow::Deleteln() { return ::wdeleteln(w); } inline int CursesWindow::Erase() { return ::werase(w); } inline int CursesWindow::Getch() { return ::wgetch(w); } inline int CursesWindow::Getstr(char * str) { return ::wgetstr(w, str); } inline int CursesWindow::Inch() { return (winch(w)); } inline int CursesWindow::Insch(char c) { return ::winsch(w, c); } inline int CursesWindow::Insertln() { return ::winsertln(w); } inline int CursesWindow::Move(int y, int x) { return ::wmove(w, y, x); } inline int CursesWindow::Mvcur(int sy, int ey, int sx, int ex) { return ::mvcur(sy, ey, sx,ex); } inline int CursesWindow::Mvaddch(int y, int x, char ch) { return (::wmove(w, y, x)==0) ? 0 : ::waddch(w, ch); } inline int CursesWindow::Mvgetch(int y, int x) { return (::wmove(w, y, x)==0) ? 0 : ::wgetch(w); } inline int CursesWindow::Mvaddstr(int y, int x, char * str) { return (::wmove(w, y, x)==0) ? 0 : ::waddstr(w, str); } inline int CursesWindow::Mvgetstr(int y, int x, char * str) { return (::wmove(w, y, x)==0) ? 0 : ::wgetstr(w, str); } inline int CursesWindow::Mvinch(int y, int x) { return (::wmove(w, y, x)==0) ? 0 : (winch(w)); } inline int CursesWindow::Mvdelch(int y, int x) { return (::wmove(w, y, x)==0) ? 0 : ::wdelch(w); } inline int CursesWindow::Mvinsch(int y, int x, char ch) { return (::wmove(w, y, x)==0) ? 0 : ::winsch(w, ch); } inline void CursesWindow::Refresh() { ::wrefresh(w); } inline int CursesWindow::Clearok(bool bf) { return (clearok(w,bf)); } inline int CursesWindow::Leaveok(bool bf) { return (leaveok(w,bf)); } inline int CursesWindow::Scrollok(bool bf) { return (scrollok(w,bf)); } inline int CursesWindow::Flushok(bool bf) { return (flushok(w, bf)); } inline void CursesWindow::Getyx(int& y, int& x) { getyx(w, y, x); } inline int CursesWindow::Standout() { return ::wstandout(w); } inline int CursesWindow::Standend() { return ::wstandend(w); } inline CursesWindow* CursesWindow::Child() { return subwins; } inline CursesWindow* CursesWindow::Parent() { return par; } inline CursesWindow* CursesWindow::Sibling() { return sib; } #endif