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.30 by sf-exg, Tue Oct 2 10:29:12 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines