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

📄 gfx_drawcontrol.c.svn-base

📁 sigmadesign smp8623 gui source code ,bingo
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
	blend_param.Src1Y = 0;	blend_param.Src2X = x; // X	blend_param.Src2Y = y;	blend_param.DstX = x;	blend_param.DstY = y;	blend_param.Width = width;	blend_param.Height = height;	blend_param.SaturateAlpha = FALSE;	status = GFXBlendRectanglesProperty(pRua, &blend_param);	return RM_OK;}RMstatus DrawBitmappedButton(struct RUA *pRua, RMButtonObject *obj, RMuint8 bmpindex, RMbool loadingPage){	RMstatus status = RM_OK;	struct GFXEngine_MoveReplaceRectangle_type move_param;	struct GFXEngine_BlendRectangles_type blend_param;	//	GFXLib_rect rect;	RMuint8 bufferindex;	RMuint32 startaddr;	RMuint8 alpha = 0x80;	RMuint32 mainmode, bkmode;	if (obj->state > STATE_DISABLED)		return RM_ERROR;	//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!	// paint background before drawing button if transparent color used	/*	if(obj->usetransparentcolor && g_bitmaps[0].path[0] != 0){	 rect.x = obj->x;	 rect.y = obj->y;	 rect.width = obj->width;	 rect.height = g_bitmaps[bmpindex].bmp.uiHeight;	 DrawBitmapRect(pRua, obj->x, obj->y, &rect, 0, 0, 0);	 }*/	//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!	// set transparency	g_bitmaps[bmpindex].transparentcolor = obj->transparentcolor;	g_bitmaps[bmpindex].usetransparentcolor = obj->usetransparentcolor;	if (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel <= 8)		SetPalette(pRua, alpha, bmpindex, GFX_SURFACE_ID_Y);	// use either bitmap allocated buffer or part(or whole) of extra buffer to draw	if (g_bitmaps[bmpindex].bmp.uiDataSize > gdata.drawBuffer.size / MAX_DRAWING_BUFFER_PARTS)	{		if (g_bitmaps[bmpindex].bmp.uiDataSize > gdata.drawBuffer.size)			bufferindex = 0; // cannot use extra, use bitmap allocated mem		else			bufferindex = GetBitmapBufferIndex(TRUE); // use whole extra buffer	}	else		bufferindex = GetBitmapBufferIndex(FALSE); // use part of extra buffer	//RMDBGLOG((GFXDBG, ">>>>>>>>>>>>>>>>>>>>>>>>>DRAWING %s, index %d\n", g_bitmaps[bmpindex].path, bmpindex));	//RMDBGLOG((GFXDBG, ">>>>>>>>>>>>>>>>>>>>>>>>>BUFFER INDEX %d avail: %ld need: %ld\n", bufferindex, gdata.drawBuffer.size, g_bitmaps[bmpindex].bmp.uiDataSize));	if (bufferindex > 0 && gdata.drawBuffer.pMappedAddr && loadingPage == FALSE)	{		RMuint32 offset = (bufferindex - 1) * (gdata.drawBuffer.size / MAX_DRAWING_BUFFER_PARTS);		RMMemcpy(gdata.drawBuffer.pMappedAddr + offset, g_bitmaps[bmpindex].bmp.pData, g_bitmaps[bmpindex].bmp.uiDataSize);		startaddr = gdata.drawBuffer.baseAddr + offset;	}	else	{		startaddr = g_bitmaps[bmpindex].pBmpAddr;	}	// color format	switch (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel)	{	case 1:		mainmode = EMhwlibColorMode_LUT_1BPP;		break;	case 2:		mainmode = EMhwlibColorMode_LUT_2BPP;		break;	case 4:		mainmode = EMhwlibColorMode_LUT_4BPP;		break;	case 8:		mainmode = EMhwlibColorMode_LUT_8BPP;		break;	default:		mainmode = EMhwlibColorMode_TrueColor;		break;	}	if (g_bitmaps[0].pBmpAddr == 0)	{		RMASSERT(g_bitmaps[bmpindex].pBmpAddr != 0);		// setup Y surface		status = SetInputSurface(pRua, mainmode, startaddr, g_bitmaps[bmpindex].bmp.uiWidth, GFX_SURFACE_ID_Y);		if (RMFAILED(status))			RMDBGLOG((GFXDBG, "Error setting surface parameters\n"));		move_param.SrcX = obj->state * obj->width;// [RC] should check this param!!!!!!		move_param.SrcY = 0;		move_param.AlphaX = 0;		move_param.AlphaY = 0;		move_param.DstX = obj->x;		move_param.DstY = obj->y;		move_param.Width = obj->width;		move_param.Height = g_bitmaps[bmpindex].bmp.uiHeight;		move_param.Merge = FALSE;		status = GFXReplaceRectangleProperty(pRua, &move_param);		return RM_OK;	}	// setup X surface	// color format	switch (g_bitmaps[0].bmp.uiNbBitPerPixel)	{	case 1:		bkmode = EMhwlibColorMode_LUT_1BPP;		break;	case 2:		bkmode = EMhwlibColorMode_LUT_2BPP;		break;	case 4:		bkmode = EMhwlibColorMode_LUT_4BPP;		break;	case 8:		bkmode = EMhwlibColorMode_LUT_8BPP;		break;	default:		bkmode = EMhwlibColorMode_TrueColor;		break;	}	status = SetInputSurface(pRua, bkmode, g_bitmaps[0].pBmpAddr, g_bitmaps[0].bmp.uiWidth, GFX_SURFACE_ID_X);	if (RMFAILED(status))		RMDBGLOG((GFXDBG, "Error setting surface parameters\n"));	// setup Y surface	// color mode from above	status = SetInputSurface(pRua, mainmode, startaddr, g_bitmaps[bmpindex].bmp.uiWidth, GFX_SURFACE_ID_Y);	if (RMFAILED(status))		RMDBGLOG((GFXDBG, "Error setting surface parameters\n"));	blend_param.Src1X = obj->state * obj->width; // Src1 YZ surface	blend_param.Src1Y = 0;	blend_param.Src2X = obj->x; // Src2 X surface	blend_param.Src2Y = obj->y;	blend_param.DstX = obj->x;	blend_param.DstY = obj->y;	blend_param.Width = obj->width;	blend_param.Height = g_bitmaps[bmpindex].bmp.uiHeight;	blend_param.SaturateAlpha = FALSE;	status = GFXBlendRectanglesProperty(pRua, &blend_param);	return RM_OK;}RMstatus DrawButton(struct RUA *pRua, RMuint16 xOrigen, RMuint16 yOrigen, RMButtonObject *obj, RMuint8 parentindex){	RMstatus status;	RMuint8 bmpindex;	GFXLib_rect rect;	RMuint32 color;	//	GFXLib_textdata txt;	Prop prop;	prop.trunc = TRUNC_NONE;	//	sub_data* data;	//	RMuint32 i,j;	if (obj->visible == FALSE)		return RM_OK;	//	status = SetOutputSurfaceBuffer(pRua, gdata.backBuffer.baseAddr, gdata.osdWidth);	//	if(RMFAILED(status))	//		return status;	// check if bitmapped	if (obj->file != 0)	{		// check if it is three-state		if (obj->selectedFile == 0 && obj->selectOverlay == 0)		{			status = GetBitmapIndex(pRua, obj->file, &bmpindex, TRUE);			if (RMFAILED(status))				return status;			DrawBitmappedButton(pRua, obj, bmpindex, FALSE);			return BitBlt(pRua);		}		else		{			if (obj->selectOverlay)			{				if (obj->state == STATE_SELECTED)				{					status = GetBitmapIndex(pRua, obj->selectOverlay, &bmpindex, TRUE);					if (RMFAILED(status))						return status;					DrawBitmapBlendBack(pRua, obj->x, obj->y, obj->transparentcolor, obj->usetransparentcolor, 0x80, bmpindex, TRUE, 0);					status = GetBitmapIndex(pRua, obj->file, &bmpindex, TRUE);					if (RMFAILED(status))						return status;					DrawBitmapBlendBack(pRua, obj->x, obj->y, obj->transparentcolor, obj->usetransparentcolor, 0x80, bmpindex, TRUE, 0);					return RM_OK;//BitBlt(pRua);				}				else				{					status = GetBitmapIndex(pRua, obj->file, &bmpindex, TRUE);					if (RMFAILED(status))						return status;					DrawBitmapBlendBack(pRua, obj->x, obj->y, obj->transparentcolor, obj->usetransparentcolor, 0x80, bmpindex, TRUE, 0);					return RM_OK;// BitBlt(pRua);				}			}			else			{				if (obj->state == STATE_SELECTED)					status = GetBitmapIndex(pRua, obj->selectedFile, &bmpindex, TRUE);				else					status = GetBitmapIndex(pRua, obj->file, &bmpindex, TRUE);				if (RMFAILED(status))					return status;				DrawBitmap(pRua, obj->x, obj->y, obj->transparentcolor, obj->usetransparentcolor, 0x80, bmpindex, TRUE, parentindex);				return RM_OK;// BitBlt(pRua);			}		}	}	// text button	rect.x = obj->x + xOrigen;	rect.y = obj->y + yOrigen;	rect.width = obj->width;	rect.height = obj->height;	// check if rectangular -- NEED RECT function!!!!!!!!!!!!!!!!!!	if (obj->rounded == FALSE)		status = Fill(pRua, rect.x, rect.y, rect.width, rect.height, obj->backgroundcolor);	else	{		status = RoundRect(pRua, rect.x, rect.y, rect.width, rect.height, obj->backgroundcolor, TRUE, parentindex);	}	if (RMFAILED(status))		return status;	// draw state	color = (obj->state == STATE_SELECTED ? obj->outlinecolor : obj->backgroundcolor);	RectOutline(pRua, &rect, color, obj->rounded, color == obj->backgroundcolor, parentindex);	//	status = GetFontIndex(pRua, obj->fontfile, obj->charwidth, &bmpindex);	//	if(RMFAILED(status))	//		return status;	RMMemset(&prop, 0, sizeof(Prop));	RMCopyAscii(prop.text, obj->text);	//	txt.foregroundcolor = (obj->state != STATE_DISABLED ? obj->foregroundcolor : DISABLED_FOREGND_COLOR);	//	txt.backgroundcolor = obj->backgroundcolor;	//	txt.transparentbackground = FALSE;	//	txt.alignment = obj->textalign;	// fill the palette and color format	//	SetTextPalette(pRua, obj->foregroundcolor, obj->backgroundcolor, FALSE);	// [RC] assuming 1bpp	//	SetTextColorFormat(pRua);	prop.scale = atoi(obj->fontfile);	prop.bgColor = obj->foregroundcolor;// & 0xFFFFFFFF;	prop.fgColor = obj->backgroundcolor & 0x00FFFFFF;	prop.alignment = obj->textalign;	//	RtkPoint	//	gfxGetTextExtents(pRua, obj->text, &prop, &rctext);	//	point.x = rect.x + ((rect.width - rctext.width) >> 1);	//	point.y = rect.y + ((rect.height - rctext.height) >> 1);	rect.x += 5;	rect.y += 5;	rect.width -= 10;	rect.height -= 10;	gfxTTDrawString(pRua, &rect, &prop, NULL);	return RM_OK;	//	return DrawString(pRua, &rect, &txt, bmpindex);}RMstatus DrawMenu(struct RUA *pRua, GFXLib_rect *rect, GFXLib_menudata *menudata, RMuint32 fcolor, RMuint32 bcolor, RMuint8 fontindex){	RMint32 i;	RMuint8 itemheight;	GFXLib_rect rc, rcText;	RMuint32 color;	//	GFXLib_textdata txt;	Prop prop;	prop.trunc = TRUNC_NONE;	if (menudata->redraw)	{		// first draw menu area and (outside) outline -- rounded		// repaint area occupied by string		RoundRect(pRua, rect->x, rect->y, rect->width, rect->height, bcolor, TRUE, 0);		if (menudata->menuoutlinecolor != 0)		{			rc.x = rect->x - 2;			rc.y = rect->y - 2;			rc.width = rect->width + 4;			rc.height = rect->height + 4;			RectOutline(pRua, &rc, menudata->menuoutlinecolor, FALSE, FALSE, 0); // rounded as well		}	}	// now draw items	RMMemset(&prop, 0, sizeof(Prop));	RMCopyAscii(prop.text, "ABC");	prop.scale = fontindex;	prop.fgColor = bcolor & 0x00FFFFFF;	prop.bgColor = fcolor | 0xFF000000;	prop.alignment = ALIGN_LEFT;	gfxGetTextExtents(pRua, &prop, &rcText);	itemheight = rcText.height * 3 / 2; //1 1/2 font height	// fill the palette and set color format	SetTextPalette(pRua, fcolor, bcolor, FALSE); // [RC] assuming 1bpp	SetTextColorFormat(pRua);	for (i = 0; i < menudata->count; i++)	{		// add text		if (menudata->redraw)		{			rc.x = rect->x + 10;			rc.y = rect->y + itemheight * i;			rc.width = rect->width - 20;			rc.height = itemheight;			RMCopyAscii(prop.text, menudata->items[i]);			//			txt.foregroundcolor = (menudata->state[i] != STATE_DISABLED ? fcolor : DISABLED_FOREGND_COLOR);			//			txt.backgroundcolor = bcolor;			//			txt.transparentbackground = FALSE;// TRUE;			//			txt.alignment = ALIGN_LEFT;			prop.alignment = ALIGN_LEFT;			gfxTTDrawString(pRua, &rc, &prop, NULL);			//			DrawString(pRua, &rc, &txt, fontindex);			if (menudata->textvalues[i] != (RMascii *) NULL)			{				//				RMuint32 rc_width = rc.width;				//				rc.width -= 10;				RMCopyAscii(prop.text, menudata->textvalues[i]);				//				txt.alignment = ALIGN_RIGHT;				//				prop.scale = 18;				prop.alignment = ALIGN_RIGHT;				gfxTTDrawString(pRua, &rc, &prop, NULL);				//				rc.width = rc_width;				//				DrawString(pRua, &rc, &txt, fontindex);			}		}		rc.x = rect->x;		rc.y = rect->y + itemheight * i;		rc.width = rect->width;		rc.height = itemheight;		// draw state		if (menudata->hasfocus)			color = (i == menudata->selecteditem ? menudata->outlinecolor : bcolor);		else			color = bcolor;		RectOutline(pRua, &rc, color, FALSE, color == bcolor, 0); // rounded as well	}	return RM_OK;}RMstatus DrawBitmapRect(struct RUA *pRua, RMuint16 x, RMuint16 y, GFXLib_rect *rect, RMuint32 transparentcolor,		RMbool usetransparentcolor, RMuint8 bmpindex){	RMstatus status = RM_OK;	RMbool hasPalette;	struct GFXEngine_MoveReplaceRectangle_type move_param;	struct GFXEngine_BlendRectangles_type blend_param;	RMuint32 mainmode;	RMuint8 alpha = 0xff;	if (g_bitmaps[bmpindex].path[0] == 0)	{		//		printf("SKIPPING BACKGROUND!!!!!!!!!!!!!!!!!!!!!!\n");		return RM_ERROR;	}	hasPalette = (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel <= 8);	// setup input Y surface	// set transparency	g_bitmaps[bmpindex].transparentcolor = transparentcolor;	g_bitmaps[bmpindex].usetransparentcolor = usetransparentcolor;	// fill the palette	if (hasPalette)		SetPalette(pRua, alpha, bmpindex, GFX_SURFACE_ID_Y);	// color format	switch (g_bitmaps[bmpindex].bmp.uiNbBitPerPixel)	{	case 1:		mainmode = EMhwlibColorMode_LUT_1BPP;		break;	case 2:		mainmode = EMhwlibColorMode_LUT_2BPP;		break;	case 4:		mainmode = EMhwlibColorMode_LUT_4BPP;		break;	case 8:		mainmode = EMhwlibColorMode_LUT_8BPP;		break;	default:		mainmode = EMhwlibColorMode_TrueColor;		break;	}	if (bmpindex == 0 || g_bitmaps[0].pBmpAddr == 0 || usetransparentcolor)	{		RMASSERT(g_bitmaps[bmpindex].pBmpAddr != 0);		status = SetInputSurface(pRua, mainmode, g_bitmaps[bmpindex].pBmpAddr, g_bitmaps[bmpindex].bmp.uiWidth, GFX_SURFACE_ID_Y);		if (RMFAILED(status))			RMDBGLOG((GFXDBG, "Error setting surface parameters\n"));		move_param.SrcX = rect->x;		move_param.SrcY = rect->y;		move_param.AlphaX = 0;		move_param.AlphaY = 0;		move_param.DstX = x;		move_param.DstY = y;		move_param.Width = rect->width;		move_param.Height = rect->height;		move_param.Merge = FALSE;		status = GFXReplaceRectangleProperty(pRua, &move_param);		return RM_OK;	}

⌨️ 快捷键说明

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