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

📄 mmimt_wap_wintab.c

📁 展讯平台的mtue源代码, 全面,精简,仅供学习, 商用后果自负
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
** File Name:                                                                *
** Author:                                                                   *
** Date:           2007/03                                                   *
** Copyright:      2007 MTONE, Inc. All Rights Reserved.                     *
** Description:                                                              *
******************************************************************************
**                         Important Edit History                            *
** --------------------------------------------------------------------------*
** DATE           NAME             DESCRIPTION                               *
** 2007/03                         Create                                    *
*****************************************************************************/
#ifdef MMI_MTUNE
#include "mmimt_wap_wintab.h"

#include "../base/mt_ini.h"
#include "../base/mt_osapi.h"
#include "../base/mmimt_ex.h"
#include "../base/mmimt_id.h"
#include "../base/mmimt_pubwin.h"
#include "../base/mmimt_text.h"

#include "guianim.h"
#include "guifont.h"
#include "guilabel.h"

//#include "mmk_ex.h"
#include "mmk_msg.h"
#include "mmk_timer.h"
#include "mmi_common.h"
#include "mmi_default.h"
#include "mmipub.h"
#include "mmi_theme.h"

#include "window_parse.h"

#define MTVAR_REF
#include "../mt_var.h"
#include "../mt_var.def"

#include "mmi_appmsg.h"
#include "mmiwap.h"
#include "mtdef.h"
////////////////////////////////////////////////////////////////

extern HMMIMTWAP g_hwapmmi;

static BOOL g_fquery = FALSE;

LOCAL MMI_RESULT_E MMIMTWAP_HandlePromptQueryWinMsg( MMI_WIN_ID_T win_id, MMI_MESSAGE_ID_E msg_id, DPARAM param )
{
	switch( msg_id )
	{
	case MSG_OPEN_WINDOW:
		g_fquery = TRUE;
		break;

	case MSG_CLOSE_WINDOW:
		g_fquery = FALSE;
		break;

	case MSG_APP_OK:
		break;

	case MSG_APP_CANCEL:
		break;
		
	default:
		break;
	}

	return MMIPUB_HandleQueryWinMsg( win_id, msg_id, param );
}

////////////////////////////////////////////////////////////////

LOCAL MMI_RESULT_E HandleConnWinMsg( MMI_WIN_ID_T win_id, MMI_MESSAGE_ID_E msg_id, DPARAM param );

WINDOW_TABLE(MMIMTWAP_CONNECT_WIN_TAB) =
{
	CLEAR_LCD,
	WIN_PRIO(WIN_ONE_LEVEL),
	WIN_FUNC((uint32)HandleConnWinMsg),
	WIN_ID(MMIMTWAP_CONNECT_WIN_ID),
	END_WIN
};

extern WINDOW_TABLE(MMIMTWAP_CONNECT_WIN_TAB);

void MMIMTWAP_OpenConnWin1111111( void )
{
	MT_TRACE( "\r\nMMIMTWAP_OpenConnWin() ...\r\n" );

	if( !MMK_IsOpenWin( MMIMTWAP_CONNECT_WIN_ID ) )
	{
		MMK_CreateWin( (uint32 *)MMIMTWAP_CONNECT_WIN_TAB, NULL );
	}
}

BOOLEAN MMIMTWAP_IsConnWinFocused( void )
{
	MT_TRACE( "\r\nMMIMTWAP_IsConnWinFocused() ...\r\n" );

	return (BOOLEAN)( MMK_IsOpenWin( MMIMTWAP_CONNECT_WIN_ID ) && MMK_IsFocusWin( MMIMTWAP_CONNECT_WIN_ID ) );
}

LOCAL MMI_RESULT_E HandleConnWinMsg( MMI_WIN_ID_T win_id, MMI_MESSAGE_ID_E msg_id, DPARAM param )
{
	MMI_RESULT_E ret = MMI_RESULT_TRUE;

	GUI_RECT_T rect; static uint8 wap_qury_prg_timer_id = 0;

	MT_TRACE( "\r\nHandleConnWinMsg() ...\r\n" );

	switch( msg_id )
	{
	case MSG_OPEN_WINDOW:

		MMI_IsEnableDeepSleep( FALSE ); MMIDEFAULT_SetDeepSleep( FALSE ); // casually
#if 0 //MK
		MMITHEME_GetWinSoftkeyRect( &rect );

		MMK_CreateDynaCtrl( MMIMTWAP_WAIT_ANIM_CTRL_ID, TYPE_ANIM, win_id, GUIANIMATE_Init( rect, ANIM_ANIM, 500, 0 ) );

		GUIANIMATE_SetAnimDataExt( MMIMTWAP_WAIT_ANIM_CTRL_ID, 0, rect.top, &rect, MMI_GetLabelAnim( _V(IMAGE_MTWAP_DOWNLOAD_BAR_ANIM) ), ANIM_ANIM, 0, 500, FALSE, TRUE );

		GUIANIMATE_SetAnimData( MMIMTWAP_WAIT_ANIM_CTRL_ID, 0, rect.top, MMI_GetLabelAnim( _V(IMAGE_MTWAP_DOWNLOAD_BAR_ANIM) ), ANIM_ANIM, 0, 500, TRUE );
#endif
		wap_qury_prg_timer_id = MMK_CreateWinTimer( win_id, 500, FALSE );

		break;

	case MSG_CLOSE_WINDOW:

		MMIMTWAP_Cancel( g_hwapmmi, 1 );

		if( wap_qury_prg_timer_id ) { MMK_StopTimer( wap_qury_prg_timer_id ); wap_qury_prg_timer_id = 0; }
#if 0
		MMK_DestroyDynaCtrl( MMIMTWAP_WAIT_ANIM_CTRL_ID );
#endif
		MMIDEFAULT_SetBackLight( TRUE ); MMI_IsEnableDeepSleep( TRUE ); MMIDEFAULT_SetDeepSleep( TRUE ); // casually

		break;

	case MSG_APP_RED:

		MMIMTWAP_Cancel( g_hwapmmi, 5 );

		ret = MMI_RESULT_FALSE;

		break;

	case MSG_TIMER:

		if( wap_qury_prg_timer_id == *(uint8 *)param )
		{
			wap_qury_prg_timer_id = MMK_CreateWinTimer( win_id, 500, FALSE );

			if( g_hwapmmi )
			{
				uint32 ncont_len, ncurr_len, ncont_range_beg, ncont_range_end, ncont_range_total;

				MMIMTWAP_QueryProgress( g_hwapmmi, &ncurr_len, &ncont_len, &ncont_range_beg, &ncont_range_end, &ncont_range_total );

				MT_TRACE( "\r\nMMIMTWAP_QueryProgress() - current_length=%u content_length=%u content_range_begin=%u content_range_end=%u content_range_total=%u\r\n", ncurr_len, ncont_len, ncont_range_beg, ncont_range_end, ncont_range_total );
			}
			else
			{
				if( g_fquery ) MMIPUB_CloseQuerytWin(PNULL);

				MMK_CloseWin( win_id );
			}
		}

		break;

	case MSG_KEYDOWN_CANCEL:

		MTPUBWIN_OpenPromptQueryWinExt2( TXT_MT_WAP_QUERY_EXIT, MMIMTWAP_HandlePromptQueryWinMsg );

		break;

	case MSG_PROMPTWIN_OK:

		MMIMTWAP_Cancel( g_hwapmmi, 3 );

		MMIPUB_CloseQuerytWin(PNULL);

		MMK_CloseWin( win_id );

		break;

	case MSG_PROMPTWIN_CANCEL:

		MMIPUB_CloseQuerytWin(PNULL);

		break;

	case MSG_GET_FOCUS:
	case MSG_FULL_PAINT:

//		MMK_SendMsg( MMK_GetPrevWinId( win_id ), MSG_FULL_PAINT, NULL );
#if 0
		MMK_SendMsg( MMK_GetPrevWinId( win_id ), MSG_FULL_PAINT, (DPARAM)(uint32)-1 );

		MMITHEME_SetUpdateDelayCount( 2 );
#endif
		break;

	default:

		ret = MMI_RESULT_FALSE;

		break;

	}

	return ret;
}

////////////////////////////////////////////////////////////////

LOCAL MMI_RESULT_E HandleDownWinMsg( MMIMT_WINDOW_ID_E win_id, MMI_MESSAGE_ID_E msg_id, DPARAM param );

WINDOW_TABLE(MMIMTWAP_DOWNLOAD_WIN_TAB) =
{
	CLEAR_LCD,
	WIN_PRIO(WIN_ONE_LEVEL),
	WIN_FUNC((uint32)HandleDownWinMsg),
	WIN_ID(MMIMTWAP_DOWNLOAD_WIN_ID),
	WIN_TITLE_ID(TXT_MT_TITLE_DOWN),
	END_WIN
};

extern WINDOW_TABLE(MMIMTWAP_DOWNLOAD_WIN_TAB);

void MMIMTWAP_OpenDownWin( void )
{
	MT_TRACE( "\r\nMMIMTWAP_OpenDownWin() ...\r\n" );

	if( !MMK_IsOpenWin( MMIMTWAP_DOWNLOAD_WIN_ID ) )
	{
		MMK_CreateWin( (uint32 *)MMIMTWAP_DOWNLOAD_WIN_TAB, NULL );
	}
}

void MMIMTWAP_RefreshDownWin( void )
{
	MT_TRACE( "\r\nMMIMTWAP_RefreshDownWin() ...\r\n" );

	MMK_SendMsg( MMIMTWAP_DOWNLOAD_WIN_ID, MSG_FULL_PAINT, NULL );
}

#define MMI_BLACK_COLOR		0x0000
//#define MMI_PURPLE_COLOR	0x81fb
#ifdef _WIN32
extern uint16 GUI_GB2UCS( uint16 *, const uint8 *, uint32 );
#endif
LOCAL void MMIMTWAP_DisplayStat( void )
{
	MMI_CONTROL_ID_E ctrl_id = MMIMTWAP_STAT_LABEL_CTRL_ID;

	uint32 ncont_len, ncurr_len, ncont_range_beg, ncont_range_end, ncont_range_total;

	uint32 cbcurr, cbtotal; MMI_STRING_T str; char szstat[128]= {0}; 


	
	if( !MMK_IsFocusWin( MMIMTWAP_DOWNLOAD_WIN_ID ) ) return;

	if( !g_hwapmmi ) return;

	MMIMTWAP_QueryProgress( g_hwapmmi, &ncurr_len, &ncont_len, &ncont_range_beg, &ncont_range_end, &ncont_range_total );

	if( !ncont_len )
	{
		static uint8 n = 0; uint8 i;

		MMIMT_GetLabelTextByLangGB( TXT_MT_WAP_STAT_CONN, &str );

		strcpy( szstat, (char *)str.str_ptr ); for( i=0; i<n%10; i++ ) strcat( szstat, "." ); n++;
	}
	else
	{
		if( ncont_range_total )
		{
			cbcurr = ncont_range_beg + ncurr_len; cbtotal = ncont_range_total;
		}
		else
		{
			cbcurr = ncurr_len; cbtotal = ncont_len;
		}

//		MMIMT_GetLabelTextByLangGB( TXT_MT_WAP_STAT_DOWN, &str );
		
		sprintf( szstat, "%uK/%uK", cbcurr/1024, cbtotal/1024 );

		
	}

	str.str_ptr = (uint8 *)szstat; str.is_ucs2 = FALSE; str.length = (uint16)strlen( szstat );

	GUILABEL_SetFontParam( ctrl_id, MMI_DEFAULT_TEXT_FONT, MMI_BLACK_COLOR, 0 );
	GUILABEL_SetBackgroundColor( ctrl_id, /* color */ MMI_WINDOW_BACKGROUND_COLOR );
	GUILABEL_SetText( ctrl_id, &str, TRUE );

//	MTGUILABEL_SetText( ctrl_id, &str, TRUE );
}

LOCAL void MMIMTWAP_DisplayProg( void )
{
	uint32 ncont_len, ncurr_len, ncont_range_beg, ncont_range_end, ncont_range_total;

        	uint32 cbcurr, cbtotal;
	GUI_RECT_T rect, rect_f; GUI_POINT_T point; GUI_FONT_T font = MMI_DEFAULT_TEXT_FONT;
	 GUI_LCD_DEV_INFO	lcd_dev_info = {GUI_LCD_0, GUI_BLOCK_0};

	uint8 fh, fw; char sztip[8]; uint8 l;

	if( !MMK_IsFocusWin( MMIMTWAP_DOWNLOAD_WIN_ID ) ) return;

	if( !g_hwapmmi ) return;

	MMIMTWAP_QueryProgress( g_hwapmmi, &ncurr_len, &ncont_len, &ncont_range_beg, &ncont_range_end, &ncont_range_total );

	if( !ncont_len ) return;

	if( ncont_range_total )
	{
		cbcurr = ncont_range_beg + ncurr_len; cbtotal = ncont_range_total;
	}
	else
	{
		cbcurr = ncurr_len; cbtotal = ncont_len;
	}

	if( !cbtotal ) return;

	MTINI_GetProfileRect( INI_MT_RECT_WAP_DOWN_PROGRESS, &rect );

	rect_f = rect;
	rect_f.right = (int16)( rect.left + ( rect.right - rect.left ) * cbcurr / cbtotal );
	rect_f.right = (int16)MAX( rect_f.right, rect.left );
	rect_f.right = (int16)MIN( rect_f.right, rect.right );

	LCD_FillRect( &lcd_dev_info, rect, MMI_WINDOW_BACKGROUND_COLOR );
	LCD_DrawRect( &lcd_dev_info, rect, MMI_PURPLE_COLOR );
	LCD_FillRect( &lcd_dev_info, rect_f, MMI_PURPLE_COLOR );

	fh = GUI_GetFontHeight( font, FALSE ); fw = GUI_GetFontWidth( font, FALSE );

	sprintf( sztip, "%u%%", (uint8)MIN( 100, cbcurr*100/cbtotal ) ); l = (uint8)strlen( sztip );

	point.x = (int16)( rect.left + ( ( rect.right - rect.left ) - l * fw ) / 2 );
	point.y = (int16)( rect.top + ( ( rect.bottom - rect.top ) - fh ) / 2 );

	point.x = (int16)MAX( point.x, rect.left ); point.x = (int16)MIN( point.x, rect.right );
	point.y = (int16)MAX( point.y, rect.top );  point.y = (int16)MIN( point.y, rect.bottom );

⌨️ 快捷键说明

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