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

📄 wingdi.c

📁 神龙卡开发原代码
💻 C
📖 第 1 页 / 共 3 页
字号:
static MWBRUSHOBJ OBJ_LTGRAY_BRUSH = {	{OBJ_BRUSH, TRUE}, BS_SOLID, RGB(192, 192, 192)};static MWBRUSHOBJ OBJ_GRAY_BRUSH = {	{OBJ_BRUSH, TRUE}, BS_SOLID, RGB(128, 128, 128)};static MWBRUSHOBJ OBJ_DKGRAY_BRUSH = {	{OBJ_BRUSH, TRUE}, BS_SOLID, RGB(32, 32, 32)};static MWBRUSHOBJ OBJ_BLACK_BRUSH = {	{OBJ_BRUSH, TRUE}, BS_SOLID, RGB(0, 0, 0)};static MWBRUSHOBJ OBJ_NULL_BRUSH = {	{OBJ_BRUSH, TRUE}, BS_NULL, RGB(0, 0, 0)};static MWPENOBJ OBJ_WHITE_PEN = {	{OBJ_PEN, TRUE}, PS_SOLID, RGB(255, 255, 255)};static MWPENOBJ OBJ_BLACK_PEN = {	{OBJ_PEN, TRUE}, PS_SOLID, RGB(0, 0, 0)};static MWPENOBJ OBJ_NULL_PEN = {	{OBJ_PEN, TRUE}, PS_NULL, RGB(0, 0, 0)};static MWFONTOBJ OBJ_OEM_FIXED_FONT = {	{OBJ_FONT, TRUE}, NULL, MWFONT_OEM_FIXED};static MWFONTOBJ OBJ_ANSI_FIXED_FONT = {	{OBJ_FONT, TRUE}, NULL, MWFONT_SYSTEM_FIXED};static MWFONTOBJ OBJ_ANSI_VAR_FONT = {	{OBJ_FONT, TRUE}, NULL, MWFONT_SYSTEM_VAR};static MWFONTOBJ OBJ_SYSTEM_FONT = {	{OBJ_FONT, TRUE}, NULL, MWFONT_SYSTEM_VAR};static MWFONTOBJ OBJ_DEVICE_DEFAULT_FONT = {	{OBJ_FONT, TRUE}, NULL, MWFONT_OEM_FIXED};static MWFONTOBJ OBJ_SYSTEM_FIXED_FONT = {	{OBJ_FONT, TRUE}, NULL, MWFONT_SYSTEM_FIXED};static MWFONTOBJ OBJ_DEFAULT_GUI_FONT = {	{OBJ_FONT, TRUE}, NULL, MWFONT_GUI_VAR};static struct hgdiobj *stockObjects[MAXSTOCKOBJECTS] = {	(struct hgdiobj *)&OBJ_WHITE_BRUSH,		/* WHITE_BRUSH*/	(struct hgdiobj *)&OBJ_LTGRAY_BRUSH,		/* LTGRAY_BRUSH*/	(struct hgdiobj *)&OBJ_GRAY_BRUSH,		/* GRAY_BRUSH*/	(struct hgdiobj *)&OBJ_DKGRAY_BRUSH,		/* DKGRAY_BRUSH*/	(struct hgdiobj *)&OBJ_BLACK_BRUSH,		/* BLACK_BRUSH*/	(struct hgdiobj *)&OBJ_NULL_BRUSH,		/* NULL_BRUSH*/	(struct hgdiobj *)&OBJ_WHITE_PEN,		/* WHITE_PEN*/	(struct hgdiobj *)&OBJ_BLACK_PEN,		/* BLACK_PEN*/	(struct hgdiobj *)&OBJ_NULL_PEN,		/* NULL_PEN*/	(struct hgdiobj *)NULL,	(struct hgdiobj *)&OBJ_OEM_FIXED_FONT,		/* OEM_FIXED_FONT*/	(struct hgdiobj *)&OBJ_ANSI_FIXED_FONT,		/* ANSI_FIXED_FONT*/	(struct hgdiobj *)&OBJ_ANSI_VAR_FONT,		/* ANSI_VAR_FONT*/	(struct hgdiobj *)&OBJ_SYSTEM_FONT,		/* SYSTEM_FONT*/	(struct hgdiobj *)&OBJ_DEVICE_DEFAULT_FONT,	/* DEVICE_DEFAULT_FONT*/	(struct hgdiobj *)NULL,				/* DEFAULT_PALETTE*/	(struct hgdiobj *)&OBJ_SYSTEM_FIXED_FONT,	/* SYSTEM_FIXED_FONT*/	(struct hgdiobj *)&OBJ_DEFAULT_GUI_FONT		/* DEFAULT_GUI_FONT*/};HGDIOBJ WINAPIGetStockObject(int nObject){	HGDIOBJ		pObj;	MWFONTOBJ *	pFont;	if(nObject >= 0 && nObject < MAXSTOCKOBJECTS) {		pObj = stockObjects[nObject];		/* create stock fonts on first access*/		if(pObj->hdr.type == OBJ_FONT) {			pFont = (MWFONTOBJ *)pObj;			if(pFont->pfont == NULL) {				pFont->pfont = GdCreateFont(&scrdev,					pFont->name, 0, NULL);			}			return pObj;		}		/* implement multiple color schemes with		 * standard background brushes...		 */		switch(nObject) {		case LTGRAY_BRUSH:		case GRAY_BRUSH:			((MWBRUSHOBJ *)pObj)->color =GetSysColor(COLOR_BTNFACE);			break;		case DKGRAY_BRUSH:			((MWBRUSHOBJ *)pObj)->color =				GetSysColor(COLOR_BTNSHADOW);			break;		}		return pObj;	}	return NULL;}HGDIOBJ WINAPISelectObject(HDC hdc, HGDIOBJ hObject){	HGDIOBJ		objOrg;	MWBITMAPOBJ *	pb;	if(!hdc || !hObject)		return NULL;	switch(hObject->hdr.type) {	case OBJ_PEN:		objOrg = (HGDIOBJ)hdc->pen;		hdc->pen = (MWPENOBJ *)hObject;		break;	case OBJ_BRUSH:		objOrg = (HGDIOBJ)hdc->brush;		hdc->brush = (MWBRUSHOBJ *)hObject;		break;	case OBJ_FONT:		objOrg = (HGDIOBJ)hdc->font;		hdc->font = (MWFONTOBJ *)hObject;		break;	case OBJ_BITMAP:		/* must be memory dc to select bitmap*/		if(!(hdc->psd->flags&PSF_MEMORY))			return NULL;		objOrg = (HGDIOBJ)hdc->bitmap;		/* setup mem dc for drawing into bitmap*/		pb = (MWBITMAPOBJ *)hObject;		/* init memory context*/		if (!hdc->psd->MapMemGC(hdc->psd, pb->width, pb->height,			pb->planes, pb->bpp, pb->linelen, pb->size,			&pb->bits[0]))				return NULL;		hdc->bitmap = (MWBITMAPOBJ *)hObject;	    	break;#if UPDATEREGIONS	case OBJ_REGION:		/*objOrg = (HGDIOBJ)hdc->region;*/		objOrg = NULL;	/* FIXME? hdc->region is destroyed below*/		SelectClipRgn(hdc, (HRGN)hObject);		break;#endif	default:		return NULL;	}	return objOrg;}BOOL WINAPIDeleteObject(HGDIOBJ hObject){	if(!hObject || hObject->hdr.stockobj)		return FALSE;	if(hObject->hdr.type == OBJ_FONT)		GdDestroyFont(((MWFONTOBJ *)hObject)->pfont);	if(hObject->hdr.type == OBJ_REGION)		GdDestroyRegion(((MWRGNOBJ *)hObject)->rgn);	GdItemFree(hObject);	return TRUE;}#if UPDATEREGIONS/* region is passed in client coords (win32 api doc bug)*/int WINAPISelectClipRgn(HDC hdc, HRGN hrgn){	return ExtSelectClipRgn(hdc, hrgn, RGN_COPY);}/* * Select a user clip region into DC, recalculate final clipregion. * Only a copy of the passed region is used. *//* region is passed in client coords (win32 api doc bug)*/int WINAPIExtSelectClipRgn(HDC hdc, HRGN hrgn, int fnMode){	HRGN	newrgn;	if(!hdc)		return ERROR;	if(hdc->region != (MWRGNOBJ *)hrgn) {		/* combine region if not null*/		if(hrgn) {			newrgn = CreateRectRgn(0, 0, 0, 0);			/* 			 * Temporarily convert region from			 * client coords to screen coords, since			 * hwnd->update is kept in screen coords.			 */			OffsetRgn(hrgn, hdc->hwnd->clirect.left,				hdc->hwnd->clirect.top);			if(fnMode == RGN_COPY)				CombineRgn(newrgn, hrgn, NULL, fnMode);			else CombineRgn(newrgn, (HRGN)hdc->region, hrgn,fnMode);			/* convert passed region back to client coords*/			OffsetRgn(hrgn, -hdc->hwnd->clirect.left,				-hdc->hwnd->clirect.top);			hrgn = newrgn;		}		DeleteObject((HRGN)hdc->region);		hdc->region = (MWRGNOBJ *)hrgn;		/* force recalc of clipregion*/		cliphdc = NULL;		MwPrepareDC(hdc);	}	if(hrgn)		return ((MWRGNOBJ *)hrgn)->rgn->type;	return NULLREGION;}/* update region is returned in client coordinates*/int WINAPIGetUpdateRgn(HWND hwnd, HRGN hrgn, BOOL bErase){	/* FIXME bErase*/	if(!hwnd)		return ERROR;	/* convert internal update region to client coords*/	GdOffsetRegion(hwnd->update, -hwnd->clirect.left, -hwnd->clirect.top);	GdCopyRegion(((MWRGNOBJ *)hrgn)->rgn, hwnd->update);	GdOffsetRegion(hwnd->update, hwnd->clirect.left, hwnd->clirect.top);	return hwnd->update->type;}#endif /* UPDATEREGIONS*//* update rectangle is returned in client coords*/BOOL WINAPIGetUpdateRect(HWND hwnd, LPRECT lpRect, BOOL bErase){	/* FIXME bErase*/	if(!hwnd)		return FALSE;#if UPDATEREGIONS	if(lpRect) {		*lpRect = hwnd->update->extents;		/* convert to client coords*/		ScreenToClient(hwnd, (LPPOINT)&lpRect->left);		ScreenToClient(hwnd, (LPPOINT)&lpRect->right);	}	/* return TRUE if update region is non-empty*/	return hwnd->update->type != NULLREGION;#else	GetClientRect(hwnd, lpRect);	return TRUE;#endif}HBRUSH WINAPICreateSolidBrush(COLORREF crColor){	MWBRUSHOBJ *hbr;	hbr = GdItemNew(MWBRUSHOBJ);	if(!hbr)		return NULL;	hbr->hdr.type = OBJ_BRUSH;	hbr->hdr.stockobj = FALSE;	hbr->style = BS_SOLID;	hbr->color = crColor;	return (HBRUSH)hbr;}HPEN WINAPICreatePen(int nPenStyle, int nWidth, COLORREF crColor){	MWPENOBJ *hpen;	/* fix: nWidth > 1*/	hpen = GdItemNew(MWPENOBJ);	if(!hpen)		return NULL;	hpen->hdr.type = OBJ_PEN;	hpen->hdr.stockobj = FALSE;	hpen->style = nPenStyle;	hpen->color = crColor;	return (HPEN)hpen;}HBITMAP WINAPICreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight){	MWBITMAPOBJ *	hbitmap;	int		size;	int		linelen;	if(!hdc)		return NULL;	nWidth = MWMAX(nWidth, 1);	nHeight = MWMAX(nHeight, 1);	/* calc memory allocation size and linelen from width and height*/	if(!GdCalcMemGCAlloc(hdc->psd, nWidth, nHeight, 0, 0, &size, &linelen))		return NULL;	/* allocate gdi object*/	hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size);	if(!hbitmap)		return NULL;	hbitmap->hdr.type = OBJ_BITMAP;	hbitmap->hdr.stockobj = FALSE;	hbitmap->width = nWidth;	hbitmap->height = nHeight;	/* create compatible with hdc*/	hbitmap->planes = hdc->psd->planes;	hbitmap->bpp = hdc->psd->bpp;	hbitmap->linelen = linelen;	hbitmap->size = size;	return (HBRUSH)hbitmap;}/* return NULL if no driver bitblit available*/HDC WINAPICreateCompatibleDC(HDC hdc){	HDC	hdcmem;	PSD	psd;	PSD	mempsd;	/* allow NULL hdc to mean screen*/	psd = hdc? hdc->psd: &scrdev;	/* allocate memory device, if driver doesn't blit will fail*/	mempsd = psd->AllocateMemGC(psd);	if(!mempsd)		return NULL;	/* allocate a DC for DesktopWindow*/	hdcmem = GetDCEx(NULL, NULL, DCX_DEFAULTCLIP);	if(!hdcmem) {		mempsd->FreeMemGC(mempsd);		return NULL;	}	hdcmem->psd = mempsd;	/* select in default bitmap to setup mem device parms*/	SelectObject(hdcmem, (HGDIOBJ)&default_bitmap);	return hdcmem;}BOOL WINAPIBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,	HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop){	/* use stretch blit with equal src and dest width/height*/	return StretchBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,		hdcSrc, nXSrc, nYSrc, nWidth, nHeight, dwRop);}BOOL WINAPIStretchBlt(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;}UINT WINAPIGetSystemPaletteEntries(HDC hdc,UINT iStartIndex,UINT nEntries,	LPPALETTEENTRY lppe){	UINT		i;	MWPALENTRY	rgb;	/* currently, we only work for screen device*/	if(!hdc || hdc->psd != &scrdev)		return 0;	for(i=0; i<nEntries; ++i) {		if(!GdGetPalette(hdc->psd, i+iStartIndex, 1, &rgb))			break;		lppe->peRed = rgb.r;		lppe->peGreen = rgb.g;		lppe->peBlue = rgb.b;		lppe->peFlags = 0;		++lppe;	}	return i;}/* allow NULL hdc for scrdev*/int WINAPIGetDeviceCaps(HDC hdc, int nIndex){	PSD	psd;	if (!hdc)		psd = &scrdev;	else psd = hdc->psd;	switch(nIndex) {	case HORZRES:		return psd->xvirtres;	case VERTRES:		return psd->yvirtres;	case BITSPIXEL:		return psd->bpp;	case PLANES:		return psd->planes;	case LOGPIXELSX:	case LOGPIXELSY:		return 96;	case SIZEPALETTE:		if (psd->bpp <= 8)			return psd->ncolors;		break;	}	return 0;}

⌨️ 快捷键说明

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