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.1 by ayin, Sat Dec 29 12:03:39 2007 UTC vs.
Revision 1.19 by ayin, Tue Feb 19 10:47:03 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 Window win;
18 int (rxvt_term::*update)(int, int, int, int);
19
20 void setIdle() { state = 1 ; }
21 void setMotion() { state = 'm'; }
22 void setUp() { state = 'U'; }
23 void setDn() { state = 'D'; }
24} scrollBar_t;
25
26#define scrollbar_isMotion() (scrollBar.state == 'm')
27#define scrollbar_isUp() (scrollBar.state == 'U')
28#define scrollbar_isDn() (scrollBar.state == 'D')
29#define scrollbar_isUpDn() isupper (scrollBar.state)
30#define isScrollbarWindow(w) (scrollBar.state && (w) == scrollBar.win)
31
32#define scrollbarnext_dnval() (scrollBar.end + (scrollBar.width + 1))
33#define scrollbarnext_upButton(y) ((y) > scrollBar.end \
34 && (y) <= scrollbarnext_dnval ())
35#define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval())
36#define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
37#define scrollbarrxvt_upButton(y) ((y) < scrollBar.beg)
38#define scrollbarrxvt_dnButton(y) ((y) > scrollBar.end)
39#define SCROLLRXVT_MINHEIGHT 10
40#define SCROLLXTERM_MINHEIGHT 10
41
42#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
43 ? SCROLLNEXT_MINHEIGHT \
44 : SCROLLRXVT_MINHEIGHT)
45#define scrollbar_above_slider(y) ((y) < scrollBar.top)
46#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
47#define scrollbar_position(y) ((y) - scrollBar.beg)
48#define scrollbar_size() (scrollBar.end - scrollBar.beg \
49 - scrollbar_minheight ())
50 12
51#define R_SB_ALIGN_CENTRE 0 13#define R_SB_ALIGN_CENTRE 0
52#define R_SB_ALIGN_TOP 1 14#define R_SB_ALIGN_TOP 1
53#define R_SB_ALIGN_BOTTOM 2 15#define R_SB_ALIGN_BOTTOM 2
54
55#define R_SB_NEXT 1
56#define R_SB_XTERM 2
57#define R_SB_PLAIN 4
58#define R_SB_RXVT 8
59 16
60#define SB_WIDTH_NEXT 19 17#define SB_WIDTH_NEXT 19
61#define SB_WIDTH_XTERM 15 18#define SB_WIDTH_XTERM 15
62#define SB_WIDTH_PLAIN 7 19#define SB_WIDTH_PLAIN 7
63#ifndef SB_WIDTH_RXVT 20#ifndef SB_WIDTH_RXVT
79#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) 36#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
80#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) 37#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
81#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 38#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
82#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)
83#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 void resize ();
72 int map (int);
73 int show (int);
74
75 bool upButton (int y)
76 {
77 if (style == R_SB_NEXT)
78 return y > end && y <= end + width + 1;
79 if (style == R_SB_RXVT)
80 return y < beg;
81 return false;
82 }
83 bool dnButton (int y)
84 {
85 if (style == R_SB_NEXT)
86 return y > end + width + 1;
87 if (style == R_SB_RXVT)
88 return y > end;
89 return false;
90 }
91 unsigned min_height ()
92 {
93 return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
94 }
95 unsigned size ()
96 {
97 return end - beg - min_height ();
98 }
99 unsigned total_width ()
100 {
101 return width + shadow * 2;
102 }
103};
104
105#define scrollbar_above_slider(y) ((y) < scrollBar.top)
106#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
107#define scrollbar_position(y) ((y) - scrollBar.beg)
108
84 /* 109 /*
85 * +-------------+ 110 * +-------------+
86 * | | <---< SB_PADDING 111 * | | <---< SB_PADDING
87 * | ::::::::::: | 112 * | ::::::::::: |
88 * | ::::::::::: | 113 * | ::::::::::: |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines