diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 12 | ||||
| -rw-r--r-- | win32/ListBox.cxx | 25 |
2 files changed, 33 insertions, 4 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index cbf8f3d3a..c0f884f6a 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -599,6 +599,18 @@ </table> <h2 id="Releases">Releases</h2> <h3> + <a href="https://www.scintilla.org/scintilla562.zip">Release 5.6.2</a> + </h3> + <ul> + <li> + Released 26 March 2026. + </li> + <li> + On Win32 with DirectWrite in a GDI scaled application, draw sharper text in autocompletion lists. + <a href="https://sourceforge.net/p/scintilla/bugs/2505/">Bug #2505</a>. + </li> + </ul> + <h3> <a href="https://www.scintilla.org/scintilla561.zip">Release 5.6.1</a> </h3> <ul> diff --git a/win32/ListBox.cxx b/win32/ListBox.cxx index b5ce7782f..31470b2ed 100644 --- a/win32/ListBox.cxx +++ b/win32/ListBox.cxx @@ -175,6 +175,10 @@ class ListBoxX : public ListBox { MouseWheelDelta wheelDelta; ListOptions options; DWORD frameStyle = WS_THICKFRAME; + float deviceScaleFactor = 1.f; + [[nodiscard]] int GetFirstIntegralMultipleDeviceScaleFactor() const noexcept { + return static_cast<int>(std::ceil(deviceScaleFactor)); + } LBGraphics graphics; @@ -265,6 +269,9 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei this); dpi = DpiForWindow(hwndParent); + if (technology != Technology::Default) { + deviceScaleFactor = Internal::GetDeviceScaleFactorWhenGdiScalingActive(hwndParent); + } POINT locationw = POINTFromPoint(location); ::MapWindowPoints(hwndParent, {}, &locationw, 1); location = PointFromPOINT(locationw); @@ -423,7 +430,8 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { #endif const PRectangle rcItemBase = PRectangleFromRECT(pDrawItem->rcItem); - const PRectangle rcItem(0, 0, rcItemBase.Width(), rcItemBase.Height()); + const int integralDeviceScaleFactor = GetFirstIntegralMultipleDeviceScaleFactor(); + const PRectangle rcItem(0, 0, rcItemBase.Width() * integralDeviceScaleFactor, rcItemBase.Height() * integralDeviceScaleFactor); PRectangle rcBox = rcItem; rcBox.left += TextOffset(); ColourRGBA colourFore; @@ -458,6 +466,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { PRectangle rcImage = rcItem; rcImage.left = left; rcImage.right = rcImage.left + images.GetWidth(); + rcImage.bottom = rcImage.top + rcItemBase.Height(); graphics.pixmapLine->DrawRGBAImage(rcImage, pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); } @@ -473,7 +482,11 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { // Blit from hMemDC to hDC const SIZE extent = SizeOfRect(pDrawItem->rcItem); - ::BitBlt(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, extent.cx, extent.cy, graphics.bm.DC(), 0, 0, SRCCOPY); + if (integralDeviceScaleFactor == 1) { + ::BitBlt(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, extent.cx, extent.cy, graphics.bm.DC(), 0, 0, SRCCOPY); + } else { + ::StretchBlt(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, extent.cx, extent.cy, graphics.bm.DC(), 0, 0, extent.cx * integralDeviceScaleFactor, extent.cy * integralDeviceScaleFactor, SRCCOPY); + } } void ListBoxX::AppendListItem(const char *text, const char *numword) { @@ -748,7 +761,8 @@ void ListBoxX::CentreItem(int n) { } void ListBoxX::AllocateBitMap() { - const SIZE extent { GetClientExtent().x, ItemHeight() }; + const int integralDeviceScaleFactor = GetFirstIntegralMultipleDeviceScaleFactor(); + const SIZE extent { GetClientExtent().x * integralDeviceScaleFactor, ItemHeight() * integralDeviceScaleFactor }; graphics.bm.Create({}, extent.cx, -extent.cy, nullptr); if (!graphics.bm) { @@ -765,9 +779,12 @@ void ListBoxX::AllocateBitMap() { return; } + const FLOAT dpiTarget = dpiDefault * static_cast<float>(integralDeviceScaleFactor); + const D2D1_RENDER_TARGET_PROPERTIES drtp = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, - { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED }); + { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED }, + dpiTarget, dpiTarget); HRESULT hr = CreateDCRenderTarget(&drtp, graphics.pBMDCTarget); if (FAILED(hr) || !graphics.pBMDCTarget) { |
