Add tests of clipping regions with wxDC with RTL layout enabled
This commit is contained in:
@@ -839,6 +839,35 @@ static void OneRegionAndDCTransformation(wxDC& dc, const wxBitmap& bmp, bool che
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void OneRegionRTL(wxDC& dc, const wxBitmap& bmp)
|
||||||
|
{
|
||||||
|
dc.SetLayoutDirection(wxLayout_RightToLeft);
|
||||||
|
if ( dc.GetLayoutDirection() != wxLayout_RightToLeft )
|
||||||
|
{
|
||||||
|
WARN("Skipping test because RTL layout direction is not supported on this platform");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
wxUnusedVar(bmp);
|
||||||
|
WARN("Skipping test known to fail in wxGTK");
|
||||||
|
#else
|
||||||
|
// Setting one clipping region inside DC area.
|
||||||
|
const int x = 10;
|
||||||
|
const int y = 20;
|
||||||
|
const int w = 60;
|
||||||
|
const int h = 75;
|
||||||
|
|
||||||
|
dc.SetClippingRegion(x, y, w, h);
|
||||||
|
dc.SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID));
|
||||||
|
dc.Clear();
|
||||||
|
int x2 = x + w - 1; // right physical edge becomes left logical edge
|
||||||
|
CheckClipBox(dc, bmp,
|
||||||
|
x, y, w, h,
|
||||||
|
(s_dcSize.x-1)-x2, y, w, h);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void TwoRegionsOverlapping(wxDC& dc, const wxBitmap& bmp)
|
static void TwoRegionsOverlapping(wxDC& dc, const wxBitmap& bmp)
|
||||||
{
|
{
|
||||||
// Setting one clipping region and next another region (partially overlapping).
|
// Setting one clipping region and next another region (partially overlapping).
|
||||||
@@ -986,6 +1015,59 @@ static void OneDevRegion(wxDC& dc, const wxBitmap& bmp, bool checkExtCoords, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void OneDevRegionRTL(wxDC& dc, const wxBitmap& bmp, bool useTransformMatrix)
|
||||||
|
{
|
||||||
|
#if wxUSE_DC_TRANSFORM_MATRIX
|
||||||
|
if ( useTransformMatrix & !dc.CanUseTransformMatrix() )
|
||||||
|
return;
|
||||||
|
#endif // wxUSE_DC_TRANSFORM_MATRIX
|
||||||
|
|
||||||
|
dc.SetLayoutDirection(wxLayout_RightToLeft);
|
||||||
|
if ( dc.GetLayoutDirection() != wxLayout_RightToLeft )
|
||||||
|
{
|
||||||
|
WARN("Skipping test because RTL layout direction is not supported on this platform");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
wxUnusedVar(bmp);
|
||||||
|
WARN("Skipping test known to fail in wxGTK");
|
||||||
|
#else
|
||||||
|
// Setting one clipping region in device coordinates
|
||||||
|
// inside transformed DC area.
|
||||||
|
const int x = 10;
|
||||||
|
const int y = 21;
|
||||||
|
const int w = 79;
|
||||||
|
const int h = 75;
|
||||||
|
|
||||||
|
#if wxUSE_DC_TRANSFORM_MATRIX
|
||||||
|
if ( useTransformMatrix )
|
||||||
|
{
|
||||||
|
wxAffineMatrix2D m;
|
||||||
|
m.Translate(40, 75);
|
||||||
|
m.Scale(2.0, 3.0);
|
||||||
|
dc.SetTransformMatrix(m);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // wxUSE_DC_TRANSFORM_MATRIX
|
||||||
|
{
|
||||||
|
dc.SetDeviceOrigin(10, 15);
|
||||||
|
dc.SetUserScale(0.5, 1.5);
|
||||||
|
dc.SetLogicalScale(4.0, 2.0);
|
||||||
|
dc.SetLogicalOrigin(-15, -20);
|
||||||
|
}
|
||||||
|
wxRegion reg(x, y, w, h);
|
||||||
|
dc.SetDeviceClippingRegion(reg);
|
||||||
|
dc.SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID));
|
||||||
|
dc.Clear();
|
||||||
|
wxPoint pos = dc.DeviceToLogical(x+w-1, y); // right physical edge becomes left logical edge
|
||||||
|
wxSize dim = dc.DeviceToLogicalRel(-w, h);
|
||||||
|
CheckClipBox(dc, bmp,
|
||||||
|
pos.x, pos.y, dim.x, dim.y,
|
||||||
|
x, y, w, h);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void OneLargeDevRegion(wxDC& dc, const wxBitmap& bmp, bool checkExtCoords, bool useTransformMatrix)
|
static void OneLargeDevRegion(wxDC& dc, const wxBitmap& bmp, bool checkExtCoords, bool useTransformMatrix)
|
||||||
{
|
{
|
||||||
#if wxUSE_DC_TRANSFORM_MATRIX
|
#if wxUSE_DC_TRANSFORM_MATRIX
|
||||||
@@ -1888,6 +1970,11 @@ TEST_CASE("ClippingBoxTestCase::wxDC", "[clip][dc]")
|
|||||||
OneRegionAndDCTransformation(dc, bmp, true, true);
|
OneRegionAndDCTransformation(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneRegionRTL")
|
||||||
|
{
|
||||||
|
OneRegionRTL(dc, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("TwoRegionsOverlapping")
|
SECTION("TwoRegionsOverlapping")
|
||||||
{
|
{
|
||||||
TwoRegionsOverlapping(dc, bmp);
|
TwoRegionsOverlapping(dc, bmp);
|
||||||
@@ -1923,6 +2010,16 @@ TEST_CASE("ClippingBoxTestCase::wxDC", "[clip][dc]")
|
|||||||
OneDevRegion(dc, bmp, true, true);
|
OneDevRegion(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL TransformMatrix")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("OneLargeDevRegion 1")
|
SECTION("OneLargeDevRegion 1")
|
||||||
{
|
{
|
||||||
OneLargeDevRegion(dc, bmp, false, false);
|
OneLargeDevRegion(dc, bmp, false, false);
|
||||||
@@ -2193,6 +2290,11 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC", "[clip][dc][gcdc]")
|
|||||||
OneRegionAndDCTransformation(dc, bmp, true, true);
|
OneRegionAndDCTransformation(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneRegionRTL")
|
||||||
|
{
|
||||||
|
OneRegionRTL(dc, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("TwoRegionsOverlapping")
|
SECTION("TwoRegionsOverlapping")
|
||||||
{
|
{
|
||||||
TwoRegionsOverlapping(dc, bmp);
|
TwoRegionsOverlapping(dc, bmp);
|
||||||
@@ -2228,6 +2330,16 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC", "[clip][dc][gcdc]")
|
|||||||
OneDevRegion(dc, bmp, true, true);
|
OneDevRegion(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL TransformMatrix")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("OneLargeDevRegion 1")
|
SECTION("OneLargeDevRegion 1")
|
||||||
{
|
{
|
||||||
OneLargeDevRegion(dc, bmp, false, false);
|
OneLargeDevRegion(dc, bmp, false, false);
|
||||||
@@ -2506,6 +2618,11 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC(GDI+)", "[clip][dc][gcdc][gdiplus]")
|
|||||||
OneRegionAndDCTransformation(dc, bmp, true, true);
|
OneRegionAndDCTransformation(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneRegionRTL")
|
||||||
|
{
|
||||||
|
OneRegionRTL(dc, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("TwoRegionsOverlapping")
|
SECTION("TwoRegionsOverlapping")
|
||||||
{
|
{
|
||||||
TwoRegionsOverlapping(dc, bmp);
|
TwoRegionsOverlapping(dc, bmp);
|
||||||
@@ -2541,6 +2658,16 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC(GDI+)", "[clip][dc][gcdc][gdiplus]")
|
|||||||
OneDevRegion(dc, bmp, true, true);
|
OneDevRegion(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL TransformMatrix")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("OneLargeDevRegion 1")
|
SECTION("OneLargeDevRegion 1")
|
||||||
{
|
{
|
||||||
OneLargeDevRegion(dc, bmp, false, false);
|
OneLargeDevRegion(dc, bmp, false, false);
|
||||||
@@ -2820,6 +2947,11 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC(Direct2D)", "[clip][dc][gcdc][direct2d]")
|
|||||||
OneRegionAndDCTransformation(dc, bmp, true, true);
|
OneRegionAndDCTransformation(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneRegionRTL")
|
||||||
|
{
|
||||||
|
OneRegionRTL(dc, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("TwoRegionsOverlapping")
|
SECTION("TwoRegionsOverlapping")
|
||||||
{
|
{
|
||||||
TwoRegionsOverlapping(dc, bmp);
|
TwoRegionsOverlapping(dc, bmp);
|
||||||
@@ -2855,6 +2987,16 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC(Direct2D)", "[clip][dc][gcdc][direct2d]")
|
|||||||
OneDevRegion(dc, bmp, true, true);
|
OneDevRegion(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL TransformMatrix")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("OneLargeDevRegion 1")
|
SECTION("OneLargeDevRegion 1")
|
||||||
{
|
{
|
||||||
OneLargeDevRegion(dc, bmp, false, false);
|
OneLargeDevRegion(dc, bmp, false, false);
|
||||||
@@ -3134,6 +3276,11 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC(Cairo)", "[clip][dc][gcdc][cairo]")
|
|||||||
OneRegionAndDCTransformation(dc, bmp, true, true);
|
OneRegionAndDCTransformation(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneRegionRTL")
|
||||||
|
{
|
||||||
|
OneRegionRTL(dc, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("TwoRegionsOverlapping")
|
SECTION("TwoRegionsOverlapping")
|
||||||
{
|
{
|
||||||
TwoRegionsOverlapping(dc, bmp);
|
TwoRegionsOverlapping(dc, bmp);
|
||||||
@@ -3169,6 +3316,16 @@ TEST_CASE("ClippingBoxTestCase::wxGCDC(Cairo)", "[clip][dc][gcdc][cairo]")
|
|||||||
OneDevRegion(dc, bmp, true, true);
|
OneDevRegion(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL TransformMatrix")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("OneLargeDevRegion 1")
|
SECTION("OneLargeDevRegion 1")
|
||||||
{
|
{
|
||||||
OneLargeDevRegion(dc, bmp, false, false);
|
OneLargeDevRegion(dc, bmp, false, false);
|
||||||
@@ -3446,6 +3603,11 @@ TEST_CASE("ClippingBoxTestCase::wxSVGFileDC", "[clip][dc][svgdc]")
|
|||||||
OneRegionAndDCTransformation(dc, bmp, true, true);
|
OneRegionAndDCTransformation(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneRegionRTL")
|
||||||
|
{
|
||||||
|
OneRegionRTL(dc, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("TwoRegionsOverlapping")
|
SECTION("TwoRegionsOverlapping")
|
||||||
{
|
{
|
||||||
TwoRegionsOverlapping(dc, bmp);
|
TwoRegionsOverlapping(dc, bmp);
|
||||||
@@ -3481,6 +3643,16 @@ TEST_CASE("ClippingBoxTestCase::wxSVGFileDC", "[clip][dc][svgdc]")
|
|||||||
OneDevRegion(dc, bmp, true, true);
|
OneDevRegion(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL TransformMatrix")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("OneLargeDevRegion 1")
|
SECTION("OneLargeDevRegion 1")
|
||||||
{
|
{
|
||||||
OneLargeDevRegion(dc, bmp, false, false);
|
OneLargeDevRegion(dc, bmp, false, false);
|
||||||
@@ -3768,6 +3940,11 @@ TEST_CASE("ClippingBoxTestCase::wxClientDC", "[clip][dc][clientdc]")
|
|||||||
OneRegionAndDCTransformation(dc, bmp, true, true);
|
OneRegionAndDCTransformation(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneRegionRTL")
|
||||||
|
{
|
||||||
|
OneRegionRTL(dc, bmp);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("TwoRegionsOverlapping")
|
SECTION("TwoRegionsOverlapping")
|
||||||
{
|
{
|
||||||
TwoRegionsOverlapping(dc, bmp);
|
TwoRegionsOverlapping(dc, bmp);
|
||||||
@@ -3803,6 +3980,16 @@ TEST_CASE("ClippingBoxTestCase::wxClientDC", "[clip][dc][clientdc]")
|
|||||||
OneDevRegion(dc, bmp, true, true);
|
OneDevRegion(dc, bmp, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("OneDevRegionRTL TransformMatrix")
|
||||||
|
{
|
||||||
|
OneDevRegionRTL(dc, bmp, true);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("OneLargeDevRegion 1")
|
SECTION("OneLargeDevRegion 1")
|
||||||
{
|
{
|
||||||
OneLargeDevRegion(dc, bmp, false, false);
|
OneLargeDevRegion(dc, bmp, false, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user