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

  1. /*
  2.     ptdpixch.c
  3.  
  4.     % Pixel oriented window painting code for character line drawing
  5.     
  6.     By Ted.     3/13/88 
  7.  
  8.     OWL 1.2
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.      3/28/90 jmd    ansi-fied
  15. */
  16.  
  17. #include "oakhead.h"
  18. #include "disppriv.h"
  19. /* -------------------------------------------------------------------------- */
  20.  
  21. void ptd_DrawPixCharBox(
  22.     ptd_struct *ptd,
  23.     opbox *boxp,
  24.     char *boxchar,
  25.     ofont_type font,
  26.     byte attr)
  27. {
  28.     char linechar[3];
  29.     opcoord fw, fh;
  30.     unsigned wid, hgt;
  31.  
  32.     if (font == NULL) {
  33.         return;
  34.     }
  35.     fw = ofont_GetWidth(font);
  36.     fh = ofont_GetHeight(font);
  37.  
  38.     wid = opbox_GetWidth(boxp) / fw;
  39.     hgt = opbox_GetHeight(boxp) / fh;
  40.  
  41.     /* Top line */
  42.     ptd_DrawPixCharLine(ptd, boxp->xmin, boxp->ymin + fh, FALSE, boxchar, font, attr, wid);
  43.  
  44.     /* Bottom line */
  45.     linechar[0] = boxchar[6];
  46.     linechar[1] = boxchar[5];
  47.     linechar[2] = boxchar[4];
  48.     ptd_DrawPixCharLine(ptd, boxp->xmin, boxp->ymax, FALSE, linechar, font, attr, wid);
  49.  
  50.     if (hgt > 2) {
  51.         /* Left line */
  52.         linechar[0] = linechar[1] = linechar[2] = boxchar[7];
  53.         ptd_DrawPixCharLine(ptd, boxp->xmin, boxp->ymin + 2*fh, TRUE, linechar, font, attr, hgt-2);
  54.  
  55.         /* Right line */
  56.         linechar[0] = linechar[1] = linechar[2] = boxchar[3];
  57.         ptd_DrawPixCharLine(ptd, boxp->xmax - fw, boxp->ymin + 2*fh, TRUE, linechar, font, attr, hgt-2);
  58.     }
  59. }
  60. /* -------------------------------------------------------------------------- */
  61.  
  62. void ptd_DrawPixCharLine(
  63.     ptd_struct *ptd,
  64.     opcoord x,
  65.     opcoord y,
  66.     boolean down,
  67.     char *linechar,
  68.     ofont_type font,
  69.     byte attr,
  70.     unsigned len)
  71. {
  72.     opcoord fw, fh;
  73.     ofont_type tfont;
  74.  
  75.     if (font == NULL) {
  76.         return;
  77.     }
  78.     fw = ofont_GetWidth(font);
  79.     fh = ofont_GetHeight(font);
  80.  
  81.     /* Save and poke ptd win font */
  82.     tfont = win_GetFont(ptd->win);
  83.     win_setfontptr(ptd->win, font);
  84.  
  85.     if (!down) {    /* Horizontal line */
  86.         if (len > 0) {
  87.             ptd_PlotChar(ptd, x, y, linechar[0], attr, 1);
  88.         }
  89.         if (len > 1) {
  90.             ptd_PlotChar(ptd, x+fw*(len-1), y, linechar[2], attr, 1);
  91.         }
  92.         if (len > 2) {
  93.             ptd_PlotChar(ptd, x+fw, y, linechar[1], attr, len-2);
  94.         }
  95.     }
  96.     else {            /* Vertical line */
  97.         if (len > 0) {
  98.             ptd_PlotChar(ptd, x, y, linechar[0], attr, 1);
  99.         }
  100.         if (len > 1) {
  101.             ptd_PlotChar(ptd, x, y+fh*(len-1), linechar[2], attr, 1);
  102.         }
  103.         if (len > 2) {
  104.             for (len -= 2; len != 0; len--) {
  105.                 y += fh;
  106.                 ptd_PlotChar(ptd, x, y, linechar[1], attr, 1);
  107.             }
  108.         }
  109.     }
  110.     /* Restore win font */
  111.     win_setfontptr(ptd->win, tfont);
  112. }
  113. /* -------------------------------------------------------------------------- */
  114.  
  115.