EWXWEXPORT(int,ELJApp_SafeYield)(wxWindow* _win) { return (int)wxSafeYield(_win); }
bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { sm_abortIt = false; sm_abortWindow = NULL; if (!printout) return false; printout->SetIsPreview(false); if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) m_printDialogData.SetMaxPage(9999); // Create a suitable device context wxPrinterDC *dc = NULL; if (prompt) { wxMacPrintDialog dialog(parent, & m_printDialogData); if (dialog.ShowModal() == wxID_OK) { dc = wxDynamicCast(dialog.GetPrintDC(), wxPrinterDC); wxASSERT(dc); m_printDialogData = dialog.GetPrintDialogData(); } } else { dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; } // May have pressed cancel. if (!dc || !dc->Ok()) { if (dc) delete dc; return false; } // on the mac we have always pixels as addressing mode with 72 dpi printout->SetPPIScreen(72, 72); PMResolution res; wxMacCarbonPrintData* nativeData = (wxMacCarbonPrintData*) (m_printDialogData.GetPrintData().GetNativeData()); #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 PMPrinter printer; PMSessionGetCurrentPrinter(nativeData->m_macPrintSession, &printer); PMPrinterGetOutputResolution( printer, nativeData->m_macPrintSettings, &res) ; #else PMGetResolution((PMPageFormat) (nativeData->m_macPageFormat), &res); #endif printout->SetPPIPrinter(int(res.hRes), int(res.vRes)); // Set printout parameters printout->SetDC(dc); int w, h; dc->GetSize(&w, &h); printout->SetPageSizePixels((int)w, (int)h); printout->SetPaperRectPixels(dc->GetPaperRect()); wxCoord mw, mh; dc->GetSizeMM(&mw, &mh); printout->SetPageSizeMM((int)mw, (int)mh); // Create an abort window wxBeginBusyCursor(); printout->OnPreparePrinting(); // Get some parameters from the printout, if defined int fromPage, toPage; int minPage, maxPage; printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); if (maxPage == 0) { wxEndBusyCursor(); return false; } // Only set min and max, because from and to have been // set by the user m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); wxWindow *win = CreateAbortWindow(parent, printout); wxSafeYield(win,true); if (!win) { wxEndBusyCursor(); wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent); delete dc; return false; } sm_abortWindow = win; sm_abortWindow->Show(true); wxSafeYield(win,true); printout->OnBeginPrinting(); bool keepGoing = true; int copyCount; for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) { if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) { wxEndBusyCursor(); wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent); break; } if (sm_abortIt) break; int pn; for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); pn++) { if (sm_abortIt) { keepGoing = false; break; } else { #if TARGET_CARBON if ( UMAGetSystemVersion() >= 0x1000 ) #endif { #if !wxMAC_USE_CORE_GRAPHICS GrafPtr thePort ; GetPort( &thePort ) ; #endif wxSafeYield(win,true); #if !wxMAC_USE_CORE_GRAPHICS SetPort( thePort ) ; #endif } dc->StartPage(); keepGoing = printout->OnPrintPage(pn); dc->EndPage(); } } printout->OnEndDocument(); } printout->OnEndPrinting(); if (sm_abortWindow) { sm_abortWindow->Show(false); delete sm_abortWindow; sm_abortWindow = NULL; } wxEndBusyCursor(); delete dc; return true; }
bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { sm_abortIt = false; sm_abortWindow = NULL; if (!printout) { sm_lastError = wxPRINTER_ERROR; return false; } printout->SetIsPreview(false); if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) m_printDialogData.SetMaxPage(9999); // Create a suitable device context wxDC *dc wxDUMMY_INITIALIZE(NULL); if (prompt) { dc = PrintDialog(parent); if (!dc) return false; } else { dc = new wxPrinterDC(m_printDialogData.GetPrintData()); } // May have pressed cancel. if (!dc || !dc->Ok()) { if (dc) delete dc; return false; } HDC hdc = ::GetDC(NULL); int logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX); int logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY); ::ReleaseDC(NULL, hdc); int logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX); int logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY); if (logPPIPrinterX == 0 || logPPIPrinterY == 0) { delete dc; sm_lastError = wxPRINTER_ERROR; return false; } printout->SetPPIScreen(logPPIScreenX, logPPIScreenY); printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY); // Set printout parameters printout->SetDC(dc); int w, h; dc->GetSize(&w, &h); printout->SetPageSizePixels((int)w, (int)h); dc->GetSizeMM(&w, &h); printout->SetPageSizeMM((int)w, (int)h); // Create an abort window wxBusyCursor busyCursor; printout->OnPreparePrinting(); // Get some parameters from the printout, if defined int fromPage, toPage; int minPage, maxPage; printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); if (maxPage == 0) { sm_lastError = wxPRINTER_ERROR; return false; } // Only set min and max, because from and to have been // set by the user m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); wxWindow *win = CreateAbortWindow(parent, printout); wxYield(); #if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__) #ifdef STRICT ::SetAbortProc((HDC) dc->GetHDC(), (ABORTPROC) m_lpAbortProc); #else ::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc); #endif #else ::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *) // cast it to right type only if required // FIXME it's really cdecl and we're casting it to stdcall - either there is // something I don't understand or it will crash at first usage #ifdef STRICT (HDC, int) #else () #endif )m_lpAbortProc); #endif if (!win) { wxLogDebug(wxT("Could not create an abort dialog.")); sm_lastError = wxPRINTER_ERROR; delete dc; return false; } sm_abortWindow = win; sm_abortWindow->Show(); wxSafeYield(); printout->OnBeginPrinting(); sm_lastError = wxPRINTER_NO_ERROR; int minPageNum = minPage, maxPageNum = maxPage; if ( !m_printDialogData.GetAllPages() ) { minPageNum = m_printDialogData.GetFromPage(); maxPageNum = m_printDialogData.GetToPage(); } int copyCount; for ( copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount++ ) { if ( !printout->OnBeginDocument(minPageNum, maxPageNum) ) { wxLogError(_("Could not start printing.")); sm_lastError = wxPRINTER_ERROR; break; } if (sm_abortIt) { sm_lastError = wxPRINTER_CANCELLED; break; } int pn; for ( pn = minPageNum; pn <= maxPageNum && printout->HasPage(pn); pn++ ) { if ( sm_abortIt ) { sm_lastError = wxPRINTER_CANCELLED; break; } dc->StartPage(); bool cont = printout->OnPrintPage(pn); dc->EndPage(); if ( !cont ) { sm_lastError = wxPRINTER_CANCELLED; break; } } printout->OnEndDocument(); } printout->OnEndPrinting(); if (sm_abortWindow) { sm_abortWindow->Show(false); delete sm_abortWindow; sm_abortWindow = NULL; } delete dc; return sm_lastError == wxPRINTER_NO_ERROR; }
/////////// // Collect void FontsCollectorThread::Collect() { // Make sure there is a separator at the end destination += _T("\\"); // Reset log box wxTextCtrl *LogBox = collector->LogBox; wxMutexGuiEnter(); LogBox->SetValue(_T("")); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,180))); LogBox->AppendText(_("Searching for fonts in file...\n")); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,0))); LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); // Scans file AssStyle *curStyle; AssDialogue *curDiag; curLine = 0; for (std::list<AssEntry*>::iterator cur=subs->Line.begin(); cur!=subs->Line.end(); cur++) { // Collect from style curStyle = AssEntry::GetAsStyle(*cur); if (curStyle) { AddFont(curStyle->font,true); wxMutexGuiEnter(); LogBox->AppendText(wxString(_T("\"")) + curStyle->font + _("\" found on style \"") + curStyle->name + _T("\".\n")); LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); } // Collect from dialogue else { curDiag = AssEntry::GetAsDialogue(*cur); if (curDiag) { curLine++; curDiag->ParseASSTags(); curDiag->ProcessParameters(GetFonts); curDiag->ClearBlocks(); } } } #ifdef __WIN32__ // Collect font data wxMutexGuiEnter(); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,180))); LogBox->AppendText(_("\nReading fonts from registry...\n")); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,0))); wxSafeYield(); wxMutexGuiLeave(); CollectFontData(); // Get fonts folder wxString source; TCHAR szPath[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_FONTS,NULL,0,szPath))) { source = wxString(szPath); } else source = wxGetOSDirectory() + _T("\\fonts"); source += _T("\\"); // Get font file names wxArrayString work; wxArrayString copied; for (size_t i=0; i<fonts.GetCount(); i++) { try { work = GetFontFiles(fonts[i]); for (size_t j=0; j<work.GetCount(); j++) { // Get path to font file wxString srcFile,dstFile; wxFileName srcFileName(work[j]); if (srcFileName.FileExists() && srcFileName.IsAbsolute()) { srcFile = work[j]; dstFile = destination + srcFileName.GetFullName(); } else { srcFile = source + work[j]; dstFile = destination + work[j]; } if (copied.Index(work[j]) == wxNOT_FOUND) { copied.Add(work[j]); // Check if it exists if (wxFileName::FileExists(dstFile)) { wxMutexGuiEnter(); LogBox->SetDefaultStyle(wxTextAttr(wxColour(255,128,0))); LogBox->AppendText(wxString(_T("\"")) + work[j] + _("\" already exists on destination.\n")); LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); } // Copy else { // Copy font bool success = Copy(srcFile,dstFile); // Report wxMutexGuiEnter(); if (success) { LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,180,0))); LogBox->AppendText(wxString(_T("\"")) + work[j] + _("\" copied.\n")); } else { LogBox->SetDefaultStyle(wxTextAttr(wxColour(220,0,0))); LogBox->AppendText(wxString(_("Failed copying \"")) + srcFile + _T("\".\n")); } LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); } } } } catch (...) { wxMutexGuiEnter(); LogBox->SetDefaultStyle(wxTextAttr(wxColour(220,0,0))); LogBox->AppendText(wxString(_("Could not find font ")) + fonts[i] + _T("\n")); wxMutexGuiLeave(); } } #endif }
FrameMain::FrameMain() : wxFrame(nullptr, -1, "", wxDefaultPosition, wxSize(920,700), wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN) , context(agi::util::make_unique<agi::Context>()) { StartupLog("Entering FrameMain constructor"); #ifdef __WXGTK__ // XXX HACK XXX // We need to set LC_ALL to "" here for input methods to work reliably. setlocale(LC_ALL, ""); // However LC_NUMERIC must be "C", otherwise some parsing fails. setlocale(LC_NUMERIC, "C"); #endif #ifdef __APPLE__ // When run from an app bundle, LC_CTYPE defaults to "C", which breaks on // anything involving unicode and in some cases number formatting. // The right thing to do here would be to query CoreFoundation for the user's // locale and add .UTF-8 to that, but :effort: LOG_D("locale") << setlocale(LC_ALL, nullptr); setlocale(LC_CTYPE, "en_US.UTF-8"); LOG_D("locale") << setlocale(LC_ALL, nullptr); #endif StartupLog("Initializing context models"); memset(context.get(), 0, sizeof(*context)); context->ass = new AssFile; StartupLog("Initializing context controls"); context->subsController = new SubsController(context.get()); context->ass->AddCommitListener(&FrameMain::UpdateTitle, this); context->subsController->AddFileOpenListener(&FrameMain::OnSubtitlesOpen, this); context->subsController->AddFileSaveListener(&FrameMain::UpdateTitle, this); context->audioController = new AudioController(context.get()); context->audioController->AddAudioOpenListener(&FrameMain::OnAudioOpen, this); context->audioController->AddAudioCloseListener(&FrameMain::OnAudioClose, this); context->local_scripts = new Automation4::LocalScriptManager(context.get()); // Initialized later due to that the selection controller is currently the subtitles grid context->selectionController = nullptr; context->videoController = VideoContext::Get(); // derp context->videoController->AddVideoOpenListener(&FrameMain::OnVideoOpen, this); StartupLog("Initializing context frames"); context->parent = this; context->previousFocus = nullptr; StartupLog("Install PNG handler"); wxImage::AddHandler(new wxPNGHandler); #ifndef __APPLE__ wxSafeYield(); #endif StartupLog("Apply saved Maximized state"); if (OPT_GET("App/Maximized")->GetBool()) Maximize(true); StartupLog("Initialize toolbar"); InitToolbar(); StartupLog("Initialize menu bar"); menu::GetMenuBar("main", this, context.get()); StartupLog("Create status bar"); CreateStatusBar(2); StartupLog("Set icon"); #ifdef _WIN32 SetIcon(wxICON(wxicon)); #else wxIcon icon; icon.CopyFromBitmap(GETIMAGE(wxicon)); SetIcon(icon); #endif StartupLog("Create views and inner main window controls"); context->dialog = new DialogManager; InitContents(); OPT_SUB("Video/Detached/Enabled", &FrameMain::OnVideoDetach, this, agi::signal::_1); StartupLog("Complete context initialization"); context->videoController->SetContext(context.get()); StartupLog("Set up drag/drop target"); SetDropTarget(new AegisubFileDropTarget(this)); StartupLog("Load default file"); context->subsController->Close(); StartupLog("Display main window"); AddFullScreenButton(this); Show(); SetDisplayMode(1, 1); // Version checker StartupLog("Possibly perform automatic updates check"); if (OPT_GET("App/First Start")->GetBool()) { OPT_SET("App/First Start")->SetBool(false); #ifdef WITH_UPDATE_CHECKER int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"), wxYES_NO | wxCENTER); OPT_SET("App/Auto/Check For Updates")->SetBool(result == wxYES); config::opt->Flush(); #endif } #ifdef WITH_UPDATE_CHECKER PerformVersionCheck(false); #endif Bind(FILE_LIST_DROPPED, &FrameMain::OnFilesDropped, this); StartupLog("Leaving FrameMain constructor"); }
SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SIM_PLOT_FRAME_BASE( aParent ), m_lastSimPlot( nullptr ) { SetKiway( this, aKiway ); m_signalsIconColorList = NULL; m_schematicFrame = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); if( m_schematicFrame == NULL ) throw std::runtime_error( "There is no schematic window" ); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( simulator_xpm ) ); SetIcon( icon ); // Get the previous size and position of windows: LoadSettings( config() ); m_simulator = SPICE_SIMULATOR::CreateInstance( "ngspice" ); if( !m_simulator ) { throw std::runtime_error( "Could not create simulator instance" ); return; } m_simulator->Init(); if( m_savedWorkbooksPath.IsEmpty() ) { m_savedWorkbooksPath = Prj().GetProjectPath(); } m_reporter = new SIM_THREAD_REPORTER( this ); m_simulator->SetReporter( m_reporter ); updateNetlistExporter(); Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( SIM_PLOT_FRAME::onClose ), NULL, this ); Connect( EVT_SIM_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onSimUpdate ), NULL, this ); Connect( EVT_SIM_REPORT, wxCommandEventHandler( SIM_PLOT_FRAME::onSimReport ), NULL, this ); Connect( EVT_SIM_STARTED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimStarted ), NULL, this ); Connect( EVT_SIM_FINISHED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimFinished ), NULL, this ); Connect( EVT_SIM_CURSOR_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onCursorUpdate ), NULL, this ); // Toolbar buttons m_toolSimulate = m_toolBar->AddTool( ID_SIM_RUN, _( "Run/Stop Simulation" ), KiBitmap( sim_run_xpm ), _( "Run Simulation" ), wxITEM_NORMAL ); m_toolAddSignals = m_toolBar->AddTool( ID_SIM_ADD_SIGNALS, _( "Add Signals" ), KiBitmap( sim_add_signal_xpm ), _( "Add signals to plot" ), wxITEM_NORMAL ); m_toolProbe = m_toolBar->AddTool( ID_SIM_PROBE, _( "Probe" ), KiBitmap( sim_probe_xpm ), _( "Probe signals on the schematic" ), wxITEM_NORMAL ); m_toolTune = m_toolBar->AddTool( ID_SIM_TUNE, _( "Tune" ), KiBitmap( sim_tune_xpm ), _( "Tune component values" ), wxITEM_NORMAL ); m_toolSettings = m_toolBar->AddTool( wxID_ANY, _( "Settings" ), KiBitmap( sim_settings_xpm ), _( "Simulation settings" ), wxITEM_NORMAL ); Connect( m_toolSimulate->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimulate ), NULL, this ); Connect( m_toolAddSignals->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onAddSignal ), NULL, this ); Connect( m_toolProbe->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onProbe ), NULL, this ); Connect( m_toolTune->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onTune ), NULL, this ); Connect( m_toolSettings->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onSettings ), NULL, this ); // Bind toolbar buttons event to existing menu event handlers, so they behave the same Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSimulate, this, m_runSimulation->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onAddSignal, this, m_addSignals->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onProbe, this, m_probeSignals->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onTune, this, m_tuneValue->GetId() ); Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSettings, this, m_settings->GetId() ); m_toolBar->Realize(); m_plotNotebook->SetPageText( 0, _( "Welcome!" ) ); // the settings dialog will be created later, on demand. // if created in the ctor, for some obscure reason, there is an issue // on Windows: when open it, the simulator frame is sent to the background. // instead of being behind the dialog frame (as it does) m_settingsDlg = NULL; // resize the subwindows size. At least on Windows, calling wxSafeYield before // resizing the subwindows forces the wxSplitWindows size events automatically generated // by wxWidgets to be executed before our resize code. // Otherwise, the changes made by setSubWindowsSashSize are overwritten by one these // events wxSafeYield(); setSubWindowsSashSize(); }
wxString dlgRepCluster::GetSql() { wxString sql; wxString name; if (chkJoinCluster->GetValue()) name = wxT("_") + cbClusterName->GetValue(); else name = wxT("_") + txtClusterName->GetValue(); wxString quotedName = qtIdent(name); if (cluster) { // edit mode int sel = cbAdminNode->GetCurrentSelection(); if (sel >= 0) { long id = (long)cbAdminNode->wxItemContainer::GetClientData(sel); if (id != cluster->GetAdminNodeID()) settings->WriteLong(wxT("Replication/") + cluster->GetName() + wxT("/AdminNode"), id); } } else { // create mode wxString backupExecutable; if (remoteServer && remoteServer->GetConnection()->EdbMinimumVersion(8, 0)) backupExecutable = edbBackupExecutable; else if (remoteServer && remoteServer->GetConnection()->GetIsGreenplum()) backupExecutable = gpBackupExecutable; else backupExecutable = pgBackupExecutable; if (remoteServer && clusterBackup.IsEmpty() && !backupExecutable.IsEmpty()) { wxArrayString environment; if (!remoteServer->GetPasswordIsStored()) environment.Add(wxT("PGPASSWORD="******" -i -F p -h ") + remoteServer->GetName() + wxT(" -p ") + NumToStr((long)remoteServer->GetPort()) + wxT(" -U ") + remoteServer->GetUsername() + wxT(" -s -O -n ") + name + wxT(" ") + cbDatabase->GetValue(), this, &environment); wxBusyCursor wait; while (process) { wxSafeYield(); if (process) clusterBackup += process->ReadInputStream(); wxSafeYield(); wxMilliSleep(10); } } if (!clusterBackup.IsEmpty()) { int opclassPos = clusterBackup.Find(wxT("CREATE OPERATOR CLASS")); sql = wxT("-- Extracted schema from existing cluster\n\n") + clusterBackup.Left(opclassPos > 0 ? opclassPos : 99999999); if (opclassPos > 0) { sql += wxT("----------- inserted by pgadmin: add public operators\n") wxT("CREATE OPERATOR public.< (PROCEDURE = xxidlt,") wxT(" LEFTARG = xxid, RIGHTARG = xxid,") wxT(" COMMUTATOR = public.\">\", NEGATOR = public.\">=\",") wxT(" RESTRICT = scalarltsel, JOIN = scalarltjoinsel);\n") wxT("CREATE OPERATOR public.= (PROCEDURE = xxideq,") wxT(" LEFTARG = xxid, RIGHTARG = xxid,") wxT(" COMMUTATOR = public.\"=\", NEGATOR = public.\"<>\",") wxT(" RESTRICT = eqsel, JOIN = eqjoinsel,") wxT(" SORT1 = public.\"<\", SORT2 = public.\"<\", HASHES);\n") wxT("CREATE OPERATOR public.<> (PROCEDURE = xxidne,") wxT(" LEFTARG = xxid, RIGHTARG = xxid,") wxT(" COMMUTATOR = public.\"<>\", NEGATOR = public.\"=\",") wxT(" RESTRICT = neqsel, JOIN = neqjoinsel);\n") wxT("CREATE OPERATOR public.> (PROCEDURE = xxidgt,") wxT(" LEFTARG = xxid, RIGHTARG = xxid,") wxT(" COMMUTATOR = public.\"<\", NEGATOR = public.\"<=\",") wxT(" RESTRICT = scalargtsel, JOIN = scalargtjoinsel);\n") wxT("CREATE OPERATOR public.<= (PROCEDURE = xxidle,") wxT(" LEFTARG = xxid, RIGHTARG = xxid,") wxT(" COMMUTATOR = public.\">=\", NEGATOR = public.\">\",") wxT(" RESTRICT = scalarltsel, JOIN = scalarltjoinsel);\n") wxT("CREATE OPERATOR public.>= (PROCEDURE = xxidge,") wxT(" LEFTARG = xxid, RIGHTARG = xxid,") wxT(" COMMUTATOR = public.\"<=\", NEGATOR = public.\"<\",") wxT(" RESTRICT = scalargtsel, JOIN = scalargtjoinsel);\n") wxT("------------- continue with backup script\n") + clusterBackup.Mid(opclassPos); } } else { sql = wxT("CREATE SCHEMA ") + quotedName + wxT(";\n\n") + ReplaceString(createScript, wxT("@NAMESPACE@"), quotedName); if (chkJoinCluster->GetValue()) sql = ReplaceString(sql, wxT("@CLUSTERNAME@"), cbClusterName->GetValue()); else sql = ReplaceString(sql, wxT("@CLUSTERNAME@"), txtClusterName->GetValue()); // From Slony 1.2 onwards, the scripts include the module version. // To figure it out, temporarily load and use _Slony_I_getModuleVersion. // We'll cache the result to save doing it again. if (sql.Contains(wxT("@MODULEVERSION@")) && slonyVersion.IsEmpty()) { this->database->ExecuteVoid(wxT("CREATE OR REPLACE FUNCTION pgadmin_slony_version() returns text as '$libdir/slony1_funcs', '_Slony_I_getModuleVersion' LANGUAGE C")); slonyVersion = this->database->ExecuteScalar(wxT("SELECT pgadmin_slony_version();")); this->database->ExecuteVoid(wxT("DROP FUNCTION pgadmin_slony_version()")); if (slonyVersion.IsEmpty()) { wxLogError(_("Couldn't test for the Slony version. Assuming 1.2.0")); slonyVersion = wxT("1.2.0"); } } sql = ReplaceString(sql, wxT("@MODULEVERSION@"), slonyVersion); } sql += wxT("\n") wxT("SELECT ") + quotedName + wxT(".initializelocalnode(") + txtNodeID->GetValue() + wxT(", ") + qtDbString(txtNodeName->GetValue()) + wxT(");\n") wxT("SELECT ") + quotedName; if (chkJoinCluster->GetValue()) sql += wxT(".enablenode_int("); else sql += wxT(".enablenode("); sql += txtNodeID->GetValue() + wxT(");\n"); } if (!txtComment->GetValue().IsEmpty()) sql += wxT("\n") wxT("COMMENT ON SCHEMA ") + quotedName + wxT(" IS ") + qtDbString(txtComment->GetValue()) + wxT(";\n"); if (chkJoinCluster->GetValue()) sql += wxT("\n\n-- In addition, the configuration is copied from the existing cluster.\n"); else { wxString schemaPrefix = qtIdent(wxT("_") + txtClusterName->GetValue()) + wxT("."); long adminNode = StrToLong(txtAdminNodeID->GetValue()); if (adminNode > 0 && adminNode != StrToLong(txtNodeID->GetValue())) { sql += wxT("\n-- Create admin node\n") wxT("SELECT ") + schemaPrefix + wxT("storeNode(") + NumToStr(adminNode) + wxT(", ") + qtDbString(txtAdminNodeName->GetValue()); if (chkJoinCluster->GetValue()) { if (StrToDouble(remoteVersion) >= 1.1) sql += wxT(", false"); } else { if (createScript.Find(wxT("storeNode (int4, text)")) < 0) sql += wxT(", false"); } sql += wxT(");\n") wxT("SELECT ") + schemaPrefix + wxT("storepath(") + txtNodeID->GetValue() + wxT(", ") + NumToStr(adminNode) + wxT(", ") + qtDbString(wxT("host=") + database->GetServer()->GetName() + wxT(" port=") + NumToStr((long)database->GetServer()->GetPort()) + wxT(" dbname=") + database->GetName()) + wxT(", ") wxT("0);\n"); } } return sql; }
void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event ) { wxString reportName; bool make_report = m_CreateRptCtrl->IsChecked(); if( make_report ) // Create a rpt file { reportName = m_RptFilenameCtrl->GetValue(); if( reportName.IsEmpty() ) { wxCommandEvent dummy; OnButtonBrowseRptFileClick( dummy ); } if( !reportName.IsEmpty() ) reportName = makeValidFileNameReport(); } SetDrcParmeters(); m_tester->SetSettings( true, // Pad to pad DRC test enabled true, // unconnected pads DRC test enabled true, // DRC test for zones enabled true, // DRC test for keepout areas enabled m_cbCourtyardOverlap->GetValue(), m_cbCourtyardMissing->GetValue(), reportName, make_report ); DelDRCMarkers(); wxBeginBusyCursor(); // run all the tests, with no UI at this time. m_Messages->Clear(); wxSafeYield(); // Allows time slice to refresh the m_Messages window m_brdEditor->GetBoard()->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations m_tester->RunTests(m_Messages); m_Notebook->ChangeSelection( 0 ); // display the 1at tab "...Markers ..." // Generate the report if( !reportName.IsEmpty() ) { if( writeReport( reportName ) ) { wxString msg; msg.Printf( _( "Report file \"%s\" created" ), GetChars( reportName ) ); wxString caption( _( "Disk File Report Completed" ) ); wxMessageDialog popupWindow( this, msg, caption ); popupWindow.ShowModal(); } else DisplayError( this, wxString::Format( _( "Unable to create report file \"%s\" "), GetChars( reportName ) ) ); } wxEndBusyCursor(); RedrawDrawPanel(); }
bool frmMain::CheckAlive() { bool userInformed = false; bool closeIt = false; wxTreeItemIdValue foldercookie; wxTreeItemId folderitem = browser->GetFirstChild(browser->GetRootItem(), foldercookie); while (folderitem) { if (browser->ItemHasChildren(folderitem)) { wxCookieType cookie; wxTreeItemId serverItem = browser->GetFirstChild(folderitem, cookie); while (serverItem) { pgServer *server = (pgServer *)browser->GetObject(serverItem); if (server && server->IsCreatedBy(serverFactory) && server->connection()) { if (server->connection()->IsAlive()) { wxCookieType cookie2; wxTreeItemId item = browser->GetFirstChild(serverItem, cookie2); while (item) { pgObject *obj = browser->GetObject(item); if (obj && obj->IsCreatedBy(databaseFactory.GetCollectionFactory())) { wxCookieType cookie3; item = browser->GetFirstChild(obj->GetId(), cookie3); while (item) { pgDatabase *db = (pgDatabase *)browser->GetObject(item); if (db && db->IsCreatedBy(databaseFactory)) { pgConn *conn = db->GetConnection(); if (conn) { if (!conn->IsAlive() && (conn->GetStatus() == PGCONN_BROKEN || conn->GetStatus() == PGCONN_BAD)) { conn->Close(); if (!userInformed) { wxMessageDialog dlg(this, _("Do you want to attempt to reconnect to the database?"), wxString::Format(_("Connection to database %s lost."), db->GetName().c_str()), wxICON_EXCLAMATION | wxYES_NO | wxYES_DEFAULT); closeIt = (dlg.ShowModal() != wxID_YES); userInformed = true; } if (closeIt) { db->Disconnect(); browser->DeleteChildren(db->GetId()); db->UpdateIcon(browser); } else { // Create a server object and connect it. wxBusyInfo waiting(wxString::Format(_("Reconnecting to database %s"), db->GetName().c_str()), this); // Give the UI a chance to redraw wxSafeYield(); wxMilliSleep(100); wxSafeYield(); if (!conn->Reconnect()) { db->Disconnect(); browser->DeleteChildren(db->GetId()); db->UpdateIcon(browser); } else // Indicate things are back to normal userInformed = false; } } } } item = browser->GetNextChild(obj->GetId(), cookie3); } } item = browser->GetNextChild(serverItem, cookie2); } } else { if (server->connection()->GetStatus() == PGCONN_BROKEN || server->connection()->GetStatus() == PGCONN_BAD) { server->connection()->Close(); if (!userInformed) { wxMessageDialog dlg(this, _("Do you want to attempt to reconnect to the server?"), wxString::Format(_("Connection to server %s lost."), server->GetName().c_str()), wxICON_EXCLAMATION | wxYES_NO | wxYES_DEFAULT); closeIt = (dlg.ShowModal() != wxID_YES); userInformed = true; } if (closeIt) { server->Disconnect(this); browser->SelectItem(serverItem); execSelChange(serverItem, true); browser->DeleteChildren(serverItem); } else { // Create a server object and connect it. wxBusyInfo waiting(wxString::Format(_("Reconnecting to server %s (%s:%d)"), server->GetDescription().c_str(), server->GetName().c_str(), server->GetPort()), this); // Give the UI a chance to redraw wxSafeYield(); wxMilliSleep(100); wxSafeYield(); if (!server->connection()->Reconnect()) { server->Disconnect(this); browser->SelectItem(serverItem); execSelChange(serverItem, true); browser->DeleteChildren(serverItem); } else // Indicate things are back to normal userInformed = false; } } } } serverItem = browser->GetNextChild(folderitem, cookie); } } folderitem = browser->GetNextChild(browser->GetRootItem(), foldercookie); } return userInformed; }
int frmMain::ReconnectServer(pgServer *server, bool restore) { // Create a server object and connect it. wxBusyInfo waiting(wxString::Format(_("Connecting to server %s (%s:%d)"), server->GetDescription().c_str(), server->GetName().c_str(), server->GetPort()), this); // Give the UI a chance to redraw wxSafeYield(); wxMilliSleep(100); wxSafeYield(); int res = server->Connect(this, true, wxEmptyString, false, true); // Check the result, and handle it as appropriate wxTreeItemId item; switch (res) { case PGCONN_OK: { if (restore && server->GetRestore()) StartMsg(_("Restoring previous environment")); else StartMsg(_("Establishing connection")); wxLogInfo(wxT("pgServer object initialised as required.")); server->ShowTreeDetail(browser); browser->Freeze(); if (restore && server->GetRestore()) item = RestoreEnvironment(server); else item = server->GetId(); browser->Thaw(); if (item) { browser->SelectItem(item); wxSafeYield(); browser->Expand(item); browser->EnsureVisible(item); } if (item) EndMsg(true); else { if (restore && server->GetRestore()) EndMsg(false); else EndMsg(true); } if (item) GetMenuFactories()->CheckMenu((pgObject *)browser->GetItemData(item), GetMenuBar(), (ctlMenuToolbar *)GetToolBar()); else GetMenuFactories()->CheckMenu(server, GetMenuBar(), (ctlMenuToolbar *)GetToolBar()); browser->SetFocus(); return res; } case PGCONN_DNSERR: /* // looks strange to me. Shouldn_t server be removed from the tree as well? delete server; OnAddServer(wxCommandEvent()); break; */ case PGCONN_BAD: ReportConnError(server); break; default: wxLogInfo(wxT("pgServer object didn't initialise because the user aborted.")); break; } server->Disconnect(this); return res; }
bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { sm_abortIt = false; sm_abortWindow = NULL; if (!printout) { sm_lastError = wxPRINTER_ERROR; return false; } if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) m_printDialogData.SetMaxPage(9999); // Create a suitable device context wxPrinterDC *dc wxDUMMY_INITIALIZE(NULL); if (prompt) { dc = wxDynamicCast(PrintDialog(parent), wxPrinterDC); if (!dc) return false; } else { dc = new wxPrinterDC(m_printDialogData.GetPrintData()); } // May have pressed cancel. if (!dc || !dc->IsOk()) { if (dc) delete dc; return false; } wxPrinterDCImpl *impl = (wxPrinterDCImpl*) dc->GetImpl(); HDC hdc = ::GetDC(NULL); int logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX); int logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY); ::ReleaseDC(NULL, hdc); int logPPIPrinterX = ::GetDeviceCaps((HDC) impl->GetHDC(), LOGPIXELSX); int logPPIPrinterY = ::GetDeviceCaps((HDC) impl->GetHDC(), LOGPIXELSY); if (logPPIPrinterX == 0 || logPPIPrinterY == 0) { delete dc; sm_lastError = wxPRINTER_ERROR; return false; } printout->SetPPIScreen(logPPIScreenX, logPPIScreenY); printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY); // Set printout parameters printout->SetDC(dc); int w, h; dc->GetSize(&w, &h); printout->SetPageSizePixels((int)w, (int)h); printout->SetPaperRectPixels(dc->GetPaperRect()); dc->GetSizeMM(&w, &h); printout->SetPageSizeMM((int)w, (int)h); // Create an abort window wxBusyCursor busyCursor; printout->OnPreparePrinting(); // Get some parameters from the printout, if defined int fromPage, toPage; int minPage, maxPage; printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); if (maxPage == 0) { sm_lastError = wxPRINTER_ERROR; return false; } // Only set min and max, because from and to have been // set by the user m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); wxPrintAbortDialog *win = CreateAbortWindow(parent, printout); wxYield(); ::SetAbortProc(GetHdcOf(*impl), wxAbortProc); if (!win) { wxLogDebug(wxT("Could not create an abort dialog.")); sm_lastError = wxPRINTER_ERROR; delete dc; return false; } sm_abortWindow = win; sm_abortWindow->Show(); wxSafeYield(); printout->OnBeginPrinting(); sm_lastError = wxPRINTER_NO_ERROR; int minPageNum = minPage, maxPageNum = maxPage; if ( !(m_printDialogData.GetAllPages() || m_printDialogData.GetSelection()) ) { minPageNum = m_printDialogData.GetFromPage(); maxPageNum = m_printDialogData.GetToPage(); } // The dc we get from the PrintDialog will do multiple copies without help // if the device supports it. Loop only if we have created a dc from our // own m_printDialogData or the device does not support multiple copies. // m_printDialogData.GetPrintData().GetNoCopies() is set from device // devMode in printdlg.cpp/wxWindowsPrintDialog::ConvertFromNative() const int maxCopyCount = !prompt || !m_printDialogData.GetPrintData().GetNoCopies() ? m_printDialogData.GetNoCopies() : 1; for ( int copyCount = 1; copyCount <= maxCopyCount; copyCount++ ) { if ( !printout->OnBeginDocument(minPageNum, maxPageNum) ) { wxLogError(_("Could not start printing.")); sm_lastError = wxPRINTER_ERROR; break; } if (sm_abortIt) { sm_lastError = wxPRINTER_CANCELLED; break; } int pn; for ( pn = minPageNum; pn <= maxPageNum && printout->HasPage(pn); pn++ ) { win->SetProgress(pn - minPageNum + 1, maxPageNum - minPageNum + 1, copyCount, maxCopyCount); if ( sm_abortIt ) { sm_lastError = wxPRINTER_CANCELLED; break; } dc->StartPage(); bool cont = printout->OnPrintPage(pn); dc->EndPage(); if ( !cont ) { sm_lastError = wxPRINTER_CANCELLED; break; } } printout->OnEndDocument(); } printout->OnEndPrinting(); if (sm_abortWindow) { sm_abortWindow->Show(false); wxDELETE(sm_abortWindow); } delete dc; return sm_lastError == wxPRINTER_NO_ERROR; }
bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { sm_abortIt = FALSE; sm_abortWindow = NULL; if (!printout) return FALSE; printout->SetIsPreview(FALSE); if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) m_printDialogData.SetMaxPage(9999); // Create a suitable device context wxDC *dc = NULL; if (prompt) { wxPrintDialog dialog(parent, & m_printDialogData); if (dialog.ShowModal() == wxID_OK) { dc = dialog.GetPrintDC(); m_printDialogData = dialog.GetPrintDialogData(); } } else { dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; } // May have pressed cancel. if (!dc || !dc->Ok()) { if (dc) delete dc; return FALSE; } // on the mac we have always pixels as addressing mode with 72 dpi printout->SetPPIScreen(72, 72); printout->SetPPIPrinter(72, 72); // Set printout parameters printout->SetDC(dc); int w, h; wxCoord ww, hh; dc->GetSize(&w, &h); printout->SetPageSizePixels((int)w, (int)h); dc->GetSizeMM(&ww, &hh); printout->SetPageSizeMM((int)ww, (int)hh); // Create an abort window wxBeginBusyCursor(); printout->OnPreparePrinting(); // Get some parameters from the printout, if defined int fromPage, toPage; int minPage, maxPage; printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); if (maxPage == 0) { wxEndBusyCursor(); return FALSE; } // Only set min and max, because from and to have been // set by the user m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); wxWindow *win = CreateAbortWindow(parent, printout); wxSafeYield(win,true); if (!win) { wxEndBusyCursor(); wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent); delete dc; return FALSE; } sm_abortWindow = win; sm_abortWindow->Show(TRUE); wxSafeYield(win,true); printout->OnBeginPrinting(); bool keepGoing = TRUE; int copyCount; for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) { if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) { wxEndBusyCursor(); wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent); break; } if (sm_abortIt) break; int pn; for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); pn++) { if (sm_abortIt) { keepGoing = FALSE; break; } else { #if TARGET_CARBON if ( UMAGetSystemVersion() >= 0x1000 ) #endif { GrafPtr thePort ; GetPort( &thePort ) ; wxSafeYield(win,true); SetPort( thePort ) ; } dc->StartPage(); keepGoing = printout->OnPrintPage(pn); dc->EndPage(); } } printout->OnEndDocument(); } printout->OnEndPrinting(); if (sm_abortWindow) { sm_abortWindow->Show(FALSE); delete sm_abortWindow; sm_abortWindow = NULL; } wxEndBusyCursor(); delete dc; return TRUE; }
void CBOINCClientManager::ShutdownBOINCCore(bool ShuttingDownManager) { wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::ShutdownBOINCCore - Function Begin")); CMainDocument* pDoc = wxGetApp().GetDocument(); wxInt32 iCount = 0; bool bClientQuit = false; wxString strConnectedCompter = wxEmptyString; wxString strPassword = wxEmptyString; double startTime = 0; wxDateTime zeroTime = wxDateTime((time_t)0); wxDateTime rpcCompletionTime = zeroTime; ASYNC_RPC_REQUEST request; int quit_result; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); #ifdef __WXMAC__ // Mac Manager shuts down client only if Manager started client if (!m_bBOINCStartedByManager) return; #endif #ifdef __WXMSW__ if (IsBOINCConfiguredAsDaemon()) { stop_daemon_via_daemonctrl(); bClientQuit = true; } else #endif { pDoc->GetConnectedComputerName(strConnectedCompter); if (!pDoc->IsComputerNameLocal(strConnectedCompter)) { RPC_CLIENT rpc; if (!rpc.init("localhost")) { pDoc->m_pNetworkConnection->GetLocalPassword(strPassword); rpc.authorize((const char*)strPassword.mb_str()); if (IsBOINCCoreRunning()) { rpc.quit(); for (iCount = 0; iCount <= 10; iCount++) { if (!bClientQuit && !IsBOINCCoreRunning()) { wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - (localhost) Application Exit Detected")); bClientQuit = true; break; } wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - (localhost) Application Exit NOT Detected, Sleeping...")); ::wxSleep(1); } } else { bClientQuit = true; } } rpc.close(); } else { if (IsBOINCCoreRunning()) { if (ShuttingDownManager) { // Set event filtering to allow RPC completion // events but not events which start new RPCs wxGetApp().SetEventFiltering(true); } quit_result = -1; request.clear(); request.which_rpc = RPC_QUIT; request.rpcType = RPC_TYPE_ASYNC_NO_REFRESH; request.completionTime = &rpcCompletionTime; request.resultPtr = &quit_result; pDoc->RequestRPC(request); // Issue an asynchronous Quit RPC // Client needs time to shut down project applications, so don't wait // for it to shut down; assume it will exit OK if Quit RPC succeeds. startTime = dtime(); while ((dtime() - startTime) < 10.0) { // Allow 10 seconds boinc_sleep(0.25); // Check 4 times per second wxSafeYield(NULL, true); // To allow handling RPC completion events if (!bClientQuit && (rpcCompletionTime != zeroTime)) { // If Quit RPC finished, check its returned value if (quit_result) { break; // Quit RPC returned an error } wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - Application Exit Detected")); bClientQuit = true; break; } wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::ShutdownBOINCCore - Application Exit NOT Detected, Sleeping...")); } } else { bClientQuit = true; } } } if (!bClientQuit) { KillClient(); } m_lBOINCCoreProcessId = 0; wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::ShutdownBOINCCore - Function End")); }