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

  1. /*
  2.     bordout.c    5/20/89
  3.  
  4.     % Border Outline draw routines
  5.     By JMD
  6.  
  7.     OWL 1.2
  8.     Copyright (c) 1989, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     Revision History:
  12.     -----------------
  13.      5/23/89 jmd    added "border features"
  14.      7/06/89 ted    Got rid of compiler warnings in EraseOutline.
  15.      7/06/89 ted    Fixed char-grid rounding.
  16.      8/26/89 jmd    Made bord_out routines public
  17.  
  18.     12/03/89 ted    Diddled with outline_round to make it use pix coords.
  19.     12/04/89 jmd    added replaceable outline function
  20.      3/13/90 ted    Added call to ptd_DrawPixCharBox to fix pixel coords bug.
  21.      3/28/90 jmd    ansi-fied
  22.      2/01/90 pmcm    added _SavePixBox to draw function for using over grwins
  23.      8/30/90 ted    changed (curr_dmgr)->wmgr. references to wmgr_ macro calls.
  24.     10/03/90 pmcm    added cache and flush to bord_EraseOutline and _DrawOutline
  25. */
  26.  
  27. #include "oakhead.h"
  28. #include "disppriv.h"
  29. #include "bordobj.h"
  30.  
  31. OGLOBAL bordout_fptr bord_drawoutfunc = FNULL;
  32.  
  33. OSTATIC void OWLPRIV outline_round(opbox *rectboxp, win_type win, opbox *rboxp);
  34. /* -------------------------------------------------------------------------- */
  35.  
  36. #define OUTER_BOX    "\332\304\277\263\331\304\300\263"
  37.  
  38. void bord_DrawOutline(win_type win, opbox *rectboxp)
  39. /*
  40.     Draws a box directly to the display
  41.     Used for moving windows.
  42.     Calls bord_drawoutfunc to draw the border outline.
  43.     If no draw func draws a character box.
  44. */
  45. {
  46.     ptd_struct    ptds;
  47.     opbox        relbox, pbox;
  48.  
  49.     /* Create our own ptd, as big as the display */
  50.     ptds.win = disp_GetDispWin();
  51.     ptds.emsgdata = NULL;
  52.     ptds.relboxp = &relbox;
  53.  
  54.     win_GetPixBox(ptds.win, ptds.relboxp);
  55.  
  56.     outline_round(rectboxp, win, &pbox);
  57.  
  58.     disp_HideMouse();
  59.     disp_Cache();
  60.  
  61.     /* Save the layer we are about to obscure */
  62.     wmgr_SavePixBox(wmgr_botsyswin(), &pbox);
  63.  
  64.     /* Draw the outline */
  65.     if (bord_drawoutfunc == FNULL || !(*bord_drawoutfunc)(&ptds, win, &pbox)) {
  66.         /* if no draw func, or if it fails, draw a char box */
  67.         ptd_DrawPixCharBox(&ptds, &pbox, OUTER_BOX, win_GetFont(win), win_GetAttr(win));
  68.     }
  69.     disp_Flush();
  70.     disp_ShowMouse();
  71. }
  72. /* -------------------------------------------------------------------------- */
  73.  
  74. void bord_EraseOutline(win_type win, opbox *rectboxp)
  75. /*
  76.     Erases a border outline.
  77.     Used for moving windows.
  78. */
  79. {
  80.      opbox    pbox, dbox;
  81.     opcoord    fw, fh;
  82.  
  83.     /* round rectbox to character grid by converting from pix to char coords */
  84.     /*  and back again (into pbox). */
  85.     outline_round(rectboxp, win, &pbox);
  86.  
  87.     /* repaint afflicted area */
  88.  
  89.     fw = win_GetFontWidth(win);
  90.     fh = win_GetFontHeight(win);
  91.  
  92.     disp_Cache();
  93.  
  94.      /* restore four strips */
  95.     wmgr_PaintPixBox(wmgr_botsyswin(),
  96.         opbox_set(&dbox, pbox.xmin, pbox.ymin, pbox.xmax, pbox.ymin + fh));
  97.  
  98.     wmgr_PaintPixBox(wmgr_botsyswin(),
  99.         opbox_set(&dbox, pbox.xmin, pbox.ymax - fh, pbox.xmax, pbox.ymax));
  100.  
  101.     pbox.ymin += fh;
  102.     pbox.ymax -= fh;
  103.  
  104.     wmgr_PaintPixBox(wmgr_botsyswin(),
  105.         opbox_set(&dbox, pbox.xmin, pbox.ymin, pbox.xmin + fw, pbox.ymax));
  106.  
  107.     wmgr_PaintPixBox(wmgr_botsyswin(),
  108.         opbox_set(&dbox, pbox.xmax - fw, pbox.ymin, pbox.xmax, pbox.ymax));
  109.  
  110.     disp_Flush();
  111. }
  112. /* -------------------------------------------------------------------------- */
  113.  
  114. static void OWLPRIV outline_round(opbox *rectboxp, win_type win, opbox *rboxp)
  115. /*
  116.     Round the coordinates for a character-width border to the right positions.
  117. */
  118. {
  119.     rboxp->xmin = rectboxp->xmin;
  120.     rboxp->ymin = rectboxp->ymin;
  121.     rboxp->xmax = opbox_GetWidth(rectboxp);
  122.     rboxp->ymax = opbox_GetHeight(rectboxp);
  123.  
  124.     if (!disp_TextFree()) {
  125.         opcoord_GridRound(&rboxp->xmin, &rboxp->ymin, win_GetFont(win));
  126.     }
  127.     if (!disp_TextFree() || win_IsCharSize(win)) {
  128.         rboxp->xmax += win_GetFontWidth(win) - 1;    /* Round up instead of down */
  129.         rboxp->ymax += win_GetFontHeight(win) - 1;
  130.         opcoord_GridRound(&rboxp->xmax, &rboxp->ymax, win_GetFont(win));
  131.     }
  132.     rboxp->xmax += rboxp->xmin;
  133.     rboxp->ymax += rboxp->ymin;
  134. }
  135. /* -------------------------------------------------------------------------- */
  136.  
  137.