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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines