home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 332_01 / border.c < prev    next >
C/C++ Source or Header  |  1990-01-06  |  4KB  |  121 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 short 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(win, l, r, t, b, tl, tr, bl, br)
  35.   WINDOW    *win;
  36.   int         l;
  37.   int         r;
  38.   int         t;
  39.   int         b;
  40.   int         tl;
  41.   int         tr;
  42.   int         bl;
  43.   int         br;
  44.   {
  45.   short     xmax, ymax, i;
  46.  
  47.   ymax = win->_maxy - 1;
  48.   xmax = win->_maxx - 1;
  49.   for (i = 1; i <= xmax-1;i++)
  50.     {
  51.     win->_line[0][i] =     t | win->_attrs;
  52.     win->_line[ymax][i] =  b | win->_attrs;
  53.     } /* for */
  54.   for (i = 1;i <= ymax-1;i++)
  55.     {
  56.     win->_line[i][0] =     l | win->_attrs;
  57.     win->_line[i][xmax] =  r | win->_attrs;
  58.     } /* for */
  59.   win->_line[0][0] =       tl | win->_attrs;
  60.   win->_line[0][xmax] =    tr | win->_attrs;
  61.   win->_line[ymax][0] =    bl | win->_attrs;
  62.   win->_line[ymax][xmax] = br | win->_attrs;
  63.  
  64.   for (i=0; i <= ymax ; i++)
  65.     {
  66.     win->_minchng[i] = 0;
  67.     win->_maxchng[i] = xmax;
  68.     } /* for */
  69.   } /* wborder */
  70.  
  71. /****************************************************************/
  72. /* Border(l, r, t, b, tl, tr, bl, br) draws a border in stdscr,    */
  73. /* with the specified characters as border edges:        */
  74. /* l    left                            */
  75. /* r    right                            */
  76. /* b    bottom                            */
  77. /* t    top                            */
  78. /* tl    top left corner                        */
  79. /* tr    top right corner                    */
  80. /* bl    bottom left corner                    */
  81. /* br    bottom right corner                    */
  82. /* Don't make this a call to wborder() - it would require soo    */
  83. /* much stack for parameters...                    */
  84. /****************************************************************/
  85.  
  86. void border(l, r, t, b, tl, tr, bl, br)
  87.   int         l;
  88.   int         r;
  89.   int         t;
  90.   int         b;
  91.   int         tl;
  92.   int         tr;
  93.   int         bl;
  94.   int         br;
  95.   {
  96.   short     xmax, ymax, i;
  97.  
  98.   ymax = stdscr->_maxy - 1;
  99.   xmax = stdscr->_maxx - 1;
  100.   for (i = 1; i <= xmax-1;i++)
  101.     {
  102.     stdscr->_line[0][i] =     t | stdscr->_attrs;
  103.     stdscr->_line[ymax][i] =  b | stdscr->_attrs;
  104.     } /* for */
  105.   for (i = 1;i <= ymax-1;i++)
  106.     {
  107.     stdscr->_line[i][0] =     l | stdscr->_attrs;
  108.     stdscr->_line[i][xmax] =  r | stdscr->_attrs;
  109.     } /* for */
  110.   stdscr->_line[0][0] =       tl | stdscr->_attrs;
  111.   stdscr->_line[0][xmax] =    tr | stdscr->_attrs;
  112.   stdscr->_line[ymax][0] =    bl | stdscr->_attrs;
  113.   stdscr->_line[ymax][xmax] = br | stdscr->_attrs;
  114.  
  115.   for (i=0; i <= ymax ; i++)
  116.     {
  117.     stdscr->_minchng[i] = 0;
  118.     stdscr->_maxchng[i] = xmax;
  119.     } /* for */
  120.   } /* border */
  121.