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.3 by ayin, Sat Dec 29 14:43:44 2007 UTC vs.
Revision 1.22 by ayin, Tue Feb 19 17:49: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 Window win;
19 int (rxvt_term::*update)(int, int, int, int);
20
21 void setIdle() { state = 1 ; }
22 void setMotion() { state = 'm'; }
23 void setUp() { state = 'U'; }
24 void setDn() { state = 'D'; }
25} scrollBar_t;
26
27#define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2)
28#define scrollbar_isMotion() (scrollBar.state == 'm')
29#define scrollbar_isUp() (scrollBar.state == 'U')
30#define scrollbar_isDn() (scrollBar.state == 'D')
31#define scrollbar_isUpDn() isupper (scrollBar.state)
32#define isScrollbarWindow(w) (scrollBar.state && (w) == scrollBar.win)
33
34#define scrollbarnext_dnval() (scrollBar.end + (scrollBar.width + 1))
35#define scrollbarnext_upButton(y) ((y) > scrollBar.end \
36 && (y) <= scrollbarnext_dnval ())
37#define scrollbarnext_dnButton(y) ((y) > scrollbarnext_dnval())
38#define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
39#define scrollbarrxvt_upButton(y) ((y) < scrollBar.beg)
40#define scrollbarrxvt_dnButton(y) ((y) > scrollBar.end)
41#define SCROLLRXVT_MINHEIGHT 10
42#define SCROLLXTERM_MINHEIGHT 10
43
44#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
45 ? SCROLLNEXT_MINHEIGHT \
46 : SCROLLRXVT_MINHEIGHT)
47#define scrollbar_above_slider(y) ((y) < scrollBar.top)
48#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
49#define scrollbar_position(y) ((y) - scrollBar.beg)
50#define scrollbar_size() (scrollBar.end - scrollBar.beg \
51 - scrollbar_minheight ())
52 12
53#define R_SB_ALIGN_CENTRE 0 13#define R_SB_ALIGN_CENTRE 0
54#define R_SB_ALIGN_TOP 1 14#define R_SB_ALIGN_TOP 1
55#define R_SB_ALIGN_BOTTOM 2 15#define R_SB_ALIGN_BOTTOM 2
56
57#define R_SB_NEXT 1
58#define R_SB_XTERM 2
59#define R_SB_PLAIN 4
60#define R_SB_RXVT 8
61 16
62#define SB_WIDTH_NEXT 19 17#define SB_WIDTH_NEXT 19
63#define SB_WIDTH_XTERM 15 18#define SB_WIDTH_XTERM 15
64#define SB_WIDTH_PLAIN 7 19#define SB_WIDTH_PLAIN 7
65#ifndef SB_WIDTH_RXVT 20#ifndef SB_WIDTH_RXVT
81#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) 36#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
82#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) 37#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
83#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 38#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
84#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)
85#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 unsigned char align;
64 Window win;
65 Cursor leftptr_cursor;
66 int (scrollBar_t::*update)(int);
67 void setup (rxvt_term *);
68 void resize ();
69 int map (int);
70 int show (int);
71 void destroy ();
72
73 bool upButton (int y)
74 {
75 if (style == R_SB_NEXT)
76 return y > end && y <= end + width + 1;
77 if (style == R_SB_RXVT)
78 return y < beg;
79 return false;
80 }
81 bool dnButton (int y)
82 {
83 if (style == R_SB_NEXT)
84 return y > end + width + 1;
85 if (style == R_SB_RXVT)
86 return y > end;
87 return false;
88 }
89 unsigned min_height ()
90 {
91 return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
92 }
93 unsigned size ()
94 {
95 return end - beg - min_height ();
96 }
97 unsigned total_width ()
98 {
99 return width + shadow * 2;
100 }
101
102#if defined(NEXT_SCROLLBAR)
103 GC blackGC,
104 whiteGC,
105 grayGC,
106 darkGC,
107 stippleGC;
108 Pixmap dimple,
109 upArrow,
110 downArrow,
111 upArrowHi,
112 downArrowHi;
113#endif
114
115#if defined(RXVT_SCROLLBAR)
116 GC scrollbarGC,
117 topShadowGC,
118 botShadowGC;
119#endif
120
121#if defined(XTERM_SCROLLBAR)
122 GC xscrollbarGC,
123 ShadowGC;
124#endif
125
126#if defined(PLAIN_SCROLLBAR)
127 GC pscrollbarGC;
128#endif
129
130private:
131 // update style dependent data
132 void update_data ();
133
134 // scrollbar-next.C
135 int show_next (int);
136 // scrollbar-rxvt.C
137 int show_rxvt (int);
138 // scrollbar-xterm.C
139 int show_xterm (int);
140 // scrollbar-plain.C
141 int show_plain (int);
142
143 void init_next ();
144};
145
146#define scrollbar_above_slider(y) ((y) < scrollBar.top)
147#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
148#define scrollbar_position(y) ((y) - scrollBar.beg)
149
86 /* 150 /*
87 * +-------------+ 151 * +-------------+
88 * | | <---< SB_PADDING 152 * | | <---< SB_PADDING
89 * | ::::::::::: | 153 * | ::::::::::: |
90 * | ::::::::::: | 154 * | ::::::::::: |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines