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.12 by ayin, Mon Jan 28 10:54:54 2008 UTC vs.
Revision 1.18 by ayin, Mon Feb 18 11:41:40 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
13struct scrollBar_t {
14 char state; /* scrollbar state */
15 char init; /* scrollbar has been initialised */
16 unsigned int beg; /* slider sub-window begin height */
17 unsigned int end; /* slider sub-window end height */
18 unsigned int top; /* slider top position */
19 unsigned int bot; /* slider bottom position */
20 unsigned int style; /* style: rxvt, xterm, next */
21 unsigned int width; /* scrollbar width */
22 int shadow; /* scrollbar shadow width */
23 int last_bot; /* scrollbar last bottom position */
24 int last_top; /* scrollbar last top position */
25 int last_state; /* scrollbar last state */
26 int len;
27 unsigned char align;
28 Window win;
29 Cursor leftptr_cursor;
30 int (rxvt_term::*update)(int, int, int, int);
31
32 void setIdle() { state = 1 ; }
33 void setMotion() { state = 'm'; }
34 void setUp() { state = 'U'; }
35 void setDn() { state = 'D'; }
36
37 bool upButton (int y)
38 {
39 if (style == R_SB_NEXT)
40 return y > end && y <= end + width + 1;
41 if (style == R_SB_RXVT)
42 return y < beg;
43 return false;
44 }
45 bool dnButton (int y)
46 {
47 if (style == R_SB_NEXT)
48 return y > end + width + 1;
49 if (style == R_SB_RXVT)
50 return y > end;
51 return false;
52 }
53};
54
55#define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2)
56#define scrollbar_isMotion() (scrollBar.state == 'm')
57#define scrollbar_isUp() (scrollBar.state == 'U')
58#define scrollbar_isDn() (scrollBar.state == 'D')
59#define scrollbar_isUpDn() (scrollbar_isUp () || scrollbar_isDn ())
60
61#define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
62#define SCROLLRXVT_MINHEIGHT 10
63
64#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
65 ? SCROLLNEXT_MINHEIGHT \
66 : SCROLLRXVT_MINHEIGHT)
67#define scrollbar_above_slider(y) ((y) < scrollBar.top)
68#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
69#define scrollbar_position(y) ((y) - scrollBar.beg)
70#define scrollbar_size() (scrollBar.end - scrollBar.beg \
71 - scrollbar_minheight ())
72 12
73#define R_SB_ALIGN_CENTRE 0 13#define R_SB_ALIGN_CENTRE 0
74#define R_SB_ALIGN_TOP 1 14#define R_SB_ALIGN_TOP 1
75#define R_SB_ALIGN_BOTTOM 2 15#define R_SB_ALIGN_BOTTOM 2
76 16
96#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) 36#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
97#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) 37#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
98#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 38#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
99#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)
100#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 // update style dependent data
70 void update_data ();
71
72 bool upButton (int y)
73 {
74 if (style == R_SB_NEXT)
75 return y > end && y <= end + width + 1;
76 if (style == R_SB_RXVT)
77 return y < beg;
78 return false;
79 }
80 bool dnButton (int y)
81 {
82 if (style == R_SB_NEXT)
83 return y > end + width + 1;
84 if (style == R_SB_RXVT)
85 return y > end;
86 return false;
87 }
88 unsigned min_height ()
89 {
90 return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
91 }
92 unsigned size ()
93 {
94 return end - beg - min_height ();
95 }
96 unsigned total_width ()
97 {
98 return width + shadow * 2;
99 }
100};
101
102#define scrollbar_above_slider(y) ((y) < scrollBar.top)
103#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
104#define scrollbar_position(y) ((y) - scrollBar.beg)
105
101 /* 106 /*
102 * +-------------+ 107 * +-------------+
103 * | | <---< SB_PADDING 108 * | | <---< SB_PADDING
104 * | ::::::::::: | 109 * | ::::::::::: |
105 * | ::::::::::: | 110 * | ::::::::::: |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines