⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxvtlib_scrollbar.c

📁 具有IDE功能的编辑器
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "rxvtlib.h"/*--------------------------------*-C-*---------------------------------* * File:	scrollbar.c *----------------------------------------------------------------------* * $Id: scrollbar.c,v 1.19.2.1 1999/07/17 09:47:26 mason Exp $ * * Copyright (C) 1997,1998 mj olesen <olesen@me.QueensU.CA> * Copyright (C) 1998      Alfredo K. Kojima <kojima@windowmaker.org> *				- N*XTstep like scrollbars * * 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. *----------------------------------------------------------------------*//*----------------------------------------------------------------------* */#ifndef NEXT_SCROLLBAR#ifdef XTERM_SCROLLBAR		/* bitmap scrollbar */	/* 12x2 bitmap */#if (SB_WIDTH != 15)#error Error, check scrollbar width (SB_WIDTH).It must be 15 for XTERM_SCROLLBAR#endif#else				/* XTERM_SCROLLBAR *//* draw triangular button with a shadow of SHADOW (1 or 2) pixels *//* INTPROTO */void            rxvtlib_Draw_button (rxvtlib *o, int x, int y, int state, int dirn){    const unsigned int sz = (SB_WIDTH), sz2 = (SB_WIDTH / 2);    XPoint          pt[3];    GC              top, bot;    switch (state) {    case +1:	top = o->topShadowGC;	bot = o->botShadowGC;	break;    case -1:	top = o->botShadowGC;	bot = o->topShadowGC;	break;    default:	top = bot = o->scrollbarGC;	break;    }/* fill triangle */    pt[0].x = x;    pt[1].x = x + sz - 1;    pt[2].x = x + sz2;    if (dirn == UP) {	pt[0].y = pt[1].y = y + sz - 1;	pt[2].y = y;    } else {	pt[0].y = pt[1].y = y;	pt[2].y = y + sz - 1;    }    XFillPolygon (o->Xdisplay, o->scrollBar.win, o->scrollbarGC,		  pt, 3, Convex, CoordModeOrigin);/* draw base */    XDrawLine (o->Xdisplay, o->scrollBar.win, (dirn == UP ? bot : top),	       pt[0].x, pt[0].y, pt[1].x, pt[1].y);/* draw shadow on left */    pt[1].x = x + sz2 - 1;    pt[1].y = y + (dirn == UP ? 0 : sz - 1);    XDrawLine (o->Xdisplay, o->scrollBar.win, top,	       pt[0].x, pt[0].y, pt[1].x, pt[1].y);#if (SHADOW > 1)/* doubled */    pt[0].x++;    if (dirn == UP) {	pt[0].y--;	pt[1].y++;    } else {	pt[0].y++;	pt[1].y--;    }    XDrawLine (o->Xdisplay, o->scrollBar.win, top,	       pt[0].x, pt[0].y, pt[1].x, pt[1].y);#endif/* draw shadow on right */    pt[1].x = x + sz - 1;/* pt[2].x = x + sz2; */    pt[1].y = y + (dirn == UP ? sz - 1 : 0);    pt[2].y = y + (dirn == UP ? 0 : sz - 1);    XDrawLine (o->Xdisplay, o->scrollBar.win, bot,	       pt[2].x, pt[2].y, pt[1].x, pt[1].y);#if (SHADOW > 1)/* doubled */    pt[1].x--;    if (dirn == UP) {	pt[2].y++;	pt[1].y--;    } else {	pt[2].y--;	pt[1].y++;    }    XDrawLine (o->Xdisplay, o->scrollBar.win, bot,	       pt[2].x, pt[2].y, pt[1].x, pt[1].y);#endif}#endif				/* ! XTERM_SCROLLBAR */#else				/* ! NEXT_SCROLLBAR *//* * N*XTSTEP like scrollbar - written by Alfredo K. Kojima *//* INTPROTO */Pixmap          rxvtlib_renderPixmap (rxvtlib *o, char **data, int width, int height){    int             x, y;    Pixmap          d;    d = XCreatePixmap (o->Xdisplay, o->scrollBar.win, width, height, o->Xdepth);    for (y = 0; y < height; y++) {	for (x = 0; x < width; x++) {	    switch (data[y][x]) {	    case ' ':	    case 'w':		XDrawPoint (o->Xdisplay, d, o->whiteGC, x, y);		break;	    case '.':	    case 'l':		XDrawPoint (o->Xdisplay, d, o->grayGC, x, y);		break;	    case '%':	    case 'd':		XDrawPoint (o->Xdisplay, d, o->darkGC, x, y);		break;	    case '#':	    case 'b':	    default:		XDrawPoint (o->Xdisplay, d, o->blackGC, x, y);		break;	    }	}    }    return d;}/* INTPROTO */void            rxvtlib_init_scrollbar_stuff (rxvtlib *o){    XGCValues       gcvalue;    XColor          xcol;    Pixmap          stipple;    unsigned long   light, dark;    gcvalue.graphics_exposures = False;    gcvalue.foreground =	BlackPixelOfScreen (DefaultScreenOfDisplay (o->Xdisplay));    o->blackGC =	XCreateGC (o->Xdisplay, o->scrollBar.win, GCForeground | GCGraphicsExposures,		   &gcvalue);    gcvalue.foreground =	WhitePixelOfScreen (DefaultScreenOfDisplay (o->Xdisplay));    o->whiteGC =	XCreateGC (o->Xdisplay, o->scrollBar.win, GCForeground | GCGraphicsExposures,		   &gcvalue);    xcol.red = 0xaeba;    xcol.green = 0xaaaa;    xcol.blue = 0xaeba;    if (!XAllocColor (o->Xdisplay, o->Xcmap, &xcol)) {	print_error ("can't allocate %s", "light gray");	xcol.pixel = o->PixColors[Color_AntiqueWhite];    }    light = gcvalue.foreground = xcol.pixel;    o->grayGC =	XCreateGC (o->Xdisplay, o->scrollBar.win, GCForeground | GCGraphicsExposures,		   &gcvalue);    xcol.red = 0x51aa;    xcol.green = 0x5555;    xcol.blue = 0x5144;    if (!XAllocColor (o->Xdisplay, o->Xcmap, &xcol)) {	print_error ("can't allocate %s", "dark gray");	xcol.pixel = o->PixColors[Color_Grey25];    }    dark = gcvalue.foreground = xcol.pixel;    o->darkGC =	XCreateGC (o->Xdisplay, o->scrollBar.win, GCForeground | GCGraphicsExposures,		   &gcvalue);    stipple = XCreateBitmapFromData (o->Xdisplay, o->scrollBar.win,				     (char *) o->stp_bits, stp_width, stp_height);    gcvalue.foreground = dark;    gcvalue.background = light;    gcvalue.fill_style = FillStippled;    gcvalue.stipple = stipple;/*    XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[Color_Red]); */    o->stippleGC = XCreateGC (o->Xdisplay, o->scrollBar.win, GCForeground | GCBackground			   | GCStipple | GCFillStyle | GCGraphicsExposures,			   &gcvalue);    o->dimple = rxvtlib_renderPixmap (o, o->SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH,			   SCROLLER_DIMPLE_HEIGHT);    o->upArrow = rxvtlib_renderPixmap (o, o->SCROLLER_ARROW_UP, ARROW_WIDTH, ARROW_HEIGHT);    o->downArrow = rxvtlib_renderPixmap (o, o->SCROLLER_ARROW_DOWN, ARROW_WIDTH, ARROW_HEIGHT);    o->upArrowHi = rxvtlib_renderPixmap (o, o->HI_SCROLLER_ARROW_UP, ARROW_WIDTH, ARROW_HEIGHT);    o->downArrowHi =	rxvtlib_renderPixmap (o, o->HI_SCROLLER_ARROW_DOWN, ARROW_WIDTH, ARROW_HEIGHT);    rxvtlib_scrollbar_show (o, 1);}/* Draw bevel & arrows *//* INTPROTO */void            rxvtlib_drawBevel (rxvtlib *o, Drawable d, int x, int y, int w, int h){    XDrawLine (o->Xdisplay, d, o->whiteGC, x, y, x + w - 1, y);    XDrawLine (o->Xdisplay, d, o->whiteGC, x, y, x, y + h - 1);    XDrawLine (o->Xdisplay, d, o->blackGC, x + w - 1, y, x + w - 1, y + h - 1);    XDrawLine (o->Xdisplay, d, o->blackGC, x, y + h - 1, x + w - 1, y + h - 1);    XDrawLine (o->Xdisplay, d, o->darkGC, x + 1, y + h - 2, x + w - 2, y + h - 2);    XDrawLine (o->Xdisplay, d, o->darkGC, x + w - 2, y + 1, x + w - 2, y + h - 2);}#endif				/* ! NEXT_SCROLLBAR *//* EXTPROTO */int             rxvtlib_scrollbar_show (rxvtlib *o, int update){    static int      scrollbar_len;	/* length of slider */    static int      last_top, last_bot, last_state;#ifndef NEXT_SCROLLBAR    static short    sb_width;		/* old (drawn) values */    int             xsb = 0;    if (!scrollbar_visible ())	return 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -