[3/4] gdi32: handle custom dash style pens
Evan Stade
estade at gmail.com
Thu Jul 26 19:13:56 CDT 2007
Hi,
changelog:
*handle PS_USERSTYLE | PS_GEOMETRIC in ExtCreatePen
*remove 7 todo_wines from tests/pen.c
dlls/gdi32/pen.c | 33 +++++++++++++++++++++++++++++----
dlls/gdi32/tests/pen.c | 24 ++++++------------------
2 files changed, 35 insertions(+), 22 deletions(-)
--
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c
index 3dd545b..c58d37a 100644
--- a/dlls/gdi32/pen.c
+++ b/dlls/gdi32/pen.c
@@ -123,14 +123,39 @@ HPEN WINAPI ExtCreatePen( DWORD style, D
if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
{
- if (!style_count || (style_count > 16) || !style_bits)
+ if(((INT)style_count) <= 0)
+ return 0;
+
+ if ((style_count > 16) || !style_bits)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- /* FIXME: PS_USERSTYLE workaround */
- FIXME("PS_USERSTYLE not handled\n");
- style = (style & ~PS_STYLE_MASK) | PS_SOLID;
+ if ((style & PS_TYPE_MASK) == PS_COSMETIC)
+ {
+ /* FIXME: PS_USERSTYLE workaround */
+ FIXME("PS_COSMETIC | PS_USERSTYLE not handled\n");
+ style = (style & ~PS_STYLE_MASK) | PS_SOLID;
+ }
+ else{
+ UINT i, sum = 0;
+
+ /* no negative values, also all-zeroes is disallowed */
+ for(i = 0; i < style_count; i++){
+ if(((INT)(style_bits[i])) < 0)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+ sum += style_bits[i];
+ }
+
+ if(!sum)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+ }
}
else
{
diff --git a/dlls/gdi32/tests/pen.c b/dlls/gdi32/tests/pen.c
index 0de3f0d..ada892b 100644
--- a/dlls/gdi32/tests/pen.c
+++ b/dlls/gdi32/tests/pen.c
@@ -409,12 +409,6 @@ test_geometric_pens:
ok(ext_pen.elp.elpPenStyle == pen[i].ret_style, "expected %x, got %x\n", pen[i].ret_style, ext_pen.elp.elpPenStyle);
else
{
-if (pen[i].style == PS_USERSTYLE)
-{
- todo_wine
- ok(ext_pen.elp.elpPenStyle == (PS_GEOMETRIC | pen[i].style), "expected %x, got %x\n", PS_GEOMETRIC | pen[i].style, ext_pen.elp.elpPenStyle);
-}
-else
ok(ext_pen.elp.elpPenStyle == (PS_GEOMETRIC | pen[i].style), "expected %x, got %x\n", PS_GEOMETRIC | pen[i].style, ext_pen.elp.elpPenStyle);
}
@@ -510,8 +504,7 @@ static void test_ps_userstyle(void)
pen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 50, &lb, 0, style);
ok(pen == 0, "ExtCreatePen should fail\n");
- todo_wine
- expect(0xdeadbeef, GetLastError());
+ expect(0xdeadbeef, GetLastError());
DeleteObject(pen);
SetLastError(0xdeadbeef);
@@ -523,24 +516,19 @@ static void test_ps_userstyle(void)
pen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 50, &lb, -1, style);
ok(pen == 0, "ExtCreatePen should fail\n");
- todo_wine
- expect(0xdeadbeef, GetLastError());
+ expect(0xdeadbeef, GetLastError());
DeleteObject(pen);
SetLastError(0xdeadbeef);
pen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 50, &lb, 5, bad_style);
- todo_wine
- ok(pen == 0, "ExtCreatePen should fail\n");
- todo_wine
- expect(ERROR_INVALID_PARAMETER, GetLastError());
+ ok(pen == 0, "ExtCreatePen should fail\n");
+ expect(ERROR_INVALID_PARAMETER, GetLastError());
DeleteObject(pen);
SetLastError(0xdeadbeef);
pen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 50, &lb, 5, bad_style2);
- todo_wine
- ok(pen == 0, "ExtCreatePen should fail\n");
- todo_wine
- expect(ERROR_INVALID_PARAMETER, GetLastError());
+ ok(pen == 0, "ExtCreatePen should fail\n");
+ expect(ERROR_INVALID_PARAMETER, GetLastError());
DeleteObject(pen);
SetLastError(0xdeadbeef);
--
1.4.1
More information about the wine-patches
mailing list