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

  1. /*
  2.     bordghzb.c   2/87    
  3.     
  4.     % border_GetHzBar
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1986, 1987, 1988, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.     11/08/88 ted    Changed to new non-window border scheme
  13.     12/18/88 jdc    Fixed calculation error
  14.     12/20/88 ted    Converted to integer math.
  15. */
  16.  
  17. #include "oakhead.h"
  18. #include "disppriv.h"
  19. #include "bordobj.h"
  20.  
  21. void bord_GetHzBar(win, lend, rend, left, right)
  22.     win_type win;
  23.     int *lend;
  24.     int *rend;
  25.     boolean *left;
  26.     boolean *right;
  27. /*
  28.     Get horizontal scroll bar info for a border.
  29.     The left and right end cols of the bar are passed
  30.     in lend and rend.  The left and right ends of the scrollbar 'elevator'
  31.     are returned in lend and rend.
  32. */
  33. {
  34.     inposdata_struct inpos;
  35.     int ellend, elrend, elwid;
  36.     int barwid;
  37.     opcoord inwid;
  38.  
  39.     if (win == NULL) {
  40.         *left = FALSE;
  41.         *right = FALSE;
  42.         return;
  43.     }
  44.     inpos.win = win;
  45.     win_Do(win, WINM_GETINPOS, NULL, &inpos);
  46.  
  47.     *left = (inpos.inbox.xmin < 0);
  48.     *right = (inpos.inbox.xmax > win_GetPixWidth(win));
  49.  
  50.     if (!(*left) && !(*right)) {
  51.         return;
  52.     }
  53.  
  54.     barwid = *rend - *lend + 1;
  55.     if (barwid <= 1) {
  56.         return;
  57.     }
  58.     inwid = opbox_GetWidth(&inpos.inbox);
  59.     if (inwid <= 0) {
  60.         return;
  61.     }
  62.     ellend = (barwid * (0 - inpos.inbox.xmin) + inwid/2) /
  63.                 inwid;
  64.     ellend += *lend;
  65.  
  66.     elwid = (barwid * win_GetPixWidth(win) + inwid/2) /
  67.                 inwid;
  68.     if (elwid <= 0) {
  69.         elwid = 1;
  70.     }
  71.     elrend = ellend + elwid - 1;
  72.  
  73.     if (win_GetPixWidth(win) <= inpos.inbox.xmax &&
  74.         elrend > *rend) {
  75.         ellend -= elrend - *rend;
  76.         elrend = *rend;
  77.     }
  78.  
  79.     if (ellend < *lend) ellend = *lend;
  80.     else if (ellend > *rend) ellend = *rend;
  81.  
  82.     if (elrend < *lend) elrend = *lend;
  83.     else if (elrend > *rend) elrend = *rend;
  84.  
  85.     *lend = ellend;
  86.     *rend = elrend;
  87. }
  88. /* -------------------------------------------------------------------------- */
  89.  
  90.