home *** CD-ROM | disk | FTP | other *** search
- /*
- bordgvtb.c 2/87
-
- % border_GetVtBar
-
- OWL 1.1
- Copyright (c) 1986, 1987, 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 11/08/88 ted Changed to new non-window border scheme
- 12/18/88 jdc Fixed calculation error
- 12/20/88 ted Converted to integer math.
- 9/06/89 ted jdc and I made eltop & elhgt calcs use long math.
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "bordobj.h"
-
- void bord_GetVtBar(win, top, bot, up, down)
- win_type win;
- int *top;
- int *bot;
- boolean *up;
- boolean *down;
- /*
- Get vertical scroll bar info for a border.
- The top and bottom rows of the bar (in border coords) are passed
- in top and bot. The top and bottom of the scrollbar 'elevator' are
- returned in top and bot.
- */
- {
- inposdata_struct inpos;
- int eltop, elbot, elhgt;
- int barhgt;
- opcoord inhgt;
-
- if (win == NULL) {
- *up = FALSE;
- *down = FALSE;
- return;
- }
- inpos.win = win;
- win_Do(win, WINM_GETINPOS, NULL, &inpos);
-
- *up = (inpos.inbox.ymin < 0);
- *down = (inpos.inbox.ymax > win_GetPixHeight(win));
-
- if (!(*up) && !(*down)) {
- return;
- }
-
- barhgt = *bot - *top + 1;
- if (barhgt <= 1) {
- return;
- }
- inhgt = opbox_GetHeight(&inpos.inbox);
- if (inhgt <= 0) {
- return;
- }
- eltop = (int)((long) ((long) barhgt * (long)(0 - inpos.inbox.ymin) + inhgt/2) / inhgt);
- eltop += *top;
-
- elhgt = (int)((long) ((long) barhgt * (long) win_GetPixHeight(win) + inhgt/2) / inhgt);
- if (elhgt <= 0) {
- elhgt = 1;
- }
- elbot = eltop + elhgt - 1;
-
- if (win_GetPixHeight(win) <= inpos.inbox.ymax &&
- elbot > *bot) {
- eltop -= elbot - *bot;
- elbot = *bot;
- }
-
- if (eltop < *top) eltop = *top;
- else if (eltop > *bot) eltop = *bot;
-
- if (elbot < *top) elbot = *top;
- else if (elbot > *bot) elbot = *bot;
-
- *top = eltop;
- *bot = elbot;
- }
- /* -------------------------------------------------------------------------- */
-
-