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

  1. /*
  2.     ptdframe.c    9/15/88
  3.  
  4.     % Map type window border clearing function.
  5.     By Ted.
  6.  
  7.     OWL 1.2
  8.     Copyright (c) 1988, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     Revision History:
  12.     -----------------
  13.     12/07/88 ted    Fixed off-by-one bug ( < vs. <= )
  14.  
  15.      3/28/90 jmd    ansi-fied
  16. */
  17.  
  18. #include "oakhead.h"
  19. #include "disppriv.h"
  20. /* -------------------------------------------------------------------------- */
  21.  
  22. void ptd_ClearFrame(ptd_struct *ptd, opcoord xoffs, opcoord yoffs, odim width, odim height, opixval color)
  23. /*
  24.     For when the window is bigger than whatever its contents are,
  25.     this function blanks out the extra area.
  26. */
  27. {
  28.     opbox tbox;
  29.     opcoord xmaxoffs, ymaxoffs;
  30.     ofont_type dfont;
  31.  
  32.     opbox_copy(&tbox, ptd->relboxp);
  33.  
  34.     xmaxoffs = xoffs + width;
  35.     ymaxoffs = yoffs + height;
  36.  
  37.     /* Round win contents inwards to char coords if appropriate */
  38.     if (!disp_TextFree()) {
  39.         dfont = disp_GetDefFont();
  40.         /* Round up instead of down */
  41.         xoffs += ofont_GetWidth(dfont) - 1;
  42.         yoffs += ofont_GetHeight(dfont) - 1;
  43.         opcoord_GridRound(&xoffs, &yoffs, dfont);
  44.         opcoord_GridRound(&xmaxoffs, &ymaxoffs, dfont);
  45.     }
  46. /* top */
  47.     if (ptd->relboxp->ymin < yoffs) {
  48.         if (ptd->relboxp->ymax > yoffs) {
  49.             ptd->relboxp->ymax = yoffs;
  50.         }
  51.         ptd_Clear(ptd, color);
  52.         ptd->relboxp->ymax = tbox.ymax;
  53.     }
  54. /* bottom */
  55.     if (ptd->relboxp->ymax > ymaxoffs) {
  56.         if (ptd->relboxp->ymin < ymaxoffs) {
  57.             ptd->relboxp->ymin = ymaxoffs;
  58.         }
  59.         ptd_Clear(ptd, color);
  60.         ptd->relboxp->ymin = tbox.ymin;
  61.     }
  62. /* don't clear corner boxes twice - truncate side strips */
  63.     if (ptd->relboxp->ymax <= yoffs ||
  64.         ptd->relboxp->ymin >= ymaxoffs) {
  65.         return;
  66.     }
  67.     if (ptd->relboxp->ymin < yoffs) {
  68.         ptd->relboxp->ymin = yoffs;
  69.     }
  70.     if (ptd->relboxp->ymax > ymaxoffs) {
  71.         ptd->relboxp->ymax = ymaxoffs;
  72.     }
  73. /* left */
  74.     if (ptd->relboxp->xmin < xoffs) {
  75.         if (ptd->relboxp->xmax > xoffs) {
  76.             ptd->relboxp->xmax = xoffs;
  77.         }
  78.         ptd_Clear(ptd, color);
  79.         ptd->relboxp->xmax = tbox.xmax;
  80.     }
  81. /* right */
  82.     if (ptd->relboxp->xmax > xmaxoffs) {
  83.         if (ptd->relboxp->xmin < xmaxoffs) {
  84.             ptd->relboxp->xmin = xmaxoffs;
  85.         }
  86.         ptd_Clear(ptd, color);
  87.         ptd->relboxp->xmin = tbox.xmin;
  88.     }
  89.     ptd->relboxp->ymin = tbox.ymin;
  90.     ptd->relboxp->ymax = tbox.ymax;
  91. }
  92. /* -------------------------------------------------------------------------- */
  93.  
  94.