14
static void sbDraw(newtComponent co);
15
static void sbDestroy(newtComponent co);
16
static void sbDrawThumb(newtComponent co, int isOn);
18
static struct componentOps sbOps = {
20
newtDefaultEventHandler,
22
newtDefaultPlaceHandler,
23
newtDefaultMappedHandler,
26
void newtScrollbarSet(newtComponent co, int where, int total) {
27
struct scrollbar * sb = co->data;
31
new = (where * (co->height - 3)) / (total ? total : 1) + 1;
33
new = (where * (co->height - 1)) / (total ? total : 1);
34
if (new != sb->curr) {
41
newtComponent newtVerticalScrollbar(int left, int top, int height,
42
int normalColorset, int thumbColorset) {
44
struct scrollbar * sb;
46
co = malloc(sizeof(*co));
47
sb = malloc(sizeof(*sb));
50
if (!strcmp(getenv("TERM"), "linux") && height >= 2) {
57
sb->cs = normalColorset;
58
sb->csThumb = thumbColorset;
71
static void sbDraw(newtComponent co) {
72
struct scrollbar * sb = co->data;
75
if (!co->isMapped) return;
79
SLsmg_set_char_set(1);
81
newtGotorc(co->top, co->left);
82
SLsmg_write_char('\x2d');
83
for (i = 1; i < co->height - 1; i++) {
84
newtGotorc(i + co->top, co->left);
85
SLsmg_write_char('\x61');
87
newtGotorc(co->top + co->height - 1, co->left);
88
SLsmg_write_char('\x2e');
90
for (i = 0; i < co->height; i++) {
91
newtGotorc(i + co->top, co->left);
92
SLsmg_write_char('\x61');
96
SLsmg_set_char_set(0);
101
static void sbDrawThumb(newtComponent co, int isOn) {
102
struct scrollbar * sb = co->data;
103
char ch = isOn ? '#' : '\x61';
105
if (!co->isMapped) return;
107
newtGotorc(sb->curr + co->top, co->left);
108
SLsmg_set_char_set(1);
111
newtColor(sb->csThumb);
115
SLsmg_write_char(ch);
116
SLsmg_set_char_set(0);
119
static void sbDestroy(newtComponent co) {
120
struct scrollbar * sb = co->data;