home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / VID.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-31  |  3.6 KB  |  143 lines

  1. /*
  2.     vid.c
  3.  
  4.     % vid_ routines
  5.  
  6.     OWL 1.2
  7.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      8/10/88 jmd    Added new object stuff
  13.      8/24/88 ted    merged driver and mode in to one stub function pointer.
  14.  
  15.     11/29/89 jmd    added casts for DG
  16.      3/28/90 jmd    ansi-fied
  17.      8/30/90 ted    made cbuf & abuf in vid_PutAttr automatic instead of static.
  18. */
  19.  
  20. #include "oakhead.h"
  21. #include "disppriv.h"
  22.  
  23. #include "viddecl.h"
  24. /* -------------------------------------------------------------------------- */
  25.  
  26. byte vid_GetMap(byte attr)
  27. {
  28.     opixval fg, bg;
  29.     byte colors;
  30.  
  31.     disp_GetAttrColors(attr, &fg, &bg);
  32.     colors = ((byte) fg) & 0x0F;
  33.     colors |= ((byte) bg) << 4;
  34.  
  35.     return(colors);
  36. }
  37. /* -------------------------------------------------------------------------- */
  38.  
  39. char vid_GetChar(int row, int col)
  40. {
  41.     char c;
  42.     byte attr;
  43.  
  44.     cmwin_GetStringAttr(vid_win, row, col, &c, &attr, 1);
  45.     return(c);
  46. }
  47. /* -------------------------------------------------------------------------- */
  48. #define MAXATTRBUF    90
  49.  
  50. int vid_PutAttr(int row, int col, byte *attrbuf, int slen)
  51. /*
  52.     Puts slen attribute bytes from attrbuf into the vid_win at row, col.
  53.     Puts at most MAXATTR attrs. The display is refreshed to reflect the new
  54.     attribute bytes.
  55.     Returns the number of bytes actually used.
  56. */
  57. {
  58.     byte abuf[MAXATTRBUF];
  59.     char cbuf[MAXATTRBUF];
  60.     int len;
  61.  
  62.     if (slen > MAXATTRBUF) {
  63.         slen = MAXATTRBUF;
  64.     }
  65.  
  66.     len = cmwin_GetStringAttr(vid_win, row, col, cbuf, abuf, slen);
  67.  
  68.     memmove((VOID *) abuf, (VOID *) attrbuf, len);
  69.  
  70.     cmwin_DrawStringAttr(vid_win, row, col, cbuf, abuf, len);
  71.  
  72.     return(len);
  73. }
  74. /* -------------------------------------------------------------------------- */
  75.  
  76. char *vid_GetAttr(int row, int col, int slen)
  77. /*
  78.     Returns a pointer to a static buffer containing slen attributes from
  79.     the vid_win at row, col. Returns MAXATTRBUF attrs at most. The buffer is
  80.     not null-terminated.
  81. */
  82. {
  83.     char cbuf[MAXATTRBUF];
  84.     static byte abuf[MAXATTRBUF];
  85.  
  86.     if (slen > MAXATTRBUF) slen = MAXATTRBUF;
  87.  
  88.     cmwin_GetStringAttr(vid_win, row, col, cbuf, abuf, slen);
  89.     return((char *) abuf);
  90. }
  91. /* -------------------------------------------------------------------------- */
  92.  
  93. void vid_ScrollWindow(int toprow, int leftcol, int botrow, int rightcol, int lines, byte attr)
  94. {
  95.     ocbox cbox;
  96.  
  97.     cbox.leftcol = leftcol;
  98.     cbox.rightcol = rightcol;
  99.     cbox.toprow = toprow;
  100.     cbox.botrow = botrow;
  101.  
  102.     cmwin_ScrollBoxVt(vid_win, &cbox, lines);
  103.     /* Note: attr is no longer used to clear opened part */ oak_notused(attr);
  104. }
  105. /* -------------------------------------------------------------------------- */
  106.  
  107. void vid_ClearWindow(int toprow, int leftcol, int botrow, int rightcol, byte attr)
  108. {
  109.     ocbox cbox;
  110.  
  111.     cbox.leftcol = leftcol;
  112.     cbox.rightcol = rightcol;
  113.     cbox.toprow = toprow;
  114.     cbox.botrow = botrow;
  115.     cmwin_ClearBox(vid_win, &cbox, (byte)attr);
  116. }
  117. /* -------------------------------------------------------------------------- */
  118.  
  119. void vid_DrawLine(char *linecp, int row1, int col1, int row2, int col2, byte attr)
  120. {
  121.     if (row1 == row2) {
  122.         cmwin_DrawHzLine(vid_win, linecp, row1, col1, col2 - col1 + 1, attr);
  123.     }
  124.     else if (col1 == col2) {
  125.         cmwin_DrawVtLine(vid_win, linecp, row1, col1, row2 - row1 + 1, attr);
  126.     }
  127. }
  128. /* -------------------------------------------------------------------------- */
  129.  
  130. void vid_DrawBox(char *boxcp, int row1, int col1, int row2, int col2, byte attr)
  131. {
  132.     ocbox cbox;
  133.  
  134.     cbox.toprow  = row1;
  135.     cbox.leftcol = col1;
  136.     cbox.botrow  = row2;
  137.     cbox.rightcol= col2;
  138.  
  139.     cmwin_DrawBox(vid_win, boxcp, &cbox, attr);
  140. }
  141. /* -------------------------------------------------------------------------- */
  142.  
  143.