📄 mt_inifun.c
字号:
/*****************************************************************************
** File Name: *
** Author: *
** Date: 2007/05/28 *
** Copyright: 2007 MTONE, Inc. All Rights Reserved. *
** Description: *
******************************************************************************
** Important Edit History *
** --------------------------------------------------------------------------*
** DATE NAME DESCRIPTION *
** 2007/05/28 Create *
*****************************************************************************/
#ifdef MMI_MTUNE
#include "mt_inifun.h"
#include "mt_ini.h"
#include "mt_osapi.h"
#include "jpg_gif_decode.h"
//#include "mmidisplay_data.h"
#include "../mtdef.h"
////////////////////////////////////////////////////////////////
extern const char *g_mtini_mmi[];
extern const char *g_mtini_cfg[];
const char *MTINI_GetProfileStr( uint32 id )
{
SCI_ASSERT( id >= MTINI_BASE && id <= MTINI_MAX );
if( id >= MTINI_MMI_BASE && id <= MTINI_MMI_MAX )
{
return g_mtini_mmi[id-MTINI_MMI_BASE];
}
else if( id >= MTINI_CFG_BASE && id <= MTINI_CFG_MAX )
{
return g_mtini_cfg[id-MTINI_CFG_BASE];
}
else
{
return "";
}
}
int MTINI_GetProfileInt( uint32 id )
{
SCI_ASSERT( id >= MTINI_BASE && id <= MTINI_MAX );
if( id >= MTINI_MMI_BASE && id <= MTINI_MMI_MAX )
{
return atoi( g_mtini_mmi[id-MTINI_MMI_BASE] );
}
else if( id >= MTINI_CFG_BASE && id <= MTINI_CFG_MAX )
{
return atoi( g_mtini_cfg[id-MTINI_CFG_BASE] );
}
else
{
return 0;
}
}
////////////////////////////////////////////////////////////////
BOOLEAN MTINI_GetProfilePoint( uint32 id, GUI_POINT_T *point_ptr )
{
const char *p;
if( id < MTINI_BASE || id > MTINI_MAX || !point_ptr ) return FALSE;
MT_MEMSET( point_ptr, 0, sizeof(GUI_RECT_T) );
p = MTINI_GetProfileStr( id );
// #ifdef _WIN32
// sscanf( p, "%u,%u", &point_ptr->x, &point_ptr->y );
// #else
point_ptr->x = (int16)atoi( p ); for( ; *p!=',' && *p; p++ ); if( *p == ',' ) p++;
point_ptr->y = (int16)atoi( p );
// #endif
return TRUE;
}
BOOLEAN MTINI_GetProfileRect( uint32 id, GUI_RECT_T *rect_ptr )
{
const char *p;
if( id < MTINI_BASE || id > MTINI_MAX || !rect_ptr ) return FALSE;
MT_MEMSET( rect_ptr, 0, sizeof(GUI_RECT_T) );
p = MTINI_GetProfileStr( id );
MT_TRACE("MTINI_GetProfileRect p = %s", p);
// #ifdef _WIN32
// sscanf( p, "%u,%u,%u,%u", &rect_ptr->left, &rect_ptr->top, &rect_ptr->right, &rect_ptr->bottom );
// #else
rect_ptr->left = (int16)atoi( p ); for( ; *p!=',' && *p; p++ ); if( *p == ',' ) p++;
rect_ptr->top = (int16)atoi( p ); for( ; *p!=',' && *p; p++ ); if( *p == ',' ) p++;
rect_ptr->right = (int16)atoi( p ); for( ; *p!=',' && *p; p++ ); if( *p == ',' ) p++;
rect_ptr->bottom = (int16)atoi( p );
// #endif
return TRUE;
}
BOOLEAN MTINI_GetProfileColor( uint32 id, GUI_COLOR_T *color )
{
uint8 r, g, b; const char *p;
if( id < MTINI_BASE || id > MTINI_MAX || !color ) return FALSE;
r = g = b = 0; p = MTINI_GetProfileStr( id );
// #ifdef _WIN32
// sscanf( p, "%u,%u,%u", &r, &g, &b );
// #else
r = (uint8)atoi( p ); for( ; *p!=',' && *p; p++ ); if( *p == ',' ) p++;
g = (uint8)atoi( p ); for( ; *p!=',' && *p; p++ ); if( *p == ',' ) p++;
b = (uint8)atoi( p );
// #endif
*color = (GUI_COLOR_T)RGB565( r, g, b );
return TRUE;
}
// "large", "middle", "small", "normal", "default"
BOOLEAN MTINI_GetProfileFont( uint32 id, GUI_FONT_T *font )
{
#if 0
const char *p; int i;
static const struct
{
const char *str; GUI_FONT_T (*fun)( void );
}
sf[] =
{
{ "large", MMI_GetLargeFontId },
{ "middle", MMI_GetMiddleFontId },
{ "small", MMI_GetSmallFontId },
{ "normal", MMI_GetNormalFontId },
{ "default", MMI_GetNormalFontId }
};
if( id < MTINI_BASE || id > MTINI_MAX || !font ) return FALSE;
p = MTINI_GetProfileStr( id );
*font = MMI_GetNormalFontId();
for( i=0; i<sizeof(sf)/sizeof(sf[0]); i++ )
{
if( !strcmp( p, sf[i].str ) )
{
*font = (*sf[i].fun)(); break;
}
}
#endif
*font = MMI_DEFAULT_TEXT_FONT;
return TRUE;
}
void MTINI_Test( void )
{
#if 1
const char *p; int n; GUI_POINT_T point; GUI_RECT_T rect; GUI_COLOR_T color; GUI_FONT_T font; BOOLEAN r = FALSE;
p = MTINI_GetProfileStr( INI_MT_STR );
n = MTINI_GetProfileInt( INI_MT_INT );
r = MTINI_GetProfilePoint( INI_MT_RECT, &point );
r = MTINI_GetProfileRect( INI_MT_RECT, &rect );
r = MTINI_GetProfileColor( INI_MT_COLOR, &color );
// r = MTINI_GetProfileFont( INI_MT_FONT, &font );
#endif
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -