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

📄 hfilefactory_anim.cpp

📁 Resource editor base speadrum Chinese mobile
💻 CPP
字号:
// HFileFactory_anim.cpp: implementation of the CHFileFactory class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resourceeditor.h"
#include "HFileFactory.h"
#include "DirFileInfo.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

BOOL CHFileFactory::GenerateAnimH( LPCTSTR pszFileName , CString bin_name)
{
    _ASSERTE( pszFileName != NULL && m_pMMIRes != NULL );

    if( !IsCoverFile(pszFileName) )
        return  FALSE;

    //buffer for unicode to mbcs
	char *pszBuf = new char[1024*100];
	int nUnicodeSize = 0; // by 16-bit
	
    CFile file;
    try{
        if( !file.Open(pszFileName, CFile::modeCreate | CFile::modeWrite) )
        {
            return FALSE;
        }

	_TCHAR szTitle[] = 
			_T("/*****************************************************************************\r\n")
			_T("** File Name:      xxx_mmi_anim.h                                            *\r\n")
			_T("** Author:                                                                   *\r\n")
			_T("** Date:           05/2006                                                   *\r\n")
			_T("** Copyright:      2006 Spreadtrum, Incoporated. All Rights Reserved.        *\r\n")
			_T("** Description:    This file is used to describe call log                    *\r\n")
			_T("******************************************************************************\r\n")
			_T("**                         Important Edit History                            *\r\n")
			_T("** --------------------------------------------------------------------------*\r\n")
			_T("** Create by Spreadtrum Resource Editor tool                                 *\r\n")
			_T("******************************************************************************/\r\n\r\n");
       

	_TCHAR szBegin[] =             
			_T("#include \"sci_types.h\"\r\n")
			_T("#include \"mmi_module.h\"\r\n\r\n")          
			_T("#ifdef __cplusplus\r\n")
			_T("extern   \"C\" {\r\n")
			_T("#endif\r\n\r\n")
			_T("///////////////////////////////////////////////////////////////////////////////\r\n")
			_T("// Animation Resource ID\r\n")
			_T("///////////////////////////////////////////////////////////////////////////////\r\n\r\n");
 
	_TCHAR szEnd[] = 
			_T("#ifdef __cplusplus\r\n")
			_T("}\r\n")
			_T("#endif\r\n\r\n")            
			_T("#endif //"); 

		//write module name in enum
		CString  strLine;
		LPCTSTR pFind = _tcsrchr(bin_name, _T('\\'));
		if( NULL == pFind )
			pFind = bin_name;
		else
			pFind++;

		CString moduleName = pFind;
		CString tempstr;
		CString module_header;
		int nLeft = moduleName.ReverseFind(_T('.'));
		if( nLeft > 0 )
		module_header=moduleName = moduleName.Left(nLeft);
		moduleName.Insert(0,_T("MMI_MODULE_"));
    	moduleName.MakeUpper();
		tempstr.Format(_T("%s"),moduleName);
		module_header.MakeUpper();
		//write file head
        nUnicodeSize = _tcslen(szTitle);
		WideCharToMultiByte( CP_ACP, 0, szTitle, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));

		//write condition compile of module head file, relative with module name
		strLine.Format(_T("%s %s_%s\r\n"),_T("#ifndef"),module_header,_T("MMI_ANIM_H_"));
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
		
  
		strLine.Format(_T("%s %s_%s\r\n\r\n"),_T("#define"),module_header,_T("MMI_ANIM_H_"));
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
		
        //write some concrete content after condition compile
		nUnicodeSize = _tcslen(szBegin);
		WideCharToMultiByte( CP_ACP, 0, szBegin, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
   
		//wirte ID enum, relative with module name
		strLine.Format(_T("%s %s_%s\r\n"),_T("typedef enum"),module_header,_T("MMI_ANIM_ID_E"));
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));

		strLine.Format(_T("%s\r\n"),_T("{"));
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));

        CDirFileInfo * pInfo = g_theApp.m_pAnimInfo;
        _ASSERTE( pInfo != NULL );
        CStringArray arrID;
        pInfo->CalcAllLeafID(arrID);
        int nSize = arrID.GetSize();

        // 在MMI中动画是和图片统一处理的,所以需要把动画的ID和图片的ID连接起来
		strLine.Format(_T("\t%s_%s = %s << %d,\r\n"),module_header, _T("IMAGE_AMIN_NULL"),tempstr,16);
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
        /*int nImgCount = g_theApp.m_MMIRes.m_mapImg.GetCount();
        if( nSize > 0 )
        {
            strLine.Format(_T("\t%s = %s+%d,\r\n"), arrID[0], "IMAGE_NULL",nImgCount + 1);
            file.Write(strLine, strLine.GetLength());
        }
        */
        for( int i = 0; i < nSize; ++i )
        {      
			//目前先不加header
            strLine.Format(_T("\t%s,\r\n"),arrID[i]);
			//strLine.Format(_T("\t%s_%s,\r\n"), module_header,arrID[i]);
			nUnicodeSize = strLine.GetLength();
			WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
			file.Write(pszBuf, strlen(pszBuf));
        }

        strLine.Format(_T("\t%s_%s\r\n"), module_header,_T("IMAGE_AMIN_MAX"));
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));

		strLine.Format(_T("%s %s_%s;\r\n\r\n"),_T("}"),module_header,_T("MMI_ANIM_ID_E"));
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
		
		nUnicodeSize = _tcslen(szEnd);
		WideCharToMultiByte( CP_ACP, 0, szEnd, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
  

		strLine.Format(_T("%s_%s\r\n"),module_header,_T("MMI_ANIM_H_"));
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
		
        file.Close();
		delete[] pszBuf;
    }
    catch(CFileException * pfe)
    {
        pfe->ReportError();
        pfe->Delete();
		delete[] pszBuf;
        return FALSE;
    }

    return  TRUE;
}

⌨️ 快捷键说明

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