📄 hfilefactory_img.cpp
字号:
// HFileFactory_Img.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::GenerateImgH( 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_image.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_anim.h\"\r\n") //CR69065
_T("#include \"mmi_imagefun.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("// Image 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 //");
CString strLine;
//write module name in enum start
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_IMAGE_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_IMAGE_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_IMAGE_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));
//write module name end
CDirFileInfo * pInfo = g_theApp.m_pImgInfo;
_ASSERTE( pInfo != NULL );
CStringArray arrID;
pInfo->CalcAllLeafID(arrID);
int nSize = arrID.GetSize();
strLine.Format(_T("\t%s_%s = %s << %d,\r\n"),module_header, _T("IMAGE_NULL"),tempstr,16);
//strLine.Format(_T("\t%s = %s << %d,\r\n"), "IMAGE_NULL",tempstr,16);
nUnicodeSize = strLine.GetLength();
WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
file.Write(pszBuf, strlen(pszBuf));
for( int i = 0; i < nSize; ++i )
{
//strLine.Format(_T("\t%s_%s,\r\n"),module_header, arrID[i]);
strLine.Format(_T("\t%s,\r\n"),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_MAX_ID"));
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"),"}",module_header,_T("MMI_IMAGE_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_IMAGE_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 + -