예제 #1
0
파일: wingdi.c 프로젝트: EPiCS/reconos_v2
/* 
 * Setup clip region from device context's associated window or bitmap.
 * Memory DC's are always associated with the desktop window, and are
 * always visible.  Return the DC's hwnd if window is visible.
 */
HWND
MwPrepareDC(HDC hdc)
{
	HWND	hwnd;

	if(!hdc || !hdc->hwnd)
		return NULL;

	hwnd = hdc->hwnd;
	if (hwnd->unmapcount)
		return NULL;

	/*
	 * If the window is not the currently clipped one, then
	 * make it the current one and define its clip rectangles.
	 */
	if(hdc != cliphdc) {
		/* clip memory dc's to the bitmap size*/
		if(hdc->psd->flags&PSF_MEMORY) {
#if DYNAMICREGIONS
			GdSetClipRegion(hdc->psd,
				GdAllocRectRegion(0, 0, hdc->psd->xvirtres,
					hdc->psd->yvirtres));
#else
			static MWCLIPRECT crc = {0, 0, 0, 0};

			crc.width = hdc->psd->xvirtres;
			crc.height = hdc->psd->yvirtres;
			GdSetClipRects(hdc->psd, 1, &crc);
#endif
		} else MwSetClipWindow(hdc);
		cliphdc = hdc;
	}

	return hwnd;
}
예제 #2
0
/* 
 * Setup clip region from device context's associated window or bitmap.
 * Memory DC's are always associated with the desktop window, and are
 * always visible.  Return the DC's hwnd if window is visible.
 */
HWND
MwPrepareDC(HDC hdc)
{
	HWND	hwnd;

	if(!hdc || !hdc->hwnd)
		return NULL;

	hwnd = hdc->hwnd;
	if (hwnd->unmapcount)
		return NULL;

	/*
	 * If the window is not the currently clipped one, then
	 * make it the current one and define its clip rectangles.
	 */
	if(hdc != cliphdc) {
		/* clip memory dc's to the bitmap size*/
		if(hdc->psd->flags&PSF_MEMORY) {
#if DYNAMICREGIONS
			/* If hdc has a clip region, use it! */
			if (hdc->region != NULL && hdc->region->rgn != NULL
			    && hdc->region->rgn->size != 0) {
				LPRECT rptr = &(hdc->region->rgn->extents);
				MWCOORD left, top;

				/* Bound left,top to 0,0 if they are negative
				 * to avoid an assertion later.
				 */
				left = (rptr->left <= 0) ? 0 : rptr->left;
				top = (rptr->top <= 0) ? 0 : rptr->top;
				GdSetClipRegion(hdc->psd,
					GdAllocRectRegion(rptr->left, rptr->top,
						rptr->right, rptr->bottom));
			} else {
				GdSetClipRegion(hdc->psd,
					GdAllocRectRegion(0, 0,
						hdc->psd->xvirtres, hdc->psd->yvirtres));
			}
#else
			static MWCLIPRECT crc = {0, 0, 0, 0};

			/* If hdc has a clip region, use it! */
			if (hdc->region != NULL && hdc->region->rgn != NULL
			    && hdc->region->rgn->size != 0) {
				LPRECT rptr = &(hdc->region->rgn->extents);

				/* Bound left,top to 0,0 if they are negative
				 * to avoid an assertion later.
				 */
				if (rptr->left > 0)
					crc.x = rptr->left;
				if (rptr->top > 0)
					crc.y = rptr->top;
				crc.width = rptr->right;
				crc.height = rptr->bottom;
			} else {
				crc.width = hdc->psd->xvirtres;
				crc.height = hdc->psd->yvirtres;
			}
			GdSetClipRects(hdc->psd, 1, &crc);
#endif
		} else MwSetClipWindow(hdc);
		cliphdc = hdc;
	}

	return hwnd;
}