… | |
… | |
3 | |
3 | |
4 | #include <X11/Xlib.h> |
4 | #include <X11/Xlib.h> |
5 | |
5 | |
6 | struct rxvt_term; |
6 | struct rxvt_term; |
7 | |
7 | |
8 | typedef struct { |
8 | #define R_SB_NEXT 1 |
|
|
9 | #define R_SB_XTERM 2 |
|
|
10 | #define R_SB_PLAIN 4 |
|
|
11 | #define R_SB_RXVT 8 |
|
|
12 | |
|
|
13 | struct scrollBar_t { |
9 | char state; /* scrollbar state */ |
14 | char state; /* scrollbar state */ |
10 | char init; /* scrollbar has been initialised */ |
15 | char init; /* scrollbar has been initialised */ |
11 | unsigned int beg; /* slider sub-window begin height */ |
16 | unsigned int beg; /* slider sub-window begin height */ |
12 | unsigned int end; /* slider sub-window end height */ |
17 | unsigned int end; /* slider sub-window end height */ |
13 | unsigned int top; /* slider top position */ |
18 | unsigned int top; /* slider top position */ |
… | |
… | |
26 | |
31 | |
27 | void setIdle() { state = 1 ; } |
32 | void setIdle() { state = 1 ; } |
28 | void setMotion() { state = 'm'; } |
33 | void setMotion() { state = 'm'; } |
29 | void setUp() { state = 'U'; } |
34 | void setUp() { state = 'U'; } |
30 | void setDn() { state = 'D'; } |
35 | void setDn() { state = 'D'; } |
31 | } scrollBar_t; |
36 | |
|
|
37 | bool upButton (int y) |
|
|
38 | { |
|
|
39 | if (style == R_SB_NEXT) |
|
|
40 | return y > end && y <= end + width + 1; |
|
|
41 | if (style == R_SB_RXVT) |
|
|
42 | return y < beg; |
|
|
43 | return false; |
|
|
44 | } |
|
|
45 | bool dnButton (int y) |
|
|
46 | { |
|
|
47 | if (style == R_SB_NEXT) |
|
|
48 | return y > end + width + 1; |
|
|
49 | if (style == R_SB_RXVT) |
|
|
50 | return y > end; |
|
|
51 | return false; |
|
|
52 | } |
|
|
53 | }; |
32 | |
54 | |
33 | #define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2) |
55 | #define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2) |
34 | #define scrollbar_isMotion() (scrollBar.state == 'm') |
56 | #define scrollbar_isMotion() (scrollBar.state == 'm') |
35 | #define scrollbar_isUp() (scrollBar.state == 'U') |
57 | #define scrollbar_isUp() (scrollBar.state == 'U') |
36 | #define scrollbar_isDn() (scrollBar.state == 'D') |
58 | #define scrollbar_isDn() (scrollBar.state == 'D') |
37 | #define scrollbar_isUpDn() (scrollbar_isUp () || scrollbar_isDn ()) |
59 | #define scrollbar_isUpDn() (scrollbar_isUp () || scrollbar_isDn ()) |
38 | |
60 | |
39 | #define scrollbarnext_dnval() (scrollBar.end + (scrollBar.width + 1)) |
|
|
40 | #define scrollbarnext_upButton(y) ((y) > scrollBar.end \ |
|
|
41 | && (y) <= scrollbarnext_dnval ()) |
|
|
42 | #define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval()) |
|
|
43 | #define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT |
61 | #define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT |
44 | #define scrollbarrxvt_upButton(y) ((y) < scrollBar.beg) |
|
|
45 | #define scrollbarrxvt_dnButton(y) ((y) > scrollBar.end) |
|
|
46 | #define SCROLLRXVT_MINHEIGHT 10 |
62 | #define SCROLLRXVT_MINHEIGHT 10 |
47 | |
63 | |
48 | #define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \ |
64 | #define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \ |
49 | ? SCROLLNEXT_MINHEIGHT \ |
65 | ? SCROLLNEXT_MINHEIGHT \ |
50 | : SCROLLRXVT_MINHEIGHT) |
66 | : SCROLLRXVT_MINHEIGHT) |
… | |
… | |
55 | - scrollbar_minheight ()) |
71 | - scrollbar_minheight ()) |
56 | |
72 | |
57 | #define R_SB_ALIGN_CENTRE 0 |
73 | #define R_SB_ALIGN_CENTRE 0 |
58 | #define R_SB_ALIGN_TOP 1 |
74 | #define R_SB_ALIGN_TOP 1 |
59 | #define R_SB_ALIGN_BOTTOM 2 |
75 | #define R_SB_ALIGN_BOTTOM 2 |
60 | |
|
|
61 | #define R_SB_NEXT 1 |
|
|
62 | #define R_SB_XTERM 2 |
|
|
63 | #define R_SB_PLAIN 4 |
|
|
64 | #define R_SB_RXVT 8 |
|
|
65 | |
76 | |
66 | #define SB_WIDTH_NEXT 19 |
77 | #define SB_WIDTH_NEXT 19 |
67 | #define SB_WIDTH_XTERM 15 |
78 | #define SB_WIDTH_XTERM 15 |
68 | #define SB_WIDTH_PLAIN 7 |
79 | #define SB_WIDTH_PLAIN 7 |
69 | #ifndef SB_WIDTH_RXVT |
80 | #ifndef SB_WIDTH_RXVT |