home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / g__inc / xcursesw.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-23  |  8.9 KB  |  393 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2.  
  3. /* 
  4. Copyright (C) 1989 Free Software Foundation
  5.     written by Eric Newton (newton@rocky.oswego.edu)
  6.  
  7. This file is part of the GNU C++ Library.  This library is free
  8. software; you can redistribute it and/or modify it under the terms of
  9. the GNU Library General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at your
  11. option) any later version.  This library is distributed in the hope
  12. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  13. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  14. PURPOSE.  See the GNU Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #ifndef _CursesWindow_h
  21. #ifdef __GNUG__
  22. #pragma once
  23. #pragma interface
  24. #endif
  25. #define _CursesWindow_h
  26. #ifdef __GNUG__
  27. #pragma once
  28. #pragma interface
  29. #endif
  30.  
  31. #include   <curses.h> 
  32.  
  33. /*
  34.  *
  35.  * C++ class for windows.
  36.  *
  37.  *
  38.  */
  39.  
  40. class CursesWindow 
  41. {
  42. protected:
  43.   static int     count;           // count of all active windows:
  44.                                   //   We rely on the c++ promise that
  45.                                   //   all otherwise uninitialized
  46.                                   //   static class vars are set to 0
  47.  
  48.   WINDOW *       w;               // the curses WINDOW
  49.  
  50.   int            alloced;         // true if we own the WINDOW
  51.  
  52.   CursesWindow*  par;             // parent, if subwindow
  53.   CursesWindow*  subwins;         // head of subwindows list
  54.   CursesWindow*  sib;             // next subwindow of parent
  55.  
  56.   void           kill_subwindows(); // disable all subwindows
  57.  
  58. public:
  59.                  CursesWindow(WINDOW* &window);   // useful only for stdscr
  60.  
  61.                  CursesWindow(int lines,          // number of lines
  62.                               int cols,           // number of columns
  63.                               int begin_y,        // line origin
  64.                               int begin_x);       // col origin
  65.  
  66.                  CursesWindow(CursesWindow& par,  // parent window
  67.                               int lines,          // number of lines
  68.                               int cols,           // number of columns
  69.                               int by,             // absolute or relative
  70.                               int bx,             //   origins:
  71.                               char absrel = 'a'); // if `a', by & bx are
  72.                                                   // absolute screen pos,
  73.                                                   // else if `r', they are
  74.                                                   // relative to par origin
  75.                 ~CursesWindow();
  76.  
  77. // terminal status
  78.   int            lines(); // number of lines on terminal, *not* window
  79.   int            cols();  // number of cols  on terminal, *not* window
  80.  
  81. // window status
  82.   int            height(); // number of lines in this window
  83.   int            width();  // number of cols in this window
  84.   int            begx();   // smallest x coord in window
  85.   int            begy();   // smallest y coord in window
  86.   int            maxx();   // largest  x coord in window
  87.   int            maxy();   // largest  x coord in window
  88.  
  89. // window positioning
  90.   int            move(int y, int x);
  91.  
  92. // coordinate positioning
  93.   void           getyx(int& y, int& x);
  94.   int            mvcur(int sy, int ey, int sx, int ex);
  95.  
  96. // input
  97.   int            getch();
  98.   int            getstr(char * str);
  99.   int            scanw(const char *, ...);
  100.  
  101. // input + positioning
  102.   int            mvgetch(int y, int x);
  103.   int            mvgetstr(int y, int x, char * str);
  104.   int            mvscanw(int, int, const char*, ...);
  105.  
  106. // output
  107.   int            addch(const char ch);
  108.   int            addstr(const char * str);
  109.   int            printw(const char * fmt, ...);
  110.   int            inch();
  111.   int            insch(char c);
  112.   int            insertln();
  113.  
  114. // output + positioning
  115.   int            mvaddch(int y, int x, char ch);
  116.   int            mvaddstr(int y, int x, char * str);
  117.   int            mvprintw(int y, int x, const char * fmt, ...);
  118.   int            mvinch(int y, int x);
  119.   int            mvinsch(int y, int x, char ch);
  120.  
  121. // borders
  122.   int            box(char vert, char  hor);
  123.  
  124. // erasure
  125.   int            erase();
  126.   int            clear();
  127.   int            clearok(cbool bf);
  128.   int            clrtobot();
  129.   int            clrtoeol();
  130.   int            delch();
  131.   int            mvdelch(int y, int x);
  132.   int            deleteln();
  133.  
  134. // screen control
  135.   int            scroll();
  136.   int            scrollok(cbool bf);
  137.   int            touchwin();
  138.   int            refresh();
  139.   int            leaveok(cbool bf);
  140.   int            flushok(cbool bf);
  141.   int            standout();
  142.   int            standend();
  143.  
  144. // multiple window control
  145.   int            overlay(CursesWindow &win);
  146.   int            overwrite(CursesWindow &win);
  147.  
  148.  
  149. // traversal support
  150.   CursesWindow*  child();
  151.   CursesWindow*  sibling();
  152.   CursesWindow*  parent();
  153. };
  154.  
  155. #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
  156.  
  157.  
  158. inline int CursesWindow::begx()
  159. {
  160.   return w->_begx;
  161. }
  162.  
  163. inline int CursesWindow::begy()
  164. {
  165.   return w->_begy;
  166. }
  167.  
  168. inline int CursesWindow::maxx()
  169. {
  170.   return w->_maxx;
  171. }
  172.  
  173. inline int CursesWindow::maxy()
  174. {
  175.   return w->_maxy;
  176. }
  177.  
  178. inline int CursesWindow::height()
  179. {
  180.   return maxy() - begy() + 1;
  181. }
  182.  
  183. inline int CursesWindow::width()
  184. {
  185.   return maxx() - begx() + 1;
  186. }
  187.  
  188. inline int CursesWindow::box(char vert, char  hor)    
  189. {
  190.   return ::box(w, vert, hor); 
  191. }
  192.  
  193. inline int CursesWindow::overlay(CursesWindow &win)         
  194. {
  195.   return ::overlay(w, win.w); 
  196. }
  197.  
  198. inline int CursesWindow::overwrite(CursesWindow &win)       
  199. {
  200.   return ::overwrite(w, win.w); 
  201. }
  202.  
  203. inline int CursesWindow::scroll()                     
  204. {
  205.   return ::scroll(w); 
  206. }
  207.  
  208.  
  209. inline int CursesWindow::touchwin()                   
  210. {
  211.   return ::touchwin(w); 
  212. }
  213.  
  214. inline int CursesWindow::addch(const char ch)         
  215. {
  216.   return ::waddch(w, ch); 
  217. }
  218.  
  219. inline int CursesWindow::addstr(const char * str)     
  220. {
  221.   return ::waddstr(w, str); 
  222. }
  223.  
  224. inline int CursesWindow::clear()                      
  225. {
  226.   return ::wclear(w); 
  227. }
  228.  
  229. inline int CursesWindow::clrtobot()                   
  230. {
  231.   return ::wclrtobot(w); 
  232. }
  233.  
  234. inline int CursesWindow::clrtoeol()                   
  235. {
  236.   return ::wclrtoeol(w); 
  237. }
  238.  
  239. inline int CursesWindow::delch()                      
  240. {
  241.   return ::wdelch(w); 
  242. }
  243.  
  244. inline int CursesWindow::deleteln()                   
  245. {
  246.   return ::wdeleteln(w); 
  247. }
  248.  
  249. inline int CursesWindow::erase()                      
  250. {
  251.   return ::werase(w); 
  252. }
  253.  
  254. inline int CursesWindow::getch()                      
  255. {
  256.   return ::wgetch(w); 
  257. }
  258.  
  259. inline int CursesWindow::getstr(char * str)           
  260. {
  261.   return ::wgetstr(w, str); 
  262. }
  263.  
  264. inline int CursesWindow::inch()                       
  265. {
  266.   return winch(w); 
  267. }
  268.  
  269. inline int CursesWindow::insch(char c)               
  270. {
  271.   return ::winsch(w, c); 
  272. }
  273.  
  274. inline int CursesWindow::insertln()                   
  275. {
  276.   return ::winsertln(w); 
  277. }
  278.  
  279. inline int CursesWindow::move(int y, int x)           
  280. {
  281.   return ::wmove(w, y, x); 
  282. }
  283.  
  284.  
  285. inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex)
  286. {
  287.   return ::mvcur(sy, ey, sx,ex);
  288. }
  289.  
  290. inline int CursesWindow::mvaddch(int y, int x, char ch)
  291. {
  292.   return (::wmove(w, y, x)==0) ? 0 : ::waddch(w, ch);
  293. }
  294.  
  295. inline int CursesWindow::mvgetch(int y, int x)
  296. {
  297.   return (::wmove(w, y, x)==0) ? 0 : ::wgetch(w);
  298. }
  299.  
  300. inline int CursesWindow::mvaddstr(int y, int x, char * str)
  301. {
  302.   return (::wmove(w, y, x)==0) ? 0 : ::waddstr(w, str);
  303. }
  304.  
  305. inline int CursesWindow::mvgetstr(int y, int x, char * str)
  306. {
  307.   return (::wmove(w, y, x)==0) ? 0 : ::wgetstr(w, str);
  308. }
  309.  
  310. inline int CursesWindow::mvinch(int y, int x)
  311. {
  312.   return (::wmove(w, y, x)==0) ? 0 : ::winch(w);
  313. }
  314.  
  315. inline int CursesWindow::mvdelch(int y, int x)
  316. {
  317.   return (::wmove(w, y, x)==0) ? 0 : ::wdelch(w);
  318. }
  319.  
  320. inline int CursesWindow::mvinsch(int y, int x, char ch)
  321. {
  322.   return (::wmove(w, y, x)==0) ? 0 : ::winsch(w, ch);
  323. }
  324.  
  325. inline int CursesWindow::refresh()                   
  326. {
  327.   return ::wrefresh(w); 
  328. }
  329.  
  330. inline int CursesWindow::clearok(cbool bf)             
  331. {
  332.   return ::clearok(w,bf); 
  333. }
  334.  
  335. inline int CursesWindow::leaveok(cbool bf)             
  336. {
  337.   return ::leaveok(w,bf); 
  338. }
  339.  
  340. inline int CursesWindow::scrollok(cbool bf)            
  341. {
  342.   return ::scrollok(w,bf); 
  343. }
  344.  
  345. inline int CursesWindow::flushok(cbool bf)            
  346. {
  347.   return ::flushok(w, bf); 
  348. }
  349.  
  350. inline void CursesWindow::getyx(int& y, int& x)       
  351. {
  352.   ::getyx(w, y, x); 
  353. }
  354.  
  355. inline int CursesWindow::standout()                   
  356. {
  357.   return ::wstandout(w); 
  358. }
  359.  
  360. inline int CursesWindow::standend()                   
  361. {
  362.   return ::wstandend(w); 
  363. }
  364.  
  365. inline int CursesWindow::lines()                      
  366. {
  367.   return LINES; 
  368. }
  369.  
  370. inline int CursesWindow::cols()                       
  371. {
  372.   return COLS; 
  373. }
  374.  
  375. inline CursesWindow* CursesWindow::child()
  376. {
  377.   return subwins;
  378. }
  379.  
  380. inline CursesWindow* CursesWindow::parent()
  381. {
  382.   return par;
  383. }
  384.  
  385. inline CursesWindow* CursesWindow::sibling()
  386. {
  387.   return sib;
  388. }
  389.  
  390.  
  391. # endif
  392. #endif
  393.