… | |
… | |
2 | #define SCROLLBAR_H |
2 | #define SCROLLBAR_H |
3 | |
3 | |
4 | #include <X11/Xlib.h> |
4 | #include <X11/Xlib.h> |
5 | |
5 | |
6 | struct rxvt_term; |
6 | struct rxvt_term; |
|
|
7 | |
|
|
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 | enum sb_state { |
|
|
14 | STATE_IDLE = 1, |
|
|
15 | STATE_MOTION, |
|
|
16 | STATE_UP, |
|
|
17 | STATE_DOWN, |
|
|
18 | }; |
7 | |
19 | |
8 | struct scrollBar_t { |
20 | struct scrollBar_t { |
9 | char state; /* scrollbar state */ |
21 | char state; /* scrollbar state */ |
10 | char init; /* scrollbar has been initialised */ |
22 | char init; /* scrollbar has been initialised */ |
11 | unsigned int beg; /* slider sub-window begin height */ |
23 | unsigned int beg; /* slider sub-window begin height */ |
… | |
… | |
22 | unsigned char align; |
34 | unsigned char align; |
23 | Window win; |
35 | Window win; |
24 | Cursor leftptr_cursor; |
36 | Cursor leftptr_cursor; |
25 | int (rxvt_term::*update)(int, int, int, int); |
37 | int (rxvt_term::*update)(int, int, int, int); |
26 | |
38 | |
27 | void setIdle() { state = 1 ; } |
39 | bool upButton (int y) |
28 | void setMotion() { state = 'm'; } |
40 | { |
29 | void setUp() { state = 'U'; } |
41 | if (style == R_SB_NEXT) |
30 | void setDn() { state = 'D'; } |
42 | return y > end && y <= end + width + 1; |
|
|
43 | if (style == R_SB_RXVT) |
|
|
44 | return y < beg; |
|
|
45 | return false; |
|
|
46 | } |
|
|
47 | bool dnButton (int y) |
|
|
48 | { |
|
|
49 | if (style == R_SB_NEXT) |
|
|
50 | return y > end + width + 1; |
|
|
51 | if (style == R_SB_RXVT) |
|
|
52 | return y > end; |
|
|
53 | return false; |
|
|
54 | } |
31 | }; |
55 | }; |
32 | |
56 | |
33 | #define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2) |
57 | #define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2) |
34 | #define scrollbar_isMotion() (scrollBar.state == 'm') |
|
|
35 | #define scrollbar_isUp() (scrollBar.state == 'U') |
|
|
36 | #define scrollbar_isDn() (scrollBar.state == 'D') |
|
|
37 | #define scrollbar_isUpDn() (scrollbar_isUp () || scrollbar_isDn ()) |
|
|
38 | |
58 | |
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 |
59 | #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 |
60 | #define SCROLLRXVT_MINHEIGHT 10 |
47 | |
61 | |
48 | #define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \ |
62 | #define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \ |
49 | ? SCROLLNEXT_MINHEIGHT \ |
63 | ? SCROLLNEXT_MINHEIGHT \ |
50 | : SCROLLRXVT_MINHEIGHT) |
64 | : SCROLLRXVT_MINHEIGHT) |
… | |
… | |
55 | - scrollbar_minheight ()) |
69 | - scrollbar_minheight ()) |
56 | |
70 | |
57 | #define R_SB_ALIGN_CENTRE 0 |
71 | #define R_SB_ALIGN_CENTRE 0 |
58 | #define R_SB_ALIGN_TOP 1 |
72 | #define R_SB_ALIGN_TOP 1 |
59 | #define R_SB_ALIGN_BOTTOM 2 |
73 | #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 | |
74 | |
66 | #define SB_WIDTH_NEXT 19 |
75 | #define SB_WIDTH_NEXT 19 |
67 | #define SB_WIDTH_XTERM 15 |
76 | #define SB_WIDTH_XTERM 15 |
68 | #define SB_WIDTH_PLAIN 7 |
77 | #define SB_WIDTH_PLAIN 7 |
69 | #ifndef SB_WIDTH_RXVT |
78 | #ifndef SB_WIDTH_RXVT |