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.1 by pcg, Mon Nov 24 17:28:08 2003 UTC vs.
Revision 1.5 by pcg, Sat Jan 31 04:12:10 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: scrollbar-rxvt.c 2 * File: scrollbar-rxvt.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: scrollbar-rxvt.C,v 1.1 2003/11/24 17:28:08 pcg Exp $
5 * 4 *
6 * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA> 5 * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA>
7 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> 6 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
27 26
28/*----------------------------------------------------------------------*/ 27/*----------------------------------------------------------------------*/
29#if defined(RXVT_SCROLLBAR) 28#if defined(RXVT_SCROLLBAR)
30 29
31/* draw triangular button with a shadow of SHADOW (1 or 2) pixels */ 30/* draw triangular button with a shadow of SHADOW (1 or 2) pixels */
32/* INTPROTO */
33void 31void
34rxvt_Draw_button(pR_ int x, int y, int state, int dirn) 32rxvt_term::Draw_button (int x, int y, int state, int dirn)
35{ 33{
36 unsigned int sz, sz2; 34 unsigned int sz, sz2;
37 XPoint pt[3]; 35 XPoint pt[3];
38 GC top, bot; 36 GC top, bot;
39 37
40 sz = R->scrollBar.width; 38 sz = scrollBar.width;
41 sz2 = sz / 2; 39 sz2 = sz / 2;
42 switch (state) { 40 switch (state) {
43 case +1: 41 case +1:
44 top = R->h->topShadowGC; 42 top = topShadowGC;
45 bot = R->h->botShadowGC; 43 bot = botShadowGC;
46 break; 44 break;
47 case -1: 45 case -1:
48 top = R->h->botShadowGC; 46 top = botShadowGC;
49 bot = R->h->topShadowGC; 47 bot = topShadowGC;
50 break; 48 break;
51 default: 49 default:
52 top = bot = R->h->scrollbarGC; 50 top = bot = scrollbarGC;
53 break; 51 break;
54 } 52 }
55 53
56/* fill triangle */ 54/* fill triangle */
57 pt[0].x = x; 55 pt[0].x = x;
62 pt[2].y = y; 60 pt[2].y = y;
63 } else { 61 } else {
64 pt[0].y = pt[1].y = y; 62 pt[0].y = pt[1].y = y;
65 pt[2].y = y + sz - 1; 63 pt[2].y = y + sz - 1;
66 } 64 }
67 XFillPolygon(R->Xdisplay, R->scrollBar.win, R->h->scrollbarGC, 65 XFillPolygon(Xdisplay, scrollBar.win, scrollbarGC,
68 pt, 3, Convex, CoordModeOrigin); 66 pt, 3, Convex, CoordModeOrigin);
69 67
70/* draw base */ 68/* draw base */
71 XDrawLine(R->Xdisplay, R->scrollBar.win, (dirn == UP ? bot : top), 69 XDrawLine(Xdisplay, scrollBar.win, (dirn == UP ? bot : top),
72 pt[0].x, pt[0].y, pt[1].x, pt[1].y); 70 pt[0].x, pt[0].y, pt[1].x, pt[1].y);
73 71
74/* draw shadow on left */ 72/* draw shadow on left */
75 pt[1].x = x + sz2 - 1; 73 pt[1].x = x + sz2 - 1;
76 pt[1].y = y + (dirn == UP ? 0 : sz - 1); 74 pt[1].y = y + (dirn == UP ? 0 : sz - 1);
77 XDrawLine(R->Xdisplay, R->scrollBar.win, top, 75 XDrawLine(Xdisplay, scrollBar.win, top,
78 pt[0].x, pt[0].y, pt[1].x, pt[1].y); 76 pt[0].x, pt[0].y, pt[1].x, pt[1].y);
79 77
80#if (SHADOW > 1) 78#if (SHADOW > 1)
81/* doubled */ 79/* doubled */
82 pt[0].x++; 80 pt[0].x++;
85 pt[1].y++; 83 pt[1].y++;
86 } else { 84 } else {
87 pt[0].y++; 85 pt[0].y++;
88 pt[1].y--; 86 pt[1].y--;
89 } 87 }
90 XDrawLine(R->Xdisplay, R->scrollBar.win, top, 88 XDrawLine(Xdisplay, scrollBar.win, top,
91 pt[0].x, pt[0].y, pt[1].x, pt[1].y); 89 pt[0].x, pt[0].y, pt[1].x, pt[1].y);
92#endif 90#endif
93/* draw shadow on right */ 91/* draw shadow on right */
94 pt[1].x = x + sz - 1; 92 pt[1].x = x + sz - 1;
95/* pt[2].x = x + sz2; */ 93/* pt[2].x = x + sz2; */
96 pt[1].y = y + (dirn == UP ? sz - 1 : 0); 94 pt[1].y = y + (dirn == UP ? sz - 1 : 0);
97 pt[2].y = y + (dirn == UP ? 0 : sz - 1); 95 pt[2].y = y + (dirn == UP ? 0 : sz - 1);
98 XDrawLine(R->Xdisplay, R->scrollBar.win, bot, 96 XDrawLine(Xdisplay, scrollBar.win, bot,
99 pt[2].x, pt[2].y, pt[1].x, pt[1].y); 97 pt[2].x, pt[2].y, pt[1].x, pt[1].y);
100#if (SHADOW > 1) 98#if (SHADOW > 1)
101/* doubled */ 99/* doubled */
102 pt[1].x--; 100 pt[1].x--;
103 if (dirn == UP) { 101 if (dirn == UP) {
105 pt[1].y--; 103 pt[1].y--;
106 } else { 104 } else {
107 pt[2].y--; 105 pt[2].y--;
108 pt[1].y++; 106 pt[1].y++;
109 } 107 }
110 XDrawLine(R->Xdisplay, R->scrollBar.win, bot, 108 XDrawLine(Xdisplay, scrollBar.win, bot,
111 pt[2].x, pt[2].y, pt[1].x, pt[1].y); 109 pt[2].x, pt[2].y, pt[1].x, pt[1].y);
112#endif 110#endif
113} 111}
114 112
115/* EXTPROTO */
116int 113int
117rxvt_scrollbar_show_rxvt(pR_ int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len) 114rxvt_term::scrollbar_show_rxvt (int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len)
118{ 115{
119 int sbshadow = R->sb_shadow; 116 int sbshadow = sb_shadow;
120 int sbwidth = (int)R->scrollBar.width; 117 int sbwidth = (int)scrollBar.width;
121 118
122 if ((R->scrollBar.init & R_SB_RXVT) == 0) { 119 if ((scrollBar.init & R_SB_RXVT) == 0) {
123 XGCValues gcvalue; 120 XGCValues gcvalue;
124 121
125 R->scrollBar.init |= R_SB_RXVT; 122 scrollBar.init |= R_SB_RXVT;
126 gcvalue.foreground = R->PixColors[Color_trough]; 123 gcvalue.foreground = PixColors[Color_trough];
127 if (sbshadow) { 124 if (sbshadow) {
128 XSetWindowBackground(R->Xdisplay, R->scrollBar.win, 125 XSetWindowBackground(Xdisplay, scrollBar.win,
129 gcvalue.foreground); 126 gcvalue.foreground);
130 XClearWindow(R->Xdisplay, R->scrollBar.win); 127 XClearWindow(Xdisplay, scrollBar.win);
131 } 128 }
132 } else { 129 } else {
133/* instead of XClearWindow (R->Xdisplay, R->scrollBar.win); */ 130/* instead of XClearWindow (Xdisplay, scrollBar.win); */
134 if (last_top < R->scrollBar.top) 131 if (last_top < scrollBar.top)
135 XClearArea(R->Xdisplay, R->scrollBar.win, 132 XClearArea(Xdisplay, scrollBar.win,
136 sbshadow, last_top, 133 sbshadow, last_top,
137 sbwidth, (R->scrollBar.top - last_top), 134 sbwidth, (scrollBar.top - last_top),
138 False); 135 False);
139 136
140 if (R->scrollBar.bot < last_bot) 137 if (scrollBar.bot < last_bot)
141 XClearArea(R->Xdisplay, R->scrollBar.win, 138 XClearArea(Xdisplay, scrollBar.win,
142 sbshadow, R->scrollBar.bot, 139 sbshadow, scrollBar.bot,
143 sbwidth, (last_bot - R->scrollBar.bot), 140 sbwidth, (last_bot - scrollBar.bot),
144 False); 141 False);
145 } 142 }
146 143
147/* scrollbar slider */ 144/* scrollbar slider */
148#ifdef SB_BORDER 145#ifdef SB_BORDER
149 { 146 {
150 int xofs; 147 int xofs;
151 148
152 if (R->Options & Opt_scrollBar_right) 149 if (Options & Opt_scrollBar_right)
153 xofs = 0; 150 xofs = 0;
154 else 151 else
155 xofs = sbshadow ? sbwidth : sbwidth - 1; 152 xofs = sbshadow ? sbwidth : sbwidth - 1;
156 153
157 XDrawLine(R->Xdisplay, R->scrollBar.win, R->h->botShadowGC, 154 XDrawLine(Xdisplay, scrollBar.win, botShadowGC,
158 xofs, 0, xofs, R->scrollBar.end + sbwidth); 155 xofs, 0, xofs, scrollBar.end + sbwidth);
159 } 156 }
160#endif 157#endif
161 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->scrollbarGC, 158 XFillRectangle(Xdisplay, scrollBar.win, scrollbarGC,
162 sbshadow, R->scrollBar.top, sbwidth, 159 sbshadow, scrollBar.top, sbwidth,
163 scrollbar_len); 160 scrollbar_len);
164 161
165 if (sbshadow) 162 if (sbshadow)
166 /* trough shadow */ 163 /* trough shadow */
167 rxvt_Draw_Shadow(R->Xdisplay, R->scrollBar.win, 164 rxvt_Draw_Shadow(Xdisplay, scrollBar.win,
168 R->h->botShadowGC, R->h->topShadowGC, 165 botShadowGC, topShadowGC,
169 0, 0, 166 0, 0,
170 sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */ 167 sbwidth + 2 * sbshadow, /* scrollbar_TotalWidth() */
171 R->scrollBar.end + (sbwidth + 1) + sbshadow); 168 scrollBar.end + (sbwidth + 1) + sbshadow);
172/* shadow for scrollbar slider */ 169/* shadow for scrollbar slider */
173 rxvt_Draw_Shadow(R->Xdisplay, R->scrollBar.win, 170 rxvt_Draw_Shadow(Xdisplay, scrollBar.win,
174 R->h->topShadowGC, R->h->botShadowGC, 171 topShadowGC, botShadowGC,
175 sbshadow, R->scrollBar.top, sbwidth, 172 sbshadow, scrollBar.top, sbwidth,
176 scrollbar_len); 173 scrollbar_len);
177 174
178/* 175/*
179 * Redraw scrollbar arrows 176 * Redraw scrollbar arrows
180 */ 177 */
181 rxvt_Draw_button(aR_ sbshadow, sbshadow, 178 Draw_button (sbshadow, sbshadow,
182 (scrollbar_isUp() ? -1 : +1), UP); 179 (scrollbar_isUp() ? -1 : +1), UP);
183 rxvt_Draw_button(aR_ sbshadow, (R->scrollBar.end + 1), 180 Draw_button (sbshadow, (scrollBar.end + 1),
184 (scrollbar_isDn() ? -1 : +1), DN); 181 (scrollbar_isDn() ? -1 : +1), DN);
185 return 1; 182 return 1;
186} 183}
187#endif /* RXVT_SCROLLBAR */ 184#endif /* RXVT_SCROLLBAR */
188/*----------------------- end-of-file (C source) -----------------------*/ 185/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines