ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.C
(Generate patch)

Comparing rxvt-unicode/src/scrollbar.C (file contents):
Revision 1.15 by pcg, Thu Apr 8 20:31:45 2004 UTC vs.
Revision 1.33 by root, Tue Jan 24 19:40:12 2006 UTC

23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *----------------------------------------------------------------------*/ 24 *----------------------------------------------------------------------*/
25 25
26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28#include "scrollbar.intpro" /* PROTOS for internal routines */
29 28
30/*----------------------------------------------------------------------*/ 29/*----------------------------------------------------------------------*/
31 30
32/* 31/*
33 * Map or unmap a scrollbar. Returns non-zero upon change of state 32 * Map or unmap a scrollbar. Returns non-zero upon change of state
36rxvt_term::scrollbar_mapping (int map) 35rxvt_term::scrollbar_mapping (int map)
37{ 36{
38 int change = 0; 37 int change = 0;
39 38
40#ifdef HAVE_SCROLLBARS 39#ifdef HAVE_SCROLLBARS
41 if (map && !scrollbar_visible ()) 40 if (map)
42 { 41 {
43 scrollBar.setIdle (); 42 scrollBar.setIdle ();
43
44 if (!scrollBar.win) 44 if (!scrollBar.win)
45 resize_scrollbar (); 45 resize_scrollbar ();
46
46 if (scrollBar.win) 47 if (scrollBar.win)
47 { 48 {
48 XMapWindow (display->display, scrollBar.win); 49 XMapWindow (display->display, scrollBar.win);
49 change = 1; 50 change = 1;
50 } 51 }
51 } 52 }
52 else if (!map && scrollbar_visible ()) 53 else
53 { 54 {
54 scrollBar.state = 0; 55 scrollBar.state = 0;
55 XUnmapWindow (display->display, scrollBar.win); 56 XUnmapWindow (display->display, scrollBar.win);
56 change = 1; 57 change = 1;
57 } 58 }
67 68
68#define R_SCROLLBEG_XTERM 0 69#define R_SCROLLBEG_XTERM 0
69#define R_SCROLLEND_XTERM szHint.height 70#define R_SCROLLEND_XTERM szHint.height
70#define R_SCROLLBEG_NEXT 0 71#define R_SCROLLBEG_NEXT 0
71#define R_SCROLLEND_NEXT szHint.height - (SB_BUTTON_TOTAL_HEIGHT + \ 72#define R_SCROLLEND_NEXT szHint.height - (SB_BUTTON_TOTAL_HEIGHT + \
72 SB_PADDING) 73 SB_PADDING)
73#define R_SCROLLBEG_RXVT (scrollBar.width + 1) + sb_shadow 74#define R_SCROLLBEG_RXVT (scrollBar.width + 1) + sb_shadow
74#define R_SCROLLEND_RXVT szHint.height - R_SCROLLBEG_RXVT - \ 75#define R_SCROLLEND_RXVT szHint.height - R_SCROLLBEG_RXVT - \
75 (2 * sb_shadow) 76 (2 * sb_shadow)
76 77
77#if defined(PLAIN_SCROLLBAR) 78#if defined(PLAIN_SCROLLBAR)
78 if (scrollBar.style == R_SB_PLAIN) 79 if (scrollBar.style == R_SB_PLAIN)
79 { 80 {
80 scrollBar.beg = R_SCROLLBEG_XTERM; 81 scrollBar.beg = R_SCROLLBEG_XTERM;
109 110
110 if (!scrollBar.win) 111 if (!scrollBar.win)
111 { 112 {
112 /* create the scrollbar window */ 113 /* create the scrollbar window */
113 scrollBar.win = XCreateSimpleWindow (display->display, 114 scrollBar.win = XCreateSimpleWindow (display->display,
114 TermWin.parent[0], 115 parent[0],
115 window_sb_x, 0, 116 window_sb_x, 0,
116 scrollbar_TotalWidth (), 117 scrollbar_TotalWidth (),
117 szHint.height, 118 szHint.height,
118 0, 119 0,
119 PixColors[Color_fg], 120 pix_colors[Color_fg],
120 PixColors[Color_bg]); 121 pix_colors[Color_border]);
121#ifdef DEBUG_X
122 XStoreName (display->display, scrollBar.win, "scrollbar");
123#endif
124 XDefineCursor (display->display, scrollBar.win, leftptr_cursor); 122 XDefineCursor (display->display, scrollBar.win, leftptr_cursor);
125 123
126 XSelectInput (display->display, scrollBar.win, 124 XSelectInput (display->display, scrollBar.win,
127 ExposureMask | ButtonPressMask | ButtonReleaseMask 125 ExposureMask | ButtonPressMask | ButtonReleaseMask
128 | Button1MotionMask | Button2MotionMask 126 | Button1MotionMask | Button2MotionMask
147{ 145{
148 int ret = 0; 146 int ret = 0;
149#ifdef HAVE_SCROLLBARS 147#ifdef HAVE_SCROLLBARS
150 int top, bot, len, adj; 148 int top, bot, len, adj;
151 149
152 if (!scrollbar_visible ()) 150 if (!scrollBar.state)
153 return 0; 151 return 0;
154 152
155 if (update) 153 if (update)
156 { 154 {
157 top = (TermWin.nscrolled - TermWin.view_start); 155 top = view_start - top_row;
158 bot = top + (TermWin.nrow - 1); 156 bot = top + (nrow - 1);
159 len = max ((TermWin.nscrolled + (TermWin.nrow - 1)), 1); 157 len = max (nrow - 1 - top_row, 1);
160 adj = (((bot - top) * scrollbar_size ()) % len) > 0 ? 1 : 0; 158 adj = (((bot - top) * scrollbar_size ()) % len) > 0 ? 1 : 0;
161 159
162 scrollBar.top = (scrollBar.beg + (top * scrollbar_size ()) / len); 160 scrollBar.top = (scrollBar.beg + (top * scrollbar_size ()) / len);
163 scrollbar_len = ((bot - top) * scrollbar_size ()) / len + 161 scrollbar_len = ((bot - top) * scrollbar_size ()) / len +
164 scrollbar_minheight () + adj; 162 scrollbar_minheight () + adj;
201 199
202# if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR)) 200# if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR))
203 if (scrollstyle) 201 if (scrollstyle)
204 { 202 {
205# ifdef NEXT_SCROLLBAR 203# ifdef NEXT_SCROLLBAR
206 if (STRNCASECMP (scrollstyle, "next", 4) == 0) 204 if (strncasecmp (scrollstyle, "next", 4) == 0)
207 style = R_SB_NEXT; 205 style = R_SB_NEXT;
208# endif 206# endif
209# ifdef XTERM_SCROLLBAR 207# ifdef XTERM_SCROLLBAR
210 if (STRNCASECMP (scrollstyle, "xterm", 5) == 0) 208 if (strncasecmp (scrollstyle, "xterm", 5) == 0)
211 style = R_SB_XTERM; 209 style = R_SB_XTERM;
212# endif 210# endif
213# ifdef PLAIN_SCROLLBAR 211# ifdef PLAIN_SCROLLBAR
214 if (STRNCASECMP (scrollstyle, "plain", 5) == 0) 212 if (strncasecmp (scrollstyle, "plain", 5) == 0)
215 style = R_SB_PLAIN; 213 style = R_SB_PLAIN;
216# endif 214# endif
217 215
218 } 216 }
219# endif 217# endif
228 226
229 if (style != R_SB_NEXT) /* dishonour request - for now */ 227 if (style != R_SB_NEXT) /* dishonour request - for now */
230 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) 228 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM)
231 width = min (i, SB_WIDTH_MAXIMUM); 229 width = min (i, SB_WIDTH_MAXIMUM);
232 230
233# if defined(RXVT_SCROLLBAR) 231# ifdef RXVT_SCROLLBAR
234 if (! (Options & Opt_scrollBar_floating) && style == R_SB_RXVT) 232 if (! OPTION (Opt_scrollBar_floating) && style == R_SB_RXVT)
235 sb_shadow = SHADOW; 233 sb_shadow = 2;
236# endif 234# endif
237 235
238 scrollBar.style = style; 236 scrollBar.style = style;
239 scrollBar.width = width; 237 scrollBar.width = width;
240 238
241 /* scrollbar_align = R_SB_ALIGN_CENTRE; */ 239 /* scrollbar_align = R_SB_ALIGN_CENTRE; */
242 if (scrollalign) 240 if (scrollalign)
243 { 241 {
244 if (STRNCASECMP (scrollalign, "top", 3) == 0) 242 if (strncasecmp (scrollalign, "top", 3) == 0)
245 scrollbar_align = R_SB_ALIGN_TOP; 243 scrollbar_align = R_SB_ALIGN_TOP;
246 else if (STRNCASECMP (scrollalign, "bottom", 6) == 0) 244 else if (strncasecmp (scrollalign, "bottom", 6) == 0)
247 scrollbar_align = R_SB_ALIGN_BOTTOM; 245 scrollbar_align = R_SB_ALIGN_BOTTOM;
248 } 246 }
249#endif 247#endif
250} 248}
251 249

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines