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

  1. /*
  2.     bordgvtb.c   2/87    
  3.     
  4.     % border_GetVtBar
  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.      9/06/89 ted    jdc and I made eltop & elhgt calcs use long math.
  16. */
  17.  
  18. #include "oakhead.h"
  19. #include "disppriv.h"
  20. #include "bordobj.h"
  21.  
  22. void bord_GetVtBar(win, top, bot, up, down)
  23.     win_type win;
  24.     int *top;
  25.     int *bot;
  26.     boolean *up;
  27.     boolean *down;
  28. /*
  29.     Get vertical scroll bar info for a border.
  30.     The top and bottom rows of the bar (in border coords) are passed
  31.     in top and bot.  The top and bottom of the scrollbar 'elevator' are
  32.     returned in top and bot.
  33. */
  34. {
  35.     inposdata_struct inpos;
  36.     int eltop, elbot, elhgt;
  37.     int barhgt;
  38.     opcoord inhgt;
  39.  
  40.     if (win == NULL) {
  41.         *up = FALSE;
  42.         *down = FALSE;
  43.         return;
  44.     }
  45.     inpos.win = win;
  46.     win_Do(win, WINM_GETINPOS, NULL, &inpos);
  47.  
  48.     *up = (inpos.inbox.ymin < 0);
  49.     *down = (inpos.inbox.ymax > win_GetPixHeight(win));
  50.  
  51.     if (!(*up) && !(*down)) {
  52.         return;
  53.     }
  54.  
  55.     barhgt = *bot - *top + 1;
  56.     if (barhgt <= 1) {
  57.         return;
  58.     }
  59.     inhgt = opbox_GetHeight(&inpos.inbox);
  60.     if (inhgt <= 0) {
  61.         return;
  62.     }
  63.     eltop = (int)((long) ((long) barhgt * (long)(0 - inpos.inbox.ymin) + inhgt/2) / inhgt);
  64.     eltop += *top;
  65.  
  66.     elhgt = (int)((long) ((long) barhgt * (long) win_GetPixHeight(win) + inhgt/2) / inhgt);
  67.     if (elhgt <= 0) {
  68.         elhgt = 1;
  69.     }
  70.     elbot = eltop + elhgt - 1;
  71.  
  72.     if (win_GetPixHeight(win) <= inpos.inbox.ymax &&
  73.         elbot > *bot) {
  74.         eltop -= elbot - *bot;
  75.         elbot = *bot;
  76.     }
  77.  
  78.     if (eltop < *top) eltop = *top;
  79.     else if (eltop > *bot) eltop = *bot;
  80.  
  81.     if (elbot < *top) elbot = *top;
  82.     else if (elbot > *bot) elbot = *bot;
  83.  
  84.     *top = eltop;
  85.     *bot = elbot;
  86. }
  87. /* -------------------------------------------------------------------------- */
  88.  
  89.