aw_resource.h

来自「AMLOGIC DPF source code」· C头文件 代码 · 共 122 行

H
122
字号
/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : aw_resource.h /Project:AVOS  				** 
**        Revision : 1.0                                       	**
**                                                             	**
*****************************************************************/
#ifndef _AW_RESOURCE_H
#define _AW_RESOURCE_H

/**
 * @file aw_resource.h
 * @author LiChao, chao_li@amlogic.com.cn
 * In order to save memory space and support multi-language, we adopt the resource file, 
 * what kind of data can store in resource file? Currently we support all read only text 
 * string or byte data. We introduce the resource file structural first, one resource 
 * file have 3 part, first part is resource file head, it indicate the size of this 
 * resource file, total resource item number of this resource file; Second part is the 
 * resource item index; Last part is the resource item data.

 * Following is the Resource file struct
 * INT32U			resource_file_size ;
 * INT32U			resource_item_num ;
 * RESOURCEITEM 	resource_item_data[resource_item_num];
 * void *			resource_data ;
 *
 * Every resource file have its resource file ID and every resource item have its item ID 
 * (index in this resource file), file ID + item ID is the resource ID, every resource 
 * identify a unique resource data. When we get a resource ID, we can call AWGetResource to 
 * get the resource data and data length. We supply a tool to convert normal data into a 
 * resource file, after converts, we can get 3 files, one is the resource ID define file, we 
 * can include this file in our program and use it as normal data; another one is resource 
 * file, it can store on disc, when the program call AWGetResource to get resource data, if 
 * this resource file already loaded in memory, AWGetResource return the data directly, if 
 * this resource file not in the memory, AWGetResource will call AWUnloadResource load this 
 * resource file to memory, and then return the data. You can keep any resource file in memory 
 * always, that's the last file, it's a memory file, and it is a resource file data array 
 * actually. When you get these resource files, you can call AWResourceRegister to register 
 * this resource file, and then you can call AWGetResource to use these resource data, if 
 * you don't need it any more, call AWUnresourceRegister to cancel it. 
 *
 * For the multi-language feature, we can generate the resource file for every kind of language, 
 * but all these languages will share same resource file ID and resource item ID, when we change 
 * a language to another language, what we need to do is unregister the old language resource 
 * file and register new language resource file, and repaint the window, it's ok. When we 
 * program the graphic user interface, we use the resource ID instead of text string point. 
 * You can get detail information at 3.3 AW GUI detail spec to see how to use a resource file 
 * and resource ID. Following is the basic function of resource management.
 */
 
/** @defgroup gui_resource GUI graphic/font/language resource manage routines.
 * @ingroup gui
 */  

#define MAX_RESOURCE_FILE_NAME			0x40

/**
 * The struct used to save all resouce information
 */
typedef struct {
	///unique ID of resource file
	INT16U	resource_file_id ;		
	///to indicate this file is in mem or not, 0 -- not in mem, 
	///otherwise is the used times of this resource file
	INT16U   resource_file_used;	
	///file name and dir path
	CHARSTR	resource_file_name[MAX_RESOURCE_FILE_NAME] ;
	///if this file in mem, this is the start addr of file data  
	CHARSTR * resource_file_addr ;
	///if this file in mem, this is the start addr of RESOURCEITEM  
	CHARSTR * resource_item_addr ;
	///if this file in mem, this is the start addr of resource 
	CHARSTR *  resource_addr ;
} AWRESOURCE ;

/**
 * The struct of resource item information
 */
typedef struct {
	///the id of this resource in this file
	INT16U	resource_id ;		
	///resource's data length, bytes
	INT16U  resource_length;	
	///resource's start addr in resource file, not include file head, 
	///so real addr in file is (8+ resource_item_num* sizeof(RESOURCEITEM) + offset)
	INT32U	resource_offset;	
} RESOURCEITEM ;

/**
 * Initialize resource manage routine.
 */
void AWResourceInit(INT32U iMaxMemSize) ;

/**
 * Register resource file to resource manage routine.
 * @param [in] res_file_id the ID of resource file, manage routine according this ID to 
 * load resouce data.
 * @param [in] res_file_name the resource file's dir and name, manage routine according this to
 * read resource file to memory. 
 * @param [in] mem_res_file_addr if this param != NULL, means this resource will keep in memory 
 * always and this is the address of resouce file in memory.
 * @return return 0 if success.
 */
INT32S AWResourceRegister(INT16U res_file_id, CHARSTR *res_file_name, CHARSTR *mem_res_file_addr) ;

/**
 * Unregister(remove) the resource file from resource manage routine.
 */
INT32S AWResourceUnregister(INT16U res_file_id) ;

/**
 * According the resource ID, return the data from resource file if ID is legal
 * @param [in] iResourceID the resource ID which you want to get 
 * @param [out] pSourceLength get the return resource data length, bytes number.
 * @return Return the resource data point if found the resource, otherwise return NULL.
 */
void *AWGetResource(INT32U iResourceID, INT16U* pSourceLength) ;

#endif //end of _AW_RESOURCE_H

⌨️ 快捷键说明

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