// ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) { SelectDirDialog* pDlg = (SelectDirDialog*)pData; switch(uMsg) { case BFFM_INITIALIZED: { // sent immediately after initialisation and so we may set the // initial selection here // // wParam = TRUE => lParam is a string and not a PIDL ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)pDlg->GetPath().c_str()); SetWindowText(hwnd, pDlg->GetName().wx_str() ); if( (pDlg->GetSearchFile().IsEmpty() == FALSE) && wxFindFirstFile(pDlg->GetPath() + pDlg->GetSearchFile() ).IsEmpty() ) SendMessage(hwnd, BFFM_ENABLEOK, 0, 0); wxIcon icon; icon.CopyFromBitmap( pDlg->GetBitmap() ); if(icon.IsOk()) ::SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon.GetHICON()); } break; case BFFM_SELCHANGED: { // Set the status window to the currently selected path. wxString strDir; if ( SHGetPathFromIDList((LPITEMIDLIST)lp, wxStringBuffer(strDir, MAX_PATH)) ) { if( (pDlg->GetSearchFile().IsEmpty() == FALSE) && wxFindFirstFile(strDir+ pDlg->GetSearchFile()).IsEmpty() ) SendMessage(hwnd, BFFM_ENABLEOK, 0, 0); } } break; //case BFFM_VALIDATEFAILED: -- might be used to provide custom message // if the user types in invalid dir name } return 0; }
//--------------------------------------------------------------------------------------- void Paths::ClearTempFiles() { // When changing language a flag was stored so that at next run the program must // clean the temp folder. Otherwise, as books have the same names in all languages, // in Spanish, the new language .hcc and hhk files will not be properly loaded. // Here I test this flag and if true, remove all files in temp folder bool fClearTemp; wxConfigBase* pPrefs = m_appScope.get_preferences(); pPrefs->Read("/Locale/LanguageChanged", &fClearTemp, false ); if (fClearTemp) { wxString sFile = wxFindFirstFile(m_sTemp); while ( !sFile.empty() ) { if (!::wxRemoveFile(sFile)) { wxLogMessage("[Paths::LoadUserPreferences] Error deleting %s", sFile.wx_str() ); } sFile = wxFindNextFile(); } //reset flag fClearTemp = false; pPrefs->Write("/Locale/LanguageChanged", fClearTemp); } }
void FileFunctionsTestCase::FindFileNext() { // Construct file name containing ASCII characters only. const wxString fileMask(wxT("horse.*")); // Check using method 1. wxString foundFile1 = wxFindFirstFile(fileMask, wxFILE); wxString foundFile2 = wxFindNextFile(); wxFileName fn1(foundFile1); wxFileName fn2(foundFile2); // Full names must be different. CPPUNIT_ASSERT( foundFile1 != foundFile2 ); // Base names must be the same. CPPUNIT_ASSERT( fn1.GetName() == fn2.GetName() ); // Check using method 2. wxFileSystem fs; wxString furl = fs.FindFirst(fileMask, wxFILE); fn1 = wxFileSystem::URLToFileName(furl); foundFile1 = fn1.GetFullPath(); furl = fs.FindNext(); fn2 = wxFileSystem::URLToFileName(furl); foundFile2 = fn2.GetFullPath(); // Full names must be different. CPPUNIT_ASSERT( fn1.GetFullPath() != fn2.GetFullPath() ); // Base names must be the same. CPPUNIT_ASSERT( fn1.GetName() == fn2.GetName() ); }
StringList AbstractFileManager::directoryContents(const String& path, String extension, bool directories, bool files) { StringList result; if (!isDirectory(path) || !wxSetWorkingDirectory(path)) return result; if (!directories && !files) return result; int flags; if (directories && files) flags = 0; else if (directories) flags = wxDIR; else flags = wxFILE; String lowerExtension = Utility::toLower(extension); wxString filename = wxFindFirstFile("*", flags); while (!filename.empty()) { String stdFilename = filename.ToStdString(); bool matches = extension.empty() || Utility::toLower(pathExtension(stdFilename)) == lowerExtension; if (matches) result.push_back(pathComponents(stdFilename).back()); filename = wxFindNextFile(); } return result; }
void UpdateFS_src() { RenderingMethod* tmp; std::string ss; CT::iso->rendering_methods.clear(); rm_files.clear(); wxString f = wxFindFirstFile("RM/*.fs"); int i=0; while ( !f.empty() ) { tmp = new RenderingMethod(); ss = f; tmp->size.set(1,1); tmp->caption = ss; tmp->fs_filename = ss; tmp->pos = tmp->size * vec2(i%3,i/3) * (1.2); CT::iso->rendering_methods.push_back(tmp); rm_files.push_back(ss); f = wxFindNextFile(); i++; } CT::iso->SetCurRM(0); CT::iso->ReLoadShader(); /* if(!rendering_methods.size()) { wxMessageBox("Шейдеры не загружены: в папке RM нет файлов *.fs"); } */ }
void ArcApp::MakeFileList(NameMap& files) { DirTraverser traverser(files, *m_factory); for (size_t i = 0; i < m_args.size(); ++i) { #ifndef __WXMSW__ wxString name = m_args[i]; #else // on Windows expand wildcards wxString name = wxFindFirstFile(m_args[i], 0); if (name.empty()) wxLogError(_T("file not found '%s'"), m_args[i].c_str()); while (!name.empty()) { #endif // if the name is a directory recursively add all it's contents if (wxDirExists(name)) { if (traverser.OnDir(name) == wxDIR_CONTINUE) { wxDir dir(name); if (dir.IsOpened()) dir.Traverse(traverser); } } else { traverser.OnFile(name); } #ifdef __WXMSW__ name = wxFindNextFile(); } #endif } if (files.empty()) wxLogWarning(_T("nothing to do")); }
wxString wxLocalFSHandler::FindFirst(const wxString& spec, int flags) { wxFileName fn = wxFileSystem::URLToFileName(GetRightLocation(spec)); const wxString found = wxFindFirstFile(ms_root + fn.GetFullPath(), flags); if ( found.empty() ) return found; return wxFileSystem::FileNameToURL(found); }
void SpellCheckerConfig::DetectDictionaryPath() { wxArrayString dictPaths; dictPaths.Add(m_DictPath); Manager::Get()->GetMacrosManager()->ReplaceEnvVars(dictPaths[0]); if (platform::windows) { wxString programs = wxT("C:\\Program Files"); wxGetEnv(wxT("ProgramFiles"), &programs); dictPaths.Add(programs + wxT("\\Mozilla Firefox\\dictionaries")); dictPaths.Add(programs + wxT("\\Mozilla\\Firefox\\dictionaries")); dictPaths.Add(programs + wxT("\\Mozilla Thunderbird\\dictionaries")); dictPaths.Add(programs + wxT("\\Mozilla\\Thunderbird\\dictionaries")); wxString libreOffice = wxFindFirstFile(programs + wxT("\\*LibreOffice*"), wxDIR); wxString openOffice = wxFindFirstFile(programs + wxT("\\*OpenOffice*"), wxDIR); wxArrayString langs = GetArrayFromString(wxT("en;fr;es;de")); for (size_t i = 0; i < langs.GetCount(); ++i) { if (!libreOffice.IsEmpty()) dictPaths.Add(libreOffice + wxT("\\share\\extensions\\dict-") + langs[i]); if (!openOffice.IsEmpty()) dictPaths.Add(openOffice + wxT("\\share\\extensions\\dict-") + langs[i]); } } else { dictPaths.Add(wxT("/usr/share/hunspell")); dictPaths.Add(wxT("/usr/share/myspell/dicts")); dictPaths.Add(wxT("/usr/share/myspell")); } dictPaths.Add(m_pPlugin->GetOnlineCheckerConfigPath()); for (size_t i = 0; i < dictPaths.GetCount(); ++i) { if ( wxDirExists(dictPaths[i]) && !wxFindFirstFile(dictPaths[i] + wxFILE_SEP_PATH + wxT("*.dic"), wxFILE).IsEmpty() ) { if (i != 0) m_DictPath = dictPaths[i]; Manager::Get()->GetLogManager()->DebugLog(_T("Detected dict path: ") + m_DictPath); break; } } }
bool NativeFileSystem::ClearDir(const gd::String & directory) { wxString file = wxFindFirstFile( directory + "/*" ); while ( !file.empty() ) { wxRemoveFile( file ); file = wxFindNextFile(); } return true; }
int WinEDA_FindFrame::ExploreAllLibraries(const wxString & wildmask, wxString & FindList) /****************************************************************************************/ { wxString FullFileName; FILE * file; int nbitems = 0, LineNum = 0; char Line[2048], *name; FullFileName = MakeFileName(g_RealLibDirBuffer, wxT("*"), g_LibExtBuffer); FullFileName = wxFindFirstFile(FullFileName); while ( ! FullFileName.IsEmpty() ) { file = wxFopen(FullFileName, wxT("rt")); if (file == NULL) continue; while (GetLine(file, Line, &LineNum, sizeof(Line)) ) { if (strnicmp(Line, "DEF", 3) == 0) { /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */ strtok(Line, " \t\r\n"); name = strtok(NULL, " \t\r\n"); wxString st_name = CONV_FROM_UTF8(name); if( WildCompareString(wildmask, st_name, FALSE) ) { nbitems ++; if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); FindList << _("Found ") << CONV_FROM_UTF8(name) << _(" in lib ") << FullFileName; } } else if (strnicmp(Line, "ALIAS", 5) == 0) { /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */ strtok(Line, " \t\r\n"); while ( (name = strtok(NULL, " \t\r\n")) != NULL ) { wxString st_name = CONV_FROM_UTF8(name); if( WildCompareString( wildmask, st_name, FALSE) ) { nbitems ++; if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); FindList << _("Found ") << CONV_FROM_UTF8(name) << _(" in lib ") << FullFileName; } } } } fclose(file); FullFileName = wxFindNextFile(); } return nbitems; }
void XmlResApp::ParseParams(const wxCmdLineParser& cmdline) { flagGettext = cmdline.Found("g"); flagVerbose = cmdline.Found("v"); flagCPP = cmdline.Found("c"); flagPython = cmdline.Found("p"); flagH = flagCPP && cmdline.Found("e"); flagValidateOnly = cmdline.Found("validate-only"); flagValidate = flagValidateOnly || cmdline.Found("validate"); cmdline.Found("xrc-schema", &parSchemaFile); if (!cmdline.Found("o", &parOutput)) { if (flagGettext) parOutput = wxEmptyString; else { if (flagCPP) parOutput = wxT("resource.cpp"); else if (flagPython) parOutput = wxT("resource.py"); else parOutput = wxT("resource.xrs"); } } if (!parOutput.empty()) { wxFileName fn(parOutput); fn.Normalize(); parOutput = fn.GetFullPath(); parOutputPath = wxPathOnly(parOutput); } if (!parOutputPath) parOutputPath = wxT("."); if (!cmdline.Found("n", &parFuncname)) parFuncname = wxT("InitXmlResource"); for (size_t i = 0; i < cmdline.GetParamCount(); i++) { #ifdef __WINDOWS__ wxString fn=wxFindFirstFile(cmdline.GetParam(i), wxFILE); while (!fn.empty()) { parFiles.Add(fn); fn=wxFindNextFile(); } #else parFiles.Add(cmdline.GetParam(i)); #endif } }
const wxString SpellCheckerConfig::GetBitmapPath()const { wxString bitmPath = m_BitmPath; Manager::Get()->GetMacrosManager()->ReplaceEnvVars(bitmPath); if ( wxDirExists(bitmPath) && !wxFindFirstFile(bitmPath + wxFILE_SEP_PATH + wxT("*.png"), wxFILE).IsEmpty() ) { Manager::Get()->GetLogManager()->DebugLog(_T("Detected bitmap path: ") + bitmPath); return bitmPath; } Manager::Get()->GetLogManager()->DebugLog(_T("Current bitmap path: ") + m_pPlugin->GetOnlineCheckerConfigPath()); return m_pPlugin->GetOnlineCheckerConfigPath(); }
void SpellCheckerConfig::DetectThesaurusPath() { wxArrayString thesPaths; thesPaths.Add(m_ThesPath); Manager::Get()->GetMacrosManager()->ReplaceEnvVars(thesPaths[0]); if (platform::windows) { wxString programs = wxT("C:\\Program Files"); wxGetEnv(wxT("ProgramFiles"), &programs); wxString libreOffice = wxFindFirstFile(programs + wxT("\\*LibreOffice*"), wxDIR); wxString openOffice = wxFindFirstFile(programs + wxT("\\*OpenOffice*"), wxDIR); wxArrayString langs = GetArrayFromString(wxT("en;fr;es;de")); for (size_t i = 0; i < langs.GetCount(); ++i) { if (!libreOffice.IsEmpty()) thesPaths.Add(libreOffice + wxT("\\share\\extensions\\dict-") + langs[i]); if (!openOffice.IsEmpty()) thesPaths.Add(openOffice + wxT("\\share\\extensions\\dict-") + langs[i]); } } else { thesPaths.Add(wxT("/usr/share/myspell/dicts")); thesPaths.Add(wxT("/usr/share/mythes")); } thesPaths.Add(m_pPlugin->GetOnlineCheckerConfigPath()); for (size_t i = 0; i < thesPaths.GetCount(); ++i) { if ( wxDirExists(thesPaths[i]) && !wxFindFirstFile(thesPaths[i] + wxFILE_SEP_PATH + wxT("th*.dat"), wxFILE).IsEmpty() ) { if (i != 0) m_ThesPath = thesPaths[i]; Manager::Get()->GetLogManager()->DebugLog(_T("Detected thes path: ") + m_ThesPath); break; } } }
std::vector<gd::String> NativeFileSystem::ReadDir(const gd::String & path, const gd::String & extension) { std::vector<gd::String> results; wxString upperExt = wxString(extension).Upper(); wxString file = wxFindFirstFile( path + "/*" ); while ( !file.empty() ) { if ( upperExt.empty() || file.Upper().EndsWith(upperExt) ) results.push_back(file); file = wxFindNextFile(); } return results; }
void Thesaurus::SetFiles(wxString idxpath, const wxString datpath) { delete m_pT; m_pT = NULL; if ( wxFile::Exists(idxpath) && wxFile::Exists(datpath) ) { m_pT = new wxThes( idxpath, datpath ); } else { Manager::Get()->GetLogManager()->Log(_T("SpellChecker: Thesaurus files '") + idxpath + _T("' not found!")); if (!wxDirExists(idxpath.BeforeLast(wxFILE_SEP_PATH)) || !wxDirExists(datpath.BeforeLast(wxFILE_SEP_PATH))) return; // path does not exist, silence invalid directory warnings wxString altIdx = wxFindFirstFile(idxpath.BeforeLast(wxT('.')) + wxT("*.idx"), wxFILE); // "*_v2.idx" if (altIdx.IsEmpty()) // try again with more wildcards { altIdx = idxpath.AfterLast(wxFILE_SEP_PATH).BeforeLast(wxT('.')) + wxT("*.idx"); altIdx.Replace(wxT("_"), wxT("*")); altIdx.Replace(wxT("-"), wxT("*")); altIdx = wxFindFirstFile(idxpath.BeforeLast(wxFILE_SEP_PATH) + wxFILE_SEP_PATH + altIdx, wxFILE); } if (altIdx.IsEmpty()) // try to find the thesaurus of a related language (something is better than nothing) { altIdx = idxpath.AfterLast(wxFILE_SEP_PATH); altIdx.Replace(wxT("_"), wxT("*")); altIdx.Replace(wxT("-"), wxT("*")); altIdx = altIdx.BeforeLast(wxT('*')) + wxT("*.idx"); altIdx = wxFindFirstFile(idxpath.BeforeLast(wxFILE_SEP_PATH) + wxFILE_SEP_PATH + altIdx, wxFILE); } wxString altDat = wxFindFirstFile(datpath.BeforeLast(wxT('.')) + wxT("*.dat"), wxFILE); // "*_v2.dat" if (altDat.IsEmpty()) // try again with more wildcards { altDat = datpath.AfterLast(wxFILE_SEP_PATH).BeforeLast(wxT('.')) + wxT("*.dat"); altDat.Replace(wxT("_"), wxT("*")); altDat.Replace(wxT("-"), wxT("*")); altDat = wxFindFirstFile(datpath.BeforeLast(wxFILE_SEP_PATH) + wxFILE_SEP_PATH + altDat, wxFILE); } if (altDat.IsEmpty()) // try to find the thesaurus of a related language (something is better than nothing) { altDat = datpath.AfterLast(wxFILE_SEP_PATH); altDat.Replace(wxT("_"), wxT("*")); altDat.Replace(wxT("-"), wxT("*")); altDat = altDat.BeforeLast(wxT('*')) + wxT("*.dat"); altDat = wxFindFirstFile(datpath.BeforeLast(wxFILE_SEP_PATH) + wxFILE_SEP_PATH + altDat, wxFILE); } if (!altIdx.IsEmpty() && !altDat.IsEmpty() && wxFileExists(altIdx) && wxFileExists(altDat)) { m_pT = new wxThes(altIdx, altDat); Manager::Get()->GetLogManager()->Log(wxT("SpellChecker: Loading '") + altIdx + wxT("' instead...")); } } }
void LoadVSTPlugins() { wxString home = DirManager::GetHomeDir(); wxString pathChar = DirManager::GetPathChar(); wxString vstDirPath = home + pathChar + "vst"; wxString fname; fname = wxFindFirstFile((const char *) (vstDirPath + pathChar + "*.DLL")); while (fname != "") { HANDLE hLib = LoadLibrary(fname); if (hLib != NULL) { // get the address of the main() function vstPluginMain pDllMain = (vstPluginMain) GetProcAddress((HINSTANCE) hLib, "main"); if (pDllMain != NULL) { AEffect *theEffect; theEffect = (pDllMain) (audioMaster); if (theEffect->magic == kEffectMagic) { wxString title = wxFileNameFromPath(fname); int len = title.Len(); if (len > 4 && (title.Mid(len - 4) == ".DLL" || title.Mid(len - 4) == ".dll")) title = title.Mid(0, len - 4); VSTEffect *vst = new VSTEffect(title, theEffect); Effect::RegisterEffect(vst); } } audacityVSTID++; } else { FreeLibrary((HINSTANCE) hLib); } fname = wxFindNextFile(); } }
void DirManager::CleanTempDir() { wxString fname; wxStringList fnameList; int count = 0; // XXX: is this too destructive, to delete everything? fname = wxFindFirstFile((const char *) (temp + wxFILE_SEP_PATH + "b*")); while (fname != "") { count++; fnameList.Add(fname); fname = wxFindNextFile(); } wxChar **array = fnameList.ListToArray(); wxProgressDialog *progress = NULL; //wxYield(); wxStartTimer(); for (int i = 0; i < count; i++) { wxString fileName = array[i]; wxRemoveFile(fileName); if (!progress && wxGetElapsedTime(false) > 500) progress = new wxProgressDialog(_("Progress"), _("Cleaning up temporary files..."), 1000, NULL, wxPD_REMAINING_TIME | wxPD_AUTO_HIDE); if (progress) progress->Update(int ((i * 1000.0) / count)); } if (progress) delete progress; delete [] array; }
void DirManager::CleanTempDir() { wxString fname; wxStringList fnameList; int count=0; fname = wxFindFirstFile((const char *)(temp + pathChar + "*")); while (fname != "") { count++; fnameList.Add(fname); fname = wxFindNextFile(); } wxChar **array = fnameList.ListToArray(); for(int i=0; i<count; i++) { wxString fileName = array[i]; wxRemoveFile(fileName); } }
void DirManager::CleanTempDir() { wxString fname; wxStringList fnameList; int count = 0; fname = wxFindFirstFile((const char *) (temp + pathChar + "*.auf")); while (fname != "") { if (fname.Length() >= 5 && fname.Right(3) == "auf") { count++; fnameList.Add(fname); } fname = wxFindNextFile(); } wxChar **array = fnameList.ListToArray(); wxProgressDialog *progress = NULL; wxYield(); wxStartTimer(); for (int i = 0; i < count; i++) { wxString fileName = array[i]; wxRemoveFile(fileName); if (!progress && wxGetElapsedTime(false) > 500) progress = new wxProgressDialog("Progress", "Cleaning up temporary files...", 1000, NULL, wxPD_REMAINING_TIME | wxPD_AUTO_HIDE); if (progress) progress->Update(int ((i * 1000.0) / count)); } if (progress) delete progress; }
void PathFinder::AddPaths(const String & ipathlist, bool recursive, bool prepend) { char *work = new char[ipathlist.length()+1]; char *found, *save_ptr; String tmp; String subdirList = wxEmptyString; MOcheck(); wxStrcpy(work,ipathlist.c_str()); found = wxStrtok(work, PATHFINDER_DELIMITER, &save_ptr); while(found) { if(prepend) pathList.push_front(found); else pathList.push_back(found); if(recursive && IsDir(found)) // look for subdirectories { tmp = String(found) + ANYFILE; wxString nextfile = wxFindFirstFile(tmp.c_str(), wxDIR); while ( !nextfile.empty() ) { if(IsDir(nextfile)) { if(subdirList.length() > 0) subdirList += _T(":"); subdirList = subdirList + String(nextfile); } nextfile = wxFindNextFile(); } } found = wxStrtok(NULL, PATHFINDER_DELIMITER, &save_ptr); } delete[] work; if(subdirList.length() > 0) AddPaths(subdirList, recursive); }
int cellSysCacheClear(void) { //if some software expects CELL_SYSCACHE_ERROR_NOTMOUNTED we need to check whether //it was mounted before, for that we would need to save the state which I don't know //where to put wxString localPath; Emu.GetVFS().GetDevice(wxString("/dev_hdd1/cache/"), localPath); if (wxDirExists(localPath)){ WxDirDeleteTraverser deleter; wxString f = wxFindFirstFile(localPath+"\\*",wxDIR); while (!f.empty()) { wxDir dir(f); dir.Traverse(deleter); f = wxFindNextFile(); } return CELL_SYSCACHE_RET_OK_CLEARED; } else{ return CELL_SYSCACHE_ERROR_ACCESS_ERROR; } }
// static void AudacityApp::FindFilesInPathList(wxString pattern, wxArrayString pathList, int flags, wxArrayString &results) { wxLogNull nolog; if (pattern == wxT("")) return; for(unsigned i=0; i<pathList.GetCount(); i++) { wxString path = pathList[i]; wxString fname = wxFindFirstFile(path + wxFILE_SEP_PATH + pattern); while(fname != wxT("")) { results.Add(fname); fname = wxFindNextFile(); } } }
void FileFunctionsTestCase::DoFindFile(const wxString& filePath) { const wxString msg = wxString::Format(wxT("File: %s"), filePath.c_str()); const char *pUnitMsg = (const char*)msg.mb_str(wxConvUTF8); // Create temporary file. wxTextFile file; CPPUNIT_ASSERT_MESSAGE( pUnitMsg, file.Create(filePath) ); CPPUNIT_ASSERT_MESSAGE( pUnitMsg, file.Close() ); // Check if file can be found (method 1). wxString foundFile = wxFindFirstFile(filePath, wxFILE); CPPUNIT_ASSERT_MESSAGE( pUnitMsg, foundFile == filePath ); // Check if file can be found (method 2). wxFileSystem fs; wxString furl = fs.FindFirst(filePath, wxFILE); wxFileName fname = wxFileSystem::URLToFileName(furl); foundFile = fname.GetFullPath(); CPPUNIT_ASSERT_MESSAGE( pUnitMsg, foundFile == filePath ); wxRemoveFile(filePath); }
bool wxvbamApp::OnInit() { // use consistent names for config SetAppName(_("vbam")); #if (wxMAJOR_VERSION >= 3) SetAppDisplayName(_T("VisualBoyAdvance-M")); #endif // load system default locale, if available locale.Init(); locale.AddCatalog(_T("wxvbam")); // make built-in xrc file available // this has to be done before parent OnInit() so xrc dump works wxFileSystem::AddHandler(new wxMemoryFSHandler); wxFileSystem::AddHandler(new wxArchiveFSHandler); wxMemoryFSHandler::AddFileWithMimeType(wxT("wxvbam.xrs"), builtin_xrs, sizeof(builtin_xrs), wxT("application/zip")); if (!wxApp::OnInit()) return false; // prepare for loading xrc files wxXmlResource* xr = wxXmlResource::Get(); // note: if linking statically, next 2 pull in lot of unused code // maybe in future if not wxSHARED, load only builtin-needed handlers xr->InitAllHandlers(); wxInitAllImageHandlers(); get_config_path(config_path); // first, load override xrcs // this can only override entire root nodes // 2.9 has LoadAllFiles(), but this is 2.8, so we'll do it manually wxString cwd = wxGetCwd(); for (int i = 0; i < config_path.size(); i++) if (wxDirExists(config_path[i]) && wxSetWorkingDirectory(config_path[i])) { // *.xr[cs] doesn't work (double the number of scans) // 2.9 gives errors for no files found, so manual precheck needed // (yet another double the number of scans) if (!wxFindFirstFile(wxT("*.xrc")).empty()) xr->Load(wxT("*.xrc")); if (!wxFindFirstFile(wxT("*.xrs")).empty()) xr->Load(wxT("*.xrs")); } wxFileName xrcDir(GetConfigurationPath() + wxT("//xrc"), wxEmptyString); if (xrcDir.DirExists() && wxSetWorkingDirectory(xrcDir.GetFullPath()) && !wxFindFirstFile(wxT("*.xrc")).empty()) { xr->Load(wxT("*.xrc")); } else { // finally, load built-in xrc xr->Load(wxT("memory:wxvbam.xrs")); } wxSetWorkingDirectory(cwd); // set up config file // this needs to be in a subdir to support other config as well // but subdir flag behaves differently 2.8 vs. 2.9. Oh well. // NOTE: this does not support XDG (freedesktop.org) paths #if defined(__WXMSW__) || defined(__APPLE__) wxFileName vbamconf(GetConfigurationPath(), _T("vbam.ini")); cfg = new wxFileConfig(wxT("vbam"), wxEmptyString, vbamconf.GetFullPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE); #else cfg = new wxFileConfig(wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString, // style = wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_SUBDIR); #endif // set global config for e.g. Windows font mapping wxFileConfig::Set(cfg); // yet another bug/deficiency in wxConfig: dirs are not created if needed // since a default config is always written, dirs are always needed // Can't figure out statically if using wxFileConfig w/o duplicating wx's // logic, so do it at run-time // wxFileConfig *f = wxDynamicCast(cfg, wxFileConfig); // wxConfigBase does not derive from wxObject!!! so no wxDynamicCast wxFileConfig* fc = dynamic_cast<wxFileConfig*>(cfg); if (fc) { wxFileName s(wxFileConfig::GetLocalFileName(GetAppName())); // at least up to 2.8.12, GetLocalFileName returns the dir if // SUBDIR is specified instead of actual file name // and SUBDIR only affects UNIX #if defined(__UNIX__) && !wxCHECK_VERSION(2,9,0) s.AppendDir(s.GetFullName()); #endif // only the path part gets created // note that 0777 is default (assumes umask will do og-w) s.Mkdir(0777, wxPATH_MKDIR_FULL); s = wxFileName::DirName(GetConfigurationPath()); s.Mkdir(0777, wxPATH_MKDIR_FULL); } load_opts(); // process command-line options for (int i = 0; i < pending_optset.size(); i++) { wxString p = pending_optset[i]; size_t eqat = p.find(wxT('=')); p[eqat] = 0; opt_set(p.c_str(), p.c_str() + eqat + 1); } pending_optset.clear(); wxFileName vba_over(GetConfigurationPath(), wxT("vba-over.ini")); wxFileName rdb(GetConfigurationPath(), wxT("Nintendo - Game Boy Advance*.dat")); wxFileName scene_rdb(GetConfigurationPath(), wxT("Nintendo - Game Boy Advance (Scene)*.dat")); wxFileName nointro_rdb(GetConfigurationPath(), wxT("Official No-Intro Nintendo Gameboy Advance Number (Date).xml")); wxString f = wxFindFirstFile(nointro_rdb.GetFullPath(), wxFILE); if (!f.empty() && wxFileName(f).IsFileReadable()) rom_database_nointro = f; f = wxFindFirstFile(scene_rdb.GetFullPath(), wxFILE); if (!f.empty() && wxFileName(f).IsFileReadable()) rom_database_scene = f; f = wxFindFirstFile(rdb.GetFullPath(), wxFILE); while (!f.empty()) { if (f == rom_database_scene.GetFullPath()) { f = wxFindNextFile(); } else if (wxFileName(f).IsFileReadable()) { rom_database = f; break; } } // load vba-over.ini // rather than dealing with wxConfig's broken search path, just use // the same one that the xrc overrides use // this also allows us to override a group at a time, add commments, and // add the file from which the group came wxMemoryInputStream mis(builtin_over, sizeof(builtin_over)); overrides = new wxFileConfig(mis); wxRegEx cmtre; // not the most efficient thing to do: read entire file into a string // just to parse the comments out wxString bovs((const char*)builtin_over, wxConvUTF8, sizeof(builtin_over)); bool cont; wxString s; long grp_idx; #define CMT_RE_START wxT("(^|[\n\r])# ?([^\n\r]*)(\r?\n|\r)\\[") for (cont = overrides->GetFirstGroup(s, grp_idx); cont; cont = overrides->GetNextGroup(s, grp_idx)) { // apparently even MacOSX sometimes uses the old \r by itself wxString cmt(CMT_RE_START); cmt += s + wxT("\\]"); if (cmtre.Compile(cmt) && cmtre.Matches(bovs)) cmt = cmtre.GetMatch(bovs, 2); else cmt = wxEmptyString; overrides->Write(s + wxT("/comment"), cmt); } if (vba_over.FileExists()) { wxStringOutputStream sos; wxFileInputStream fis(vba_over.GetFullPath()); // not the most efficient thing to do: read entire file into a string // just to parse the comments out fis.Read(sos); // rather than assuming the file is seekable, use the string we just // read as an input stream wxStringInputStream sis(sos.GetString()); wxFileConfig ov(sis); for (cont = ov.GetFirstGroup(s, grp_idx); cont; cont = ov.GetNextGroup(s, grp_idx)) { overrides->DeleteGroup(s); overrides->SetPath(s); ov.SetPath(s); overrides->Write(wxT("path"), GetConfigurationPath()); // apparently even MacOSX sometimes uses \r by itself wxString cmt(CMT_RE_START); cmt += s + wxT("\\]"); if (cmtre.Compile(cmt) && cmtre.Matches(sos.GetString())) cmt = cmtre.GetMatch(sos.GetString(), 2); else cmt = wxEmptyString; overrides->Write(wxT("comment"), cmt); long ent_idx; for (cont = ov.GetFirstEntry(s, ent_idx); cont; cont = ov.GetNextEntry(s, ent_idx)) overrides->Write(s, ov.Read(s, wxEmptyString)); ov.SetPath(wxT("/")); overrides->SetPath(wxT("/")); } } // create the main window frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame); if (!frame) { wxLogError(_("Could not create main window")); return false; } // Create() cannot be overridden easily if (!frame->BindControls()) return false; frame->Show(true); return true; }
StyleDialog::StyleDialog ( wxWindow *parent, wxIcon icon, const std::string& bufferParameterUtf8, const wxString& fileNameParameter, const wxString& ruleSetDirectoryParameter, const wxString& filterDirectoryParameter, const wxString& ruleSetPresetParameter, const wxString& filterPresetParameter, #if !defined(USE_ENCHANT) && defined(__WXMSW__) const wxString& aspellDataPathParameter, const wxString& aspellDictPathParameter, #endif int typeParameter, bool readOnlyParameter, wxPoint position, wxSize size ) : wxDialog ( parent, wxID_ANY, wxString ( ( typeParameter == ID_TYPE_STYLE) ? _ ( "Style" ) : _ ( "Spelling" ) ), position, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX ), indexForContextMenu ( -1 ), bufferUtf8 ( bufferParameterUtf8 ), #if !defined(USE_ENCHANT) && defined(__WXMSW__) aspellDataPath ( aspellDataPathParameter ), aspellDictPath ( aspellDictPathParameter ), #endif fileName ( fileNameParameter ), ruleSetDirectory ( ruleSetDirectoryParameter ), filterDirectory ( filterDirectoryParameter ), ruleSetPreset ( ruleSetPresetParameter ), filterPreset ( filterPresetParameter ), type(typeParameter), readOnly ( readOnlyParameter ) { SetIcon ( icon ); // top box ruleSetCombo = new wxComboBox ( this, ID_STYLE_COMBO_RULESET, _T ( "" ), wxDefaultPosition, wxSize ( 200, -1 ) ); int width, height; ruleSetCombo->GetSize ( &width, &height ); wxSize buttonSize ( 100, height ); filterCombo = new wxComboBox ( this, ID_STYLE_COMBO_FILTER, _T ( "" ), wxDefaultPosition, wxSize ( 200, -1 ) ); //if (type != ID_TYPE_STYLE) // from v. 1.1.0.7: never show filterCombo->Show ( false ); wxButton *createReportButton = new wxButton ( this, ID_STYLE_REPORT, _ ( "&Check" ), wxDefaultPosition, buttonSize, 0 ); wxBoxSizer *comboSizer = new wxBoxSizer ( wxHORIZONTAL ); comboSizer->Add ( ruleSetCombo, 0, wxRIGHT, 10 ); comboSizer->Add ( filterCombo, 0, wxRIGHT, 10 ); comboSizer->Add ( createReportButton, 0, wxRIGHT, 10 ); // middle box wxListCtrl *myTable = new wxListCtrl ( this, ID_STYLE_TABLE, wxPoint ( 0, 0 ), wxSize ( -1, -1 ), wxLC_REPORT ); int widthUnit = 35; myTable->InsertColumn ( 0, _ ( "No." ), wxLIST_FORMAT_LEFT, widthUnit * 1 ); myTable->InsertColumn ( 1, _ ( "Context" ), wxLIST_FORMAT_RIGHT, widthUnit * 3 ); myTable->InsertColumn ( 2, _ ( "Error" ), wxLIST_FORMAT_CENTER, widthUnit * 3 ); myTable->InsertColumn ( 3, _ ( "Context" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); myTable->InsertColumn ( 4, _ ( "Suggestion" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); myTable->InsertColumn ( 5, _ ( "Rule" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); myTable->InsertColumn ( 6, _ ( "Action" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); table = myTable; // lower box wxButton *editItemsButton = new wxButton ( this, ID_STYLE_EDIT, _ ( "&Apply changes" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *webReportButton = new wxButton ( this, ID_STYLE_WEB_REPORT, _ ( "&Printable report" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *webSummaryButton = new wxButton ( this, ID_STYLE_WEB_SUMMARY, _ ( "Pr&intable summary" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *selectAllButton = new wxButton ( this, ID_STYLE_CHANGE_ALL, _ ( "C&hange all" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *deselectAllButton = new wxButton ( this, ID_STYLE_IGNORE_ALL, _ ( "I&gnore all" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *cancelButton = new wxButton ( this, wxID_CANCEL, _ ( "Ca&ncel" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxBoxSizer *reportButtonSizer = new wxBoxSizer ( wxHORIZONTAL ); reportButtonSizer->Add ( editItemsButton, 0, wxRIGHT, 10 ); reportButtonSizer->Add ( webReportButton, 0, wxLEFT | wxRIGHT, 10 ); reportButtonSizer->Add ( webSummaryButton, 0, wxRIGHT, 10 ); reportButtonSizer->Add ( selectAllButton, 0, wxLEFT | wxRIGHT, 10 ); reportButtonSizer->Add ( deselectAllButton, 0, wxRIGHT, 10 ); reportButtonSizer->Add ( cancelButton, 0, wxLEFT, 10 ); // status bar status = new wxStatusBar ( this, wxID_ANY ); // overall sizer wxBoxSizer *reportTopSizer = new wxBoxSizer ( wxVERTICAL ); reportTopSizer->Add ( comboSizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); reportTopSizer->Add ( table, 1, wxEXPAND | wxALL, 5 ); reportTopSizer->Add ( reportButtonSizer, 0, wxALL, 5 ); reportTopSizer->Add ( status, 0, wxEXPAND | wxALL ); this->SetSizer ( reportTopSizer ); createReportButton->SetFocus(); if ( readOnly ) filterCombo->Enable ( false ); // keyboard shortcuts wxAcceleratorEntry entries[7]; entries[0].Set ( wxACCEL_ALT, ( int ) 'C', ID_STYLE_REPORT ); entries[1].Set ( wxACCEL_ALT, ( int ) 'A', ID_STYLE_EDIT ); entries[2].Set ( wxACCEL_ALT, ( int ) 'W', ID_STYLE_WEB_REPORT ); entries[3].Set ( wxACCEL_ALT, ( int ) 'B', ID_STYLE_WEB_SUMMARY ); entries[4].Set ( wxACCEL_ALT, ( int ) 'H', ID_STYLE_CHANGE_ALL ); entries[5].Set ( wxACCEL_ALT, ( int ) 'I', ID_STYLE_IGNORE_ALL ); entries[6].Set ( wxACCEL_ALT, ( int ) 'N', wxID_CANCEL ); wxAcceleratorTable accel ( 7, entries ); this->SetAcceleratorTable ( accel ); // update combo lists // special case spellcheck if (type == ID_TYPE_SPELL) { #ifdef USE_ENCHANT EnchantBroker *broker = enchant_broker_init(); dictdetect adetected(ruleSetCombo); enchant_broker_list_dicts(broker, EnchantDictDescribe, &adetected); bool anyFound = !adetected.empty(); #else AspellConfig *config; AspellDictInfoList *dlist; AspellDictInfoEnumeration *dels; const AspellDictInfo *entry; config = new_aspell_config(); #ifdef __WXMSW__ aspell_config_replace ( config, "data-dir", aspellDataPath.mb_str() ); //ASPELL_DATA_PATH ); aspell_config_replace ( config, "dict-dir", aspellDictPath.mb_str() ); //ASPELL_DICT_PATH ); #endif dlist = get_aspell_dict_info_list( config ); delete_aspell_config ( config ); dels = aspell_dict_info_list_elements ( dlist ); bool anyFound = false; while ( ( entry = aspell_dict_info_enumeration_next ( dels ) ) != 0 ) { anyFound = true; std::string stdEntry = entry->name; wxString entry = wxString ( stdEntry.c_str(), wxConvUTF8, stdEntry.size() ); ruleSetCombo->Append ( entry ); } #endif if ( anyFound ) { if ( ruleSetPreset.empty() ) ruleSetPreset = _ ( "en_US" ); ruleSetCombo->SetValue ( ruleSetPreset ); } else { ruleSetCombo->Append ( _ ( "(No dictionaries found)" ) ); ruleSetCombo->Select ( 0 ); createReportButton->Enable ( false ); } return; } // all other branches if ( wxDirExists ( ruleSetDirectory ) ) { wxString ruleMask, ruleFile; ruleMask = ruleSetDirectory + wxFileName::GetPathSeparator() + _T ( "*.xml" ); ruleFile = wxFindFirstFile ( ruleMask, wxFILE ); if ( !ruleFile.empty() ) { ruleFile.Replace ( _T ( ".xml" ), _T ( "" ) ); ruleFile.Replace ( _T ( "_" ), _T ( " " ) ); ruleSetCombo->Append ( wxFileNameFromPath ( ruleFile ) ); for ( ;; ) { ruleFile = wxFindNextFile(); if ( ruleFile.empty() ) break; ruleFile.Replace ( _T ( ".xml" ), _T ( "" ) ); ruleFile.Replace ( _T ( "_" ), _T ( " " ) ); ruleSetCombo->Append ( wxFileNameFromPath ( ruleFile ) ); } } if ( ruleSetPreset.empty() ) ruleSetPreset = _ ( "Default" ); ruleSetCombo->SetValue ( ruleSetPreset ); } else { ruleSetCombo->Append ( _ ( "(No rule sets found)" ) ); ruleSetCombo->Select ( 0 ); } if ( wxDirExists ( filterDirectory ) ) { filterCombo->Append ( _ ( "(No filter)" ) ); wxString filterMask, filterFile; filterMask = filterDirectory + wxFileName::GetPathSeparator() + _T ( "*.xml" ); filterFile = wxFindFirstFile ( filterMask, wxFILE ); if ( !filterFile.empty() ) { filterFile.Replace ( _T ( ".xml" ), _T ( "" ) ); filterCombo->Append ( wxFileNameFromPath ( filterFile ) ); for ( ;; ) { filterFile = wxFindNextFile(); if ( filterFile.empty() ) break; filterFile.Replace ( _T ( ".xml" ), _T ( "" ) ); filterCombo->Append ( wxFileNameFromPath ( filterFile ) ); } } filterCombo->SetValue ( filterPreset ); } else { filterCombo->Append ( _ ( "(No filters found)" ) ); filterCombo->Select ( 0 ); } }
wxString wxLocalFSHandler::FindFirst(const wxString& spec, int flags) { wxFileName fn = wxFileSystem::URLToFileName(GetRightLocation(spec)); return wxFindFirstFile(ms_root + fn.GetFullPath(), flags); }
void dbUpgrade::BackupDB(const wxString& FileName, int BackupType, int FilesToKeep, int UpgradeVersion) { wxFileName fn(FileName); if (!fn.IsOk()) return; wxString BackupName = ""; // define string in backup filename switch (BackupType) { case BACKUPTYPE::START : BackupName = "_start_"; break; case BACKUPTYPE::CLOSE : BackupName = "_update_"; break; case BACKUPTYPE::VERSION_UPGRADE : BackupName = wxString::Format("_upgrade_v%i_", UpgradeVersion); break; default: break; } wxString backupFileName = FileName + BackupName + wxDateTime().Today().FormatISODate() + "." + fn.GetExt(); wxFileName fnBak(backupFileName); // process backup switch (BackupType) { case BACKUPTYPE::START: if (!fnBak.FileExists()) { wxCopyFile(FileName, backupFileName, true); } break; case BACKUPTYPE::CLOSE: wxCopyFile(FileName, backupFileName, true); break; case BACKUPTYPE::VERSION_UPGRADE: if (!fnBak.FileExists()) { wxCopyFile(FileName, backupFileName, true); } break; default: break; } // Cleanup old backups if (BackupType != BACKUPTYPE::VERSION_UPGRADE) { wxArrayString backupFileArray; wxString fileSearch = FileName + BackupName + "*." + fn.GetExt(); wxString backupFile = wxFindFirstFile(fileSearch); while (!backupFile.empty()) { backupFileArray.Add(backupFile); backupFile = wxFindNextFile(); } if (backupFileArray.Count() > (size_t)FilesToKeep) { backupFileArray.Sort(true); // ensure file is not read only before deleting file. wxFileName fnLastFile(backupFileArray.Last()); if (fnLastFile.IsFileWritable()) wxRemoveFile(backupFileArray.Last()); } } }
void SpringLobbyApp::CacheAndSettingsSetup() { SetSettingsStandAlone( false ); const wxString userConfigDir = GetConfigfileDir(); if ( sett().IsFirstRun() && !wxDirExists( userConfigDir ) ) { wxMkdir( userConfigDir ); } if ( (sett().GetCacheVersion() < CACHE_VERSION) && !sett().IsFirstRun() ) { sett().SetMapCachingThreadProgress( 0 ); // reset map cache thread sett().SetModCachingThreadProgress( 0 ); // reset mod cache thread if ( wxDirExists( sett().GetCachePath() ) ) { wxLogWarning( _T("erasing old cache ver %d (app cache ver %d)"), sett().GetCacheVersion(), CACHE_VERSION ); wxString file = wxFindFirstFile( sett().GetCachePath() + wxFILE_SEP_PATH + _T("*") ); while ( !file.empty() ) { wxRemoveFile( file ); file = wxFindNextFile(); } } } if ( !sett().IsFirstRun() ) { int settversion = sett().GetSettingsVersion(); if ( settversion < 3 ) { sett().ConvertOldSpringDirsOptions(); } if ( settversion < 4 ) { if ( sett().GetTorrentPort() == DEFSETT_SPRING_PORT ) sett().SetTorrentPort( DEFSETT_SPRING_PORT + 1 ); } if ( settversion < 5 ) { wxArrayString list = sett().GetServers(); int count = list.GetCount(); wxArrayString wordlist = sett().GetHighlightedWords(); for ( int i= 0; i < count; i++ ) { wxString nick = sett().GetServerAccountNick( list[i] ); if ( wordlist.Index( nick ) == -1 ) { wordlist.Add( nick ); } } sett().SetHighlightedWords( wordlist ); } if ( settversion < 6 ) { sett().ConvertOldServerSettings(); } if ( settversion < 7 ) { sett().AddChannelJoin( _T("springlobby"), _T("") ); } if ( settversion < 8 ) { sett().DeleteServer( _T("Backup server") ); sett().SetServer( _T("Backup server 1"), _T("springbackup1.servegame.com"), 8200 ); sett().SetServer( _T("Backup server 2"), _T("springbackup2.servegame.org"), 8200 ); sett().SetServer( _T("Test server"), _T("taspringmaster.servegame.com"), 8300 ); } if ( settversion < 10 ) { sett().ConvertOldColorSettings(); } if ( settversion < 11 ) { if( IsUACenabled() ) { usync().ReloadUnitSyncLib(); if ( usync().IsLoaded() ) usync().SetSpringDataPath(_T("")); // UAC is on, fix the spring data path } } if ( settversion < 12 ) { sett().ConvertOldChannelSettings(); } if ( settversion < 13 ) { sett().ConvertOldHiglightSettings(); } if ( settversion < 15 ) { sett().TranslateSavedColumWidths(); } if ( settversion < 21 ) { sett().RemoveLayouts(); } if ( settversion < 18 ) { //new downloader was introduced sett().ClearTorrentListToResume(); } if( settversion < 19 ) { //the dummy column hack was removed on win sett().NukeColumnWidths(); } if ( settversion < 22 ) { if ( m_translationhelper ) { // add locale's language code to autojoin if ( m_translationhelper->GetLocale() ) { wxString localecode = m_translationhelper->GetLocale()->GetCanonicalName(); if ( localecode.Find(_T("_")) != -1 ) localecode = localecode.BeforeFirst(_T('_')); if ( localecode == _T("en") ) // we'll skip en for now, maybe in the future we'll reactivate it sett().AddChannelJoin( localecode, _T("") ); } } } if ( settversion < 23 ) { sett().ConvertLists(); sett().AddKnownMatchmakerCPU(6667); } } if ( sett().ShouldAddDefaultServerSettings() || ( sett().GetSettingsVersion() < 14 && sett().GetServers().Count() < 2 ) ) sett().SetDefaultServerSettings(); if ( sett().ShouldAddDefaultChannelSettings() ) { sett().AddChannelJoin( _T("main"), _T("") ); sett().AddChannelJoin( _T("newbies"), _T("") ); if ( m_translationhelper ) { if ( m_translationhelper->GetLocale() ) { wxString localecode = m_translationhelper->GetLocale()->GetCanonicalName(); if ( localecode.Find(_T("_")) != -1 ) localecode = localecode.BeforeFirst(_T('_')); sett().AddChannelJoin( localecode, _T("") ); // add locale's language code to autojoin } } } if ( sett().ShouldAddDefaultGroupSettings() ) { sett().AddGroup( _("Default") ); sett().AddGroup( _("Ignore PM") ); useractions().ChangeAction( _("Ignore PM"), UserActions::ActIgnorePM ); sett().AddGroup( _("Ignore chat") ); useractions().ChangeAction( _("Ignore chat"), UserActions::ActIgnoreChat ); sett().AddGroup( _("Battle Autokick") ); useractions().ChangeAction( _("Battle Autokick"), UserActions::ActAutokick ); sett().AddGroup( _("Friends") ); useractions().ChangeAction( _("Friends"), UserActions::ActNotifBattle ); useractions().ChangeAction( _("Friends"), UserActions::ActHighlight ); useractions().ChangeAction( _("Friends"), UserActions::ActNotifLogin ); useractions().SetGroupColor( _("Friends"), wxColour( 0, 0, 255 ) ); } }
wxWindow* SettingDlg::CreateProjectPage(wxWindow *parent) { //validator: integer wxIntegerValidator<unsigned int> vald_int; wxStaticText* st; wxPanel *page = new wxPanel(parent); //project save wxBoxSizer *group1 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "Open/Save"), wxVERTICAL); m_prj_save_chk = new wxCheckBox(page, ID_PrjSaveChk, "Save project when capture viewport or export movie."); m_realtime_cmp_chk = new wxCheckBox(page, ID_RealtimeCmpChk, "Compress data in graphics memory when loading."); group1->Add(10, 5); group1->Add(m_prj_save_chk); group1->Add(10, 5); group1->Add(m_realtime_cmp_chk); group1->Add(10, 5); //font wxBoxSizer *group2 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "Render View Font and Size"), wxVERTICAL); wxBoxSizer *sizer2_1 = new wxBoxSizer(wxHORIZONTAL); st = new wxStaticText(page, 0, "Font:"); m_font_cmb = new wxComboBox(page, ID_FontCmb, "", wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY); //populate fonts std::string exePath = wxStandardPaths::Get().GetExecutablePath().ToStdString(); exePath = exePath.substr(0,exePath.find_last_of(std::string()+GETSLASH())); wxString loc = wxString(exePath) + GETSLASH() + wxString("Fonts") + GETSLASH() + wxString("*.ttf"); wxLogNull logNo; wxString file = wxFindFirstFile(loc); while (!file.empty()) { file = file.AfterLast(GETSLASH()); file = file.BeforeLast('.'); m_font_cmb->Append(file); file = wxFindNextFile(); } sizer2_1->Add(st); sizer2_1->Add(20, 10); sizer2_1->Add(m_font_cmb); sizer2_1->Add(20, 10); st = new wxStaticText(page, 0, "Size:"); m_font_size_cmb = new wxComboBox(page, ID_FontSizeCmb, "", wxDefaultPosition, wxSize(50, -1), 0, NULL, wxCB_READONLY); for (int font_size=10; font_size<31; font_size+=2) m_font_size_cmb->Append(wxString::Format("%d", font_size)); sizer2_1->Add(st); sizer2_1->Add(20, 10); sizer2_1->Add(m_font_size_cmb); group2->Add(10, 5); group2->Add(sizer2_1, 0, wxEXPAND); group2->Add(10, 5); st = new wxStaticText(page, 0, "Put TrueType font files into the \"Fonts\" folder.\n"\ "Restart FluoRender to load new font files."); group2->Add(st); group2->Add(10, 5); //script wxBoxSizer *group3 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "4D Script"), wxVERTICAL); m_run_script_chk = new wxCheckBox(page, ID_RunScriptChk, "Enable execution of a script on 4D data during playback."); st = new wxStaticText(page, 0, "Compose and save the text file \"script_4d.txt\" in the same folder as the\n"\ "4D data. See details in the user manual for the syntax of the script."); group3->Add(10, 5); group3->Add(m_run_script_chk); group3->Add(10, 5); group3->Add(st); group3->Add(10, 5); //paint history depth wxBoxSizer *group4 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "Paint History"), wxVERTICAL); wxBoxSizer *sizer4_1 = new wxBoxSizer(wxHORIZONTAL); m_paint_hist_depth_sldr = new wxSlider(page, ID_PaintHistDepthSldr, 0, 0, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL); m_paint_hist_depth_text = new wxTextCtrl(page, ID_PaintHistDepthText, "0", wxDefaultPosition, wxSize(40, 20), 0, vald_int); st = new wxStaticText(page, 0, "The number of undo steps for paint brush selection.\n" \ "Set the value to 0 to disable history.\n" \ "A value greater than 0 slows down speed and increases memory usage."); sizer4_1->Add(m_paint_hist_depth_sldr, 1, wxEXPAND); sizer4_1->Add(m_paint_hist_depth_text, 0, wxALIGN_CENTER); group4->Add(10, 5); group4->Add(sizer4_1, 0, wxEXPAND); group4->Add(10, 5); group4->Add(st); group4->Add(10, 5); wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL); sizerV->Add(10, 10); sizerV->Add(group1, 0, wxEXPAND); sizerV->Add(10, 10); sizerV->Add(group2, 0, wxEXPAND); sizerV->Add(10, 10); sizerV->Add(group3, 0, wxEXPAND); sizerV->Add(10, 10); sizerV->Add(group4, 0, wxEXPAND); page->SetSizer(sizerV); return page; }
void LoadVSTPlugins() { wxString home = DirManager::GetHomeDir(); wxString pathChar = DirManager::GetPathChar(); wxString vstDirPath = home + pathChar + "vst"; wxString fname; fname = wxFindFirstFile((const char *) (vstDirPath + pathChar + "*")); while (fname != "") { short resID; FSSpec spec; wxMacFilename2FSSpec(fname, &spec); resID = FSpOpenResFile(&spec, fsRdPerm); Handle codeH; int count = Count1Resources('aEff'); for (int i = 0; i < count; i++) { CFragConnectionID connID; Ptr mainAddr; Str255 errName; Str255 fragName; char fragNameCStr[256]; short resID; OSType resType; OSErr err; codeH = Get1IndResource('aEff', count); GetResInfo(codeH, &resID, &resType, fragName); DetachResource(codeH); HLock(codeH); err = GetMemFragment(*codeH, GetHandleSize(codeH), fragName, kPrivateCFragCopy, &connID, (Ptr *) & mainAddr, errName); if (err >= 0) { Ptr symbolAddress; CFragSymbolClass symbolClass; err = FindSymbol(connID, "\pmain", &symbolAddress, &symbolClass); if (!err) { vstPluginMain pluginMain = (vstPluginMain) symbolAddress; AEffect *theEffect; theEffect = pluginMain(audioMaster); if (theEffect->magic == kEffectMagic) { memcpy(fragNameCStr, &fragName[1], fragName[0]); fragNameCStr[fragName[0]] = 0; VSTEffect *vst = new VSTEffect(wxString(fragNameCStr), theEffect); Effect::RegisterEffect(vst); } } } else { HUnlock(codeH); } audacityVSTID++; // Don't HUnlock unless you don't want to keep it in memory } CloseResFile(resID); fname = wxFindNextFile(); } }