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

  1. /*
  2.     bordgvtb.c   2/87    
  3.     
  4.     % border_GetVtBar
  5.  
  6.     OWL 1.2
  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.      3/16/90 jmd    preened
  18.      3/28/90 jmd    ansi-fied
  19. */
  20.  
  21. #include "oakhead.h"
  22. #include "disppriv.h"
  23. #include "bordobj.h"
  24.  
  25. void bord_GetVtBar(win_type win, int *top, int *bot, boolean *up, boolean *down)
  26. /*
  27.     Get vertical scroll bar info for a border.
  28.     The top and bottom rows of the bar (in border coords) are passed
  29.     in top and bot.  The top and bottom of the scrollbar 'elevator' are
  30.     returned in top and bot.
  31. */
  32. {
  33.     inposdata_struct inpos;
  34.     int eltop, elbot, elhgt;
  35.     int barhgt;
  36.     opcoord inhgt;
  37.  
  38.     if (win == NULL) {
  39.         *up = FALSE;
  40.         *down = FALSE;
  41.         return;
  42.     }
  43.     inpos.win = win;
  44.     win_Do(win, WINM_GETINPOS, NULL, &inpos);
  45.  
  46.     *up = (inpos.inbox.ymin < 0);
  47.     *down = (inpos.inbox.ymax > win_GetPixHeight(win));
  48.  
  49.     if (!(*up) && !(*down)) {
  50.         return;
  51.     }
  52.  
  53.     barhgt = *bot - *top + 1;
  54.     if (barhgt <= 1) {
  55.         return;
  56.     }
  57.  
  58.     inhgt = opbox_GetHeight(&inpos.inbox);
  59.     if (inhgt <= 0) {
  60.         return;
  61.     }
  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) {
  79.         eltop = *top;
  80.     }
  81.     else if (eltop > *bot) {
  82.         eltop = *bot;
  83.     }
  84.  
  85.     if (elbot < *top) {
  86.         elbot = *top;
  87.     }
  88.     else if (elbot > *bot) {
  89.         elbot = *bot;
  90.     }
  91.  
  92.     *top = eltop;
  93.     *bot = elbot;
  94. }
  95. /* -------------------------------------------------------------------------- */
  96.  
  97.