ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar-rxvt.C
(Generate patch)

Comparing rxvt-unicode/src/scrollbar-rxvt.C (file contents):
Revision 1.10 by root, Mon Jun 21 22:24:07 2004 UTC vs.
Revision 1.22 by root, Mon Jan 16 17:11:12 2006 UTC

21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *----------------------------------------------------------------------*/ 22 *----------------------------------------------------------------------*/
23 23
24#include "../config.h" /* NECESSARY */ 24#include "../config.h" /* NECESSARY */
25#include "rxvt.h" /* NECESSARY */ 25#include "rxvt.h" /* NECESSARY */
26#include "scrollbar-rxvt.intpro" /* PROTOS for internal routines */
27 26
28/*----------------------------------------------------------------------*/ 27/*----------------------------------------------------------------------*/
29#if defined(RXVT_SCROLLBAR) 28#if defined(RXVT_SCROLLBAR)
30 29
30#define SHADOW_WIDTH 1
31
32static void
33rxvt_Draw_Shadow (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h)
34{
35 int shadow;
36
37 shadow = (w == 0 || h == 0) ? 1 : SHADOW_WIDTH;
38 w += x - 1;
39 h += y - 1;
40 for (; shadow-- > 0; x++, y++, w--, h--)
41 {
42 XDrawLine (display, win, topShadow, x, y, w, y);
43 XDrawLine (display, win, topShadow, x, y, x, h);
44 XDrawLine (display, win, botShadow, w, h, w, y + 1);
45 XDrawLine (display, win, botShadow, w, h, x + 1, h);
46 }
47}
48
31/* draw triangular button with a shadow of SHADOW (1 or 2) pixels */ 49/* draw triangular button with a shadow of 2 pixels */
32void 50void
33rxvt_term::Draw_button (int x, int y, int state, int dirn) 51rxvt_term::Draw_button (int x, int y, int state, int dirn)
34{ 52{
35 unsigned int sz, sz2; 53 unsigned int sz, sz2;
36 XPoint pt[3]; 54 XPoint pt[3];
79 pt[1].x = x + sz2 - 1; 97 pt[1].x = x + sz2 - 1;
80 pt[1].y = y + (dirn == UP ? 0 : sz - 1); 98 pt[1].y = y + (dirn == UP ? 0 : sz - 1);
81 XDrawLine (display->display, scrollBar.win, top, 99 XDrawLine (display->display, scrollBar.win, top,
82 pt[0].x, pt[0].y, pt[1].x, pt[1].y); 100 pt[0].x, pt[0].y, pt[1].x, pt[1].y);
83 101
84#if (SHADOW > 1) 102#if SHADOW_WIDTH > 1
85 /* doubled */ 103 /* doubled */
86 pt[0].x++; 104 pt[0].x++;
105
87 if (dirn == UP) 106 if (dirn == UP)
88 { 107 {
89 pt[0].y--; 108 pt[0].y--;
90 pt[1].y++; 109 pt[1].y++;
91 } 110 }
92 else 111 else
93 { 112 {
94 pt[0].y++; 113 pt[0].y++;
95 pt[1].y--; 114 pt[1].y--;
96 } 115 }
116
97 XDrawLine (display->display, scrollBar.win, top, 117 XDrawLine (display->display, scrollBar.win, top,
98 pt[0].x, pt[0].y, pt[1].x, pt[1].y); 118 pt[0].x, pt[0].y, pt[1].x, pt[1].y);
99#endif 119#endif
120
100 /* draw shadow on right */ 121 /* draw shadow on right */
101 pt[1].x = x + sz - 1; 122 pt[1].x = x + sz - 1;
102 /* pt[2].x = x + sz2; */ 123 /* pt[2].x = x + sz2; */
103 pt[1].y = y + (dirn == UP ? sz - 1 : 0); 124 pt[1].y = y + (dirn == UP ? sz - 1 : 0);
104 pt[2].y = y + (dirn == UP ? 0 : sz - 1); 125 pt[2].y = y + (dirn == UP ? 0 : sz - 1);
105 XDrawLine (display->display, scrollBar.win, bot, 126 XDrawLine (display->display, scrollBar.win, bot,
106 pt[2].x, pt[2].y, pt[1].x, pt[1].y); 127 pt[2].x, pt[2].y, pt[1].x, pt[1].y);
128
107#if (SHADOW > 1) 129#if SHADOW_WIDTH > 1
108 /* doubled */ 130 /* doubled */
109 pt[1].x--; 131 pt[1].x--;
110 if (dirn == UP) 132 if (dirn == UP)
111 { 133 {
112 pt[2].y++; 134 pt[2].y++;
122 pt[2].x, pt[2].y, pt[1].x, pt[1].y); 144 pt[2].x, pt[2].y, pt[1].x, pt[1].y);
123#endif 145#endif
124} 146}
125 147
126int 148int
127rxvt_term::scrollbar_show_rxvt (int update __attribute__ ((unused)), int last_top, int last_bot, int scrollbar_len) 149rxvt_term::scrollbar_show_rxvt (int update, int last_top, int last_bot, int scrollbar_len)
128{ 150{
129 int sbshadow = sb_shadow; 151 int sbshadow = sb_shadow;
130 int sbwidth = (int)scrollBar.width; 152 int sbwidth = (int)scrollBar.width;
131 153
132 if ((scrollBar.init & R_SB_RXVT) == 0) 154 if ((scrollBar.init & R_SB_RXVT) == 0)
133 { 155 {
134 scrollBar.init |= R_SB_RXVT; 156 scrollBar.init |= R_SB_RXVT;
157
135 if (sbshadow) 158 if (sbshadow)
136 { 159 {
137 XSetWindowBackground (display->display, scrollBar.win, PixColors[Color_trough]); 160 XSetWindowBackground (display->display, scrollBar.win, pix_colors_focused[Color_trough]);
138 XClearWindow (display->display, scrollBar.win); 161 XClearWindow (display->display, scrollBar.win);
139 } 162 }
140 } 163 }
141 else 164 else
142 { 165 {
143 /* instead of XClearWindow (display->display, scrollBar.win); */ 166 if (update)
167 {
144 if (last_top < scrollBar.top) 168 if (last_top < scrollBar.top)
145 XClearArea (display->display, scrollBar.win, 169 XClearArea (display->display, scrollBar.win,
146 sbshadow, last_top, 170 sbshadow, last_top,
147 sbwidth, (scrollBar.top - last_top), 171 sbwidth, (scrollBar.top - last_top),
148 False); 172 False);
149 173
150 if (scrollBar.bot < last_bot) 174 if (scrollBar.bot < last_bot)
151 XClearArea (display->display, scrollBar.win, 175 XClearArea (display->display, scrollBar.win,
152 sbshadow, scrollBar.bot, 176 sbshadow, scrollBar.bot,
153 sbwidth, (last_bot - scrollBar.bot), 177 sbwidth, (last_bot - scrollBar.bot),
154 False); 178 False);
179 }
180 else
181 XClearWindow (display->display, scrollBar.win);
155 } 182 }
156 183
157 /* scrollbar slider */ 184 /* scrollbar slider */
158#ifdef SB_BORDER 185#ifdef SB_BORDER
159 { 186 {
160 int xofs; 187 int xofs;
161 188
162 if (Options & Opt_scrollBar_right) 189 if (OPTION (Opt_scrollBar_right))
163 xofs = 0; 190 xofs = 0;
164 else 191 else
165 xofs = sbshadow ? sbwidth : sbwidth - 1; 192 xofs = sbshadow ? sbwidth : sbwidth - 1;
166 193
167 XDrawLine (display->display, scrollBar.win, botShadowGC, 194 XDrawLine (display->display, scrollBar.win, botShadowGC,
193 220
194 return 1; 221 return 1;
195} 222}
196#endif /* RXVT_SCROLLBAR */ 223#endif /* RXVT_SCROLLBAR */
197/*----------------------- end-of-file (C source) -----------------------*/ 224/*----------------------- end-of-file (C source) -----------------------*/
225

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines