MainWindow::MainWindow(const std::string &simulationName) { this->m_dw = NULL; this->m_gen = new Generator(simulationName); // // Menu // QMenu *menuFichier = menuBar()->addMenu("&File"); /* QAction *menuOpen = menuFichier->addAction("Open"); menuOpen->setDisabled(true); QAction *menuNew = menuFichier->addAction("New"); menuNew->setDisabled(true); QAction *menuSave = menuFichier->addAction("Save"); menuSave->setDisabled(true); QAction *menuSaveAs = menuFichier->addAction("Save as"); menuSaveAs->setDisabled(true); */ QAction *menuSavePix = menuFichier->addAction("Save as picture"); connect(menuSavePix, SIGNAL(triggered()), this, SLOT(SavePicture())); QAction *menuXml = menuFichier->addAction("Save as XML"); connect(menuXml, SIGNAL(triggered()), this, SLOT(SaveXml())); QAction *menuXmlLoad = menuFichier->addAction("Load XML file"); connect(menuXmlLoad, SIGNAL(triggered()), this, SLOT(LoadXml())); QAction *actionQuit = menuFichier->addAction("Quit"); connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); QMenu *menuEdit = menuBar()->addMenu("&Edit"); QAction *actionConfig = menuEdit->addAction("Configuration"); actionConfig->setDisabled(true); //connect(actionConfig, SIGNAL(triggered()), this, SLOT(ConfigurationMenu())); QMenu *menuView = menuBar()->addMenu("&Generate"); QAction *actionCpp = menuView->addAction("&C++"); connect(actionCpp, SIGNAL(triggered()), this, SLOT(GenerateCpp())); QAction *actionPython = menuView->addAction("&Python"); connect(actionPython, SIGNAL(triggered()), this, SLOT(GeneratePython())); QMenu *menuHelp = menuBar()->addMenu("&Help"); QAction *menuOnlineHelp = menuHelp->addAction("Online Help"); menuOnlineHelp->setDisabled(true); //connect(menuOnlineHelp, SIGNAL(triggered()), this, SLOT(Help())); QAction *menuAbout = menuHelp->addAction("About"); connect(menuAbout, SIGNAL(triggered()), this, SLOT(About())); menuAbout = menuAbout; menuHelp = menuHelp; // // toolbar for add equipements. // QToolBar *toolBarFichier = addToolBar(""); //PC QIcon pcIcon(":/Ico/Pc.png"); QString pcString("Terminal"); QAction *pcAction = toolBarFichier->addAction(pcIcon, pcString); connect(pcAction, SIGNAL(triggered()), this, SLOT(CreatePc())); //Pc-group QIcon pcgIcon(":/Ico/Pc-group.png"); QString pcgString("Terminal Group"); QAction *pcgAction = toolBarFichier->addAction(pcgIcon, pcgString); connect(pcgAction, SIGNAL(triggered()), this, SLOT(CreatePcGroup())); //PC-Emu QIcon emuIcon(":/Ico/Emu.png"); QString emuString("PC with emu"); QAction *emuAction = toolBarFichier->addAction(emuIcon, emuString); connect(emuAction, SIGNAL(triggered()), this, SLOT(CreateEmu())); //PC-Tap QIcon tapIcon(":/Ico/Tap.png"); QString tapString("PC with tap"); QAction *tapAction = toolBarFichier->addAction(tapIcon, tapString); connect(tapAction, SIGNAL(triggered()), this, SLOT(CreateTap())); //AP-Wifi QIcon apIcon(":/Ico/Ap-Wifi.png"); QString apString("AP Wifi"); QAction *apAction = toolBarFichier->addAction(apIcon, apString); connect(apAction, SIGNAL(triggered()), this, SLOT(CreateAp())); //StationWifi QIcon stasIcon(":/Ico/StationWifi.png"); QString stasString("Station Wifi"); QAction *stasAction = toolBarFichier->addAction(stasIcon, stasString); connect(stasAction, SIGNAL(triggered()), this, SLOT(CreateStation())); //Hub QIcon hubIcon(":/Ico/Hub.png"); QString hubString("Hub"); QAction *hubAction = toolBarFichier->addAction(hubIcon, hubString); connect(hubAction, SIGNAL(triggered()), this, SLOT(CreateHub())); //Switch QIcon switchIcon(":/Ico/Switch.png"); QString switchString("Switch"); QAction *switchAction = toolBarFichier->addAction(switchIcon, switchString); connect(switchAction, SIGNAL(triggered()), this, SLOT(CreateSwitch())); //Router QIcon routerIcon(":/Ico/Router.png"); QString routerString("Router"); QAction *routerAction = toolBarFichier->addAction(routerIcon, routerString); connect(routerAction, SIGNAL(triggered()), this, SLOT(CreateRouter())); //separator toolBarFichier->addSeparator(); // Wired Link QIcon linkIcon(":/Ico/WiredLink.png"); QString linkString("Wired Link"); QAction *linkAction = toolBarFichier->addAction(linkIcon, linkString); connect(linkAction, SIGNAL(triggered()), this, SLOT(CreateWiredLink())); // Station link QIcon stasLinkIcon(":/Ico/Link.png"); QString stasLinkString("Station Link"); QAction *stasLinkAction = toolBarFichier->addAction(stasLinkIcon, stasLinkString); connect(stasLinkAction, SIGNAL(triggered()), this, SLOT(CreateWifiLink())); //P2P link QIcon p2pLinkIcon(":/Ico/P2pLink.png"); QString p2pLinkString("P2P Link"); QAction *p2pLinkAction = toolBarFichier->addAction(p2pLinkIcon, p2pLinkString); connect(p2pLinkAction, SIGNAL(triggered()), this, SLOT(CreateP2pLink())); //separator toolBarFichier->addSeparator(); QIcon appsLinkIcon(""); QString appsLinkString("Application"); QAction *appsLinkAction = toolBarFichier->addAction(appsLinkIcon, appsLinkString); connect(appsLinkAction, SIGNAL(triggered()), this, SLOT(CreateApplication())); //separator toolBarFichier->addSeparator(); //Delete button QIcon delIcon(":/Ico/Del.png"); QString delString("Delete"); this->m_delAction = toolBarFichier->addAction(delIcon, delString); this->m_delAction->setDisabled (true); connect(this->m_delAction, SIGNAL(triggered()), this, SLOT(DeleteObject())); // // Creation of Drag N Drop Area. // QHBoxLayout *dragLayout = new QHBoxLayout; this->m_dw = new DragWidget(); dragLayout->addWidget(this->m_dw); QWidget *zoneCentral = new QWidget; zoneCentral->setLayout(dragLayout); this->setCentralWidget(zoneCentral); // // // this->m_dw->SetMainWindow(this); }
void CExport::DoExport(bool previewMode, const CString& pathName, bool bApp, int layoutid) { // Progress dialog is going from 10% to 100% in this function // Make the DLL list CList<CString, CString&> dllList; CPath path; path.SetToCurrentDirectory(); // Allocate some initial space for the binary blocks imageBlock.allocate(20000); // 20kb initial image buffer eventBlock.allocate(5000); // 5kb initial event buffer LayoutBlock.allocate(5000); // 5kb initial frame buffer appBlock.allocate(1000); // 1kb initial app buffer hlslBlock.allocate(5000); // 5kb initial hlsl buffer menuBlock.allocate(1000); // Generate GenerateLayout(dllList); // also loads DLLs to dllList ProgressDlg.SetProgress(15); GenerateEvents(); ProgressDlg.SetProgress(20); GenerateApplicationData(layoutid); ProgressDlg.SetProgress(25); GenerateImages(); // Longest job, use 25-80% ProgressDlg.SetProgress(80); // Open the file for addition of file data in resource m_UpdateHandle = BeginUpdateResource(pathName, FALSE); // Do python GeneratePython(); // HLSL UpdateResource(m_UpdateHandle, "HLSL", MAKEINTRESOURCE(994), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), hlslBlock.ptr(), hlslBlock.size()); ProgressDlg.SetProgress(81); // Images UpdateResource(m_UpdateHandle, "IMAGEBLOCK", MAKEINTRESOURCE(995), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), imageBlock.ptr(), imageBlock.size()); ProgressDlg.SetProgress(82); // Application settings UpdateResource(m_UpdateHandle, "APPBLOCK", MAKEINTRESOURCE(997), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), appBlock.ptr(), appBlock.size()); ProgressDlg.SetProgress(83); // Layouts UpdateResource(m_UpdateHandle, "LEVELBLOCK", MAKEINTRESOURCE(998), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), LayoutBlock.ptr(), LayoutBlock.size()); ProgressDlg.SetProgress(84); // Events UpdateResource(m_UpdateHandle, "EVENTBLOCK", MAKEINTRESOURCE(999), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), eventBlock.ptr(), eventBlock.size()); ProgressDlg.SetProgress(85); // Number of DLLs long c = dllList.GetCount(); CString ibuf; long te = c; te += MvtLookup.size(); ibuf.Format("%d", te); int ilen = 0; // Make string of DLL count in to resource string format wchar_t* resString = AllocStringResourceFormat(ibuf, 1, &ilen); // String of DLL count is a string at resource 1 UpdateResource(m_UpdateHandle, RT_STRING, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), resString, ilen); // AllocStringResourceFormat makes a new string delete [] resString; CString dll; POSITION pos4 = dllList.GetHeadPosition(); int d = 0; for (d = 1000; d < (1000 + c); d++) { // In preview mode, we only put the string of the plugin name in the resources if (previewMode) { dll = dllList.GetNext(pos4); ilen = 0; // Make string of DLL count in to resource string format wchar_t* resString = AllocStringResourceFormat(dll, 1, &ilen); UpdateResource(m_UpdateHandle, RT_STRING, MAKEINTRESOURCE(d), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), resString, ilen); delete [] resString; } // In export EXE mode, the actual DLL file must be dumped in resources else { CString dllPath; dllPath.Format("%sPlugins\\Runtime\\%s", path.GetFullPath(), dllList.GetNext(pos4)); // Get the DLL file binary FILE* f = fopen(dllPath, "rb"); fseek(f, 0, SEEK_END); int fsize = ftell(f); fseek(f, 0, SEEK_SET); BYTE* fdata = new BYTE[fsize]; fread(fdata, 1, fsize, f); fclose(f); UpdateResource(m_UpdateHandle, "DLLBLOCK", MAKEINTRESOURCE(d), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), fdata, fsize); delete [] fdata; } }//for ProgressDlg.SetProgress(88); // Behavior DLLs are added afterwards int iter = 0; for (int Mvt = d; Mvt < (d + MvtLookup.size()); Mvt++) { if (previewMode) { dll = MvtLookup[iter].Name; ilen = 0; // Make string of DLL count in to resource string format wchar_t* resString = AllocStringResourceFormat(dll, 1, &ilen); UpdateResource(m_UpdateHandle, RT_STRING, MAKEINTRESOURCE(Mvt), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), resString, ilen); delete [] resString; iter++; } // In EXE mode export actual DLL file else { CString dllPath; dllPath.Format("%sPlugins\\Runtime\\%s", path.GetFullPath(), MvtLookup[iter].Name); // Get the DLL file binary FILE* f = fopen(dllPath, "rb"); fseek(f, 0, SEEK_END); int fsize = ftell(f); fseek(f, 0, SEEK_SET); BYTE* fdata = new BYTE[fsize]; fread(fdata, 1, fsize, f); fclose(f); UpdateResource(m_UpdateHandle, "DLLBLOCK", MAKEINTRESOURCE(Mvt), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), fdata, fsize); delete [] fdata; iter++; } }//for ProgressDlg.SetProgress(90); ExportResources(previewMode); ProgressDlg.SetProgress(99); UpdateResource(m_UpdateHandle, "MENUBLOCK", MAKEINTRESOURCE(993), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), menuBlock.ptr(), menuBlock.size()); // Write DLL segment EndUpdateResource(m_UpdateHandle, FALSE); // Free the bin data imageBlock.free(); eventBlock.free(); appBlock.free(); LayoutBlock.free(); hlslBlock.free(); menuBlock.free(); if (m_bInstaller) { // Now create an installer if necessary CreateInstaller(); // Delete the old file DeleteFile(m_Out); // Transfer installer to path CPath Transfer; Transfer.SetPath(m_Out); CopyFile(m_InstallerOut, m_Out, FALSE); } // Now we're done ProgressDlg.SetProgress(100); }