--- rxvt-unicode/src/scrollbar-next.C 2004/02/01 01:34:41 1.7 +++ rxvt-unicode/src/scrollbar-next.C 2006/01/25 21:09:21 1.22 @@ -1,11 +1,12 @@ /*--------------------------------*-C-*---------------------------------* - * File: scrollbar-next.c + * File: scrollbar-next.C *----------------------------------------------------------------------* * * Copyright (c) 1997,1998 mj olesen * Copyright (c) 1998 Alfredo K. Kojima * - N*XTstep like scrollbars * Copyright (c) 1999-2001 Geoff Wing + * Copyright (c) 2004 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +25,6 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ -#include "scrollbar-next.intpro" /* PROTOS for internal routines */ /*----------------------------------------------------------------------*/ #if defined(NEXT_SCROLLBAR) @@ -123,7 +123,7 @@ Pixmap d; GC pointcolour; - d = XCreatePixmap(Xdisplay, scrollBar.win, width, height, XDEPTH); + d = XCreatePixmap (xdisp, scrollBar.win, width, height, depth); for (y = 0; y < height; y++) { @@ -137,7 +137,8 @@ pointcolour = darkGC; else /* if (a == '#' || a == 'b' || a) */ pointcolour = blackGC; - XDrawPoint(Xdisplay, d, pointcolour, x, y); + + XDrawPoint (xdisp, d, pointcolour, x, y); } } return d; @@ -153,46 +154,45 @@ gcvalue.graphics_exposures = False; - gcvalue.foreground = PixColors[Color_Black]; - blackGC = XCreateGC(Xdisplay, scrollBar.win, - GCForeground | GCGraphicsExposures, &gcvalue); - - gcvalue.foreground = PixColors[Color_White]; - whiteGC = XCreateGC(Xdisplay, scrollBar.win, - GCForeground | GCGraphicsExposures, &gcvalue); + gcvalue.foreground = pix_colors_focused[Color_Black]; + blackGC = XCreateGC (xdisp, scrollBar.win, + GCForeground | GCGraphicsExposures, &gcvalue); + + gcvalue.foreground = pix_colors_focused[Color_White]; + whiteGC = XCreateGC (xdisp, scrollBar.win, + GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0xaeba; xcol.green = 0xaaaa; xcol.blue = 0xaeba; - //if (!rXAllocColor (&xcol, "light gray"))//TODO//D// - xcol.pixel = PixColors[Color_AntiqueWhite]; + xcol.pixel = pix_colors_focused[Color_scroll]; light = gcvalue.foreground = xcol.pixel; - grayGC = XCreateGC(Xdisplay, scrollBar.win, - GCForeground | GCGraphicsExposures, &gcvalue); + grayGC = XCreateGC (xdisp, scrollBar.win, + GCForeground | GCGraphicsExposures, &gcvalue); xcol.red = 0x51aa; xcol.green = 0x5555; xcol.blue = 0x5144; //if (!rXAllocColor (&xcol, "dark gray"))//TODO//D// - xcol.pixel = PixColors[Color_Grey25]; + xcol.pixel = pix_colors_focused[Color_Grey25]; dark = gcvalue.foreground = xcol.pixel; - darkGC = XCreateGC(Xdisplay, scrollBar.win, + darkGC = XCreateGC (xdisp, scrollBar.win, GCForeground | GCGraphicsExposures, &gcvalue); - stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win, - (char *)n_stp_bits, n_stp_width, - n_stp_height); + stipple = XCreateBitmapFromData (xdisp, scrollBar.win, + (char *)n_stp_bits, n_stp_width, + n_stp_height); gcvalue.foreground = dark; gcvalue.background = light; gcvalue.fill_style = FillOpaqueStippled; gcvalue.stipple = stipple; - /* XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[Color_Red]); */ + /* XSetWindowBackground (xdisp, scrollBar.win, pix_colors_focused[Color_Red]); */ - stippleGC = XCreateGC(Xdisplay, scrollBar.win, - GCForeground | GCBackground | GCStipple - | GCFillStyle | GCGraphicsExposures, &gcvalue); + stippleGC = XCreateGC (xdisp, scrollBar.win, + GCForeground | GCBackground | GCStipple + | GCFillStyle | GCGraphicsExposures, &gcvalue); dimple = renderPixmap (SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT); @@ -211,27 +211,27 @@ void rxvt_term::drawBevel (Drawable d, int x1, int y1, int w, int h) { - int x2, y2; + int x2, y2; x2 = x1 + w - 1; /* right point */ y2 = y1 + h - 1; /* bottom point */ /* white top and left */ - XDrawLine(Xdisplay, d, whiteGC, x1, y1, x2, y1); - XDrawLine(Xdisplay, d, whiteGC, x1, y1, x1, y2); + XDrawLine (xdisp, d, whiteGC, x1, y1, x2, y1); + XDrawLine (xdisp, d, whiteGC, x1, y1, x1, y2); /* black bottom and right */ - XDrawLine(Xdisplay, d, blackGC, x1, y2, x2, y2); - XDrawLine(Xdisplay, d, blackGC, x2, y1, x2, y2); + XDrawLine (xdisp, d, blackGC, x1, y2, x2, y2); + XDrawLine (xdisp, d, blackGC, x2, y1, x2, y2); /* dark inside bottom and right */ x1++, y1++, x2--, y2--; /* move in one point */ - XDrawLine(Xdisplay, d, darkGC, x1, y2, x2, y2); - XDrawLine(Xdisplay, d, darkGC, x2, y1, x2, y2); + XDrawLine (xdisp, d, darkGC, x1, y2, x2, y2); + XDrawLine (xdisp, d, darkGC, x2, y1, x2, y2); } int rxvt_term::scrollbar_show_next (int update, int last_top, int last_bot, int scrollbar_len) { - int height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING; - Drawable s; + int height = scrollBar.end + SB_BUTTON_TOTAL_HEIGHT + SB_PADDING; + Drawable s; if ((scrollBar.init & R_SB_NEXT) == 0) { @@ -239,34 +239,38 @@ init_scrollbar_stuff (); } - if (TermWin.nscrolled == 0 || !update) + if (top_row == 0 || !update) { - XFillRectangle(Xdisplay, scrollBar.win, grayGC, 0, 0, - SB_WIDTH_NEXT + 1, height); - XDrawRectangle(Xdisplay, scrollBar.win, blackGC, 0, - -SB_BORDER_WIDTH, SB_WIDTH_NEXT, - height + SB_BORDER_WIDTH); - XFillRectangle(Xdisplay, scrollBar.win, stippleGC, - SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height); + XFillRectangle (xdisp, scrollBar.win, grayGC, 0, 0, + SB_WIDTH_NEXT + 1, height); + XDrawRectangle (xdisp, scrollBar.win, blackGC, 0, + -SB_BORDER_WIDTH, SB_WIDTH_NEXT, + height + SB_BORDER_WIDTH); + XFillRectangle (xdisp, scrollBar.win, stippleGC, + SB_LEFT_PADDING, 0, SB_BUTTON_WIDTH, height); } - if (TermWin.nscrolled) + + if (top_row) { if (last_top < scrollBar.top || !update) - XFillRectangle(Xdisplay, scrollBar.win, stippleGC, - SB_LEFT_PADDING, SB_PADDING + last_top, - SB_BUTTON_WIDTH, scrollBar.top - last_top); + XFillRectangle (xdisp, scrollBar.win, stippleGC, + SB_LEFT_PADDING, SB_PADDING + last_top, + SB_BUTTON_WIDTH, scrollBar.top - last_top); + if (scrollBar.bot < last_bot || !update) - XFillRectangle(Xdisplay, scrollBar.win, stippleGC, - SB_LEFT_PADDING, scrollBar.bot + SB_PADDING, - SB_BUTTON_WIDTH, (last_bot - scrollBar.bot)); - XFillRectangle(Xdisplay, scrollBar.win, grayGC, - SB_LEFT_PADDING, scrollBar.top + SB_PADDING, - SB_BUTTON_WIDTH, scrollbar_len); - XCopyArea(Xdisplay, dimple, scrollBar.win, whiteGC, 0, 0, - SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, - (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2, - scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT + - (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2); + XFillRectangle (xdisp, scrollBar.win, stippleGC, + SB_LEFT_PADDING, scrollBar.bot + SB_PADDING, + SB_BUTTON_WIDTH, (last_bot - scrollBar.bot)); + + XFillRectangle (xdisp, scrollBar.win, grayGC, + SB_LEFT_PADDING, scrollBar.top + SB_PADDING, + SB_BUTTON_WIDTH, scrollbar_len); + + XCopyArea (xdisp, dimple, scrollBar.win, whiteGC, 0, 0, + SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, + (SB_WIDTH_NEXT - SCROLLER_DIMPLE_WIDTH) / 2, + scrollBar.top + SB_BEVEL_WIDTH_UPPER_LEFT + + (scrollbar_len - SCROLLER_DIMPLE_HEIGHT) / 2); drawBevel (scrollBar.win, SB_BUTTON_BEVEL_X, scrollBar.top + SB_PADDING, SB_BUTTON_WIDTH, @@ -278,16 +282,17 @@ height - SB_BUTTON_SINGLE_HEIGHT, SB_BUTTON_WIDTH, SB_BUTTON_HEIGHT); - s = (scrollbar_isUp()) ? upArrowHi : upArrow; - XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0, - ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, - height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); - - s = (scrollbar_isDn()) ? downArrowHi : downArrow; - XCopyArea(Xdisplay, s, scrollBar.win, whiteGC, 0, 0, - ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, - height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); + s = (scrollbar_isUp ()) ? upArrowHi : upArrow; + XCopyArea (xdisp, s, scrollBar.win, whiteGC, 0, 0, + ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, + height - SB_BUTTON_BOTH_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); + + s = (scrollbar_isDn ()) ? downArrowHi : downArrow; + XCopyArea (xdisp, s, scrollBar.win, whiteGC, 0, 0, + ARROW_WIDTH, ARROW_HEIGHT, SB_BUTTON_FACE_X, + height - SB_BUTTON_SINGLE_HEIGHT + SB_BEVEL_WIDTH_UPPER_LEFT); } + return 1; } #endif /* NEXT_SCROLLBAR */