Exemplo n.º 1
0
Arquivo: pixmap.c Projeto: mcgrew/lxvt
/* EXTPROTO */
Pixmap
rxvt_load_bg_pixmap(rxvt_t *r, int page, const char *file)
{
    Pixmap	pixmap;
    long	w = 0, h = 0;

    assert(file != NULL);

    pixmap = rxvt_load_pixmap (r, file, &w, &h);
    if (IS_PIXMAP(PVTS(r, page)->bg.pixmap))
	XFreePixmap (r->Xdisplay, PVTS(r, page)->bg.pixmap);
    PVTS(r, page)->bg.pixmap = pixmap;

    if( NOT_PIXMAP(pixmap) )
    {
	if( page == ATAB(r) )
	{
	    /* Force resetting the background color */
	    r->fgbg_tabnum = -1;
	    rxvt_set_vt_colors( r, page );
	}

	return None;
    }

    PVTS(r, page)->xpm_attr.closeness = 30000;
    PVTS(r, page)->xpm_attr.colormap = XCMAP;
    PVTS(r, page)->xpm_attr.visual = XVISUAL;
    PVTS(r, page)->xpm_attr.depth = XDEPTH;
    PVTS(r, page)->xpm_attr.valuemask = (XpmCloseness | XpmColormap |
	    XpmVisual | XpmDepth | XpmSize | XpmReturnPixels);
    PVTS(r, page)->xpm_attr.width = w;
    PVTS(r, page)->xpm_attr.height = h;
    rxvt_resize_pixmap(r, page);
    return (pixmap);
}
Exemplo n.º 2
0
/* EXTPROTO */
int
rxvt_scrollbar_show_next(rxvt_t *r, int update, int last_top, int last_bot, int scroller_len)
{
	int			height;
	Drawable	s;
	int			page = ATAB(r);


	height = r->scrollBar.end + NEXT_SB_TBTN_HEIGHT + NEXT_SB_PAD;

	if (PVTS(r, page)->nscrolled == 0 || !update) {
		XClearArea (r->Xdisplay, r->scrollBar.win,
			0, 0, SB_WIDTH_NEXT + 1, height, False);

		CHOOSE_GC_FG(r, r->scrollBar.next_fg);
		XDrawRectangle(r->Xdisplay, r->scrollBar.win, r->scrollBar.gc,
			0, NEXT_SB_BD_WIDTH, SB_WIDTH_NEXT,
			height + NEXT_SB_BD_WIDTH);

# 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
		XFillRectangle(r->Xdisplay, r->scrollBar.win, TILEGC,
			NEXT_SB_LPAD, 0, NEXT_SB_BTN_WIDTH, height);
	}

	if (PVTS(r, page)->nscrolled) {
		if (last_top < r->scrollBar.top || !update)	{
			/*
			** Area above the scroller
			*/
# ifdef TRANSPARENT
			/* clear background when there's transparent */
			if ((r->Options & Opt_transparent) &&
				(r->Options & Opt_transparent_scrollbar))
				XClearArea (r->Xdisplay, r->scrollBar.win,
					NEXT_SB_LPAD, NEXT_SB_PAD + last_top,
					NEXT_SB_BTN_WIDTH, r->scrollBar.top - last_top,
					False);
			else
# endif
# ifdef BACKGROUND_IMAGE
			/* clear background when there's bg image */
			if (None != r->scrollBar.pixmap)
				XClearArea (r->Xdisplay, r->scrollBar.win,
					NEXT_SB_LPAD, NEXT_SB_PAD + last_top,
					NEXT_SB_BTN_WIDTH, r->scrollBar.top - last_top,
					False);
			else
# endif
			XFillRectangle(r->Xdisplay, r->scrollBar.win, TILEGC,
				NEXT_SB_LPAD, NEXT_SB_PAD + last_top,
				NEXT_SB_BTN_WIDTH, r->scrollBar.top - last_top);
		}

		if (r->scrollBar.bot < last_bot || !update)	{
			/*
			** Area above the buttons but below the scroller
			*/
# ifdef TRANSPARENT
			/* clear background when there's transparent */
			if ((r->Options & Opt_transparent) &&
				(r->Options & Opt_transparent_scrollbar))
				XClearArea(r->Xdisplay, r->scrollBar.win,
					NEXT_SB_LPAD, r->scrollBar.bot + NEXT_SB_PAD,
					NEXT_SB_BTN_WIDTH, (last_bot - r->scrollBar.bot),
					False);
			else
# endif
# ifdef BACKGROUND_IMAGE
			/* clear background when there's bg image */
			if (None != r->scrollBar.pixmap)
				XClearArea (r->Xdisplay, r->scrollBar.win,
					NEXT_SB_LPAD, r->scrollBar.bot + NEXT_SB_PAD,
					NEXT_SB_BTN_WIDTH, (last_bot - r->scrollBar.bot),
					False);
			else
# endif
			XFillRectangle(r->Xdisplay, r->scrollBar.win, TILEGC,
				NEXT_SB_LPAD, r->scrollBar.bot + NEXT_SB_PAD,
				NEXT_SB_BTN_WIDTH, (last_bot - r->scrollBar.bot));
		}


		/*
		** Area of the scroller
		*/
# ifdef TRANSPARENT
		/* clear background when there's transparent */
		if ((r->Options & Opt_transparent) &&
			(r->Options & Opt_transparent_scrollbar))
			XClearArea (r->Xdisplay, r->scrollBar.win,
				NEXT_SB_LPAD, r->scrollBar.top + NEXT_SB_PAD,
				NEXT_SB_BTN_WIDTH, scroller_len/*-NEXT_SB_BTN_HEIGHT*/,
				False);
		else
# endif
# ifdef BACKGROUND_IMAGE
		/* clear background when there's bg image */
		if (None != r->scrollBar.pixmap)
			XClearArea (r->Xdisplay, r->scrollBar.win,
				NEXT_SB_LPAD, r->scrollBar.top + NEXT_SB_PAD,
				NEXT_SB_BTN_WIDTH, scroller_len/*-NEXT_SB_BTN_HEIGHT*/,
				False);
		else
# endif
		{
			CHOOSE_GC_FG(r, r->scrollBar.next_bg);
			XFillRectangle(r->Xdisplay, r->scrollBar.win,
				r->scrollBar.gc,
				NEXT_SB_LPAD, r->scrollBar.top + NEXT_SB_PAD,
				NEXT_SB_BTN_WIDTH, scroller_len/*-NEXT_SB_BTN_HEIGHT*/);
		}


		/*
		** Here comes the dimple in the scroller
		*/
		CHOOSE_GC_FG(r, r->scrollBar.next_white);
		XCopyArea(r->Xdisplay, DIMPLE, r->scrollBar.win,
				r->scrollBar.gc, 0, 0,
				DIMPLE_WIDTH, DIMPLE_HEIGHT,
				(SB_WIDTH_NEXT - DIMPLE_WIDTH) / 2,
				r->scrollBar.top + NEXT_BEVEL_ULEFT_WIDTH +
				(scroller_len - DIMPLE_HEIGHT) / 2);

		/*
		** Bevel around the scroller
		*/
		next_draw_bevel(r, r->scrollBar.win, NEXT_BEVEL_X,
			r->scrollBar.top + NEXT_SB_PAD, NEXT_SB_BTN_WIDTH,
			scroller_len);
		/*
		** Bevel around the buttons
		*/
		next_draw_bevel(r, r->scrollBar.win, NEXT_BEVEL_X,
			height - NEXT_SB_DBTN_HEIGHT, NEXT_SB_BTN_WIDTH,
			NEXT_SB_BTN_HEIGHT);
		next_draw_bevel(r, r->scrollBar.win, NEXT_BEVEL_X,
			height - NEXT_SB_SBTN_HEIGHT, NEXT_SB_BTN_WIDTH,
			NEXT_SB_BTN_HEIGHT);

		/*
		** Top button
		*/
		CHOOSE_GC_FG(r, r->scrollBar.next_white);
		s = (scrollbar_isUp()) ? HIUPARROW : UPARROW;
		XCopyArea(r->Xdisplay, s, r->scrollBar.win, r->scrollBar.gc,
			0, 0,
			ARROW_WIDTH, ARROW_HEIGHT, NEXT_BTN_FACE_X,
			height-NEXT_SB_DBTN_HEIGHT+NEXT_BEVEL_ULEFT_WIDTH);

		/*
		** Bottom button
		*/
		s = (scrollbar_isDn()) ? HIDNARROW : DNARROW;
		XCopyArea(r->Xdisplay, s, r->scrollBar.win, r->scrollBar.gc,
			0, 0,
			ARROW_WIDTH, ARROW_HEIGHT, NEXT_BTN_FACE_X,
			height-NEXT_SB_SBTN_HEIGHT+NEXT_BEVEL_ULEFT_WIDTH);
	}

	return 1;
}