Andrew Eikum : gdiplus: Create utility function get_graphics_bounds.
Alexandre Julliard
julliard at winehq.org
Thu Aug 13 10:41:25 CDT 2009
Module: wine
Branch: master
Commit: fdf48f1d4dd15784f86dd5b15c4be7c60d2eec1f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fdf48f1d4dd15784f86dd5b15c4be7c60d2eec1f
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Wed Aug 12 15:36:54 2009 -0500
gdiplus: Create utility function get_graphics_bounds.
---
dlls/gdiplus/graphics.c | 41 +++++++++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 10799c7..8f73ee9 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -1040,6 +1040,28 @@ static GpStatus restore_container(GpGraphics* graphics,
return Ok;
}
+static GpStatus get_graphics_bounds(GpGraphics* graphics, GpRectF* rect)
+{
+ RECT wnd_rect;
+
+ if(graphics->hwnd) {
+ if(!GetClientRect(graphics->hwnd, &wnd_rect))
+ return GenericError;
+
+ rect->X = wnd_rect.left;
+ rect->Y = wnd_rect.top;
+ rect->Width = wnd_rect.right - wnd_rect.left;
+ rect->Height = wnd_rect.bottom - wnd_rect.top;
+ }else{
+ rect->X = 0;
+ rect->Y = 0;
+ rect->Width = GetDeviceCaps(graphics->hdc, HORZRES);
+ rect->Height = GetDeviceCaps(graphics->hdc, VERTRES);
+ }
+
+ return Ok;
+}
+
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
{
TRACE("(%p, %p)\n", hdc, graphics);
@@ -3120,7 +3142,7 @@ GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color)
{
GpSolidFill *brush;
GpStatus stat;
- RECT rect;
+ GpRectF wnd_rect;
TRACE("(%p, %x)\n", graphics, color);
@@ -3133,18 +3155,13 @@ GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color)
if((stat = GdipCreateSolidFill(color, &brush)) != Ok)
return stat;
- if(graphics->hwnd){
- if(!GetWindowRect(graphics->hwnd, &rect)){
- GdipDeleteBrush((GpBrush*)brush);
- return GenericError;
- }
-
- GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, (REAL)(rect.right - rect.left),
- (REAL)(rect.bottom - rect.top));
+ if((stat = get_graphics_bounds(graphics, &wnd_rect)) != Ok){
+ GdipDeleteBrush((GpBrush*)brush);
+ return stat;
}
- else
- GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, (REAL)GetDeviceCaps(graphics->hdc, HORZRES),
- (REAL)GetDeviceCaps(graphics->hdc, VERTRES));
+
+ GdipFillRectangle(graphics, (GpBrush*)brush, wnd_rect.X, wnd_rect.Y,
+ wnd_rect.Width, wnd_rect.Height);
GdipDeleteBrush((GpBrush*)brush);
More information about the wine-cvs
mailing list