void CopyDialog::EventTimer( int tid ) { if ( tid == 1 ) { unsigned ms = 0; int64_t bytes = 0; { MutexLock lock( &threadData.infoMutex ); ms = threadData.infoMs; bytes = threadData.infoBytes; threadData.infoBytes = 0; lock.Unlock(); } //shift int i; for ( i = SPEED_NODE_COUNT - 1; i > 0; i-- ) { _speedList[i] = _speedList[i - 1]; } _speedList[0].bytes = bytes; if ( bytes > 0 ) { unsigned n = ms - _lastMs; _speedList[0].deltaMs = n > 1000000 ? 0 : n; _lastMs = ms; } else { _speedList[0].deltaMs = 0; } int64_t sumBytes = 0; int64_t sumMs = 0; for ( i = 0; i < SPEED_NODE_COUNT; i++ ) { sumMs += _speedList[i].deltaMs; sumBytes += _speedList[i].bytes; } int64_t speed = 0; if ( sumMs > 0 && sumBytes > 0 ) { speed = ( sumBytes * 1000 ) / sumMs; } _speedStr.SetText( utf8str_to_unicode( GetSmallPrintableSpeedStr( speed ) ).data() ); return; } }
void SysOptDialog::SetCurLang(const char *id) { curLangId = new_char_str(id); if (id[0] == '-') langVal.SetText( utf8_to_unicode( _LT("English") ).ptr() ); else if (id[0]=='+') langVal.SetText( utf8_to_unicode( _LT("Autodetect") ).ptr() ); else { for (int i = 0; i<list.count(); i++) { if (!strcmp(list[i].id.ptr(), id)) { langVal.SetText( utf8_to_unicode( list[i].name.ptr() ).ptr() ); return; } } langVal.SetText( utf8_to_unicode( id ).ptr() ); } }
bool SftpLogonDialog::Command( int id, int subId, Win* win, void* data ) { if ( id == 1000 ) { int ret; if ( SelectCharset( ( NCDialogParent* )Parent(), &ret, charset ) ) { charset = ret; charsetIdText.SetText( utf8_to_unicode( charset_table[ret]->name ).data() ); } return true; } return NCVertDialog::Command( id, subId, win, data ); }
void StyleOptDialog::RefreshFontInfo() { int count = pList->count(); int cur = fontList.GetCurrent(); const char *s = ""; if (count>=0 && cur>=0 && cur<count) { int n = fontList.GetCurrentInt(); if (pList->get(n).newFont.ptr()) s = pList->get(n).newFont->printable_name(); else if (pList->get(n).oldFont) s = pList->get(n).oldFont->printable_name(); } fontNameStatic.SetText(utf8_to_unicode(s).ptr()); }