--- rxvt-unicode/src/scrollbar-rxvt.C 2004/06/21 22:24:07 1.10 +++ rxvt-unicode/src/scrollbar-rxvt.C 2006/01/25 21:09:21 1.25 @@ -23,33 +23,52 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ -#include "scrollbar-rxvt.intpro" /* PROTOS for internal routines */ /*----------------------------------------------------------------------*/ #if defined(RXVT_SCROLLBAR) -/* draw triangular button with a shadow of SHADOW (1 or 2) pixels */ -void -rxvt_term::Draw_button (int x, int y, int state, int dirn) +#define SHADOW_WIDTH 1 + +static void +draw_shadow (rxvt_term *term, int x, int y, int w, int h) { - unsigned int sz, sz2; - XPoint pt[3]; - GC top, bot; + int shadow; + + shadow = (w == 0 || h == 0) ? 1 : SHADOW_WIDTH; + w += x - 1; + h += y - 1; + + for (; shadow-- > 0; x++, y++, w--, h--) + { + XDrawLine (term->xdisp, term->scrollBar.win, term->topShadowGC, x, y, w, y); + XDrawLine (term->xdisp, term->scrollBar.win, term->topShadowGC, x, y, x, h); + XDrawLine (term->xdisp, term->scrollBar.win, term->botShadowGC, w, h, w, y + 1); + XDrawLine (term->xdisp, term->scrollBar.win, term->botShadowGC, w, h, x + 1, h); + } +} - sz = scrollBar.width; +/* draw triangular button with a shadow of 2 pixels */ +static void +draw_button (rxvt_term *term, int x, int y, int state, int dirn) +{ + unsigned int sz, sz2; + XPoint pt[3]; + GC top, bot; + + sz = term->scrollBar.width; sz2 = sz / 2; switch (state) { case +1: - top = topShadowGC; - bot = botShadowGC; + top = term->topShadowGC; + bot = term->botShadowGC; break; case -1: - top = botShadowGC; - bot = topShadowGC; + top = term->botShadowGC; + bot = term->topShadowGC; break; default: - top = bot = scrollbarGC; + top = bot = term->scrollbarGC; break; } @@ -68,22 +87,23 @@ pt[2].y = y + sz - 1; } - XFillPolygon (display->display, scrollBar.win, scrollbarGC, + XFillPolygon (term->xdisp, term->scrollBar.win, term->scrollbarGC, pt, 3, Convex, CoordModeOrigin); /* draw base */ - XDrawLine (display->display, scrollBar.win, (dirn == UP ? bot : top), + XDrawLine (term->xdisp, term->scrollBar.win, (dirn == UP ? bot : top), pt[0].x, pt[0].y, pt[1].x, pt[1].y); /* draw shadow on left */ pt[1].x = x + sz2 - 1; pt[1].y = y + (dirn == UP ? 0 : sz - 1); - XDrawLine (display->display, scrollBar.win, top, + XDrawLine (term->xdisp, term->scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); -#if (SHADOW > 1) +#if SHADOW_WIDTH > 1 /* doubled */ pt[0].x++; + if (dirn == UP) { pt[0].y--; @@ -94,17 +114,20 @@ pt[0].y++; pt[1].y--; } - XDrawLine (display->display, scrollBar.win, top, + + XDrawLine (term->xdisp, term->scrollBar.win, top, pt[0].x, pt[0].y, pt[1].x, pt[1].y); #endif + /* draw shadow on right */ pt[1].x = x + sz - 1; /* pt[2].x = x + sz2; */ pt[1].y = y + (dirn == UP ? sz - 1 : 0); pt[2].y = y + (dirn == UP ? 0 : sz - 1); - XDrawLine (display->display, scrollBar.win, bot, + XDrawLine (term->xdisp, term->scrollBar.win, bot, pt[2].x, pt[2].y, pt[1].x, pt[1].y); -#if (SHADOW > 1) + +#if SHADOW_WIDTH > 1 /* doubled */ pt[1].x--; if (dirn == UP) @@ -118,40 +141,45 @@ pt[1].y++; } - XDrawLine (display->display, scrollBar.win, bot, + XDrawLine (term->xdisp, term->scrollBar.win, bot, pt[2].x, pt[2].y, pt[1].x, pt[1].y); #endif } int -rxvt_term::scrollbar_show_rxvt (int update __attribute__ ((unused)), int last_top, int last_bot, int scrollbar_len) +rxvt_term::scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len) { - int sbshadow = sb_shadow; - int sbwidth = (int)scrollBar.width; + int sbshadow = sb_shadow; + int sbwidth = (int)scrollBar.width; if ((scrollBar.init & R_SB_RXVT) == 0) { scrollBar.init |= R_SB_RXVT; + if (sbshadow) { - XSetWindowBackground (display->display, scrollBar.win, PixColors[Color_trough]); - XClearWindow (display->display, scrollBar.win); + XSetWindowBackground (xdisp, scrollBar.win, pix_colors_focused[Color_trough]); + XClearWindow (xdisp, scrollBar.win); } } else { - /* instead of XClearWindow (display->display, scrollBar.win); */ - if (last_top < scrollBar.top) - XClearArea (display->display, scrollBar.win, - sbshadow, last_top, - sbwidth, (scrollBar.top - last_top), - False); - - if (scrollBar.bot < last_bot) - XClearArea (display->display, scrollBar.win, - sbshadow, scrollBar.bot, - sbwidth, (last_bot - scrollBar.bot), - False); + if (update) + { + if (last_top < scrollBar.top) + XClearArea (xdisp, scrollBar.win, + sbshadow, last_top, + sbwidth, (scrollBar.top - last_top), + False); + + if (scrollBar.bot < last_bot) + XClearArea (xdisp, scrollBar.win, + sbshadow, scrollBar.bot, + sbwidth, (last_bot - scrollBar.bot), + False); + } + else + XClearWindow (xdisp, scrollBar.win); } /* scrollbar slider */ @@ -159,39 +187,33 @@ { int xofs; - if (Options & Opt_scrollBar_right) + if (OPTION (Opt_scrollBar_right)) xofs = 0; else xofs = sbshadow ? sbwidth : sbwidth - 1; - XDrawLine (display->display, scrollBar.win, botShadowGC, + XDrawLine (xdisp, scrollBar.win, botShadowGC, xofs, 0, xofs, scrollBar.end + sbwidth); } #endif - XFillRectangle (display->display, scrollBar.win, scrollbarGC, + XFillRectangle (xdisp, scrollBar.win, scrollbarGC, sbshadow, scrollBar.top, sbwidth, scrollbar_len); if (sbshadow) /* trough shadow */ - rxvt_Draw_Shadow (display->display, scrollBar.win, - botShadowGC, topShadowGC, - 0, 0, - sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth () */ - scrollBar.end + (sbwidth + 1) + sbshadow); + draw_shadow (this, 0, 0, sbwidth + 2 * sbshadow, scrollBar.end + (sbwidth + 1) + sbshadow); /* shadow for scrollbar slider */ - rxvt_Draw_Shadow (display->display, scrollBar.win, - topShadowGC, botShadowGC, - sbshadow, scrollBar.top, sbwidth, - scrollbar_len); + draw_shadow (this, sbshadow, scrollBar.top, sbwidth, scrollbar_len); /* Redraw scrollbar arrows */ - Draw_button (sbshadow, sbshadow, (scrollbar_isUp () ? -1 : +1), UP); - Draw_button (sbshadow, scrollBar.end + 1, (scrollbar_isDn () ? -1 : +1), DN); + draw_button (this, sbshadow, sbshadow, (scrollbar_isUp () ? -1 : +1), UP); + draw_button (this, sbshadow, scrollBar.end + 1, (scrollbar_isDn () ? -1 : +1), DN); return 1; } #endif /* RXVT_SCROLLBAR */ /*----------------------- end-of-file (C source) -----------------------*/ +