1 |
pcg |
1.1 |
/*--------------------------------*-C-*---------------------------------* |
2 |
pcg |
1.10 |
* File: scrollbar-xterm.C |
3 |
pcg |
1.1 |
*----------------------------------------------------------------------* |
4 |
|
|
* |
5 |
|
|
* Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA> |
6 |
|
|
* Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> |
7 |
root |
1.21 |
* Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com> |
8 |
pcg |
1.1 |
* |
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 |
pcg |
1.5 |
const unsigned char x_stp_bits[] = { 0xaa, 0x55 }; |
33 |
pcg |
1.1 |
|
34 |
|
|
int |
35 |
root |
1.17 |
rxvt_term::scrollbar_show_xterm (int update, int last_top, int last_bot, int scrollbar_len) |
36 |
pcg |
1.1 |
{ |
37 |
root |
1.17 |
int xsb = 0; |
38 |
|
|
int sbwidth = scrollBar.width - 1; |
39 |
pcg |
1.1 |
|
40 |
pcg |
1.6 |
if ((scrollBar.init & R_SB_XTERM) == 0) |
41 |
|
|
{ |
42 |
|
|
XGCValues gcvalue; |
43 |
|
|
|
44 |
|
|
scrollBar.init |= R_SB_XTERM; |
45 |
root |
1.20 |
gcvalue.stipple = XCreateBitmapFromData (dpy, scrollBar.win, |
46 |
pcg |
1.6 |
(char *)x_stp_bits, x_stp_width, |
47 |
|
|
x_stp_height); |
48 |
|
|
if (!gcvalue.stipple) |
49 |
root |
1.15 |
rxvt_fatal ("can't create bitmap\n"); |
50 |
pcg |
1.9 |
|
51 |
pcg |
1.6 |
gcvalue.fill_style = FillOpaqueStippled; |
52 |
root |
1.17 |
gcvalue.foreground = pix_colors_focused[Color_fg]; |
53 |
|
|
gcvalue.background = pix_colors_focused[Color_bg]; |
54 |
pcg |
1.6 |
|
55 |
root |
1.20 |
xscrollbarGC = XCreateGC (dpy, scrollBar.win, |
56 |
root |
1.11 |
GCForeground | GCBackground |
57 |
|
|
| GCFillStyle | GCStipple, &gcvalue); |
58 |
root |
1.17 |
gcvalue.foreground = pix_colors_focused[Color_border]; |
59 |
root |
1.20 |
ShadowGC = XCreateGC (dpy, scrollBar.win, GCForeground, &gcvalue); |
60 |
pcg |
1.1 |
} |
61 |
root |
1.17 |
|
62 |
|
|
if (update) |
63 |
|
|
{ |
64 |
root |
1.18 |
xsb = OPTION (Opt_scrollBar_right) ? 1 : 0; |
65 |
root |
1.17 |
if (last_top < scrollBar.top) |
66 |
root |
1.20 |
XClearArea (dpy, scrollBar.win, |
67 |
root |
1.17 |
sb_shadow + xsb, last_top, |
68 |
|
|
sbwidth, (scrollBar.top - last_top), False); |
69 |
|
|
|
70 |
|
|
if (scrollBar.bot < last_bot) |
71 |
root |
1.20 |
XClearArea (dpy, scrollBar.win, |
72 |
root |
1.17 |
sb_shadow + xsb, scrollBar.bot, |
73 |
|
|
sbwidth, (last_bot - scrollBar.bot), False); |
74 |
|
|
} |
75 |
|
|
else |
76 |
root |
1.20 |
XClearWindow (dpy, scrollBar.win); |
77 |
pcg |
1.6 |
|
78 |
|
|
/* scrollbar slider */ |
79 |
root |
1.20 |
XFillRectangle (dpy, scrollBar.win, xscrollbarGC, |
80 |
pcg |
1.6 |
xsb + 1, scrollBar.top, sbwidth - 2, scrollbar_len); |
81 |
|
|
|
82 |
root |
1.20 |
XDrawLine (dpy, scrollBar.win, ShadowGC, |
83 |
pcg |
1.6 |
xsb ? 0 : sbwidth, scrollBar.beg, |
84 |
|
|
xsb ? 0 : sbwidth, scrollBar.end); |
85 |
|
|
return 1; |
86 |
pcg |
1.1 |
} |
87 |
|
|
#endif /* XTERM_SCROLLBAR */ |
88 |
|
|
/*----------------------- end-of-file (C source) -----------------------*/ |