void VDUIHotKeyExControlW32::OnPaint() { PAINTSTRUCT ps; HDC hdc = BeginPaint(mhwnd, &ps); if (!hdc) return; RECT r; if (GetClientRect(mhwnd, &r)) { VDVERIFY(DrawEdge(hdc, &r, EDGE_SUNKEN, BF_ADJUST | BF_RECT)); VDVERIFY(FillRect(hdc, &r, (HBRUSH)(COLOR_WINDOW + 1))); int cx = GetSystemMetrics(SM_CXEDGE); int cy = GetSystemMetrics(SM_CYEDGE); r.left += cx; r.top += cy; r.right -= cx; r.bottom -= cy; if (r.right > r.left && r.bottom > r.top) { SetBkColor(hdc, GetSysColor(COLOR_WINDOW)); SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT)); SetTextAlign(hdc, TA_TOP | TA_LEFT); HGDIOBJ holdFont = SelectObject(hdc, mhfont); if (holdFont) { ExtTextOutW(hdc, r.left, r.top, ETO_CLIPPED, &r, mBuffer.c_str(), mBuffer.size(), NULL); SelectObject(hdc, holdFont); } } } EndPaint(mhwnd, &ps); }
void VDFileFixDirPath(VDStringW& path) { if (!path.empty()) { wchar_t c = path[path.size()-1]; if (c != L'/' && c != L'\\' && c != L':') path += L'\\'; } }
void VDVideoWindow::UpdateSourcePARMenuItem() { VDStringW s; if (mSourcePAR <= 0) s = L"Unknown ratio"; else s.sprintf(L"%.4g:1 pixel", mSourcePAR); VDStringW t(mSourcePARTextPattern); VDStringW::size_type pos = t.find('?'); if (pos != VDStringW::npos) t.replace(pos, 1, s.data(), s.size()); VDSetMenuItemTextByCommandW32(mhmenu, ID_DISPLAY_AR_PIXEL_SOURCE, t.c_str()); }
void VDUIHotKeyExControlW32::UpdateCaretPosition() { if (GetFocus() != mhwnd) return; int x = GetSystemMetrics(SM_CXEDGE) * 2; int y = GetSystemMetrics(SM_CYEDGE) * 2; HDC hdc = GetDC(mhwnd); if (hdc) { HGDIOBJ holdFont = SelectObject(hdc, mhfont); if (holdFont) { SIZE sz; if (GetTextExtentPoint32W(hdc, mBuffer.c_str(), mBuffer.size(), &sz)) x += sz.cx; SelectObject(hdc, holdFont); } } SetCaretPos(x, y); }
void VDLog(int severity, const VDStringW& s) { int strSize = s.size() + 1; if (strSize >= 16384) { VDASSERT(false); return; } vdsynchronized(g_csLog) { for(;;) { int currentSize = (g_logTail - g_logHead) & 16383; if (currentSize + strSize < 16384) // NOTE: This means that the last byte in the ring buffer can never be used. break; while(g_log[g_logHead++ & 16383]) ; g_logHead &= 16383; } const wchar_t *ps = s.data(); g_log[g_logTail++] = severity; for(int i=1; i<strSize; ++i) g_log[g_logTail++ & 16383] = *ps++; g_log[g_logTail++ & 16383] = 0; g_logTail &= 16383; VDThreadID currentThread = VDGetCurrentThreadID(); for(tVDLoggers::const_iterator it(g_loggers.begin()), itEnd(g_loggers.end()); it!=itEnd; ++it) { if (!(*it).second || currentThread == (*it).second) (*it).first->AddLogEntry(severity, s); } } }
void VDSubstituteStrings(VDStringW& s) { VDStringW::size_type posLast = 0; VDStringW::size_type pos = s.find('$'); if (pos == VDStringW::npos) return; VDStringW t; for(;;) { t.append(s, posLast, pos - posLast); if (pos == VDStringW::npos || pos+1 >= s.size()) break; wchar_t c = s[pos+1]; switch(c) { case L'b': t.append_sprintf(L"%d", version_num); break; case L'n': t.append(VD_PROGRAM_NAMEW); break; case L'v': t.append(VD_PROGRAM_VERSIONW); break; case L's': t.append(VD_PROGRAM_SPECIAL_BUILDW); break; case L'c': t.append(VD_PROGRAM_CONFIGW); break; case L'C': t.append(VD_PROGRAM_GENERIC_CONFIGW); break; case L'p': t.append(VD_PROGRAM_PLATFORM_NAMEW); break; case L'k': #if VD_COMPILER_MSVC >= 1600 #if VD_CPU_AMD64 t.append(L"Microsoft Visual Studio 2010 for AMD64"); #else t.append(L"Microsoft Visual Studio 2010 for X86"); #endif #elif VD_COMPILER_MSVC >= 1500 #if VD_CPU_AMD64 t.append(L"Microsoft Visual Studio 2008 for AMD64"); #else t.append(L"Microsoft Visual Studio 2008 for X86"); #endif #elif VD_COMPILER_MSVC >= 1400 #if VD_CPU_AMD64 #if VD_COMPILER_MSVC_VC8_DDK t.append(L"Microsoft Visual C++ 8.0 for AMD64 (DDK version)"); #elif VD_COMPILER_MSVC_VC8_PSDK t.append(L"Microsoft Visual C++ 8.0 for AMD64 (PSDK version)"); #else t.append(L"Microsoft Visual Studio 2005 for AMD64"); #endif #else t.append(L"Microsoft Visual Studio 2005 for X86"); #endif #else t.append("Unknown compiler"); #endif break; } posLast = pos + 2; pos = s.find('$', posLast); } s = t; }