1 |
/*--------------------------------*-C-*---------------------------------* |
2 |
* File: scrollbar-xterm.c |
3 |
*----------------------------------------------------------------------* |
4 |
* $Id: scrollbar-xterm.C,v 1.2 2003/11/23 19:32:51 root Exp $ |
5 |
* |
6 |
* Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA> |
7 |
* Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.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 |
#include "scrollbar-xterm.intpro" /* PROTOS for internal routines */ |
27 |
|
28 |
/*----------------------------------------------------------------------*/ |
29 |
#if defined(XTERM_SCROLLBAR) |
30 |
|
31 |
#define x_stp_width 8 |
32 |
#define x_stp_height 2 |
33 |
const unsigned char x_stp_bits[] = { 0xff, 0xff }; |
34 |
|
35 |
/* EXTPROTO */ |
36 |
int |
37 |
rxvt_scrollbar_show_xterm(pR_ int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) |
38 |
{ |
39 |
int xsb = 0; |
40 |
int sbwidth = R->scrollBar.width - 1; |
41 |
|
42 |
if ((R->scrollBar.init & R_SB_XTERM) == 0) { |
43 |
XGCValues gcvalue; |
44 |
|
45 |
R->scrollBar.init |= R_SB_XTERM; |
46 |
gcvalue.stipple = XCreateBitmapFromData(R->Xdisplay, R->scrollBar.win, |
47 |
(char *)x_stp_bits, x_stp_width, |
48 |
x_stp_height); |
49 |
if (!gcvalue.stipple) { |
50 |
rxvt_print_error("can't create bitmap"); |
51 |
exit(EXIT_FAILURE); |
52 |
} |
53 |
gcvalue.fill_style = FillOpaqueStippled; |
54 |
gcvalue.foreground = R->PixColors[Color_fg]; |
55 |
gcvalue.background = R->PixColors[Color_bg]; |
56 |
|
57 |
R->h->xscrollbarGC = XCreateGC(R->Xdisplay, R->scrollBar.win, |
58 |
GCForeground | GCBackground |
59 |
| GCFillStyle | GCStipple, &gcvalue); |
60 |
gcvalue.foreground = R->PixColors[Color_border]; |
61 |
R->h->ShadowGC = XCreateGC(R->Xdisplay, R->scrollBar.win, GCForeground, |
62 |
&gcvalue); |
63 |
} |
64 |
/* instead of XClearWindow (R->Xdisplay, R->scrollBar.win); */ |
65 |
xsb = (R->Options & Opt_scrollBar_right) ? 1 : 0; |
66 |
if (last_top < R->scrollBar.top) |
67 |
XClearArea(R->Xdisplay, R->scrollBar.win, |
68 |
R->sb_shadow + xsb, last_top, |
69 |
sbwidth + 1, (R->scrollBar.top - last_top), False); |
70 |
|
71 |
if (R->scrollBar.bot < last_bot) |
72 |
XClearArea(R->Xdisplay, R->scrollBar.win, |
73 |
R->sb_shadow + xsb, R->scrollBar.bot, |
74 |
sbwidth + 1, (last_bot - R->scrollBar.bot), False); |
75 |
|
76 |
/* scrollbar slider */ |
77 |
XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->xscrollbarGC, |
78 |
xsb + 1, R->scrollBar.top, sbwidth, scrollbar_len); |
79 |
|
80 |
/*XDrawLine(R->Xdisplay, R->scrollBar.win, R->h->ShadowGC, |
81 |
xsb ? 0 : sbwidth, R->scrollBar.beg, |
82 |
xsb ? 0 : sbwidth, R->scrollBar.end);*/ |
83 |
return 1; |
84 |
} |
85 |
#endif /* XTERM_SCROLLBAR */ |
86 |
/*----------------------- end-of-file (C source) -----------------------*/ |