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.32 by root, Mon Jan 16 15:12:48 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#ifdef DEBUG_X
122 XStoreName (display->display, scrollBar.win, "scrollbar"); 123 XStoreName (display->display, scrollBar.win, "scrollbar");
123#endif 124#endif
124 XDefineCursor (display->display, scrollBar.win, leftptr_cursor); 125 XDefineCursor (display->display, scrollBar.win, leftptr_cursor);
125 126
147{ 148{
148 int ret = 0; 149 int ret = 0;
149#ifdef HAVE_SCROLLBARS 150#ifdef HAVE_SCROLLBARS
150 int top, bot, len, adj; 151 int top, bot, len, adj;
151 152
152 if (!scrollbar_visible ()) 153 if (!scrollBar.state)
153 return 0; 154 return 0;
154 155
155 if (update) 156 if (update)
156 { 157 {
157 top = (TermWin.nscrolled - TermWin.view_start); 158 top = view_start - top_row;
158 bot = top + (TermWin.nrow - 1); 159 bot = top + (nrow - 1);
159 len = max ((TermWin.nscrolled + (TermWin.nrow - 1)), 1); 160 len = max (nrow - 1 - top_row, 1);
160 adj = (((bot - top) * scrollbar_size ()) % len) > 0 ? 1 : 0; 161 adj = (((bot - top) * scrollbar_size ()) % len) > 0 ? 1 : 0;
161 162
162 scrollBar.top = (scrollBar.beg + (top * scrollbar_size ()) / len); 163 scrollBar.top = (scrollBar.beg + (top * scrollbar_size ()) / len);
163 scrollbar_len = ((bot - top) * scrollbar_size ()) / len + 164 scrollbar_len = ((bot - top) * scrollbar_size ()) / len +
164 scrollbar_minheight () + adj; 165 scrollbar_minheight () + adj;
201 202
202# if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR)) 203# if (defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) || defined(PLAIN_SCROLLBAR))
203 if (scrollstyle) 204 if (scrollstyle)
204 { 205 {
205# ifdef NEXT_SCROLLBAR 206# ifdef NEXT_SCROLLBAR
206 if (STRNCASECMP (scrollstyle, "next", 4) == 0) 207 if (strncasecmp (scrollstyle, "next", 4) == 0)
207 style = R_SB_NEXT; 208 style = R_SB_NEXT;
208# endif 209# endif
209# ifdef XTERM_SCROLLBAR 210# ifdef XTERM_SCROLLBAR
210 if (STRNCASECMP (scrollstyle, "xterm", 5) == 0) 211 if (strncasecmp (scrollstyle, "xterm", 5) == 0)
211 style = R_SB_XTERM; 212 style = R_SB_XTERM;
212# endif 213# endif
213# ifdef PLAIN_SCROLLBAR 214# ifdef PLAIN_SCROLLBAR
214 if (STRNCASECMP (scrollstyle, "plain", 5) == 0) 215 if (strncasecmp (scrollstyle, "plain", 5) == 0)
215 style = R_SB_PLAIN; 216 style = R_SB_PLAIN;
216# endif 217# endif
217 218
218 } 219 }
219# endif 220# endif
228 229
229 if (style != R_SB_NEXT) /* dishonour request - for now */ 230 if (style != R_SB_NEXT) /* dishonour request - for now */
230 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM) 231 if (thickness && (i = atoi (thickness)) >= SB_WIDTH_MINIMUM)
231 width = min (i, SB_WIDTH_MAXIMUM); 232 width = min (i, SB_WIDTH_MAXIMUM);
232 233
233# if defined(RXVT_SCROLLBAR) 234# ifdef RXVT_SCROLLBAR
234 if (! (Options & Opt_scrollBar_floating) && style == R_SB_RXVT) 235 if (! OPTION (Opt_scrollBar_floating) && style == R_SB_RXVT)
235 sb_shadow = SHADOW; 236 sb_shadow = 2;
236# endif 237# endif
237 238
238 scrollBar.style = style; 239 scrollBar.style = style;
239 scrollBar.width = width; 240 scrollBar.width = width;
240 241
241 /* scrollbar_align = R_SB_ALIGN_CENTRE; */ 242 /* scrollbar_align = R_SB_ALIGN_CENTRE; */
242 if (scrollalign) 243 if (scrollalign)
243 { 244 {
244 if (STRNCASECMP (scrollalign, "top", 3) == 0) 245 if (strncasecmp (scrollalign, "top", 3) == 0)
245 scrollbar_align = R_SB_ALIGN_TOP; 246 scrollbar_align = R_SB_ALIGN_TOP;
246 else if (STRNCASECMP (scrollalign, "bottom", 6) == 0) 247 else if (strncasecmp (scrollalign, "bottom", 6) == 0)
247 scrollbar_align = R_SB_ALIGN_BOTTOM; 248 scrollbar_align = R_SB_ALIGN_BOTTOM;
248 } 249 }
249#endif 250#endif
250} 251}
251 252

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines