ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.h
Revision: 1.17
Committed: Sun Feb 17 12:11:56 2008 UTC (16 years, 3 months ago) by ayin
Content type: text/plain
Branch: MAIN
Changes since 1.16: +8 -8 lines
Log Message:
Make scrollbar_{minheight,size} methods of scrollBar_t.

File Contents

# Content
1 #ifndef SCROLLBAR_H
2 #define SCROLLBAR_H
3
4 #include <X11/Xlib.h>
5
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
17 #define SB_WIDTH_NEXT 19
18 #define SB_WIDTH_XTERM 15
19 #define SB_WIDTH_PLAIN 7
20 #ifndef SB_WIDTH_RXVT
21 # define SB_WIDTH_RXVT 10
22 #endif
23
24 /*
25 * NeXT scrollbar defines
26 */
27 #define SB_PADDING 1
28 #define SB_BORDER_WIDTH 1
29 #define SB_BEVEL_WIDTH_UPPER_LEFT 1
30 #define SB_BEVEL_WIDTH_LOWER_RIGHT 2
31 #define SB_LEFT_PADDING (SB_PADDING + SB_BORDER_WIDTH)
32 #define SB_MARGIN_SPACE (SB_PADDING * 2)
33 #define SB_BUTTON_WIDTH (SB_WIDTH_NEXT - SB_MARGIN_SPACE - SB_BORDER_WIDTH)
34 #define SB_BUTTON_HEIGHT (SB_BUTTON_WIDTH)
35 #define SB_BUTTON_SINGLE_HEIGHT (SB_BUTTON_HEIGHT + SB_PADDING)
36 #define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
37 #define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
38 #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
39 #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))
41
42 enum sb_state {
43 STATE_IDLE = 1,
44 STATE_MOTION,
45 STATE_UP,
46 STATE_DOWN,
47 };
48
49 struct scrollBar_t {
50 rxvt_term *term;
51 char state; /* scrollbar state */
52 char init; /* scrollbar has been initialised */
53 unsigned int beg; /* slider sub-window begin height */
54 unsigned int end; /* slider sub-window end height */
55 unsigned int top; /* slider top position */
56 unsigned int bot; /* slider bottom position */
57 unsigned int style; /* style: rxvt, xterm, next */
58 unsigned int width; /* scrollbar width */
59 int shadow; /* scrollbar shadow width */
60 int last_bot; /* scrollbar last bottom position */
61 int last_top; /* scrollbar last top position */
62 int last_state; /* scrollbar last state */
63 int len;
64 unsigned char align;
65 Window win;
66 Cursor leftptr_cursor;
67 int (rxvt_term::*update)(int, int, int, int);
68 void setup (rxvt_term *);
69
70 bool upButton (int y)
71 {
72 if (style == R_SB_NEXT)
73 return y > end && y <= end + width + 1;
74 if (style == R_SB_RXVT)
75 return y < beg;
76 return false;
77 }
78 bool dnButton (int y)
79 {
80 if (style == R_SB_NEXT)
81 return y > end + width + 1;
82 if (style == R_SB_RXVT)
83 return y > end;
84 return false;
85 }
86 unsigned min_height ()
87 {
88 return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
89 }
90 unsigned size ()
91 {
92 return end - beg - min_height ();
93 }
94 unsigned total_width ()
95 {
96 return width + shadow * 2;
97 }
98 };
99
100 #define scrollbar_above_slider(y) ((y) < scrollBar.top)
101 #define scrollbar_below_slider(y) ((y) > scrollBar.bot)
102 #define scrollbar_position(y) ((y) - scrollBar.beg)
103
104 /*
105 * +-------------+
106 * | | <---< SB_PADDING
107 * | ::::::::::: |
108 * | ::::::::::: |
109 * '''''''''''''''''
110 * ,,,,,,,,,,,,,,,,,
111 * | ::::::::::: |
112 * | ::::::::::: |
113 * | +---------------< SB_BEVEL_WIDTH_UPPER_LEFT
114 * | | :::::::: |
115 * | V :::: vv-------< SB_BEVEL_WIDTH_LOWER_RIGHT
116 * | +---------+ |
117 * | | ......%%| |
118 * | | ......%%| |
119 * | | .. ()..%%| |
120 * | | ......%%| |
121 * | | %%%%%%%%| |
122 * | +---------+ | <.........................
123 * | | <---< SB_PADDING :
124 * | +---------+ | <-+.......... :---< SB_BUTTON_TOTAL_HEIGHT
125 * | | ......%%| | | : :
126 * | | ../\..%%| | |---< SB_BUTTON_HEIGHT :
127 * | | %%%%%%%%| | | : :
128 * | +---------+ | <-+ : :
129 * | | : :
130 * | +---------+ | <-+ :---< SB_BUTTON_BOTH_HEIGHT
131 * | | ......%%| | | : :
132 * | | ..\/..%%| | | : :
133 * | | %%%%%%%%| | |---< SB_BUTTON_SINGLE_HEIGHT
134 * | +---------+ | | : :
135 * | | | : :
136 * +-------------+ <-+.........:............:
137 * ^^|_________| :
138 * || | :
139 * || +---< SB_BUTTON_WIDTH
140 * || :
141 * |+------< SB_PADDING
142 * |: :
143 * +----< SB_BORDER_WIDTH
144 * : :
145 * :............:
146 * |
147 * +---< SB_WIDTH_NEXT
148 */
149
150 #endif