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.15 by ayin, Sun Feb 17 11:37:21 2008 UTC vs.
Revision 1.25 by sf-exg, Mon Aug 22 17:23:56 2011 UTC

2#define SCROLLBAR_H 2#define SCROLLBAR_H
3 3
4#include <X11/Xlib.h> 4#include <X11/Xlib.h>
5 5
6struct rxvt_term; 6struct rxvt_term;
7
8#define R_SB_NEXT 1
9#define R_SB_XTERM 2
10#define R_SB_PLAIN 4
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 rxvt_term *term;
22 char state; /* scrollbar state */
23 char init; /* scrollbar has been initialised */
24 unsigned int beg; /* slider sub-window begin height */
25 unsigned int end; /* slider sub-window end height */
26 unsigned int top; /* slider top position */
27 unsigned int bot; /* slider bottom position */
28 unsigned int style; /* style: rxvt, xterm, next */
29 unsigned int width; /* scrollbar width */
30 int shadow; /* scrollbar shadow width */
31 int last_bot; /* scrollbar last bottom position */
32 int last_top; /* scrollbar last top position */
33 int last_state; /* scrollbar last state */
34 int len;
35 unsigned char align;
36 Window win;
37 Cursor leftptr_cursor;
38 int (rxvt_term::*update)(int, int, int, int);
39 void setup (rxvt_term *);
40
41 bool upButton (int y)
42 {
43 if (style == R_SB_NEXT)
44 return y > end && y <= end + width + 1;
45 if (style == R_SB_RXVT)
46 return y < beg;
47 return false;
48 }
49 bool dnButton (int y)
50 {
51 if (style == R_SB_NEXT)
52 return y > end + width + 1;
53 if (style == R_SB_RXVT)
54 return y > end;
55 return false;
56 }
57 unsigned total_width ()
58 {
59 return width + shadow * 2;
60 }
61};
62
63#define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
64#define SCROLLRXVT_MINHEIGHT 10
65
66#define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
67 ? SCROLLNEXT_MINHEIGHT \
68 : SCROLLRXVT_MINHEIGHT)
69#define scrollbar_above_slider(y) ((y) < scrollBar.top)
70#define scrollbar_below_slider(y) ((y) > scrollBar.bot)
71#define scrollbar_position(y) ((y) - scrollBar.beg)
72#define scrollbar_size() (scrollBar.end - scrollBar.beg \
73 - scrollbar_minheight ())
74
75#define R_SB_ALIGN_CENTRE 0
76#define R_SB_ALIGN_TOP 1
77#define R_SB_ALIGN_BOTTOM 2
78 7
79#define SB_WIDTH_NEXT 19 8#define SB_WIDTH_NEXT 19
80#define SB_WIDTH_XTERM 15 9#define SB_WIDTH_XTERM 15
81#define SB_WIDTH_PLAIN 7 10#define SB_WIDTH_PLAIN 7
82#ifndef SB_WIDTH_RXVT 11#ifndef SB_WIDTH_RXVT
98#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) 27#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
99#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) 28#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
100#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 29#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
101#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) 30#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT)
102#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) 31#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2))
32
33enum sb_state {
34 STATE_OFF,
35 STATE_IDLE,
36 STATE_MOTION,
37 STATE_UP,
38 STATE_DOWN,
39};
40
41enum sb_style {
42 R_SB_NEXT = 1,
43 R_SB_XTERM = 2,
44 R_SB_PLAIN = 4,
45 R_SB_RXVT = 8,
46};
47
48enum sb_align {
49 R_SB_ALIGN_CENTRE,
50 R_SB_ALIGN_TOP,
51 R_SB_ALIGN_BOTTOM,
52};
53
54struct scrollBar_t
55{
56 rxvt_term *term;
57 sb_state state; /* scrollbar state */
58 char init; /* scrollbar has been initialised */
59 unsigned int beg; /* slider sub-window begin height */
60 unsigned int end; /* slider sub-window end height */
61 unsigned int top; /* slider top position */
62 unsigned int bot; /* slider bottom position */
63 sb_style style; /* style: rxvt, xterm, next */
64 unsigned int width; /* scrollbar width */
65 int shadow; /* scrollbar shadow width */
66 int last_bot; /* scrollbar last bottom position */
67 int last_top; /* scrollbar last top position */
68 int last_state; /* scrollbar last state */
69 sb_align align;
70 Window win;
71 Cursor leftptr_cursor;
72 int (scrollBar_t::*update)(int);
73 void setup (rxvt_term *);
74 void resize ();
75 int map (int);
76 int show (int);
77 void destroy ();
78
79 bool upButton (int y)
80 {
81 if (style == R_SB_NEXT)
82 return y > end && y <= end + width + 1;
83 if (style == R_SB_RXVT)
84 return y < beg;
85 return false;
86 }
87 bool dnButton (int y)
88 {
89 if (style == R_SB_NEXT)
90 return y > end + width + 1;
91 if (style == R_SB_RXVT)
92 return y > end;
93 return false;
94 }
95 unsigned min_height ()
96 {
97 return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
98 }
99 unsigned size ()
100 {
101 return end - beg - min_height ();
102 }
103 unsigned total_width ()
104 {
105 return width + shadow * 2;
106 }
107 bool above_slider (int y)
108 {
109 return y < top;
110 }
111 bool below_slider (int y)
112 {
113 return y > bot;
114 }
115 int position (int y)
116 {
117 return y - beg;
118 }
119
120
121#if defined(NEXT_SCROLLBAR)
122 GC blackGC,
123 whiteGC,
124 grayGC,
125 darkGC,
126 stippleGC;
127 Pixmap dimple,
128 upArrow,
129 downArrow,
130 upArrowHi,
131 downArrowHi;
132#endif
133
134#if defined(RXVT_SCROLLBAR)
135 GC scrollbarGC,
136 topShadowGC,
137 botShadowGC;
138#endif
139
140#if defined(XTERM_SCROLLBAR)
141 GC xscrollbarGC,
142 ShadowGC;
143#endif
144
145#if defined(PLAIN_SCROLLBAR)
146 GC pscrollbarGC;
147#endif
148
149private:
150 // update style dependent data
151 void update_data ();
152
153 // scrollbar-next.C
154 int show_next (int);
155 // scrollbar-rxvt.C
156 int show_rxvt (int);
157 // scrollbar-xterm.C
158 int show_xterm (int);
159 // scrollbar-plain.C
160 int show_plain (int);
161
162 void init_next ();
163};
164
103 /* 165 /*
104 * +-------------+ 166 * +-------------+
105 * | | <---< SB_PADDING 167 * | | <---< SB_PADDING
106 * | ::::::::::: | 168 * | ::::::::::: |
107 * | ::::::::::: | 169 * | ::::::::::: |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines