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

📄 mmimain.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
            hour=currclock.hour-12;
        }
        else if( currclock.hour==0 )
        {
            hour=12;
        }
        else
        {
            hour=currclock.hour;
        }   
        sprintf(line,"%02d:%02d%s",hour,currclock.min, AmPm); //zgz, 2002.8.23  	   
    }
    else
        sprintf(line,"%02d:%02d",currclock.hour,currclock.min);
#if (MAIN_LCD_SIZE==4)									// WYJ MI18800000425
    if( FFS_flashData.language==0 )
    {
        weekpositionX = 71;
        /*2003/10/30,talcon change 125 t0 110 */
        //weekpositionY = 125;
        weekpositionY = 110;
    }
    else
    {
        weekpositionX = 3;
        weekpositionY = 113;
    }

    switch( today.week ) //xsf add for get weekday 12.06
    {
    case 0:
        dspl_TextOut(weekpositionX,weekpositionY,DSPL_TXTATTR_WHITE_EDGE,(char*)GET_TEXT(TxtSunday));
        break;
    case 1:
        dspl_TextOut(weekpositionX,weekpositionY,DSPL_TXTATTR_WHITE_EDGE,(char*)GET_TEXT(TxtMonday));
        break;
    case 2:
        dspl_TextOut(weekpositionX,weekpositionY,DSPL_TXTATTR_WHITE_EDGE,(char*)GET_TEXT(TxtTuesday));
        break;
    case 3:
        dspl_TextOut(weekpositionX,weekpositionY,DSPL_TXTATTR_WHITE_EDGE,(char*)GET_TEXT(TxtWednesday));
        break;
    case 4:
        dspl_TextOut(weekpositionX,weekpositionY,DSPL_TXTATTR_WHITE_EDGE,(char*)GET_TEXT(TxtThursday));
        break;
    case 5:
        dspl_TextOut(weekpositionX,weekpositionY,DSPL_TXTATTR_WHITE_EDGE,(char*)GET_TEXT(TxtFriday));
        break;
    case 6:
        dspl_TextOut(weekpositionX,weekpositionY,DSPL_TXTATTR_WHITE_EDGE,(char*)GET_TEXT(TxtSaturday));
        break;
    default:
        break;

    }

	/* 2004/05/11 sunsj modify */
    dspl_TextOut( SCREEN_SIZE_X - 2 - get_StringWidth(line), SCREEN_SIZE_Y - Mmi_layout_line_height()*2, 
		DSPL_TXTATTR_WHITE_EDGE, (char *)line);  
#elif (MAIN_LCD_SIZE==3)
	dspl_TextOut((126 - get_StringWidth(line))/2,66,DSPL_TXTATTR_WHITE_EDGE,(char *)line);//jhxu720
#endif
	
}
/*******************************************************************************

 $Function:  setClockFormat

 $Description:  used to switch between 24 hour and 12 hour display format

 $Returns:    none.

 $Arguments:  format enum

*******************************************************************************/
void setClockFormat(UBYTE format)
{
    if( FFS_flashData.time_format == format )  //zgz,2002.8.23
        return;
    /*
    if (format == TWELVE_HOUR)
      FFS_flashData.time_format = TWELVE_HOUR;
    else
      FFS_flashData.time_format = TWENTYFOUR_HOUR;
    */
    FFS_flashData.time_format = format;

    flash_write(); //store format in flash
}

/*******************************************************************************

 $Function:  ClockSet

 $Description:   exit MMI main module

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void ClockSet(CLOCK *currclock)
{

    timStop(times);                     /* clock stop   only for PC testing  */

    second = currclock->hour*3600 + currclock->min*60 + currclock->sec;
    timStart(times);                    /* clock new starts         */
}
/*******************************************************************************

 $Function:  DateSet

 $Description:   date set -

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void DateSet(Date *currdate)
{

    currdate->day++;

    if( (currdate->day >= 29) && (currdate->month EQ 2) )
    {
        if( currdate->day EQ 29 )
        {
            if( ((currdate->year%4) NEQ 0) && (currdate->year NEQ 2000) )
            {
                currdate->day = 1;
                currdate->month = 3;
            }
        }
        else
        {
            currdate->day = 1;
            currdate->month = 3;
        }
    }

    if( currdate->day >= 31 )
    {
        if( currdate->day EQ 31 )
        {
            switch( currdate->month )
            {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                break;
            default:
                currdate->day = 1;
                currdate->month++;
                break;
            }
        }
        else
        {
            currdate->day = 1;
            if( currdate->month != 12 )
                currdate->month++;
            else
            {
                currdate->month = 1;
                currdate->year++;
            }
        }
    }
}
/*******************************************************************************

 $Function:  showDATE

 $Description:   display date

 $Returns:

 $Arguments:

*******************************************************************************/
void showDATE(void)
{
    char line[MAX_LINE];/* only for PC testing  */
    char s[5];
    int c;
    sprintf(s,"%04d",currdate.year);
    //itoa(currdate.year,s,10);
    c=atoi(&s[2]);

    sprintf(line,"%02d.%02d.%02d",c,currdate.month, currdate.day);
    if( FFS_flashData.language==0 )
        dspl_TextOut(3,128,DSPL_TXTATTR_WHITE_EDGE,(char *)line);// zy add 0918 DSPL_TXTATTR_WHITE_EDGE
    else
    {

        /*...................zy change the date display place 04/08/02.......................  */
        //sprintf(line,"%02d/%02d/%04d",currdate.month, currdate.day, currdate.year);
        dspl_TextOut(2,128,DSPL_TXTATTR_WHITE_EDGE,(char *)line);
        sprintf(line,"%04d/%02d/%02d",currdate.year,currdate.month, currdate.day);

    }
    /* ...................end of zy change..................................................................*/
}

/*******************************************************************************

 $Function:  truncateString

 $Description:

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void truncateString(char* strDest,char* strOrig,unsigned int truncLength,int pos,char* trunChar)
{
    unsigned int real_lenth=0,dspl_lenth=0;  //xsf add 03.03.11
    unsigned char * ss=(unsigned char*)strOrig;
    char *s;

    if( wstrBitlen(strOrig)>truncLength )//zy 12/23 for eng with chn menu
    {
        if( wstrlen(trunChar)<truncLength )
        {

            if( pos == POS_END )
            {
                if( *(unsigned char*)strOrig==0x80 )
                {
                    //begin of xsf add 2003.03.11
                    ss++;
                    while( ((*ss<<8)+*(ss+1)!=0) && ((dspl_lenth<truncLength-1) || ((dspl_lenth==truncLength-1) && (*ss==0x00))) )
                    {
                        if( *ss==0x00 )//if not chinese
                            dspl_lenth++;
                        else
                            dspl_lenth+=2;
                        real_lenth+=2;
                        ss+=2;
                    }
                    truncLength=real_lenth;
                    //end of xsf add 2003.03.11
                    wstrncpy(strDest,strOrig,truncLength-2);
                }
                else
                    wstrncpy(strDest,strOrig,truncLength-wstrBitlen(trunChar));
                // s=strDest;
                // s+=truncLength-wstrBitlen(trunChar);
                // wstrcpy(s,trunChar);
                wstrcat(strDest, trunChar);
            }
            else
            {
                s = strOrig;
                s = s+wstrlen(strOrig)-truncLength;
                wstrncpy(strDest,s,truncLength+1);
                wstrncpy(strDest,trunChar,wstrlen(trunChar));
            }
        }
        else
        {
            wstrncpy(strDest,trunChar,truncLength);
            s = strDest;//zy add 09/27
            s++;
            *s='\0'; /* RSA/JVJ-SPR#1204. The wrong address was being overwritten */
        }
    }
    else
        wstrncpy(strDest,strOrig,wstrlen(strOrig));

}

/*******************************************************************************

 $Function:  displayAlignedText

 $Description:  Display text horizontally aligned [left|right|center] in specified row.


 $Returns:    none.

 $Arguments:

*******************************************************************************/
void displayAlignedText( T_MMI_ALIGN x_alignment, USHORT y_lineNum, UBYTE attrib, char* string )
{
    int stringLength = 0;
    USHORT startXPos = 0;      // starting X pos for display

    dspl_DevCaps deviceCaps;

    dspl_GetDeviceCaps(&deviceCaps);

    /* 2003/11/27 sunsj get string length */
    //stringLength=wstrBitlen(string)*8;  //xsf changed to wstrBitlen 2003.01.23
    stringLength = get_StringWidth(string);

    switch( x_alignment )
    {
    case LEFT:

        break;

    case RIGHT:
        startXPos = (USHORT) deviceCaps.Width - stringLength /*- OneCharLen*/ ;
        break;

    case CENTER:
        if( (deviceCaps.Width - stringLength)>=0 )
            startXPos = (USHORT) (deviceCaps.Width - stringLength) / 2;
        else
            startXPos =0;   
        break;
#if(MAIN_LCD_SIZE==3)//jhxu720
	case CENTER_RIGHT://jhxu720 add
        if( (deviceCaps.Width - stringLength)>=0 )
            startXPos = (USHORT) (deviceCaps.Width - stringLength) / 2+22;
        else
            startXPos =0;   
        break;
#endif		

    }

    dspl_TextOut(startXPos, y_lineNum, attrib, (char*)string );
}

/*******************************************************************************
	$Function:		TruncateStringAddDot
	$Description:
	$Author:		Sunny
	$Date:			2004-05-09
*******************************************************************************/
void TruncateStringAddDot(char *strDest, char *strOrig, unsigned int Length)
{
	unsigned int real_lenth = 0, dspl_lenth = 0, strLength = 0;  
    unsigned char *ss = (unsigned char*)strOrig;
	U16 Temp_Char, HighByte, LowByte;
	
	strLength = get_StringWidth(strOrig);

	if(strLength > Length)
	{
		if(*(unsigned char*)strOrig == 0x80)//UNICODE
		{
			ss++;

			HighByte = (*ss & 0x00ff) << 8;
			LowByte = (*(ss+1) & 0x00ff);
			
			Temp_Char = HighByte | LowByte;
			
			while((Temp_Char) && (dspl_lenth < Length))
			{
				dspl_lenth += get_CharWidth( Temp_Char );
				ss += 2;
				HighByte = (*ss & 0x00ff) << 8;
				LowByte = (*(ss+1) & 0x00ff);
				
				Temp_Char = HighByte | LowByte;
				real_lenth += 2;
			}

			real_lenth -= 3;
			memcpy(strDest, strOrig, real_lenth);
			strDest[real_lenth] = 0x00;
			strDest[real_lenth + 1] = 0x2e;
			strDest[real_lenth + 2] = 0x00;
			strDest[real_lenth + 3] = 0x00;
		}
		else
		{
			while((*ss) && (dspl_lenth < Length))
			{
				dspl_lenth += get_CharWidth(*ss);
				ss += 1;
				real_lenth += 1;
			}

			real_lenth -= 2;
			memcpy(strDest, strOrig, real_lenth);
			strDest[real_lenth] = '.';
			strDest[real_lenth + 1] = 0x00;
		}
	}
	else
	{
		wstrncpy(strDest, strOrig, wstrlen(strOrig));
	}

}

/*******************************************************************************
	$Function:		DisplayAlignedAndTruncate
	$Description:
	$Author:		Sunny
	$Date:			2004-05-09
	$History		sunsj
					2004-05-19
*******************************************************************************/
void DisplayAlignedAndTruncate(T_MMI_ALIGN x_alignment, USHORT y_lineNum, USHORT length, UBYTE attrib, char* strtext)
{
	char text[50];
	int nLen = 0;

	if(*(unsigned char*)strtext == 0x80) //chinese don't truncate
	{
		if(get_StringWidth((char *)strtext) < length)
		{
			displayAlignedText(x_alignment, y_lineNum, attrib, strtext);
		}
		else
		{
			dspl_TextOut_Center(y_lineNum, length, attrib, strtext);
		}		
		return;
	}

	if(get_StringWidth((char *)strtext) < length)
	{
		displayAlignedText(x_alignment, y_lineNum, attrib, strtext);
	}
	else
	{
		TruncateStringAddDot(text, strtext, length);
		dspl_TextOut_Center(y_lineNum, length, attrib, text);
	}	
}

/*******************************************************************************

⌨️ 快捷键说明

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