… | |
… | |
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 | #define R_SB_ALIGN_CENTRE 0 |
|
|
14 | #define R_SB_ALIGN_TOP 1 |
|
|
15 | #define R_SB_ALIGN_BOTTOM 2 |
|
|
16 | |
7 | |
17 | #define SB_WIDTH_NEXT 19 |
8 | #define SB_WIDTH_NEXT 19 |
18 | #define SB_WIDTH_XTERM 15 |
9 | #define SB_WIDTH_XTERM 15 |
19 | #define SB_WIDTH_PLAIN 7 |
10 | #define SB_WIDTH_PLAIN 7 |
20 | #ifndef SB_WIDTH_RXVT |
11 | #ifndef SB_WIDTH_RXVT |
… | |
… | |
38 | #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) |
29 | #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) |
39 | #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) |
30 | #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) |
40 | #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) |
31 | #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) |
41 | |
32 | |
42 | enum sb_state { |
33 | enum sb_state { |
|
|
34 | STATE_OFF, |
43 | STATE_IDLE = 1, |
35 | STATE_IDLE, |
44 | STATE_MOTION, |
36 | STATE_MOTION, |
45 | STATE_UP, |
37 | STATE_UP, |
46 | STATE_DOWN, |
38 | STATE_DOWN, |
47 | }; |
39 | }; |
48 | |
40 | |
|
|
41 | enum sb_style { |
|
|
42 | R_SB_NEXT = 1, |
|
|
43 | R_SB_XTERM = 2, |
|
|
44 | R_SB_PLAIN = 4, |
|
|
45 | R_SB_RXVT = 8, |
|
|
46 | }; |
|
|
47 | |
|
|
48 | enum sb_align { |
|
|
49 | R_SB_ALIGN_CENTRE, |
|
|
50 | R_SB_ALIGN_TOP, |
|
|
51 | R_SB_ALIGN_BOTTOM, |
|
|
52 | }; |
|
|
53 | |
49 | struct scrollBar_t { |
54 | struct scrollBar_t |
|
|
55 | { |
50 | rxvt_term *term; |
56 | rxvt_term *term; |
51 | char state; /* scrollbar state */ |
57 | sb_state state; /* scrollbar state */ |
52 | char init; /* scrollbar has been initialised */ |
58 | char init; /* scrollbar has been initialised */ |
53 | unsigned int beg; /* slider sub-window begin height */ |
59 | unsigned int beg; /* slider sub-window begin height */ |
54 | unsigned int end; /* slider sub-window end height */ |
60 | unsigned int end; /* slider sub-window end height */ |
55 | unsigned int top; /* slider top position */ |
61 | unsigned int top; /* slider top position */ |
56 | unsigned int bot; /* slider bottom position */ |
62 | unsigned int bot; /* slider bottom position */ |
57 | unsigned int style; /* style: rxvt, xterm, next */ |
63 | sb_style style; /* style: rxvt, xterm, next */ |
58 | unsigned int width; /* scrollbar width */ |
64 | unsigned int width; /* scrollbar width */ |
59 | int shadow; /* scrollbar shadow width */ |
65 | int shadow; /* scrollbar shadow width */ |
60 | int last_bot; /* scrollbar last bottom position */ |
66 | int last_bot; /* scrollbar last bottom position */ |
61 | int last_top; /* scrollbar last top position */ |
67 | int last_top; /* scrollbar last top position */ |
62 | int last_state; /* scrollbar last state */ |
68 | int last_state; /* scrollbar last state */ |
63 | int len; |
69 | sb_align align; |
64 | unsigned char align; |
|
|
65 | Window win; |
70 | Window win; |
66 | Cursor leftptr_cursor; |
71 | Cursor leftptr_cursor; |
67 | int (rxvt_term::*update)(int, int, int, int); |
72 | int (scrollBar_t::*update)(int); |
68 | void setup (rxvt_term *); |
73 | void setup (rxvt_term *); |
|
|
74 | void resize (); |
|
|
75 | int map (int); |
|
|
76 | int show (int); |
|
|
77 | void destroy (); |
69 | |
78 | |
70 | bool upButton (int y) |
79 | bool upButton (int y) |
71 | { |
80 | { |
72 | if (style == R_SB_NEXT) |
81 | if (style == R_SB_NEXT) |
73 | return y > end && y <= end + width + 1; |
82 | return y > end && y <= end + width + 1; |
… | |
… | |
93 | } |
102 | } |
94 | unsigned total_width () |
103 | unsigned total_width () |
95 | { |
104 | { |
96 | return width + shadow * 2; |
105 | return width + shadow * 2; |
97 | } |
106 | } |
98 | }; |
107 | bool above_slider (int y) |
|
|
108 | { |
|
|
109 | return y < top; |
|
|
110 | } |
|
|
111 | bool below_slider (int y) |
|
|
112 | { |
|
|
113 | return y > bot; |
|
|
114 | } |
|
|
115 | int position (int y) |
|
|
116 | { |
|
|
117 | return y - beg; |
|
|
118 | } |
99 | |
119 | |
100 | #define scrollbar_above_slider(y) ((y) < scrollBar.top) |
120 | |
101 | #define scrollbar_below_slider(y) ((y) > scrollBar.bot) |
121 | #if defined(NEXT_SCROLLBAR) |
102 | #define scrollbar_position(y) ((y) - scrollBar.beg) |
122 | GC blackGC, |
|
|
123 | whiteGC, |
|
|
124 | grayGC, |
|
|
125 | darkGC, |
|
|
126 | stippleGC; |
|
|
127 | Pixmap dimple, |
|
|
128 | upArrow, |
|
|
129 | downArrow, |
|
|
130 | upArrowHi, |
|
|
131 | downArrowHi; |
|
|
132 | #endif |
|
|
133 | |
|
|
134 | #if defined(RXVT_SCROLLBAR) |
|
|
135 | GC scrollbarGC, |
|
|
136 | topShadowGC, |
|
|
137 | botShadowGC; |
|
|
138 | #endif |
|
|
139 | |
|
|
140 | #if defined(XTERM_SCROLLBAR) |
|
|
141 | GC xscrollbarGC, |
|
|
142 | ShadowGC; |
|
|
143 | #endif |
|
|
144 | |
|
|
145 | #if defined(PLAIN_SCROLLBAR) |
|
|
146 | GC pscrollbarGC; |
|
|
147 | #endif |
|
|
148 | |
|
|
149 | private: |
|
|
150 | // update style dependent data |
|
|
151 | void update_data (); |
|
|
152 | |
|
|
153 | // scrollbar-next.C |
|
|
154 | int show_next (int); |
|
|
155 | // scrollbar-rxvt.C |
|
|
156 | int show_rxvt (int); |
|
|
157 | // scrollbar-xterm.C |
|
|
158 | int show_xterm (int); |
|
|
159 | // scrollbar-plain.C |
|
|
160 | int show_plain (int); |
|
|
161 | |
|
|
162 | void init_next (); |
|
|
163 | }; |
103 | |
164 | |
104 | /* |
165 | /* |
105 | * +-------------+ |
166 | * +-------------+ |
106 | * | | <---< SB_PADDING |
167 | * | | <---< SB_PADDING |
107 | * | ::::::::::: | |
168 | * | ::::::::::: | |