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

📄 scrollbar-sgi.c

📁 Mrxvt是一个小巧
💻 C
📖 第 1 页 / 共 2 页
字号:
/* EXTPROTO */void rxvt_scrollbar_init_sgi (rxvt_t* r){    XGCValues		gcvalue;	unsigned long	gcmask;    Pixmap			stipple;    XColor			xcol;    unsigned int	x_offset, y_offset;	/* Initialize colors */    r->scrollBar.sgi_black =		BlackPixelOfScreen(DefaultScreenOfDisplay(r->Xdisplay));    r->scrollBar.sgi_white =		WhitePixelOfScreen(DefaultScreenOfDisplay(r->Xdisplay));	/* alloc light gray */    xcol.red = 0xde00;    xcol.green = 0xde00;    xcol.blue = 0xde00;    if (!rxvt_alloc_color (r, &xcol, "light gray")) {#ifndef NO_BRIGHTCOLOR		r->scrollBar.sgi_fg = r->PixColors [Color_AntiqueWhite];#else		r->scrollBar.sgi_fg = r->PixColors [Color_White];#endif	    }	else		r->scrollBar.sgi_fg = xcol.pixel;	/* alloc light medium gray */    xcol.red = 0xaa00;    xcol.green = 0xaa00;    xcol.blue = 0xaa00;    if (!rxvt_alloc_color (r, &xcol, "light medium gray")) {#ifndef NO_BRIGHTCOLOR		r->scrollBar.sgi_lmedium = r->PixColors [Color_AntiqueWhite];#else		r->scrollBar.sgi_lmedium = r->PixColors [Color_White];#endif	    }	else	    r->scrollBar.sgi_lmedium = xcol.pixel;	/* alloc medium gray */    xcol.red = 0xbd00;    xcol.green = 0xbd00;    xcol.blue = 0xbd00;    if (!rxvt_alloc_color (r, &xcol, "medium gray")) {#ifndef NO_BRIGHTCOLOR		r->scrollBar.sgi_bg = r->PixColors [Color_Black];#else		r->scrollBar.sgi_bg = r->PixColors [Color_Grey50];#endif	    }	else	    r->scrollBar.sgi_bg = xcol.pixel;	/* alloc dark gray */    xcol.red = 0x8e00;    xcol.green = 0x8e00;    xcol.blue = 0x8e00;    if (!rxvt_alloc_color (r, &xcol, "dark gray")) {#ifndef NO_BRIGHTCOLOR		r->scrollBar.sgi_dark = r->PixColors [Color_Grey25];#else		r->scrollBar.sgi_dark = r->PixColors [Color_Black];#endif	    }    r->scrollBar.sgi_dark = xcol.pixel;	/* alloc very dark gray */    xcol.red = 0x5e00;    xcol.green = 0x5e00;    xcol.blue = 0x5e00;    if (!rxvt_alloc_color (r, &xcol, "very dark gray")) {#ifndef NO_BRIGHTCOLOR		r->scrollBar.sgi_vdark = r->PixColors [Color_Grey25];#else		r->scrollBar.sgi_vdark = r->PixColors [Color_Black];#endif	    }    r->scrollBar.sgi_vdark = xcol.pixel;	/* Create GCs */	gcvalue.foreground = r->scrollBar.sgi_white;	gcmask = GCForeground;	r->scrollBar.gc = XCreateGC (r->Xdisplay, r->scrollBar.win,						gcmask, &gcvalue);    stipple = XCreateBitmapFromData(r->Xdisplay, r->scrollBar.win,				    (const char*) stp_bits, stp_width, stp_height);	assert (None != stipple);    gcvalue.foreground = r->scrollBar.sgi_dark;    gcvalue.background = r->scrollBar.sgi_bg;    gcvalue.fill_style = FillStippled;    gcvalue.stipple = stipple;	gcmask = GCForeground | GCBackground | GCStipple | GCFillStyle;    r->scrollBar.sgi_stippleGC = XCreateGC(r->Xdisplay,					r->scrollBar.win, gcmask, &gcvalue);	assert (None != r->scrollBar.sgi_stippleGC);	/* Create icons */	r->scrollBar.sgi_dimple = create_icon (r, SCROLLER_DIMPLE,		0, 0,		SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT);	assert (None != r->scrollBar.sgi_dimple);    x_offset = y_offset = (ARROW_SOURCE_WIDTH-SGI_ARROW_WIDTH)>>1;	r->scrollBar.sgi_upArrow = create_icon (r, SCROLLER_ARROW_UP,		x_offset, y_offset,		ARROW_SOURCE_WIDTH, ARROW_SOURCE_HEIGHT);	r->scrollBar.sgi_upArrowHi = create_icon (r, HI_SCROLLER_ARROW_UP,		x_offset, y_offset,		ARROW_SOURCE_WIDTH, ARROW_SOURCE_HEIGHT);	r->scrollBar.sgi_upArrowLow = create_icon (r, LO_SCROLLER_ARROW_UP,		x_offset, y_offset,		ARROW_SOURCE_WIDTH, ARROW_SOURCE_HEIGHT);	r->scrollBar.sgi_downArrow = create_icon (r, SCROLLER_ARROW_DOWN,		x_offset, y_offset,		ARROW_SOURCE_WIDTH, ARROW_SOURCE_HEIGHT);	r->scrollBar.sgi_downArrowHi = create_icon (r,		HI_SCROLLER_ARROW_DOWN,		x_offset, y_offset,		ARROW_SOURCE_WIDTH, ARROW_SOURCE_HEIGHT);	r->scrollBar.sgi_downArrowLow = create_icon (r,		LO_SCROLLER_ARROW_DOWN,		x_offset, y_offset,		ARROW_SOURCE_WIDTH, ARROW_SOURCE_HEIGHT);#ifdef TRANSPARENT	/* set background color when there's no transparent */	if (!((r->Options & Opt_transparent) &&		(r->Options & Opt_transparent_scrollbar)))#endif#ifdef BACKGROUND_IMAGE	/* set background color when there's no bg image */	if (None == r->scrollBar.pixmap)#endif		XSetWindowBackground (r->Xdisplay, r->scrollBar.win,			r->scrollBar.sgi_bg);}/* EXTPROTO */void rxvt_scrollbar_exit_sgi (rxvt_t* r){	if (None != r->scrollBar.sgi_stippleGC)	{		XFreeGC (r->Xdisplay, r->scrollBar.sgi_stippleGC);		r->scrollBar.sgi_stippleGC = None;	}	if (None != r->scrollBar.sgi_dimple)	{		XFreePixmap (r->Xdisplay, r->scrollBar.sgi_dimple);		r->scrollBar.sgi_dimple = None;	}	if (None != r->scrollBar.sgi_upArrow)	{		XFreePixmap (r->Xdisplay, r->scrollBar.sgi_upArrow);		r->scrollBar.sgi_upArrow = None;	}	if (None != r->scrollBar.sgi_upArrowHi)	{		XFreePixmap (r->Xdisplay, r->scrollBar.sgi_upArrowHi);		r->scrollBar.sgi_upArrowHi = None;	}	if (None != r->scrollBar.sgi_upArrowLow)	{		XFreePixmap (r->Xdisplay, r->scrollBar.sgi_upArrowLow);		r->scrollBar.sgi_upArrowLow = None;	}	if (None != r->scrollBar.sgi_downArrow)	{		XFreePixmap (r->Xdisplay, r->scrollBar.sgi_downArrow);		r->scrollBar.sgi_downArrow = None;	}	if (None != r->scrollBar.sgi_downArrowHi)	{		XFreePixmap (r->Xdisplay, r->scrollBar.sgi_downArrowHi);		r->scrollBar.sgi_downArrowHi = None;	}	if (None != r->scrollBar.sgi_downArrowLow)	{		XFreePixmap (r->Xdisplay, r->scrollBar.sgi_downArrowLow);		r->scrollBar.sgi_downArrowLow = None;	}}/* EXTPROTO */intrxvt_scrollbar_show_sgi (rxvt_t* r, int update, int last_top, int last_bot, int scroller_len){	register int	new_height = 			r->scrollBar.end + SGI_SB_BUTTON_HEIGHT + 			((r->sb_shadow) << 1);	if (!update)		scrollbar_fill_back (r, r->scrollBar.end);    if (0 == AVTS(r)->nscrolled) {		/* top button */		XCopyArea (r->Xdisplay, r->scrollBar.sgi_upArrowLow,			r->scrollBar.win, r->scrollBar.gc,			/* src x, y, width, height */			0, 0, SGI_ARROW_WIDTH, SGI_ARROW_HEIGHT,			/* dst x, y */			((SB_WIDTH_SGI)>>1)-(SGI_ARROW_WIDTH>>1)+1,			SGI_BEVEL_SIZE);		/* bottom button */		XCopyArea (r->Xdisplay, r->scrollBar.sgi_downArrowLow,			r->scrollBar.win, r->scrollBar.gc,			/* src x, y, width, height */			0, 0, SGI_ARROW_WIDTH, SGI_ARROW_HEIGHT,			/* dst x, y */			((SB_WIDTH_SGI)>>1)-(SGI_ARROW_WIDTH>>1)+1,			new_height - SGI_ARROW_HEIGHT - SGI_BEVEL_SIZE);    }    else	{		/* (AVTS(r)->nscrolled > 0) */		DBG_MSG(2, (stderr, "top=%d, bot=%d, last_top=%d, last_bot=%d\n", r->scrollBar.top, r->scrollBar.bot, last_top, last_bot));		if (last_top < r->scrollBar.top)			XClearArea (r->Xdisplay, r->scrollBar.win,			0, last_top,			SB_WIDTH_SGI-1, (last_top - r->scrollBar.top), False);		if (r->scrollBar.bot < last_bot)			XClearArea (r->Xdisplay, r->scrollBar.win,			0, r->scrollBar.bot,			SB_WIDTH_SGI-1, (last_bot - r->scrollBar.bot + 1), False);		XClearArea (r->Xdisplay, r->scrollBar.win,			0, r->scrollBar.top,			SB_WIDTH_SGI-1, scroller_len, False);		/* scroller frame */		CHOOSE_GC_FG(r, r->scrollBar.sgi_vdark);		XDrawRectangle (r->Xdisplay, r->scrollBar.win, r->scrollBar.gc,			0, r->scrollBar.top,			SB_WIDTH_SGI-1, scroller_len);		/* bevel of scroller, inside scroller frame */		sgi_draw_bevel (r, r->scrollBar.win,			1, r->scrollBar.top+1,			SB_WIDTH_SGI-3, scroller_len-2);		/*		sgi_draw_bevel (r, r->scrollBar.win,			0, 0,			SB_WIDTH_SGI-1, SGI_SB_BUTTON_HEIGHT);	    sgi_draw_bevel (r, r->scrollBar.win,			0, new_height-SGI_SB_BUTTON_HEIGHT, 			SB_WIDTH_SGI-1, SGI_SB_BUTTON_HEIGHT);		*/			/* dimple */		XCopyArea (r->Xdisplay, r->scrollBar.sgi_dimple,			r->scrollBar.win, r->scrollBar.gc,			0, 0,			SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT,			((SB_WIDTH_SGI)>>1)-(SCROLLER_DIMPLE_WIDTH>>1)+1,			r->scrollBar.top + ((scroller_len-SCROLLER_DIMPLE_HEIGHT)>>1));			/* top button */		XCopyArea (r->Xdisplay, (scrollbar_isUp()) ?			r->scrollBar.sgi_upArrowHi : r->scrollBar.sgi_upArrow,			r->scrollBar.win, r->scrollBar.gc,			/* src x, y, width, height */			0, 0, SGI_ARROW_WIDTH, SGI_ARROW_HEIGHT,			/* dst x, y */			((SB_WIDTH_SGI)>>1)-(SGI_ARROW_WIDTH>>1)+1,			SGI_BEVEL_SIZE);		/* bottom button */		XCopyArea (r->Xdisplay, (scrollbar_isDn()) ?			r->scrollBar.sgi_downArrowHi : r->scrollBar.sgi_downArrow,			r->scrollBar.win, r->scrollBar.gc,			/* src x, y, width, height */			0, 0, SGI_ARROW_WIDTH, SGI_ARROW_HEIGHT,			/* dst x, y */			((SB_WIDTH_SGI)>>1)-(SGI_ARROW_WIDTH>>1)+1,			new_height - SGI_ARROW_HEIGHT - SGI_BEVEL_SIZE);    }	/* bottom line of top button */	CHOOSE_GC_FG(r, r->scrollBar.sgi_fg);	XDrawLine (r->Xdisplay, r->scrollBar.win, r->scrollBar.gc,		0, SGI_SB_BUTTON_HEIGHT-1,		SB_WIDTH_SGI-1, SGI_SB_BUTTON_HEIGHT-1);	/* top line of bottom button */	XDrawLine (r->Xdisplay, r->scrollBar.win, r->scrollBar.gc,		0, new_height-SGI_SB_BUTTON_HEIGHT,		SB_WIDTH_SGI-1, new_height-SGI_SB_BUTTON_HEIGHT);        return 1;}#endif	/* SGI_SCROLLBAR */#endif	/* HAVE_SCROLLBARS *//*----------------------- end-of-file (C source) -----------------------*/

⌨️ 快捷键说明

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