void CHLSL_Solver_ReadSemantics::Render( Preview2DContext &c ) { int opNum = 0; const ResourceType_t &type = GetResourceType(); switch ( type ) { case RESOURCETYPE_TEXCOORD_0: case RESOURCETYPE_TEXCOORD_1: case RESOURCETYPE_TEXCOORD_2: case RESOURCETYPE_TEXCOORD_3: case RESOURCETYPE_TEXCOORD_4: case RESOURCETYPE_TEXCOORD_5: case RESOURCETYPE_TEXCOORD_6: case RESOURCETYPE_TEXCOORD_7: opNum = type - RESOURCETYPE_TEXCOORD_0; break; case RESOURCETYPE_COLOR_0: case RESOURCETYPE_COLOR_1: opNum = type - RESOURCETYPE_COLOR_0 + NPSOP_WRITE_COLOR_0; break; } Assert( opNum >= NPSOP_WRITE_TEXCOORD_0 && opNum < NPSOP_WRITE_MAX ); c.pMat_PsInOP->SetIntValue( opNum ); CNodeView::RenderSingleSolver( c, c.pMat_PsIn ); UpdateTargetVarToReflectMapIndex( 0 ); }
bool CWin::ExistsSkinFile(STRINGorID xml, LPCTSTR type) {//busy to do it return false; CDuiString strResourcePath = GetSkinPath(); strResourcePath += GetSkinFolder().GetData(); CMarkup m_xml; switch (GetResourceType()) { case UILIB_FILE: { if (HIWORD(xml.m_lpstr) != NULL) { if (*(xml.m_lpstr) == _T('<')) { return true; } else { CDuiString sFile = strResourcePath + xml.m_lpstr; HANDLE hFile = ::CreateFile(sFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return false; DWORD dwSize = ::GetFileSize(hFile, NULL); if (dwSize == 0) return false; if (dwSize > 4096 * 1024) return false; DWORD dwRead = 0; BYTE* pByte = new BYTE[dwSize]; ::ReadFile(hFile, pByte, dwSize, &dwRead, NULL); ::CloseHandle(hFile); if (dwRead != dwSize) { delete[] pByte; return false; } delete[] pByte; return true; } } else{ } } break; case UILIB_ZIP: { } break; case UILIB_RESOURCE: { } break; case UILIB_ZIPRESOURCE: { } } return false; }
void CHLSL_Solver_ReadSemantics::OnVarInit( const WriteContext_FXC &context ) { const ResourceType_t &type = GetResourceType(); const char *varname = GetResourceTypeName( type ); CHLSL_Var *target = GetTargetVar( 0 ); char tmp[MAXTARGC]; Q_snprintf( tmp, MAXTARGC, "In.%s", varname ); target->SetName( tmp, true ); }
CGEnResource* CGEnMain::LoadPicture(char *name) { eResourceType type = GetResourceType(name); if(type==resAnim) return LoadAnim(name); else if(type==resLightTex) return LoadLightTex(name); else return NULL; }
// 初始化资源管理器 void CMainWnd::InitResource() { if (GetResourceType() == UILIB_RESOURCE) { // 加载资源管理器 CResourceManager::GetInstance()->LoadResource(_T("IDR_RES"), _T("xml")); } else { // 加载资源管理器 CResourceManager::GetInstance()->LoadResource(_T("res.xml"), NULL); } }
wxsItemResData* wxsItemRes::BuildResData(wxsItemEditor* Editor) { wxString ProjectPath = GetProjectPath(); return new wxsItemResData( ProjectPath + GetWxsFileName(), ProjectPath + GetSrcFileName(), ProjectPath + GetHdrFileName(), GetXrcFileName().empty() ? _T("") : ProjectPath + GetXrcFileName(), GetResourceName(), GetResourceType(), GetLanguage(), m_UseForwardDeclarations, m_UseI18n, GetTreeItemId(), Editor, this); }
void CHLSL_Solver_ReadSemantics::OnWriteFXC( bool bIsPixelShader, WriteContext_FXC &context ) { const ResourceType_t &type = GetResourceType(); const char *varname = GetResourceTypeName( type ); const char *semanticsname = GetSemanticTypeName( type ); const char *semanticdatatype = GetSemanticType( type ); const bool bIsTexCoord = ( type >= RESOURCETYPE_TEXCOORD_0 && type <= RESOURCETYPE_TEXCOORD_7 ); const bool bIsColor = ( type >= RESOURCETYPE_COLOR_0 && type <= RESOURCETYPE_COLOR_3 ); char tmp[MAXTARGC]; if ( bIsPixelShader && ( bIsTexCoord || bIsColor ) ) //semanticdatatype = GetVarCodeNameFromFlag( pInfo->_IntValue_0 ); semanticdatatype = GetVarCodeNameFromFlag( GetData()._IntValue_0 ); else if ( !bIsPixelShader ) { if ( bIsTexCoord ) { int typenum = type - RESOURCETYPE_TEXCOORD_0; Assert( typenum >= 0 && typenum < 3 ); semanticdatatype = GetVarCodeNameFromFlag( vs_setup.iDataTypeFlag_TexCoords[typenum] ); } else if ( bIsColor ) { int typenum = type - RESOURCETYPE_COLOR_0; Assert( typenum >= 0 && typenum < 3 ); semanticdatatype = GetVarCodeNameFromFlag( vs_setup.iDataTypeFlag_Color[typenum] ); } } Q_snprintf( tmp, MAXTARGC, "%s %s", semanticdatatype, varname ); int tabsWorth = StringTabsWorth( tmp ); Q_snprintf( tmp, MAXTARGC, "\n%s %s", semanticdatatype, varname ); context.buf_semantics_In.PutString( tmp ); for ( int i = 6 - tabsWorth; i >= 0; i-- ) context.buf_semantics_In.PutString( "\t" ); Q_snprintf( tmp, MAXTARGC, ":\t%s;", semanticsname ); context.buf_semantics_In.PutString( tmp ); }
LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); styleValue &= ~WS_CAPTION; ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); RECT rcClient; ::GetClientRect(*this, &rcClient); ::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, \ rcClient.bottom - rcClient.top, SWP_FRAMECHANGED); m_PaintManager.Init(m_hWnd); m_PaintManager.AddPreMessageFilter(this); CDialogBuilder builder; CDuiString strResourcePath=m_PaintManager.GetResourcePath(); if (strResourcePath.IsEmpty()) { strResourcePath=m_PaintManager.GetInstancePath(); strResourcePath+=GetSkinFolder().GetData(); } m_PaintManager.SetResourcePath(strResourcePath.GetData()); switch(GetResourceType()) { case UILIB_ZIP: m_PaintManager.SetResourceZip(GetZIPFileName().GetData(), true); break; case UILIB_ZIPRESOURCE: { HRSRC hResource = ::FindResource(m_PaintManager.GetResourceDll(), GetResourceID(), _T("ZIPRES")); if( hResource == NULL ) return 0L; DWORD dwSize = 0; HGLOBAL hGlobal = ::LoadResource(m_PaintManager.GetResourceDll(), hResource); if( hGlobal == NULL ) { #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif return 0L; } dwSize = ::SizeofResource(m_PaintManager.GetResourceDll(), hResource); if( dwSize == 0 ) return 0L; m_lpResourceZIPBuffer = new BYTE[ dwSize ]; if (m_lpResourceZIPBuffer != NULL) { ::CopyMemory(m_lpResourceZIPBuffer, (LPBYTE)::LockResource(hGlobal), dwSize); } #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif m_PaintManager.SetResourceZip(m_lpResourceZIPBuffer, dwSize); } break; } CControlUI* pRoot=NULL; if (GetResourceType()==UILIB_RESOURCE) { STRINGorID xml(_ttoi(GetSkinFile().GetData())); pRoot = builder.Create(xml, _T("xml"), this, &m_PaintManager); } else pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager); ASSERT(pRoot); if (pRoot==NULL) { MessageBox(NULL,_T("加载资源文件失败"),_T("Duilib"),MB_OK|MB_ICONERROR); ExitProcess(1); return 0; } m_PaintManager.AttachDialog(pRoot); m_PaintManager.AddNotifier(this); InitWindow(); return 0; }
LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { m_PaintManager.Init(m_hWnd); m_PaintManager.AddPreMessageFilter(this); CDialogBuilder builder; if (m_PaintManager.GetResourcePath().IsEmpty()) { // 允许更灵活的资源路径定义 CDuiString strResourcePath=m_PaintManager.GetInstancePath(); strResourcePath+=GetSkinFolder().GetData(); m_PaintManager.SetResourcePath(strResourcePath.GetData()); } switch(GetResourceType()) { case UILIB_ZIP: m_PaintManager.SetResourceZip(GetZIPFileName().GetData(), true); break; case UILIB_ZIPRESOURCE: { HRSRC hResource = ::FindResource(m_PaintManager.GetResourceDll(), GetResourceID(), _T("ZIPRES")); if( hResource == NULL ) return 0L; DWORD dwSize = 0; HGLOBAL hGlobal = ::LoadResource(m_PaintManager.GetResourceDll(), hResource); if( hGlobal == NULL ) { #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif return 0L; } dwSize = ::SizeofResource(m_PaintManager.GetResourceDll(), hResource); if( dwSize == 0 ) return 0L; m_lpResourceZIPBuffer = new BYTE[ dwSize ]; if (m_lpResourceZIPBuffer != NULL) { ::CopyMemory(m_lpResourceZIPBuffer, (LPBYTE)::LockResource(hGlobal), dwSize); } #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif m_PaintManager.SetResourceZip(m_lpResourceZIPBuffer, dwSize); } break; } CControlUI* pRoot=NULL; if (GetResourceType()==UILIB_RESOURCE) { STRINGorID xml(_ttoi(GetSkinFile().GetData())); pRoot = builder.Create(xml, _T("xml"), this, &m_PaintManager); } else pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager); ASSERT(pRoot); if (pRoot==NULL) { MessageBox(NULL,_T("加载资源文件失败"),_T("Duilib"),MB_OK|MB_ICONERROR); ExitProcess(1); return 0; } m_PaintManager.AttachDialog(pRoot); m_PaintManager.AddNotifier(this); m_PaintManager.SetBackgroundTransparent(TRUE); InitWindow(); return 0; }
CControlUI* IDuiWindow::CreateRoot() { CDialogBuilder builder; CDuiString strResourcePath = GetSkinPath(); strResourcePath += GetSkinFolder().GetData(); m_PaintManager.SetResourcePath(strResourcePath.GetData()); CControlUI* pRoot = NULL; switch (GetResourceType()) { case UILIB_FILE: { pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager); } break; case UILIB_ZIP: { m_PaintManager.SetResourceZip(GetZIPFileName().GetData(), true); pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager); } break; case UILIB_RESOURCE: { HINSTANCE hCurInst = CPaintManagerUI::GetResourceDll(); m_PaintManager.SetCurResInstance(hCurInst); pRoot = builder.Create(_ttoi(GetSkinFile().GetData()), _T("xml"), this, &m_PaintManager); } break; case UILIB_ZIPRESOURCE: { HINSTANCE hCurInst = m_PaintManager.GetCurResInstance(); if (!hCurInst) hCurInst = CPaintManagerUI::GetResourceDll(); m_PaintManager.SetCurResInstance(hCurInst); HRSRC hResource = ::FindResource(hCurInst, GetResourceID(), _T("ZIPRES")); if (hResource == NULL) return NULL; DWORD dwSize = 0; HGLOBAL hGlobal = ::LoadResource(hCurInst, hResource); if (hGlobal == NULL) { #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif return NULL; } dwSize = ::SizeofResource(hCurInst, hResource); if (dwSize == 0) return NULL; m_lpResourceZIPBuffer = new BYTE[dwSize]; if (m_lpResourceZIPBuffer != NULL) { ::CopyMemory(m_lpResourceZIPBuffer, (LPBYTE)::LockResource(hGlobal), dwSize); } #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif m_PaintManager.SetResourceZip(m_lpResourceZIPBuffer, dwSize); pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager); } } ASSERT(pRoot); if (pRoot == NULL) { MessageBox(NULL, _T("加载资源文件失败"), _T("Duilib"), MB_OK | MB_ICONERROR); ExitProcess(1); return NULL; } return pRoot; }
LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { // 调整窗口样式 LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); styleValue &= ~WS_CAPTION; ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); // 调整窗口尺寸 RECT rcClient; ::GetClientRect(*this, &rcClient); ::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, SWP_FRAMECHANGED); // 关联UI管理器 m_PaintManager.Init(m_hWnd, GetManagerName()); // 注册PreMessage回调 m_PaintManager.AddPreMessageFilter(this); // 允许更灵活的资源路径定义 if (CPaintManagerUI::GetResourcePath().IsEmpty()) { CDuiString strResourcePath = CPaintManagerUI::GetInstancePath(); strResourcePath += GetSkinFolder().GetData(); CPaintManagerUI::SetResourcePath(strResourcePath.GetData()); } // 加载资源 switch(GetResourceType()) { case UILIB_ZIP: CPaintManagerUI::SetResourceZip(GetZIPFileName().GetData(), true); break; case UILIB_ZIPRESOURCE: { HRSRC hResource = ::FindResource(m_PaintManager.GetResourceDll(), GetResourceID(), _T("ZIPRES")); if( hResource == NULL ) return 0L; DWORD dwSize = 0; HGLOBAL hGlobal = ::LoadResource(m_PaintManager.GetResourceDll(), hResource); if( hGlobal == NULL ) { #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif return 0L; } dwSize = ::SizeofResource(m_PaintManager.GetResourceDll(), hResource); if( dwSize == 0 ) return 0L; CPaintManagerUI::SetResourceZip((LPBYTE)::LockResource(hGlobal), dwSize); #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif } break; } // 资源管理器接口 InitResource(); // 创建主窗口 CControlUI* pRoot=NULL; CDialogBuilder builder; if (GetResourceType() == UILIB_RESOURCE) { STRINGorID xml(_ttoi(GetSkinFile().GetData())); pRoot = builder.Create(xml, _T("xml"), this, &m_PaintManager); } else { pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager); } if (pRoot == NULL) { MessageBox(NULL,_T("加载资源文件失败"),_T("Duilib"),MB_OK|MB_ICONERROR); ExitProcess(1); return 0; } m_PaintManager.AttachDialog(pRoot); // 添加Notify事件接口 m_PaintManager.AddNotifier(this); // 窗口初始化完毕 InitWindow(); return 0; }
int wxsItemRes::OnGetTreeIcon() { const wxsItemInfo* Info = wxsItemFactory::GetInfo(GetResourceType()); if ( Info ) return Info->TreeIconId; return wxsResource::OnGetTreeIcon(); }
bool wxsItemRes::CreateNewResource(NewResourceParams& Params) { wxFileName HFN(GetProjectPath()+Params.Hdr); SetLanguage(wxsCodeMarks::IdFromExt(HFN.GetExt())); switch ( GetLanguage() ) { case wxsCPP: { SetResourceName(Params.Class); // Building arguments for constructor wxString CallArgs; wxString CtorArgs; wxString CtorArgsD; if ( Params.CtorParent ) { CallArgs << _T("parent"); CtorArgs << _T("wxWindow* parent"); CtorArgsD << _T("wxWindow* parent"); if ( Params.CtorParentDef ) { CtorArgsD << _T("=0"); } } if ( Params.CtorId ) { if ( !CtorArgs.IsEmpty() ) { CallArgs << _T(","); CtorArgs << _T(","); CtorArgsD << _T(","); } CallArgs << _T("id"); CtorArgs << _T("wxWindowID id"); CtorArgsD << _T("wxWindowID id"); if ( Params.CtorIdDef ) { CtorArgsD << _T("=wxID_ANY"); } } if ( Params.CtorPos ) { if ( !CtorArgs.IsEmpty() ) { CallArgs << _T(","); CtorArgs << _T(","); CtorArgsD << _T(","); } CallArgs << _T("pos"); CtorArgs << _T("const wxPoint& pos"); CtorArgsD << _T("const wxPoint& pos"); if ( Params.CtorPosDef ) { CtorArgsD << _T("=wxDefaultPosition"); } } if ( Params.CtorSize ) { if ( !CtorArgs.IsEmpty() ) { CallArgs << _T(","); CtorArgs << _T(","); CtorArgsD << _T(","); } CallArgs << _T("size"); CtorArgs << _T("const wxSize& size"); CtorArgsD << _T("const wxSize& size"); if ( Params.CtorSizeDef ) { CtorArgsD << _T("=wxDefaultSize"); } } wxString CtorArgsF = CtorArgs; if ( !Params.CustomCtorArgs.IsEmpty() ) { if ( !CtorArgs.IsEmpty() ) { CtorArgs << _T(","); CtorArgsD << _T(","); } CtorArgs << Params.CustomCtorArgs; CtorArgsD << Params.CustomCtorArgs; } // Generating code m_HdrFileName = Params.Hdr; if ( Params.GenHdr ) { wxString Name = GetProjectPath()+Params.Hdr; wxFileName::Mkdir(wxFileName(Name).GetPath(),0777,wxPATH_MKDIR_FULL); wxFile File(Name,wxFile::write); wxString Guard = HFN.GetName().Upper() + _T("_H"); wxString Header = CppEmptyHeader; wxString InitFuncDecl; wxString HeadersPch; if ( Params.UseInitFunc ) { InitFuncDecl << _T("\tprotected:\n\n") _T("\t\tvoid ") << Params.InitFunc << _T("(") << CtorArgsF << _T(");\n\n"); } if ( Params.UsePch && !Params.PchGuard.IsEmpty() ) { HeadersPch << _T("#ifndef ") + Params.PchGuard + _T("\n") _T("\t") + wxsCodeMarks::Beg(wxsCPP,_T("HeadersPCH"),Params.Class) + _T("\n") _T("\t") + wxsCodeMarks::End(wxsCPP) + _T("\n") _T("#endif\n"); } Header.Replace(_T("$(CtorArgs)"),CtorArgsD); Header.Replace(_T("$(Guard)"),Guard); Header.Replace(_T("$(ClassName)"),Params.Class); Header.Replace(_T("$(BaseClassName)"),Params.BaseClass); Header.Replace(_T("$(InitFuncDecl)"),InitFuncDecl); Header.Replace(_T("$(HeadersPch)"),HeadersPch); wxString Scope = _T(""); switch ( Params.ScopeMembers ) { case NewResourceParams::Private: Scope = _T("\tprivate:\n\n"); break; case NewResourceParams::Protected: Scope = _T("\tprotected:\n\n"); break; default:; } Header.Replace(_T("$(MembersScope)"),Scope); Scope = _T(""); if ( Params.ScopeIds != Params.ScopeMembers ) { switch ( Params.ScopeIds ) { case NewResourceParams::Public: Scope = _T("\tpublic:\n\n"); break; case NewResourceParams::Private: Scope = _T("\tprivate:\n\n"); break; case NewResourceParams::Protected: Scope = _T("\tprotected:\n\n"); break; } } Header.Replace(_T("$(IdsScope)"),Scope); Scope = _T(""); if ( Params.ScopeHandlers != Params.ScopeIds ) { switch ( Params.ScopeHandlers ) { case NewResourceParams::Public: Scope = _T("\tpublic:\n\n"); break; case NewResourceParams::Private: Scope = _T("\tprivate:\n\n"); break; case NewResourceParams::Protected: Scope = _T("\tprotected:\n\n"); break; } } Header.Replace(_T("$(HandlersScope)"),Scope); // TODO: Use wxsCoder to save file's content, so it will // have proper encoding and EOL stuff if ( !File.Write(Header) ) return false; } m_SrcFileName = Params.Src; if ( Params.GenSrc ) { wxString Name = GetProjectPath()+Params.Src; wxFileName::Mkdir(wxFileName(Name).GetPath(),0777,wxPATH_MKDIR_FULL); wxFile File(Name,wxFile::write); HFN.MakeRelativeTo(wxFileName(Name).GetPath()); wxString Include = HFN.GetFullPath(wxPATH_UNIX); wxString PchCode; if ( Params.UsePch ) { wxFileName PCH(GetProjectPath()+Params.Pch); PCH.MakeRelativeTo(wxFileName(Name).GetPath()); PchCode << _T("#include \"") << PCH.GetFullPath(wxPATH_UNIX) << _T("\"\n"); } wxString CtorInitCode; if ( Params.UseInitFunc ) { CtorInitCode << _T("\t") << Params.InitFunc << _T("(") << CallArgs << _T(");\n"); CtorInitCode << _T("}\n\n"); CtorInitCode << _T("void ") << Params.Class << _T("::") << Params.InitFunc << _T("(") << CtorArgsF << _T(")\n"); CtorInitCode << _T("{\n"); } wxString IntHeadersPch; if ( Params.UsePch && !Params.PchGuard.IsEmpty() ) { IntHeadersPch << _T("#ifndef ") + Params.PchGuard + _T("\n") _T("\t") + wxsCodeMarks::Beg(wxsCPP,_T("InternalHeadersPCH"),Params.Class) + _T("\n") _T("\t") + wxsCodeMarks::End(wxsCPP) + _T("\n") _T("#endif\n"); } wxString Source = CppEmptySource; Source.Replace(_T("$(PchCode)"),PchCode); Source.Replace(_T("$(CtorArgs)"),CtorArgs); Source.Replace(_T("$(Include)"),Include); Source.Replace(_T("$(ClassName)"),Params.Class); Source.Replace(_T("$(BaseClassName)"),Params.BaseClass); Source.Replace(_T("$(CtorInit)"),CtorInitCode); Source.Replace(_T("$(InternalHeadersPch)"),IntHeadersPch); // TODO: Use wxsCoder to save file's content, so it will // have proper encoding and EOL stuff if ( !File.Write(Source) ) return false; } m_XrcFileName = Params.Xrc; if ( !Params.Xrc.IsEmpty() && Params.GenXrc ) { wxString Name = GetProjectPath()+Params.Xrc; wxFileName::Mkdir(wxFileName(Name).GetPath(),0777,wxPATH_MKDIR_FULL); wxFile File(Name,wxFile::write); if ( !File.Write(EmptyXrc) ) return false; } if ( Params.Wxs.IsEmpty() ) { // Searching for new wxs file name // TODO: Do not use constant folder name wxString WxsNameBase = _T("wxsmith"); wxString WxsName; if ( !wxFileName::DirExists(GetProjectPath()+WxsNameBase) ) { if ( !wxFileName::Mkdir(GetProjectPath()+WxsNameBase,0777,wxPATH_MKDIR_FULL) ) { return false; } } WxsNameBase += _T("/") + Params.Class; WxsName = WxsNameBase + _T(".wxs"); int Cnt = 0; for(;;) { if ( !wxFileName::FileExists(GetProjectPath()+WxsName) && !wxFileName::DirExists(GetProjectPath()+WxsName) ) { break; } Cnt++; WxsName = wxString::Format(_T("%s%d.wxs"),WxsNameBase.wx_str(),Cnt); } m_WxsFileName = WxsName; Params.Wxs = WxsName; { wxString Name = GetProjectPath()+m_WxsFileName; wxFile File(Name,wxFile::write); wxString Content = EmptyWxs; Content.Replace(_T("$(ClassName)"),Params.Class); Content.Replace(_T("$(BaseClassName)"),GetResourceType()); if ( !File.Write(Content) ) { return false; } } } else { m_WxsFileName = Params.Wxs; } m_UseForwardDeclarations = Params.UseFwdDecl; m_UseI18n = Params.UseI18n; return true; } default:; } SetLanguage(wxsUnknownLanguage); return false; }
CControlUI* CWin::CreateRoot(STRINGorID xml, LPCTSTR type /* = NULL */, IDialogBuilderCallback* pCallback /* = NULL */, CControlUI* pParent /* = NULL */) { CDialogBuilder builder; CDuiString strResourcePath = GetSkinPath(); strResourcePath += GetSkinFolder().GetData(); _paintManager->SetResourcePath(strResourcePath.GetData()); CControlUI* pRoot = NULL; switch (GetResourceType()) { case UILIB_FILE: { pRoot = builder.Create(xml, type, pCallback, _paintManager, pParent); } break; case UILIB_ZIP: { _paintManager->SetResourceZip(GetZIPFileName().GetData(), true); pRoot = builder.Create(xml, type, pCallback, _paintManager, pParent); } break; case UILIB_RESOURCE: { HINSTANCE hCurInst = CPaintManagerUI::GetResourceDll(); _paintManager->SetCurResInstance(hCurInst); pRoot = builder.Create(xml, type, pCallback, _paintManager, pParent); } break; case UILIB_ZIPRESOURCE: { HINSTANCE hCurInst = _paintManager->GetCurResInstance(); if (!hCurInst) hCurInst = CPaintManagerUI::GetResourceDll(); _paintManager->SetCurResInstance(hCurInst); HRSRC hResource = ::FindResource(hCurInst, GetResourceID(), _T("ZIPRES")); if (hResource == NULL) return NULL; DWORD dwSize = 0; HGLOBAL hGlobal = ::LoadResource(hCurInst, hResource); if (hGlobal == NULL) { #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif return NULL; } dwSize = ::SizeofResource(hCurInst, hResource); if (dwSize == 0) return NULL; m_lpResourceZIPBuffer = new BYTE[dwSize]; if (m_lpResourceZIPBuffer != NULL) { ::CopyMemory(m_lpResourceZIPBuffer, (LPBYTE)::LockResource(hGlobal), dwSize); } #if defined(WIN32) && !defined(UNDER_CE) ::FreeResource(hResource); #endif _paintManager->SetResourceZip(m_lpResourceZIPBuffer, dwSize); pRoot = builder.Create(xml, type, pCallback, _paintManager, pParent); } } ASSERT(pRoot); if (pRoot == NULL) { MessageBox(NULL, _T("加载资源文件失败"), _T("Duilib"), MB_OK | MB_ICONERROR); ExitProcess(1); return NULL; } return pRoot; }