… | |
… | |
30 | #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) |
30 | #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) |
31 | #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) |
31 | #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) |
32 | #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) |
32 | #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) |
33 | |
33 | |
34 | enum sb_state { |
34 | enum sb_state { |
35 | STATE_OFF, |
35 | SB_STATE_OFF, |
36 | STATE_IDLE, |
36 | SB_STATE_IDLE, |
37 | STATE_MOTION, |
37 | SB_STATE_MOTION, |
38 | STATE_UP, |
38 | SB_STATE_UP, |
39 | STATE_DOWN, |
39 | SB_STATE_DOWN, |
40 | }; |
40 | }; |
41 | |
41 | |
42 | enum sb_style { |
42 | enum sb_style { |
43 | R_SB_NEXT = 1, |
43 | SB_STYLE_NEXT = 1, |
44 | R_SB_XTERM = 2, |
44 | SB_STYLE_XTERM = 2, |
45 | R_SB_PLAIN = 4, |
45 | SB_STYLE_PLAIN = 4, |
46 | R_SB_RXVT = 8, |
46 | SB_STYLE_RXVT = 8, |
47 | }; |
47 | }; |
48 | |
48 | |
49 | enum sb_align { |
49 | enum sb_align { |
50 | R_SB_ALIGN_CENTRE, |
50 | SB_ALIGN_CENTRE, |
51 | R_SB_ALIGN_TOP, |
51 | SB_ALIGN_TOP, |
52 | R_SB_ALIGN_BOTTOM, |
52 | SB_ALIGN_BOTTOM, |
53 | }; |
53 | }; |
54 | |
54 | |
55 | struct scrollBar_t |
55 | struct scrollBar_t |
56 | { |
56 | { |
57 | rxvt_term *term; |
57 | rxvt_term *term; |
… | |
… | |
71 | Window win; |
71 | Window win; |
72 | Cursor leftptr_cursor; |
72 | Cursor leftptr_cursor; |
73 | int (scrollBar_t::*update)(int); |
73 | int (scrollBar_t::*update)(int); |
74 | void setup (rxvt_term *); |
74 | void setup (rxvt_term *); |
75 | void resize (); |
75 | void resize (); |
76 | int map (int); |
76 | void map (int); |
77 | int show (int); |
77 | int show (int); |
78 | void destroy (); |
78 | void destroy (); |
79 | |
79 | |
80 | bool upButton (int y) |
80 | bool upButton (int y) |
81 | { |
81 | { |
82 | if (style == R_SB_NEXT) |
82 | if (style == SB_STYLE_NEXT) |
83 | return y > end && y <= end + width + 1; |
83 | return y > end && y <= end + width + 1; |
84 | if (style == R_SB_RXVT) |
84 | if (style == SB_STYLE_RXVT) |
85 | return y < beg; |
85 | return y < beg; |
86 | return false; |
86 | return false; |
87 | } |
87 | } |
88 | bool dnButton (int y) |
88 | bool dnButton (int y) |
89 | { |
89 | { |
90 | if (style == R_SB_NEXT) |
90 | if (style == SB_STYLE_NEXT) |
91 | return y > end + width + 1; |
91 | return y > end + width + 1; |
92 | if (style == R_SB_RXVT) |
92 | if (style == SB_STYLE_RXVT) |
93 | return y > end; |
93 | return y > end; |
94 | return false; |
94 | return false; |
95 | } |
95 | } |
96 | int min_height () |
96 | int min_height () |
97 | { |
97 | { |
98 | return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10; |
98 | return style == SB_STYLE_NEXT ? SB_THUMB_MIN_HEIGHT : 10; |
99 | } |
99 | } |
100 | int size () |
100 | int size () |
101 | { |
101 | { |
102 | return max (end - beg - min_height (), 0); |
102 | return max (end - beg - min_height (), 0); |
103 | } |
103 | } |