|
|
1.1 ! root 1: /* ! 2: * Functions for scrollbars ! 3: * ! 4: * Copyright (c) 1992-93 by Udo Munk ! 5: */ ! 6: ! 7: #ifdef AIX ! 8: #define NLS ! 9: #endif ! 10: ! 11: #include <curses.h> ! 12: #include "winfun.h" ! 13: ! 14: extern WINDOW *open_window(); ! 15: extern void free(); ! 16: ! 17: SCROLLBAR *create_scrollbar(y, x, s) ! 18: int x, y, s; ! 19: { ! 20: register SCROLLBAR *sp; ! 21: register int i; ! 22: ! 23: if ((sp = (SCROLLBAR *) malloc(sizeof(SCROLLBAR))) == NULL) ! 24: nomem(); ! 25: if ((sp->sc_window = open_window(s, 2, y, x)) == (WINDOW *) 0) ! 26: nomem(); ! 27: sp->sc_size = s; ! 28: sp->sc_position = 1; ! 29: mvwaddch(sp->sc_window, 0, 1, u_arrow); ! 30: mvwaddch(sp->sc_window, 1, 1, fullboard); ! 31: for (i = 2; i < s -1; i++) ! 32: mvwaddch(sp->sc_window, i, 1, checkboard); ! 33: mvwaddch(sp->sc_window, s-1, 1, d_arrow); ! 34: wrefresh(sp->sc_window); ! 35: return (sp); ! 36: } ! 37: ! 38: remove_scrollbar(p) ! 39: SCROLLBAR *p; ! 40: { ! 41: close_window(p->sc_window); ! 42: free((char *) p); ! 43: } ! 44: ! 45: update_slider(s, n, p) ! 46: SCROLLBAR *s; ! 47: int n, p; ! 48: { ! 49: register int np; ! 50: ! 51: /* compute new position of the slider */ ! 52: if (p == 0) ! 53: np = 1; ! 54: else if (p == n-1) ! 55: np = s->sc_size - 2; ! 56: else ! 57: np = (s->sc_size - 2) * p / n + 1; ! 58: ! 59: /* update position of the slider */ ! 60: if (np != s->sc_position) { ! 61: mvwaddch(s->sc_window, s->sc_position, 1, checkboard); ! 62: mvwaddch(s->sc_window, np, 1, fullboard); ! 63: s->sc_position = np; ! 64: wrefresh(s->sc_window); ! 65: } ! 66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.