home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / BORDOUT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  3.3 KB  |  125 lines

  1. /*
  2.     bordout.c    5/20/89
  3.  
  4.     % Border Outline draw routines
  5.     By JMD
  6.  
  7.     OWL 1.1
  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.  
  19. #include "oakhead.h"
  20. #include "disppriv.h"
  21. #include "bordobj.h"
  22.  
  23. OSTATIC void OWLPRIV outline_round(_arg3(opbox *rectboxp, win_type win, ocbox *cboxp));
  24. /* -------------------------------------------------------------------------- */
  25.  
  26. #define OUTER_BOX    "\332\304\277\263\331\304\300\263"
  27.  
  28. void bord_DrawOutline(win, rectboxp)
  29.     win_type win;
  30.     opbox *rectboxp;
  31. /*
  32.     Draws a box directly to the display
  33.     Used for moving windows.
  34. */
  35. {
  36.     ptd_struct    ptds;
  37.     opbox        relbox;
  38.     ocbox        cbox;
  39.  
  40.     /* Create our own ptd, as big as the display */
  41.     ptds.win = disp_GetDispWin();
  42.     ptds.emsgdata = NULL;
  43.     ptds.relboxp = &relbox;
  44.  
  45.     win_GetPixBox(ptds.win, ptds.relboxp);
  46.  
  47.     /* Draw the outline */
  48.     outline_round(rectboxp, win, &cbox);
  49.  
  50.     disp_HideMouse();
  51.     ptd_DrawCharBox(&ptds, OUTER_BOX, &cbox, win_GetAttr(win));
  52.     disp_ShowMouse();
  53. }
  54. /* -------------------------------------------------------------------------- */
  55.  
  56. void bord_EraseOutline(win, rectboxp)
  57.     win_type win;
  58.     opbox *rectboxp;
  59. /*
  60.     Erases a border outline.
  61.     Used for moving windows.
  62. */
  63. {
  64.      opbox    pbox, dbox;
  65.     ocbox    cbox;
  66.     int     fw, fh;
  67.  
  68.     /* round rectbox to character grid by converting from pix to char coords */
  69.     /*  and back again (into pbox). */
  70.     outline_round(rectboxp, win, &cbox);
  71.     ocbox_pixcoords(&cbox, win_GetFont(win), &pbox);
  72.  
  73.     /* repaint afflicted area */
  74.  
  75.     fw = win_GetFontWidth(win);
  76.     fh = win_GetFontHeight(win);
  77.  
  78.      /* restore four strips */
  79.     wmgr_PaintPixBox((curr_dmgr)->wmgr.bot_sys_win,
  80.         opbox_set(&dbox, pbox.xmin, pbox.ymin, pbox.xmax, pbox.ymin + fh));
  81.  
  82.     wmgr_PaintPixBox((curr_dmgr)->wmgr.bot_sys_win,
  83.         opbox_set(&dbox, pbox.xmin, pbox.ymax - fh, pbox.xmax, pbox.ymax));
  84.  
  85.     pbox.ymin += fh;
  86.     pbox.ymax -= fh;
  87.  
  88.     wmgr_PaintPixBox((curr_dmgr)->wmgr.bot_sys_win,
  89.         opbox_set(&dbox, pbox.xmin, pbox.ymin, pbox.xmin + fw, pbox.ymax));
  90.  
  91.     wmgr_PaintPixBox((curr_dmgr)->wmgr.bot_sys_win,
  92.         opbox_set(&dbox, pbox.xmax - fw, pbox.ymin, pbox.xmax, pbox.ymax));
  93. }
  94. /* -------------------------------------------------------------------------- */
  95.  
  96. static void OWLPRIV outline_round(rectboxp, win, cboxp)
  97.     opbox *rectboxp;
  98.     win_type win;
  99.     ocbox *cboxp;
  100. /*
  101.     Round the coordinates for a character-width border to the right positions.
  102. */
  103. {
  104.     opbox rbox;
  105.  
  106.     rbox.xmin = rectboxp->xmin;
  107.     rbox.ymin = rectboxp->ymin;
  108.     rbox.xmax = opbox_GetWidth(rectboxp);
  109.     rbox.ymax = opbox_GetHeight(rectboxp);
  110.  
  111.     if (!disp_TextFree()) {
  112.         opcoord_GridRound(&rbox.xmin, &rbox.ymin, win_GetFont(win));
  113.     }
  114.     if (!disp_TextFree() || win_IsCharSize(win)) {
  115.         rbox.xmax += win_GetFontWidth(win) - 1;    /* Round up instead of down */
  116.         rbox.ymax += win_GetFontHeight(win) - 1;
  117.         opcoord_GridRound(&rbox.xmax, &rbox.ymax, win_GetFont(win));
  118.     }
  119.     rbox.xmax += rbox.xmin;
  120.     rbox.ymax += rbox.ymin;
  121.     opbox_charcoords(&rbox, win_GetFont(win), cboxp);
  122. }
  123. /* -------------------------------------------------------------------------- */
  124.  
  125.