void MainWindow::OnCreation() { mpLoopVoice = GetAudioEngine()->PlaySound(nglPath(_T("rsrc:/audio/drums-loop.wav")), nuiSound::eStream); mpLoopVoice->Acquire(); mpLoopVoice->SetLoop(true); nuiGrid* pMainGrid = new nuiGrid(2, 2); AddChild(pMainGrid); pMainGrid->SetObjectName(_T("MainGrid")); uint32 nbRows = GRID_NB_ROWS; uint32 nbCol = GRID_NB_COLUMNS; { nuiLabel* pLabel = new nuiLabel(_T("Memory Sounds")); pLabel->SetObjectName(_T("MemoryLabel")); pMainGrid->SetCell(0, 0, pLabel); for (uint32 i = 0; i < GRID_NB_ROWS * GRID_NB_COLUMNS; i++) { nglString str; str.Format(_T("rsrc:/audio/sound%d.wav"), i); nglPath path(str); nuiSound* pSound = nuiSoundManager::Instance.GetSound(path, nuiSound::eMemory); pSound->Acquire(); mSounds.push_back(pSound); } std::vector<std::pair<nglKeyCode, nglString> > keys; keys.push_back(std::make_pair(NK_1, _T("1"))); keys.push_back(std::make_pair(NK_2, _T("2"))); keys.push_back(std::make_pair(NK_3, _T("3"))); keys.push_back(std::make_pair(NK_4, _T("4"))); keys.push_back(std::make_pair(NK_Q, _T("q"))); keys.push_back(std::make_pair(NK_W, _T("w"))); keys.push_back(std::make_pair(NK_E, _T("e"))); keys.push_back(std::make_pair(NK_R, _T("r"))); keys.push_back(std::make_pair(NK_A, _T("a"))); keys.push_back(std::make_pair(NK_S, _T("s"))); keys.push_back(std::make_pair(NK_D, _T("d"))); keys.push_back(std::make_pair(NK_F, _T("f"))); keys.push_back(std::make_pair(NK_Z, _T("z"))); keys.push_back(std::make_pair(NK_X, _T("x"))); keys.push_back(std::make_pair(NK_C, _T("c"))); keys.push_back(std::make_pair(NK_V, _T("v"))); nuiGrid* pGrid = new nuiGrid(nbCol, nbRows); pGrid->SetObjectName(_T("MemorySoundsGrid")); pMainGrid->SetCell(0, 1, pGrid); NGL_ASSERT(keys.size() == nbRows * nbCol); for (uint32 r = 0; r < nbRows; r++) { for (uint32 c = 0; c < nbCol; c++) { uint32 index = r * nbCol + c; nglString text = keys[index].second; nuiButton* pButton = new nuiButton(text); mSoundButtons.push_back(pButton); pButton->SetObjectName(_T("GridButton")); pGrid->SetCell(c, r, pButton); mEventSink.Connect(pButton->Activated, &MainWindow::OnButtonActivated, (void*)index); nglString hotkeyName; nglString hotkeyDesc; hotkeyName.Format(_T("SoundButton%d"), index); hotkeyDesc.Format(_T("PlaySound%d"), index); RegisterHotKeyKey(hotkeyName, keys[index].first, nuiNoKey, false, false, hotkeyDesc); mEventSink.Connect(GetHotKeyEvent(hotkeyName), &MainWindow::OnSoundHotKey, (void*)index); } } } { nuiLabel* pLabel = new nuiLabel(_T("Synth Sounds")); pLabel->SetObjectName(_T("SynthLabel")); pMainGrid->SetCell(1, 0, pLabel); for (uint32 r = 0; r < nbRows; r++) { for (uint32 c = 0; c < nbCol; c++) { nuiSynthSound* pSynthSound = nuiSoundManager::Instance.GetSynthSound(); pSynthSound->SetSampleRate(GetAudioEngine()->GetSampleRate()); pSynthSound->SetReleaseTime(3); float freq = 100; if (c == 0) freq = 82.41; else if (c == 1) freq = 123.47; else if (c == 2) freq = 146.83; else if (c == 3) freq = 164.81; nuiSynthSound::SignalType type = nuiSynthSound::eSinus; float gain; if (r == 0) { gain = 0.8; type = nuiSynthSound::eSinus; } else if (r == 1) { gain = 0.4; type = nuiSynthSound::eTriangle; } else if (r == 2) { gain = 0.4; type = nuiSynthSound::eSaw; } else if (r == 3) { gain = 0.2; type = nuiSynthSound::eSquare; } pSynthSound->SetGain(gain); pSynthSound->SetFreq(freq); pSynthSound->SetType(type); pSynthSound->Acquire(); mSynthSounds.push_back(pSynthSound); } } std::vector<std::pair<nglKeyCode, nglString> > keys; keys.push_back(std::make_pair(NK_7, _T("7"))); keys.push_back(std::make_pair(NK_8, _T("8"))); keys.push_back(std::make_pair(NK_9, _T("9"))); keys.push_back(std::make_pair(NK_0, _T("0"))); keys.push_back(std::make_pair(NK_U, _T("u"))); keys.push_back(std::make_pair(NK_I, _T("i"))); keys.push_back(std::make_pair(NK_O, _T("o"))); keys.push_back(std::make_pair(NK_P, _T("p"))); keys.push_back(std::make_pair(NK_J, _T("j"))); keys.push_back(std::make_pair(NK_K, _T("k"))); keys.push_back(std::make_pair(NK_L, _T("l"))); keys.push_back(std::make_pair(NK_SEMICOLON, _T(";"))); keys.push_back(std::make_pair(NK_M, _T("m"))); keys.push_back(std::make_pair(NK_COMMA, _T(","))); keys.push_back(std::make_pair(NK_PERIOD, _T("."))); keys.push_back(std::make_pair(NK_SLASH, _T("/"))); uint32 nbRows = GRID_NB_ROWS; uint32 nbCol = GRID_NB_COLUMNS; nuiGrid* pGrid = new nuiGrid(nbCol, nbRows); pGrid->SetObjectName(_T("SynthSoundsGrid")); pMainGrid->SetCell(1, 1, pGrid); NGL_ASSERT(keys.size() == nbRows * nbCol); for (uint32 r = 0; r < nbRows; r++) { for (uint32 c = 0; c < nbCol; c++) { uint32 index = r * nbCol + c; nglString text = keys[index].second; nuiButton* pButton = new nuiButton(text); mSynthSoundButtons.push_back(pButton); pButton->SetObjectName(_T("GridButton")); pGrid->SetCell(c, r, pButton); mEventSink.Connect(pButton->Activated, &MainWindow::OnSynthButtonActivated, (void*)index); nglString hotkeyName; nglString hotkeyDesc; hotkeyName.Format(_T("SynthSoundButton%d"), index); hotkeyDesc.Format(_T("PlaySynthSound%d"), index); RegisterHotKeyKey(hotkeyName, keys[index].first, nuiNoKey, false, false, hotkeyDesc); mEventSink.Connect(GetHotKeyEvent(hotkeyName), &MainWindow::OnSynthSoundHotKey, (void*)index); } } } }
bool ProjectGenerator::Make() { NGL_OUT(_T("nui project generator\n")); // create target directory nglPath targetpath = nglPath(mProjectTargetPath); if (!targetpath.Create()) { nglString msg; msg.Format(_T("creating target directory '%ls'"), targetpath.GetChars()); return MsgError(msg); } NGL_OUT(_T("nui project generator : target directory created '%ls'\n"), targetpath.GetChars()); //copy the src folder if (!CopyDirectory(targetpath + nglPath(_T("src")), mNuiTemplatePath + nglPath(_T("src")))) return false; //copy the resources folders if (!CopyDirectory(targetpath + nglPath(_T("resources")), mNuiTemplatePath + nglPath(_T("resources")))) return false; if (!CopyDirectory(targetpath + nglPath(_T("resources/css")), mNuiTemplatePath + nglPath(_T("resources/css")))) return false; if (!CopyDirectory(targetpath + nglPath(_T("resources/decorations")), mNuiTemplatePath + nglPath(_T("resources/decorations")))) return false; nglPath projpath; nglPath projectfile; nglString filename; // create xcodeproj folder if (mpCheckXcode->IsPressed()) { projpath = targetpath; nglString projfolder = mProjectName + nglString(_T(".xcodeproj")); projpath += nglPath(projfolder); if (!projpath.Create()) { nglString msg; msg.Format(_T("creating xcodeproj folder '%ls'"), projpath.GetChars()); return MsgError(msg); } NGL_OUT(_T("nui project generator : project folder created '%ls'\n"), projpath.GetChars()); // generate xcode project file projectfile = targetpath; projectfile += nglPath(projfolder); projectfile += nglPath(_T("project.pbxproj")); if (!GenerateFile(mNuiTemplatePath + nglPath(_T("TemplateApp.xcodeproj/project.pbxproj")), projectfile)) return false; } // generate visual studio 2008 project file if (mpCheckVisualStudio2008->IsPressed()) { filename = mProjectName + nglString(_T(".2008.vcproj")); projectfile = targetpath; projectfile += nglPath(filename); if (!GenerateFile(mNuiTemplatePath + nglPath(_T("TemplateApp.2008.vcproj")), projectfile)) return false; } // generate visual studio 2008 solution file if (mpCheckVisualStudio2008->IsPressed()) { filename = mProjectName + nglString(_T(".2008.sln")); projectfile = targetpath; projectfile += nglPath(filename); if (!GenerateFile(mNuiTemplatePath + nglPath(_T("TemplateApp.2008.sln")), projectfile)) return false; } // generate Info.plist if (mpCheckXcode->IsPressed()) { filename = mProjectName + nglString(_T(".plist")); projectfile = targetpath; projectfile += nglPath(filename); if (!GenerateFile(mNuiTemplatePath + nglPath(_T("TemplateApp.plist")), projectfile)) return false; } // generate iPhone Info.plist if (mpCheckXcode->IsPressed()) { filename = mProjectName + nglString(_T("-iPhone.plist")); projectfile = targetpath; projectfile += nglPath(filename); if (!GenerateFile(mNuiTemplatePath + nglPath(_T("TemplateApp-iPhone.plist")), projectfile)) return false; } // generate resource.rc filename = _T("resource.rc"); projectfile = targetpath; projectfile += nglPath(filename); if (!GenerateFile(mNuiTemplatePath + nglPath(_T("resource.rc")), projectfile)) return false; nglString msg; msg.Format(_T("nui project '%ls' successfully generated!"), mProjectName.GetChars()); nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK); pMessageBox->QueryUser(); return true; }
bool nuiFileTree::SetRootPath(const nglPath& rPath) { mRootPath = rPath; mEventSink.DisconnectAll(); if (mpFileBox) mpFileBox->Trash(); mpFileBox = new nuiVBox(2); mpFileBox->SetExpand(nuiExpandShrinkAndGrow); AddChild(mpFileBox); mpFileBox->SetCellMinPixels(0, FIRST_ROW_HEIGHT); mpScrollView = new nuiScrollView(true,true); mpFileBox->SetCell(1, mpScrollView); mpFileBox->SetCellExpand(1, nuiExpandShrinkAndGrow); if (rPath == nglPath(ROOTPATH_ALLVOLUMES)) { mpFileBox->SetCell(0, NULL); nuiTreeNodePtr pRoot = new nuiTreeNode(ROOTPATH_ALLVOLUMES); pRoot->Open(true); mpTreeView = new nuiTreeView(pRoot, false); mpTreeView->SetDeSelectable(false); mpTreeView->SetMultiSelectable(true); mpScrollView->AddChild(mpTreeView); std::list<nglPathVolume> volumes; nglPath::GetVolumes(volumes, nglPathVolume::All); std::list<nglPathVolume>::iterator it = volumes.begin(); std::list<nglPathVolume>::iterator end = volumes.end(); while (it != end) { const nglPathVolume vol(*it); nuiTreeNodePtr pNode = GetNewNode(vol.mPath); pRoot->AddChild(pNode); ++it; } mpTreeView->SetDragStartDelegate(nuiMakeDelegate(this, &nuiFileTree::OnDragStartDelegate)); mpTreeView->SetDragRequestDataDelegate(nuiMakeDelegate(this, &nuiFileTree::OnDragRequestDataDelegate)); mpTreeView->SetDragStopDelegate(nuiMakeDelegate(this, &nuiFileTree::OnDragStopDelegate)); return true; } // "go to parent folder" link nuiButton* pBtn = new nuiButton(); pBtn->SetPosition(nuiLeft); pBtn->SetObjectClass(_T("nuiFileTree::ParentFolderButton")); pBtn->SetObjectName(_T("nuiFileTree::ParentFolderButton")); pBtn->InvalidateLayout(); nuiImage* pIcon = new nuiImage(); pIcon->SetObjectName(_T("nuiFileTree::ParentFolderIcon")); pIcon->SetObjectClass(_T("nuiFileTree::ParentFolderIcon")); pBtn->AddChild(pIcon); // connect link to event mEventSink.Connect(pBtn->Activated, &nuiFileTree::OnGotoParentFolder); mpFileBox->SetCell(0, pBtn); nuiTreeNodePtr pNode = GetNewNode(rPath); if (pNode) { nuiTreeNodePtr pRoot = new nuiTreeNode(_T("HiddenRoot")); pRoot->AddChild(pNode); pRoot->Open(true); pNode->Open(true); mpTreeView = new nuiTreeView(pRoot, false); mpTreeView->SetDeSelectable(false); mpScrollView->AddChild(mpTreeView); } mpTreeView->SetDragStartDelegate(nuiMakeDelegate(this, &nuiFileTree::OnDragStartDelegate)); mpTreeView->SetDragRequestDataDelegate(nuiMakeDelegate(this, &nuiFileTree::OnDragRequestDataDelegate)); mpTreeView->SetDragStopDelegate(nuiMakeDelegate(this, &nuiFileTree::OnDragStopDelegate)); return true; }
void ProjectGenerator::OnGenerateButton(const nuiEvent& rEvent) { nglString source = mpNuiSource->GetText(); nglString target = mpProjectTarget->GetText(); source.Trim(); target.Trim(); if ((source == nglString::Null) || (target == nglString::Null)) { nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), _T("Project Creator"), _T("source and target information can't be empty!"), eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } nglPath sourcePath(source); if (!sourcePath.Exists()) { nglString msg; msg.Format(_T("the nui source directory '%ls' does not exist!"), sourcePath.GetChars()); nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } if (!mNuiCheckProjectFile || !mNuiCheckTools) { nglString msg; msg.Format(_T("Parts of nui could not be found.\nCheck the nui source directory or checkout the complete nui sources from libnui.net!")); nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } mNuiSourcePath = source; mProjectTargetPath = target; nglPath path = nglPath(target); mProjectName = path.GetNodeName(); nglPath targetPath(target); nglString xcodeproj = mProjectName + _T(".xcodeproj"); targetPath += nglPath(xcodeproj); if (targetPath.Exists()) { nglString msg; msg.Format(_T("the following project exists already!\n'%ls'"), targetPath.GetChars()); nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } GetPreferences().Save(); Make(); rEvent.Cancel(); }
void ProjectGenerator::OnBrowseSource(const nuiEvent& rEvent) { mNuiSourcePath.Trim(); if (mNuiSourcePath == nglString::Null) { nglPath path(ePathUser); mNuiSourcePath = path.GetPathName(); } nuiDialogSelectDirectory* pDialog = new nuiDialogSelectDirectory(GetMainWindow(), _T("SELECT THE NUI SOURCE DIRECTORY"), mNuiSourcePath, nglPath(_T("/"))); mEventSink.Connect(pDialog->DirectorySelected, &ProjectGenerator::OnSourceSelected, (void*)pDialog); rEvent.Cancel(); return; }
int nglApplication::WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { if (!SysInit(hInstance)) return 1; nglString module, s; nglChar buffer[BUFSIZE + 1]; GetModuleFileName(GetModuleHandle(NULL), buffer, BUFSIZE); buffer[BUFSIZE] = 0; module = buffer; // Fetch application's name (mName) from module name s = module; int i = s.FindLast (_T('\\')); if (i != -1) s.DeleteLeft (i + 1); SetName(s); // Fetch application's executable path SetPath(nglPath(module).GetAbsolutePath()); // Get application user args ParseCmdLine(lpCmdLine); #if 0 int res = 0; int format = -1; // Create a dummy context to be able to query ARB's wglChoosePixelFormatARB PIXELFORMATDESCRIPTOR pfd; pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_ACCELERATED; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 0; // FIXME pfd.cRedBits = 0; pfd.cRedShift = 0; pfd.cGreenBits = 0; pfd.cGreenShift = 0; pfd.cBlueBits = 0; pfd.cBlueShift = 0; pfd.cAlphaBits = 0; pfd.cAlphaShift = 0; pfd.cAccumBits = 0; pfd.cAccumRedBits = 0; pfd.cAccumGreenBits = 0; pfd.cAccumBlueBits = 0; pfd.cAccumAlphaBits = 0; pfd.cDepthBits = 0; pfd.cStencilBits = 0; pfd.cAuxBuffers = 0; pfd.iLayerType = 0; pfd.bReserved = 0; pfd.dwLayerMask = 0; pfd.dwVisibleMask = 0; pfd.dwDamageMask = 0; WNDCLASS wc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = NULL; wc.lpszMenuName = NULL; wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC; wc.hbrBackground = NULL; wc.lpfnWndProc = &::DefWindowProc; wc.lpszClassName = NGL_CONTEXT_CLASS; if (!RegisterClass( &wc )) { NGL_DEBUG( OutputDebugString(_T("NGL: error: unable to create ") NGL_CONTEXT_CLASS _T(" window class\n")); ) return false;
void ProjectGenerator::OnTimerTick(const nuiEvent& rEvent) { mpTimer->Stop(); // check if nui3 project file has been found nglString text = mpNuiSource->GetText(); text.Trim(); nglPath path(text); nglPath proj = path; proj += nglPath(_T("nui3.xcodeproj")); bool allOK = true; if (proj.Exists()) { mNuiCheckProjectFile = true; mpNuiCheckProjectFile->SetText(_T("found")); mpNuiCheckProjectFile->SetColor(eNormalTextFg, nuiColor(_T("green"))); allOK &= true; } else { mNuiCheckProjectFile = false; mpNuiCheckProjectFile->SetText(_T("not found!")); mpNuiCheckProjectFile->SetColor(eNormalTextFg, nuiColor(_T("red"))); allOK &= false; } // check if nui3 tool has been found (make_rc.py is taken as a reference) nglPath tool = path; tool += nglPath(_T("tools/make_rc.py")); if (tool.Exists()) { mNuiCheckTools = true; mpNuiCheckTools->SetText(_T("found")); mpNuiCheckTools->SetColor(eNormalTextFg, nuiColor(_T("green"))); allOK &= true; } else { mNuiCheckTools = false; mpNuiCheckTools->SetText(_T("not found!")); mpNuiCheckTools->SetColor(eNormalTextFg, nuiColor(_T("red"))); allOK &= false; } nglPath templatePath = path; templatePath += nglPath(_T("tools/TemplateApp/TemplateApp.xcodeproj")); if (templatePath.Exists()) { mNuiCheckTemplate = true; mpNuiCheckTemplate->SetText(_T("found")); mpNuiCheckTemplate->SetColor(eNormalTextFg, nuiColor(_T("green"))); allOK &= true; } else { mNuiCheckTemplate = false; mpNuiCheckTemplate->SetText(_T("not found!")); mpNuiCheckTemplate->SetColor(eNormalTextFg, nuiColor(_T("red"))); allOK &= false; } if (allOK) mpIconSourceDirectory->SetObjectName(_T("Icon::SourceDirectory")); else mpIconSourceDirectory->SetObjectName(_T("Icon::SourceDirectory::Disabled")); // compute nui relative path to project mNuiRelativeSource = nglPath(mpNuiSource->GetText()); mNuiRelativeSource.MakeRelativeTo(nglPath(mpProjectTarget->GetText())); mpNuiRelativeSource->SetText(mNuiRelativeSource.GetPathName()); mNuiTemplatePath = nglPath(mpNuiSource->GetText()); mNuiTemplatePath += nglPath(_T("tools/TemplateApp")); rEvent.Cancel(); }
MainWindow::MainWindow(const nglContextInfo& rContextInfo, const nglWindowInfo& rInfo, bool ShowFPS, const nglContext* pShared ) : nuiMainWindow(rContextInfo, rInfo, pShared, nglPath(ePathCurrent)), mEventSink(this) { SetDebugMode(true); LoadCSS(_T("rsrc:/css/main.css")); }
bool nuiImageDecoration::Load(const nuiXMLNode* pNode) { mClientRect.SetValue(nuiGetString(pNode, _T("ClientRect"), _T("{0,0,0,0}"))); mpTexture = nuiTexture::GetTexture(nglPath(nuiGetString(pNode, _T("Texture"), nglString::Empty))); return true; }
void Generator::OnStart(const nuiEvent& rEvent) { // check tool mTool = nglPath(mpToolLabel->GetText()); if (!mTool.Exists() || !mTool.IsLeaf()) { nuiMessageBox* pBox = new nuiMessageBox((nuiMainWindow*)GetMainWindow(), _T("oups"), _T("the generator tool command line path is not valid."), eMB_OK); pBox->QueryUser(); return; } // check source directory nglPath source(mpSourceLabel->GetText()); nglPath pngSource = source + nglPath(_T("png")); if (!source.Exists() || source.IsLeaf() || !pngSource.Exists() || pngSource.IsLeaf()) { nuiMessageBox* pBox = new nuiMessageBox((nuiMainWindow*)GetMainWindow(), _T("oups"), _T("the graphic resources path is not valid.\nIt must contain a 'png' folder,\nwith all the graphic resources inside."), eMB_OK); pBox->QueryUser(); return; } GetApp()->GetPreferences().SetPath(MAIN_KEY, _T("Tool"), mTool); GetApp()->GetPreferences().SetPath(MAIN_KEY, _T("Source"), source); // empty code source folder nglPath codeSource = source + nglPath(_T("src")); if (codeSource.Exists()) { nglString cmd; cmd.Format(_T("rm -rf %ls/*"), codeSource.GetChars()); system(cmd.GetStdString().c_str()); } // else create the folder else codeSource.Create(); // delete "includer file" nglPath includeSource = nglPath(source.GetChars() + nglString(_T(".h"))); if (includeSource.Exists()) { nglString cmd; cmd.Format(_T("rm %ls"), includeSource.GetChars()); system(cmd.GetStdString().c_str()); } // parse png file list ParsePngFiles(pngSource, pngSource, codeSource); //****************************************************************** // // create the "includer file" // nglPath HincluderPath = nglPath(source.GetPathName() + _T(".h")); nglPath CPPincluderPath = nglPath(source.GetPathName() + _T(".cpp")); char* includer_str = "/*\n" "NUI3 - C++ cross-platform GUI framework for OpenGL based applications\n" "Copyright (C) 2002-2003 Sebastien Metrot & Vincent Caron\n" "\n" "licence: see nui3/LICENCE.TXT\n" "*/\n" "\n" "\n"; nglString HincluderStr(includer_str); HincluderStr.Append(_T("#pragma once\n\n")); nglString CPPincluderStr(includer_str); CPPincluderStr.Append(_T("#include \"nui.h\"\n\n")); DumpIncluder(pngSource, pngSource,codeSource, HincluderPath, CPPincluderPath, HincluderStr, CPPincluderStr); // write the "includer file" on disk nglIOStream* ostream = HincluderPath.OpenWrite(); NGL_ASSERT(ostream); ostream->WriteText(HincluderStr); delete ostream; ostream = CPPincluderPath.OpenWrite(); NGL_ASSERT(ostream); ostream->WriteText(CPPincluderStr); delete ostream; nuiMessageBox* pBox = new nuiMessageBox((nuiMainWindow*)GetMainWindow(), _T("embed_graphics"), _T("process successfull!"), eMB_OK); pBox->QueryUser(); }
void Generator::OnBrowseSource(const nuiEvent& rEvent) { mTimer.Stop(); mTimerSink.Disconnect(mTimer.Tick, &Generator::OnBrowseSource); nuiDialogSelectDirectory* pDialog = new nuiDialogSelectDirectory((nuiMainWindow*)GetMainWindow(), _T("SELECT THE GRAPHIC RESOURCES DIRECTORY"), nglPath(ePathUser), nglPath(_T("/"))); mEventSink.Connect(pDialog->DirectorySelected, &Generator::OnSourceSelected, (void*)pDialog); pDialog->DoModal(); }
bool nglPath_SetVolume(nglPathVolume& rVolume, nglString& rMPoint, nglString& rDevice, nglString& rFSType, nglString& rOptions) { rVolume.mPath = nglPath(rMPoint); rVolume.mFlags = nglPathVolume::Offline; rVolume.mType = nglPathVolume::eTypeUnknown; if ((rMPoint == _T("none")) || (rMPoint == _T("/")) || (rMPoint == _T("/boot")) || (rMPoint == _T("/usr")) || (rMPoint == _T("/usr/local")) || (rMPoint == _T("/var")) || (rMPoint == _T("/tmp")) || (rMPoint == _T("/home"))) { rVolume.mFlags |= nglPathVolume::System; } if (!rDevice.Compare(_T("/dev/hd"), 0, 7)) { int controler = (rDevice[7] - 'a') / 2 + 1; int channel = (rDevice[7] - 'a') % 2; int partition = rDevice[8] - '0'; rVolume.mComment.Format(_T("%s on %d%s partition (%s on %d%s IDE controler)"), rFSType.GetChars(), partition, _intrank(partition), channel ? _T("slave") : _T("master"), controler, _intrank(controler)); } else if (!rDevice.Compare(_T("/dev/sd"), 0, 7)) { int dev = rDevice[7] - 'a'; int partition = rDevice[8] - '0'; rVolume.mComment.Format(_T("%s on %d%s partition (%d%s SCSI device)"), rFSType.GetChars(), partition, _intrank(partition), dev, _intrank(dev)); rVolume.mType = nglPathVolume::eTypeHD; } else if ((!rDevice.Compare(_T("/dev/sr"), 0, 7)) || (!rDevice.Compare(_T("/dev/sg"), 0, 7))) { int dev = rDevice[7] - '0' + 1; rVolume.mComment.Format(_T("%s (%d%s SCSI device)"), rFSType.GetChars(), dev, _intrank(dev)); rVolume.mFlags |= nglPathVolume::Removable; rVolume.mType = nglPathVolume::eTypeCD; } else if (!rDevice.Compare(_T("/dev/fd"), 0, 7)) { int dev = rDevice[7] - '0' + 1; rVolume.mComment.Format(_T("%d%s floppy"), dev, _intrank(dev)); rVolume.mFlags |= nglPathVolume::Removable; rVolume.mType = nglPathVolume::eTypeFloppy; } if (rFSType == _T("smbfs")) { rVolume.mComment.Format(_T("%s (SMB)"), rDevice.GetChars()); rVolume.mType = nglPathVolume::eTypeNetwork; } else if (rFSType == _T("nfs")) { rVolume.mComment.Format(_T("%s (NFS)"), rDevice.GetChars()); rVolume.mType = nglPathVolume::eTypeNetwork; } else if ((rFSType == _T("proc")) || (rFSType == _T("devfs")) || (rFSType == _T("usbdevfs")) || (rFSType == _T("devpts"))) { rVolume.mComment = rFSType; rVolume.mFlags |= nglPathVolume::System; } if (nglPath_IsRO(rOptions)) rVolume.mFlags |= nglPathVolume::ReadOnly; return true; }