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

📄 mapp_uimenudraw2.c

📁 mstar 776 开发的车载dvd
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************
 Copyright (c) 2006 MStar Semiconductor, Inc.
 All rights reserved.

 [Module Name]: MApp_uiMenuDraw2.c
 [Date]:        2006/11/01
 [Comment]:
   OSD draw components relative subroutine..
 [Reversion History]:
*******************************************************************************/
#define MAPP_UI_MENU_DRAW2_C

#include "MApp_GlobalVar.h"
#include "MApp_GlobalFunction.h"
#include "MApp_Font.h"

#include "MApp_UiMenuDef.h"

#include "MApp_UiMenu.h"
#include "MApp_UiMenuComponent2.h"
#include "MApp_UiMenuTbl.h"
#include "MApp_UiMenuDraw2.h"

#include "OSDcp_loadbitmap.h"
#include "OSDcp_loadfont.h"
// sws
#include "MApp_UiMenuStr.h"
#include "MApp_UiMenufunc.h"
#include "msAPI_Font.h"
#include "Drvge2.h"
#include "MApp_SignalCheck.h"
#include "MApp_VDMode.h"
#include "msAPI_Scaler.h"
#include "OSDcp_Bitmap_EnumIndex.h"
#include "mreg51.h"  	//add by Jason071031 for control IE of interrup

BMPHANDLE  Osdcp_bmpHandle[];
FONTHANDLE  Osdcp_fHandle[];

#define OSDDBG(x) //x

//============================================================================
#define min(x, y) (((x) < (y)) ? (x) : (y))


#define CHAR_WIDTH  CHAR_IDX_2BYTE
extern U16* p_string_buffer;
extern U16* p_alt_string_buffer;
extern U16* p_copy_string_buffer;

U8 	IeBuffer;//add by Jason071031 For IR crash

static FONTHANDLE MApp_UiMenu_GetCharacterTable(U16 *pu16Str, FONTHANDLE fontDefault)
{
	// see EN 300 468 V1.7.1 (2006-05)
	if ( pu16Str[0]>=0x01 && pu16Str[0]<=0x05 )
		return fontDefault;   //todo when have fonts
	else if ( pu16Str[0]>=0x11 && pu16Str[0]<=0x14 )
		return Font[5].fHandle;

	return fontDefault;
}

static U8* MApp_UiMenu_GetFirstCharater(U16 *pu16Str)
{
	// see EN 300 468 V1.7.1 (2006-05)
	U8 *pu8Str = (U8 *) pu16Str;
	if ( pu16Str[0]>=0x01 && pu16Str[0]<=0x05 )
		pu8Str+=2;
	else if ( pu16Str[0]>=0x11 && pu16Str[0]<=0x14 )
		pu8Str+=2;

	return pu8Str;
}

static U32 MApp_UiMenu_BorderColor(U32 block_clr, U8 multiplicator, U8 divisor)
{
   U32 br_clr=(block_clr&0x00ff0000)>>16;
   U32 bg_clr=(block_clr&0x0000ff00)>>8;
   U32 bb_clr=(block_clr&0x000000ff);
   U32 border_clr;

   border_clr= (U32)((min((br_clr*multiplicator/divisor), 255)&0xff)<<16) + (U32)((min((bg_clr*multiplicator/divisor), 255)&0xff)<<8) + (U32)((min((bb_clr*multiplicator/divisor), 255)&0xff));

   return border_clr;
}

static void MApp_UiMenu_DrawSingleBorder(U16 x, U16 y, U16 width, U16 height, U32 block_clr, U32 gradient_clr, U8 u8Gradient, OSDClrBtn *pclrBtn, U8 multiplicator, U8 divisor)
{
   pclrBtn->x=x;
   pclrBtn->y=y;
   pclrBtn->width=width;
   pclrBtn->height=height;
   pclrBtn->u8Gradient=u8Gradient;

   if (u8Gradient==CONSTANT_COLOR)
   {
      pclrBtn->b_clr= MApp_UiMenu_BorderColor(block_clr, multiplicator, divisor);
   }
   else
   {
      pclrBtn->b_clr= MApp_UiMenu_BorderColor(block_clr, multiplicator, divisor);
      pclrBtn->g_clr= MApp_UiMenu_BorderColor(gradient_clr, multiplicator, divisor);
   	}

   msAPI_OSD_DrawBlock(pclrBtn);
}

static void MApp_UiMenu_DrawBorder(OSDClrBtn *pclrBtn, U8 multiplicator_0, U8 divisor_0, U8 multiplicator_1, U8 divisor_1)
{
   U16 x=pclrBtn->x;
   U16 y=pclrBtn->y;
   U16 width=pclrBtn->width;
   U16 height=pclrBtn->height;
   U32 block_clr=pclrBtn->b_clr;
   U32 gradient_clr=pclrBtn->g_clr;

   if (((pclrBtn->width)<4)||((pclrBtn->height)<4)||((pclrBtn->radius)!=0))
   {
   	    return;
   }

   if (pclrBtn->u8Gradient==CONSTANT_COLOR)
   {
      MApp_UiMenu_DrawSingleBorder(x+1, y+1, width-3, 1, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y, width-1, 1, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+2, 1, height-4, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y+1, 1, height-2, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+width-2, y+1, 1, height-2, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x+width-1, y, 1, height, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_1, multiplicator_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+height-2, width-3, 1, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x, y+height-1, width-1, 1, block_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_1, multiplicator_1);
   	}
   else if (pclrBtn->u8Gradient==GRADIENT_X_COLOR)
   {
      MApp_UiMenu_DrawSingleBorder(x+1, y+1, width-3, 1, block_clr, gradient_clr, GRADIENT_X_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y, width-1, 1, block_clr, gradient_clr, GRADIENT_X_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+2, 1, height-4, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y+1, 1, height-2, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+width-2, y+1, 1, height-2, gradient_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x+width-1, y, 1, height, gradient_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_1, multiplicator_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+height-2, width-3, 1, block_clr, gradient_clr, GRADIENT_X_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x, y+height-1, width-1, 1, block_clr, gradient_clr, GRADIENT_X_COLOR, pclrBtn, divisor_1, multiplicator_1);
   }
   else if (pclrBtn->u8Gradient==GRADIENT_Y_COLOR)
   {
      MApp_UiMenu_DrawSingleBorder(x+1, y+1, width-3, 1, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y, width-1, 1, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+2, 1, height-4, block_clr, gradient_clr, GRADIENT_Y_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y+1, 1, height-2, block_clr, gradient_clr, GRADIENT_Y_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+width-2, y+1, 1, height-2, block_clr, gradient_clr, GRADIENT_Y_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x+width-1, y, 1, height, block_clr, gradient_clr, GRADIENT_Y_COLOR, pclrBtn, divisor_1, multiplicator_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+height-2, width-3, 1, gradient_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x, y+height-1, width-1, 1, gradient_clr, gradient_clr, CONSTANT_COLOR, pclrBtn, divisor_1, multiplicator_1);
   }
   else if (pclrBtn->u8Gradient==GRADIENT_X_CENTER_COLOR)
   {
      MApp_UiMenu_DrawSingleBorder(x+1, y+1, width-3, 1, block_clr, gradient_clr, GRADIENT_X_CENTER_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y, width-1, 1, block_clr, gradient_clr, GRADIENT_X_CENTER_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+2, 1, height-4, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y+1, 1, height-2, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+width-2, y+1, 1, height-2, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x+width-1, y, 1, height, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, divisor_1, multiplicator_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+height-2, width-3, 1, block_clr, gradient_clr, GRADIENT_X_CENTER_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x, y+height-1, width-1, 1, block_clr, gradient_clr, GRADIENT_X_CENTER_COLOR, pclrBtn, divisor_1, multiplicator_1);
   }
   else if (pclrBtn->u8Gradient==GRADIENT_Y_CENTER_COLOR)
   {
      MApp_UiMenu_DrawSingleBorder(x+1, y+1, width-3, 1, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y, width-1, 1, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+2, 1, height-4, block_clr, gradient_clr, GRADIENT_Y_CENTER_COLOR, pclrBtn, multiplicator_0, divisor_0);
      MApp_UiMenu_DrawSingleBorder(x, y+1, 1, height-2, block_clr, gradient_clr, GRADIENT_Y_CENTER_COLOR, pclrBtn, multiplicator_1, divisor_1);

      MApp_UiMenu_DrawSingleBorder(x+width-2, y+1, 1, height-2, block_clr, gradient_clr, GRADIENT_Y_CENTER_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x+width-1, y, 1, height, block_clr, gradient_clr, GRADIENT_Y_CENTER_COLOR, pclrBtn, divisor_1, multiplicator_1);

      MApp_UiMenu_DrawSingleBorder(x+1, y+height-2, width-3, 1, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, divisor_0, multiplicator_0);
      MApp_UiMenu_DrawSingleBorder(x, y+height-1, width-1, 1, block_clr, block_clr, CONSTANT_COLOR, pclrBtn, divisor_1, multiplicator_1);
   }
}

void MApp_UiMenu_DrawLine_2(U8 u8CPIndex)
{
    g_ClrLine.x1 = g_u16GroupXPos + OSDLineComponents_2[u8CPIndex].u16OffsetXPos;
    g_ClrLine.y1 = g_u16GroupYPos + OSDLineComponents_2[u8CPIndex].u16OffsetYPos;
    g_ClrLine.x2 = OSDLineComponents_2[u8CPIndex].u16EndOffsetXPos;
    g_ClrLine.y2 = OSDLineComponents_2[u8CPIndex].u16EndOffsetYPos;
    g_ClrLine.u32LineColor	= OSDLineComponents_2[u8CPIndex].u32LineColor;
    g_ClrLine.u8LineWidth	= OSDLineComponents_2[u8CPIndex].u8LineWidth;

    msAPI_OSD_DrawLine(&g_ClrLine);
}

void MApp_UiMenu_DrawLine_TouchPanel(U16 ivalue, U16 jvalue)
{
    g_ClrLine.x1 = ivalue;
    g_ClrLine.y1 = jvalue;
    g_ClrLine.x2 = ivalue;
    g_ClrLine.y2 = jvalue;
    g_ClrLine.u32LineColor = 0x080808;
    g_ClrLine.u8LineWidth = 1;

    msAPI_OSD_DrawLine(&g_ClrLine);
}

// Addy 20071107
void MApp_UiMenu_DrawBlock_TouchPanel(U16 ivalue, U16 jvalue, U8 TPcolor, U8 TPsize)
{
    if(TPsize == 0)
    {
        clrBtn1.x = ivalue;
        clrBtn1.y = jvalue;
        clrBtn1.width = 1;
        clrBtn1.height = 1;
    }
    else if(TPsize == 1)
    {
        clrBtn1.x = ivalue -1;
        clrBtn1.y = jvalue -1;
        clrBtn1.width = 2;
        clrBtn1.height = 2;
    }
    else if(TPsize == 2)
    {
        clrBtn1.x = ivalue - 1;
        clrBtn1.y = jvalue - 1;
        clrBtn1.width = 3;
        clrBtn1.height = 3;
    }
    else if(TPsize == 3)
    {
        clrBtn1.x = ivalue - 2;
        clrBtn1.y = jvalue - 2;
        clrBtn1.width = 4;
        clrBtn1.height = 4;
    }
    else if(TPsize == 4)
    {
        clrBtn1.x = ivalue - 2;
        clrBtn1.y = jvalue - 2;
        clrBtn1.width = 5;
        clrBtn1.height = 5;
    }
    else if(TPsize == 5)
    {
        clrBtn1.x = ivalue - 3;
        clrBtn1.y = jvalue - 3;
        clrBtn1.width = 6;
        clrBtn1.height = 6;
    }
    else if(TPsize == 6)
    {
        clrBtn1.x = ivalue - 3;
        clrBtn1.y = jvalue - 3;
        clrBtn1.width = 7;
        clrBtn1.height = 7;
    }
    else if(TPsize == 7)
    {
        clrBtn1.x = ivalue - 4;
        clrBtn1.y = jvalue - 4;
        clrBtn1.width = 8;
        clrBtn1.height = 8;
    }
    else
    {
        clrBtn1.x = ivalue;
        clrBtn1.y = jvalue;
        clrBtn1.width = 1;
        clrBtn1.height = 1;
    }

    clrBtn1.radius = 0;
    clrBtn1.u8Gradient = CONSTANT_COLOR;
    clrBtn1.fHighLight = FALSE;
    if(TPcolor == 0)
    {
        clrBtn1.b_clr = 0x080808;
        clrBtn1.g_clr = 0x080808;
    }
    else if(TPcolor == 1)
    {
        clrBtn1.b_clr = 0xf8f8f8;
        clrBtn1.g_clr = 0xf8f8f8;
    }
    else if(TPcolor == 2)
    {
        clrBtn1.b_clr = 0xf80808;
        clrBtn1.g_clr = 0xf80808;
    }
    else if(TPcolor == 3)
    {
        clrBtn1.b_clr = 0x08f808;
        clrBtn1.g_clr = 0x08f808;
    }
    else if(TPcolor == 4)
    {
        clrBtn1.b_clr = 0x0808f8;
        clrBtn1.g_clr = 0x0808f8;
    }
    else if(TPcolor == 5)
    {
        clrBtn1.b_clr = 0x08f8f8;
        clrBtn1.g_clr = 0x08f8f8;
    }
    else if(TPcolor == 6)
    {
        clrBtn1.b_clr = 0xf808f8;
        clrBtn1.g_clr = 0xf808f8;
    }
    else if(TPcolor == 7)
    {
        clrBtn1.b_clr = 0xf8f808;
        clrBtn1.g_clr = 0xf8f808;
    }
    else
    {
        clrBtn1.b_clr = 0x080808;
        clrBtn1.g_clr = 0x080808;
    }

    msAPI_OSD_DrawBlock(&clrBtn1);
}

void MApp_UiMenu_DrawBlock_TouchPanel_Color(U16 ivalue, U16 jvalue, U8 TPcolor)
{
    clrBtn1.x = ivalue;
    clrBtn1.y = jvalue;
    #if(PANEL_WIDTH == 480)
    clrBtn1.width = 30;
    clrBtn1.height = 26;
    #else
    clrBtn1.width = 50;
    clrBtn1.height = 50;
    #endif
    clrBtn1.radius = 0;
    clrBtn1.u8Gradient = CONSTANT_COLOR;
    clrBtn1.fHighLight = FALSE;
    clrBtn1.b_clr = 0x080808;
    clrBtn1.g_clr = 0x080808;

⌨️ 快捷键说明

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