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

Comparing rxvt-unicode/src/scrollbar-next.C (file contents):
Revision 1.2 by pcg, Mon Nov 24 17:31:28 2003 UTC vs.
Revision 1.3 by pcg, Tue Nov 25 11:52:42 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: scrollbar-next.c 2 * File: scrollbar-next.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: scrollbar-next.C,v 1.2 2003/11/24 17:31:28 pcg Exp $ 4 * $Id: scrollbar-next.C,v 1.3 2003/11/25 11:52:42 pcg Exp $
5 * 5 *
6 * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA> 6 * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA>
7 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> 7 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org>
8 * - N*XTstep like scrollbars 8 * - N*XTstep like scrollbars
9 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> 9 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
123 d = XCreatePixmap(R->Xdisplay, R->scrollBar.win, width, height, XDEPTH); 123 d = XCreatePixmap(R->Xdisplay, R->scrollBar.win, width, height, XDEPTH);
124 124
125 for (y = 0; y < height; y++) { 125 for (y = 0; y < height; y++) {
126 for (x = 0; x < width; x++) { 126 for (x = 0; x < width; x++) {
127 if ((a = data[y][x]) == ' ' || a == 'w') 127 if ((a = data[y][x]) == ' ' || a == 'w')
128 pointcolour = R->h->whiteGC; 128 pointcolour = R->whiteGC;
129 else if (a == '.' || a == 'l') 129 else if (a == '.' || a == 'l')
130 pointcolour = R->h->grayGC; 130 pointcolour = R->grayGC;
131 else if (a == '%' || a == 'd') 131 else if (a == '%' || a == 'd')
132 pointcolour = R->h->darkGC; 132 pointcolour = R->darkGC;
133 else /* if (a == '#' || a == 'b' || a) */ 133 else /* if (a == '#' || a == 'b' || a) */
134 pointcolour = R->h->blackGC; 134 pointcolour = R->blackGC;
135 XDrawPoint(R->Xdisplay, d, pointcolour, x, y); 135 XDrawPoint(R->Xdisplay, d, pointcolour, x, y);
136 } 136 }
137 } 137 }
138 return d; 138 return d;
139} 139}
148 unsigned long light, dark; 148 unsigned long light, dark;
149 149
150 gcvalue.graphics_exposures = False; 150 gcvalue.graphics_exposures = False;
151 151
152 gcvalue.foreground = R->PixColors[Color_Black]; 152 gcvalue.foreground = R->PixColors[Color_Black];
153 R->h->blackGC = XCreateGC(R->Xdisplay, R->scrollBar.win, 153 R->blackGC = XCreateGC(R->Xdisplay, R->scrollBar.win,
154 GCForeground | GCGraphicsExposures, &gcvalue); 154 GCForeground | GCGraphicsExposures, &gcvalue);
155 155
156 gcvalue.foreground = R->PixColors[Color_White]; 156 gcvalue.foreground = R->PixColors[Color_White];
157 R->h->whiteGC = XCreateGC(R->Xdisplay, R->scrollBar.win, 157 R->whiteGC = XCreateGC(R->Xdisplay, R->scrollBar.win,
158 GCForeground | GCGraphicsExposures, &gcvalue); 158 GCForeground | GCGraphicsExposures, &gcvalue);
159 159
160 xcol.red = 0xaeba; 160 xcol.red = 0xaeba;
161 xcol.green = 0xaaaa; 161 xcol.green = 0xaaaa;
162 xcol.blue = 0xaeba; 162 xcol.blue = 0xaeba;
163 if (!rxvt_rXAllocColor(aR_ &xcol, "light gray")) 163 if (!rxvt_rXAllocColor(aR_ &xcol, "light gray"))
164 xcol.pixel = R->PixColors[Color_AntiqueWhite]; 164 xcol.pixel = R->PixColors[Color_AntiqueWhite];
165 light = gcvalue.foreground = xcol.pixel; 165 light = gcvalue.foreground = xcol.pixel;
166 R->h->grayGC = XCreateGC(R->Xdisplay, R->scrollBar.win, 166 R->grayGC = XCreateGC(R->Xdisplay, R->scrollBar.win,
167 GCForeground | GCGraphicsExposures, &gcvalue); 167 GCForeground | GCGraphicsExposures, &gcvalue);
168 168
169 xcol.red = 0x51aa; 169 xcol.red = 0x51aa;
170 xcol.green = 0x5555; 170 xcol.green = 0x5555;
171 xcol.blue = 0x5144; 171 xcol.blue = 0x5144;
172 if (!rxvt_rXAllocColor(aR_ &xcol, "dark gray")) 172 if (!rxvt_rXAllocColor(aR_ &xcol, "dark gray"))
173 xcol.pixel = R->PixColors[Color_Grey25]; 173 xcol.pixel = R->PixColors[Color_Grey25];
174 dark = gcvalue.foreground = xcol.pixel; 174 dark = gcvalue.foreground = xcol.pixel;
175 R->h->darkGC = XCreateGC(R->Xdisplay, R->scrollBar.win, 175 R->darkGC = XCreateGC(R->Xdisplay, R->scrollBar.win,
176 GCForeground | GCGraphicsExposures, &gcvalue); 176 GCForeground | GCGraphicsExposures, &gcvalue);
177 177
178 stipple = XCreateBitmapFromData(R->Xdisplay, R->scrollBar.win, 178 stipple = XCreateBitmapFromData(R->Xdisplay, R->scrollBar.win,
179 (char *)n_stp_bits, n_stp_width, 179 (char *)n_stp_bits, n_stp_width,
180 n_stp_height); 180 n_stp_height);
184 gcvalue.fill_style = FillOpaqueStippled; 184 gcvalue.fill_style = FillOpaqueStippled;
185 gcvalue.stipple = stipple; 185 gcvalue.stipple = stipple;
186 186
187/* XSetWindowBackground(R->Xdisplay, R->scrollBar.win, R->PixColors[Color_Red]); */ 187/* XSetWindowBackground(R->Xdisplay, R->scrollBar.win, R->PixColors[Color_Red]); */
188 188
189 R->h->stippleGC = XCreateGC(R->Xdisplay, R->scrollBar.win, 189 R->stippleGC = XCreateGC(R->Xdisplay, R->scrollBar.win,
190 GCForeground | GCBackground | GCStipple 190 GCForeground | GCBackground | GCStipple
191 | GCFillStyle | GCGraphicsExposures, &gcvalue); 191 | GCFillStyle | GCGraphicsExposures, &gcvalue);
192 192
193 R->h->dimple = rxvt_renderPixmap(aR_ SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, 193 R->dimple = rxvt_renderPixmap(aR_ SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH,
194 SCROLLER_DIMPLE_HEIGHT); 194 SCROLLER_DIMPLE_HEIGHT);
195 195
196 R->h->upArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_UP, ARROW_WIDTH, 196 R->upArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_UP, ARROW_WIDTH,
197 ARROW_HEIGHT); 197 ARROW_HEIGHT);
198 R->h->downArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_DOWN, ARROW_WIDTH, 198 R->downArrow = rxvt_renderPixmap(aR_ SCROLLER_ARROW_DOWN, ARROW_WIDTH,
199 ARROW_HEIGHT); 199 ARROW_HEIGHT);
200 R->h->upArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_UP, ARROW_WIDTH, 200 R->upArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_UP, ARROW_WIDTH,
201 ARROW_HEIGHT); 201 ARROW_HEIGHT);
202 R->h->downArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_DOWN, 202 R->downArrowHi = rxvt_renderPixmap(aR_ HI_SCROLLER_ARROW_DOWN,
203 ARROW_WIDTH, ARROW_HEIGHT); 203 ARROW_WIDTH, ARROW_HEIGHT);
204} 204}
205 205
206/* Draw bevel & arrows */ 206/* Draw bevel & arrows */
207/* INTPROTO */ 207/* INTPROTO */
211 int x2, y2; 211 int x2, y2;
212 212
213 x2 = x1 + w - 1; /* right point */ 213 x2 = x1 + w - 1; /* right point */
214 y2 = y1 + h - 1; /* bottom point */ 214 y2 = y1 + h - 1; /* bottom point */
215/* white top and left */ 215/* white top and left */
216 XDrawLine(R->Xdisplay, d, R->h->whiteGC, x1, y1, x2, y1); 216 XDrawLine(R->Xdisplay, d, R->whiteGC, x1, y1, x2, y1);
217 XDrawLine(R->Xdisplay, d, R->h->whiteGC, x1, y1, x1, y2); 217 XDrawLine(R->Xdisplay, d, R->whiteGC, x1, y1, x1, y2);
218/* black bottom and right */ 218/* black bottom and right */
219 XDrawLine(R->Xdisplay, d, R->h->blackGC, x1, y2, x2, y2); 219 XDrawLine(R->Xdisplay, d, R->blackGC, x1, y2, x2, y2);
220 XDrawLine(R->Xdisplay, d, R->h->blackGC, x2, y1, x2, y2); 220 XDrawLine(R->Xdisplay, d, R->blackGC, x2, y1, x2, y2);
221/* dark inside bottom and right */ 221/* dark inside bottom and right */
222 x1++, y1++, x2--, y2--; /* move in one point */ 222 x1++, y1++, x2--, y2--; /* move in one point */
223 XDrawLine(R->Xdisplay, d, R->h->darkGC, x1, y2, x2, y2); 223 XDrawLine(R->Xdisplay, d, R->darkGC, x1, y2, x2, y2);
224 XDrawLine(R->Xdisplay, d, R->h->darkGC, x2, y1, x2, y2); 224 XDrawLine(R->Xdisplay, d, R->darkGC, x2, y1, x2, y2);
225} 225}
226 226
227/* EXTPROTO */ 227/* EXTPROTO */
228int 228int
229rxvt_scrollbar_show_next(pR_ int update, int last_top, int last_bot, int scrollbar_len) 229rxvt_scrollbar_show_next(pR_ int update, int last_top, int last_bot, int scrollbar_len)
235 R->scrollBar.init |= R_SB_NEXT; 235 R->scrollBar.init |= R_SB_NEXT;
236 rxvt_init_scrollbar_stuff(aR); 236 rxvt_init_scrollbar_stuff(aR);
237 } 237 }
238 238
239 if (R->TermWin.nscrolled == 0 || !update) { 239 if (R->TermWin.nscrolled == 0 || !update) {
240 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->grayGC, 0, 0, 240 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->grayGC, 0, 0,
241 SB_WIDTH_NEXT + 1, height); 241 SB_WIDTH_NEXT + 1, height);
242 XDrawRectangle(R->Xdisplay, R->scrollBar.win, R->h->blackGC, 0, 242 XDrawRectangle(R->Xdisplay, R->scrollBar.win, R->blackGC, 0,
243 -SB_BORDER_WIDTH, SB_WIDTH_NEXT, 243 -SB_BORDER_WIDTH, SB_WIDTH_NEXT,
244 height + SB_BORDER_WIDTH); 244 height + SB_BORDER_WIDTH);
245 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->stippleGC, 245 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->stippleGC,
246 SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height); 246 SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height);
247 } 247 }
248 if (R->TermWin.nscrolled) { 248 if (R->TermWin.nscrolled) {
249 if (last_top < R->scrollBar.top || !update) 249 if (last_top < R->scrollBar.top || !update)
250 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->stippleGC, 250 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->stippleGC,
251 SB_LEFT_PADDING, SB_PADDING + last_top, 251 SB_LEFT_PADDING, SB_PADDING + last_top,
252 SB_BUTTON_WIDTH, R->scrollBar.top - last_top); 252 SB_BUTTON_WIDTH, R->scrollBar.top - last_top);
253 if (R->scrollBar.bot < last_bot || !update) 253 if (R->scrollBar.bot < last_bot || !update)
254 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->stippleGC, 254 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->stippleGC,
255 SB_LEFT_PADDING, R->scrollBar.bot + SB_PADDING, 255 SB_LEFT_PADDING, R->scrollBar.bot + SB_PADDING,
256 SB_BUTTON_WIDTH, (last_bot - R->scrollBar.bot)); 256 SB_BUTTON_WIDTH, (last_bot - R->scrollBar.bot));
257 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->h->grayGC, 257 XFillRectangle(R->Xdisplay, R->scrollBar.win, R->grayGC,
258 SB_LEFT_PADDING, R->scrollBar.top + SB_PADDING, 258 SB_LEFT_PADDING, R->scrollBar.top + SB_PADDING,
259 SB_BUTTON_WIDTH, scrollbar_len); 259 SB_BUTTON_WIDTH, scrollbar_len);
260 XCopyArea(R->Xdisplay, R->h->dimple, R->scrollBar.win, R->h->whiteGC, 0, 0, 260 XCopyArea(R->Xdisplay, R->dimple, R->scrollBar.win, R->whiteGC, 0, 0,
261 SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, 261 SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT,
262 (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2, 262 (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2,
263 R->scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT + 263 R->scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT +
264 (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2); 264 (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2);
265 265
271 SB_BUTTON_HEIGHT); 271 SB_BUTTON_HEIGHT);
272 rxvt_drawBevel(aR_ R->scrollBar.win, SB_BUTTON_BEVEL_X, 272 rxvt_drawBevel(aR_ R->scrollBar.win, SB_BUTTON_BEVEL_X,
273 height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH, 273 height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH,
274 SB_BUTTON_HEIGHT); 274 SB_BUTTON_HEIGHT);
275 275
276 s = (scrollbar_isUp()) ? R->h->upArrowHi : R->h->upArrow; 276 s = (scrollbar_isUp()) ? R->upArrowHi : R->upArrow;
277 XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->h->whiteGC, 0, 0, 277 XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->whiteGC, 0, 0,
278 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, 278 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
279 height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); 279 height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
280 280
281 s = (scrollbar_isDn()) ? R->h->downArrowHi : R->h->downArrow; 281 s = (scrollbar_isDn()) ? R->downArrowHi : R->downArrow;
282 XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->h->whiteGC, 0, 0, 282 XCopyArea(R->Xdisplay, s, R->scrollBar.win, R->whiteGC, 0, 0,
283 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, 283 ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X,
284 height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); 284 height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT);
285 } 285 }
286 return 1; 286 return 1;
287} 287}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines