예제 #1
0
파일: ConLog.cpp 프로젝트: 252525fb/rpcs3
void LogWriter::WriteToLog(wxString prefix, wxString value, wxString colour/*, wxColour bgcolour*/)
{
	if(ThreadBase* thr = GetCurrentNamedThread())
	{
		prefix = (prefix.IsEmpty() ? "" : prefix + " : ") + thr->GetThreadName();
	}

	if(m_logfile.IsOpened())
		m_logfile.Write((prefix.IsEmpty() ? wxEmptyString : "[" + prefix + "]: ") + value + "\n");

	if(!ConLogFrame) return;

	wxCriticalSectionLocker lock(g_cs_conlog);

	if(wxThread::IsMain())
	{
		while(LogBuffer.IsBusy()) wxYieldIfNeeded();
	}
	else
	{
		while(LogBuffer.IsBusy()) Sleep(1);
	}

	//if(LogBuffer.put == LogBuffer.get) LogBuffer.Flush();

	LogBuffer.Push(LogPacket(prefix, value, colour));
}
예제 #2
0
void wxHugeScrollBar::OnOffsetScroll( wxScrollEvent& event ){
	if( m_range <= 2147483647){
		m_thumb = event.GetPosition();
		}
	else{	//64bit mode
		int64_t here =event.GetPosition();
		if(here == 2147483646)	//if maximum set
			m_thumb = m_range-1;	//than give maximum m_thumb which is -1 from range
		else
			m_thumb = static_cast<int64_t>(here*(m_range/2147483647.0));
		}
	wxYieldIfNeeded();

#ifdef _DEBUG_SCROLL_
	if(event.GetEventType() == wxEVT_SCROLL_CHANGED)
		std::cout << "wxEVT_SCROLL_CHANGED"  << std::endl;
	if(event.GetEventType() == wxEVT_SCROLL_THUMBTRACK)
		std::cout << "wxEVT_SCROLL_THUMBTRACK"  << std::endl;
	if(event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE)
		std::cout << "wxEVT_SCROLL_THUMBRELEASE"  << std::endl;
	if( event.GetEventType() == wxEVT_SCROLL_LINEDOWN )
		std::cout << "wxEVT_SCROLL_LINEDOWN"  << std::endl;
	if( event.GetEventType() == wxEVT_SCROLL_LINEUP )
		std::cout << "wxEVT_SCROLL_LINEUP" << std::endl;
	if( event.GetEventType() == wxEVT_SCROLL_PAGEUP )
		std::cout << "wxEVT_SCROLL_PAGEUP" << std::endl;
	if( event.GetEventType() == wxEVT_SCROLL_PAGEDOWN )
		std::cout << "wxEVT_SCROLL_PAGEDOWN" << std::endl;
	if( event.GetEventType() == wxEVT_SCROLLWIN_LINEUP )
		std::cout << "wxEVT_SCROLLWIN_LINEUP" << std::endl;
	if( event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN )
		std::cout << "wxEVT_SCROLLWIN_LINEDOWN" << std::endl;
#endif
	event.Skip();
	}
예제 #3
0
void JMTimer::Notify() {
  jmlib->doJuggle();
  if (canvas)   canvas->Refresh();
#ifdef OPENGL_SUPPORT
  if (glCanvas) glCanvas->Refresh();
#endif
  wxWakeUpIdle();
  wxYieldIfNeeded();
}
예제 #4
0
파일: progdlgg.cpp 프로젝트: 252525fb/rpcs3
void wxProgressDialog::UpdateMessage(const wxString &newmsg)
{
    if ( !newmsg.empty() && newmsg != m_msg->GetLabel() )
    {
        m_msg->SetLabel(newmsg);

        wxYieldIfNeeded() ;
    }
}
예제 #5
0
void MultiMC::InstallUpdate()
{
	int tryNum = 0;
	wxProgressDialog *progDlg = new wxProgressDialog(_("Installing updates..."),
		_("Waiting for old version to exit..."));

Retry:
	tryNum++;
	progDlg->Pulse(wxString::Format(
		_("Waiting for old version to exit... Try #%i."), tryNum));

	// Let the other process exit.
	PulseYieldSleep(1, progDlg);

	wxFileName targetFile(updateTarget);
	
	if (!wxCopyFile(thisFileName, targetFile.GetFullPath()))
	{
		if (tryNum < installUpdateTries)
			goto Retry;
		else
		{
			wxLogError(_("Failed to install updates. Tried %i times. \n\
This is probably because the file that is supposed to be updated is in use. \n\
Please check to make sure there are no other running MultiMC processes \n\
and that MultiMC's updater has sufficient permissions to replace the file \n\
%s and then try again."), tryNum, targetFile.GetFullPath().c_str());
			progDlg->Destroy();
			return;
		}
	}

	progDlg->Pulse(_("Update installed successfully. Starting MultiMC..."));
	progDlg->Fit();
	progDlg->CenterOnScreen();
	wxYieldIfNeeded();
	
	targetFile.MakeAbsolute();

	if (!updateQuiet)
	{
		wxProcess proc;
		wxExecute("\"" + targetFile.GetFullPath() + "\"", wxEXEC_ASYNC, &proc);
		proc.Detach();
	}
	progDlg->Destroy();
}

void MultiMC::YieldSleep(int secs)
{
	int waitLoops = secs * 10;
	for (int i = 0; i < waitLoops; i++)
	{
		wxMilliSleep(100);
		Yield(true);
	}
}
예제 #6
0
void PHPWorkspace::DoNotifyFilesRemoved(const wxArrayString& files)
{
    if(!files.IsEmpty()) {

        wxBusyInfo info(_("Updating workspace..."));
        wxYieldIfNeeded();
        EventNotifier::Get()->PostFileRemovedEvent(files);
    }
}
예제 #7
0
inline void PulseYieldSleep(int secs, wxProgressDialog *dlg)
{
	int waitLoops = secs * 10;
	for (int i = 0; i < waitLoops; i++)
	{
		wxMilliSleep(100);
		wxYieldIfNeeded();
		dlg->Pulse();
	}
}
예제 #8
0
파일: utilscmn.cpp 프로젝트: 252525fb/rpcs3
// Yield to other apps/messages and disable user input to all windows except
// the given one
bool wxSafeYield(wxWindow *win, bool onlyIfNeeded)
{
    wxWindowDisabler wd(win);

    bool rc;
    if (onlyIfNeeded)
        rc = wxYieldIfNeeded();
    else
        rc = wxYield();

    return rc;
}
예제 #9
0
cbSplashScreen::cbSplashScreen(wxBitmap &label, long timeout, wxWindow *parent, wxWindowID id, long style)
: wxFrame(parent, id, wxEmptyString, wxPoint(0, 0), wxSize(100, 100), style),
  m_timer(this, cbSplashScreen_timer_id)//, r(0, 0, 181, 181)
{
  //r.Union(50, 35, 181, 181);
  //r.Union(166, 13, 181, 181);
  //r.Union(259, 29, 181, 181);

  int w = label.GetWidth();
  int h = label.GetHeight();

  SetClientSize(w, h);
  CentreOnScreen();

  wxScreenDC screen_dc;
  wxMemoryDC label_dc;

  #ifndef __WXMAC__
    int x = GetPosition().x;
    int y = GetPosition().y;
  #endif

  m_label.Create(w, h);

  label_dc.SelectObject(m_label);
  #ifndef __WXMAC__
    label_dc.Blit(0, 0, w, h, &screen_dc, x, y);
  #else
    label_dc.SetBackground(*wxWHITE_BRUSH);
    label_dc.Clear();
  #endif
  label_dc.DrawBitmap(label, 0, 0, true);
  label_dc.SelectObject(wxNullBitmap);

  //SetShape(r);

  Show(true);
  SetThemeEnabled(false); // seems to be useful by description
  SetBackgroundStyle(wxBG_STYLE_CUSTOM); // the trick for GTK+ (notice it's after Show())

  #if ( defined( __WXMAC__ ) || defined( __WXMSW__ ) )
    Update();
  #else
    wxYieldIfNeeded();
  #endif

  if (timeout != -1)
  {
    m_timer.Start(timeout, true);
  }
}
예제 #10
0
파일: ConLog.cpp 프로젝트: bsaetia/rpcs3
void LogWriter::WriteToLog(const std::string& prefix, const std::string& value, u8 lvl/*, wxColour bgcolour*/)
{
	std::string new_prefix = prefix;
	if(!prefix.empty())
	{
		if(NamedThreadBase* thr = GetCurrentNamedThread())
		{
			new_prefix += " : " + thr->GetThreadName();
		}
	}

	if(m_logfile.IsOpened() && !new_prefix.empty())
		m_logfile.Write(fmt::FromUTF8("[" + new_prefix + "]: " + value + "\n"));

	if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue()))
		return;

	std::lock_guard<std::mutex> lock(g_cs_conlog);

#ifdef QT_UI
	// TODO: Use ThreadBase instead, track main thread id
	if(QThread::currentThread() == qApp->thread())
#else
	if(wxThread::IsMain())
#endif
	{
		while(LogBuffer.IsBusy())
		{
			// need extra break condition?
			wxYieldIfNeeded();
		}
	}
	else
	{
		while (LogBuffer.IsBusy())
		{
			if (Emu.IsStopped())
			{
				break;
			}
			Sleep(1);
		}
	}

	//if(LogBuffer.put == LogBuffer.get) LogBuffer.Flush();

	LogBuffer.Push(LogPacket(new_prefix, value, g_log_colors[lvl]));
}
예제 #11
0
void HexEditorCtrl::ControlShow( panels control, bool show ){
	if( control == OFFSET_CTRL ){
		offset_ctrl->Show( show );
		m_static_offset->Show(show);
		}
	else if(control == HEX_CTRL ){
		hex_ctrl->Show( show );
		m_static_address->Show(show);
		}
	else if(control == TEXT_CTRL ){
		text_ctrl->Show( show );
		m_static_byteview->Show(show);
		}
	wxYieldIfNeeded();
	Layout();
	Fit();
	}
예제 #12
0
void EffectNyquist::OSCallback()
{
   if (mStop) {
      mStop = false;
      nyx_stop();
   }
   else if (mBreak) {
      mBreak = false;
      nyx_break();
   }
   else if (mCont) {
      mCont = false;
      nyx_continue();
   }

   wxYieldIfNeeded();
}
예제 #13
0
파일: progdlgg.cpp 프로젝트: 252525fb/rpcs3
bool wxProgressDialog::DoAfterUpdate(bool *skip)
{
    // we have to yield because not only we want to update the display but
    // also to process the clicks on the cancel and skip buttons
    wxYieldIfNeeded();

    Update();

    if ( m_skip && skip && !*skip )
    {
        *skip = true;
        m_skip = false;
        EnableSkip();
    }

    return m_state != Canceled;
}
예제 #14
0
wxSplashScreen::wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds,
                               wxWindow* parent, wxWindowID id, const wxPoint& pos,
                               const wxSize& size, long style)
    : wxFrame(parent, id, wxEmptyString, wxPoint(0,0), wxSize(100, 100),
              style | wxFRAME_TOOL_WINDOW | wxFRAME_NO_TASKBAR)
{
    Init();

    // splash screen must not be used as parent by the other windows because it
    // is going to disappear soon, indicate it by giving it this special style
    SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);

#if defined(__WXGTK20__)
    gtk_window_set_type_hint(GTK_WINDOW(m_widget),
                             GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
#endif

    m_splashStyle = splashStyle;
    m_milliseconds = milliseconds;

    m_window = new wxSplashScreenWindow(bitmap, this, wxID_ANY, pos, size, wxNO_BORDER);

    SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());

    if (m_splashStyle & wxSPLASH_CENTRE_ON_PARENT)
        CentreOnParent();
    else if (m_splashStyle & wxSPLASH_CENTRE_ON_SCREEN)
        CentreOnScreen();

    if (m_splashStyle & wxSPLASH_TIMEOUT)
    {
        m_timer.SetOwner(this, wxSPLASH_TIMER_ID);
        m_timer.Start(milliseconds, true);
    }

    Show(true);
    m_window->SetFocus();
#if defined( __WXMSW__ ) || defined(__WXMAC__)
    Update(); // Without this, you see a blank screen for an instant
#elif defined(__WXGTK20__)
    // we don't need to do anything at least on wxGTK with GTK+ 2.12.9
#else
    wxYieldIfNeeded(); // Should eliminate this
#endif
}
예제 #15
0
void wxDownloadDialog::OnIdle(wxIdleEvent &ev)
{
    if (m_bDisableEvents || !m_bConnecting)
        return;

    static wxDateTime lastLabelUpdate = wxDateTime::Now();
    if ((wxDateTime::Now() - lastLabelUpdate).GetMilliseconds() > 200)   // avoid flickering
    {
        // we don't know how much we progressed
        m_pGauge->Pulse();

        lastLabelUpdate = wxDateTime::Now();
    }

    // we have to yield because not only we want to update the display but
    // also to process the clicks on the cancel and skip buttons
    wxYieldIfNeeded();
}
예제 #16
0
/* static */
void AutoCaptureMechanism::Delay(int seconds)
{
    // TODO: Switch this to use wxTimer.

    // Wait for 3 seconds
    clock_t start = clock();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    while ( clock() - start < (clock_t)CLOCKS_PER_SEC * seconds)
        wxYieldIfNeeded();
}
예제 #17
0
void FreqWindow::Recalc()
{
   if (!mData || mDataLen < mWindowSize) {
      DrawPlot();
      return;
   }

   SpectrumAnalyst::Algorithm alg =
      SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
   int windowFunc = mFuncChoice->GetSelection();

   wxWindow *hadFocus = FindFocus();
   // In wxMac, the skipped window MUST be a top level window.  I'd originally made it
   // just the mProgress window with the idea of preventing user interaction with the
   // controls while the plot was being recalculated.  This doesn't appear to be necessary
   // so just use the the top level window instead.
   {
      Maybe<wxWindowDisabler> blocker;
      if (IsShown())
         blocker.create(this);
      wxYieldIfNeeded();

      mAnalyst->Calculate(alg, windowFunc, mWindowSize, mRate,
         mData.get(), mDataLen,
         &mYMin, &mYMax, mProgress);
   }
   if (hadFocus) {
      hadFocus->SetFocus();
   }

   if (alg == SpectrumAnalyst::Spectrum) {
      if(mYMin < -dBRange)
         mYMin = -dBRange;
      if(mYMax <= -dBRange)
         mYMax = -dBRange + 10.; // it's all out of range, but show a scale.
      else
         mYMax += .5;
   }

   // Prime the scrollbar
   mPanScroller->SetScrollbar(0, (mYMax - mYMin) * 100, (mYMax - mYMin) * 100, 1);

   DrawPlot();
}
예제 #18
0
void wxDownloadDialog::OnDownloadUpdate(wxDownloadEvent &ev)
{
    // the input stream has been created - now we've started to download data
    m_bConnecting = false;

    if (m_bDisableEvents)
        return;

    static wxDateTime lastLabelUpdate = wxDateTime::Now();
    wxLogDebug(wxS("wxDownloadDialog::OnDownloadUpdate"));

    if ((wxDateTime::Now() - lastLabelUpdate).GetMilliseconds() > 200)   // avoid flickering
    {
        double fraction = ev.GetDownloadProgress();
        if (fraction != 0)
        {
            m_pGauge->SetValue((int)(fraction * 100));
        }
        else
        {
            // we don't know how much we progressed
            m_pGauge->Pulse();
        }

        if (m_pElapsedTime)
            m_pElapsedTime->SetLabel(ev.GetElapsedTime().Format());
        if (m_pRemainingTime)
            m_pRemainingTime->SetLabel(ev.GetEstimatedRemainingTime().Format());
        if (m_pEstimatedTime)
            m_pEstimatedTime->SetLabel(ev.GetEstimatedTime().Format());

        wxString currsize = wxFileName::GetHumanReadableSize(ev.GetCurrentSize()),
                 totalsize = wxFileName::GetHumanReadableSize(ev.GetTotalSize());
        m_pSize->SetLabel(currsize + wxS(" / ") + totalsize);
        m_pSpeed->SetLabel(ev.GetHumanReadableDownloadSpeed());

        lastLabelUpdate = wxDateTime::Now();
    }

    // we have to yield because not only we want to update the display but
    // also to process the clicks on the cancel and skip buttons
    wxYieldIfNeeded();
}
예제 #19
0
파일: splash.cpp 프로젝트: EdgarTx/wx
wxSplashScreen::wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
    wxFrame(parent, id, wxEmptyString, wxPoint(0,0), wxSize(100, 100), style)
{
    // At least for GTK+ 2.0, this hint is not available.
#if defined(__WXGTK20__)
#if GTK_CHECK_VERSION(2,2,0)
    gtk_window_set_type_hint(GTK_WINDOW(m_widget),
                             GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
#endif
#endif

    m_window = NULL;
    m_splashStyle = splashStyle;
    m_milliseconds = milliseconds;

    m_window = new wxSplashScreenWindow(bitmap, this, wxID_ANY, pos, size, wxNO_BORDER);

    SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());

    if (m_splashStyle & wxSPLASH_CENTRE_ON_PARENT)
        CentreOnParent();
    else if (m_splashStyle & wxSPLASH_CENTRE_ON_SCREEN)
        CentreOnScreen();

    if (m_splashStyle & wxSPLASH_TIMEOUT)
    {
        m_timer.SetOwner(this, wxSPLASH_TIMER_ID);
        m_timer.Start(milliseconds, true);
    }

    Show(true);
    m_window->SetFocus();
#if defined( __WXMSW__ ) || defined(__WXMAC__)
    Update(); // Without this, you see a blank screen for an instant
#else
    wxYieldIfNeeded(); // Should eliminate this
#endif
}
예제 #20
0
SplashScreen::SplashScreen( wxBitmap &label, long timeout, wxWindow *parent, wxWindowID id, long style )
        : wxFrame( parent, id, wxEmptyString, wxPoint( 0, 0 ), wxSize( 100, 100 ), style ),
        r( 0, 0, 181, 181 ), m_timer( this, cbSplashScreen_timer_id ),
        timeUp(false)
{
    r.Union( label );

    int w = label.GetWidth();
    int h = label.GetHeight();

    SetClientSize( w, h );
    CentreOnScreen();

    wxScreenDC screen_dc;
    wxMemoryDC label_dc;

    int x;
    int y;

    x = GetPosition().x;
    y = GetPosition().y;

    m_label.Create( w, h );

    label_dc.SelectObject( m_label );
    label_dc.Blit( 0, 0, w, h, &screen_dc, x, y );
    label_dc.DrawBitmap( label, 0, 0, true );
    label_dc.SelectObject( wxNullBitmap );

    SetShape( r );

    Show( true );
    SetThemeEnabled( false ); // seems to be useful by description
    SetBackgroundStyle( wxBG_STYLE_CUSTOM ); // the trick for GTK+ (notice it's after Show())

    SetTitle("GDevelop");

    wxIconBundle icons;
    icons.AddIcon("res/icon16.png");
    icons.AddIcon("res/icon24.png");
    #if defined(LINUX) || defined(MACOS)
    icons.AddIcon("res/icon32linux.png");
    icons.AddIcon("res/icon48linux.png");
    icons.AddIcon("res/icon64linux.png");
    icons.AddIcon("res/icon128linux.png");
    #else
    icons.AddIcon("res/icon32.png");
    icons.AddIcon("res/icon48.png");
    icons.AddIcon("res/icon128.png");
    #endif
    SetIcons(icons);

    Centre( wxBOTH | wxCENTRE_ON_SCREEN ); // centre only works when the window is showing

    Update();
    wxYieldIfNeeded();

    if ( timeout != -1 )
    {
        m_timer.Start( timeout, true );
    }
}
예제 #21
0
파일: progdlgg.cpp 프로젝트: 252525fb/rpcs3
bool
wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
{
    wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );

#ifdef __WXMSW__
    value /= m_factor;
#endif // __WXMSW__

    wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );

    if ( m_gauge )
        m_gauge->SetValue(value);

    UpdateMessage(newmsg);

    if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
    {
        unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
        if (    m_last_timeupdate < elapsed
             || value == m_maximum
           )
        {
            m_last_timeupdate = elapsed;
            unsigned long estimated = m_break +
                  (unsigned long)(( (double) (elapsed-m_break) * m_maximum ) / ((double)value)) ;
            if (    estimated > m_display_estimated
                 && m_ctdelay >= 0
               )
            {
                ++m_ctdelay;
            }
            else if (    estimated < m_display_estimated
                      && m_ctdelay <= 0
                    )
            {
                --m_ctdelay;
            }
            else
            {
                m_ctdelay = 0;
            }
            if (    m_ctdelay >= m_delay          // enough confirmations for a higher value
                 || m_ctdelay <= (m_delay*-1)     // enough confirmations for a lower value
                 || value == m_maximum            // to stay consistent
                 || elapsed > m_display_estimated // to stay consistent
                 || ( elapsed > 0 && elapsed < 4 ) // additional updates in the beginning
               )
            {
                m_display_estimated = estimated;
                m_ctdelay = 0;
            }
        }

        long display_remaining = m_display_estimated - elapsed;
        if ( display_remaining < 0 )
        {
            display_remaining = 0;
        }

        SetTimeLabel(elapsed, m_elapsed);
        SetTimeLabel(m_display_estimated, m_estimated);
        SetTimeLabel(display_remaining, m_remaining);
    }

    if ( value == m_maximum )
    {
        if ( m_state == Finished )
        {
            // ignore multiple calls to Update(m_maximum): it may sometimes be
            // troublesome to ensure that Update() is not called twice with the
            // same value (e.g. because of the rounding errors) and if we don't
            // return now we're going to generate asserts below
            return true;
        }

        // so that we return true below and that out [Cancel] handler knew what
        // to do
        m_state = Finished;
        if( !(GetWindowStyle() & wxPD_AUTO_HIDE) )
        {
            EnableClose();
            DisableSkip();
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
            EnableCloseButton();
#endif // __WXMSW__

            if ( newmsg.empty() )
            {
                // also provide the finishing message if the application didn't
                m_msg->SetLabel(_("Done."));
            }

            wxYieldIfNeeded() ;

            (void)ShowModal();
        }
        else // auto hide
        {
            // reenable other windows before hiding this one because otherwise
            // Windows wouldn't give the focus back to the window which had
            // been previously focused because it would still be disabled
            ReenableOtherWindows();

            Hide();
        }
    }
    else // not at maximum yet
    {
        return DoAfterUpdate(skip);
    }

    // update the display in case yielding above didn't do it
    Update();

    return m_state != Canceled;
}
예제 #22
0
void rYieldIfNeeded()
{
	wxYieldIfNeeded();
}