*** empty log message ***
[dana/urxvt.git] / src / scrollbar-xterm.C
1 /*--------------------------------*-C-*---------------------------------*
2  * File:        scrollbar-xterm.C
3  *----------------------------------------------------------------------*
4  *
5  * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA>
6  * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
7  * Copyright (c) 2004      Marc Lehmann <pcg@goof.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *----------------------------------------------------------------------*/
23
24 #include "../config.h"          /* NECESSARY */
25 #include "rxvt.h"               /* NECESSARY */
26
27 /*----------------------------------------------------------------------*/
28 #if defined(XTERM_SCROLLBAR)
29
30 #define x_stp_width     8
31 #define x_stp_height    2
32 const unsigned char x_stp_bits[] = { 0xaa, 0x55 };
33
34 int
35 rxvt_term::scrollbar_show_xterm (int update, int last_top, int last_bot, int scrollbar_len)
36 {
37   int xsb = 0;
38   int sbwidth = scrollBar.width - 1;
39
40   if ((scrollBar.init & R_SB_XTERM) == 0)
41     {
42       XGCValues       gcvalue;
43
44       scrollBar.init |= R_SB_XTERM;
45       gcvalue.stipple = XCreateBitmapFromData (display->display, scrollBar.win,
46                                               (char *)x_stp_bits, x_stp_width,
47                                               x_stp_height);
48       if (!gcvalue.stipple)
49         rxvt_fatal ("can't create bitmap\n");
50
51       gcvalue.fill_style = FillOpaqueStippled;
52       gcvalue.foreground = pix_colors_focused[Color_fg];
53       gcvalue.background = pix_colors_focused[Color_bg];
54
55       xscrollbarGC = XCreateGC (display->display, scrollBar.win,
56                                 GCForeground | GCBackground
57                                 | GCFillStyle | GCStipple, &gcvalue);
58       gcvalue.foreground = pix_colors_focused[Color_border];
59       ShadowGC = XCreateGC (display->display, scrollBar.win, GCForeground, &gcvalue);
60     }
61
62   if (update)
63     {
64       xsb = (options & Opt_scrollBar_right) ? 1 : 0;
65       if (last_top < scrollBar.top)
66         XClearArea (display->display, scrollBar.win,
67                    sb_shadow + xsb, last_top,
68                    sbwidth, (scrollBar.top - last_top), False);
69
70       if (scrollBar.bot < last_bot)
71         XClearArea (display->display, scrollBar.win,
72                    sb_shadow + xsb, scrollBar.bot,
73                    sbwidth, (last_bot - scrollBar.bot), False);
74     }
75   else
76     XClearWindow (display->display, scrollBar.win);
77
78   /* scrollbar slider */
79   XFillRectangle (display->display, scrollBar.win, xscrollbarGC,
80                  xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len);
81
82   XDrawLine (display->display, scrollBar.win, ShadowGC,
83             xsb ? 0 : sbwidth, scrollBar.beg,
84             xsb ? 0 : sbwidth, scrollBar.end);
85   return 1;
86 }
87 #endif                          /* XTERM_SCROLLBAR */
88 /*----------------------- end-of-file (C source) -----------------------*/