当前位置: 首页>>代码示例>>C++>>正文


C++ wxTimeSpan函数代码示例

本文整理汇总了C++中wxTimeSpan函数的典型用法代码示例。如果您正苦于以下问题:C++ wxTimeSpan函数的具体用法?C++ wxTimeSpan怎么用?C++ wxTimeSpan使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wxTimeSpan函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

const wxTimeSpan IdleDetector::GetIdleTime()
{
#ifdef WIN32
	LASTINPUTINFO   info;
	info.cbSize = sizeof(info);
	if (::GetLastInputInfo (&info))
	{
		long timeIdle = ::GetTickCount() - info.dwTime;
		// Handle overflow
		if (timeIdle < 0)
			timeIdle = timeIdle + UINT_MAX + 1;

		return wxTimeSpan(0, 0, 0, timeIdle);
	}
#else
	if( screen_info == NULL ) {
		screen_info = XScreenSaverAllocInfo();
		display = XOpenDisplay(0);
	}

	XScreenSaverQueryInfo(display, DefaultRootWindow(display), screen_info);
	return wxTimeSpan( 0, 0, 0, screen_info->idle );
#endif
	return wxTimeSpan ();
}
开发者ID:alexcb,项目名称:tracker,代码行数:25,代码来源:inactivity.cpp

示例2: wxDateTime

void CGarbageCollector::RecycleTaskInstances()
{
    BSLERRCODE rc;
    std::vector<CTaskInstance*> oTaskInstances;
    std::vector<CTaskInstance*>::iterator iter;
    CTaskInstance* pTaskInstance = NULL;
    CRPCProfile* pRPCProfile = NULL;
    CSyncProfile* pSyncProfile = NULL;
    wxDateTime dtExpirationDate = wxDateTime((time_t)0);
    wxDateTime dtRPCCompletedDate = wxDateTime((time_t)0);
    wxUint32 uiInterval = 0;

    rc = m_pHost->FindSyncProfile(CBSLClient::AutoSyncPropertyTaskInstancesUpdateInterval, &pSyncProfile);
    if (BSLERR_SUCCESS != rc) return;
    if (!pSyncProfile) return;

    rc = m_pHost->FindRPCProfile(CLASSINFO(CRPCSyncTaskInstances)->GetClassName(), &pRPCProfile);
    if (BSLERR_SUCCESS != rc) return;
    if (!pRPCProfile) return;

    uiInterval = pSyncProfile->GetValue();
    if (!uiInterval) return;

    dtRPCCompletedDate = pRPCProfile->GetLastRequestTime() + pRPCProfile->GetTotalDuration();

    rc = m_pHost->EnumerateTaskInstances(oTaskInstances);
    if (BSLERR_SUCCESS != rc) return;

    for (iter = oTaskInstances.begin(); iter != oTaskInstances.end(); ++iter)
    {
        pTaskInstance = *iter;

        // An item is deemed expired if it wasn't refreshed the last time the synchronize
        // RPC was called.
        //
        dtExpirationDate =
            pTaskInstance->GetLastModifiedTime() +
            wxTimeSpan(0, 0, uiInterval, 0) +
            wxTimeSpan(0, 0, 0, 250);

        if ((m_dtNow > dtExpirationDate) && (dtRPCCompletedDate > dtExpirationDate))
        {
            wxLogTrace(wxT("Function Status"),
                wxT("CGarbageCollector::RecycleTaskInstances - Recycle '%p', dtNow: '%s', dtExpirationDate: '%s', dtRPCCompletedDate: '%s'"),
                pTaskInstance,
                m_dtNow.Format(wxT("%H:%M:%S.%l")).c_str(),
                dtRPCCompletedDate.Format(wxT("%H:%M:%S.%l")).c_str(),
                dtExpirationDate.Format(wxT("%H:%M:%S.%l")).c_str()
            );

            m_pHost->DeleteTaskInstance(pTaskInstance);
        }
    }
}
开发者ID:romw,项目名称:boincsentinels,代码行数:54,代码来源:GarbageCollector.cpp

示例3: wxTimeSpan

wxTimeSpan CControlSocket::GetTimezoneOffset()
{
	if (!m_pCurrentServer)
		return wxTimeSpan();

	int seconds = 0;
	if (CServerCapabilities::GetCapability(*m_pCurrentServer, timezone_offset, &seconds) != yes)
		return wxTimeSpan();

	return wxTimeSpan(0, 0, seconds);
}
开发者ID:bugiii,项目名称:filezilla3ex,代码行数:11,代码来源:ControlSocket.cpp

示例4: ElapsedTimeToStr

wxString ElapsedTimeToStr(wxLongLong msec)
{
	wxTimeSpan tsMsec(0, 0, 0, msec);

	int days = tsMsec.GetDays();
	int hours = (wxTimeSpan(tsMsec.GetHours(), 0, 0, 0) - wxTimeSpan(days * 24)).GetHours();
	int minutes = (wxTimeSpan(0, tsMsec.GetMinutes(), 0, 0) - wxTimeSpan(hours)).GetMinutes();
	long seconds = (wxTimeSpan(0, 0, tsMsec.GetSeconds(), 0) - wxTimeSpan(0, minutes)).GetSeconds().ToLong();
	long milliseconds = (wxTimeSpan(0, 0, 0, tsMsec.GetMilliseconds()) - wxTimeSpan(0, 0, seconds)).GetMilliseconds().ToLong();

	if (days > 0)
		return wxString::Format(
		           wxT("%d %s, %02d:%02d:%02ld hours"),
		           days, wxT("days"), hours, minutes, seconds
		       );
	else if (hours > 0)
		return wxString::Format(
		           wxT("%02d:%02d:%02ld hours"), hours, minutes, seconds
		       );
	else if (msec >= 1000 * 60)
		return wxString::Format(wxT("%02d:%02ld minutes"), minutes, seconds);
	else if (msec >= 1000)
		return wxString::Format(
		           wxT("%ld.%ld secs"), seconds, milliseconds / 100
		       );
	else
		return msec.ToString() + wxT(" msec");
}
开发者ID:swflb,项目名称:pgadmin3,代码行数:28,代码来源:misc.cpp

示例5: fn

void FileNameTestCase::TestGetTimes()
{
    wxFileName fn(wxFileName::CreateTempFileName("filenametest"));
    CPPUNIT_ASSERT( fn.IsOk() );
    wxON_BLOCK_EXIT1( wxRemoveFile, fn.GetFullPath() );

    wxDateTime dtAccess, dtMod, dtCreate;
    CPPUNIT_ASSERT( fn.GetTimes(&dtAccess, &dtMod, &dtCreate) );

    // make sure all retrieved dates are equal to the current date&time 
    // with an accuracy up to 1 minute
    CPPUNIT_ASSERT(dtCreate.IsEqualUpTo(wxDateTime::Now(), wxTimeSpan(0,1)));
    CPPUNIT_ASSERT(dtMod.IsEqualUpTo(wxDateTime::Now(), wxTimeSpan(0,1)));
    CPPUNIT_ASSERT(dtAccess.IsEqualUpTo(wxDateTime::Now(), wxTimeSpan(0,1)));
}
开发者ID:slunski,项目名称:wxWidgets,代码行数:15,代码来源:filenametest.cpp

示例6: switch

wxString BattleListCtrl::GetItemText(long item, long column) const
{
    if ( m_data[item] == NULL )
        return wxEmptyString;

    const IBattle& battle= *m_data[item];
    const BattleOptions& opts = battle.GetBattleOptions();

    switch ( column ) {
        case 0:
        case 1:
        case 2:
        default: return wxEmptyString;

        case 3: return ( opts.description );
		case 4: return ( battle.GetHostMapName() );
		case 5: return ( battle.GetHostModName() );
        case 6: return ( opts.founder );
		case 7: return wxFormat(_T("%d") ) % int(battle.GetSpectators());
		case 8: return wxFormat(_T("%d") ) % (int(battle.GetNumUsers()) - int(battle.GetSpectators()));
		case 9: return wxFormat(_T("%d") ) % int(battle.GetMaxPlayers());
        case 10: return ( wxTimeSpan(0/*h*/,0/*m*/,
                                     battle.GetBattleRunningTime()).Format(_T("%H:%M")) );
		case 11: return battle.GetEngineVersion();
    }
}
开发者ID:tulipe7,项目名称:springlobby,代码行数:26,代码来源:battlelistctrl.cpp

示例7: wxGetApp

UserSettings::UserSettings() {
  IconSize = wxGetApp().GetOSValidIconSize(LARGE_ICON_SIZE);
  Locale = _T("en");
  PortableAppsPath = _T("$(Drive)/PortableApps");
  DocumentsPath = _T("$(Drive)/Documents");
  MusicPath = _T("$(Drive)/Documents/Music");
  PicturesPath = _T("$(Drive)/Documents/Pictures");
  VideosPath = _T("$(Drive)/Documents/Videos");
  Skin = _T("Default");
  Rotated = false;
  AlwaysOnTop = false;
  MinimizeOnClose = true;
  UniqueApplicationInstance = true;
  AutoHideApplication = false;
  RunMultiLaunchOnStartUp = false;
  CloseAppsOnEject = false;
  HotKeyControl = false;
  HotKeyAlt = false;
  HotKeyShift = false;
  HotKeyKey = 0;

  ShowDeleteIconMessage = true;
  ShowEjectDriveMessage = true;
  ShowMinimizeMessage = true;

  NextUpdateCheckTime = wxDateTime::Now();
  // This is just to force an update check the first time the 
  // app is launched.
  NextUpdateCheckTime.Subtract(wxTimeSpan(24));
}
开发者ID:tanaga9,项目名称:appetizer,代码行数:30,代码来源:UserSettings.cpp

示例8: SetOwner

void IdleDetector::Start (wxEvtHandler* owner, const wxTimeSpan& timeout)
{
	SetOwner (owner);
	m_timeout = timeout;
	m_isIdle = false;
	SetState (false, wxTimeSpan());
}
开发者ID:alexcb,项目名称:tracker,代码行数:7,代码来源:inactivity.cpp

示例9: TIME_ASSERT

bool CDateTime::ImbueTime( int hour, int minute, int second, int millisecond )
{
	if( !IsValid() || a_ > days ) {
		return false;
	}

	if( second == -1 ) {
		a_ = minutes;
		TIME_ASSERT(millisecond == -1);
		second = millisecond = 0;
	}
	else if( millisecond == -1 ) {
		a_ = seconds;
		millisecond = 0;
	}
	else {
		a_ = milliseconds;
	}

	if( hour < 0 || hour >= 24 ) {
		return false;
	}
	if( minute < 0 || minute >= 60 ) {
		return false;
	}
	if( second < 0 || second >= 60 ) {
		return false;
	}
	if( millisecond < 0 || millisecond >= 1000 ) {
		return false;
	}

	t_ += wxTimeSpan(hour, minute, second, millisecond);
	return true;
}
开发者ID:Typz,项目名称:FileZilla,代码行数:35,代码来源:timeex.cpp

示例10: wxTimeSpan

void PlotDialog::OnMouseEventsPlot( wxMouseEvent& event )
{
    wxStaticText *stMousePosition[3] = {m_stMousePosition1, m_stMousePosition2, m_stMousePosition3};
    if(event.Leaving()) {
        for(int i=0; i<3; i++)
            stMousePosition[i]->SetLabel(_("N/A"));
        return;
    }

    int w, h;
    m_PlotWindow->GetSize( &w, &h);

    wxPoint p = event.GetPosition();

#if 0
    double position = m_sPosition->GetValue() / 100.0;
    double scale = 100.0 / m_sScale->GetValue();

    double time = (((double)p.x/w - position) / scale + position) * (m_maxtime - m_mintime) + m_mintime;
    wxDateTime datetime = m_StartTime + wxTimeSpan(0, 0, time);
#endif

    for(int i=0; i<3; i++) {
        double value = (1.0 - (double)p.y / h) * (m_maxvalue - m_minvalue) + m_minvalue;
        stMousePosition[i]->SetLabel(wxString::Format(_T(" %.3f"), value));
    }
}
开发者ID:Rasbats,项目名称:OpenCPN.3.3.1117_weather_routing,代码行数:27,代码来源:PlotDialog.cpp

示例11: MinTime

wxDateTime GRIBUIDialog::TimelineTime()
{
    int tl = (m_TimeLineHours == 0) ? 0 : m_sTimeline->GetValue();
    int hours = tl/m_OverlaySettings.m_HourDivider;
    int minutes = (tl%m_OverlaySettings.m_HourDivider)*60/m_OverlaySettings.m_HourDivider;
    return MinTime() + wxTimeSpan(hours, minutes);
}
开发者ID:IgorMikhal,项目名称:OpenCPN,代码行数:7,代码来源:GribUIDialog.cpp

示例12: WXCTimer

void WXCJob::Start ()
{
    wxDateTime dtNextExec;

    // old timer there?
    if (pTimer_)
        pTimer_->Stop();
    else
        pTimer_ = new WXCTimer(this);

    // get last execution
    wxDateTime dtLastExec = WXCTimestampFile::Instance().GetLast(GetOriginalLine());

    // there is a last execution timestamp
    if ( dtLastExec.IsValid() )
    {
        // last execution in the past
        if ( dtLastExec <= wxDateTime::Now() )
        {
            // catchup ?
            if ( !bOption_nocatchup_ )
            {
                // catch up the job
                if ( time_.GetNext(dtLastExec) < wxDateTime::Now() )
                {
                    Execute();
                    return;
                }
                else
                {
                    dtNextExec = time_.GetNext(dtLastExec);
                }
            }
            else
            {
                dtNextExec = time_.GetNext();
            }
        }
        else
        // its in the future
        {
            dtNextExec = dtLastExec;
        }
    }

	// the job wasn't started before
    if ( !(dtNextExec.IsValid()) )
		dtNextExec = wxDateTime::Now() + wxTimeSpan(0, 0, 15);

    // start the timer
    pTimer_->Start(dtNextExec);

    // remember timestamp for future execution
    if ( !(dtLastExec.IsValid()) )
    {
        WXCTimestampFile::Instance().Set(GetOriginalLine(), dtNextExec);
        WXCTimestampFile::Instance().Save();
    }
}
开发者ID:BackupTheBerlios,项目名称:wxcron-svn,代码行数:59,代码来源:WXCJob.cpp

示例13: WXUNUSED

void TimerRecordDialog::OnTimeText_Duration(wxCommandEvent& WXUNUSED(event))
{
   double dTime = m_pTimeTextCtrl_Duration->GetTimeValue();
   long hr = (long)(dTime / 3600.0);
   long min = (long)((dTime - (hr * 3600.0)) / 60.0);
   long sec = (long)(dTime - (hr * 3600.0) - (min * 60.0));
   m_TimeSpan_Duration = wxTimeSpan(hr, min, sec); //v milliseconds?

   this->UpdateEnd(); // Keep Start constant and update End for changed Duration.
}
开发者ID:Cactuslegs,项目名称:audacity-of-nope,代码行数:10,代码来源:TimerRecordDialog.cpp

示例14: TToString

//date/time in the desired time zone format
static wxString TToString( const wxDateTime date_time, const int time_zone )
{  
    wxDateTime t( date_time );
    t.MakeFromTimezone( wxDateTime::UTC );
    if( t.IsDST() ) t.Subtract( wxTimeSpan( 1, 0, 0, 0 ) );
    switch( time_zone ) {
        case 0: return t.Format( _T(" %a %d-%b-%Y  %H:%M "), wxDateTime::Local ) + _T("LOC");//:%S
        case 1: 
        default: return t.Format( _T(" %a %d-%b-%Y %H:%M  "), wxDateTime::UTC ) + _T("UTC");
    }
}
开发者ID:IgorMikhal,项目名称:OpenCPN,代码行数:12,代码来源:GribUIDialog.cpp

示例15: wxAtoi

void wxGPProcess::ProcessInput(wxString sInputData)
{
	if(m_nState != enumGISTaskWork)
        return;
    sInputData = sInputData.Trim(true).Trim(false);
//INFO, DONE, ERR, ??
	wxString sRest;
	if( sInputData.StartsWith(wxT("DONE: "), &sRest) )
	{
		int nPercent = wxAtoi(sRest.Trim(true).Trim(false).Truncate(sRest.Len() - 1));
		wxTimeSpan Elapsed = wxDateTime::Now() - m_dtBeg;//time left
        wxString sTxt;
		if(m_pProgressor)
			m_pProgressor->SetValue(nPercent);

        double nPercentR = 100 - nPercent;
		if(nPercentR >= 0)
		{
			//wxTimeSpan Remains = Elapsed * (nPercentR / nPercent);
			long dMSec = double(Elapsed.GetMilliseconds().ToDouble() * nPercentR) / nPercent;
			wxTimeSpan Remains = wxTimeSpan(0,0,0,dMSec);
			m_dtEstEnd = wxDateTime::Now() + Remains;
			sTxt = wxString(_("Remains ")) + Remains.Format(_("%H hour(s) %M min. %S sec."));
		}

		if(m_pTrackCancel && !sTxt.IsEmpty())
			m_pTrackCancel->PutMessage(sTxt, -1, enumGISMessageTitle);
		return;
	}
	if( sInputData.StartsWith(wxT("INFO: "), &sRest) )
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sRest, -1, enumGISMessageNorm);
		return;
	}
	if( sInputData.StartsWith(wxT("ERR: "), &sRest) )
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sRest, -1, enumGISMessageErr);
		return;
	}
	if( sInputData.StartsWith(wxT("WARN: "), &sRest) )
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sRest, -1, enumGISMessageWarning);
		return;
	}
    else
	{
		if(m_pTrackCancel)
			m_pTrackCancel->PutMessage(sInputData, -1, enumGISMessageInfo);
		return;
	}
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:54,代码来源:gptoolmngr.cpp


注:本文中的wxTimeSpan函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。