Commit Graph
22 Commits
Author SHA1 Message Date
Paxipu 0fbb475bd3 Don't let a page header or footer paint over the page body
wxHtmlPrintout::RenderPage() renders the body first and then the header
and footer through m_RendererHdr, calling

    m_RendererHdr.Render(x, y);

which leaves wxHtmlDCRenderer::Render()'s "to" parameter at its INT_MAX
default. The header is therefore free to draw the full height of its
HTML, not just the header area -- and an HTML background colour drawn by
the header covers the body that was rendered underneath it.

Pass the header and footer heights, which RenderPage() already knows, as
the bound.

The test renders a page with a body background colour and a header into a
wxMemoryDC and checks that a pixel well inside the body still has the
body's colour.

Closes #26915.

Assisted-by: Claude
2026-08-26 17:26:40 +02:00
Vadim Zeitlin c1fc91dd56 Make the text used in wxHtmlPrintout::Pagination test more readable
Use raw literal for it and strip all the quotes except the escaped ones
in the text itself, which now don't need to be escaped any longer.
2026-08-24 18:46:44 +02:00
Vadim Zeitlin 6992194ddc Check result of wxHtmlPrintout::SetUp() in pagination unit test
It shouldn't fail, but make sure we detect it if it does.
2026-08-24 18:46:44 +02:00
Vadim Zeitlin 46d8f1357b Fix wxHtmlPrintout::Pagination test failing depending on the font DPI
The test used a font with a fixed size in pixels and passed its point size
to SetStandardFonts() in order to be independent of the DPI, but this only
works if wxFont uses the same DPI for the pixel to point conversion as the
one used when rendering the text later, which is not the case under wxGTK,
where wxFontInfo(wxSize(10, 16)).GetPointSize() returns 9 and not the
expected 12, resulting in smaller text and hence fewer pages than expected.

Compute the point size corresponding to the desired pixel size ourselves,
using the PPI of the DC the text is going to be rendered on, and also set
the printer PPI to the screen one, on all platforms and not just wxGTK3,
to ensure that the fonts are not scaled when rendering.
2026-08-24 18:46:44 +02:00
Richard 272da6bcff Fix wxHTML BODY background colour in print rendering
Store BODY BGCOLOR in the wxHTML parser state even when there is no
window interface, then carry the parsed colour onto the renderer root
cell so wxHtmlDCRenderer fills printed pages with it instead of white.

Add a renderer regression test covering BODY BGCOLOR output.

Fixes #20652.

Closes #26677.
2026-07-20 20:53:16 +02:00
Robert Roebling 4f26f1d14c Disable printing in HTML test if no printing available 2025-10-29 08:09:16 +01:00
PB f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
Vadim Zeitlin ef0f4243fb Tweak wxHtmlPrintout::Pagination unit test to pass under Travis
For some reason, the height of a text line is 15px there and not 18px as
locally, so 400px high image still fit on the second page in the last
test. Make it higher to ensure that it doesn't.
2019-07-19 01:40:44 +02:00
Vadim Zeitlin 08c7a0ca82 Hack to make wxHtmlPrintout unit test pass under wxGTK3
Set the "printer" PPI explicitly for wxMemoryDC used in the test to
ensure that it's the same in all ports: currently wxGTK3 stands out
because it uses 72 DPI unlike wxMSW and wxGTK2, which use 96.
2019-07-18 17:45:20 +02:00
Vadim Zeitlin 9e05eb42b5 Fix outdated comment in wxHtmlPrintout unit test
This should have been part of 321854b519
which changed the code, but not the accompanying comment.
2018-07-25 13:52:49 +02:00
Vadim Zeitlin 0338796847 Remove unnecessary headers from wxHtmlPrintout unit test
These headers were added by 905789485a
which was replaced with 321854b519 later
and are not needed any more.
2018-07-25 13:49:00 +02:00
Vadim Zeitlin 6acd663190 Revert "Add even more debug output to the test"
This reverts commit 1ce009e73a as AppVeyor
test failures problem is fixed now.
2018-07-25 13:47:13 +02:00
Vadim Zeitlin 542124aa95 Fix page-break-inside:avoid to work for nested tags too
The initial version was too naïve and didn't work correctly if the <div>
with this style had nested elements.
2018-07-25 02:23:02 +02:00
Vadim Zeitlin 321854b519 Try using fixed font size in pixels in the test 2018-07-22 00:54:05 +02:00
Vadim Zeitlin 1ce009e73a Add even more debug output to the test 2018-07-22 00:43:26 +02:00
Vadim Zeitlin 96cca10328 Use fixed font name in the HTML pagination test 2018-07-22 00:43:26 +02:00
Vadim Zeitlin 905789485a Fix the just added pagination test for high DPI systems
Adjust the font size used by a DPI-dependent factor to ensure that the
text takes the same amount of pixels independently of DPI.
2018-07-22 00:43:25 +02:00
Vadim Zeitlin 566e401a3f Add support for style="page-break-inside:avoid" to wxHTML
Allow using this style to prevent page breaks inside the given <div>.
2018-07-22 00:43:25 +02:00
Vadim Zeitlin b55578e40c Fix HTML pagination test for high DPI values
The standard margins, expressed in millimeters, could result in the
usable page space being much smaller than 1000px used for the DC size
when using higher DPIs, which means that the test checking that a 2400px
image took only 3 pages could fail, as it could require 4 of them in
this case.

Fix this by getting rid of the margins, as this should ensure that the
page height is exactly 1000px now, independently of the actual DPI.
2018-05-27 22:43:28 +02:00
Vadim Zeitlin 8dffab0556 Add another page-break-before test to pagination unit test
Check that the nested elements with this style are handled as expected.
2018-05-27 22:28:33 +02:00
Vadim Zeitlin b0ae6681be Add a test of explicit page breaks in wxHtmlPrintout too
Check that using the style forcing a page break does work.
2018-05-24 17:53:26 +02:00
Vadim Zeitlin dd92a269c3 Add a simple unit test for wxHtmlPrintout pagination logic
Verify that the number of pages to be printed is as expected.
2018-05-23 18:14:07 +02:00