Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Jan 13, 2024
1 parent bb9eeb0 commit 14fb896
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/WinWebDiffLib/WebToolWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,10 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler
return rc;
};

void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *pDrawItem)
void DrawDiffMap(HDC hdcMem, const RECT& rc)
{
FillSolidRect(hdcMem, { 0, 0, rc.right, rc.bottom }, RGB(255, 255, 255));

const int paneCount = m_pWebDiffWindow->GetPaneCount();
if (!m_pWebDiffWindow || paneCount == 0)
return;
Expand All @@ -471,15 +473,8 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler

IWebDiffWindow::ColorSettings colors;
m_pWebDiffWindow->GetDiffColorSettings(colors);
RECT rc;
GetClientRect(pDrawItem->hwndItem, &rc);
auto [scaleX, scaleY] = CalcScalingFactor(rc);

HDC hdcMem = CreateCompatibleDC(pDrawItem->hDC);
HBITMAP hBitmap = CreateCompatibleBitmap(pDrawItem->hDC, rc.right, rc.bottom);
HBITMAP hOldBitmap = SelectBitmap(hdcMem, hBitmap);

FillSolidRect(hdcMem, { 0, 0, rc.right, rc.bottom }, RGB(255, 255, 255));
const int curDiff = m_pWebDiffWindow->GetCurrentDiffIndex();
for (int pane = 0; pane < paneCount; ++pane)
{
Expand Down Expand Up @@ -519,10 +514,22 @@ class CWebToolWindow : public IWebToolWindow, IWebDiffEventHandler

SelectBrush(hdcMem, hOldBrush);
}
}

void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *pDrawItem)
{
RECT rc;
GetClientRect(pDrawItem->hwndItem, &rc);

HDC hdcMem = CreateCompatibleDC(pDrawItem->hDC);
HBITMAP hBitmap = CreateCompatibleBitmap(pDrawItem->hDC, rc.right, rc.bottom);
HBITMAP hOldBitmap = SelectBitmap(hdcMem, hBitmap);

DrawDiffMap(hdcMem, rc);

BitBlt(pDrawItem->hDC, 0, 0, rc.right, rc.bottom, hdcMem, 0, 0, SRCCOPY);

SelectBrush(hdcMem, hOldBitmap);
SelectBitmap(hdcMem, hOldBitmap);
DeleteBitmap(hBitmap);
DeleteDC(hdcMem);
}
Expand Down

0 comments on commit 14fb896

Please sign in to comment.