--- rxvt-unicode/src/scrollbar-xterm.C 2003/11/24 17:31:28 1.2 +++ rxvt-unicode/src/scrollbar-xterm.C 2014/05/22 18:54:33 1.35 @@ -1,14 +1,14 @@ -/*--------------------------------*-C-*---------------------------------* - * File: scrollbar-xterm.c +/*----------------------------------------------------------------------* + * File: scrollbar-xterm.C *----------------------------------------------------------------------* - * $Id: scrollbar-xterm.C,v 1.2 2003/11/24 17:31:28 pcg Exp $ * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1999-2001 Geoff Wing + * Copyright (c) 2004-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -23,64 +23,67 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ -#include "scrollbar-xterm.intpro" /* PROTOS for internal routines */ /*----------------------------------------------------------------------*/ #if defined(XTERM_SCROLLBAR) #define x_stp_width 8 #define x_stp_height 2 -const unsigned char x_stp_bits[] = { 0xff, 0xff }; +const unsigned char x_stp_bits[] = { 0xaa, 0x55 }; -/* EXTPROTO */ int -rxvt_scrollbar_show_xterm(pR_ int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) +scrollBar_t::show_xterm (int update) { - int xsb = 0; - int sbwidth = R->scrollBar.width - 1; + int xsb = 0; + int sbwidth = width - 1; - if ((R->scrollBar.init & R_SB_XTERM) == 0) { - XGCValues gcvalue; + if ((init & SB_STYLE_XTERM) == 0) + { + XGCValues gcvalue; + + init |= SB_STYLE_XTERM; + gcvalue.stipple = XCreateBitmapFromData (term->dpy, win, + (char *)x_stp_bits, x_stp_width, + x_stp_height); + if (!gcvalue.stipple) + rxvt_fatal ("can't create bitmap\n"); + + gcvalue.fill_style = FillOpaqueStippled; + gcvalue.foreground = term->pix_colors_focused[Color_scroll]; + gcvalue.background = term->pix_colors_focused[Color_bg]; + + xscrollbarGC = XCreateGC (term->dpy, win, + GCForeground | GCBackground + | GCFillStyle | GCStipple, &gcvalue); + gcvalue.foreground = term->pix_colors_focused[Color_border]; + ShadowGC = XCreateGC (term->dpy, win, GCForeground, &gcvalue); + } + + xsb = term->option (Opt_scrollBar_right) ? 1 : 0; - R->scrollBar.init |= R_SB_XTERM; - gcvalue.stipple = XCreateBitmapFromData(R->Xdisplay, R->scrollBar.win, - (char *)x_stp_bits, x_stp_width, - x_stp_height); - if (!gcvalue.stipple) { - rxvt_print_error("can't create bitmap"); - exit(EXIT_FAILURE); - } - gcvalue.fill_style = FillOpaqueStippled; - gcvalue.foreground = R->PixColors[Color_fg]; - gcvalue.background = R->PixColors[Color_bg]; - - R->h->xscrollbarGC = XCreateGC(R->Xdisplay, R->scrollBar.win, - GCForeground | GCBackground - | GCFillStyle | GCStipple, &gcvalue); - gcvalue.foreground = R->PixColors[Color_border]; - R->h->ShadowGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground, - &gcvalue); + if (update) + { + if (last_top < top) + XClearArea (term->dpy, win, + xsb, last_top, + sbwidth, (top - last_top), False); + + if (bot < last_bot) + XClearArea (term->dpy, win, + xsb, bot, + sbwidth, (last_bot - bot), False); } -/* instead of XClearWindow (R->Xdisplay, R->scrollBar.win); */ - xsb = (R->Options & Opt_scrollBar_right) ? 1 : 0; - if (last_top < R->scrollBar.top) - XClearArea(R->Xdisplay, R->scrollBar.win, - R->sb_shadow + xsb, last_top, - sbwidth + 1, (R->scrollBar.top - last_top), False); - - if (R->scrollBar.bot < last_bot) - XClearArea(R->Xdisplay, R->scrollBar.win, - R->sb_shadow + xsb, R->scrollBar.bot, - sbwidth + 1, (last_bot - R->scrollBar.bot), False); - -/* scrollbar slider */ - XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->xscrollbarGC, - xsb + 1, R->scrollBar.top, sbwidth, scrollbar_len); - - /*XDrawLine(R->Xdisplay, R->scrollBar.win, R->h->ShadowGC, - xsb ? 0 : sbwidth, R->scrollBar.beg, - xsb ? 0 : sbwidth, R->scrollBar.end);*/ - return 1; + else + XClearWindow (term->dpy, win); + + /* scrollbar slider */ + XFillRectangle (term->dpy, win, xscrollbarGC, + xsb + 1, top, sbwidth - 2, bot - top); + + XDrawLine (term->dpy, win, ShadowGC, + xsb ? 0 : sbwidth, beg, + xsb ? 0 : sbwidth, end); + return 1; } -#endif /* XTERM_SCROLLBAR */ +#endif /* XTERM_SCROLLBAR */ /*----------------------- end-of-file (C source) -----------------------*/