1 | #ifndef SCROLLBAR_H |
1 | #ifndef SCROLLBAR_H |
2 | #define SCROLLBAR_H |
2 | #define SCROLLBAR_H |
3 | |
3 | |
4 | #include <X11/Xlib.h> |
4 | #include <X11/Xlib.h> |
|
|
5 | #include "rxvtutil.h" |
5 | |
6 | |
6 | struct rxvt_term; |
7 | struct rxvt_term; |
7 | |
8 | |
8 | #define SB_WIDTH_NEXT 19 |
9 | #define SB_WIDTH_NEXT 19 |
9 | #define SB_WIDTH_XTERM 15 |
10 | #define SB_WIDTH_XTERM 15 |
… | |
… | |
54 | struct scrollBar_t |
55 | struct scrollBar_t |
55 | { |
56 | { |
56 | rxvt_term *term; |
57 | rxvt_term *term; |
57 | sb_state state; /* scrollbar state */ |
58 | sb_state state; /* scrollbar state */ |
58 | char init; /* scrollbar has been initialised */ |
59 | char init; /* scrollbar has been initialised */ |
59 | unsigned int beg; /* slider sub-window begin height */ |
60 | int beg; /* slider sub-window begin height */ |
60 | unsigned int end; /* slider sub-window end height */ |
61 | int end; /* slider sub-window end height */ |
61 | unsigned int top; /* slider top position */ |
62 | int top; /* slider top position */ |
62 | unsigned int bot; /* slider bottom position */ |
63 | int bot; /* slider bottom position */ |
63 | sb_style style; /* style: rxvt, xterm, next */ |
64 | sb_style style; /* style: rxvt, xterm, next */ |
64 | unsigned int width; /* scrollbar width */ |
65 | int width; /* scrollbar width */ |
65 | int shadow; /* scrollbar shadow width */ |
66 | int shadow; /* scrollbar shadow width */ |
66 | int last_bot; /* scrollbar last bottom position */ |
67 | int last_bot; /* scrollbar last bottom position */ |
67 | int last_top; /* scrollbar last top position */ |
68 | int last_top; /* scrollbar last top position */ |
68 | int last_state; /* scrollbar last state */ |
69 | int last_state; /* scrollbar last state */ |
69 | sb_align align; |
70 | sb_align align; |
70 | Window win; |
71 | Window win; |
71 | Cursor leftptr_cursor; |
72 | Cursor leftptr_cursor; |
72 | int (scrollBar_t::*update)(int); |
73 | int (scrollBar_t::*update)(int); |
73 | void setup (rxvt_term *); |
74 | void setup (rxvt_term *); |
74 | void resize (); |
75 | void resize (); |
75 | int map (int); |
76 | void map (int); |
76 | int show (int); |
77 | int show (int); |
77 | void destroy (); |
78 | void destroy (); |
78 | |
79 | |
79 | bool upButton (int y) |
80 | bool upButton (int y) |
80 | { |
81 | { |
… | |
… | |
90 | return y > end + width + 1; |
91 | return y > end + width + 1; |
91 | if (style == R_SB_RXVT) |
92 | if (style == R_SB_RXVT) |
92 | return y > end; |
93 | return y > end; |
93 | return false; |
94 | return false; |
94 | } |
95 | } |
95 | unsigned min_height () |
96 | int min_height () |
96 | { |
97 | { |
97 | return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10; |
98 | return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10; |
98 | } |
99 | } |
99 | unsigned size () |
100 | int size () |
100 | { |
101 | { |
101 | return end - beg - min_height (); |
102 | return max (end - beg - min_height (), 0); |
102 | } |
103 | } |
103 | unsigned total_width () |
104 | int total_width () |
104 | { |
105 | { |
105 | return width + shadow * 2; |
106 | return width + shadow * 2; |
106 | } |
107 | } |
|
|
108 | bool above_slider (int y) |
|
|
109 | { |
|
|
110 | return y < top; |
|
|
111 | } |
|
|
112 | bool below_slider (int y) |
|
|
113 | { |
|
|
114 | return y > bot; |
|
|
115 | } |
|
|
116 | int position (int y) |
|
|
117 | { |
|
|
118 | return y - beg; |
|
|
119 | } |
|
|
120 | |
107 | |
121 | |
108 | #if defined(NEXT_SCROLLBAR) |
122 | #if defined(NEXT_SCROLLBAR) |
109 | GC blackGC, |
123 | GC blackGC, |
110 | whiteGC, |
124 | whiteGC, |
111 | grayGC, |
125 | grayGC, |
… | |
… | |
146 | // scrollbar-plain.C |
160 | // scrollbar-plain.C |
147 | int show_plain (int); |
161 | int show_plain (int); |
148 | |
162 | |
149 | void init_next (); |
163 | void init_next (); |
150 | }; |
164 | }; |
151 | |
|
|
152 | #define scrollbar_above_slider(y) ((y) < scrollBar.top) |
|
|
153 | #define scrollbar_below_slider(y) ((y) > scrollBar.bot) |
|
|
154 | #define scrollbar_position(y) ((y) - scrollBar.beg) |
|
|
155 | |
165 | |
156 | /* |
166 | /* |
157 | * +-------------+ |
167 | * +-------------+ |
158 | * | | <---< SB_PADDING |
168 | * | | <---< SB_PADDING |
159 | * | ::::::::::: | |
169 | * | ::::::::::: | |