?? mmimt_ex.c
字號:
/*****************************************************************************
** File Name: *
** Author: *
** Date: 2007/06/30 *
** Copyright: 2007 MTONE, Inc. All Rights Reserved. *
** Description: *
******************************************************************************
** Important Edit History *
** --------------------------------------------------------------------------*
** DATE NAME DESCRIPTION *
** 2007/06/30 Create *
*****************************************************************************/
#ifdef MMI_MTUNE
#include "mmimt_ex.h"
#include "mt_osapi.h"
#include "mmimt_text.h"
#include "mmi_ctrl_register.h"
#include "mmi_text.h"
#include "mmi_theme.h"
#include "guilabel.h"
#include "guilistbox.h"
#include "mtdef.h"
#define MTVAR_REF
#include "../mt_var.h"
#include "../mt_var.def"
#include "mmiphone.h"
#include "mmimp3.h"
#include "mt_nv.h"
#include "mt_string.h"
////////////////////////////////////////////////////////////////
BOOLEAN MTMMISTR_IsEqual( const MMI_STRING_T *string1, const MMI_STRING_T *string2 )
{
if( !string1 && !string2 ) return TRUE;
if( !string1 || !string2 ) return FALSE;
if( string1->is_ucs2 != string2->is_ucs2 ) return FALSE;
if( string1->length != string2->length ) return FALSE;
if( string1->length )
{
if( string1->str_ptr && string2->str_ptr )
{
return (BOOLEAN)( 0 == MT_MEMCMP( string1->str_ptr, string2->str_ptr, string1->length ) );
}
else
{
return (BOOLEAN)( string1->str_ptr == string2->str_ptr );
}
}
return TRUE;
}
BOOLEAN MTMMK_SendMsgTP( uint32 win_id, BOOLEAN is_down, const GUI_RECT_T *rect_ptr )
{
GUI_POINT_T point;
SCI_ASSERT( rect_ptr->left >= 0 && rect_ptr->top >= 0 && rect_ptr->right >= 0 && rect_ptr->bottom >= 0 );
SCI_ASSERT( rect_ptr->right - rect_ptr->top && rect_ptr->bottom - rect_ptr->top );
point.x = (int16)( rect_ptr->left + ( rect_ptr->right - rect_ptr->left ) / 2 );
point.y = (int16)( rect_ptr->top + ( rect_ptr->bottom - rect_ptr->top ) / 2 );
return MMK_SendMsg( win_id, (MMI_MESSAGE_ID_E)( ( is_down ) ? ( MSG_TP_DOWN ) : ( MSG_TP_UP ) ), (DPARAM)&point );
}
void MTMMITHEME_GetClientRect( GUI_RECT_T *rect_ptr )
{
GUI_RECT_T rect ;
rect = MT_GetClientRect();
if( !rect_ptr ) return;
#if 0
rect_ptr->left = 0;
rect_ptr->right = MMITHEME_GetMainScreenRightPiexl();
rect = MMITHEME_GetTitleTextRect();
rect_ptr->top = (int16)( rect.bottom + 1 );
MMITHEME_GetWinSoftkeyRect( &rect );
rect_ptr->bottom = (int16)( MMITHEME_GetMainScreenBottomPiexl() - ( rect.bottom - rect.top + 1 ) );
#endif
rect_ptr->left =rect.left;
rect_ptr->right = rect.right;
rect_ptr->top = rect.top;
rect_ptr->bottom = rect.bottom;
}
const MMI_STRING_T *MTGUILABEL_GetText( uint32 ctrl_id )
{
GUI_LABEL_CTRL_T* label_ptr = (GUI_LABEL_CTRL_T *)MMK_GetCtrlPtrBaseCtrlId( ctrl_id )->adddata_ptr;
if( !label_ptr || label_ptr->ctrl_type != TYPE_LABEL ) return NULL;
return &label_ptr->text;
}
BOOLEAN MTGUILABEL_SetText( uint32 ctrl_id, MMI_STRING_T *text_ptr, BOOLEAN is_fresh )
{
static BOOLEAN f = FALSE;
BOOLEAN r = TRUE;
if( !f )
{
f = TRUE;
if( !MTMMISTR_IsEqual( MTGUILABEL_GetText( ctrl_id ), text_ptr ) )
{
r = GUILABEL_SetText( ctrl_id, text_ptr, is_fresh );
}
f = FALSE;
}
return r;
}
BOOLEAN MTGUILISTBOX_AppendListItem( uint32 ctrl_id, const uint8 *str_ptr, uint8 str_len, BOOLEAN is_ucs2,
uint32 left_softkey_id, uint32 left_icon_id )
{
GUI_LISTBOX_ITEM_T item = { 0 }; uint8 l;
SCI_ASSERT( str_ptr );
l = (uint8)MIN( LISTBOX_STRING_MAX_NUM, str_len );
MT_MEMCPY( item.str, str_ptr, l );
item.is_ucs2 = is_ucs2;
item.str_len = l;
item.softkey_id[0] = left_softkey_id;
item.softkey_id[1] = TXT_NULL;
item.softkey_id[2] = STXT_EXIT;
item.left_icon_id = left_icon_id;
return GUILISTBOX_AppendItem( ctrl_id, &item );
}
BOOLEAN MTGUILISTBOX_ReplaceListItem( uint32 ctrl_id, uint16 pos, const uint8 *str_ptr, uint8 str_len, BOOLEAN is_ucs2,
uint32 left_softkey_id, uint32 left_icon_id )
{
GUI_LISTBOX_ITEM_T item = { 0 }; uint8 l;
SCI_ASSERT( str_ptr );
l = (uint8)MIN( LISTBOX_STRING_MAX_NUM, str_len );
MT_MEMCPY( item.str, str_ptr, l );
item.is_ucs2 = is_ucs2;
item.str_len = l;
item.softkey_id[0] = left_softkey_id;
item.softkey_id[1] = TXT_NULL;
item.softkey_id[2] = STXT_EXIT;
item.left_icon_id = left_icon_id;
return GUILISTBOX_ReplaceItem( ctrl_id, &item, pos );
}
BOOLEAN MTGUILISTBOX_AppendListItemByTextId( uint32 ctrl_id, uint32 text_id,
uint32 left_softkey_id, uint32 left_icon_id )
{
MMI_STRING_T str; MMI_GetLabelTextByLang( text_id, &str );
return MTGUILISTBOX_AppendListItem( ctrl_id, str.str_ptr, (uint8)str.length, str.is_ucs2, left_softkey_id, left_icon_id );
}
/*
BOOLEAN MTGUILISTBOX_AppendListItemWithIndexIcon( uint32 ctrl_id, const uint8 *str_ptr, uint8 str_len, BOOLEAN is_ucs2,
uint32 left_softkey_id, uint8 index, BOOLEAN on )
{
SCI_ASSERT( str_ptr != NULL );
return MTGUILISTBOX_AppendListItem( ctrl_id, str_ptr, str_len, is_ucs2, left_softkey_id, ( ( on ) ? ( _V(IMAGE_COM_NUMBER_ON_01) ) : ( _V(IMAGE_COM_NUMBER_OFF_01) ) ) + index );
}
BOOLEAN MTGUILISTBOX_AppendListItemWithIndexIconByTextId( uint32 ctrl_id, uint32 text_id,
uint32 left_softkey_id, uint8 index, BOOLEAN on )
{
MMI_STRING_T str; MMI_GetLabelText( text_id, &str );
return MTGUILISTBOX_AppendListItemWithIndexIcon( ctrl_id, str.str_ptr, (uint8)str.length, str.is_ucs2, left_softkey_id, index, on );
}
BOOLEAN MTGUILISTBOX_ChangeIndexIconId( uint32 ctrl_id, uint8 index, BOOLEAN on )
{
return GUILISTBOX_ChangeIconId( ctrl_id, index, ( ( on ) ? ( _V(IMAGE_COM_NUMBER_ON_01) ) : ( _V(IMAGE_COM_NUMBER_OFF_01) ) ) + index, 0 );
}
*/
BOOLEAN MTGUILISTBOX_GetMoveItemIndex( uint32 ctrl_id, uint32 msg_id, uint16 *i, uint16 *j )
{
uint16 n, u, v;
if( !i && !j )
{
MT_TRACE( "\r\nMTGUILISTBOX_GetMoveItemIndex() exit: argument invalid\r\n" ); return FALSE;
}
if( i ) *i = 0; if( j ) *j = 0;
if( msg_id != MSG_CTL_LISTBOX_MOVEBOTTOM && msg_id != MSG_CTL_LISTBOX_MOVEDOWN && msg_id != MSG_CTL_LISTBOX_MOVETOP && msg_id != MSG_CTL_LISTBOX_MOVEUP )
{
MT_TRACE( "\r\nMTGUILISTBOX_GetMoveItemIndex() exit: argument invalid\r\n" ); return FALSE;
}
n = GUILISTBOX_GetTotalItemNum( ctrl_id );
if( !n )
{
MT_TRACE( "\r\nMTGUILISTBOX_GetMoveItemIndex() exit: GUILISTBOX_GetTotalItemNum() ret 0\r\n" ); return FALSE;
}
#ifdef GUILISTBOX_TOPWISE
if( MSG_CTL_LISTBOX_MOVEBOTTOM == msg_id || MSG_CTL_LISTBOX_MOVEDOWN == msg_id )
{
u = (uint16)( ( GUILISTBOX_GetCurItemIndex( ctrl_id ) + n - 1 ) % n );
}
else // MSG_CTL_LISTBOX_MOVETOP == msg_id || MSG_CTL_LISTBOX_MOVEUP == msg_id
{
u = (uint16)( ( GUILISTBOX_GetCurItemIndex( ctrl_id ) + 1 ) % n );
}
#else
u = GUILISTBOX_GetCurItemIndex( ctrl_id ) ;
#endif
if( MSG_CTL_LISTBOX_MOVEBOTTOM == msg_id || MSG_CTL_LISTBOX_MOVEDOWN == msg_id )
{
v = (uint16)( ( u - 1+ n ) % n );
}
else // MSG_CTL_LISTBOX_MOVETOP || MSG_CTL_LISTBOX_MOVEUP
{
v = (uint16)( ( u + 1 ) % n );
}
MT_TRACE( "\r\nMTGUILISTBOX_GetMoveItemIndex(): u=%u v=%u\r\n", u, v );
if( i ) *i = v; if( j ) *j = u;
return TRUE;
}
LOCAL uint16 CalculatePageLineNum(
uint16 rect_height,
uint16 font_height,
uint16 line_space
)
{
uint16 page_line_num = 0;
uint16 line_height = 0;
line_height = font_height + line_space;
if (0 != line_height)
{
page_line_num = rect_height/line_height;
if ((rect_height%line_height) >= font_height-2)
{
page_line_num++;
}
}
else
{
SCI_PASSERT(FALSE, ("CalculatePageLineNum: the line height is zero!"));
}
return (page_line_num);
}
LOCAL BOOLEAN CalculateEachRect(
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -