ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.h
(Generate patch)

Comparing rxvt-unicode/src/scrollbar.h (file contents):
Revision 1.13 by ayin, Tue Jan 29 13:57:23 2008 UTC vs.
Revision 1.16 by ayin, Sun Feb 17 12:11:36 2008 UTC

7 7
8#define R_SB_NEXT 1 8#define R_SB_NEXT 1
9#define R_SB_XTERM 2 9#define R_SB_XTERM 2
10#define R_SB_PLAIN 4 10#define R_SB_PLAIN 4
11#define R_SB_RXVT 8 11#define R_SB_RXVT 8
12
13enum sb_state {
14 STATE_IDLE = 1,
15 STATE_MOTION,
16 STATE_UP,
17 STATE_DOWN,
18};
19
20struct scrollBar_t {
21 char state; /* scrollbar state */
22 char init; /* scrollbar has been initialised */
23 unsigned int beg; /* slider sub-window begin height */
24 unsigned int end; /* slider sub-window end height */
25 unsigned int top; /* slider top position */
26 unsigned int bot; /* slider bottom position */
27 unsigned int style; /* style: rxvt, xterm, next */
28 unsigned int width; /* scrollbar width */
29 int shadow; /* scrollbar shadow width */
30 int last_bot; /* scrollbar last bottom position */
31 int last_top; /* scrollbar last top position */
32 int last_state; /* scrollbar last state */
33 int len;
34 unsigned char align;
35 Window win;
36 Cursor leftptr_cursor;
37 int (rxvt_term::*update)(int, int, int, int);
38
39 bool upButton (int y)
40 {
41 if (style == R_SB_NEXT)
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 }
55};
56
57#define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2)
58
59#define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
60#define SCROLLRXVT_MINHEIGHT 10
61
62#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
63 ? SCROLLNEXT_MINHEIGHT \
64 : SCROLLRXVT_MINHEIGHT)
65#define scrollbar_above_slider(y) ((y) < scrollBar.top)
66#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
67#define scrollbar_position(y) ((y) - scrollBar.beg)
68#define scrollbar_size() (scrollBar.end - scrollBar.beg \
69 - scrollbar_minheight ())
70 12
71#define R_SB_ALIGN_CENTRE 0 13#define R_SB_ALIGN_CENTRE 0
72#define R_SB_ALIGN_TOP 1 14#define R_SB_ALIGN_TOP 1
73#define R_SB_ALIGN_BOTTOM 2 15#define R_SB_ALIGN_BOTTOM 2
74 16
94#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) 36#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
95#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) 37#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
96#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 38#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
97#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) 39#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT)
98#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) 40#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2))
41
42enum sb_state {
43 STATE_IDLE = 1,
44 STATE_MOTION,
45 STATE_UP,
46 STATE_DOWN,
47};
48
49struct 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 total_width ()
87 {
88 return width + shadow * 2;
89 }
90};
91
92#define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
93#define SCROLLRXVT_MINHEIGHT 10
94
95#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
96 ? SCROLLNEXT_MINHEIGHT \
97 : SCROLLRXVT_MINHEIGHT)
98#define scrollbar_above_slider(y) ((y) < scrollBar.top)
99#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
100#define scrollbar_position(y) ((y) - scrollBar.beg)
101#define scrollbar_size() (scrollBar.end - scrollBar.beg \
102 - scrollbar_minheight ())
103
99 /* 104 /*
100 * +-------------+ 105 * +-------------+
101 * | | <---< SB_PADDING 106 * | | <---< SB_PADDING
102 * | ::::::::::: | 107 * | ::::::::::: |
103 * | ::::::::::: | 108 * | ::::::::::: |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines