void CDocTemplate::SetContainerInfo(UINT nIDOleInPlaceContainer) { ASSERT(nIDOleInPlaceContainer != 0); m_nIDContainerResource = nIDOleInPlaceContainer; if (!CDocManager::bStaticInit) LoadTemplate(); }
DocxEditBox::DocxEditBox(void) { string type_id=this->GetNewId(), id=this->GetNewId(); LoadTemplate(m_xml, TEMPLATE_PATH "editbox.xml"); // replace id ReplaceString(m_xml, id, ID_MARK); // replace type id ReplaceString(m_xml, type_id, TYPEID_MARK); }
NewWorldDialog::NewWorldDialog(QWidget *parent) : QDialog(parent), ui(new Ui::NewWorldDialog) { ui->setupUi(this); selected_object = NULL; for (int i = 0; i < Class::nmetaclasses; i++) { Class* c = Class::metaclasses[i]; if (c->abstract) continue; for (Class* p = c; p; p = Class::Lookup(p->pname)) { if (strcmp(p->name, "Block") == 0) { ui->prototypeList->addItem(c->name); break; } if (strcmp(p->name, "Shape") == 0) { ui->prototypeList->addItem(c->name); break; } } } ui->prototypeList->setCurrentRow(0); ui->objectTable->setDragDropMode(QAbstractItemView::InternalMove); ui->splitter->setStretchFactor(0,3); ui->splitter->setStretchFactor(1,2); ui->objectTable->setFocus(); ui->containerObject->setLayout(new QGridLayout); ui->commentBox->setVisible(false); DeselectObject(); is_start = true; connect(ui->objectTable, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), ui->prototypeList, SLOT(clearSelection())); connect(ui->prototypeList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(DeselectObject())); connect(ui->saveTemplate, SIGNAL(released()), this, SLOT(SaveTemplate())); connect(ui->loadTemplate, SIGNAL(released()), this, SLOT(LoadTemplate())); connect(ui->copyObject, SIGNAL(released()), this, SLOT(CopyObject())); connect(ui->addObject, SIGNAL(released()), this, SLOT(AddObject())); connect(ui->removeObject, SIGNAL(released()), this, SLOT(RemoveObject())); connect(ui->objectTable, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(SelectObject(QListWidgetItem*,QListWidgetItem*))); connect(ui->numberBox, SIGNAL(valueChanged(int)), this, SLOT(SetObjectNumber(int))); connect(ui->commentVisibleBox, SIGNAL(toggled(bool)), ui->commentBox, SLOT(setVisible(bool))); connect(this, SIGNAL(accepted()), SLOT(CreateWorld())); }
void Parser::Run(itxString* tpldir, itxString* pname, char* ext) { TemplateFile* new_tpl = NULL; TemplateFile* popped_tpl = NULL; // interpretazione dei dati try { if ((new_tpl = LoadTemplate(tpldir, pname, ext)) != NULL) { m_TplStack.Push(new_tpl); m_CurTpl = new_tpl; g_DebugFile.m_CurrentTemplate = m_CurTpl->m_PathName; DebugTrace2(TEMPLATE, "Parser::Run: template is: %s\n", m_CurTpl->m_PathName.GetBuffer()); try { ProcTplData(m_CurTpl->GetContentBuffer(), &(m_CurTpl->m_Output)); } catch(...) { DebugTrace2(IN_ERROR, "Unhandled exception during ProcTplData: now context is Run(itxString*, itxString*, char*), going on...\n"); } //Return from template was forced, reset dedicated variable if(m_ForceReturn != 0) m_ForceReturn = 0; //Finish with this template m_TplStack.Pop((void**)&popped_tpl); if (popped_tpl != new_tpl) DebugTrace2(DEFAULT, "Template mismatch in Parser::Run : expected %s, found %s\n", new_tpl->m_PathName.GetBuffer(), popped_tpl->m_PathName.GetBuffer()); //Reassign the currente template with the topmost of the stack if ((m_CurTpl = (TemplateFile*) m_TplStack.Top()) != NULL) { m_CurTpl->m_Output += new_tpl->m_Output; DebugTrace2(TEMPLATE, "Parser::Run: template is: %s\n", m_CurTpl->m_PathName.GetBuffer()); delete new_tpl; } else m_CurTpl = new_tpl; g_DebugFile.m_CurrentTemplate = m_CurTpl->m_PathName; } } catch(...) { DebugTrace2(IN_ERROR, "Unhandled exception in Parser::Run. Current template is '%s'\n", pname->GetBuffer()); throw; } }
//--------------------------------------------------------------------------- void __fastcall TFileViewDlg::PBDblClick(TObject *Sender) { if( pCurPage->pList == NULL ) return; if( m_CurFile >= pCurPage->pList->Count ) return; if( Mmsstv->SBTX->Down ) return; if( pCurPage->m_Type ){ // テンプレート CWaitCursor w; Mmsstv->AdjustPage(pgTemp); AnsiString as; GetCurFileName(as); if( pCurPage->m_Type == 4 ){ Mmsstv->DropOle(-1, 0, as.c_str(), (Sender == KP) ? 0 : 1); } else if( pCurPage->m_Type == 3 ){ // DLL Mmsstv->DropLib(-1, 0, as.c_str()); } else if( pCurPage->m_Type == 2 ){ CDrawGroup Group; LoadTemplate(&Group, as.c_str(), NULL); Mmsstv->AddTemplate(&Group); } else { LoadTemplate(&Mmsstv->DrawMain, as.c_str(), NULL); } Mmsstv->UpdatePic(); } else if( SBMode->Down ){ KTXSClick(Sender); } else { KTXClick(Sender); } #if 0 if( Sender->ClassNameIs("TPaintBox") ){ TPaintBox *pBox = (TPaintBox *)Sender; if( pBox->Dragging() ) pBox->EndDrag(FALSE); } #endif }
BOOL CXTPPropertyPage::CreatePage(CWnd* pParentWnd) { if (GetSafeHwnd()) return TRUE; HGLOBAL hTemplate = NULL; HINSTANCE hInstance = NULL; if (!LoadTemplate(hTemplate, hInstance)) return FALSE; if (!hTemplate) return FALSE; DLGTEMPLATE* lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate); if (!lpDialogTemplate) return FALSE; DLGEXTEMPLATE* lpDialogExTemplate = (DLGEXTEMPLATE*)lpDialogTemplate; DWORD lSaveStyle; if (lpDialogExTemplate->wSignature == 0xFFFF) lSaveStyle = lpDialogExTemplate->dwStyle; else lSaveStyle = lpDialogTemplate->style; DWORD dwNewStyle = (lSaveStyle & (DS_LOCALEDIT | WS_CLIPCHILDREN | DS_SETFONT | DS_FIXEDSYS)) | WS_CHILD | WS_TABSTOP | DS_3DLOOK | DS_CONTROL; if (lpDialogExTemplate->wSignature == 0xFFFF) lpDialogExTemplate->dwStyle = dwNewStyle; else lpDialogTemplate->style = dwNewStyle; BOOL bResult = CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInstance); CSize sz; CXTPWindowRect rc(this); m_totalDev = rc.Size(); m_bCreated = TRUE; GlobalUnlock(hTemplate); GlobalFree(hTemplate); return bResult; }
BOOL CXTPPropertyPage::LoadTemplate() { HGLOBAL hTemplate = NULL; HINSTANCE hInstance = NULL; if (!LoadTemplate(hTemplate, hInstance)) return FALSE; if (!hTemplate) return FALSE; DLGTEMPLATE* lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate); if (!lpDialogTemplate) return FALSE; DLGEXTEMPLATE* lpDialogExTemplate = (DLGEXTEMPLATE*)lpDialogTemplate; BOOL bDialogEx = lpDialogExTemplate->wSignature == 0xFFFF; m_lineDev = CXTPDrawHelpers::Dlu2Pix(5, 5); if ((m_psp.dwFlags & PSP_USETITLE) == 0) { WORD* lpTitle = bDialogEx ? (WORD*)(lpDialogExTemplate + 1) : (WORD*)(lpDialogTemplate + 1); if (*lpTitle == (WORD)-1) // Skip menu name string or ordinal lpTitle += 2; else while(*lpTitle++); if (*lpTitle == (WORD)-1) // Skip class name string or ordinal lpTitle += 2; else while(*lpTitle++); m_strCaption = CString((LPWSTR)lpTitle); } CDialogTemplate dlgTemp(hTemplate); dlgTemp.GetSizeInPixels(&m_totalDev); GlobalUnlock(hTemplate); GlobalFree(hTemplate); return TRUE; }
CDocTemplate::CDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass) { ASSERT_VALID_IDR(nIDResource); ASSERT(pDocClass == NULL || pDocClass->IsDerivedFrom(RUNTIME_CLASS(CDocument))); ASSERT(pFrameClass == NULL || pFrameClass->IsDerivedFrom(RUNTIME_CLASS(CFrameWnd))); ASSERT(pViewClass == NULL || pViewClass->IsDerivedFrom(RUNTIME_CLASS(CView))); m_nIDResource = nIDResource; m_nIDServerResource = NULL; m_nIDEmbeddingResource = NULL; m_nIDContainerResource = NULL; m_pDocClass = pDocClass; m_pFrameClass = pFrameClass; m_pViewClass = pViewClass; m_pOleFrameClass = NULL; m_pOleViewClass = NULL; m_pAttachedFactory = NULL; m_hMenuInPlace = NULL; m_hAccelInPlace = NULL; m_hMenuEmbedding = NULL; m_hAccelEmbedding = NULL; m_hMenuInPlaceServer = NULL; m_hAccelInPlaceServer = NULL; // add to pStaticList if constructed as static instead of on heap if (CDocManager::bStaticInit) { m_bAutoDelete = FALSE; if (CDocManager::pStaticList == NULL) CDocManager::pStaticList = new CPtrList; if (CDocManager::pStaticDocManager == NULL) CDocManager::pStaticDocManager = new CDocManager; CDocManager::pStaticList->AddTail(this); } else { m_bAutoDelete = TRUE; // usually allocated on the heap LoadTemplate(); } }
void CDocTemplate::SetServerInfo(UINT nIDOleEmbedding, UINT nIDOleInPlaceServer, CRuntimeClass* pOleFrameClass, CRuntimeClass* pOleViewClass) { ASSERT_VALID_IDR(nIDOleEmbedding); if (nIDOleInPlaceServer != 0) ASSERT_VALID_IDR(nIDOleInPlaceServer); ASSERT(pOleFrameClass == NULL || pOleFrameClass->IsDerivedFrom(RUNTIME_CLASS(CFrameWnd))); ASSERT(pOleViewClass == NULL || pOleViewClass->IsDerivedFrom(RUNTIME_CLASS(CView))); m_pOleFrameClass = pOleFrameClass; m_pOleViewClass = pOleViewClass; m_nIDEmbeddingResource = nIDOleEmbedding; m_nIDServerResource = nIDOleInPlaceServer; if (!CDocManager::bStaticInit) LoadTemplate(); }
//--------------------------------------------------------------------------- void __fastcall TFileViewDlg::LoadFile(Graphics::TBitmap *pBitmap, LPCSTR pName) { if( pCurPage->m_Type >= 3 ){ int xw = m_RectS.Right; int yw = m_RectS.Bottom; pBitmap->Width = xw; pBitmap->Height = yw; FillBitmap(pBitmap, clBtnFace); WORD Icon = 0; HICON hIcon = ::ExtractAssociatedIcon(HInstance, (LPSTR)pName, &Icon); if( hIcon != NULL ){ TIcon *pIcon = new TIcon; pIcon->Handle = hIcon; pBitmap->Canvas->Draw((xw - pIcon->Width)/2, (yw >= 64) ? (yw - pIcon->Height)/2 : 0, pIcon); delete pIcon; } pBitmap->Canvas->Font->Height = -12; int fw = pBitmap->Canvas->TextWidth(pName); int fh = pBitmap->Canvas->TextHeight(pName); int tm = ::SetBkMode(pBitmap->Canvas->Handle, TRANSPARENT); int x = (xw - fw) / 2; if( x < 0 ) x = 0; pBitmap->Canvas->TextOut(x, hIcon != NULL ? yw - fh : (yw - fh)/2, pName); ::SetBkMode(pBitmap->Canvas->Handle, tm); } else if( pCurPage->m_Type ){ CDrawGroup *pGroup = new CDrawGroup; if( LoadTemplate(pGroup, pName, pBitmap->Canvas) == TRUE ){ pBitmap->Width = pGroup->m_SX; pBitmap->Height = pGroup->m_SY; FillBitmap(pBitmap, pGroup->m_TransCol); MultProc(); pGroup->Draw(pBitmap->Canvas); } pGroup->FreeItem(); delete pGroup; } else { ::LoadImage(pBitmap, pName); } }
bool KSC_SurfaceShader::LoadAndCompile() { return LoadTemplate(mTypeName.c_str()); }
void ReflectionParser::GenerateFiles(void) { fs::path sourceRootDirectory( m_options.sourceRoot ); fs::path outputFileDirectory( m_options.outputModuleFileDirectory ); m_moduleFileHeaderTemplate = LoadTemplate( kTemplateModuleFileHeader ); if (!m_moduleFileHeaderTemplate.isValid( )) { std::stringstream error; error << "Unable to compile module file header template." << std::endl; error << m_moduleFileHeaderTemplate.errorMessage( ); throw std::exception( error.str( ).c_str( ) ); } m_moduleFileSourceTemplate = LoadTemplate( kTemplateModuleFileSource ); if (!m_moduleFileSourceTemplate.isValid( )) { std::stringstream error; error << "Unable to compile module file source template." << std::endl; error << m_moduleFileSourceTemplate.errorMessage( ); throw std::exception( error.str( ).c_str( ) ); } TemplateData moduleFilesData { TemplateData::Type::List }; fs::path metaCacheFileName = m_options.outputModuleFileDirectory; metaCacheFileName /= ".meta-cache"; auto metaCacheFileExists = exists( metaCacheFileName ); std::string moduleFileCache; for (auto &file : m_moduleFiles) { fs::path filePath( file.first ); // path relative to the source root auto relativeDir = utils::MakeRelativePath( sourceRootDirectory, filePath ) .replace_extension( "" ).string( ); if (relativeDir.find_first_of( ".." ) != std::string::npos) continue; auto outputFile = outputFileDirectory / relativeDir; auto outputFileHeader = change_extension( outputFile, "Generated.h" ); auto outputFileSource = change_extension( outputFile, "Generated.cpp" ); // module file name file.second.name = boost::regex_replace( relativeDir, kSpecialCharsRegex, "_" ); moduleFileCache += file.second.name + '\n'; TemplateData moduleFileData { TemplateData::Type::Object }; moduleFileData[ "name" ] = file.second.name; moduleFileData[ "header" ] = outputFileHeader.string( ); moduleFilesData << moduleFileData; // if the generated file header doesn't exist, we need to regenerate if (m_options.forceRebuild || !metaCacheFileExists || !exists( outputFileHeader )) { generateModuleFile( outputFileHeader, outputFileSource, file.first, file.second ); continue; } auto lastSourceWrite = last_write_time( filePath ); auto lastGeneratedWrite = last_write_time( outputFileHeader ); // if the generated file is older than the source file, we need to regenerate if (lastSourceWrite > lastGeneratedWrite) generateModuleFile( outputFileHeader, outputFileSource, file.first, file.second ); } fs::path moduleCacheFileName = m_options.outputModuleFileDirectory; moduleCacheFileName /= ".meta-cache"; if (!m_options.forceRebuild && metaCacheFileExists) { std::ifstream cacheFile( moduleCacheFileName.string( ) ); std::istreambuf_iterator<char> cacheFileBegin( cacheFile ); std::istreambuf_iterator<char> cacheFileEnd( nullptr ); // the cache is the same, so we don't need to write the source files if (utils::RangeEqual( moduleFileCache.begin( ), moduleFileCache.end( ), cacheFileBegin, cacheFileEnd )) { return; } } // update the cache utils::WriteText( moduleCacheFileName.string( ), moduleFileCache ); // module source file { auto sourceTemplate = LoadTemplate( kTemplateModuleSource ); if (!sourceTemplate.isValid( )) { std::stringstream error; error << "Unable to compile module source template." << std::endl; error << sourceTemplate.errorMessage( ); throw std::exception( error.str( ).c_str( ) ); } TemplateData sourceData { TemplateData::Type::Object }; addGlobalTemplateData( sourceData ); sourceData[ "moduleFile" ] = moduleFilesData; COMPILE_TYPE_TEMPLATES( sourceData, "external", m_externals ); fs::path sourcePath( m_options.outputModuleSource ); fs::create_directory( sourcePath.parent_path( ) ); utils::WriteText( sourcePath.string( ), sourceTemplate.render( sourceData ) ); } }