home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / cursesp.zip / BORDER.C < prev    next >
C/C++ Source or Header  |  1991-12-03  |  4KB  |  105 lines

  1. /****************************************************************/
  2. /* Box border control routines of the PCcurses package.        */
  3. /*                                */
  4. /****************************************************************/
  5. /* This version of curses is based on ncurses, a curses version    */
  6. /* originally written by Pavel Curtis at Cornell University.    */
  7. /* I have made substantial changes to make it run on IBM PC's,    */
  8. /* and therefore consider myself free make it public domain.    */
  9. /*                Bjorn Larsson (bl@infovox.se)    */
  10. /****************************************************************/
  11. /* 1.4 : Changed to draw a border. Use int wherever        */
  12. /*     possible: Portability improvements:        900114    */
  13. /* 1.3:     Released:                    881005    */
  14. /****************************************************************/
  15.  
  16. #include <curses.h>
  17. #include <curspriv.h>
  18.  
  19. char _curses_border_rcsid[] = "@(#)border.c     v.1.4  - 900114";
  20.  
  21. /****************************************************************/
  22. /* Wborder(win, l, r, t, b, tl, tr, bl, br) draws a border in    */
  23. /* window win, with the specified characters as border edges:    */
  24. /* l    left                            */
  25. /* r    right                            */
  26. /* b    bottom                            */
  27. /* t    top                            */
  28. /* tl    top left corner                        */
  29. /* tr    top right corner                    */
  30. /* bl    bottom left corner                    */
  31. /* br    bottom right corner                    */
  32. /****************************************************************/
  33.  
  34. void wborder(WINDOW *win, int l, int r, int t, int b, int tl, 
  35.         int tr, int bl, int br)
  36.   {
  37.   int     xmax, ymax, i;
  38.  
  39.   ymax = win->_maxy - 1;
  40.   xmax = win->_maxx - 1;
  41.   for (i = 1; i <= xmax-1;i++)
  42.     {
  43.     win->_line[0][i] =     t | win->_attrs;
  44.     win->_line[ymax][i] =  b | win->_attrs;
  45.     } /* for */
  46.   for (i = 1;i <= ymax-1;i++)
  47.     {
  48.     win->_line[i][0] =     l | win->_attrs;
  49.     win->_line[i][xmax] =  r | win->_attrs;
  50.     } /* for */
  51.   win->_line[0][0] =       tl | win->_attrs;
  52.   win->_line[0][xmax] =    tr | win->_attrs;
  53.   win->_line[ymax][0] =    bl | win->_attrs;
  54.   win->_line[ymax][xmax] = br | win->_attrs;
  55.  
  56.   for (i=0; i <= ymax ; i++)
  57.     {
  58.     win->_minchng[i] = 0;
  59.     win->_maxchng[i] = xmax;
  60.     } /* for */
  61.   } /* wborder */
  62.  
  63. /****************************************************************/
  64. /* Border(l, r, t, b, tl, tr, bl, br) draws a border in stdscr,    */
  65. /* with the specified characters as border edges:        */
  66. /* l    left                            */
  67. /* r    right                            */
  68. /* b    bottom                            */
  69. /* t    top                            */
  70. /* tl    top left corner                        */
  71. /* tr    top right corner                    */
  72. /* bl    bottom left corner                    */
  73. /* br    bottom right corner                    */
  74. /* Don't make this a call to wborder() - it would require soo    */
  75. /* much stack for parameters...                    */
  76. /****************************************************************/
  77.  
  78. void border(int l, int r, int t, int b, int tl, int tr, int bl, int br)
  79.   {
  80.   int     xmax, ymax, i;
  81.  
  82.   ymax = stdscr->_maxy - 1;
  83.   xmax = stdscr->_maxx - 1;
  84.   for (i = 1; i <= xmax-1;i++)
  85.     {
  86.     stdscr->_line[0][i] =     t | stdscr->_attrs;
  87.     stdscr->_line[ymax][i] =  b | stdscr->_attrs;
  88.     } /* for */
  89.   for (i = 1;i <= ymax-1;i++)
  90.     {
  91.     stdscr->_line[i][0] =     l | stdscr->_attrs;
  92.     stdscr->_line[i][xmax] =  r | stdscr->_attrs;
  93.     } /* for */
  94.   stdscr->_line[0][0] =       tl | stdscr->_attrs;
  95.   stdscr->_line[0][xmax] =    tr | stdscr->_attrs;
  96.   stdscr->_line[ymax][0] =    bl | stdscr->_attrs;
  97.   stdscr->_line[ymax][xmax] = br | stdscr->_attrs;
  98.  
  99.   for (i=0; i <= ymax ; i++)
  100.     {
  101.     stdscr->_minchng[i] = 0;
  102.     stdscr->_maxchng[i] = xmax;
  103.     } /* for */
  104.   } /* border */
  105.