MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / RecalcLayout

Method RecalcLayout

WinArk/HexControl.cpp:420–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420void CHexControl::RecalcLayout() {
421 if (m_Buffer == nullptr) {
422 return;
423 }
424
425 CRect rc;
426 GetClientRect(&rc);
427
428 auto lines = int((m_Buffer->GetSize() + (m_BytesPerLine - 1)) / m_BytesPerLine);
429 if (m_Buffer->GetSize() % m_BytesPerLine != 0)
430 lines++;
431
432 m_Lines = rc.Height() / m_CharHeight;
433
434 m_AddressDigits = m_Buffer->GetSize() < 1LL << 16 ? 4 : 8;
435
436 SCROLLINFO si;
437 si.cbSize = sizeof(si);
438 si.fMask = SIF_PAGE | SIF_RANGE;
439 si.nMin = 0;
440 si.nMax = lines - 1;
441 si.nPage = rc.bottom / m_CharHeight;
442 SetScrollInfo(SB_VERT, &si);
443
444 auto chars = m_AddressDigits + m_BytesPerLine * 2 + (m_BytesPerLine / m_DataSize) + m_BytesPerLine;
445
446 si.nMax = static_cast<int>(chars) - 1;
447 si.nPage = rc.right / m_CharWidth;
448 SetScrollInfo(SB_HORZ, &si);
449
450 si.fMask = SIF_POS;
451 GetScrollInfo(SB_VERT, &si);
452
453 m_StartOffset = si.nPos * m_BytesPerLine;
454 ATLASSERT(m_StartOffset >= 0);
455 if (m_StartOffset + m_Lines * m_BytesPerLine >= m_Buffer->GetSize()) {
456 m_StartOffset = m_Buffer->GetSize() - (m_Lines - 1) * m_BytesPerLine;
457 if (m_StartOffset < 0)
458 m_StartOffset = 0;
459 m_StartOffset = m_StartOffset - m_StartOffset % m_BytesPerLine;
460 ATLASSERT(m_StartOffset >= 0);
461 }
462 m_EndOffset = m_StartOffset + m_Lines * m_BytesPerLine;
463 if (m_EndOffset > m_Buffer->GetSize())
464 m_EndOffset = m_Buffer->GetSize();
465 RedrawWindow();
466}
467
468void CHexControl::InitFontMetrics() {
469 if (m_Font)

Callers

nothing calls this directly

Calls 1

GetSizeMethod · 0.45

Tested by

no test coverage detected