Exemple #1
0
BOOL WINAPI
StretchBlt(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest,
	int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc,
	int nWidthSrc, int nHeightSrc, DWORD dwRop)
{

	HWND	hwnd;
	POINT	dst, src;

	if(!hdcDest || !hdcSrc)
		return FALSE;
	dst.x = nXOriginDest;
	dst.y = nYOriginDest;
	src.x = nXOriginSrc;
	src.y = nYOriginSrc;

	/* if src screen DC, convert coords*/
	/* FIXME: src clipping isn't checked, only one set of cliprects also*/
	if(!MwIsMemDC(hdcSrc) && MwIsClientDC(hdcSrc)) {
		if(!(hwnd = MwPrepareDC(hdcSrc)))
			return FALSE;
		ClientToScreen(hwnd, &src);
	}
	/* if dst screen DC, convert coords and set clipping*/
	/* FIXME: if dest is also screen, src clipping will be overwritten*/
	if(!MwIsMemDC(hdcDest) && MwIsClientDC(hdcDest)) {
		if(!(hwnd = MwPrepareDC(hdcDest)))
			return FALSE;
		ClientToScreen(hwnd, &dst);
	}

	if (nWidthDest == nWidthSrc && nHeightDest == nHeightSrc) {
		GdBlit(hdcDest->psd, dst.x, dst.y, nWidthDest, nHeightDest,
			hdcSrc->psd, src.x, src.y, dwRop);
	} else {
		GdStretchBlit(hdcDest->psd, dst.x, dst.y,
			nWidthDest, nHeightDest, hdcSrc->psd, src.x, src.y,
			nWidthSrc, nHeightSrc, dwRop);
	}
	return TRUE;
}
Exemple #2
0
/*
 * Draw a window's background pixmap.
 *
 * The flags mean:
 *   GR_BACKGROUND_TILE- tile the pixmap across the window (default).
 *   GR_BACKGROUND_TOPLEFT- draw the pixmap at (0,0) relative to the window.
 *   GR_BACKGROUND_CENTER- draw the pixmap in the middle of the window.
 *   GR_BACKGROUND_STRETCH- stretch the pixmap within the window.
 *   GR_BACKGROUND_TRANS- if the pixmap is smaller than the window and not
 *     using tile mode, there will be gaps around the pixmap. This flag causes
 *     to not fill in the spaces with the background colour.
 */
void GsWpDrawBackgroundPixmap(GR_WINDOW *wp, GR_PIXMAP *pm, GR_COORD x,
	GR_COORD y, GR_SIZE width, GR_SIZE height)
{
	GR_SIZE destwidth, destheight, fillwidth, fillheight, pmwidth, pmheight;
	GR_COORD fromx, fromy, destx, desty, pixmapx = 0, pixmapy = 0;

	if(wp->bgpixmapflags & (GR_BACKGROUND_TOPLEFT|GR_BACKGROUND_STRETCH)) {
		pixmapx = 0;
		pixmapy = 0;
	} else if(wp->bgpixmapflags & GR_BACKGROUND_CENTER) {
		if(pm->width >= wp->width) pixmapx = 0;
		else pixmapx = (wp->width - pm->width) / 2;
		if(pm->height >= wp->height) pixmapy = 0;
		else pixmapy = (wp->height - pm->height) / 2;
	} else { 
		/* GR_BACKGROUND_TILE (default)*/
		GsWpTileBackgroundPixmap(wp, pm, x, y, width, height);
		return;
	}

	if(pm->width > wp->width) pmwidth = wp->width;
	else pmwidth = pm->width;
	if(pm->height > wp->height) pmheight = wp->height;
	else pmheight = pm->height;

	if(x > pixmapx) {
		destx = x;
		fromx = x - pixmapx;
		destwidth = pixmapx + pmwidth - x;
	} else {
		destx = pixmapx;
		fromx = 0;
		destwidth = x + width - pixmapx;
	}

	if(y > pixmapy) {
		desty = y;
		fromy = y - pixmapy;
		destheight = pixmapy + pmheight - desty;
	} else {
		desty = pixmapy;
		fromy = 0;
		destheight = y + height - pixmapy;
	}

	if(destwidth > 0 && destheight > 0) {
		if (wp->bgpixmapflags & GR_BACKGROUND_STRETCH) {
			GdStretchBlit(wp->psd, destx + wp->x, desty + wp->y,
				destwidth, destheight, pm->psd, fromx, fromy,
				pm->width, pm->height, MWROP_COPY);
		} else GdBlit(wp->psd, destx + wp->x, desty + wp->y, destwidth,
			destheight, pm->psd, fromx, fromy, MWROP_COPY);
	}

	if(wp->bgpixmapflags & (GR_BACKGROUND_TRANS|GR_BACKGROUND_STRETCH))
		return;

	/* Fill in the gaps around the pixmap */
	if(x < pixmapx) {
		fillwidth = pixmapx - x;
		if(fillwidth > width) fillwidth = width;
		fillheight = height;
		GdFillRect(wp->psd, wp->x + x, wp->y + y, fillwidth,fillheight);
	}
	if((x + width) > (pixmapx + pmwidth)) {
		fillwidth = (x + width) - (pixmapx + pmwidth);
		if(fillwidth > width) fillwidth = width;
		fillheight = height;
		if(x < (pixmapx + pmwidth)) destx = pixmapx + pmwidth + wp->x;
		else destx = x + wp->x;
		GdFillRect(wp->psd, destx, wp->y + y, fillwidth, fillheight);
	}
	if(y < pixmapy) {
		fillheight = pixmapy - y;
		if(fillheight > height) fillheight = height;
		if(x < pixmapx) destx = pixmapx + wp->x;
		else destx = x + wp->x;
		if((x + width) > (pixmapx + pmwidth))
			fillwidth = pixmapx + pmwidth - destx;
		else fillwidth = x + width - destx;
		if((fillwidth > 0) && (fillheight > 0)) {
			GdFillRect(wp->psd, destx, wp->y + y, fillwidth,
							fillheight);
		}
	}
	if((y + height) > (pixmapy + pmheight)) {
		fillheight = (y + height) - (pixmapy + pmheight);
		if(fillheight > height) fillheight = height;
		if(x < pixmapx) destx = pixmapx + wp->x;
		else destx = x + wp->x;
		if(y < (pixmapy + pmheight)) desty = pixmapy + pmheight + wp->y;
		else desty = y + wp->y;
	
		if((x + width) > (pixmapx + pmwidth))
			fillwidth = pixmapx + pmwidth - destx;
		else fillwidth = x + width - destx;
		if((fillwidth > 0) && (fillheight > 0)) {
			GdFillRect(wp->psd, destx, desty, fillwidth,fillheight);
		}
	}
}
Exemple #3
0
/*
 * Draw a window's background pixmap.
 *
 * The flags mean:
 *   GR_BACKGROUND_TILE- tile the pixmap across the window (default).
 *   GR_BACKGROUND_TOPLEFT- draw the pixmap at (0,0) relative to the window.
 *   GR_BACKGROUND_CENTER- draw the pixmap in the middle of the window.
 *   GR_BACKGROUND_STRETCH- stretch the pixmap within the window.
 *   GR_BACKGROUND_TRANS- if the pixmap is smaller than the window and not
 *     using tile mode, there will be gaps around the pixmap. This flag causes
 *     to not fill in the spaces with the background colour.
 */
void
GsDrawBackgroundPixmap(GR_WINDOW *wp, GR_PIXMAP *pm, GR_COORD x,
	GR_COORD y, GR_SIZE width, GR_SIZE height)
{
	GR_SIZE destwidth, destheight, fillwidth, fillheight, pmwidth, pmheight;
	GR_COORD fromx, fromy, destx, desty, pixmapx = 0, pixmapy = 0;

	if(wp->bgpixmapflags & GR_BACKGROUND_STRETCH) {
		/* must use whole window coords or stretch will have incorrect ratios*/
		GdStretchBlit(wp->psd, wp->x, wp->y, wp->x + wp->width, wp->y + wp->height,
			pm->psd, 0, 0, pm->width - 1, pm->height - 1, MWROP_SRC_OVER);
		return;
	}

	if(wp->bgpixmapflags == GR_BACKGROUND_TILE) {
		GsTileBackgroundPixmap(wp, pm, x, y, width, height);
		return;
	}

	if(wp->bgpixmapflags & GR_BACKGROUND_CENTER) {
		if (pm->width < wp->width) pixmapx = (wp->width - pm->width) / 2;
		if (pm->height < wp->height) pixmapy = (wp->height - pm->height) / 2;
	}

	/* topleft & center calcs*/
	pmwidth = MWMIN(pm->width, wp->width);
	pmheight = MWMIN(pm->height, wp->height);

	if(x > pixmapx) {
		destx = x;
		fromx = x - pixmapx;
		destwidth = pixmapx + pmwidth - x;
	} else {
		destx = pixmapx;
		fromx = 0;
		destwidth = x + width - pixmapx;
	}

	if(y > pixmapy) {
		desty = y;
		fromy = y - pixmapy;
		destheight = pixmapy + pmheight - desty;
	} else {
		desty = pixmapy;
		fromy = 0;
		destheight = y + height - pixmapy;
	}

	if(destwidth > 0 && destheight > 0) {
		destwidth = MWMIN(width, destwidth);
		destheight = MWMIN(height, destheight);

		GdBlit(wp->psd, wp->x + destx, wp->y + desty, destwidth, destheight,
			pm->psd, fromx, fromy, MWROP_SRC_OVER);
	}

	if(wp->bgpixmapflags & GR_BACKGROUND_TRANS)
		return;

	/* Fill in the gaps around the pixmap */
	if(x < pixmapx) {
		fillwidth = pixmapx - x;
		if(fillwidth > width) fillwidth = width;
		fillheight = height;

		GdFillRect(wp->psd, wp->x + x, wp->y + y, fillwidth, fillheight);
	}
	if(x + width > pixmapx + pmwidth) {
		fillwidth = (x + width) - (pixmapx + pmwidth);
		if(fillwidth > width) fillwidth = width;
		fillheight = height;

		if(x < pixmapx + pmwidth)
			destx = pixmapx + pmwidth + wp->x;
		else destx = x + wp->x;

		GdFillRect(wp->psd, destx, wp->y + y, fillwidth, fillheight);
	}
	if(y < pixmapy) {
		fillheight = pixmapy - y;
		if(fillheight > height) fillheight = height;

		if(x < pixmapx)
			destx = pixmapx + wp->x;
		else destx = x + wp->x;
		if(x + width > pixmapx + pmwidth)
			fillwidth = pixmapx + pmwidth - destx;
		else fillwidth = x + width - destx;

		if(fillwidth > 0 && fillheight > 0)
			GdFillRect(wp->psd, destx, wp->y + y, fillwidth, fillheight);
	}
	if(y + height > pixmapy + pmheight) {
		fillheight = (y + height) - (pixmapy + pmheight);
		if(fillheight > height) fillheight = height;

		if(x < pixmapx)
			destx = pixmapx + wp->x;
		else destx = x + wp->x;
		if(y < pixmapy + pmheight)
			desty = pixmapy + pmheight + wp->y;
		else desty = y + wp->y;
	
		if(x + width > pixmapx + pmwidth)
			fillwidth = pixmapx + pmwidth - destx;
		else fillwidth = x + width - destx;
		if(fillwidth > 0 && fillheight > 0)
			GdFillRect(wp->psd, destx, desty, fillwidth, fillheight);
	}
}