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.10 by ayin, Fri Jan 4 17:57:28 2008 UTC vs.
Revision 1.16 by ayin, Sun Feb 17 12:11:36 2008 UTC

3 3
4#include <X11/Xlib.h> 4#include <X11/Xlib.h>
5 5
6struct rxvt_term; 6struct rxvt_term;
7 7
8typedef struct { 8#define R_SB_NEXT 1
9 char state; /* scrollbar state */ 9#define R_SB_XTERM 2
10 char init; /* scrollbar has been initialised */ 10#define R_SB_PLAIN 4
11 unsigned int beg; /* slider sub-window begin height */ 11#define R_SB_RXVT 8
12 unsigned int end; /* slider sub-window end height */
13 unsigned int top; /* slider top position */
14 unsigned int bot; /* slider bottom position */
15 unsigned int style; /* style: rxvt, xterm, next */
16 unsigned int width; /* scrollbar width */
17 int shadow; /* scrollbar shadow width */
18 int last_bot; /* scrollbar last bottom position */
19 int last_top; /* scrollbar last top position */
20 int last_state; /* scrollbar last state */
21 int len;
22 unsigned char align;
23 Window win;
24 Cursor leftptr_cursor;
25 int (rxvt_term::*update)(int, int, int, int);
26
27 void setIdle() { state = 1 ; }
28 void setMotion() { state = 'm'; }
29 void setUp() { state = 'U'; }
30 void setDn() { state = 'D'; }
31} scrollBar_t;
32
33#define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2)
34#define scrollbar_isMotion() (scrollBar.state == 'm')
35#define scrollbar_isUp() (scrollBar.state == 'U')
36#define scrollbar_isDn() (scrollBar.state == 'D')
37#define scrollbar_isUpDn() (scrollbar_isUp () || scrollbar_isDn ())
38
39#define scrollbarnext_dnval() (scrollBar.end + (scrollBar.width + 1))
40#define scrollbarnext_upButton(y) ((y) > scrollBar.end \
41 && (y) <= scrollbarnext_dnval ())
42#define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval())
43#define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
44#define scrollbarrxvt_upButton(y) ((y) < scrollBar.beg)
45#define scrollbarrxvt_dnButton(y) ((y) > scrollBar.end)
46#define SCROLLRXVT_MINHEIGHT 10
47
48#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
49 ? SCROLLNEXT_MINHEIGHT \
50 : SCROLLRXVT_MINHEIGHT)
51#define scrollbar_above_slider(y) ((y) < scrollBar.top)
52#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
53#define scrollbar_position(y) ((y) - scrollBar.beg)
54#define scrollbar_size() (scrollBar.end - scrollBar.beg \
55 - scrollbar_minheight ())
56 12
57#define R_SB_ALIGN_CENTRE 0 13#define R_SB_ALIGN_CENTRE 0
58#define R_SB_ALIGN_TOP 1 14#define R_SB_ALIGN_TOP 1
59#define R_SB_ALIGN_BOTTOM 2 15#define R_SB_ALIGN_BOTTOM 2
60
61#define R_SB_NEXT 1
62#define R_SB_XTERM 2
63#define R_SB_PLAIN 4
64#define R_SB_RXVT 8
65 16
66#define SB_WIDTH_NEXT 19 17#define SB_WIDTH_NEXT 19
67#define SB_WIDTH_XTERM 15 18#define SB_WIDTH_XTERM 15
68#define SB_WIDTH_PLAIN 7 19#define SB_WIDTH_PLAIN 7
69#ifndef SB_WIDTH_RXVT 20#ifndef SB_WIDTH_RXVT
85#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) 36#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
86#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) 37#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
87#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 38#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
88#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)
89#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
90 /* 104 /*
91 * +-------------+ 105 * +-------------+
92 * | | <---< SB_PADDING 106 * | | <---< SB_PADDING
93 * | ::::::::::: | 107 * | ::::::::::: |
94 * | ::::::::::: | 108 * | ::::::::::: |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines