--- rxvt-unicode/src/scrollbar-rxvt.C 2004/01/31 04:12:10 1.5 +++ rxvt-unicode/src/scrollbar-rxvt.C 2004/02/01 01:34:41 1.6 @@ -31,155 +31,169 @@ void rxvt_term::Draw_button (int x, int y, int state, int dirn) { - unsigned int sz, sz2; - XPoint pt[3]; - GC top, bot; - - sz = scrollBar.width; - sz2 = sz / 2; - switch (state) { - case +1: - top = topShadowGC; - bot = botShadowGC; - break; - case -1: - top = botShadowGC; - bot = topShadowGC; - break; - default: - top = bot = scrollbarGC; - break; - } - -/* fill triangle */ - pt[0].x = x; - pt[1].x = x + sz - 1; - pt[2].x = x + sz2; - if (dirn == UP) { - pt[0].y = pt[1].y = y + sz - 1; - pt[2].y = y; - } else { - pt[0].y = pt[1].y = y; - pt[2].y = y + sz - 1; - } - XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC, - pt, 3, Convex, CoordModeOrigin); - -/* draw base */ - XDrawLine(Xdisplay, 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(Xdisplay, scrollBar.win, top, - pt[0].x, pt[0].y, pt[1].x, pt[1].y); + unsigned int sz, sz2; + XPoint pt[3]; + GC top, bot; + + sz = scrollBar.width; + sz2 = sz / 2; + switch (state) + { + case +1: + top = topShadowGC; + bot = botShadowGC; + break; + case -1: + top = botShadowGC; + bot = topShadowGC; + break; + default: + top = bot = scrollbarGC; + break; + } + + /* fill triangle */ + pt[0].x = x; + pt[1].x = x + sz - 1; + pt[2].x = x + sz2; + if (dirn == UP) + { + pt[0].y = pt[1].y = y + sz - 1; + pt[2].y = y; + } + else + { + pt[0].y = pt[1].y = y; + pt[2].y = y + sz - 1; + } + XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC, + pt, 3, Convex, CoordModeOrigin); + + /* draw base */ + XDrawLine(Xdisplay, 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(Xdisplay, scrollBar.win, top, + pt[0].x, pt[0].y, pt[1].x, pt[1].y); #if (SHADOW > 1) -/* doubled */ - pt[0].x++; - if (dirn == UP) { - pt[0].y--; - pt[1].y++; - } else { - pt[0].y++; - pt[1].y--; + /* doubled */ + pt[0].x++; + if (dirn == UP) + { + pt[0].y--; + pt[1].y++; } - XDrawLine(Xdisplay, scrollBar.win, top, - pt[0].x, pt[0].y, pt[1].x, pt[1].y); + else + { + pt[0].y++; + pt[1].y--; + } + XDrawLine(Xdisplay, 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(Xdisplay, scrollBar.win, bot, - pt[2].x, pt[2].y, pt[1].x, pt[1].y); + /* 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(Xdisplay, scrollBar.win, bot, + pt[2].x, pt[2].y, pt[1].x, pt[1].y); #if (SHADOW > 1) -/* doubled */ - pt[1].x--; - if (dirn == UP) { - pt[2].y++; - pt[1].y--; - } else { - pt[2].y--; - pt[1].y++; + /* doubled */ + pt[1].x--; + if (dirn == UP) + { + pt[2].y++; + pt[1].y--; } - XDrawLine(Xdisplay, scrollBar.win, bot, - pt[2].x, pt[2].y, pt[1].x, pt[1].y); + else + { + pt[2].y--; + pt[1].y++; + } + XDrawLine(Xdisplay, 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) { - 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) { - XGCValues gcvalue; + if ((scrollBar.init & R_SB_RXVT) == 0) + { + XGCValues gcvalue; - scrollBar.init |= R_SB_RXVT; - gcvalue.foreground = PixColors[Color_trough]; - if (sbshadow) { - XSetWindowBackground(Xdisplay, scrollBar.win, - gcvalue.foreground); - XClearWindow(Xdisplay, scrollBar.win); - } - } else { -/* instead of XClearWindow (Xdisplay, scrollBar.win); */ - if (last_top < scrollBar.top) - XClearArea(Xdisplay, scrollBar.win, - sbshadow, last_top, - sbwidth, (scrollBar.top - last_top), - False); - - if (scrollBar.bot < last_bot) - XClearArea(Xdisplay, scrollBar.win, - sbshadow, scrollBar.bot, - sbwidth, (last_bot - scrollBar.bot), - False); + scrollBar.init |= R_SB_RXVT; + gcvalue.foreground = PixColors[Color_trough]; + if (sbshadow) + { + XSetWindowBackground(Xdisplay, scrollBar.win, + gcvalue.foreground); + XClearWindow(Xdisplay, scrollBar.win); + } } - -/* scrollbar slider */ -#ifdef SB_BORDER + else { - int xofs; + /* instead of XClearWindow (Xdisplay, scrollBar.win); */ + if (last_top < scrollBar.top) + XClearArea(Xdisplay, scrollBar.win, + sbshadow, last_top, + sbwidth, (scrollBar.top - last_top), + False); + + if (scrollBar.bot < last_bot) + XClearArea(Xdisplay, scrollBar.win, + sbshadow, scrollBar.bot, + sbwidth, (last_bot - scrollBar.bot), + False); + } - if (Options & Opt_scrollBar_right) - xofs = 0; - else - xofs = sbshadow ? sbwidth : sbwidth - 1; + /* scrollbar slider */ +#ifdef SB_BORDER + { + int xofs; - XDrawLine(Xdisplay, scrollBar.win, botShadowGC, - xofs, 0, xofs, scrollBar.end + sbwidth); - } + if (Options & Opt_scrollBar_right) + xofs = 0; + else + xofs = sbshadow ? sbwidth : sbwidth - 1; + + XDrawLine(Xdisplay, scrollBar.win, botShadowGC, + xofs, 0, xofs, scrollBar.end + sbwidth); + } #endif - XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC, - sbshadow, scrollBar.top, sbwidth, - scrollbar_len); - - if (sbshadow) - /* trough shadow */ - rxvt_Draw_Shadow(Xdisplay, scrollBar.win, - botShadowGC, topShadowGC, - 0, 0, - sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */ - scrollBar.end + (sbwidth + 1) + sbshadow); -/* shadow for scrollbar slider */ + XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC, + sbshadow, scrollBar.top, sbwidth, + scrollbar_len); + + if (sbshadow) + /* trough shadow */ rxvt_Draw_Shadow(Xdisplay, scrollBar.win, - topShadowGC, botShadowGC, - 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); - return 1; + botShadowGC, topShadowGC, + 0, 0, + sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */ + scrollBar.end + (sbwidth + 1) + sbshadow); + /* shadow for scrollbar slider */ + rxvt_Draw_Shadow(Xdisplay, scrollBar.win, + topShadowGC, botShadowGC, + 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); + return 1; } #endif /* RXVT_SCROLLBAR */ /*----------------------- end-of-file (C source) -----------------------*/