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

  1. /*
  2.     bordssds.c
  3.  
  4.     % bord_SetSides
  5.  
  6.     2/87 by jmd
  7.  
  8.     OWL 1.2
  9.     Copyright (c) 1987, 1988, 1989 by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.     10/31/88 Ted    Removed linking.
  15.      5/28/89 jmd    added Shadow support
  16.      8/10/89 ted    Moved Shadow support to winexpos.
  17.      9/27/89 ted    Added bord_GetSides funcs.
  18.  
  19.     12/02/89 ted    Made bord_GetSides a macro to bord_getfwhsides.
  20.     12/10/89 jmd    made win_GetBorder macro
  21.      3/28/90 jmd    ansi-fied
  22. */
  23.  
  24. #include "oakhead.h"
  25. #include "disppriv.h"
  26. #include "bordobj.h"
  27. /* -------------------------------------------------------------------------- */
  28.  
  29. void bord_SetSides(win_type win, int topoffs, int leftoffs, int botoffs, int rightoffs)
  30. /*
  31.     Sets the relative sides of the border.
  32.     Should be called when border is opened and when
  33.     a SETSIZE message is received.
  34. */
  35. {
  36.     opcoord fw, fh;
  37.  
  38.     fw = win_GetFontWidth(win);
  39.     fh = win_GetFontHeight(win);
  40.  
  41.     bord_SetPixSides(win, (opcoord) leftoffs*fw, (opcoord) topoffs*fh,
  42.                           (opcoord) rightoffs*fw, (opcoord) botoffs*fh);
  43. }
  44. /* -------------------------------------------------------------------------- */
  45.  
  46. void bord_SetPixSides(win_type win, opcoord xminoffs, opcoord yminoffs, opcoord xmaxoffs, opcoord ymaxoffs)
  47. /*
  48.     Sets the relative sides of the border.
  49.     Should be called when border is opened and when SETSIZE message is received.
  50. */
  51. {
  52.     opcoord winx, winy, winw, winh;
  53.  
  54.     winx = win_GetXmin(win);
  55.     winy = win_GetYmin(win);
  56.  
  57.     winw = win_GetPixWidth(win);
  58.     winh = win_GetPixHeight(win);
  59.  
  60.     win_inboxp(win)->xmin = -xminoffs;
  61.     win_inboxp(win)->ymin = -yminoffs;
  62.  
  63.     win_ReallySetPixPosition(win, winx, winy);
  64.  
  65.     win_inboxp(win)->xmax = opbox_GetWidth(win_pixboxp(win)) - xmaxoffs;
  66.     win_inboxp(win)->ymax = opbox_GetHeight(win_pixboxp(win)) - ymaxoffs;
  67.  
  68.     win_ReallySetPixSize(win, winw, winh);
  69. }
  70. /* -------------------------------------------------------------------------- */
  71.  
  72. boolean bord_getfwhsides(win_type win, opcoord fw, opcoord fh, int *topoffsp, int *leftoffsp, int *botoffsp, int *rightoffsp)
  73. {
  74.     opcoord xminoffs, yminoffs, xmaxoffs, ymaxoffs;
  75.  
  76.     if (bord_GetPixSides(win, &xminoffs, &yminoffs, &xmaxoffs, &ymaxoffs)) {
  77.  
  78.         *topoffsp    = -((-yminoffs) / fh);
  79.         *botoffsp    = ymaxoffs / fh;
  80.         *leftoffsp    = -((-xminoffs) / fw);
  81.         *rightoffsp    = xmaxoffs / fw;
  82.  
  83.         return(TRUE);
  84.     }
  85.     else return(FALSE);
  86. }
  87. /* -------------------------------------------------------------------------- */
  88.  
  89. boolean bord_GetPixSides(win_type win, opcoord *xminoffsp, opcoord *yminoffsp, opcoord *xmaxoffsp, opcoord *ymaxoffsp)
  90. {
  91.     *xminoffsp = -win_inboxp(win)->xmin;
  92.     *yminoffsp = -win_inboxp(win)->ymin;
  93.  
  94.     *xmaxoffsp = opbox_GetWidth(win_pixboxp(win)) - win_inboxp(win)->xmax;
  95.     *ymaxoffsp = opbox_GetHeight(win_pixboxp(win)) - win_inboxp(win)->ymax;
  96.  
  97.     return(win_GetBorder(win) != NULL);
  98. }
  99. /* -------------------------------------------------------------------------- */
  100.  
  101.