home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / djgpp / include / curseswi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-20  |  9.8 KB  |  408 lines

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