void OptionPage::OptionChoice(wxFlexGridSizer *flex, const wxString &name, const wxArrayString &choices, const char *opt_name) { parent->AddChangeableOption(opt_name); const auto opt = OPT_GET(opt_name); auto cb = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY | wxCB_DROPDOWN); Add(flex, name, cb); switch (opt->GetType()) { case agi::OptionType::Int: { int val = opt->GetInt(); cb->Select(val < (int)choices.size() ? val : 0); cb->Bind(wxEVT_COMBOBOX, IntCBUpdater(opt_name, parent)); break; } case agi::OptionType::String: { wxString val(to_wx(opt->GetString())); if (cb->FindString(val) != wxNOT_FOUND) cb->SetStringSelection(val); else if (!choices.empty()) cb->SetSelection(0); cb->Bind(wxEVT_COMBOBOX, StringUpdater(opt_name, parent)); break; } default: throw agi::InternalError("Unsupported type"); } }
void ParamsDialog::display_invalid_params(const wxArrayString& params) { if (params.empty()) return; wxString msg = "The following parameters are invalid.\n"; wxArrayString::const_iterator it; for (it = params.begin(); it != params.end(); it++) msg += '\n' + *it; wxMessageBox(msg, "Error", wxICON_ERROR); }
wxArrayString Model_Checking::all_type() { static wxArrayString types; if (types.empty()) { for (const auto& r : TYPE_CHOICES) types.Add(r.second); } return types; }
wxArrayString Model_Checking::all_status() { static wxArrayString status; if (status.empty()) { for (const auto& r : STATUS_ENUM_CHOICES) status.Add(r.second); } return status; }
void FileActionThread::DoFileAction(FileAction action, const wxArrayString& sources, const wxString& targetDir, bool allowUndo) { //static if (sources.empty()) return; #ifdef __WXMSW__ // Paths have to be double-null terminated wxString filePaths; for (unsigned int i = 0; i < sources.GetCount(); ++i) { filePaths += sources[i] + wxT('\0'); } const wxString target = targetDir + wxT('\0'); // The File Operation Structure SHFILEOPSTRUCT SHFileOp; ZeroMemory(&SHFileOp, sizeof(SHFILEOPSTRUCT)); SHFileOp.hwnd = NULL; SHFileOp.pFrom = filePaths.c_str(); SHFileOp.fFlags = FOF_NOCONFIRMMKDIR; if (allowUndo) SHFileOp.fFlags |= FOF_ALLOWUNDO; switch (action) { case FILEACTION_DELETE: SHFileOp.wFunc = FO_DELETE; break; case FILEACTION_DELETE_SILENT: SHFileOp.wFunc = FO_DELETE; SHFileOp.fFlags |= FOF_SILENT|FOF_NOCONFIRMATION|FOF_NOERRORUI; break; case FILEACTION_COPY: SHFileOp.wFunc = FO_COPY; SHFileOp.pTo = target.c_str(); break; case FILEACTION_MOVE: SHFileOp.wFunc = FO_MOVE; SHFileOp.pTo = target.c_str(); break; default: wxASSERT(false); return; } // Do the file operation SHFileOperation(&SHFileOp); #endif //__WXMSW__ return; }
const void MerryCommandManager::AddFiles(const wxArrayString& files,const wxArrayString& excludes) { if (excludes.empty()) return AddFiles(files); for(int i=files.GetCount()-1;i >= 0;--i) { int j; for(j = excludes.size()-1;j >= 0;--j) {//过滤符合条件的内容 if (files[i].Matches(excludes[j])) break; } if (j == -1 && this->AddCommand(files[i]) == -2) break; } }
bool ArcApp::List() { wxInputStreamPtr in(MakeInputStream()); if (!in.get()) return false; wxArchiveInputStreamPtr arc(m_factory->NewStream(*in)); wxArchiveEntryPtr entry; while (entry.reset(arc->GetNextEntry()), entry.get() && arc->CloseEntry()) if (m_args.empty() || entry->GetName().Matches(m_args[0])) *m_info << std::setw(9) << entry->GetSize() << " " << entry->GetDateTime().Format(_T("%x %X")).mb_str() << " " << entry->GetName().mb_str() << std::endl; return arc->Eof(); }
bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, const wxArrayString& choices, long style, const wxValidator& validator, const wxString& name ) { if ( !Create( parent, id, pos, size, 0, NULL, style, validator, name ) ) return false; Append( choices ); if ( !choices.empty() ) SetSelection( 0 ); SetInitialSize( size ); return true; }
void GUI::ListDialog(wxWindow* parent, wxString title, const wxArrayString& param_items) { if(param_items.empty()) return; wxArrayString list_items(param_items); // Create the window wxDialog* dlg = newd wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER | wxCAPTION | wxCLOSE_BOX); wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); wxListBox* item_list = newd wxListBox(dlg, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SINGLE); item_list->SetMinSize(wxSize(500, 300)); for(size_t i = 0; i != list_items.GetCount();) { wxString str = list_items[i]; size_t pos = str.find(wxT("\n")); if(pos != wxString::npos) { // Split string! item_list->Append(str.substr(0, pos)); list_items[i] = str.substr(pos+1); continue; } item_list->Append(list_items[i]); ++i; } sizer->Add(item_list, 1, wxEXPAND); wxSizer* stdsizer = newd wxBoxSizer(wxHORIZONTAL); stdsizer->Add(newd wxButton(dlg, wxID_OK, wxT("OK")), wxSizerFlags(1).Center()); sizer->Add(stdsizer, wxSizerFlags(0).Center()); dlg->SetSizerAndFit(sizer); // Show the window dlg->ShowModal(); delete dlg; }
bool ArcApp::Extract() { wxInputStreamPtr in(MakeInputStream()); if (!in.get()) return false; wxArchiveInputStreamPtr arc(m_factory->NewStream(*in)); wxArchiveEntryPtr entry; while (entry.reset(arc->GetNextEntry()), entry.get() != NULL) { if (!m_args.empty() && !entry->GetName().Matches(m_args[0])) continue; *m_info << "extracting " << entry->GetName().mb_str() << std::endl; wxFileName fn(entry->GetName()); if (entry->IsDir()) { fn.Mkdir(0777, wxPATH_MKDIR_FULL); } else { wxFileName::Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL); wxFFileOutputStream out(entry->GetName()); if (!out || !out.Write(*arc) || !arc->Eof()) return false; } #ifdef __WXMSW__ if (!entry->IsDir()) { #endif wxDateTime dt = entry->GetDateTime(); fn.SetTimes(NULL, &dt, NULL); #ifdef __WXMSW__ } #endif } return arc->Eof(); }
bool PoeditApp::OnInit() { if (!wxApp::OnInit()) return false; #if defined(__WXMAC__) wxSystemOptions::SetOption(wxMAC_TEXTCONTROL_USE_SPELL_CHECKER, 1); #endif #ifdef __WXMAC__ SetExitOnFrameDelete(false); #endif #if defined(__UNIX__) && !defined(__WXMAC__) wxStandardPaths::Get().SetInstallPrefix(POEDIT_PREFIX); wxString home = wxGetHomeDir() + "/"; // create Poedit cfg dir, move ~/.poedit to ~/.poedit/config // (upgrade from older versions of Poedit which used ~/.poedit file) if (!wxDirExists(home + ".poedit")) { if (wxFileExists(home + ".poedit")) wxRenameFile(home + ".poedit", home + ".poedit2"); wxMkdir(home + ".poedit"); if (wxFileExists(home + ".poedit2")) wxRenameFile(home + ".poedit2", home + ".poedit/config"); } #endif SetVendorName("Vaclav Slavik"); SetAppName("Poedit"); #if defined(__WXMAC__) #define CFG_FILE (wxStandardPaths::Get().GetUserConfigDir() + "/net.poedit.Poedit.cfg") #elif defined(__UNIX__) #define CFG_FILE (home + ".poedit/config") #else #define CFG_FILE wxEmptyString #endif #ifdef __WXMAC__ // upgrade from the old location of config file: wxString oldcfgfile = wxStandardPaths::Get().GetUserConfigDir() + "/poedit.cfg"; if (wxFileExists(oldcfgfile) && !wxFileExists(CFG_FILE)) { wxRenameFile(oldcfgfile, CFG_FILE); } #endif wxConfigBase::Set( new wxConfig(wxEmptyString, wxEmptyString, CFG_FILE, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_LOCAL_FILE)); wxConfigBase::Get()->SetExpandEnvVars(false); wxImage::AddHandler(new wxPNGHandler); wxXmlResource::Get()->InitAllHandlers(); #if defined(__WXMAC__) wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "/*.xrc"); #elif defined(__WXMSW__) wxStandardPaths::Get().DontIgnoreAppSubDir(); wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "\\Resources\\*.xrc"); #else InitXmlResource(); #endif SetDefaultCfg(wxConfig::Get()); #if defined(__WXMAC__) || defined(__WXMSW__) u_setDataDirectory(wxStandardPaths::Get().GetResourcesDir().mb_str()); #endif #ifndef __WXMAC__ wxArtProvider::PushBack(new PoeditArtProvider); #endif SetupLanguage(); #ifdef __WXMAC__ wxMenuBar *bar = wxXmlResource::Get()->LoadMenuBar("mainmenu_mac_global"); TweakOSXMenuBar(bar); wxMenuBar::MacSetCommonMenuBar(bar); // so that help menu is correctly merged with system-provided menu // (see http://sourceforge.net/tracker/index.php?func=detail&aid=1600747&group_id=9863&atid=309863) s_macHelpMenuTitleName = _("&Help"); #endif FileHistory().Load(*wxConfig::Get()); // NB: It's important to do this before TM is used for the first time. if ( !MigrateLegacyTranslationMemory() ) return false; // NB: opening files or creating empty window is handled differently on // Macs, using MacOpenFiles() and MacNewFile(), so don't create empty // window if no files are given on command line; but still support // passing files on command line if (!gs_filesToOpen.empty()) { OpenFiles(gs_filesToOpen); gs_filesToOpen.clear(); } #ifndef __WXMAC__ else { OpenNewFile(); } #endif // !__WXMAC__ #ifdef USE_SPARKLE Sparkle_Initialize(CheckForBetaUpdates()); #endif // USE_SPARKLE #ifdef __WXMSW__ const char *appcast = "http://releases.poedit.net/appcast-win"; if ( CheckForBetaUpdates() ) { // Beta versions use unstable feed. appcast = "http://releases.poedit.net/appcast-win/beta"; } win_sparkle_set_appcast_url(appcast); win_sparkle_init(); #endif return true; }
// Run // int TestApp::RunTests() { #if wxUSE_LOG // Switch off logging unless --verbose bool verbose = wxLog::GetVerbose(); wxLog::EnableLogging(verbose); #else bool verbose = false; #endif CppUnit::TextTestRunner runner; if ( m_registries.empty() ) { // run or list all tests which use the CPPUNIT_TEST_SUITE_REGISTRATION() macro // (i.e. those registered in the "All tests" registry); if there are other // tests not registered with the CPPUNIT_TEST_SUITE_REGISTRATION() macro // then they won't be listed/run! AddTest(runner, TestFactoryRegistry::getRegistry().makeTest()); if (m_list) { cout << "\nNote that the list above is not complete as it doesn't include the \n"; cout << "tests disabled by default.\n"; } } else // run only the selected tests { for (size_t i = 0; i < m_registries.size(); i++) { const wxString reg = m_registries[i]; Test *test = GetTestByName(reg); if ( !test && !reg.EndsWith("TestCase") ) { test = GetTestByName(reg + "TestCase"); } if ( !test ) { cerr << "No such test suite: " << string(reg.mb_str()) << endl; return 2; } AddTest(runner, test); } } if ( m_list ) return EXIT_SUCCESS; runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), cout)); // there is a bug // (http://sf.net/tracker/index.php?func=detail&aid=1649369&group_id=11795&atid=111795) // in some versions of cppunit: they write progress dots to cout (and not // cerr) and don't flush it so all the dots appear at once at the end which // is not very useful so unbuffer cout to work around this cout.setf(ios::unitbuf); // add detail listener if needed DetailListener detailListener(m_timing); if ( m_detail || m_timing ) runner.eventManager().addListener(&detailListener); // finally ensure that we report our own exceptions nicely instead of // giving "uncaught exception of unknown type" messages runner.eventManager().pushProtector(new wxUnitTestProtector); bool printProgress = !(verbose || m_detail || m_timing); runner.run("", false, true, printProgress); return runner.result().testFailures() == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
void ThreadSearch::LoadConfig(bool& showPanel, int& sashPosition, ThreadSearchViewManagerBase::eManagerTypes& mgrType, wxArrayString& searchPatterns, wxArrayString& searchDirs, wxArrayString& searchMasks) { if ( !IsAttached() ) return; ConfigManager* pCfg = Manager::Get()->GetConfigManager(_T("ThreadSearch")); m_FindData.SetMatchWord (pCfg->ReadBool(wxT("/MatchWord"), true)); m_FindData.SetStartWord (pCfg->ReadBool(wxT("/StartWord"), false)); m_FindData.SetMatchCase (pCfg->ReadBool(wxT("/MatchCase"), true)); m_FindData.SetRegEx (pCfg->ReadBool(wxT("/RegEx"), false)); m_FindData.SetHiddenSearch (pCfg->ReadBool(wxT("/HiddenSearch"), true)); m_FindData.SetRecursiveSearch (pCfg->ReadBool(wxT("/RecursiveSearch"), true)); m_CtxMenuIntegration = pCfg->ReadBool(wxT("/CtxMenuIntegration"), true); m_UseDefValsForThreadSearch = pCfg->ReadBool(wxT("/UseDefaultValues"), true); m_ShowSearchControls = pCfg->ReadBool(wxT("/ShowSearchControls"), true); m_ShowDirControls = pCfg->ReadBool(wxT("/ShowDirControls"), false); m_ShowCodePreview = pCfg->ReadBool(wxT("/ShowCodePreview"), false); m_DeletePreviousResults = pCfg->ReadBool(wxT("/DeletePreviousResults"), false); m_DisplayLogHeaders = pCfg->ReadBool(wxT("/DisplayLogHeaders"), true); m_DrawLogLines = pCfg->ReadBool(wxT("/DrawLogLines"), false); m_AutosizeLogColumns = pCfg->ReadBool(wxT("/AutosizeLogColumns"), true); showPanel = pCfg->ReadBool(wxT("/ShowPanel"), true); m_FindData.SetScope (pCfg->ReadInt (wxT("/Scope"), ScopeProjectFiles)); m_FindData.SetSearchPath (pCfg->Read (wxT("/DirPath"), wxEmptyString)); m_FindData.SetSearchMask (pCfg->Read (wxT("/Mask"), wxT("*.cpp;*.c;*.h"))); sashPosition = pCfg->ReadInt(wxT("/SplitterPosn"), 0); int splitterMode = pCfg->ReadInt(wxT("/SplitterMode"), wxSPLIT_VERTICAL); m_SplitterMode = wxSPLIT_VERTICAL; if ( splitterMode == wxSPLIT_HORIZONTAL ) { m_SplitterMode = wxSPLIT_HORIZONTAL; } int managerType = pCfg->ReadInt(wxT("/ViewManagerType"), ThreadSearchViewManagerBase::TypeMessagesNotebook); mgrType = ThreadSearchViewManagerBase::TypeMessagesNotebook; if ( managerType == ThreadSearchViewManagerBase::TypeLayout ) { mgrType = ThreadSearchViewManagerBase::TypeLayout; } int loggerType = pCfg->ReadInt(wxT("/LoggerType"), ThreadSearchLoggerBase::TypeList); m_LoggerType = ThreadSearchLoggerBase::TypeList; if ( loggerType == ThreadSearchLoggerBase::TypeTree ) { m_LoggerType = ThreadSearchLoggerBase::TypeTree; } searchPatterns = pCfg->ReadArrayString(wxT("/SearchPatterns")); searchDirs = pCfg->ReadArrayString(wxT("/SearchDirs")); if (searchDirs.empty()) searchDirs.push_back(m_FindData.GetSearchPath()); searchMasks = pCfg->ReadArrayString(wxT("/SearchMasks")); if (searchMasks.empty()) searchMasks.push_back(m_FindData.GetSearchMask()); }