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

📄 mmiresources.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*******************************************************************************

					CONDAT (UK)

********************************************************************************                                                                              

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.                                 
                                                                              
********************************************************************************

 $Project name:	Basic MMI                                                      
 $Project code:	BMI (6349)                                                           
 $Module:		Resource Manager
 $File:		    MmiResources.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		Condat(UK)                                                         
 $Date:		    25/10/00                                                      
                                                                               
********************************************************************************
                                                                              
 Description:

   Simple wrapper for the MMI Block Resources

   This module provides a simple interface to the block
   resources module, giving access to a single language,
   which can be used to get strings by Id.

   This module is a hack to provide an interface to the
   resource manager which can be easily used by a single
   process. If an application needs to use the resource
   manager it should call it directly, initialising it's
   own context safe handlers.

   This module is designed to wrap the resource API
   functions in a manner that gives the easiest and
   fastest implementation. It is therefore not a
   reentrant module, however given it only performs
   read only actions this should not be a problem.
                        
********************************************************************************
 $History: MmiResources.c

	25/10/00			Original Condat(UK) BMI version.	
	03/10/02		Replaced most of the file with version on branch for issue 1150 (MC, SPR 1242) 
 $End

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


/*******************************************************************************
                                                                              
                                Include Files                                 
                                                                              
*******************************************************************************/
#define ENTITY_MFW

/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"

#else

#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#endif

#include "mfw_sys.h"

#include "p_sim.h"


#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_lng.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_tim.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_cm.h"
#include "mfw_sat.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_ffs.h" /*MC, SPR 1111*/
//Include the following  ensure that the function definitions within it match the
//definitions in this file.
#include "mfw_mmi.h"
#include "dspl.h"

#include "ksd.h"
#include "psa.h"

/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#endif

#include "MmiResources.h"
#include "MmiBlkLangDB.h"
#include "MmiBlkManager.h"
#include "MmiBlkResources.h"
#include "MmiBookShared.h"

#include "MmiDummy.h"
#include "MmiMmi.h"
#include "MmiMain.h"
#include "MmiStart.h"
#include "MmiPins.h"


#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiDialogs.h"
#include "MmiIcons.h"	//GW
#include "mfw_ffs.h"
// this is for traces
#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"


#include "mmilists.h"
#include "mmiColours.h"

//#define COLOURDISPLAY
//#define TRACE_EVENT_COL TRACE_EVENT

#ifndef TRACE_EVENT_COL
#define TRACE_EVENT_COL
#endif

#ifndef LSCREEN
#define FIRST_LINE 6
#define SECOND_LINE 14
#define THIRD_LINE 24
#define FOURTH_LINE 32
#define FIFTH_LINE 40
#define SIXTH_LINE 48
#define LINE_HEIGHT 8
#define FIRST_LINE_CHINESE 12
#define SECOND_LINE_CHINESE 24
#define THIRD_LINE_CHINESE 36
#define FOURTH_LINE_CHINESE 48
#define LINE_HEIGHT_CHINESE 12

#define FIRST_LINE_ICON 6
#define SECOND_LINE_ICON 14
#define THIRD_LINE_ICON 20


#else
//#define LINE_HEIGHT 12
//Colour display - all lines are the same height
//move to header for the moment #define LINE_HEIGHT 12
#endif
//x33x-end*/

#ifndef LSCREEN
#define SK_HEIGHT_LATIN				(LINE_HEIGHT_LATIN)
#define SK_HEIGHT_CHINESE			(LINE_HEIGHT_CHINESE)
#define TITLE_HEIGHT_LATIN			(LINE_HEIGHT_LATIN)
#define TITLE_HEIGHT_CHINESE		(LINE_HEIGHT_CHINESE)

#define NLINES_LATIN				(SCREEN_SIZE_Y/LINE_HEIGHT_LATIN)	//6
#define NLINES_CHINESE				(SCREEN_SIZE_Y/LINE_HEIGHT_CHINESE)	//4
#define CHINESE_MENU_VERTICAL_SIZE 		((NLINES_CHINESE-1)*LINE_HEIGHT_CHINESE)
#define STANDARD_MENU_VERTICAL_SIZE ((NLINES_LATIN-1)*LINE_HEIGHT_LATIN)

#define ICON_HEIGHT					(6)
#else
#define SK_HEIGHT_LATIN				(LINE_HEIGHT+8)
#define SK_HEIGHT_CHINESE			(LINE_HEIGHT+8)
#define TITLE_HEIGHT_LATIN			(LINE_HEIGHT_LATIN+4)
#define TITLE_HEIGHT_CHINESE		(LINE_HEIGHT_CHINESE+4)
#define ALLOFFSET					(LINE_HEIGHT*2)
#define MNUOFFSET					(LINE_HEIGHT)

#define NLINES_LATIN				(SCREEN_SIZE_Y/LINE_HEIGHT_LATIN)	
#define NLINES_CHINESE				(SCREEN_SIZE_Y/LINE_HEIGHT_CHINESE)	
#define CHINESE_MENU_VERTICAL_SIZE 		((NLINES_CHINESE*LINE_HEIGHT_CHINESE)-SK_HEIGHT_CHINESE)
#define STANDARD_MENU_VERTICAL_SIZE ((NLINES_LATIN*LINE_HEIGHT_LATIN)-SK_HEIGHT_LATIN)

#define ICON_HEIGHT					(22)
#endif


/*******************************************************************************
                                                                              
                                Static data elements
                                                                              
*******************************************************************************/

/* Define static data elements to give the global
   handles. These are not re-entrant, but what the
   hell, there will only be one of these in the
   system
*/
static tBlkHandle BlkManager = NULL;
UBYTE currentLanguage		= NULL;
static tBlkHandle Language   = NULL;
static long int   ModuleKey  = -1;


/* Define a unique key value to determine if the constructor
   has been called. This is slightly dangerous as there is 
   a chance that the key value powers up in this state, however
   this is unlikely in a cold boot situation. (In a warm boot,
   if the RAM contents are preserved then the block resource
   manager will also be preserved, so there should be no
   problem there).
*/
#define KEYVALUE 0x00FADE00


/* We know that the resource manager deals with two languages
   at present, English and German, The first element in the
   lists will indicate which is which in a later version, however
   for now, we will just define constant settings for these.

   Note that the current MMI doesn't fully support German
   characters, but the resource manager does.
*/

#define SHOW_CONFIRM     3
int Easy_Text_Available = TRUE;

 char* SIMToolKitString=NULL;


/*SPR 1111, country code and langauge tables*/
/*MC, if English and Chinese Available*/
#ifdef CHINESE_MMI
static CountryLangEntry LanguageTableEntries[7]=
{ 
	{"001", ENGLISH_LANGUAGE}, /*USA*/
	{"044", ENGLISH_LANGUAGE},	/*UK*/
	{"061", ENGLISH_LANGUAGE},	/*Australia*/
	{"353", ENGLISH_LANGUAGE},	/*Ireland*/
	{"064", ENGLISH_LANGUAGE},	/*New Zealand*/
	{"086", CHINESE_LANGUAGE}, /*PRChina*/
	{"065", CHINESE_LANGUAGE} /*Singapore*/
};

static CountryLanguageTable LanguageTable =
{ 7, LanguageTableEntries};
#else	/*MC, if English and German Available*/
static CountryLangEntry LanguageTableEntries[7]=
{ 
	{"001", ENGLISH_LANGUAGE}, /*USA*/
	{"044", ENGLISH_LANGUAGE},	/*UK*/
	{"061", ENGLISH_LANGUAGE},	/*Australia*/
	{"353", ENGLISH_LANGUAGE},	/*Ireland*/
	{"064", ENGLISH_LANGUAGE},	/*New Zealand*/
	{"043", GERMAN_LANGUAGE}, /*Austria*/
	{"049", GERMAN_LANGUAGE} /*Germany*/
};

static CountryLanguageTable LanguageTable =
{ 7, LanguageTableEntries};


#endif

typedef struct 
{
	// cp_resource_file_t rf;
	RESOURCE_DIRECTORY_HEADER language_table;
	RESOURCE_DIRECTORY_HEADER melody_table;
	RESOURCE_DIRECTORY_HEADER glyph_table;
	RESOURCE_DIRECTORY_HEADER zone_table;

	UBYTE langid;		// current language_table
	UBYTE fontid;		// current font
	ST_DIMENSION    fontHeight;	// current font height

}  res_ResMgr_type;

// private resources data 
static res_ResMgr_type this_res ;

typedef struct
{
  T_MMI_CONTROL    mmi_control;
  T_MFW_HND        resources_win;        /* MFW win handler      */
} T_resources;

T_resources resources_data;

enum {
	COL_TYPE_SCREEN=0,
	COL_TYPE_SK,
	COL_TYPE_HL,
	COL_TYPE_TITLE,
	COL_TYPE_MAX
};

typedef struct {
	U32 fgd;
	U32 bgd;
} T_COLDATA;

const char * colourFileDir = "/mmi";
const char * colourFileName = "MmiColour";

static T_COLDATA colArray[LAST_COLOUR_DEF][COL_TYPE_MAX];

#define FGD_COL 1
#define BGD_COL 2
#define NO_COL 3

#ifndef LSCREEN
#define NLINES 4
#define NLINES_MAX 5
#else
#define NLINES ((SCREEN_SIZE_Y-SK_HEIGHT_LATIN)/LINE_HEIGHT)
#define NLINES_MAX ((SCREEN_SIZE_Y-SK_HEIGHT_LATIN)/LINE_HEIGHT)
#endif

/*Data should be reset */
MfwRect menuArea 							= {0,0,10,10};
MfwRect menuNamesArea	 					= {0,0,10,10};
MfwRect menuListArea 						= {0,0,10,10};
MfwRect editor_menuArea						= {0,0,10,10};		/* menus display area      */
MfwRect network_menuArea 					= {0,0,10,10};			/* menus display area      */
MfwRect sat_setup_menuArea					= {0,0,10,10};			/* menus display area      */
MfwRect sat_select_menuArea 				= {0,0,10,10};			/* menus display area      */
MfwRect smscb_M_CBArea 						= {0,0,10,10}; /* menus display area      */
MfwRect smscb_M_CB_ACTArea					= {0,0,10,10}; /* menus display area      */
MfwRect smscb_M_CB_TOPArea 					= {0,0,10,10};/* menus display area      */
MfwRect smscb_M_CB_TOP_CONSArea				= {0,0,10,10}; /* menus display area      */
MfwRect smscb_M_CB_TOP_CONS_SELArea			= {0,0,10,10}; /* menus display area      */
MfwRect smscb_CBArea						= {0,0,10,10}; /* menus display area      */
MfwRect smscb_CB_OPTArea					= {0,0,10,10}; /* menus display area      */
MfwRect readSMS_menuArea					= {0,0,10,10}; /* menus display area      */
MfwRect SmsRead_R_OPTArea					= {0,0,10,10};/* menus display area      */
MfwRect SmsSend_R_OPTArea					= {0,0,10,10}; /* menus display area      */
MfwRect melody_menuArea 					= {0,0,10,10}; /* menus display area      */
MfwRect MAINICONarea						= {0,0,10,10};
MfwRect MAINICONareaColour 					= {0,0,10,10};	//For the larger colour main icons

static int resources_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void resources_language_confirm(void);
void resources_dialog_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason);
void resources (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
T_MFW_HND resources_Init (T_MFW_HND parent_window);
void resources_Exit (T_MFW_HND own_window);
T_MFW_HND resources_create (T_MFW_HND parent_window);
void initDefaultDataColour (void);



/*******************************************************************************
                                                                              
                                Private Routines
                                                                              
*******************************************************************************/

static void LanguageEnable( int newLanguage )
{
    /* Initialise if required
    */
	currentLanguage = newLanguage;
	if ( ModuleKey != KEYVALUE )
	{
		/* Nope, then go do it, If the mmibm_* routines fail to initialise
		   they will return NULL, and they both deal with bad input values
		   cleanly, so we don't need error checking here.
		*/
        BlkManager = mmibm_Initialise( Mmir_BaseAddress(), Mmir_NumberOfEntries() );
		ModuleKey  = KEYVALUE;
	}

    /* Set up the new language based on the incoming value
    */
    /*MC, SPR 1150, simplified for easier addition of new languages*/
    if (newLanguage> 0 && newLanguage <= NO_OF_LANGUAGES)
    	Language   = mmibm_SupplyResourceHandler( BlkManager, newLanguage );
}


/*******************************************************************************
                                                                              
                                Public Routines
                                                                              
*******************************************************************************/

/*******************************************************************************
 $Function:    	MmiRsrcGetText

 $Description:	Define access routine for the actual get text
                routine. In order to make sure the routine can
				be invoked and will automatically start, we will
				use the key value above to ensure we detect the
				startup conditions.
				
				The calling routine for this function should check
				for NULL values which will be returned if the 

 $Returns:		Pointer to resource indicated by Id (Or NULL)

 $Arguments:	Id of requested resource
 
*******************************************************************************/

char *MmiRsrcGetText( int Id )
{
	/* Check if we have already initialised
	*/
	if ( ModuleKey != KEYVALUE )
        LanguageEnable( ENGLISH_LANGUAGE );

    /* JVJ #1576 SAT is an exception, since the Menu string is variable depending on the SIM*/
    /* but the Languages table is constant. Therefore we need this workaround for the Mainmenu*/
    /* to display the SAT header */
    if ((Id == TxtSimToolkit)&&(SIMToolKitString))
        return (char*)SIMToolKitString;

    /* use the currently set up resource handler for the English
	   language to get the text associaed with the Id, again if
	   there has been a problem with the initialisation of the
	   English handler, then the fetch routine will deal with it
	   cleanly and return NULL.
	*/
	return (char *) mmibr_Fetch( Language, Id );
}

/*MC, SPR 1150 new function, don't need to write a new function for each new langauge now*/
void MmiRsrcSetLang( int lang )
{	if (lang == CHINESE_LANGUAGE)
		dspl_set_char_type(DSPL_TYPE_UNICODE);
	else
		dspl_set_char_type(DSPL_TYPE_ASCII);
    LanguageEnable( lang );
	Mmi_layout_areas();
	FFS_flashData.language = lang;
	flash_write();


}
/*MC SPR 1150, Simplified menu interface functions.  
It should be simpler to add new functions for new languages
We still need to write individual functions for each language to interface with the menus as
the menu architecture does not allow passing parmeters*/

void Mmi_Set2English( void )
{
  Mmi_Set2Language(ENGLISH_LANGUAGE); 
}

void Mmi_Set2German( void )
{	
   Mmi_Set2Language(GERMAN_LANGUAGE); 
}

void Mmi_Set2Chinese( void )

⌨️ 快捷键说明

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