--- src/main.c.old Fri Jun 9 07:36:27 2000 +++ src/main.c Mon Jan 29 10:44:05 2001 @@ -770,15 +770,20 @@ scrollBar.beg = 0; scrollBar.end = height; #ifndef XTERM_SCROLLBAR -# ifdef NEXT_SCROLLBAR +#ifdef NEXT_SCROLLBAR /* arrows can be different */ scrollBar.end -= GetScrollArrowsHeight(); -# else +#else +#ifdef SGI_SCROLLBAR + scrollBar.beg += GetScrollArrowHeight(); + scrollBar.end -= GetScrollArrowHeight(); +#else /* arrows are as high as wide - leave 1 pixel gap */ scrollBar.beg += (SB_WIDTH + 1) + sb_shadow; scrollBar.end -= (SB_WIDTH + 1) + sb_shadow; -# endif +#endif #endif +#endif width -= (SB_WIDTH + 2 * sb_shadow); if (Options & Opt_scrollBar_right) @@ -1162,6 +1167,58 @@ break; } } + +/* + * Xwsh escape sequences: ESC P Ps.y;Pt ESC \ + * 1 = change title + * 3 = change iconName + * 4 = set text color by string + * 5 = set page color by string + * 6 = set selection text color by string + * 7 = set selection page color by string + * 8 = set cursor text color by string + * 9 = set cursor page color by string + * 10 = set half intensity by string + * 11 = set bold intensity by string + * 101 = bind string to key Ps+1 and pass as value + * 103 = bind string to key Ps+1 and pass s function + */ +/* PROTO */ +void +xwsh_seq(int op, const char *str) +{ + int changed = 0; + + assert(str != NULL); + switch (op) { + case Xwsh_title: + set_title(str); + break; + case Xwsh_iconName: + set_iconName(str); + break; + case Xwsh_textColor: + break; + case Xwsh_pageColor: + break; + case Xwsh_selTextColor: + break; + case Xwsh_selPageColor: + break; + case Xwsh_cursorTextColor: + break; + case Xwsh_cursorPageColor: + break; + case Xwsh_halfIntColor: + break; + case Xwsh_boldIntColor: + break; + case Xwsh_bindStrKeyVal: + break; + case Xwsh_bindStrKeyFunc: + break; + } +} /*}}} */ @@ -1702,7 +1759,7 @@ SetBackgroundType( rs_backgroundType ); #endif -#if defined(XTERM_SCROLLBAR) || defined(NEXT_SCROLLBAR) +#if defined(XTERM_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(SGI_SCROLLBAR) sb_shadow = 0; #else sb_shadow = (Options & Opt_scrollBar_floating) ? 0 : SHADOW; --- src/feature.h.old Tue May 16 09:05:37 2000 +++ src/feature.h Mon Jan 29 10:44:05 2001 @@ -171,6 +171,19 @@ #endif /* XTERM_SCROLLBAR */ #endif +#ifdef SGI_SCROLLBAR +#undef SB_WIDTH +/* could be anything from 13 to 19 but the true SGI Xwsh is 18 */ +#define SB_WIDTH 18 +/* this will define somemore parameters for shaping Xwsh scrollbars */ +/* NEXT_SCROLL_CLEAN if defined removes shades of gray from buttons */ +#define NEXT_SCROLL_CLEAN +#define NEXT_SCROLL_SQUARE_ARROWS +#define SB_BORDER_WIDTH 1 +/* this makes buttons thinner then scrollbar's base ( if more then 0 ) */ +#define SIDE_STEP_WIDTH 0 +#endif + /* * Default separating chars for multiple-click selection * Space and tab are separate separating characters and are not settable --- src/protos.h.old Tue May 16 09:07:49 2000 +++ src/protos.h Mon Jan 29 10:44:05 2001 @@ -14,7 +14,11 @@ #ifdef NEXT_SCROLLBAR # include "scrollbar2.pro" #else +#ifdef SGI_SCROLLBAR +# include "scrollbar3.pro" +#else # include "scrollbar.pro" +#endif #endif #ifdef UTMP_SUPPORT #include "utmp.pro" --- src/command.c.old Sun May 28 09:46:35 2000 +++ src/command.c Mon Jan 29 10:44:05 2001 @@ -195,7 +195,7 @@ # define MULTICLICK_TIME 500 #endif #ifndef SCROLLBAR_INITIAL_DELAY -# ifdef NEXT_SCROLLER +#if defined(NEXT_SCROLLER) || defined(SGI_SCROLLER) # define SCROLLBAR_INITIAL_DELAY 20 # else # define SCROLLBAR_INITIAL_DELAY 40 @@ -2873,6 +2873,9 @@ case ']': process_xterm_seq(); break; + case 'P': + process_xwsh_seq(); + break; case 'c': scr_poweron(); break; @@ -3116,6 +3119,42 @@ menubar_dispatch((char *) string); else xterm_seq(arg, (char *) string); + } +} +/*}}} */ + +/*{{{ process xwsh text parameters sequences `ESC P Ps .y Pt ESC\' */ +/* PROTO */ +void +process_xwsh_seq(void) +{ + unsigned char ch, string[STRING_MAX]; + int i,arg; + + ch = cmd_getc(); + for (arg = 0; isdigit(ch); ch = cmd_getc()) + arg = arg * 10 + (ch - '0'); + + if (ch == '.') { + if ((ch = cmd_getc()) == 'y') { + int n = 0; + + while ((ch = cmd_getc()) != '\033') { + if (ch) { + if (ch == '\t') + ch = ' '; /* translate '\t' to space */ + else if (ch < ' ') + return; /* control character - exit */ + + if (n < sizeof(string) - 1) + string[n++] = ch; + } + } + if ((ch = cmd_getc()) == '\\') { + string[n] = '\0'; + xwsh_seq(arg, (char *) string); + } + } } } /*}}} */ --- src/rxvt.h.old Sun Jul 2 23:08:24 2000 +++ src/rxvt.h Mon Jan 29 10:44:05 2001 @@ -699,6 +699,22 @@ #define XTerm_font 50 /* + * Xwsh escape sequences: ESC P Ps .y Pt ESC\ + */ +#define Xwsh_title 1 +#define Xwsh_iconName 3 +#define Xwsh_textColor 4 +#define Xwsh_pageColor 5 +#define Xwsh_selTextColor 6 +#define Xwsh_selPageColor 7 +#define Xwsh_cursorTextColor 8 +#define Xwsh_cursorPageColor 9 +#define Xwsh_halfIntColor 10 +#define Xwsh_boldIntColor 11 +#define Xwsh_bindStrKeyVal 101 /* not implemented */ +#define Xwsh_bindStrKeyFunc 103 /* not implemented */ + +/* * rxvt extensions of XTerm escape sequences: ESC ] Ps;Pt BEL */ #define XTerm_Menu 10 /* set menu item */ @@ -835,6 +851,12 @@ && (y) <= scrollbar_dnval()) # define scrollbar_dnButton(y) ((y) > scrollbar_dnval()) #else +# define scrollbar_upButton(y) ((y) < scrollBar.beg) +# define scrollbar_dnButton(y) ((y) > scrollBar.end) +#endif + +#ifdef SGI_SCROLLBAR +# define scrollbar_dnval() (scrollBar.end + (SB_WIDTH + 1)) # define scrollbar_upButton(y) ((y) < scrollBar.beg) # define scrollbar_dnButton(y) ((y) > scrollBar.end) #endif --- src/xdefaults.c.old Wed May 31 00:17:56 2000 +++ src/xdefaults.c Mon Jan 29 10:44:05 2001 @@ -419,6 +419,9 @@ #ifdef NEXT_SCROLLBAR fprintf(stderr, "NeXT scrollbar,"); # endif +#ifdef SGI_SCROLLBAR + fprintf(stderr, "SGI Xwsh scrollbar,"); +# endif #ifdef NO_RESOURCES fprintf(stderr, "NoResources"); #else --- autoconf/config.h.in.old Mon May 22 08:56:13 2000 +++ autoconf/config.h.in Mon Jan 29 10:44:05 2001 @@ -101,6 +101,9 @@ /* Define if you want to use NeXT style scrollbars */ #undef NEXT_SCROLLBAR +/* Define if you want to use SGI style scrollbars */ +#undef SGI_SCROLLBAR + /* Define if you want to revert to Xterm style scrollbars */ #undef XTERM_SCROLLBAR --- autoconf/configure.in.old Mon May 29 10:58:49 2000 +++ autoconf/configure.in Mon Jan 29 10:44:05 2001 @@ -82,6 +82,13 @@ SBARFILE=scrollbar2 fi +AC_ARG_ENABLE(sgi-scroll, + [ --enable-sgi-scroll enable SGI Xwsh style scrollbar], + [if test x$enableval = xyes; then + AC_DEFINE(SGI_SCROLLBAR) + SBARFILE=scrollbar3 + fi]) + AC_ARG_ENABLE(xterm-scroll, [ --enable-xterm-scroll revert to Xterm style scrollbar], [if test x$enableval = xyes; then --- autoconf/acconfig.h.old Mon May 22 08:56:13 2000 +++ autoconf/acconfig.h Mon Jan 29 10:44:05 2001 @@ -56,6 +56,9 @@ /* Define if you want to use NeXT style scrollbars */ #undef NEXT_SCROLLBAR +/* Define if you want to use SGI style scrollbars */ +#undef SGI_SCROLLBAR + /* Define if you want to revert to Xterm style scrollbars */ #undef XTERM_SCROLLBAR --- configure.old Mon May 29 10:58:49 2000 +++ configure Mon Jan 29 10:44:05 2001 @@ -26,7 +26,7 @@ ac_help="$ac_help --enable-graphics enable aterm own graphics mode (see src/graphics)" ac_help="$ac_help - --enable-next-scroll enable NeXT style scrollbar [yes] " + --enable-sgi-scroll enable SGI style scrollbar [yes] " ac_help="$ac_help --enable-xterm-scroll revert to Xterm style scrollbar" ac_help="$ac_help @@ -729,14 +727,24 @@ enable_next_scroll="yes" fi +# Check whether --enable-sgi-scroll or --disable-sgi-scroll was given. +if test "${enable_sgi_scroll+set}" = set; then + enableval="$enable_sgi_scroll" + if test x$enableval = xyes; then + cat >> confdefs.h <<\EOF +#define SGI_SCROLLBAR 1 +EOF -if test "x$enable_next_scroll" = "xyes"; -then + SBARFILE=scrollbar3 + else + if test "x$enable_next_scroll" = "xyes"; then cat >> confdefs.h <<\EOF #define NEXT_SCROLLBAR 1 EOF SBARFILE=scrollbar2 + fi + fi fi # Check whether --enable-xterm-scroll or --disable-xterm-scroll was given. --- /dev/null Wed Mar 20 09:46:35 2002 +++ src/scrollbar3.c Sun Jan 28 12:18:52 2001 @@ -0,0 +1,858 @@ + /*--------------------------------*-C-*---------------------------------* + * File: scrollbar3.c + *----------------------------------------------------------------------* + * SGI Xwsh Scrollbar hack by Frank Everdij + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *----------------------------------------------------------------------*/ +/* + * Same code as scrollbar2.c, but this one is rewritten to do + * SGI IRIX Xwsh-like scrollbars. Original code from Alfredo Kojima and + * Sasha Vasko + * + * 2000 Frank Everdij + */ + + +#include "rxvt.h" /* NECESSARY */ + +/*----------------------------------------------------------------------* + */ + +static GC paintGC = None; +static GC grayGC = None; +static GC stippleGC = None; +static Pixel blackPixel, whitePixel, lightPixel, lmediumPixel, mediumPixel, darkPixel, vdarkPixel; + +static char *SCROLLER_DIMPLE[] = { +" ", +"##############", +".============%", +".============%", +" ", +"##############", +".============%", +".============%", +" ", +"##############" +}; + +#define SCROLLER_DIMPLE_WIDTH 14 +#define SCROLLER_DIMPLE_HEIGHT 10 + + + +static char *SCROLLER_ARROW_UP[] = { +"==============", +"==============", +"======*=======", +"======**======", +"======**======", +"=====****=====", +"=====****=====", +"====******====", +"====******====", +"===********===", +"===********===", +"==============", +"==============", +"==============" +}; + +static char *SCROLLER_ARROW_DOWN[] = { +"==============", +"==============", +"==*********===", +"===********===", +"===********===", +"====******====", +"====******====", +"=====****=====", +"=====****=====", +"======**======", +"======**======", +"==============", +"==============", +"==============" +}; + + + +static char *LO_SCROLLER_ARROW_UP[] = { +"==============", +"==============", +"======-=======", +"======--======", +"======--======", +"=====----=====", +"=====----=====", +"====------====", +"====------====", +"===--------===", +"===--------===", +"==============", +"==============", +"==============" +}; + +static char *LO_SCROLLER_ARROW_DOWN[] = { +"==============", +"==============", +"==---------===", +"===--------===", +"===--------===", +"====------====", +"====------====", +"=====----=====", +"=====----=====", +"======--======", +"======--======", +"==============", +"==============", +"==============" +}; + + + +static char *HI_SCROLLER_ARROW_UP[] = { +" ", +" ", +" % ", +" %% ", +" %% ", +" %%%% ", +" %%%% ", +" %%%%%% ", +" %%%%%% ", +" %%%%%%%% ", +" %%%%%%%% ", +" ", +" ", +" " +}; + +static char *HI_SCROLLER_ARROW_DOWN[] = { +" ", +" ", +" %%%%%%%%% ", +" %%%%%%%% ", +" %%%%%%%% ", +" %%%%%% ", +" %%%%%% ", +" %%%% ", +" %%%% ", +" %% ", +" %% ", +" ", +" ", +" " +}; + +#define ARROW_SOURCE_WIDTH 14 +#define ARROW_SOURCE_HEIGHT 14 + +typedef struct { + Pixmap icon ; + Pixmap icon_mask ; + int origin_x, origin_y, width, height ; +} Icon; + +typedef struct { + unsigned arrow_width, arrow_height ; + int bValid ; + char** Data[6] ; + Icon Arrows[6] ; +}ScrollArrows ; + +static Icon dimple = +{None, None, 0, 0, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT}; + +static ScrollArrows NeXTScrollArrows = +{ ARROW_SOURCE_WIDTH, ARROW_SOURCE_HEIGHT, 0, + {SCROLLER_ARROW_UP, HI_SCROLLER_ARROW_UP, LO_SCROLLER_ARROW_UP, + SCROLLER_ARROW_DOWN, HI_SCROLLER_ARROW_DOWN, LO_SCROLLER_ARROW_DOWN} }; +#define UP_ARROW (NeXTScrollArrows.Arrows[0]) +#define UP_ARROW_HI (NeXTScrollArrows.Arrows[1]) +#define UP_ARROW_LO (NeXTScrollArrows.Arrows[2]) +#define DOWN_ARROW (NeXTScrollArrows.Arrows[3]) +#define DOWN_ARROW_HI (NeXTScrollArrows.Arrows[4]) +#define DOWN_ARROW_LO (NeXTScrollArrows.Arrows[5]) + + +#define ARROW_WIDTH (NeXTScrollArrows.arrow_width) +#define ARROW_HEIGHT (NeXTScrollArrows.arrow_height) + +#define BEVEL_HI_WIDTH 1 +#define BEVEL_LO_WIDTH 1 +#define BEVEL_SIZE (BEVEL_HI_WIDTH+BEVEL_LO_WIDTH) + +#define SB_BUTTON_HEIGHT ((BEVEL_SIZE<<1)+ARROW_HEIGHT) +#define SB_BUTTONS_HEIGHT (SB_BUTTON_HEIGHT<<1) + +#ifndef SB_BORDER_WIDTH +# define SB_BORDER_WIDTH 1 +#endif +#define SB_BORDER_SIZE (SB_BORDER_WIDTH<<1) + +#ifndef SIDE_STEP_WIDTH +# define SIDE_STEP_WIDTH 0 +#endif +#ifndef SCROLL_SHADOW_HEIGHT +# define SCROLL_SHADOW_HEIGHT 1 +#endif +/* end unconfigurable stuff */ + + +#define stp_width 8 +#define stp_height 8 +static unsigned char stp_bits[] = { + 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa}; + +#ifdef TRANSPARENT +#define IS_TRANSP_SCROLL (Options&Opt_transparent_sb) +#else +#define IS_TRANSP_SCROLL 0 +#endif + +typedef struct { + GC blackGC; + GC whiteGC; + GC lightGC; + GC lmediumGC; + GC mediumGC; + GC darkGC; + GC vdarkGC; + GC maskGC; + GC maskGC_0; +}IconGC; + + +static void +init_scroll_size(void) +{ + NeXTScrollArrows.arrow_width = (SB_WIDTH-(BEVEL_SIZE<<1)-SIDE_STEP_WIDTH); + MIN_IT( NeXTScrollArrows.arrow_width, ARROW_SOURCE_WIDTH ); + +#ifdef NEXT_SCROLL_SQUARE_ARROWS + NeXTScrollArrows.arrow_height = NeXTScrollArrows.arrow_width ; +#else + NeXTScrollArrows.arrow_height = ARROW_SOURCE_HEIGHT ; +#endif + NeXTScrollArrows.bValid = 1 ; +} + +/* PROTO */ +unsigned +GetScrollArrowsHeight() +{ + if( !NeXTScrollArrows.bValid ) init_scroll_size(); + return (SB_BUTTONS_HEIGHT); +} + +/* PROTO */ +unsigned +GetScrollArrowHeight() +{ + if( !NeXTScrollArrows.bValid ) init_scroll_size(); + return (SB_BUTTON_HEIGHT); +} + +static void +CheckIconGC(IconGC* igc, Pixmap icon, Pixmap icon_mask) +{ + XGCValues values ; + unsigned long valuemask = GCForeground|GCGraphicsExposures ; + + values.graphics_exposures = False; + + if( igc == NULL ) return ; + if( igc->maskGC == None ) + { + values.foreground = 1 ; + igc->maskGC = XCreateGC( Xdisplay, icon_mask, valuemask, &values ); + } + if( igc->maskGC_0 == None ) + { + values.foreground = 0 ; + igc->maskGC_0 = XCreateGC( Xdisplay, icon_mask, valuemask, &values ); + } + if( igc->whiteGC == None ) + { + values.foreground = whitePixel ; + igc->whiteGC = XCreateGC( Xdisplay, icon, valuemask, &values ); + } + if( igc->lightGC == None ) + { + values.foreground = lightPixel ; + igc->lightGC = XCreateGC( Xdisplay, icon, valuemask, &values ); + } + if( igc->lmediumGC == None ) + { + values.foreground = lmediumPixel ; + igc->lmediumGC = XCreateGC( Xdisplay, icon, valuemask, &values ); + } + if( igc->mediumGC == None ) + { + values.foreground = mediumPixel ; + igc->mediumGC = XCreateGC( Xdisplay, icon, valuemask, &values ); + } + if( igc->darkGC == None ) + { + values.foreground = darkPixel ; + igc->darkGC = XCreateGC( Xdisplay, icon, valuemask, &values ); + } + if( igc->vdarkGC == None ) + { + values.foreground = vdarkPixel ; + igc->vdarkGC = XCreateGC( Xdisplay, icon, valuemask, &values ); + } + if( igc->blackGC == None ) + { + values.foreground = blackPixel ; + igc->blackGC = XCreateGC( Xdisplay, icon, valuemask, &values ); + } +} + +static void +FreeIconGC( IconGC* igc ) +{ + if( igc ) + { + if( igc->maskGC != None ) + { + XFreeGC( Xdisplay, igc->maskGC ); + igc->maskGC = None; + } + if( igc->maskGC_0 != None ) + { + XFreeGC( Xdisplay, igc->maskGC_0 ); + igc->maskGC_0 = None; + } + if( igc->whiteGC == None ) + { + XFreeGC( Xdisplay, igc->whiteGC ); + igc->whiteGC = None; + } + if( igc->lightGC == None ) + { + XFreeGC( Xdisplay, igc->lightGC ); + igc->lightGC = None; + } + if( igc->lmediumGC == None ) + { + XFreeGC( Xdisplay, igc->lmediumGC ); + igc->lmediumGC = None; + } + if( igc->mediumGC == None ) + { + XFreeGC( Xdisplay, igc->mediumGC ); + igc->mediumGC = None; + } + if( igc->darkGC == None ) + { + XFreeGC( Xdisplay, igc->darkGC ); + igc->darkGC = None; + } + if( igc->vdarkGC == None ) + { + XFreeGC( Xdisplay, igc->vdarkGC ); + igc->vdarkGC = None; + } + if( igc->blackGC != None ) + { + XFreeGC( Xdisplay, igc->blackGC ); + igc->blackGC = None; + } + } +} + +static void +renderIcon(char **data, Icon* pIcon, IconGC* igc) +{ + Pixmap d, mask; + register int i, k ; + int x, y ; + GC maskgc, paintgc ; + + d = XCreatePixmap(Xdisplay, scrollBar.win, pIcon->width, pIcon->height, Xdepth); + mask = XCreatePixmap(Xdisplay, scrollBar.win, pIcon->width, pIcon->height, 1); + + CheckIconGC( igc, d, mask ); + y = pIcon->origin_y ; + + for (i = 0; i < pIcon->height ; y++, i++ ) { + x = pIcon->origin_x ; + for (k = 0; k < pIcon->width ; k++, x++ ) { + maskgc = igc->maskGC ; + switch (data[y][x]) { + case ' ': + case 'w': paintgc = igc->whiteGC ; break; + case '.': + case 'l': paintgc = igc->lightGC ; break; + case '-': + case 'g': paintgc = igc->lmediumGC ; break; + case '%': + case 'd': paintgc = igc->darkGC ; break; + case '*': + case 'v': paintgc = igc->vdarkGC ; break; + case '#': + case 'b': paintgc = igc->blackGC ; break; + case '=': + case 'm': + default: paintgc = grayGC; + maskgc = igc->maskGC_0 ; + break; + } + XDrawPoint(Xdisplay, d, paintgc, k, i); + XDrawPoint(Xdisplay, mask, maskgc, k, i); + } + } + + pIcon->icon = d ; + pIcon->icon_mask = mask ; +} + +static void +PlaceIcon( Icon* i, int x, int y, Drawable buffer ) +{ +#ifdef TRANSPARENT + if( IS_TRANSP_SCROLL ) + { + XSetClipMask( Xdisplay, paintGC, i->icon_mask ); + XSetClipOrigin( Xdisplay, paintGC, x, y ); + } +#endif + XCopyArea(Xdisplay, i->icon, buffer, paintGC, 0, 0, + i->width, i->height,x,y ); + +} + +static void +init_stuff(void) +{ + XGCValues gcvalue; + XColor xcol; + Pixmap stipple; + unsigned long light, dark; + unsigned arrow_x_offset, arrow_y_offset ; + IconGC icongc = {None,None,None,None,None,None,None,None}; + int i ; + + gcvalue.graphics_exposures = False; + + blackPixel = BlackPixelOfScreen(DefaultScreenOfDisplay(Xdisplay)); + whitePixel = WhitePixelOfScreen(DefaultScreenOfDisplay(Xdisplay)); + + xcol.red = 0xde00; + xcol.green = 0xde00; + xcol.blue = 0xde00; + if (!XAllocColor (Xdisplay, Xcmap, &xcol)) + { + print_error ("can't allocate %s", "light gray"); +#ifndef NO_BRIGHTCOLOR + xcol.pixel = PixColors [Color_AntiqueWhite]; +#else + xcol.pixel = PixColors [Color_White]; +#endif + } + + light = lightPixel = xcol.pixel; + /* light = lightPixel = gcvalue.foreground = xcol.pixel; + grayGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground|GCGraphicsExposures, + &gcvalue); + */ + + xcol.red = 0xaa00; + xcol.green = 0xaa00; + xcol.blue = 0xaa00; + if (!XAllocColor (Xdisplay, Xcmap, &xcol)) + { + print_error ("can't allocate %s", "light gray"); +#ifndef NO_BRIGHTCOLOR + xcol.pixel = PixColors [Color_AntiqueWhite]; +#else + xcol.pixel = PixColors [Color_White]; +#endif + } + + lmediumPixel = xcol.pixel; + + xcol.red = 0xbd00; + xcol.green = 0xbd00; + xcol.blue = 0xbd00; + if (!XAllocColor (Xdisplay, Xcmap, &xcol)) + { + print_error ("can't allocate %s", "light medium gray"); +#ifndef NO_BRIGHTCOLOR + xcol.pixel = PixColors [Color_Black]; +#else + xcol.pixel = PixColors [Color_Grey50]; +#endif + + } + + mediumPixel = gcvalue.foreground = xcol.pixel; + grayGC = XCreateGC(Xdisplay, scrollBar.win, + GCForeground|GCGraphicsExposures,&gcvalue); + + + xcol.red = 0x8e00; + xcol.green = 0x8e00; + xcol.blue = 0x8e00; + if (!XAllocColor (Xdisplay, Xcmap, &xcol)) + { + print_error ("can't allocate %s", "dark gray"); +#ifndef NO_BRIGHTCOLOR + xcol.pixel = PixColors [Color_Grey25]; +#else + xcol.pixel = PixColors [Color_Black]; +#endif + + } + + darkPixel = xcol.pixel; + + xcol.red = 0x5e00; + xcol.green = 0x5e00; + xcol.blue = 0x5e00; + if (!XAllocColor (Xdisplay, Xcmap, &xcol)) + { + print_error ("can't allocate %s", "very dark gray"); +#ifndef NO_BRIGHTCOLOR + xcol.pixel = PixColors [Color_Grey25]; +#else + xcol.pixel = PixColors [Color_Black]; +#endif + + } + + vdarkPixel = xcol.pixel; + + renderIcon(SCROLLER_DIMPLE, &dimple, &icongc); + + if( !NeXTScrollArrows.bValid ) init_scroll_size(); + + arrow_x_offset = (ARROW_SOURCE_WIDTH-ARROW_WIDTH)>>1; +#ifdef NEXT_SCROLL_SQUARE_ARROWS + arrow_y_offset = arrow_x_offset ; +#else + arrow_y_offset = 0; /* not implemented yet */ +#endif + + for( i = 0 ; i < 6 ; i++ ) + { + NeXTScrollArrows.Arrows[i].origin_x = arrow_x_offset ; + NeXTScrollArrows.Arrows[i].origin_y = arrow_y_offset ; + NeXTScrollArrows.Arrows[i].width = ARROW_WIDTH ; + NeXTScrollArrows.Arrows[i].height = ARROW_HEIGHT ; + renderIcon(NeXTScrollArrows.Data[i], &(NeXTScrollArrows.Arrows[i]), &icongc ); + } + + FreeIconGC( &icongc ); + + gcvalue.foreground = whitePixel; + paintGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground|GCGraphicsExposures, + &gcvalue); + + stipple = XCreateBitmapFromData(Xdisplay, scrollBar.win, + stp_bits, stp_width, stp_height); + gcvalue.foreground = darkPixel; + gcvalue.background = light; + gcvalue.fill_style = FillStippled; + gcvalue.stipple = stipple; + + stippleGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground|GCBackground + |GCStipple|GCFillStyle|GCGraphicsExposures, + &gcvalue); + + scrollbar_show(1); +} + + +/* Draw bevel & arrows */ +static void +drawBevel(Drawable d, int x, int y, int w, int h) +{ + XSetForeground( Xdisplay, paintGC, lightPixel ); + XDrawLine(Xdisplay, d, paintGC, x, y, x+w , y); + XDrawLine(Xdisplay, d, paintGC, x, y, x, y+h ); + + XSetForeground( Xdisplay, paintGC, lightPixel ); + XDrawLine(Xdisplay, d, paintGC, x+1, y+1, x+w-1, y+1); + XDrawLine(Xdisplay, d, paintGC, x+1, y+1, x+1, y+h-1); + + XSetForeground( Xdisplay, paintGC, darkPixel ); + XDrawLine(Xdisplay, d, paintGC, x+w , y+1, x+w , y+h ); + XDrawLine(Xdisplay, d, paintGC, x+1, y+h , x+w , y+h ); + + XSetForeground( Xdisplay, paintGC, darkPixel ); + XDrawLine(Xdisplay, d, paintGC, x+w-1, y+2, x+w-1, y+h-1); + XDrawLine(Xdisplay, d, paintGC, x+2, y+h-1, x+w-1, y+h-1); + +#ifndef NEXT_SCROLL_CLEAN + + XSetForeground( Xdisplay, paintGC, darkPixel ); + XDrawLine(Xdisplay, d, paintGC, x+1, y+h-2, x+w-2, y+h-2); + XDrawLine(Xdisplay, d, paintGC, x+w-2, y+1, x+w-2, y+h-2); +#endif + +} + + +extern char* MyName ; +/* PROTO */ +int +scrollbar_mapping(int map) +{ + int change = 0; + + if (map && !scrollbar_visible()) { + scrollBar.state = 1; + XMapWindow(Xdisplay, scrollBar.win); + change = 1; + } else if (!map && scrollbar_visible()) { + scrollBar.state = 0; + XUnmapWindow(Xdisplay, scrollBar.win); + change = 1; + } + return change; +} + +#ifdef TRANSPARENT +typedef struct { + Pixmap root; + unsigned int x, y, height ; + + Pixmap cache; +}TransparencyCache ; + +#endif + +Pixmap scrollbar_fill_back( unsigned int height, int check_cache ) +{ + + Pixmap buffer = None; +#ifdef TRANSPARENT + static TransparencyCache tCache = {None, -1, -1, 0, None}; +#endif + + /* create double buffer */ + buffer = XCreatePixmap(Xdisplay, scrollBar.win, SB_WIDTH+SB_BORDER_WIDTH, height, Xdepth); + +#ifdef TRANSPARENT + if( IS_TRANSP_SCROLL && scrollBar.state ) + { + Pixmap root_pmap = None ; + unsigned int root_width = 0, root_height = 0 ; + if( check_cache == 1 ) + { + int cache_valid = 0 ; + root_pmap = ValidatePixmap(root_pmap, 1, 1, &root_width, &root_height); + if( height == tCache.height && root_pmap == tCache.root ) + { + int my_x, my_y ; + if( GetWinPosition(scrollBar.win, &my_x, &my_y) ) + { + if( my_x== tCache.x && my_y == tCache.y ) cache_valid = 1 ; + else { tCache.x = my_x ; tCache.y = my_y ; } + }else cache_valid = 1 ; + }else { tCache.root = root_pmap ; tCache.height = height ; } + if( cache_valid == 0 ) + { + if(tCache.cache) XFreePixmap( Xdisplay, tCache.cache ); + tCache.cache = CutWinPixmap( scrollBar.win, root_pmap, root_width, root_height, SB_WIDTH+SB_BORDER_WIDTH, height, grayGC, &(TermWin.background.Shading)); + } + } + if( tCache.cache != None ) + { + FillPixmapWithTile( buffer, tCache.cache, 0, 0, SB_WIDTH+SB_BORDER_WIDTH, height, 0, 0 ); + if( TermWin.tintGC) + XFillRectangle(Xdisplay, buffer, TermWin.tintGC, 0, 0, SB_WIDTH+SB_BORDER_WIDTH-1, height-1); + return buffer ; + } + } +#endif + + /* draw the background */ + XSetForeground(Xdisplay, paintGC, lightPixel ); + XFillRectangle(Xdisplay, buffer, paintGC, 0, 0, SB_WIDTH+SB_BORDER_WIDTH, height); + + XSetForeground(Xdisplay, paintGC, darkPixel ); + /* + XDrawRectangle(Xdisplay, buffer, paintGC, 0, 0, SB_WIDTH, height); + */ + XDrawLine(Xdisplay, buffer, paintGC, SB_WIDTH, 1, SB_WIDTH, height); + XDrawLine(Xdisplay, buffer, paintGC, 2, height-1, SB_WIDTH, height-1); + + if (TermWin.nscrolled > 0) + { + XFillRectangle( Xdisplay, buffer, grayGC, + SB_BORDER_WIDTH+SB_BORDER_WIDTH, SB_BORDER_WIDTH+SB_BUTTON_HEIGHT-1, + SB_WIDTH-SB_BORDER_SIZE-SIDE_STEP_WIDTH, + height-SB_BUTTONS_HEIGHT ); + } else { + XFillRectangle(Xdisplay, buffer, grayGC, + SB_BORDER_WIDTH+SB_BORDER_WIDTH, SB_BORDER_WIDTH, + SB_WIDTH-SB_BORDER_SIZE, height-SB_BORDER_SIZE); + + PlaceIcon(&UP_ARROW_LO, + ((SB_WIDTH)>>1)-(ARROW_WIDTH>>1)-SIDE_STEP_WIDTH+1, + BEVEL_SIZE, + buffer ); + XDrawLine(Xdisplay, buffer, paintGC, 2, SB_BUTTON_HEIGHT-1, SB_WIDTH-BEVEL_HI_WIDTH, SB_BUTTON_HEIGHT-1); + + PlaceIcon(&DOWN_ARROW_LO, + ((SB_WIDTH)>>1)-(ARROW_WIDTH>>1)-SIDE_STEP_WIDTH+1, + height - SB_BUTTON_HEIGHT+BEVEL_SIZE, + buffer ); + XSetForeground(Xdisplay, paintGC, lightPixel ); + XDrawLine(Xdisplay, buffer, paintGC, 2, height-SB_BUTTON_HEIGHT, SB_WIDTH, height-SB_BUTTON_HEIGHT); + } + + return buffer ; +} + + +int +scrollbar_show_cached(int update, int check_cache) +{ + /* old (drawn) values */ + static int last_top, last_bot, last_len; + static int scrollbar_len; /* length of slider */ + Pixmap buffer; + int height = scrollBar.end + SB_BUTTON_HEIGHT + sb_shadow ; + + if (paintGC == None) + init_stuff(); + + if (update) + { + int top = (TermWin.nscrolled - TermWin.view_start); + int bot = top + (TermWin.nrow - 1); + int len = max((TermWin.nscrolled + (TermWin.nrow - 1)),1); + +#define MIN_SCROLL_LENGTH (SCROLLER_DIMPLE_HEIGHT+3) + scrollBar.top = (scrollBar.beg - 1 + + (top * (scrollbar_size()-SB_BORDER_SIZE-MIN_SCROLL_LENGTH)) / len); + scrollBar.bot = (scrollBar.beg + MIN_SCROLL_LENGTH+ + (bot * (scrollbar_size()-SB_BORDER_SIZE-MIN_SCROLL_LENGTH)) / len); + + scrollbar_len = scrollBar.bot - scrollBar.top; + /* no change */ + if ((scrollBar.top == last_top) && (scrollBar.bot == last_bot)) + return 0; + + } + + last_top = scrollBar.top; + last_bot = scrollBar.bot; + last_len = scrollbar_len; + + buffer = scrollbar_fill_back( height, check_cache ); + if (TermWin.nscrolled > 0) + { + + int x, y ; +#ifdef TRANSPARENT + if( !IS_TRANSP_SCROLL ) + { + XFillRectangle(Xdisplay, buffer, grayGC, + SB_BORDER_WIDTH+BEVEL_HI_WIDTH, + scrollBar.top+SB_BORDER_WIDTH-SIDE_STEP_WIDTH, + SB_WIDTH-SB_BORDER_WIDTH-1, scrollbar_len); + } +#endif + + XSetForeground(Xdisplay, paintGC, vdarkPixel ); + XDrawRectangle(Xdisplay, buffer, paintGC, SB_BORDER_WIDTH+1, + scrollBar.top+SB_BORDER_WIDTH, + SB_WIDTH-SB_BORDER_SIZE-SIDE_STEP_WIDTH-1, + scrollbar_len); + drawBevel(buffer, SB_BORDER_WIDTH+1, + scrollBar.top+SB_BORDER_WIDTH+SCROLL_SHADOW_HEIGHT, + SB_WIDTH-SB_BORDER_SIZE-SIDE_STEP_WIDTH-1, + scrollbar_len-SCROLL_SHADOW_HEIGHT-1); + drawBevel(buffer, SB_BORDER_WIDTH, + 1-SB_BORDER_WIDTH, + SB_WIDTH-SIDE_STEP_WIDTH-1, + SB_BUTTON_HEIGHT-1); + drawBevel(buffer, SB_BORDER_WIDTH, + height-SB_BUTTON_HEIGHT+1-SB_BORDER_WIDTH, + SB_WIDTH-SIDE_STEP_WIDTH-1, + SB_BUTTON_HEIGHT-1); + + PlaceIcon(&dimple, + ((SB_WIDTH)>>1)-(SCROLLER_DIMPLE_WIDTH>>1)+1-SIDE_STEP_WIDTH, + scrollBar.top + SB_BORDER_WIDTH + 1 + + ((scrollbar_len-SCROLLER_DIMPLE_HEIGHT)>>1), + buffer ); + PlaceIcon((scrollbar_isUp())?&UP_ARROW_HI:&UP_ARROW, + ((SB_WIDTH)>>1)-(ARROW_WIDTH>>1)-SIDE_STEP_WIDTH+1, + BEVEL_SIZE, + buffer ); + + PlaceIcon((scrollbar_isDn())?&DOWN_ARROW_HI:&DOWN_ARROW, + ((SB_WIDTH)>>1)-(ARROW_WIDTH>>1)-SIDE_STEP_WIDTH+1, + height - SB_BUTTON_HEIGHT+BEVEL_SIZE, + buffer ); + +#ifdef TRANSPARENT + if( IS_TRANSP_SCROLL ) + XSetClipMask( Xdisplay, paintGC, None ); +#endif + + } + + if (Options & Opt_scrollBar_right) + XCopyArea(Xdisplay, buffer, scrollBar.win, paintGC, 0, 0, + SB_WIDTH+SB_BORDER_WIDTH, height, 0, 0); + else + XCopyArea(Xdisplay, buffer, scrollBar.win, paintGC, 0, 0, + SB_WIDTH+SB_BORDER_WIDTH, height, 0-SB_BORDER_WIDTH, 0); + + XFreePixmap(Xdisplay, buffer); + + return 1; +} + +/* PROTO */ +int +scrollbar_show(int update) +{ + scrollbar_show_cached(update, 0); +} + + +/* PROTO */ +void +refresh_transparent_scrollbar() +{ +#ifdef TRANSPARENT + if( IS_TRANSP_SCROLL ) scrollbar_show_cached(0, 1); +#endif +} + + +/* PROTO */ +void +map_scrollBar(int map) +{ + if (scrollbar_mapping(map)) { + resize(); + scr_touch(); + } +} + +/*----------------------- end-of-file (C source) -----------------------*/