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.21 by ayin, Tue Feb 19 17:49:16 2008 UTC

7 7
8#define R_SB_NEXT 1 8#define R_SB_NEXT 1
9#define R_SB_XTERM 2 9#define R_SB_XTERM 2
10#define R_SB_PLAIN 4 10#define R_SB_PLAIN 4
11#define R_SB_RXVT 8 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 12
75#define R_SB_ALIGN_CENTRE 0 13#define R_SB_ALIGN_CENTRE 0
76#define R_SB_ALIGN_TOP 1 14#define R_SB_ALIGN_TOP 1
77#define R_SB_ALIGN_BOTTOM 2 15#define R_SB_ALIGN_BOTTOM 2
78 16
98#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2) 36#define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
99#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING) 37#define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
100#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 38#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
101#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)
102#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 // update style dependent data
69 void update_data ();
70 void resize ();
71 int map (int);
72 int show (int);
73 void destroy ();
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#if defined(NEXT_SCROLLBAR)
105 GC blackGC,
106 whiteGC,
107 grayGC,
108 darkGC,
109 stippleGC;
110 Pixmap dimple,
111 upArrow,
112 downArrow,
113 upArrowHi,
114 downArrowHi;
115#endif
116
117#if defined(RXVT_SCROLLBAR)
118 GC scrollbarGC,
119 topShadowGC,
120 botShadowGC;
121#endif
122
123#if defined(XTERM_SCROLLBAR)
124 GC xscrollbarGC,
125 ShadowGC;
126#endif
127
128#if defined(PLAIN_SCROLLBAR)
129 GC pscrollbarGC;
130#endif
131
132 // scrollbar-next.C
133 int show_next (int);
134 // scrollbar-rxvt.C
135 int show_rxvt (int);
136 // scrollbar-xterm.C
137 int show_xterm (int);
138 // scrollbar-plain.C
139 int show_plain (int);
140
141private:
142 void init_next ();
143};
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
103 /* 149 /*
104 * +-------------+ 150 * +-------------+
105 * | | <---< SB_PADDING 151 * | | <---< SB_PADDING
106 * | ::::::::::: | 152 * | ::::::::::: |
107 * | ::::::::::: | 153 * | ::::::::::: |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines