2007-06-11 18:54:03 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Google (Evan Stade)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <math.h>
|
2007-08-15 23:22:09 +00:00
|
|
|
#include <limits.h>
|
2007-06-11 18:54:03 +00:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wingdi.h"
|
2007-08-15 01:58:39 +00:00
|
|
|
#include "wine/unicode.h"
|
2007-07-31 02:10:03 +00:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "ocidl.h"
|
|
|
|
#include "olectl.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
2007-08-08 01:42:00 +00:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
2007-06-11 18:54:03 +00:00
|
|
|
#include "gdiplus.h"
|
|
|
|
#include "gdiplus_private.h"
|
|
|
|
#include "wine/debug.h"
|
2009-07-05 22:04:20 +00:00
|
|
|
#include "wine/list.h"
|
2007-06-11 18:54:03 +00:00
|
|
|
|
2007-07-07 20:20:41 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
|
|
|
|
|
|
|
|
/* looks-right constants */
|
|
|
|
#define ANCHOR_WIDTH (2.0)
|
2007-07-06 23:13:49 +00:00
|
|
|
#define MAX_ITERS (50)
|
2007-06-20 02:31:28 +00:00
|
|
|
|
2007-06-18 23:55:51 +00:00
|
|
|
/* Converts angle (in degrees) to x/y coordinates */
|
|
|
|
static void deg2xy(REAL angle, REAL x_0, REAL y_0, REAL *x, REAL *y)
|
|
|
|
{
|
|
|
|
REAL radAngle, hypotenuse;
|
|
|
|
|
|
|
|
radAngle = deg2rad(angle);
|
|
|
|
hypotenuse = 50.0; /* arbitrary */
|
|
|
|
|
|
|
|
*x = x_0 + cos(radAngle) * hypotenuse;
|
|
|
|
*y = y_0 + sin(radAngle) * hypotenuse;
|
|
|
|
}
|
|
|
|
|
2007-07-20 01:22:51 +00:00
|
|
|
/* Converts from gdiplus path point type to gdi path point type. */
|
|
|
|
static BYTE convert_path_point_type(BYTE type)
|
|
|
|
{
|
|
|
|
BYTE ret;
|
|
|
|
|
|
|
|
switch(type & PathPointTypePathTypeMask){
|
|
|
|
case PathPointTypeBezier:
|
|
|
|
ret = PT_BEZIERTO;
|
|
|
|
break;
|
|
|
|
case PathPointTypeLine:
|
|
|
|
ret = PT_LINETO;
|
|
|
|
break;
|
|
|
|
case PathPointTypeStart:
|
|
|
|
ret = PT_MOVETO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Bad point type\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(type & PathPointTypeCloseSubpath)
|
|
|
|
ret |= PT_CLOSEFIGURE;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
|
|
|
|
{
|
|
|
|
HPEN gdipen;
|
|
|
|
REAL width;
|
2007-07-27 23:07:39 +00:00
|
|
|
INT save_state = SaveDC(graphics->hdc), i, numdashes;
|
2007-07-25 00:18:58 +00:00
|
|
|
GpPointF pt[2];
|
2007-07-27 23:07:39 +00:00
|
|
|
DWORD dash_array[MAX_DASHLEN];
|
2007-07-25 00:18:54 +00:00
|
|
|
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
2007-08-14 01:34:31 +00:00
|
|
|
if(pen->unit == UnitPixel){
|
|
|
|
width = pen->width;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
/* Get an estimate for the amount the pen width is affected by the world
|
|
|
|
* transform. (This is similar to what some of the wine drivers do.) */
|
|
|
|
pt[0].X = 0.0;
|
|
|
|
pt[0].Y = 0.0;
|
|
|
|
pt[1].X = 1.0;
|
|
|
|
pt[1].Y = 1.0;
|
|
|
|
GdipTransformMatrixPoints(graphics->worldtrans, pt, 2);
|
|
|
|
width = sqrt((pt[1].X - pt[0].X) * (pt[1].X - pt[0].X) +
|
|
|
|
(pt[1].Y - pt[0].Y) * (pt[1].Y - pt[0].Y)) / sqrt(2.0);
|
|
|
|
|
|
|
|
width *= pen->width * convert_unit(graphics->hdc,
|
|
|
|
pen->unit == UnitWorld ? graphics->unit : pen->unit);
|
|
|
|
}
|
2007-07-25 00:18:54 +00:00
|
|
|
|
2007-07-27 23:07:39 +00:00
|
|
|
if(pen->dash == DashStyleCustom){
|
|
|
|
numdashes = min(pen->numdashes, MAX_DASHLEN);
|
|
|
|
|
|
|
|
TRACE("dashes are: ");
|
|
|
|
for(i = 0; i < numdashes; i++){
|
|
|
|
dash_array[i] = roundr(width * pen->dashes[i]);
|
|
|
|
TRACE("%d, ", dash_array[i]);
|
|
|
|
}
|
|
|
|
TRACE("\n and the pen style is %x\n", pen->style);
|
|
|
|
|
|
|
|
gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb,
|
|
|
|
numdashes, dash_array);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb, 0, NULL);
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
SelectObject(graphics->hdc, gdipen);
|
|
|
|
|
|
|
|
return save_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void restore_dc(GpGraphics *graphics, INT state)
|
|
|
|
{
|
|
|
|
DeleteObject(SelectObject(graphics->hdc, GetStockObject(NULL_PEN)));
|
|
|
|
RestoreDC(graphics->hdc, state);
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
/* This helper applies all the changes that the points listed in ptf need in
|
|
|
|
* order to be drawn on the device context. In the end, this should include at
|
|
|
|
* least:
|
|
|
|
* -scaling by page unit
|
|
|
|
* -applying world transformation
|
|
|
|
* -converting from float to int
|
|
|
|
* Native gdiplus uses gdi32 to do all this (via SetMapMode, SetViewportExtEx,
|
|
|
|
* SetWindowExtEx, SetWorldTransform, etc.) but we cannot because we are using
|
|
|
|
* gdi to draw, and these functions would irreparably mess with line widths.
|
|
|
|
*/
|
|
|
|
static void transform_and_round_points(GpGraphics *graphics, POINT *pti,
|
2007-07-25 00:18:50 +00:00
|
|
|
GpPointF *ptf, INT count)
|
2007-07-24 03:24:53 +00:00
|
|
|
{
|
|
|
|
REAL unitscale;
|
2007-07-25 00:18:50 +00:00
|
|
|
GpMatrix *matrix;
|
2007-07-24 03:24:53 +00:00
|
|
|
int i;
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
unitscale = convert_unit(graphics->hdc, graphics->unit);
|
2007-07-24 03:24:53 +00:00
|
|
|
|
2007-07-25 00:18:39 +00:00
|
|
|
/* apply page scale */
|
|
|
|
if(graphics->unit != UnitDisplay)
|
|
|
|
unitscale *= graphics->scale;
|
|
|
|
|
2007-07-25 00:18:50 +00:00
|
|
|
GdipCloneMatrix(graphics->worldtrans, &matrix);
|
|
|
|
GdipScaleMatrix(matrix, unitscale, unitscale, MatrixOrderAppend);
|
|
|
|
GdipTransformMatrixPoints(matrix, ptf, count);
|
2007-07-26 02:15:20 +00:00
|
|
|
GdipDeleteMatrix(matrix);
|
2007-07-25 00:18:50 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
for(i = 0; i < count; i++){
|
2007-07-25 00:18:50 +00:00
|
|
|
pti[i].x = roundr(ptf[i].X);
|
|
|
|
pti[i].y = roundr(ptf[i].Y);
|
2007-07-24 03:24:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-01 19:26:50 +00:00
|
|
|
static ARGB blend_colors(ARGB start, ARGB end, REAL position)
|
2009-03-16 17:51:04 +00:00
|
|
|
{
|
|
|
|
ARGB result=0;
|
|
|
|
ARGB i;
|
|
|
|
for (i=0xff; i<=0xff0000; i = i << 8)
|
2009-05-01 19:26:50 +00:00
|
|
|
result |= (int)((start&i)*(1.0f - position)+(end&i)*(position))&i;
|
2009-03-16 17:51:04 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-05-01 19:26:50 +00:00
|
|
|
static ARGB blend_line_gradient(GpLineGradient* brush, REAL position)
|
|
|
|
{
|
|
|
|
REAL blendfac;
|
|
|
|
|
2009-05-01 20:23:02 +00:00
|
|
|
/* clamp to between 0.0 and 1.0, using the wrap mode */
|
|
|
|
if (brush->wrap == WrapModeTile)
|
|
|
|
{
|
|
|
|
position = fmodf(position, 1.0f);
|
|
|
|
if (position < 0.0f) position += 1.0f;
|
|
|
|
}
|
|
|
|
else /* WrapModeFlip* */
|
|
|
|
{
|
|
|
|
position = fmodf(position, 2.0f);
|
|
|
|
if (position < 0.0f) position += 2.0f;
|
|
|
|
if (position > 1.0f) position = 2.0f - position;
|
|
|
|
}
|
|
|
|
|
2009-05-01 19:26:50 +00:00
|
|
|
if (brush->blendcount == 1)
|
|
|
|
blendfac = position;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i=1;
|
|
|
|
REAL left_blendpos, left_blendfac, right_blendpos, right_blendfac;
|
|
|
|
REAL range;
|
|
|
|
|
|
|
|
/* locate the blend positions surrounding this position */
|
|
|
|
while (position > brush->blendpos[i])
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* interpolate between the blend positions */
|
|
|
|
left_blendpos = brush->blendpos[i-1];
|
|
|
|
left_blendfac = brush->blendfac[i-1];
|
|
|
|
right_blendpos = brush->blendpos[i];
|
|
|
|
right_blendfac = brush->blendfac[i];
|
|
|
|
range = right_blendpos - left_blendpos;
|
|
|
|
blendfac = (left_blendfac * (right_blendpos - position) +
|
|
|
|
right_blendfac * (position - left_blendpos)) / range;
|
|
|
|
}
|
2009-09-14 21:48:03 +00:00
|
|
|
|
|
|
|
if (brush->pblendcount == 0)
|
|
|
|
return blend_colors(brush->startcolor, brush->endcolor, blendfac);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i=1;
|
|
|
|
ARGB left_blendcolor, right_blendcolor;
|
|
|
|
REAL left_blendpos, right_blendpos;
|
|
|
|
|
|
|
|
/* locate the blend colors surrounding this position */
|
|
|
|
while (blendfac > brush->pblendpos[i])
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* interpolate between the blend colors */
|
|
|
|
left_blendpos = brush->pblendpos[i-1];
|
|
|
|
left_blendcolor = brush->pblendcolor[i-1];
|
|
|
|
right_blendpos = brush->pblendpos[i];
|
|
|
|
right_blendcolor = brush->pblendcolor[i];
|
|
|
|
blendfac = (blendfac - left_blendpos) / (right_blendpos - left_blendpos);
|
|
|
|
return blend_colors(left_blendcolor, right_blendcolor, blendfac);
|
|
|
|
}
|
2009-05-01 19:26:50 +00:00
|
|
|
}
|
|
|
|
|
2009-03-16 17:51:04 +00:00
|
|
|
static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
|
|
|
|
{
|
|
|
|
switch (brush->bt)
|
|
|
|
{
|
|
|
|
case BrushTypeLinearGradient:
|
|
|
|
{
|
|
|
|
GpLineGradient *line = (GpLineGradient*)brush;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
SelectClipPath(graphics->hdc, RGN_AND);
|
|
|
|
if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
|
|
|
|
{
|
|
|
|
GpPointF endpointsf[2];
|
|
|
|
POINT endpointsi[2];
|
|
|
|
POINT poly[4];
|
|
|
|
|
|
|
|
SelectObject(graphics->hdc, GetStockObject(NULL_PEN));
|
|
|
|
|
|
|
|
endpointsf[0] = line->startpoint;
|
|
|
|
endpointsf[1] = line->endpoint;
|
|
|
|
transform_and_round_points(graphics, endpointsi, endpointsf, 2);
|
|
|
|
|
|
|
|
if (abs(endpointsi[0].x-endpointsi[1].x) > abs(endpointsi[0].y-endpointsi[1].y))
|
|
|
|
{
|
|
|
|
/* vertical-ish gradient */
|
|
|
|
int startx, endx; /* x co-ordinates of endpoints shifted to intersect the top of the visible rectangle */
|
2009-05-01 20:23:02 +00:00
|
|
|
int startbottomx; /* x co-ordinate of start point shifted to intersect the bottom of the visible rectangle */
|
2009-03-16 17:51:04 +00:00
|
|
|
int width;
|
|
|
|
COLORREF col;
|
|
|
|
HBRUSH hbrush, hprevbrush;
|
2009-05-01 20:23:02 +00:00
|
|
|
int leftx, rightx; /* x co-ordinates where the leftmost and rightmost gradient lines hit the top of the visible rectangle */
|
|
|
|
int x;
|
|
|
|
int tilt; /* horizontal distance covered by a gradient line */
|
2009-03-16 17:51:04 +00:00
|
|
|
|
|
|
|
startx = roundr((rc.top - endpointsf[0].Y) * (endpointsf[1].Y - endpointsf[0].Y) / (endpointsf[0].X - endpointsf[1].X) + endpointsf[0].X);
|
|
|
|
endx = roundr((rc.top - endpointsf[1].Y) * (endpointsf[1].Y - endpointsf[0].Y) / (endpointsf[0].X - endpointsf[1].X) + endpointsf[1].X);
|
|
|
|
width = endx - startx;
|
|
|
|
startbottomx = roundr((rc.bottom - endpointsf[0].Y) * (endpointsf[1].Y - endpointsf[0].Y) / (endpointsf[0].X - endpointsf[1].X) + endpointsf[0].X);
|
2009-05-01 20:23:02 +00:00
|
|
|
tilt = startx - startbottomx;
|
2009-03-16 17:51:04 +00:00
|
|
|
|
2009-05-01 20:23:02 +00:00
|
|
|
if (startx >= startbottomx)
|
|
|
|
{
|
|
|
|
leftx = rc.left;
|
|
|
|
rightx = rc.right + tilt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
leftx = rc.left + tilt;
|
|
|
|
rightx = rc.right;
|
|
|
|
}
|
2009-03-16 17:51:04 +00:00
|
|
|
|
|
|
|
poly[0].y = rc.bottom;
|
|
|
|
poly[1].y = rc.top;
|
|
|
|
poly[2].y = rc.top;
|
|
|
|
poly[3].y = rc.bottom;
|
|
|
|
|
2009-05-01 20:23:02 +00:00
|
|
|
for (x=leftx; x<=rightx; x++)
|
2009-03-16 17:51:04 +00:00
|
|
|
{
|
2009-05-01 20:23:02 +00:00
|
|
|
ARGB argb = blend_line_gradient(line, (x-startx)/(REAL)width);
|
2009-03-16 17:51:04 +00:00
|
|
|
col = ARGB2COLORREF(argb);
|
|
|
|
hbrush = CreateSolidBrush(col);
|
|
|
|
hprevbrush = SelectObject(graphics->hdc, hbrush);
|
2009-05-01 20:37:35 +00:00
|
|
|
poly[0].x = x - tilt - 1;
|
|
|
|
poly[1].x = x - 1;
|
2009-05-01 20:23:02 +00:00
|
|
|
poly[2].x = x;
|
|
|
|
poly[3].x = x - tilt;
|
2009-03-16 17:51:04 +00:00
|
|
|
Polygon(graphics->hdc, poly, 4);
|
|
|
|
SelectObject(graphics->hdc, hprevbrush);
|
|
|
|
DeleteObject(hbrush);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (endpointsi[0].y != endpointsi[1].y)
|
|
|
|
{
|
|
|
|
/* horizontal-ish gradient */
|
|
|
|
int starty, endy; /* y co-ordinates of endpoints shifted to intersect the left of the visible rectangle */
|
2009-05-01 20:23:02 +00:00
|
|
|
int startrighty; /* y co-ordinate of start point shifted to intersect the right of the visible rectangle */
|
2009-03-16 17:51:04 +00:00
|
|
|
int height;
|
|
|
|
COLORREF col;
|
|
|
|
HBRUSH hbrush, hprevbrush;
|
2009-05-01 20:23:02 +00:00
|
|
|
int topy, bottomy; /* y co-ordinates where the topmost and bottommost gradient lines hit the left of the visible rectangle */
|
|
|
|
int y;
|
|
|
|
int tilt; /* vertical distance covered by a gradient line */
|
2009-03-16 17:51:04 +00:00
|
|
|
|
|
|
|
starty = roundr((rc.left - endpointsf[0].X) * (endpointsf[0].X - endpointsf[1].X) / (endpointsf[1].Y - endpointsf[0].Y) + endpointsf[0].Y);
|
|
|
|
endy = roundr((rc.left - endpointsf[1].X) * (endpointsf[0].X - endpointsf[1].X) / (endpointsf[1].Y - endpointsf[0].Y) + endpointsf[1].Y);
|
|
|
|
height = endy - starty;
|
|
|
|
startrighty = roundr((rc.right - endpointsf[0].X) * (endpointsf[0].X - endpointsf[1].X) / (endpointsf[1].Y - endpointsf[0].Y) + endpointsf[0].Y);
|
2009-05-01 20:23:02 +00:00
|
|
|
tilt = starty - startrighty;
|
2009-03-16 17:51:04 +00:00
|
|
|
|
2009-05-01 20:23:02 +00:00
|
|
|
if (starty >= startrighty)
|
|
|
|
{
|
|
|
|
topy = rc.top;
|
|
|
|
bottomy = rc.bottom + tilt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
topy = rc.top + tilt;
|
|
|
|
bottomy = rc.bottom;
|
|
|
|
}
|
2009-03-16 17:51:04 +00:00
|
|
|
|
|
|
|
poly[0].x = rc.right;
|
|
|
|
poly[1].x = rc.left;
|
|
|
|
poly[2].x = rc.left;
|
|
|
|
poly[3].x = rc.right;
|
|
|
|
|
2009-05-01 20:23:02 +00:00
|
|
|
for (y=topy; y<=bottomy; y++)
|
2009-03-16 17:51:04 +00:00
|
|
|
{
|
2009-05-01 20:23:02 +00:00
|
|
|
ARGB argb = blend_line_gradient(line, (y-starty)/(REAL)height);
|
2009-03-16 17:51:04 +00:00
|
|
|
col = ARGB2COLORREF(argb);
|
|
|
|
hbrush = CreateSolidBrush(col);
|
|
|
|
hprevbrush = SelectObject(graphics->hdc, hbrush);
|
2009-05-01 20:37:35 +00:00
|
|
|
poly[0].y = y - tilt - 1;
|
|
|
|
poly[1].y = y - 1;
|
2009-05-01 20:23:02 +00:00
|
|
|
poly[2].y = y;
|
|
|
|
poly[3].y = y - tilt;
|
2009-03-16 17:51:04 +00:00
|
|
|
Polygon(graphics->hdc, poly, 4);
|
|
|
|
SelectObject(graphics->hdc, hprevbrush);
|
|
|
|
DeleteObject(hbrush);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* else startpoint == endpoint */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-05-20 16:24:18 +00:00
|
|
|
case BrushTypeSolidColor:
|
|
|
|
{
|
|
|
|
GpSolidFill *fill = (GpSolidFill*)brush;
|
|
|
|
if (fill->bmp)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
/* partially transparent fill */
|
|
|
|
|
|
|
|
SelectClipPath(graphics->hdc, RGN_AND);
|
|
|
|
if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
|
|
|
|
{
|
|
|
|
HDC hdc = CreateCompatibleDC(NULL);
|
|
|
|
HBITMAP oldbmp;
|
|
|
|
BLENDFUNCTION bf;
|
|
|
|
|
|
|
|
if (!hdc) break;
|
|
|
|
|
|
|
|
oldbmp = SelectObject(hdc, fill->bmp);
|
|
|
|
|
|
|
|
bf.BlendOp = AC_SRC_OVER;
|
|
|
|
bf.BlendFlags = 0;
|
|
|
|
bf.SourceConstantAlpha = 255;
|
|
|
|
bf.AlphaFormat = AC_SRC_ALPHA;
|
|
|
|
|
|
|
|
GdiAlphaBlend(graphics->hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc, 0, 0, 1, 1, bf);
|
|
|
|
|
|
|
|
SelectObject(hdc, oldbmp);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* else fall through */
|
|
|
|
}
|
2009-03-16 17:51:04 +00:00
|
|
|
default:
|
|
|
|
SelectObject(graphics->hdc, brush->gdibrush);
|
|
|
|
FillPath(graphics->hdc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-18 23:55:51 +00:00
|
|
|
/* GdipDrawPie/GdipFillPie helper function */
|
2007-07-25 00:18:54 +00:00
|
|
|
static void draw_pie(GpGraphics *graphics, REAL x, REAL y, REAL width,
|
|
|
|
REAL height, REAL startAngle, REAL sweepAngle)
|
2007-06-18 23:55:51 +00:00
|
|
|
{
|
2007-07-24 03:24:53 +00:00
|
|
|
GpPointF ptf[4];
|
|
|
|
POINT pti[4];
|
2007-06-18 23:55:51 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[0].X = x;
|
|
|
|
ptf[0].Y = y;
|
|
|
|
ptf[1].X = x + width;
|
|
|
|
ptf[1].Y = y + height;
|
|
|
|
|
|
|
|
deg2xy(startAngle+sweepAngle, x + width / 2.0, y + width / 2.0, &ptf[2].X, &ptf[2].Y);
|
|
|
|
deg2xy(startAngle, x + width / 2.0, y + width / 2.0, &ptf[3].X, &ptf[3].Y);
|
2007-06-18 23:55:51 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
transform_and_round_points(graphics, pti, ptf, 4);
|
2007-06-18 23:55:51 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
Pie(graphics->hdc, pti[0].x, pti[0].y, pti[1].x, pti[1].y, pti[2].x,
|
|
|
|
pti[2].y, pti[3].x, pti[3].y);
|
2007-06-18 23:55:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-07 20:20:41 +00:00
|
|
|
/* Draws the linecap the specified color and size on the hdc. The linecap is in
|
2007-07-21 00:50:02 +00:00
|
|
|
* direction of the line from x1, y1 to x2, y2 and is anchored on x2, y2. Probably
|
|
|
|
* should not be called on an hdc that has a path you care about. */
|
2007-07-24 03:24:53 +00:00
|
|
|
static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL size,
|
2007-07-20 01:22:51 +00:00
|
|
|
const GpCustomLineCap *custom, REAL x1, REAL y1, REAL x2, REAL y2)
|
2007-07-07 20:20:41 +00:00
|
|
|
{
|
2007-07-25 00:18:58 +00:00
|
|
|
HGDIOBJ oldbrush = NULL, oldpen = NULL;
|
2007-07-20 01:22:51 +00:00
|
|
|
GpMatrix *matrix = NULL;
|
2007-07-25 00:18:58 +00:00
|
|
|
HBRUSH brush = NULL;
|
|
|
|
HPEN pen = NULL;
|
2007-07-24 03:24:53 +00:00
|
|
|
PointF ptf[4], *custptf = NULL;
|
2007-07-20 01:22:51 +00:00
|
|
|
POINT pt[4], *custpt = NULL;
|
|
|
|
BYTE *tp = NULL;
|
2007-07-24 03:24:53 +00:00
|
|
|
REAL theta, dsmall, dbig, dx, dy = 0.0;
|
2007-07-20 01:22:51 +00:00
|
|
|
INT i, count;
|
|
|
|
LOGBRUSH lb;
|
2007-07-25 00:18:58 +00:00
|
|
|
BOOL customstroke;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-21 00:50:14 +00:00
|
|
|
if((x1 == x2) && (y1 == y2))
|
2007-07-07 20:20:41 +00:00
|
|
|
return;
|
|
|
|
|
2007-07-21 00:50:14 +00:00
|
|
|
theta = gdiplus_atan2(y2 - y1, x2 - x1);
|
|
|
|
|
2007-07-25 00:18:58 +00:00
|
|
|
customstroke = (cap == LineCapCustom) && custom && (!custom->fill);
|
|
|
|
if(!customstroke){
|
|
|
|
brush = CreateSolidBrush(color);
|
|
|
|
lb.lbStyle = BS_SOLID;
|
|
|
|
lb.lbColor = color;
|
|
|
|
lb.lbHatch = 0;
|
|
|
|
pen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT |
|
|
|
|
PS_JOIN_MITER, 1, &lb, 0,
|
|
|
|
NULL);
|
|
|
|
oldbrush = SelectObject(graphics->hdc, brush);
|
|
|
|
oldpen = SelectObject(graphics->hdc, pen);
|
|
|
|
}
|
2007-07-07 20:20:41 +00:00
|
|
|
|
|
|
|
switch(cap){
|
|
|
|
case LineCapFlat:
|
|
|
|
break;
|
|
|
|
case LineCapSquare:
|
|
|
|
case LineCapSquareAnchor:
|
|
|
|
case LineCapDiamondAnchor:
|
|
|
|
size = size * (cap & LineCapNoAnchor ? ANCHOR_WIDTH : 1.0) / 2.0;
|
|
|
|
if(cap == LineCapDiamondAnchor){
|
|
|
|
dsmall = cos(theta + M_PI_2) * size;
|
|
|
|
dbig = sin(theta + M_PI_2) * size;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
dsmall = cos(theta + M_PI_4) * size;
|
|
|
|
dbig = sin(theta + M_PI_4) * size;
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[0].X = x2 - dsmall;
|
|
|
|
ptf[1].X = x2 + dbig;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[0].Y = y2 - dbig;
|
|
|
|
ptf[3].Y = y2 + dsmall;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[1].Y = y2 - dsmall;
|
|
|
|
ptf[2].Y = y2 + dbig;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[3].X = x2 - dbig;
|
|
|
|
ptf[2].X = x2 + dsmall;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
transform_and_round_points(graphics, pt, ptf, 4);
|
|
|
|
Polygon(graphics->hdc, pt, 4);
|
2007-07-07 20:20:41 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case LineCapArrowAnchor:
|
|
|
|
size = size * 4.0 / sqrt(3.0);
|
|
|
|
|
2007-07-20 01:22:47 +00:00
|
|
|
dx = cos(M_PI / 6.0 + theta) * size;
|
|
|
|
dy = sin(M_PI / 6.0 + theta) * size;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[0].X = x2 - dx;
|
|
|
|
ptf[0].Y = y2 - dy;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-20 01:22:47 +00:00
|
|
|
dx = cos(- M_PI / 6.0 + theta) * size;
|
|
|
|
dy = sin(- M_PI / 6.0 + theta) * size;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[1].X = x2 - dx;
|
|
|
|
ptf[1].Y = y2 - dy;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[2].X = x2;
|
|
|
|
ptf[2].Y = y2;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
transform_and_round_points(graphics, pt, ptf, 3);
|
|
|
|
Polygon(graphics->hdc, pt, 3);
|
2007-07-07 20:20:41 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case LineCapRoundAnchor:
|
|
|
|
dx = dy = ANCHOR_WIDTH * size / 2.0;
|
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[0].X = x2 - dx;
|
|
|
|
ptf[0].Y = y2 - dy;
|
|
|
|
ptf[1].X = x2 + dx;
|
|
|
|
ptf[1].Y = y2 + dy;
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pt, ptf, 2);
|
|
|
|
Ellipse(graphics->hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
|
2007-07-07 20:20:41 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case LineCapTriangle:
|
|
|
|
size = size / 2.0;
|
|
|
|
dx = cos(M_PI_2 + theta) * size;
|
|
|
|
dy = sin(M_PI_2 + theta) * size;
|
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[0].X = x2 - dx;
|
|
|
|
ptf[0].Y = y2 - dy;
|
|
|
|
ptf[1].X = x2 + dx;
|
|
|
|
ptf[1].Y = y2 + dy;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-20 01:22:47 +00:00
|
|
|
dx = cos(theta) * size;
|
|
|
|
dy = sin(theta) * size;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[2].X = x2 + dx;
|
|
|
|
ptf[2].Y = y2 + dy;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
transform_and_round_points(graphics, pt, ptf, 3);
|
|
|
|
Polygon(graphics->hdc, pt, 3);
|
2007-07-07 20:20:41 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case LineCapRound:
|
2007-07-24 03:24:53 +00:00
|
|
|
dx = dy = size / 2.0;
|
|
|
|
|
|
|
|
ptf[0].X = x2 - dx;
|
|
|
|
ptf[0].Y = y2 - dy;
|
|
|
|
ptf[1].X = x2 + dx;
|
|
|
|
ptf[1].Y = y2 + dy;
|
|
|
|
|
2007-07-20 01:22:47 +00:00
|
|
|
dx = -cos(M_PI_2 + theta) * size;
|
|
|
|
dy = -sin(M_PI_2 + theta) * size;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf[2].X = x2 - dx;
|
|
|
|
ptf[2].Y = y2 - dy;
|
|
|
|
ptf[3].X = x2 + dx;
|
|
|
|
ptf[3].Y = y2 + dy;
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
transform_and_round_points(graphics, pt, ptf, 4);
|
|
|
|
Pie(graphics->hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y, pt[2].x,
|
|
|
|
pt[2].y, pt[3].x, pt[3].y);
|
2007-07-07 20:20:41 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case LineCapCustom:
|
2007-07-20 01:22:51 +00:00
|
|
|
if(!custom)
|
|
|
|
break;
|
|
|
|
|
|
|
|
count = custom->pathdata.Count;
|
|
|
|
custptf = GdipAlloc(count * sizeof(PointF));
|
|
|
|
custpt = GdipAlloc(count * sizeof(POINT));
|
|
|
|
tp = GdipAlloc(count);
|
|
|
|
|
|
|
|
if(!custptf || !custpt || !tp || (GdipCreateMatrix(&matrix) != Ok))
|
|
|
|
goto custend;
|
|
|
|
|
|
|
|
memcpy(custptf, custom->pathdata.Points, count * sizeof(PointF));
|
|
|
|
|
|
|
|
GdipScaleMatrix(matrix, size, size, MatrixOrderAppend);
|
|
|
|
GdipRotateMatrix(matrix, (180.0 / M_PI) * (theta - M_PI_2),
|
|
|
|
MatrixOrderAppend);
|
|
|
|
GdipTranslateMatrix(matrix, x2, y2, MatrixOrderAppend);
|
|
|
|
GdipTransformMatrixPoints(matrix, custptf, count);
|
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
transform_and_round_points(graphics, custpt, custptf, count);
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
2007-07-20 01:22:51 +00:00
|
|
|
tp[i] = convert_path_point_type(custom->pathdata.Types[i]);
|
|
|
|
|
2007-07-21 00:50:02 +00:00
|
|
|
if(custom->fill){
|
2007-07-24 03:24:53 +00:00
|
|
|
BeginPath(graphics->hdc);
|
|
|
|
PolyDraw(graphics->hdc, custpt, tp, count);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
StrokeAndFillPath(graphics->hdc);
|
2007-07-21 00:50:02 +00:00
|
|
|
}
|
|
|
|
else
|
2007-07-24 03:24:53 +00:00
|
|
|
PolyDraw(graphics->hdc, custpt, tp, count);
|
2007-07-20 01:22:51 +00:00
|
|
|
|
|
|
|
custend:
|
|
|
|
GdipFree(custptf);
|
|
|
|
GdipFree(custpt);
|
|
|
|
GdipFree(tp);
|
|
|
|
GdipDeleteMatrix(matrix);
|
|
|
|
break;
|
2007-07-07 20:20:41 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:18:58 +00:00
|
|
|
if(!customstroke){
|
|
|
|
SelectObject(graphics->hdc, oldbrush);
|
|
|
|
SelectObject(graphics->hdc, oldpen);
|
|
|
|
DeleteObject(brush);
|
|
|
|
DeleteObject(pen);
|
|
|
|
}
|
2007-07-07 20:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Shortens the line by the given percent by changing x2, y2.
|
2007-07-21 00:50:07 +00:00
|
|
|
* If percent is > 1.0 then the line will change direction.
|
|
|
|
* If percent is negative it can lengthen the line. */
|
2007-07-07 20:20:41 +00:00
|
|
|
static void shorten_line_percent(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL percent)
|
|
|
|
{
|
|
|
|
REAL dist, theta, dx, dy;
|
|
|
|
|
|
|
|
if((y1 == *y2) && (x1 == *x2))
|
|
|
|
return;
|
|
|
|
|
2007-07-21 00:50:07 +00:00
|
|
|
dist = sqrt((*x2 - x1) * (*x2 - x1) + (*y2 - y1) * (*y2 - y1)) * -percent;
|
2007-07-21 00:50:14 +00:00
|
|
|
theta = gdiplus_atan2((*y2 - y1), (*x2 - x1));
|
2007-07-07 20:20:41 +00:00
|
|
|
dx = cos(theta) * dist;
|
|
|
|
dy = sin(theta) * dist;
|
|
|
|
|
2007-07-21 00:50:07 +00:00
|
|
|
*x2 = *x2 + dx;
|
|
|
|
*y2 = *y2 + dy;
|
2007-07-07 20:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Shortens the line by the given amount by changing x2, y2.
|
2007-07-21 00:50:07 +00:00
|
|
|
* If the amount is greater than the distance, the line will become length 0.
|
|
|
|
* If the amount is negative, it can lengthen the line. */
|
2007-07-07 20:20:41 +00:00
|
|
|
static void shorten_line_amt(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL amt)
|
|
|
|
{
|
|
|
|
REAL dx, dy, percent;
|
|
|
|
|
|
|
|
dx = *x2 - x1;
|
|
|
|
dy = *y2 - y1;
|
|
|
|
if(dx == 0 && dy == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
percent = amt / sqrt(dx * dx + dy * dy);
|
|
|
|
if(percent >= 1.0){
|
|
|
|
*x2 = x1;
|
|
|
|
*y2 = y1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shorten_line_percent(x1, y1, x2, y2, percent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draws lines between the given points, and if caps is true then draws an endcap
|
2007-08-03 00:53:13 +00:00
|
|
|
* at the end of the last line. */
|
2007-07-24 03:24:53 +00:00
|
|
|
static GpStatus draw_polyline(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF * pt, INT count, BOOL caps)
|
2007-07-07 20:20:41 +00:00
|
|
|
{
|
2007-07-21 00:50:11 +00:00
|
|
|
POINT *pti = NULL;
|
|
|
|
GpPointF *ptcopy = NULL;
|
2007-07-12 01:07:44 +00:00
|
|
|
GpStatus status = GenericError;
|
|
|
|
|
|
|
|
if(!count)
|
|
|
|
return Ok;
|
|
|
|
|
|
|
|
pti = GdipAlloc(count * sizeof(POINT));
|
2007-07-21 00:50:11 +00:00
|
|
|
ptcopy = GdipAlloc(count * sizeof(GpPointF));
|
2007-07-12 01:07:44 +00:00
|
|
|
|
2007-07-21 00:50:11 +00:00
|
|
|
if(!pti || !ptcopy){
|
2007-07-12 01:07:44 +00:00
|
|
|
status = OutOfMemory;
|
|
|
|
goto end;
|
|
|
|
}
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-25 00:18:50 +00:00
|
|
|
memcpy(ptcopy, pt, count * sizeof(GpPointF));
|
2007-07-24 03:24:53 +00:00
|
|
|
|
2007-07-25 00:18:50 +00:00
|
|
|
if(caps){
|
2007-07-07 20:20:41 +00:00
|
|
|
if(pen->endcap == LineCapArrowAnchor)
|
2007-07-21 00:50:11 +00:00
|
|
|
shorten_line_amt(ptcopy[count-2].X, ptcopy[count-2].Y,
|
|
|
|
&ptcopy[count-1].X, &ptcopy[count-1].Y, pen->width);
|
2007-07-21 00:50:07 +00:00
|
|
|
else if((pen->endcap == LineCapCustom) && pen->customend)
|
2007-07-21 00:50:11 +00:00
|
|
|
shorten_line_amt(ptcopy[count-2].X, ptcopy[count-2].Y,
|
|
|
|
&ptcopy[count-1].X, &ptcopy[count-1].Y,
|
|
|
|
pen->customend->inset * pen->width);
|
|
|
|
|
|
|
|
if(pen->startcap == LineCapArrowAnchor)
|
|
|
|
shorten_line_amt(ptcopy[1].X, ptcopy[1].Y,
|
|
|
|
&ptcopy[0].X, &ptcopy[0].Y, pen->width);
|
|
|
|
else if((pen->startcap == LineCapCustom) && pen->customstart)
|
|
|
|
shorten_line_amt(ptcopy[1].X, ptcopy[1].Y,
|
|
|
|
&ptcopy[0].X, &ptcopy[0].Y,
|
2007-08-08 01:42:44 +00:00
|
|
|
pen->customstart->inset * pen->width);
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
|
2007-07-21 00:50:11 +00:00
|
|
|
pt[count - 2].X, pt[count - 2].Y, pt[count - 1].X, pt[count - 1].Y);
|
2007-07-24 03:24:53 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
|
2007-12-31 16:29:57 +00:00
|
|
|
pt[1].X, pt[1].Y, pt[0].X, pt[0].Y);
|
2007-07-07 20:20:41 +00:00
|
|
|
}
|
2007-07-25 00:18:50 +00:00
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptcopy, count);
|
2007-07-07 20:20:41 +00:00
|
|
|
|
2008-02-10 20:40:52 +00:00
|
|
|
if(Polyline(graphics->hdc, pti, count))
|
|
|
|
status = Ok;
|
2007-07-12 01:07:44 +00:00
|
|
|
|
|
|
|
end:
|
2007-07-07 20:20:41 +00:00
|
|
|
GdipFree(pti);
|
2007-07-21 00:50:11 +00:00
|
|
|
GdipFree(ptcopy);
|
2007-07-12 01:07:44 +00:00
|
|
|
|
|
|
|
return status;
|
2007-07-07 20:20:41 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 23:13:49 +00:00
|
|
|
/* Conducts a linear search to find the bezier points that will back off
|
|
|
|
* the endpoint of the curve by a distance of amt. Linear search works
|
|
|
|
* better than binary in this case because there are multiple solutions,
|
|
|
|
* and binary searches often find a bad one. I don't think this is what
|
|
|
|
* Windows does but short of rendering the bezier without GDI's help it's
|
2007-07-21 00:50:11 +00:00
|
|
|
* the best we can do. If rev then work from the start of the passed points
|
|
|
|
* instead of the end. */
|
|
|
|
static void shorten_bezier_amt(GpPointF * pt, REAL amt, BOOL rev)
|
2007-07-06 23:13:49 +00:00
|
|
|
{
|
|
|
|
GpPointF origpt[4];
|
2007-07-21 00:50:11 +00:00
|
|
|
REAL percent = 0.00, dx, dy, origx, origy, diff = -1.0;
|
|
|
|
INT i, first = 0, second = 1, third = 2, fourth = 3;
|
|
|
|
|
|
|
|
if(rev){
|
|
|
|
first = 3;
|
|
|
|
second = 2;
|
|
|
|
third = 1;
|
|
|
|
fourth = 0;
|
|
|
|
}
|
2007-07-06 23:13:49 +00:00
|
|
|
|
2007-07-21 00:50:11 +00:00
|
|
|
origx = pt[fourth].X;
|
|
|
|
origy = pt[fourth].Y;
|
2007-07-06 23:13:49 +00:00
|
|
|
memcpy(origpt, pt, sizeof(GpPointF) * 4);
|
|
|
|
|
|
|
|
for(i = 0; (i < MAX_ITERS) && (diff < amt); i++){
|
|
|
|
/* reset bezier points to original values */
|
|
|
|
memcpy(pt, origpt, sizeof(GpPointF) * 4);
|
|
|
|
/* Perform magic on bezier points. Order is important here.*/
|
2007-07-21 00:50:11 +00:00
|
|
|
shorten_line_percent(pt[third].X, pt[third].Y, &pt[fourth].X, &pt[fourth].Y, percent);
|
|
|
|
shorten_line_percent(pt[second].X, pt[second].Y, &pt[third].X, &pt[third].Y, percent);
|
|
|
|
shorten_line_percent(pt[third].X, pt[third].Y, &pt[fourth].X, &pt[fourth].Y, percent);
|
|
|
|
shorten_line_percent(pt[first].X, pt[first].Y, &pt[second].X, &pt[second].Y, percent);
|
|
|
|
shorten_line_percent(pt[second].X, pt[second].Y, &pt[third].X, &pt[third].Y, percent);
|
|
|
|
shorten_line_percent(pt[third].X, pt[third].Y, &pt[fourth].X, &pt[fourth].Y, percent);
|
2007-07-06 23:13:49 +00:00
|
|
|
|
2007-07-21 00:50:11 +00:00
|
|
|
dx = pt[fourth].X - origx;
|
|
|
|
dy = pt[fourth].Y - origy;
|
2007-07-06 23:13:49 +00:00
|
|
|
|
|
|
|
diff = sqrt(dx * dx + dy * dy);
|
|
|
|
percent += 0.0005 * amt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draws bezier curves between given points, and if caps is true then draws an
|
2007-08-03 00:53:13 +00:00
|
|
|
* endcap at the end of the last line. */
|
2007-07-24 03:24:53 +00:00
|
|
|
static GpStatus draw_polybezier(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF * pt, INT count, BOOL caps)
|
2007-07-06 23:13:49 +00:00
|
|
|
{
|
2007-08-03 00:53:08 +00:00
|
|
|
POINT *pti;
|
2007-07-21 00:50:11 +00:00
|
|
|
GpPointF *ptcopy;
|
2007-07-12 01:07:39 +00:00
|
|
|
GpStatus status = GenericError;
|
|
|
|
|
|
|
|
if(!count)
|
|
|
|
return Ok;
|
|
|
|
|
|
|
|
pti = GdipAlloc(count * sizeof(POINT));
|
2007-07-21 00:50:11 +00:00
|
|
|
ptcopy = GdipAlloc(count * sizeof(GpPointF));
|
2007-07-12 01:07:39 +00:00
|
|
|
|
2007-07-21 00:50:11 +00:00
|
|
|
if(!pti || !ptcopy){
|
2007-07-12 01:07:39 +00:00
|
|
|
status = OutOfMemory;
|
|
|
|
goto end;
|
|
|
|
}
|
2007-07-06 23:13:49 +00:00
|
|
|
|
2007-07-25 00:18:50 +00:00
|
|
|
memcpy(ptcopy, pt, count * sizeof(GpPointF));
|
2007-07-24 03:24:53 +00:00
|
|
|
|
2007-07-25 00:18:50 +00:00
|
|
|
if(caps){
|
2007-07-06 23:13:49 +00:00
|
|
|
if(pen->endcap == LineCapArrowAnchor)
|
2007-07-21 00:50:11 +00:00
|
|
|
shorten_bezier_amt(&ptcopy[count-4], pen->width, FALSE);
|
2007-08-03 00:53:08 +00:00
|
|
|
else if((pen->endcap == LineCapCustom) && pen->customend)
|
|
|
|
shorten_bezier_amt(&ptcopy[count-4], pen->width * pen->customend->inset,
|
|
|
|
FALSE);
|
2007-07-06 23:13:49 +00:00
|
|
|
|
2007-07-21 00:50:11 +00:00
|
|
|
if(pen->startcap == LineCapArrowAnchor)
|
|
|
|
shorten_bezier_amt(ptcopy, pen->width, TRUE);
|
2007-08-03 00:53:08 +00:00
|
|
|
else if((pen->startcap == LineCapCustom) && pen->customstart)
|
2007-08-08 01:42:44 +00:00
|
|
|
shorten_bezier_amt(ptcopy, pen->width * pen->customstart->inset, TRUE);
|
2007-07-21 00:50:11 +00:00
|
|
|
|
2007-07-12 01:08:26 +00:00
|
|
|
/* the direction of the line cap is parallel to the direction at the
|
|
|
|
* end of the bezier (which, if it has been shortened, is not the same
|
|
|
|
* as the direction from pt[count-2] to pt[count-1]) */
|
2007-07-24 03:24:53 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
|
2007-07-21 00:50:11 +00:00
|
|
|
pt[count - 1].X - (ptcopy[count - 1].X - ptcopy[count - 2].X),
|
|
|
|
pt[count - 1].Y - (ptcopy[count - 1].Y - ptcopy[count - 2].Y),
|
2007-07-12 01:08:26 +00:00
|
|
|
pt[count - 1].X, pt[count - 1].Y);
|
2007-07-06 23:13:49 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
|
2007-07-21 00:50:11 +00:00
|
|
|
pt[0].X - (ptcopy[0].X - ptcopy[1].X),
|
|
|
|
pt[0].Y - (ptcopy[0].Y - ptcopy[1].Y), pt[0].X, pt[0].Y);
|
2007-07-06 23:13:49 +00:00
|
|
|
}
|
2007-07-25 00:18:50 +00:00
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptcopy, count);
|
2007-07-06 23:13:49 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
PolyBezier(graphics->hdc, pti, count);
|
2007-07-12 01:07:39 +00:00
|
|
|
|
|
|
|
status = Ok;
|
|
|
|
|
|
|
|
end:
|
2007-07-06 23:13:49 +00:00
|
|
|
GdipFree(pti);
|
2007-07-21 00:50:11 +00:00
|
|
|
GdipFree(ptcopy);
|
2007-07-12 01:07:39 +00:00
|
|
|
|
|
|
|
return status;
|
2007-07-06 23:13:49 +00:00
|
|
|
}
|
|
|
|
|
2007-07-12 01:07:34 +00:00
|
|
|
/* Draws a combination of bezier curves and lines between points. */
|
2007-07-24 03:24:53 +00:00
|
|
|
static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF * pt,
|
2007-07-12 01:07:34 +00:00
|
|
|
GDIPCONST BYTE * types, INT count, BOOL caps)
|
|
|
|
{
|
2007-08-03 00:53:08 +00:00
|
|
|
POINT *pti = GdipAlloc(count * sizeof(POINT));
|
2007-07-12 01:07:34 +00:00
|
|
|
BYTE *tp = GdipAlloc(count);
|
2007-07-21 00:50:11 +00:00
|
|
|
GpPointF *ptcopy = GdipAlloc(count * sizeof(GpPointF));
|
|
|
|
INT i, j;
|
2007-07-12 01:07:34 +00:00
|
|
|
GpStatus status = GenericError;
|
|
|
|
|
|
|
|
if(!count){
|
|
|
|
status = Ok;
|
|
|
|
goto end;
|
|
|
|
}
|
2007-07-21 00:50:11 +00:00
|
|
|
if(!pti || !tp || !ptcopy){
|
2007-07-12 01:07:34 +00:00
|
|
|
status = OutOfMemory;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2007-07-21 00:50:11 +00:00
|
|
|
for(i = 1; i < count; i++){
|
2007-07-12 01:07:34 +00:00
|
|
|
if((types[i] & PathPointTypePathTypeMask) == PathPointTypeBezier){
|
|
|
|
if((i + 2 >= count) || !(types[i + 1] & PathPointTypeBezier)
|
|
|
|
|| !(types[i + 1] & PathPointTypeBezier)){
|
|
|
|
ERR("Bad bezier points\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:18:50 +00:00
|
|
|
memcpy(ptcopy, pt, count * sizeof(GpPointF));
|
|
|
|
|
2007-07-14 00:51:49 +00:00
|
|
|
/* If we are drawing caps, go through the points and adjust them accordingly,
|
|
|
|
* and draw the caps. */
|
|
|
|
if(caps){
|
|
|
|
switch(types[count - 1] & PathPointTypePathTypeMask){
|
|
|
|
case PathPointTypeBezier:
|
|
|
|
if(pen->endcap == LineCapArrowAnchor)
|
2007-07-21 00:50:11 +00:00
|
|
|
shorten_bezier_amt(&ptcopy[count - 4], pen->width, FALSE);
|
2007-08-03 00:53:08 +00:00
|
|
|
else if((pen->endcap == LineCapCustom) && pen->customend)
|
|
|
|
shorten_bezier_amt(&ptcopy[count - 4],
|
|
|
|
pen->width * pen->customend->inset, FALSE);
|
2007-07-12 01:07:34 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
|
2007-07-21 00:50:11 +00:00
|
|
|
pt[count - 1].X - (ptcopy[count - 1].X - ptcopy[count - 2].X),
|
|
|
|
pt[count - 1].Y - (ptcopy[count - 1].Y - ptcopy[count - 2].Y),
|
2007-07-14 00:51:49 +00:00
|
|
|
pt[count - 1].X, pt[count - 1].Y);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case PathPointTypeLine:
|
|
|
|
if(pen->endcap == LineCapArrowAnchor)
|
2007-07-21 00:50:11 +00:00
|
|
|
shorten_line_amt(ptcopy[count - 2].X, ptcopy[count - 2].Y,
|
|
|
|
&ptcopy[count - 1].X, &ptcopy[count - 1].Y,
|
2007-07-14 00:51:49 +00:00
|
|
|
pen->width);
|
2007-07-21 00:50:07 +00:00
|
|
|
else if((pen->endcap == LineCapCustom) && pen->customend)
|
2007-07-21 00:50:11 +00:00
|
|
|
shorten_line_amt(ptcopy[count - 2].X, ptcopy[count - 2].Y,
|
|
|
|
&ptcopy[count - 1].X, &ptcopy[count - 1].Y,
|
2007-07-21 00:50:07 +00:00
|
|
|
pen->customend->inset * pen->width);
|
2007-07-14 00:51:49 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
|
2007-07-20 01:22:51 +00:00
|
|
|
pt[count - 2].X, pt[count - 2].Y, pt[count - 1].X,
|
|
|
|
pt[count - 1].Y);
|
2007-07-14 00:51:49 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Bad path last point\n");
|
|
|
|
goto end;
|
2007-07-12 01:07:34 +00:00
|
|
|
}
|
2007-07-21 00:50:11 +00:00
|
|
|
|
|
|
|
/* Find start of points */
|
|
|
|
for(j = 1; j < count && ((types[j] & PathPointTypePathTypeMask)
|
|
|
|
== PathPointTypeStart); j++);
|
|
|
|
|
|
|
|
switch(types[j] & PathPointTypePathTypeMask){
|
|
|
|
case PathPointTypeBezier:
|
|
|
|
if(pen->startcap == LineCapArrowAnchor)
|
|
|
|
shorten_bezier_amt(&ptcopy[j - 1], pen->width, TRUE);
|
2007-08-03 00:53:08 +00:00
|
|
|
else if((pen->startcap == LineCapCustom) && pen->customstart)
|
|
|
|
shorten_bezier_amt(&ptcopy[j - 1],
|
2007-08-08 01:42:44 +00:00
|
|
|
pen->width * pen->customstart->inset, TRUE);
|
2007-07-21 00:50:11 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
|
2007-07-21 00:50:11 +00:00
|
|
|
pt[j - 1].X - (ptcopy[j - 1].X - ptcopy[j].X),
|
|
|
|
pt[j - 1].Y - (ptcopy[j - 1].Y - ptcopy[j].Y),
|
|
|
|
pt[j - 1].X, pt[j - 1].Y);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case PathPointTypeLine:
|
|
|
|
if(pen->startcap == LineCapArrowAnchor)
|
|
|
|
shorten_line_amt(ptcopy[j].X, ptcopy[j].Y,
|
|
|
|
&ptcopy[j - 1].X, &ptcopy[j - 1].Y,
|
|
|
|
pen->width);
|
|
|
|
else if((pen->startcap == LineCapCustom) && pen->customstart)
|
|
|
|
shorten_line_amt(ptcopy[j].X, ptcopy[j].Y,
|
|
|
|
&ptcopy[j - 1].X, &ptcopy[j - 1].Y,
|
|
|
|
pen->customstart->inset * pen->width);
|
|
|
|
|
2007-07-27 23:07:50 +00:00
|
|
|
draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
|
2007-07-21 00:50:11 +00:00
|
|
|
pt[j].X, pt[j].Y, pt[j - 1].X,
|
|
|
|
pt[j - 1].Y);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Bad path points\n");
|
|
|
|
goto end;
|
|
|
|
}
|
2007-07-12 01:07:34 +00:00
|
|
|
}
|
2007-07-25 00:18:50 +00:00
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptcopy, count);
|
2007-07-12 01:07:34 +00:00
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
tp[i] = convert_path_point_type(types[i]);
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
PolyDraw(graphics->hdc, pti, tp, count);
|
2007-07-12 01:07:34 +00:00
|
|
|
|
|
|
|
status = Ok;
|
|
|
|
|
|
|
|
end:
|
|
|
|
GdipFree(pti);
|
2007-07-21 00:50:11 +00:00
|
|
|
GdipFree(ptcopy);
|
2007-07-12 01:07:34 +00:00
|
|
|
GdipFree(tp);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-11-24 21:01:47 +00:00
|
|
|
GpStatus trace_path(GpGraphics *graphics, GpPath *path)
|
|
|
|
{
|
|
|
|
GpStatus result;
|
|
|
|
|
|
|
|
BeginPath(graphics->hdc);
|
|
|
|
result = draw_poly(graphics, NULL, path->pathdata.Points,
|
|
|
|
path->pathdata.Types, path->pathdata.Count, FALSE);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-07-05 22:04:20 +00:00
|
|
|
typedef struct _GraphicsContainerItem {
|
|
|
|
struct list entry;
|
|
|
|
GraphicsContainer contid;
|
|
|
|
|
|
|
|
SmoothingMode smoothing;
|
|
|
|
CompositingQuality compqual;
|
|
|
|
InterpolationMode interpolation;
|
|
|
|
CompositingMode compmode;
|
|
|
|
TextRenderingHint texthint;
|
|
|
|
REAL scale;
|
|
|
|
GpUnit unit;
|
|
|
|
PixelOffsetMode pixeloffset;
|
|
|
|
UINT textcontrast;
|
|
|
|
GpMatrix* worldtrans;
|
|
|
|
GpRegion* clip;
|
|
|
|
} GraphicsContainerItem;
|
|
|
|
|
|
|
|
static GpStatus init_container(GraphicsContainerItem** container,
|
|
|
|
GDIPCONST GpGraphics* graphics){
|
|
|
|
GpStatus sts;
|
|
|
|
|
|
|
|
*container = GdipAlloc(sizeof(GraphicsContainerItem));
|
|
|
|
if(!(*container))
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
(*container)->contid = graphics->contid + 1;
|
|
|
|
|
|
|
|
(*container)->smoothing = graphics->smoothing;
|
|
|
|
(*container)->compqual = graphics->compqual;
|
|
|
|
(*container)->interpolation = graphics->interpolation;
|
|
|
|
(*container)->compmode = graphics->compmode;
|
|
|
|
(*container)->texthint = graphics->texthint;
|
|
|
|
(*container)->scale = graphics->scale;
|
|
|
|
(*container)->unit = graphics->unit;
|
|
|
|
(*container)->textcontrast = graphics->textcontrast;
|
|
|
|
(*container)->pixeloffset = graphics->pixeloffset;
|
|
|
|
|
|
|
|
sts = GdipCloneMatrix(graphics->worldtrans, &(*container)->worldtrans);
|
|
|
|
if(sts != Ok){
|
|
|
|
GdipFree(*container);
|
|
|
|
*container = NULL;
|
|
|
|
return sts;
|
|
|
|
}
|
|
|
|
|
|
|
|
sts = GdipCloneRegion(graphics->clip, &(*container)->clip);
|
|
|
|
if(sts != Ok){
|
|
|
|
GdipDeleteMatrix((*container)->worldtrans);
|
|
|
|
GdipFree(*container);
|
|
|
|
*container = NULL;
|
|
|
|
return sts;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_container(GraphicsContainerItem* container){
|
|
|
|
GdipDeleteMatrix(container->worldtrans);
|
|
|
|
GdipDeleteRegion(container->clip);
|
|
|
|
GdipFree(container);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GpStatus restore_container(GpGraphics* graphics,
|
|
|
|
GDIPCONST GraphicsContainerItem* container){
|
|
|
|
GpStatus sts;
|
|
|
|
GpMatrix *newTrans;
|
|
|
|
GpRegion *newClip;
|
|
|
|
|
|
|
|
sts = GdipCloneMatrix(container->worldtrans, &newTrans);
|
|
|
|
if(sts != Ok)
|
|
|
|
return sts;
|
|
|
|
|
|
|
|
sts = GdipCloneRegion(container->clip, &newClip);
|
|
|
|
if(sts != Ok){
|
|
|
|
GdipDeleteMatrix(newTrans);
|
|
|
|
return sts;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipDeleteMatrix(graphics->worldtrans);
|
|
|
|
graphics->worldtrans = newTrans;
|
|
|
|
|
|
|
|
GdipDeleteRegion(graphics->clip);
|
|
|
|
graphics->clip = newClip;
|
|
|
|
|
|
|
|
graphics->contid = container->contid - 1;
|
|
|
|
|
|
|
|
graphics->smoothing = container->smoothing;
|
|
|
|
graphics->compqual = container->compqual;
|
|
|
|
graphics->interpolation = container->interpolation;
|
|
|
|
graphics->compmode = container->compmode;
|
|
|
|
graphics->texthint = container->texthint;
|
|
|
|
graphics->scale = container->scale;
|
|
|
|
graphics->unit = container->unit;
|
|
|
|
graphics->textcontrast = container->textcontrast;
|
|
|
|
graphics->pixeloffset = container->pixeloffset;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-08-12 20:36:54 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-08-26 23:03:08 +00:00
|
|
|
/* on success, rgn will contain the region of the graphics object which
|
|
|
|
* is visible after clipping has been applied */
|
|
|
|
static GpStatus get_visible_clip_region(GpGraphics *graphics, GpRegion *rgn)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpRectF rectf;
|
|
|
|
GpRegion* tmp;
|
|
|
|
|
|
|
|
if((stat = get_graphics_bounds(graphics, &rectf)) != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
if((stat = GdipCreateRegion(&tmp)) != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
if((stat = GdipCombineRegionRect(tmp, &rectf, CombineModeReplace)) != Ok)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
if((stat = GdipCombineRegionRegion(tmp, graphics->clip, CombineModeIntersect)) != Ok)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
stat = GdipCombineRegionRegion(rgn, tmp, CombineModeReplace);
|
|
|
|
|
|
|
|
end:
|
|
|
|
GdipDeleteRegion(tmp);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2007-06-11 18:54:03 +00:00
|
|
|
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
|
2007-12-23 09:56:32 +00:00
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", hdc, graphics);
|
|
|
|
|
2007-12-23 09:56:32 +00:00
|
|
|
return GdipCreateFromHDC2(hdc, NULL, graphics);
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **graphics)
|
2007-06-11 18:54:03 +00:00
|
|
|
{
|
2007-07-25 00:18:47 +00:00
|
|
|
GpStatus retval;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p)\n", hdc, hDevice, graphics);
|
|
|
|
|
2007-12-23 09:56:32 +00:00
|
|
|
if(hDevice != NULL) {
|
2009-06-09 20:48:05 +00:00
|
|
|
FIXME("Don't know how to handle parameter hDevice\n");
|
2007-12-23 09:56:32 +00:00
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-06-11 18:54:03 +00:00
|
|
|
if(hdc == NULL)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
if(graphics == NULL)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2007-06-23 02:27:02 +00:00
|
|
|
*graphics = GdipAlloc(sizeof(GpGraphics));
|
|
|
|
if(!*graphics) return OutOfMemory;
|
|
|
|
|
2007-07-25 00:18:47 +00:00
|
|
|
if((retval = GdipCreateMatrix(&(*graphics)->worldtrans)) != Ok){
|
|
|
|
GdipFree(*graphics);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-08-26 22:03:27 +00:00
|
|
|
if((retval = GdipCreateRegion(&(*graphics)->clip)) != Ok){
|
|
|
|
GdipFree((*graphics)->worldtrans);
|
|
|
|
GdipFree(*graphics);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-06-11 18:54:03 +00:00
|
|
|
(*graphics)->hdc = hdc;
|
2008-09-05 12:51:25 +00:00
|
|
|
(*graphics)->hwnd = WindowFromDC(hdc);
|
2009-04-24 18:29:56 +00:00
|
|
|
(*graphics)->owndc = FALSE;
|
2007-07-14 00:51:13 +00:00
|
|
|
(*graphics)->smoothing = SmoothingModeDefault;
|
2007-07-14 00:51:25 +00:00
|
|
|
(*graphics)->compqual = CompositingQualityDefault;
|
2007-07-14 00:51:29 +00:00
|
|
|
(*graphics)->interpolation = InterpolationModeDefault;
|
2007-07-14 00:51:33 +00:00
|
|
|
(*graphics)->pixeloffset = PixelOffsetModeDefault;
|
2007-08-14 01:34:27 +00:00
|
|
|
(*graphics)->compmode = CompositingModeSourceOver;
|
2007-07-24 03:24:41 +00:00
|
|
|
(*graphics)->unit = UnitDisplay;
|
2007-07-25 00:18:39 +00:00
|
|
|
(*graphics)->scale = 1.0;
|
2008-08-24 10:45:18 +00:00
|
|
|
(*graphics)->busy = FALSE;
|
2008-11-09 11:32:26 +00:00
|
|
|
(*graphics)->textcontrast = 4;
|
2009-07-05 22:04:20 +00:00
|
|
|
list_init(&(*graphics)->containers);
|
|
|
|
(*graphics)->contid = 0;
|
2007-06-11 18:54:03 +00:00
|
|
|
|
2009-12-18 21:09:45 +00:00
|
|
|
TRACE("<-- %p\n", *graphics);
|
|
|
|
|
2007-06-11 18:54:03 +00:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
|
|
|
|
{
|
|
|
|
GpStatus ret;
|
2009-04-24 18:34:55 +00:00
|
|
|
HDC hdc;
|
2007-06-11 18:54:03 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", hwnd, graphics);
|
|
|
|
|
2009-04-24 18:34:55 +00:00
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
|
|
|
|
if((ret = GdipCreateFromHDC(hdc, graphics)) != Ok)
|
|
|
|
{
|
|
|
|
ReleaseDC(hwnd, hdc);
|
2007-06-11 18:54:03 +00:00
|
|
|
return ret;
|
2009-04-24 18:34:55 +00:00
|
|
|
}
|
2007-06-11 18:54:03 +00:00
|
|
|
|
|
|
|
(*graphics)->hwnd = hwnd;
|
2009-04-24 18:29:56 +00:00
|
|
|
(*graphics)->owndc = TRUE;
|
2007-06-11 18:54:03 +00:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-05-09 12:40:41 +00:00
|
|
|
/* FIXME: no icm handling */
|
|
|
|
GpStatus WINGDIPAPI GdipCreateFromHWNDICM(HWND hwnd, GpGraphics **graphics)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", hwnd, graphics);
|
|
|
|
|
2008-05-09 12:40:41 +00:00
|
|
|
return GdipCreateFromHWND(hwnd, graphics);
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:19:05 +00:00
|
|
|
GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete,
|
|
|
|
GpMetafile **metafile)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 22:04:20 +00:00
|
|
|
TRACE("(%p,%i,%p)\n", hemf, delete, metafile);
|
|
|
|
|
2007-07-25 00:19:05 +00:00
|
|
|
if(!hemf || !metafile)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:19:15 +00:00
|
|
|
GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
|
|
|
|
GDIPCONST WmfPlaceableFileHeader * placeable, GpMetafile **metafile)
|
|
|
|
{
|
2007-08-01 02:15:12 +00:00
|
|
|
IStream *stream = NULL;
|
2007-07-31 02:10:03 +00:00
|
|
|
UINT read;
|
|
|
|
BYTE* copy;
|
|
|
|
HENHMETAFILE hemf;
|
2009-12-31 22:15:37 +00:00
|
|
|
GpStatus retval = Ok;
|
2007-07-25 00:19:15 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d, %p, %p)\n", hwmf, delete, placeable, metafile);
|
|
|
|
|
2007-07-25 00:19:15 +00:00
|
|
|
if(!hwmf || !metafile || !placeable)
|
|
|
|
return InvalidParameter;
|
2007-08-08 01:42:16 +00:00
|
|
|
|
|
|
|
*metafile = NULL;
|
2007-07-31 02:10:03 +00:00
|
|
|
read = GetMetaFileBitsEx(hwmf, 0, NULL);
|
|
|
|
if(!read)
|
|
|
|
return GenericError;
|
|
|
|
copy = GdipAlloc(read);
|
|
|
|
GetMetaFileBitsEx(hwmf, read, copy);
|
|
|
|
|
2007-08-02 00:55:33 +00:00
|
|
|
hemf = SetWinMetaFileBits(read, copy, NULL, NULL);
|
2007-07-31 02:10:03 +00:00
|
|
|
GdipFree(copy);
|
|
|
|
|
|
|
|
read = GetEnhMetaFileBits(hemf, 0, NULL);
|
|
|
|
copy = GdipAlloc(read);
|
|
|
|
GetEnhMetaFileBits(hemf, read, copy);
|
|
|
|
DeleteEnhMetaFile(hemf);
|
|
|
|
|
|
|
|
if(CreateStreamOnHGlobal(copy, TRUE, &stream) != S_OK){
|
|
|
|
ERR("could not make stream\n");
|
2007-08-08 01:42:16 +00:00
|
|
|
GdipFree(copy);
|
2009-12-31 22:15:37 +00:00
|
|
|
retval = GenericError;
|
2007-08-08 01:42:16 +00:00
|
|
|
goto err;
|
2007-07-31 02:10:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*metafile = GdipAlloc(sizeof(GpMetafile));
|
2007-08-01 02:15:12 +00:00
|
|
|
if(!*metafile){
|
|
|
|
retval = OutOfMemory;
|
2007-08-08 01:42:16 +00:00
|
|
|
goto err;
|
2007-08-01 02:15:12 +00:00
|
|
|
}
|
2007-07-31 02:10:03 +00:00
|
|
|
|
|
|
|
if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture,
|
2007-08-08 01:42:16 +00:00
|
|
|
(LPVOID*) &((*metafile)->image.picture)) != S_OK)
|
2009-12-31 22:15:37 +00:00
|
|
|
{
|
|
|
|
retval = GenericError;
|
2007-08-08 01:42:16 +00:00
|
|
|
goto err;
|
2009-12-31 22:15:37 +00:00
|
|
|
}
|
2007-08-08 01:42:16 +00:00
|
|
|
|
2007-07-31 02:10:03 +00:00
|
|
|
|
|
|
|
(*metafile)->image.type = ImageTypeMetafile;
|
2009-09-14 16:23:45 +00:00
|
|
|
memcpy(&(*metafile)->image.format, &ImageFormatWMF, sizeof(GUID));
|
2009-12-11 22:51:46 +00:00
|
|
|
(*metafile)->image.palette_flags = 0;
|
|
|
|
(*metafile)->image.palette_count = 0;
|
|
|
|
(*metafile)->image.palette_size = 0;
|
|
|
|
(*metafile)->image.palette_entries = NULL;
|
2009-12-27 01:46:55 +00:00
|
|
|
(*metafile)->image.xres = (REAL)placeable->Inch;
|
|
|
|
(*metafile)->image.yres = (REAL)placeable->Inch;
|
2007-07-31 02:09:57 +00:00
|
|
|
(*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
|
2009-12-27 01:07:37 +00:00
|
|
|
(*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Top) / ((REAL) placeable->Inch);
|
2007-07-31 02:09:57 +00:00
|
|
|
(*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right
|
|
|
|
- placeable->BoundingBox.Left)) / ((REAL) placeable->Inch);
|
|
|
|
(*metafile)->bounds.Height = ((REAL) (placeable->BoundingBox.Bottom
|
|
|
|
- placeable->BoundingBox.Top)) / ((REAL) placeable->Inch);
|
|
|
|
(*metafile)->unit = UnitInch;
|
|
|
|
|
2007-07-31 02:10:03 +00:00
|
|
|
if(delete)
|
|
|
|
DeleteMetaFile(hwmf);
|
|
|
|
|
2009-12-18 21:09:45 +00:00
|
|
|
TRACE("<-- %p\n", *metafile);
|
|
|
|
|
2007-08-08 01:42:16 +00:00
|
|
|
err:
|
2009-12-31 22:15:37 +00:00
|
|
|
if (retval != Ok)
|
|
|
|
GdipFree(*metafile);
|
2007-08-01 02:15:12 +00:00
|
|
|
IStream_Release(stream);
|
|
|
|
return retval;
|
2007-07-25 00:19:15 +00:00
|
|
|
}
|
|
|
|
|
2008-07-10 14:30:30 +00:00
|
|
|
GpStatus WINGDIPAPI GdipCreateMetafileFromWmfFile(GDIPCONST WCHAR *file,
|
|
|
|
GDIPCONST WmfPlaceableFileHeader * placeable, GpMetafile **metafile)
|
|
|
|
{
|
|
|
|
HMETAFILE hmf = GetMetaFileW(file);
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %p)\n", debugstr_w(file), placeable, metafile);
|
|
|
|
|
|
|
|
if(!hmf) return InvalidParameter;
|
|
|
|
|
|
|
|
return GdipCreateMetafileFromWmf(hmf, TRUE, placeable, metafile);
|
|
|
|
}
|
|
|
|
|
2009-06-02 01:02:11 +00:00
|
|
|
GpStatus WINGDIPAPI GdipCreateMetafileFromFile(GDIPCONST WCHAR *file,
|
|
|
|
GpMetafile **metafile)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", file, metafile);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipCreateMetafileFromStream(IStream *stream,
|
|
|
|
GpMetafile **metafile)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", stream, metafile);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-08-08 01:42:00 +00:00
|
|
|
GpStatus WINGDIPAPI GdipCreateStreamOnFile(GDIPCONST WCHAR * filename,
|
|
|
|
UINT access, IStream **stream)
|
|
|
|
{
|
|
|
|
DWORD dwMode;
|
|
|
|
HRESULT ret;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%s, %u, %p)\n", debugstr_w(filename), access, stream);
|
|
|
|
|
2007-08-08 01:42:00 +00:00
|
|
|
if(!stream || !filename)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(access & GENERIC_WRITE)
|
|
|
|
dwMode = STGM_SHARE_DENY_WRITE | STGM_WRITE | STGM_CREATE;
|
|
|
|
else if(access & GENERIC_READ)
|
|
|
|
dwMode = STGM_SHARE_DENY_WRITE | STGM_READ | STGM_FAILIFTHERE;
|
|
|
|
else
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
ret = SHCreateStreamOnFileW(filename, dwMode, stream);
|
|
|
|
|
|
|
|
return hresult_to_status(ret);
|
|
|
|
}
|
|
|
|
|
2007-06-11 18:54:03 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
|
|
|
|
{
|
2009-07-05 22:04:20 +00:00
|
|
|
GraphicsContainerItem *cont, *next;
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p)\n", graphics);
|
|
|
|
|
2007-06-11 18:54:03 +00:00
|
|
|
if(!graphics) return InvalidParameter;
|
2008-08-25 21:58:33 +00:00
|
|
|
if(graphics->busy) return ObjectBusy;
|
|
|
|
|
2009-04-24 18:29:56 +00:00
|
|
|
if(graphics->owndc)
|
2007-06-11 18:54:03 +00:00
|
|
|
ReleaseDC(graphics->hwnd, graphics->hdc);
|
|
|
|
|
2009-07-05 22:04:20 +00:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cont, next, &graphics->containers, GraphicsContainerItem, entry){
|
|
|
|
list_remove(&cont->entry);
|
|
|
|
delete_container(cont);
|
|
|
|
}
|
|
|
|
|
2008-08-26 22:03:27 +00:00
|
|
|
GdipDeleteRegion(graphics->clip);
|
2007-07-25 00:18:47 +00:00
|
|
|
GdipDeleteMatrix(graphics->worldtrans);
|
2008-08-24 10:45:05 +00:00
|
|
|
GdipFree(graphics);
|
2007-06-11 18:54:03 +00:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2007-06-12 17:44:31 +00:00
|
|
|
|
2007-06-20 02:31:19 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x,
|
|
|
|
REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
|
|
|
|
{
|
2007-07-12 01:07:09 +00:00
|
|
|
INT save_state, num_pts;
|
|
|
|
GpPointF points[MAX_ARC_PTS];
|
2007-07-12 01:07:39 +00:00
|
|
|
GpStatus retval;
|
2007-06-20 02:31:19 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y,
|
|
|
|
width, height, startAngle, sweepAngle);
|
|
|
|
|
2008-02-26 05:06:27 +00:00
|
|
|
if(!graphics || !pen || width <= 0 || height <= 0)
|
2007-06-20 02:31:19 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-12 01:07:09 +00:00
|
|
|
num_pts = arc2polybezier(points, x, y, width, height, startAngle, sweepAngle);
|
2007-06-20 02:31:19 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
2007-06-20 02:31:19 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
retval = draw_polybezier(graphics, pen, points, num_pts, TRUE);
|
2007-06-20 02:31:19 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
restore_dc(graphics, save_state);
|
2007-06-20 02:31:19 +00:00
|
|
|
|
2007-07-12 01:07:39 +00:00
|
|
|
return retval;
|
2007-06-20 02:31:19 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 05:02:59 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x,
|
|
|
|
INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d, %.2f, %.2f)\n", graphics, pen, x, y,
|
|
|
|
width, height, startAngle, sweepAngle);
|
|
|
|
|
2008-05-07 20:39:05 +00:00
|
|
|
return GdipDrawArc(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle);
|
2008-02-26 05:02:59 +00:00
|
|
|
}
|
|
|
|
|
2007-06-16 04:27:38 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics *graphics, GpPen *pen, REAL x1,
|
|
|
|
REAL y1, REAL x2, REAL y2, REAL x3, REAL y3, REAL x4, REAL y4)
|
|
|
|
{
|
2007-07-06 23:13:49 +00:00
|
|
|
INT save_state;
|
|
|
|
GpPointF pt[4];
|
2007-07-12 01:07:39 +00:00
|
|
|
GpStatus retval;
|
2007-06-16 04:27:38 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x1, y1,
|
|
|
|
x2, y2, x3, y3, x4, y4);
|
|
|
|
|
2007-06-16 04:27:38 +00:00
|
|
|
if(!graphics || !pen)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-06 23:13:49 +00:00
|
|
|
pt[0].X = x1;
|
|
|
|
pt[0].Y = y1;
|
|
|
|
pt[1].X = x2;
|
|
|
|
pt[1].Y = y2;
|
|
|
|
pt[2].X = x3;
|
|
|
|
pt[2].Y = y3;
|
|
|
|
pt[3].X = x4;
|
|
|
|
pt[3].Y = y4;
|
2007-06-16 04:27:38 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
2007-06-16 04:27:38 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
retval = draw_polybezier(graphics, pen, pt, 4, TRUE);
|
2008-02-26 05:00:43 +00:00
|
|
|
|
|
|
|
restore_dc(graphics, save_state);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawBezierI(GpGraphics *graphics, GpPen *pen, INT x1,
|
|
|
|
INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpPointF pt[4];
|
|
|
|
GpStatus retval;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d)\n", graphics, pen, x1, y1,
|
|
|
|
x2, y2, x3, y3, x4, y4);
|
|
|
|
|
2008-02-26 05:00:43 +00:00
|
|
|
if(!graphics || !pen)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-02-26 05:00:43 +00:00
|
|
|
pt[0].X = x1;
|
|
|
|
pt[0].Y = y1;
|
|
|
|
pt[1].X = x2;
|
|
|
|
pt[1].Y = y2;
|
|
|
|
pt[2].X = x3;
|
|
|
|
pt[2].Y = y3;
|
|
|
|
pt[3].X = x4;
|
|
|
|
pt[3].Y = y4;
|
|
|
|
|
|
|
|
save_state = prepare_dc(graphics, pen);
|
|
|
|
|
|
|
|
retval = draw_polybezier(graphics, pen, pt, 4, TRUE);
|
2007-07-06 23:13:49 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
restore_dc(graphics, save_state);
|
2007-06-16 04:27:38 +00:00
|
|
|
|
2007-07-12 01:07:39 +00:00
|
|
|
return retval;
|
2007-06-16 04:27:38 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 23:04:50 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawBeziers(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF *points, INT count)
|
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
GpStatus ret;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2008-07-02 23:04:50 +00:00
|
|
|
if(!graphics || !pen || !points || (count <= 0))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-07-02 23:04:50 +00:00
|
|
|
for(i = 0; i < floor(count / 4); i++){
|
|
|
|
ret = GdipDrawBezier(graphics, pen,
|
|
|
|
points[4*i].X, points[4*i].Y,
|
|
|
|
points[4*i + 1].X, points[4*i + 1].Y,
|
|
|
|
points[4*i + 2].X, points[4*i + 2].Y,
|
|
|
|
points[4*i + 3].X, points[4*i + 3].Y);
|
|
|
|
if(ret != Ok)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawBeziersI(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPoint *points, INT count)
|
|
|
|
{
|
|
|
|
GpPointF *pts;
|
|
|
|
GpStatus ret;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2008-07-02 23:04:50 +00:00
|
|
|
if(!graphics || !pen || !points || (count <= 0))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-07-02 23:04:50 +00:00
|
|
|
pts = GdipAlloc(sizeof(GpPointF) * count);
|
|
|
|
if(!pts)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
pts[i].X = (REAL)points[i].X;
|
|
|
|
pts[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GdipDrawBeziers(graphics,pen,pts,count);
|
|
|
|
|
|
|
|
GdipFree(pts);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-07-08 20:39:31 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawClosedCurve(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF *points, INT count)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2008-07-08 20:39:31 +00:00
|
|
|
return GdipDrawClosedCurve2(graphics, pen, points, count, 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawClosedCurveI(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPoint *points, INT count)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2008-07-08 20:39:31 +00:00
|
|
|
return GdipDrawClosedCurve2I(graphics, pen, points, count, 1.0);
|
|
|
|
}
|
|
|
|
|
2008-07-08 20:39:19 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawClosedCurve2(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF *points, INT count, REAL tension)
|
|
|
|
{
|
2008-09-03 15:57:09 +00:00
|
|
|
GpPath *path;
|
2008-07-08 20:39:19 +00:00
|
|
|
GpStatus stat;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %.2f)\n", graphics, pen, points, count, tension);
|
|
|
|
|
2008-07-08 20:39:19 +00:00
|
|
|
if(!graphics || !pen || !points || count <= 0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-09-03 15:57:09 +00:00
|
|
|
if((stat = GdipCreatePath(FillModeAlternate, &path)) != Ok)
|
|
|
|
return stat;
|
2008-07-08 20:39:19 +00:00
|
|
|
|
2008-09-03 15:57:09 +00:00
|
|
|
stat = GdipAddPathClosedCurve2(path, points, count, tension);
|
|
|
|
if(stat != Ok){
|
|
|
|
GdipDeletePath(path);
|
|
|
|
return stat;
|
|
|
|
}
|
2008-07-08 20:39:19 +00:00
|
|
|
|
2008-09-03 15:57:09 +00:00
|
|
|
stat = GdipDrawPath(graphics, pen, path);
|
2008-07-08 20:39:19 +00:00
|
|
|
|
2008-09-03 15:57:09 +00:00
|
|
|
GdipDeletePath(path);
|
2008-07-08 20:39:19 +00:00
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawClosedCurve2I(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPoint *points, INT count, REAL tension)
|
|
|
|
{
|
|
|
|
GpPointF *ptf;
|
|
|
|
GpStatus stat;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %.2f)\n", graphics, pen, points, count, tension);
|
|
|
|
|
2008-07-08 20:39:19 +00:00
|
|
|
if(!points || count <= 0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
ptf = GdipAlloc(sizeof(GpPointF)*count);
|
|
|
|
if(!ptf)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
ptf[i].X = (REAL)points[i].X;
|
|
|
|
ptf[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
stat = GdipDrawClosedCurve2(graphics, pen, ptf, count, tension);
|
|
|
|
|
|
|
|
GdipFree(ptf);
|
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2008-04-28 20:09:55 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawCurve(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF *points, INT count)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2008-04-28 20:09:55 +00:00
|
|
|
return GdipDrawCurve2(graphics,pen,points,count,1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawCurveI(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPoint *points, INT count)
|
|
|
|
{
|
|
|
|
GpPointF *pointsF;
|
|
|
|
GpStatus ret;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2009-06-28 18:33:52 +00:00
|
|
|
if(!points)
|
2008-04-28 20:09:55 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
pointsF = GdipAlloc(sizeof(GpPointF)*count);
|
|
|
|
if(!pointsF)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
pointsF[i].X = (REAL)points[i].X;
|
|
|
|
pointsF[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GdipDrawCurve(graphics,pen,pointsF,count);
|
|
|
|
GdipFree(pointsF);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-06-20 02:31:28 +00:00
|
|
|
/* Approximates cardinal spline with Bezier curves. */
|
|
|
|
GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF *points, INT count, REAL tension)
|
|
|
|
{
|
|
|
|
/* PolyBezier expects count*3-2 points. */
|
2007-07-10 03:54:23 +00:00
|
|
|
INT i, len_pt = count*3-2, save_state;
|
|
|
|
GpPointF *pt;
|
2007-06-20 02:31:28 +00:00
|
|
|
REAL x1, x2, y1, y2;
|
2007-07-12 01:07:39 +00:00
|
|
|
GpStatus retval;
|
2007-06-20 02:31:28 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %.2f)\n", graphics, pen, points, count, tension);
|
|
|
|
|
2007-06-20 02:31:28 +00:00
|
|
|
if(!graphics || !pen)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-06-06 17:02:29 +00:00
|
|
|
if(count < 2)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2007-07-10 03:54:23 +00:00
|
|
|
pt = GdipAlloc(len_pt * sizeof(GpPointF));
|
2009-06-06 17:02:29 +00:00
|
|
|
if(!pt)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
2007-06-20 02:31:28 +00:00
|
|
|
tension = tension * TENSION_CONST;
|
|
|
|
|
|
|
|
calc_curve_bezier_endp(points[0].X, points[0].Y, points[1].X, points[1].Y,
|
|
|
|
tension, &x1, &y1);
|
|
|
|
|
2007-07-10 03:54:23 +00:00
|
|
|
pt[0].X = points[0].X;
|
|
|
|
pt[0].Y = points[0].Y;
|
|
|
|
pt[1].X = x1;
|
|
|
|
pt[1].Y = y1;
|
2007-06-20 02:31:28 +00:00
|
|
|
|
|
|
|
for(i = 0; i < count-2; i++){
|
|
|
|
calc_curve_bezier(&(points[i]), tension, &x1, &y1, &x2, &y2);
|
|
|
|
|
2007-07-10 03:54:23 +00:00
|
|
|
pt[3*i+2].X = x1;
|
|
|
|
pt[3*i+2].Y = y1;
|
|
|
|
pt[3*i+3].X = points[i+1].X;
|
|
|
|
pt[3*i+3].Y = points[i+1].Y;
|
|
|
|
pt[3*i+4].X = x2;
|
|
|
|
pt[3*i+4].Y = y2;
|
2007-06-20 02:31:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
calc_curve_bezier_endp(points[count-1].X, points[count-1].Y,
|
|
|
|
points[count-2].X, points[count-2].Y, tension, &x1, &y1);
|
|
|
|
|
2007-07-10 03:54:23 +00:00
|
|
|
pt[len_pt-2].X = x1;
|
|
|
|
pt[len_pt-2].Y = y1;
|
|
|
|
pt[len_pt-1].X = points[count-1].X;
|
|
|
|
pt[len_pt-1].Y = points[count-1].Y;
|
2007-06-20 02:31:28 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
2007-06-20 02:31:28 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
retval = draw_polybezier(graphics, pen, pt, len_pt, TRUE);
|
2007-06-20 02:31:28 +00:00
|
|
|
|
2007-07-10 03:54:23 +00:00
|
|
|
GdipFree(pt);
|
2007-07-25 00:18:54 +00:00
|
|
|
restore_dc(graphics, save_state);
|
2007-06-20 02:31:28 +00:00
|
|
|
|
2007-07-12 01:07:39 +00:00
|
|
|
return retval;
|
2007-06-20 02:31:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-28 20:09:44 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawCurve2I(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPoint *points, INT count, REAL tension)
|
|
|
|
{
|
|
|
|
GpPointF *pointsF;
|
|
|
|
GpStatus ret;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %.2f)\n", graphics, pen, points, count, tension);
|
|
|
|
|
2009-06-28 18:33:59 +00:00
|
|
|
if(!points)
|
2008-04-28 20:09:44 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
pointsF = GdipAlloc(sizeof(GpPointF)*count);
|
|
|
|
if(!pointsF)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
pointsF[i].X = (REAL)points[i].X;
|
|
|
|
pointsF[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GdipDrawCurve2(graphics,pen,pointsF,count,tension);
|
|
|
|
GdipFree(pointsF);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-06-30 03:12:40 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawCurve3(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPointF *points, INT count, INT offset, INT numberOfSegments,
|
|
|
|
REAL tension)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %p, %d, %d, %d, %.2f)\n", graphics, pen, points, count, offset, numberOfSegments, tension);
|
|
|
|
|
|
|
|
if(offset >= count || numberOfSegments > count - offset - 1 || numberOfSegments <= 0){
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GdipDrawCurve2(graphics, pen, points + offset, numberOfSegments + 1, tension);
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawCurve3I(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpPoint *points, INT count, INT offset, INT numberOfSegments,
|
|
|
|
REAL tension)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %p, %d, %d, %d, %.2f)\n", graphics, pen, points, count, offset, numberOfSegments, tension);
|
|
|
|
|
|
|
|
if(count < 0){
|
|
|
|
return OutOfMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(offset >= count || numberOfSegments > count - offset - 1 || numberOfSegments <= 0){
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GdipDrawCurve2I(graphics, pen, points + offset, numberOfSegments + 1, tension);
|
|
|
|
}
|
|
|
|
|
2008-06-27 08:59:23 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x,
|
|
|
|
REAL y, REAL width, REAL height)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpPointF ptf[2];
|
|
|
|
POINT pti[2];
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y, width, height);
|
|
|
|
|
2008-06-27 08:59:23 +00:00
|
|
|
if(!graphics || !pen)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-06-27 08:59:23 +00:00
|
|
|
ptf[0].X = x;
|
|
|
|
ptf[0].Y = y;
|
|
|
|
ptf[1].X = x + width;
|
|
|
|
ptf[1].Y = y + height;
|
|
|
|
|
|
|
|
save_state = prepare_dc(graphics, pen);
|
|
|
|
SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptf, 2);
|
|
|
|
|
|
|
|
Ellipse(graphics->hdc, pti[0].x, pti[0].y, pti[1].x, pti[1].y);
|
|
|
|
|
|
|
|
restore_dc(graphics, save_state);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawEllipseI(GpGraphics *graphics, GpPen *pen, INT x,
|
|
|
|
INT y, INT width, INT height)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d)\n", graphics, pen, x, y, width, height);
|
|
|
|
|
2008-06-27 08:59:23 +00:00
|
|
|
return GdipDrawEllipse(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-28 20:10:01 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImage(GpGraphics *graphics, GpImage *image, REAL x, REAL y)
|
|
|
|
{
|
2009-08-20 21:16:05 +00:00
|
|
|
UINT width, height;
|
|
|
|
GpPointF points[3];
|
2008-04-28 20:10:01 +00:00
|
|
|
|
2009-08-20 21:16:05 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f)\n", graphics, image, x, y);
|
2008-09-02 19:45:39 +00:00
|
|
|
|
2007-08-08 01:42:12 +00:00
|
|
|
if(!graphics || !image)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
GdipGetImageWidth(image, &width);
|
|
|
|
GdipGetImageHeight(image, &height);
|
|
|
|
|
2009-08-20 21:16:05 +00:00
|
|
|
/* FIXME: we should use the graphics and image dpi, somehow */
|
2007-08-08 01:42:12 +00:00
|
|
|
|
2009-08-20 21:16:05 +00:00
|
|
|
points[0].X = points[2].X = x;
|
|
|
|
points[0].Y = points[1].Y = y;
|
|
|
|
points[1].X = x + width;
|
|
|
|
points[2].Y = y + height;
|
2007-08-08 01:42:12 +00:00
|
|
|
|
2009-08-20 21:16:05 +00:00
|
|
|
return GdipDrawImagePointsRect(graphics, image, points, 3, 0, 0, width, height,
|
|
|
|
UnitPixel, NULL, NULL, NULL);
|
|
|
|
}
|
2007-08-08 01:42:12 +00:00
|
|
|
|
2009-08-20 21:16:05 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImageI(GpGraphics *graphics, GpImage *image, INT x,
|
|
|
|
INT y)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %d, %d)\n", graphics, image, x, y);
|
|
|
|
|
|
|
|
return GdipDrawImage(graphics, image, (REAL)x, (REAL)y);
|
2007-08-08 01:42:12 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 03:34:37 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImagePointRect(GpGraphics *graphics, GpImage *image,
|
|
|
|
REAL x, REAL y, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight,
|
|
|
|
GpUnit srcUnit)
|
|
|
|
{
|
2009-09-04 17:51:48 +00:00
|
|
|
GpPointF points[3];
|
|
|
|
TRACE("(%p, %p, %f, %f, %f, %f, %f, %f, %d)\n", graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcUnit);
|
|
|
|
|
|
|
|
points[0].X = points[2].X = x;
|
|
|
|
points[0].Y = points[1].Y = y;
|
|
|
|
|
|
|
|
/* FIXME: convert image coordinates to Graphics coordinates? */
|
|
|
|
points[1].X = x + srcwidth;
|
|
|
|
points[2].Y = y + srcheight;
|
|
|
|
|
|
|
|
return GdipDrawImagePointsRect(graphics, image, points, 3, srcx, srcy,
|
|
|
|
srcwidth, srcheight, srcUnit, NULL, NULL, NULL);
|
2009-06-03 03:34:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawImagePointRectI(GpGraphics *graphics, GpImage *image,
|
|
|
|
INT x, INT y, INT srcx, INT srcy, INT srcwidth, INT srcheight,
|
|
|
|
GpUnit srcUnit)
|
|
|
|
{
|
2009-09-04 17:51:48 +00:00
|
|
|
return GdipDrawImagePointRect(graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcUnit);
|
2009-06-03 03:34:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-04 04:31:21 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImagePoints(GpGraphics *graphics, GpImage *image,
|
|
|
|
GDIPCONST GpPointF *dstpoints, INT count)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p, %d): stub\n", graphics, image, dstpoints, count);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawImagePointsI(GpGraphics *graphics, GpImage *image,
|
|
|
|
GDIPCONST GpPoint *dstpoints, INT count)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p, %d): stub\n", graphics, image, dstpoints, count);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-08-10 01:25:09 +00:00
|
|
|
/* FIXME: partially implemented (only works for rectangular parallelograms) */
|
2007-07-31 02:09:45 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image,
|
2007-07-31 02:10:07 +00:00
|
|
|
GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth,
|
|
|
|
REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes,
|
|
|
|
DrawImageAbort callback, VOID * callbackData)
|
2007-07-31 02:09:45 +00:00
|
|
|
{
|
2007-07-31 02:10:07 +00:00
|
|
|
GpPointF ptf[3];
|
|
|
|
POINT pti[3];
|
2007-08-01 02:16:23 +00:00
|
|
|
REAL dx, dy;
|
2007-07-31 02:09:45 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %f, %f, %f, %f, %d, %p, %p, %p)\n", graphics, image, points,
|
|
|
|
count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback,
|
2007-07-31 02:10:07 +00:00
|
|
|
callbackData);
|
2007-07-31 02:09:45 +00:00
|
|
|
|
2008-04-24 21:58:36 +00:00
|
|
|
if(!graphics || !image || !points || count != 3)
|
2007-07-31 02:10:07 +00:00
|
|
|
return InvalidParameter;
|
2007-07-31 02:09:45 +00:00
|
|
|
|
2009-12-18 21:45:02 +00:00
|
|
|
TRACE("%s %s %s\n", debugstr_pointf(&points[0]), debugstr_pointf(&points[1]),
|
|
|
|
debugstr_pointf(&points[2]));
|
|
|
|
|
2007-07-31 02:10:07 +00:00
|
|
|
memcpy(ptf, points, 3 * sizeof(GpPointF));
|
|
|
|
transform_and_round_points(graphics, pti, ptf, 3);
|
|
|
|
|
2009-08-28 21:21:27 +00:00
|
|
|
if (image->picture)
|
|
|
|
{
|
|
|
|
if(srcUnit == UnitInch)
|
|
|
|
dx = dy = (REAL) INCH_HIMETRIC;
|
|
|
|
else if(srcUnit == UnitPixel){
|
|
|
|
dx = ((REAL) INCH_HIMETRIC) /
|
|
|
|
((REAL) GetDeviceCaps(graphics->hdc, LOGPIXELSX));
|
|
|
|
dy = ((REAL) INCH_HIMETRIC) /
|
|
|
|
((REAL) GetDeviceCaps(graphics->hdc, LOGPIXELSY));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NotImplemented;
|
|
|
|
|
|
|
|
if(IPicture_Render(image->picture, graphics->hdc,
|
|
|
|
pti[0].x, pti[0].y, pti[1].x - pti[0].x, pti[2].y - pti[0].y,
|
|
|
|
srcx * dx, srcy * dy,
|
|
|
|
srcwidth * dx, srcheight * dy,
|
|
|
|
NULL) != S_OK){
|
|
|
|
if(callback)
|
|
|
|
callback(callbackData);
|
|
|
|
return GenericError;
|
|
|
|
}
|
2007-08-01 02:16:23 +00:00
|
|
|
}
|
2009-08-28 21:21:27 +00:00
|
|
|
else if (image->type == ImageTypeBitmap && ((GpBitmap*)image)->hbitmap)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
GpBitmap* bitmap = (GpBitmap*)image;
|
2009-08-28 22:21:10 +00:00
|
|
|
int temp_hdc=0, temp_bitmap=0;
|
|
|
|
HBITMAP hbitmap, old_hbm=NULL;
|
2009-08-28 21:21:27 +00:00
|
|
|
|
|
|
|
if (srcUnit == UnitInch)
|
|
|
|
dx = dy = 96.0; /* FIXME: use the image resolution */
|
|
|
|
else if (srcUnit == UnitPixel)
|
|
|
|
dx = dy = 1.0;
|
|
|
|
else
|
|
|
|
return NotImplemented;
|
|
|
|
|
2009-08-28 22:21:10 +00:00
|
|
|
if (bitmap->format == PixelFormat32bppARGB)
|
2009-08-28 21:21:27 +00:00
|
|
|
{
|
2009-08-28 22:21:10 +00:00
|
|
|
BITMAPINFOHEADER bih;
|
|
|
|
BYTE *temp_bits;
|
|
|
|
|
|
|
|
/* we need a bitmap with premultiplied alpha */
|
2009-08-28 21:21:27 +00:00
|
|
|
hdc = CreateCompatibleDC(0);
|
2009-08-28 22:21:10 +00:00
|
|
|
temp_hdc = 1;
|
|
|
|
temp_bitmap = 1;
|
|
|
|
|
|
|
|
bih.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
bih.biWidth = bitmap->width;
|
|
|
|
bih.biHeight = -bitmap->height;
|
|
|
|
bih.biPlanes = 1;
|
|
|
|
bih.biBitCount = 32;
|
|
|
|
bih.biCompression = BI_RGB;
|
|
|
|
bih.biSizeImage = 0;
|
|
|
|
bih.biXPelsPerMeter = 0;
|
|
|
|
bih.biYPelsPerMeter = 0;
|
|
|
|
bih.biClrUsed = 0;
|
|
|
|
bih.biClrImportant = 0;
|
|
|
|
|
|
|
|
hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS,
|
|
|
|
(void**)&temp_bits, NULL, 0);
|
|
|
|
|
|
|
|
convert_32bppARGB_to_32bppPARGB(bitmap->width, bitmap->height,
|
|
|
|
temp_bits, bitmap->width*4, bitmap->bits, bitmap->stride);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hbitmap = bitmap->hbitmap;
|
|
|
|
hdc = bitmap->hdc;
|
|
|
|
temp_hdc = (hdc == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (temp_hdc)
|
|
|
|
{
|
|
|
|
if (!hdc) hdc = CreateCompatibleDC(0);
|
|
|
|
old_hbm = SelectObject(hdc, hbitmap);
|
2009-08-28 21:21:27 +00:00
|
|
|
}
|
2007-08-01 02:16:23 +00:00
|
|
|
|
2009-08-28 22:21:10 +00:00
|
|
|
if (bitmap->format == PixelFormat32bppARGB || bitmap->format == PixelFormat32bppPARGB)
|
|
|
|
{
|
|
|
|
BLENDFUNCTION bf;
|
|
|
|
|
|
|
|
bf.BlendOp = AC_SRC_OVER;
|
|
|
|
bf.BlendFlags = 0;
|
|
|
|
bf.SourceConstantAlpha = 255;
|
|
|
|
bf.AlphaFormat = AC_SRC_ALPHA;
|
|
|
|
|
|
|
|
GdiAlphaBlend(graphics->hdc, pti[0].x, pti[0].y, pti[1].x-pti[0].x, pti[2].y-pti[0].y,
|
|
|
|
hdc, srcx*dx, srcy*dy, srcwidth*dx, srcheight*dy, bf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StretchBlt(graphics->hdc, pti[0].x, pti[0].y, pti[1].x-pti[0].x, pti[2].y-pti[0].y,
|
|
|
|
hdc, srcx*dx, srcy*dy, srcwidth*dx, srcheight*dy, SRCCOPY);
|
|
|
|
}
|
2009-08-28 21:21:27 +00:00
|
|
|
|
2009-08-28 22:21:10 +00:00
|
|
|
if (temp_hdc)
|
2009-08-28 21:21:27 +00:00
|
|
|
{
|
|
|
|
SelectObject(hdc, old_hbm);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
2009-08-28 22:21:10 +00:00
|
|
|
|
|
|
|
if (temp_bitmap)
|
|
|
|
DeleteObject(hbitmap);
|
2009-08-28 21:21:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("GpImage with no IPicture or HBITMAP?!\n");
|
|
|
|
return NotImplemented;
|
2007-07-31 02:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
2007-07-31 02:09:45 +00:00
|
|
|
}
|
|
|
|
|
2008-04-28 20:10:05 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImagePointsRectI(GpGraphics *graphics, GpImage *image,
|
|
|
|
GDIPCONST GpPoint *points, INT count, INT srcx, INT srcy, INT srcwidth,
|
|
|
|
INT srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes,
|
|
|
|
DrawImageAbort callback, VOID * callbackData)
|
|
|
|
{
|
|
|
|
GpPointF pointsF[3];
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %d, %d, %d, %d, %d, %p, %p, %p)\n", graphics, image, points, count,
|
|
|
|
srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback,
|
|
|
|
callbackData);
|
|
|
|
|
2008-04-28 20:10:05 +00:00
|
|
|
if(!points || count!=3)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
pointsF[i].X = (REAL)points[i].X;
|
|
|
|
pointsF[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GdipDrawImagePointsRect(graphics, image, pointsF, count, (REAL)srcx, (REAL)srcy,
|
|
|
|
(REAL)srcwidth, (REAL)srcheight, srcUnit, imageAttributes,
|
|
|
|
callback, callbackData);
|
|
|
|
}
|
|
|
|
|
2007-08-10 01:25:09 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImageRectRect(GpGraphics *graphics, GpImage *image,
|
|
|
|
REAL dstx, REAL dsty, REAL dstwidth, REAL dstheight, REAL srcx, REAL srcy,
|
|
|
|
REAL srcwidth, REAL srcheight, GpUnit srcUnit,
|
|
|
|
GDIPCONST GpImageAttributes* imageattr, DrawImageAbort callback,
|
|
|
|
VOID * callbackData)
|
|
|
|
{
|
|
|
|
GpPointF points[3];
|
|
|
|
|
2008-09-05 11:14:56 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p, %p, %p)\n",
|
2008-09-02 19:45:39 +00:00
|
|
|
graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy,
|
|
|
|
srcwidth, srcheight, srcUnit, imageattr, callback, callbackData);
|
|
|
|
|
2007-08-10 01:25:09 +00:00
|
|
|
points[0].X = dstx;
|
|
|
|
points[0].Y = dsty;
|
|
|
|
points[1].X = dstx + dstwidth;
|
|
|
|
points[1].Y = dsty;
|
|
|
|
points[2].X = dstx;
|
|
|
|
points[2].Y = dsty + dstheight;
|
|
|
|
|
|
|
|
return GdipDrawImagePointsRect(graphics, image, points, 3, srcx, srcy,
|
|
|
|
srcwidth, srcheight, srcUnit, imageattr, callback, callbackData);
|
|
|
|
}
|
|
|
|
|
2008-02-29 05:54:47 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImageRectRectI(GpGraphics *graphics, GpImage *image,
|
|
|
|
INT dstx, INT dsty, INT dstwidth, INT dstheight, INT srcx, INT srcy,
|
|
|
|
INT srcwidth, INT srcheight, GpUnit srcUnit,
|
|
|
|
GDIPCONST GpImageAttributes* imageAttributes, DrawImageAbort callback,
|
|
|
|
VOID * callbackData)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
GpPointF points[3];
|
|
|
|
|
2008-09-05 11:14:56 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d, %d, %d, %d, %d, %d, %p, %p, %p)\n",
|
2008-09-02 19:45:39 +00:00
|
|
|
graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy,
|
|
|
|
srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData);
|
2008-02-29 05:54:47 +00:00
|
|
|
|
|
|
|
points[0].X = dstx;
|
|
|
|
points[0].Y = dsty;
|
|
|
|
points[1].X = dstx + dstwidth;
|
|
|
|
points[1].Y = dsty;
|
|
|
|
points[2].X = dstx;
|
|
|
|
points[2].Y = dsty + dstheight;
|
|
|
|
|
|
|
|
return GdipDrawImagePointsRect(graphics, image, points, 3, srcx, srcy,
|
|
|
|
srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData);
|
|
|
|
}
|
|
|
|
|
2008-04-24 21:58:36 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawImageRect(GpGraphics *graphics, GpImage *image,
|
|
|
|
REAL x, REAL y, REAL width, REAL height)
|
|
|
|
{
|
|
|
|
RectF bounds;
|
|
|
|
GpUnit unit;
|
|
|
|
GpStatus ret;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, image, x, y, width, height);
|
|
|
|
|
2008-04-24 21:58:36 +00:00
|
|
|
if(!graphics || !image)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
ret = GdipGetImageBounds(image, &bounds, &unit);
|
|
|
|
if(ret != Ok)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return GdipDrawImageRectRect(graphics, image, x, y, width, height,
|
|
|
|
bounds.X, bounds.Y, bounds.Width, bounds.Height,
|
|
|
|
unit, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawImageRectI(GpGraphics *graphics, GpImage *image,
|
|
|
|
INT x, INT y, INT width, INT height)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d)\n", graphics, image, x, y, width, height);
|
|
|
|
|
2008-04-24 21:58:36 +00:00
|
|
|
return GdipDrawImageRect(graphics, image, (REAL)x, (REAL)y, (REAL)width, (REAL)height);
|
|
|
|
}
|
|
|
|
|
2007-08-02 00:55:58 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawLine(GpGraphics *graphics, GpPen *pen, REAL x1,
|
|
|
|
REAL y1, REAL x2, REAL y2)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpPointF pt[2];
|
|
|
|
GpStatus retval;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x1, y1, x2, y2);
|
|
|
|
|
2007-08-02 00:55:58 +00:00
|
|
|
if(!pen || !graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-02 00:55:58 +00:00
|
|
|
pt[0].X = x1;
|
|
|
|
pt[0].Y = y1;
|
|
|
|
pt[1].X = x2;
|
|
|
|
pt[1].Y = y2;
|
|
|
|
|
|
|
|
save_state = prepare_dc(graphics, pen);
|
|
|
|
|
|
|
|
retval = draw_polyline(graphics, pen, pt, 2, TRUE);
|
|
|
|
|
|
|
|
restore_dc(graphics, save_state);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-06-12 17:44:31 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1,
|
|
|
|
INT y1, INT x2, INT y2)
|
|
|
|
{
|
2007-07-02 22:13:05 +00:00
|
|
|
INT save_state;
|
2007-07-07 20:20:41 +00:00
|
|
|
GpPointF pt[2];
|
2007-07-12 01:07:44 +00:00
|
|
|
GpStatus retval;
|
2007-06-12 17:44:31 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d)\n", graphics, pen, x1, y1, x2, y2);
|
|
|
|
|
2007-06-12 17:44:31 +00:00
|
|
|
if(!pen || !graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-07 20:20:41 +00:00
|
|
|
pt[0].X = (REAL)x1;
|
|
|
|
pt[0].Y = (REAL)y1;
|
|
|
|
pt[1].X = (REAL)x2;
|
|
|
|
pt[1].Y = (REAL)y2;
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
2007-07-02 22:13:05 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
retval = draw_polyline(graphics, pen, pt, 2, TRUE);
|
2007-07-02 22:13:05 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
restore_dc(graphics, save_state);
|
2007-06-12 17:44:31 +00:00
|
|
|
|
2007-07-12 01:07:44 +00:00
|
|
|
return retval;
|
2007-06-12 17:44:31 +00:00
|
|
|
}
|
2007-06-12 17:51:20 +00:00
|
|
|
|
2007-06-21 23:15:13 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawLines(GpGraphics *graphics, GpPen *pen, GDIPCONST
|
|
|
|
GpPointF *points, INT count)
|
|
|
|
{
|
2007-07-12 01:07:16 +00:00
|
|
|
INT save_state;
|
2007-07-12 01:07:44 +00:00
|
|
|
GpStatus retval;
|
2007-06-21 23:15:13 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2007-06-21 23:15:13 +00:00
|
|
|
if(!pen || !graphics || (count < 2))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
2007-06-21 23:15:13 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
retval = draw_polyline(graphics, pen, points, count, TRUE);
|
2007-06-21 23:15:13 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
restore_dc(graphics, save_state);
|
2007-06-21 23:15:13 +00:00
|
|
|
|
2007-07-12 01:07:44 +00:00
|
|
|
return retval;
|
2007-06-21 23:15:13 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 12:58:39 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, GDIPCONST
|
|
|
|
GpPoint *points, INT count)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpStatus retval;
|
|
|
|
GpPointF *ptf = NULL;
|
|
|
|
int i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2008-02-29 12:58:39 +00:00
|
|
|
if(!pen || !graphics || (count < 2))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-02-29 12:58:39 +00:00
|
|
|
ptf = GdipAlloc(count * sizeof(GpPointF));
|
|
|
|
if(!ptf) return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i ++){
|
|
|
|
ptf[i].X = (REAL) points[i].X;
|
|
|
|
ptf[i].Y = (REAL) points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
save_state = prepare_dc(graphics, pen);
|
|
|
|
|
|
|
|
retval = draw_polyline(graphics, pen, ptf, count, TRUE);
|
|
|
|
|
|
|
|
restore_dc(graphics, save_state);
|
|
|
|
|
|
|
|
GdipFree(ptf);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-07-12 01:07:34 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
|
|
|
|
{
|
2007-07-14 00:51:49 +00:00
|
|
|
INT save_state;
|
2007-07-12 01:07:34 +00:00
|
|
|
GpStatus retval;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p)\n", graphics, pen, path);
|
|
|
|
|
2007-07-12 01:07:34 +00:00
|
|
|
if(!pen || !graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
2007-07-12 01:07:34 +00:00
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
retval = draw_poly(graphics, pen, path->pathdata.Points,
|
2007-07-14 00:51:49 +00:00
|
|
|
path->pathdata.Types, path->pathdata.Count, TRUE);
|
2007-07-12 01:07:34 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
restore_dc(graphics, save_state);
|
2007-07-12 01:07:34 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-06-18 23:55:51 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawPie(GpGraphics *graphics, GpPen *pen, REAL x,
|
|
|
|
REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
|
|
|
|
{
|
2007-07-25 00:18:54 +00:00
|
|
|
INT save_state;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y,
|
|
|
|
width, height, startAngle, sweepAngle);
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
if(!graphics || !pen)
|
2007-06-18 23:55:51 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
|
|
|
SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
|
|
|
|
draw_pie(graphics, x, y, width, height, startAngle, sweepAngle);
|
|
|
|
|
|
|
|
restore_dc(graphics, save_state);
|
|
|
|
|
|
|
|
return Ok;
|
2007-06-18 23:55:51 +00:00
|
|
|
}
|
|
|
|
|
2008-04-24 16:48:00 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawPieI(GpGraphics *graphics, GpPen *pen, INT x,
|
|
|
|
INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d, %.2f, %.2f)\n", graphics, pen, x, y,
|
|
|
|
width, height, startAngle, sweepAngle);
|
|
|
|
|
2008-04-24 16:48:00 +00:00
|
|
|
return GdipDrawPie(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle);
|
|
|
|
}
|
|
|
|
|
2008-04-20 17:27:10 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawRectangle(GpGraphics *graphics, GpPen *pen, REAL x,
|
|
|
|
REAL y, REAL width, REAL height)
|
2007-06-12 17:51:20 +00:00
|
|
|
{
|
2007-07-10 03:54:18 +00:00
|
|
|
INT save_state;
|
2007-08-08 01:43:08 +00:00
|
|
|
GpPointF ptf[4];
|
|
|
|
POINT pti[4];
|
2007-06-12 17:51:20 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y, width, height);
|
|
|
|
|
2007-06-12 17:51:20 +00:00
|
|
|
if(!pen || !graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-08 01:43:08 +00:00
|
|
|
ptf[0].X = x;
|
|
|
|
ptf[0].Y = y;
|
|
|
|
ptf[1].X = x + width;
|
|
|
|
ptf[1].Y = y;
|
|
|
|
ptf[2].X = x + width;
|
|
|
|
ptf[2].Y = y + height;
|
|
|
|
ptf[3].X = x;
|
|
|
|
ptf[3].Y = y + height;
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = prepare_dc(graphics, pen);
|
2007-07-10 03:54:18 +00:00
|
|
|
SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
|
2007-06-12 17:51:20 +00:00
|
|
|
|
2007-08-08 01:43:08 +00:00
|
|
|
transform_and_round_points(graphics, pti, ptf, 4);
|
|
|
|
Polygon(graphics->hdc, pti, 4);
|
2007-06-12 17:51:20 +00:00
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
restore_dc(graphics, save_state);
|
2007-06-12 17:51:20 +00:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2007-06-18 23:55:51 +00:00
|
|
|
|
2008-04-20 17:27:10 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x,
|
|
|
|
INT y, INT width, INT height)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d)\n", graphics, pen, x, y, width, height);
|
|
|
|
|
2008-04-20 17:27:10 +00:00
|
|
|
return GdipDrawRectangle(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
|
|
|
|
}
|
|
|
|
|
2007-08-14 01:34:46 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawRectangles(GpGraphics *graphics, GpPen *pen,
|
2007-08-29 19:42:01 +00:00
|
|
|
GDIPCONST GpRectF* rects, INT count)
|
2007-08-14 01:34:46 +00:00
|
|
|
{
|
|
|
|
GpPointF *ptf;
|
|
|
|
POINT *pti;
|
|
|
|
INT save_state, i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, rects, count);
|
|
|
|
|
2007-08-14 01:34:46 +00:00
|
|
|
if(!graphics || !pen || !rects || count < 1)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-14 01:34:46 +00:00
|
|
|
ptf = GdipAlloc(4 * count * sizeof(GpPointF));
|
|
|
|
pti = GdipAlloc(4 * count * sizeof(POINT));
|
|
|
|
|
|
|
|
if(!ptf || !pti){
|
|
|
|
GdipFree(ptf);
|
|
|
|
GdipFree(pti);
|
|
|
|
return OutOfMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
ptf[4 * i + 3].X = ptf[4 * i].X = rects[i].X;
|
|
|
|
ptf[4 * i + 1].Y = ptf[4 * i].Y = rects[i].Y;
|
|
|
|
ptf[4 * i + 2].X = ptf[4 * i + 1].X = rects[i].X + rects[i].Width;
|
|
|
|
ptf[4 * i + 3].Y = ptf[4 * i + 2].Y = rects[i].Y + rects[i].Height;
|
|
|
|
}
|
|
|
|
|
|
|
|
save_state = prepare_dc(graphics, pen);
|
|
|
|
SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptf, 4 * count);
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
Polygon(graphics->hdc, &pti[4 * i], 4);
|
|
|
|
|
|
|
|
restore_dc(graphics, save_state);
|
|
|
|
|
|
|
|
GdipFree(ptf);
|
|
|
|
GdipFree(pti);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-04-24 16:48:08 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawRectanglesI(GpGraphics *graphics, GpPen *pen,
|
|
|
|
GDIPCONST GpRect* rects, INT count)
|
|
|
|
{
|
|
|
|
GpRectF *rectsF;
|
|
|
|
GpStatus ret;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, rects, count);
|
|
|
|
|
2008-04-24 16:48:08 +00:00
|
|
|
if(!rects || count<=0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
rectsF = GdipAlloc(sizeof(GpRectF) * count);
|
|
|
|
if(!rectsF)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0;i < count;i++){
|
|
|
|
rectsF[i].X = (REAL)rects[i].X;
|
|
|
|
rectsF[i].Y = (REAL)rects[i].Y;
|
|
|
|
rectsF[i].Width = (REAL)rects[i].Width;
|
|
|
|
rectsF[i].Height = (REAL)rects[i].Height;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GdipDrawRectangles(graphics, pen, rectsF, count);
|
|
|
|
GdipFree(rectsF);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-08-15 01:58:39 +00:00
|
|
|
GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string,
|
|
|
|
INT length, GDIPCONST GpFont *font, GDIPCONST RectF *rect,
|
|
|
|
GDIPCONST GpStringFormat *format, GDIPCONST GpBrush *brush)
|
|
|
|
{
|
2007-08-15 23:22:13 +00:00
|
|
|
HRGN rgn = NULL;
|
2007-08-15 01:58:39 +00:00
|
|
|
HFONT gdifont;
|
|
|
|
LOGFONTW lfw;
|
|
|
|
TEXTMETRICW textmet;
|
2009-09-04 19:11:52 +00:00
|
|
|
GpPointF pt[3], rectcpy[4];
|
2007-08-15 01:58:39 +00:00
|
|
|
POINT corners[4];
|
|
|
|
WCHAR* stringdup;
|
|
|
|
REAL angle, ang_cos, ang_sin, rel_width, rel_height;
|
2009-06-04 22:51:07 +00:00
|
|
|
INT sum = 0, height = 0, offsety = 0, fit, fitcpy, save_state, i, j, lret, nwidth,
|
2009-07-24 21:24:19 +00:00
|
|
|
nheight, lineend;
|
2007-08-15 01:58:39 +00:00
|
|
|
SIZE size;
|
2009-06-29 21:36:11 +00:00
|
|
|
POINT drawbase;
|
|
|
|
UINT drawflags;
|
2007-08-15 23:22:17 +00:00
|
|
|
RECT drawcoord;
|
2007-08-15 01:58:39 +00:00
|
|
|
|
2009-05-13 18:55:46 +00:00
|
|
|
TRACE("(%p, %s, %i, %p, %s, %p, %p)\n", graphics, debugstr_wn(string, length),
|
|
|
|
length, font, debugstr_rectf(rect), format, brush);
|
|
|
|
|
2007-08-15 01:58:39 +00:00
|
|
|
if(!graphics || !string || !font || !brush || !rect)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2007-08-15 23:22:00 +00:00
|
|
|
if((brush->bt != BrushTypeSolidColor)){
|
2007-08-15 01:58:39 +00:00
|
|
|
FIXME("not implemented for given parameters\n");
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2009-06-04 22:51:07 +00:00
|
|
|
if(format){
|
2007-08-15 23:22:00 +00:00
|
|
|
TRACE("may be ignoring some format flags: attr %x\n", format->attr);
|
|
|
|
|
2009-06-04 22:51:07 +00:00
|
|
|
/* Should be no need to explicitly test for StringAlignmentNear as
|
|
|
|
* that is default behavior if no alignment is passed. */
|
|
|
|
if(format->vertalign != StringAlignmentNear){
|
|
|
|
RectF bounds;
|
|
|
|
GdipMeasureString(graphics, string, length, font, rect, format, &bounds, 0, 0);
|
|
|
|
|
|
|
|
if(format->vertalign == StringAlignmentCenter)
|
|
|
|
offsety = (rect->Height - bounds.Height) / 2;
|
|
|
|
else if(format->vertalign == StringAlignmentFar)
|
|
|
|
offsety = (rect->Height - bounds.Height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-15 02:01:07 +00:00
|
|
|
if(length == -1) length = lstrlenW(string);
|
|
|
|
|
2007-08-15 01:58:39 +00:00
|
|
|
stringdup = GdipAlloc(length * sizeof(WCHAR));
|
|
|
|
if(!stringdup) return OutOfMemory;
|
|
|
|
|
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
SetBkMode(graphics->hdc, TRANSPARENT);
|
|
|
|
SetTextColor(graphics->hdc, brush->lb.lbColor);
|
|
|
|
|
2009-09-04 19:11:52 +00:00
|
|
|
pt[0].X = 0.0;
|
|
|
|
pt[0].Y = 0.0;
|
|
|
|
pt[1].X = 1.0;
|
|
|
|
pt[1].Y = 0.0;
|
|
|
|
pt[2].X = 0.0;
|
|
|
|
pt[2].Y = 1.0;
|
|
|
|
GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, pt, 3);
|
|
|
|
angle = -gdiplus_atan2((pt[1].Y - pt[0].Y), (pt[1].X - pt[0].X));
|
|
|
|
ang_cos = cos(angle);
|
|
|
|
ang_sin = sin(angle);
|
|
|
|
rel_width = sqrt((pt[1].Y-pt[0].Y)*(pt[1].Y-pt[0].Y)+
|
|
|
|
(pt[1].X-pt[0].X)*(pt[1].X-pt[0].X));
|
|
|
|
rel_height = sqrt((pt[2].Y-pt[0].Y)*(pt[2].Y-pt[0].Y)+
|
|
|
|
(pt[2].X-pt[0].X)*(pt[2].X-pt[0].X));
|
|
|
|
|
2007-08-15 01:58:39 +00:00
|
|
|
rectcpy[3].X = rectcpy[0].X = rect->X;
|
2009-06-04 22:51:07 +00:00
|
|
|
rectcpy[1].Y = rectcpy[0].Y = rect->Y + offsety;
|
2007-08-15 01:58:39 +00:00
|
|
|
rectcpy[2].X = rectcpy[1].X = rect->X + rect->Width;
|
2009-06-04 22:51:07 +00:00
|
|
|
rectcpy[3].Y = rectcpy[2].Y = rect->Y + offsety + rect->Height;
|
2007-08-15 01:58:39 +00:00
|
|
|
transform_and_round_points(graphics, corners, rectcpy, 4);
|
|
|
|
|
2009-04-01 19:08:12 +00:00
|
|
|
if (roundr(rect->Width) == 0)
|
|
|
|
nwidth = INT_MAX;
|
|
|
|
else
|
|
|
|
nwidth = roundr(rel_width * rect->Width);
|
|
|
|
|
|
|
|
if (roundr(rect->Height) == 0)
|
|
|
|
nheight = INT_MAX;
|
|
|
|
else
|
2007-08-15 23:22:13 +00:00
|
|
|
nheight = roundr(rel_height * rect->Height);
|
2009-04-01 19:08:12 +00:00
|
|
|
|
|
|
|
if (roundr(rect->Width) != 0 && roundr(rect->Height) != 0)
|
|
|
|
{
|
|
|
|
/* FIXME: If only the width or only the height is 0, we should probably still clip */
|
2007-08-15 23:22:13 +00:00
|
|
|
rgn = CreatePolygonRgn(corners, 4, ALTERNATE);
|
|
|
|
SelectClipRgn(graphics->hdc, rgn);
|
|
|
|
}
|
2007-08-15 01:58:39 +00:00
|
|
|
|
|
|
|
/* Use gdi to find the font, then perform transformations on it (height,
|
|
|
|
* width, angle). */
|
|
|
|
SelectObject(graphics->hdc, CreateFontIndirectW(&font->lfw));
|
|
|
|
GetTextMetricsW(graphics->hdc, &textmet);
|
2008-02-29 22:06:47 +00:00
|
|
|
lfw = font->lfw;
|
2007-08-15 01:58:39 +00:00
|
|
|
|
|
|
|
lfw.lfHeight = roundr(((REAL)lfw.lfHeight) * rel_height);
|
|
|
|
lfw.lfWidth = roundr(textmet.tmAveCharWidth * rel_width);
|
|
|
|
|
2009-07-24 18:56:22 +00:00
|
|
|
lfw.lfEscapement = lfw.lfOrientation = roundr((angle / M_PI) * 1800.0);
|
2007-08-15 01:58:39 +00:00
|
|
|
|
|
|
|
gdifont = CreateFontIndirectW(&lfw);
|
|
|
|
DeleteObject(SelectObject(graphics->hdc, CreateFontIndirectW(&lfw)));
|
|
|
|
|
|
|
|
for(i = 0, j = 0; i < length; i++){
|
|
|
|
if(!isprintW(string[i]) && (string[i] != '\n'))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
stringdup[j] = string[i];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
length = j;
|
|
|
|
|
2009-06-30 14:23:07 +00:00
|
|
|
if (!format || format->align == StringAlignmentNear)
|
2009-06-29 21:36:11 +00:00
|
|
|
{
|
|
|
|
drawbase.x = corners[0].x;
|
|
|
|
drawbase.y = corners[0].y;
|
|
|
|
drawflags = DT_NOCLIP | DT_EXPANDTABS;
|
|
|
|
}
|
|
|
|
else if (format->align == StringAlignmentCenter)
|
|
|
|
{
|
|
|
|
drawbase.x = (corners[0].x + corners[1].x)/2;
|
|
|
|
drawbase.y = (corners[0].y + corners[1].y)/2;
|
|
|
|
drawflags = DT_NOCLIP | DT_EXPANDTABS | DT_CENTER;
|
|
|
|
}
|
|
|
|
else /* (format->align == StringAlignmentFar) */
|
|
|
|
{
|
|
|
|
drawbase.x = corners[1].x;
|
|
|
|
drawbase.y = corners[1].y;
|
|
|
|
drawflags = DT_NOCLIP | DT_EXPANDTABS | DT_RIGHT;
|
|
|
|
}
|
|
|
|
|
2007-08-15 01:58:39 +00:00
|
|
|
while(sum < length){
|
2009-06-29 21:36:11 +00:00
|
|
|
drawcoord.left = drawcoord.right = drawbase.x + roundr(ang_sin * (REAL) height);
|
|
|
|
drawcoord.top = drawcoord.bottom = drawbase.y + roundr(ang_cos * (REAL) height);
|
2007-08-15 23:22:17 +00:00
|
|
|
|
2007-08-15 23:21:56 +00:00
|
|
|
GetTextExtentExPointW(graphics->hdc, stringdup + sum, length - sum,
|
|
|
|
nwidth, &fit, NULL, &size);
|
2007-08-15 01:58:39 +00:00
|
|
|
fitcpy = fit;
|
|
|
|
|
|
|
|
if(fit == 0){
|
2009-06-29 21:36:11 +00:00
|
|
|
DrawTextW(graphics->hdc, stringdup + sum, 1, &drawcoord, drawflags);
|
2007-08-15 01:58:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(lret = 0; lret < fit; lret++)
|
|
|
|
if(*(stringdup + sum + lret) == '\n')
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Line break code (may look strange, but it imitates windows). */
|
|
|
|
if(lret < fit)
|
2009-07-24 21:24:19 +00:00
|
|
|
lineend = fit = lret; /* this is not an off-by-one error */
|
2007-08-15 23:21:56 +00:00
|
|
|
else if(fit < (length - sum)){
|
|
|
|
if(*(stringdup + sum + fit) == ' ')
|
|
|
|
while(*(stringdup + sum + fit) == ' ')
|
|
|
|
fit++;
|
|
|
|
else
|
|
|
|
while(*(stringdup + sum + fit - 1) != ' '){
|
|
|
|
fit--;
|
|
|
|
|
|
|
|
if(*(stringdup + sum + fit) == '\t')
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(fit == 0){
|
|
|
|
fit = fitcpy;
|
|
|
|
break;
|
|
|
|
}
|
2007-08-15 01:58:39 +00:00
|
|
|
}
|
2009-07-24 21:24:19 +00:00
|
|
|
lineend = fit;
|
|
|
|
while(*(stringdup + sum + lineend - 1) == ' ' ||
|
|
|
|
*(stringdup + sum + lineend - 1) == '\t')
|
|
|
|
lineend--;
|
2007-08-15 23:21:56 +00:00
|
|
|
}
|
2009-07-24 21:24:19 +00:00
|
|
|
else
|
|
|
|
lineend = fit;
|
|
|
|
DrawTextW(graphics->hdc, stringdup + sum, min(length - sum, lineend),
|
2009-06-29 21:36:11 +00:00
|
|
|
&drawcoord, drawflags);
|
2007-08-15 01:58:39 +00:00
|
|
|
|
|
|
|
sum += fit + (lret < fitcpy ? 1 : 0);
|
|
|
|
height += size.cy;
|
|
|
|
|
2007-08-15 23:22:13 +00:00
|
|
|
if(height > nheight)
|
2007-08-15 01:58:39 +00:00
|
|
|
break;
|
2007-08-15 23:22:00 +00:00
|
|
|
|
|
|
|
/* Stop if this was a linewrap (but not if it was a linebreak). */
|
|
|
|
if((lret == fitcpy) && format && (format->attr & StringFormatFlagsNoWrap))
|
|
|
|
break;
|
2007-08-15 01:58:39 +00:00
|
|
|
}
|
|
|
|
|
2007-09-25 19:52:58 +00:00
|
|
|
GdipFree(stringdup);
|
2007-08-15 01:58:39 +00:00
|
|
|
DeleteObject(rgn);
|
|
|
|
DeleteObject(gdifont);
|
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-08-21 22:16:49 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillClosedCurve2(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
GDIPCONST GpPointF *points, INT count, REAL tension, GpFillMode fill)
|
|
|
|
{
|
|
|
|
GpPath *path;
|
|
|
|
GpStatus stat;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %.2f, %d)\n", graphics, brush, points,
|
|
|
|
count, tension, fill);
|
|
|
|
|
2008-08-21 22:16:49 +00:00
|
|
|
if(!graphics || !brush || !points)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-08-21 22:16:49 +00:00
|
|
|
stat = GdipCreatePath(fill, &path);
|
|
|
|
if(stat != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
stat = GdipAddPathClosedCurve2(path, points, count, tension);
|
|
|
|
if(stat != Ok){
|
|
|
|
GdipDeletePath(path);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
stat = GdipFillPath(graphics, brush, path);
|
|
|
|
if(stat != Ok){
|
|
|
|
GdipDeletePath(path);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipDeletePath(path);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipFillClosedCurve2I(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
GDIPCONST GpPoint *points, INT count, REAL tension, GpFillMode fill)
|
|
|
|
{
|
|
|
|
GpPointF *ptf;
|
|
|
|
GpStatus stat;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %.2f, %d)\n", graphics, brush, points,
|
|
|
|
count, tension, fill);
|
|
|
|
|
2008-08-21 22:16:49 +00:00
|
|
|
if(!points || count <= 0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
ptf = GdipAlloc(sizeof(GpPointF)*count);
|
|
|
|
if(!ptf)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0;i < count;i++){
|
|
|
|
ptf[i].X = (REAL)points[i].X;
|
|
|
|
ptf[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
stat = GdipFillClosedCurve2(graphics, brush, ptf, count, tension, fill);
|
|
|
|
|
|
|
|
GdipFree(ptf);
|
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2008-04-28 20:10:10 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x,
|
|
|
|
REAL y, REAL width, REAL height)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpPointF ptf[2];
|
|
|
|
POINT pti[2];
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, brush, x, y, width, height);
|
|
|
|
|
2008-04-28 20:10:10 +00:00
|
|
|
if(!graphics || !brush)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-04-28 20:10:10 +00:00
|
|
|
ptf[0].X = x;
|
|
|
|
ptf[0].Y = y;
|
|
|
|
ptf[1].X = x + width;
|
|
|
|
ptf[1].Y = y + height;
|
|
|
|
|
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptf, 2);
|
|
|
|
|
2009-07-11 15:29:44 +00:00
|
|
|
BeginPath(graphics->hdc);
|
2008-04-28 20:10:10 +00:00
|
|
|
Ellipse(graphics->hdc, pti[0].x, pti[0].y, pti[1].x, pti[1].y);
|
2009-07-11 15:29:44 +00:00
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
brush_fill_path(graphics, brush);
|
2008-04-28 20:10:10 +00:00
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x,
|
|
|
|
INT y, INT width, INT height)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d)\n", graphics, brush, x, y, width, height);
|
|
|
|
|
2008-04-28 20:10:10 +00:00
|
|
|
return GdipFillEllipse(graphics,brush,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
|
|
|
|
}
|
|
|
|
|
2007-07-14 03:19:46 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpStatus retval;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p)\n", graphics, brush, path);
|
|
|
|
|
2007-07-14 03:19:46 +00:00
|
|
|
if(!brush || !graphics || !path)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 03:19:46 +00:00
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
|
|
|
|
: WINDING));
|
|
|
|
|
|
|
|
BeginPath(graphics->hdc);
|
2007-07-24 03:24:53 +00:00
|
|
|
retval = draw_poly(graphics, NULL, path->pathdata.Points,
|
2007-07-14 03:19:46 +00:00
|
|
|
path->pathdata.Types, path->pathdata.Count, FALSE);
|
|
|
|
|
|
|
|
if(retval != Ok)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
EndPath(graphics->hdc);
|
2009-03-16 17:51:04 +00:00
|
|
|
brush_fill_path(graphics, brush);
|
2007-07-14 03:19:46 +00:00
|
|
|
|
|
|
|
retval = Ok;
|
|
|
|
|
|
|
|
end:
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-06-18 23:55:51 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x,
|
|
|
|
REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
|
|
|
|
{
|
2007-07-25 00:18:54 +00:00
|
|
|
INT save_state;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n",
|
|
|
|
graphics, brush, x, y, width, height, startAngle, sweepAngle);
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
if(!graphics || !brush)
|
2007-06-18 23:55:51 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-25 00:18:54 +00:00
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
2009-07-11 15:32:34 +00:00
|
|
|
BeginPath(graphics->hdc);
|
2007-07-25 00:18:54 +00:00
|
|
|
draw_pie(graphics, x, y, width, height, startAngle, sweepAngle);
|
2009-07-11 15:32:34 +00:00
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
brush_fill_path(graphics, brush);
|
2007-07-25 00:18:54 +00:00
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
return Ok;
|
2007-06-18 23:55:51 +00:00
|
|
|
}
|
2007-07-14 00:51:13 +00:00
|
|
|
|
2008-04-24 16:48:23 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillPieI(GpGraphics *graphics, GpBrush *brush, INT x,
|
|
|
|
INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d, %.2f, %.2f)\n",
|
|
|
|
graphics, brush, x, y, width, height, startAngle, sweepAngle);
|
|
|
|
|
2008-04-24 16:48:23 +00:00
|
|
|
return GdipFillPie(graphics,brush,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle);
|
|
|
|
}
|
|
|
|
|
2007-08-02 00:55:50 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillPolygon(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
GDIPCONST GpPointF *points, INT count, GpFillMode fillMode)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpPointF *ptf = NULL;
|
|
|
|
POINT *pti = NULL;
|
|
|
|
GpStatus retval = Ok;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %d)\n", graphics, brush, points, count, fillMode);
|
|
|
|
|
2007-08-02 00:55:50 +00:00
|
|
|
if(!graphics || !brush || !points || !count)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-02 00:55:50 +00:00
|
|
|
ptf = GdipAlloc(count * sizeof(GpPointF));
|
|
|
|
pti = GdipAlloc(count * sizeof(POINT));
|
|
|
|
if(!ptf || !pti){
|
|
|
|
retval = OutOfMemory;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(ptf, points, count * sizeof(GpPointF));
|
|
|
|
|
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
SetPolyFillMode(graphics->hdc, (fillMode == FillModeAlternate ? ALTERNATE
|
|
|
|
: WINDING));
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptf, count);
|
2009-07-11 15:35:40 +00:00
|
|
|
|
|
|
|
BeginPath(graphics->hdc);
|
2007-08-02 00:55:50 +00:00
|
|
|
Polygon(graphics->hdc, pti, count);
|
2009-07-11 15:35:40 +00:00
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
brush_fill_path(graphics, brush);
|
2007-08-02 00:55:50 +00:00
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
end:
|
|
|
|
GdipFree(ptf);
|
|
|
|
GdipFree(pti);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:24:35 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillPolygonI(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
GDIPCONST GpPoint *points, INT count, GpFillMode fillMode)
|
|
|
|
{
|
2007-07-24 03:24:53 +00:00
|
|
|
INT save_state, i;
|
|
|
|
GpPointF *ptf = NULL;
|
|
|
|
POINT *pti = NULL;
|
|
|
|
GpStatus retval = Ok;
|
2007-07-24 03:24:35 +00:00
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d, %d)\n", graphics, brush, points, count, fillMode);
|
|
|
|
|
2007-07-24 03:24:35 +00:00
|
|
|
if(!graphics || !brush || !points || !count)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-24 03:24:53 +00:00
|
|
|
ptf = GdipAlloc(count * sizeof(GpPointF));
|
|
|
|
pti = GdipAlloc(count * sizeof(POINT));
|
|
|
|
if(!ptf || !pti){
|
|
|
|
retval = OutOfMemory;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < count; i ++){
|
|
|
|
ptf[i].X = (REAL) points[i].X;
|
|
|
|
ptf[i].Y = (REAL) points[i].Y;
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:24:35 +00:00
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
SetPolyFillMode(graphics->hdc, (fillMode == FillModeAlternate ? ALTERNATE
|
|
|
|
: WINDING));
|
2007-07-24 03:24:53 +00:00
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptf, count);
|
2009-07-11 15:37:22 +00:00
|
|
|
|
|
|
|
BeginPath(graphics->hdc);
|
2007-07-24 03:24:53 +00:00
|
|
|
Polygon(graphics->hdc, pti, count);
|
2009-07-11 15:37:22 +00:00
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
brush_fill_path(graphics, brush);
|
2007-07-24 03:24:35 +00:00
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
2007-07-24 03:24:53 +00:00
|
|
|
|
|
|
|
end:
|
|
|
|
GdipFree(ptf);
|
|
|
|
GdipFree(pti);
|
|
|
|
|
|
|
|
return retval;
|
2007-07-24 03:24:35 +00:00
|
|
|
}
|
|
|
|
|
2008-08-03 08:19:36 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillPolygon2(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
GDIPCONST GpPointF *points, INT count)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, brush, points, count);
|
|
|
|
|
2008-08-03 08:19:36 +00:00
|
|
|
return GdipFillPolygon(graphics, brush, points, count, FillModeAlternate);
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipFillPolygon2I(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
GDIPCONST GpPoint *points, INT count)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, brush, points, count);
|
|
|
|
|
2008-08-03 08:19:36 +00:00
|
|
|
return GdipFillPolygonI(graphics, brush, points, count, FillModeAlternate);
|
|
|
|
}
|
|
|
|
|
2007-08-09 02:42:10 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
REAL x, REAL y, REAL width, REAL height)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpPointF ptf[4];
|
|
|
|
POINT pti[4];
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, brush, x, y, width, height);
|
|
|
|
|
2007-08-09 02:42:10 +00:00
|
|
|
if(!graphics || !brush)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-09 02:42:10 +00:00
|
|
|
ptf[0].X = x;
|
|
|
|
ptf[0].Y = y;
|
|
|
|
ptf[1].X = x + width;
|
|
|
|
ptf[1].Y = y;
|
|
|
|
ptf[2].X = x + width;
|
|
|
|
ptf[2].Y = y + height;
|
|
|
|
ptf[3].X = x;
|
|
|
|
ptf[3].Y = y + height;
|
|
|
|
|
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptf, 4);
|
|
|
|
|
2009-05-06 21:34:19 +00:00
|
|
|
BeginPath(graphics->hdc);
|
2007-08-09 02:42:10 +00:00
|
|
|
Polygon(graphics->hdc, pti, 4);
|
2009-05-06 21:34:19 +00:00
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
brush_fill_path(graphics, brush);
|
2007-08-09 02:42:10 +00:00
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-08 01:43:04 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush,
|
|
|
|
INT x, INT y, INT width, INT height)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
GpPointF ptf[4];
|
|
|
|
POINT pti[4];
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d, %d, %d, %d)\n", graphics, brush, x, y, width, height);
|
|
|
|
|
2007-08-08 01:43:04 +00:00
|
|
|
if(!graphics || !brush)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-08 01:43:04 +00:00
|
|
|
ptf[0].X = x;
|
|
|
|
ptf[0].Y = y;
|
|
|
|
ptf[1].X = x + width;
|
|
|
|
ptf[1].Y = y;
|
|
|
|
ptf[2].X = x + width;
|
|
|
|
ptf[2].Y = y + height;
|
|
|
|
ptf[3].X = x;
|
|
|
|
ptf[3].Y = y + height;
|
|
|
|
|
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, ptf, 4);
|
|
|
|
|
2009-07-11 15:38:47 +00:00
|
|
|
BeginPath(graphics->hdc);
|
2007-08-08 01:43:04 +00:00
|
|
|
Polygon(graphics->hdc, pti, 4);
|
2009-07-11 15:38:47 +00:00
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
brush_fill_path(graphics, brush);
|
2007-08-08 01:43:04 +00:00
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-04-28 20:10:15 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillRectangles(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRectF *rects,
|
|
|
|
INT count)
|
|
|
|
{
|
|
|
|
GpStatus ret;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, brush, rects, count);
|
|
|
|
|
2008-04-28 20:10:15 +00:00
|
|
|
if(!rects)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
ret = GdipFillRectangle(graphics, brush, rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
|
|
|
|
if(ret != Ok) return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipFillRectanglesI(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRect *rects,
|
|
|
|
INT count)
|
|
|
|
{
|
|
|
|
GpRectF *rectsF;
|
|
|
|
GpStatus ret;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, brush, rects, count);
|
|
|
|
|
2008-04-28 20:10:15 +00:00
|
|
|
if(!rects || count <= 0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
rectsF = GdipAlloc(sizeof(GpRectF)*count);
|
|
|
|
if(!rectsF)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
rectsF[i].X = (REAL)rects[i].X;
|
|
|
|
rectsF[i].Y = (REAL)rects[i].Y;
|
|
|
|
rectsF[i].X = (REAL)rects[i].Width;
|
|
|
|
rectsF[i].Height = (REAL)rects[i].Height;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GdipFillRectangles(graphics,brush,rectsF,count);
|
|
|
|
GdipFree(rectsF);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-02-03 19:17:47 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipFillRegion [GDIPLUS.@]
|
|
|
|
*/
|
2008-07-10 19:15:59 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFillRegion(GpGraphics* graphics, GpBrush* brush,
|
|
|
|
GpRegion* region)
|
|
|
|
{
|
2009-02-03 19:17:47 +00:00
|
|
|
INT save_state;
|
|
|
|
GpStatus status;
|
|
|
|
HRGN hrgn;
|
2009-07-11 15:57:07 +00:00
|
|
|
RECT rc;
|
2009-02-03 19:17:47 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", graphics, brush, region);
|
|
|
|
|
2008-07-10 19:15:59 +00:00
|
|
|
if (!(graphics && brush && region))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-02-03 19:17:47 +00:00
|
|
|
status = GdipGetRegionHRgn(region, graphics, &hrgn);
|
|
|
|
if(status != Ok)
|
|
|
|
return status;
|
2008-07-10 19:15:59 +00:00
|
|
|
|
2009-02-03 19:17:47 +00:00
|
|
|
save_state = SaveDC(graphics->hdc);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
2009-07-11 15:57:07 +00:00
|
|
|
ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND);
|
|
|
|
|
|
|
|
if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
|
|
|
|
{
|
|
|
|
BeginPath(graphics->hdc);
|
|
|
|
Rectangle(graphics->hdc, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
EndPath(graphics->hdc);
|
|
|
|
|
|
|
|
brush_fill_path(graphics, brush);
|
|
|
|
}
|
2009-02-03 19:17:47 +00:00
|
|
|
|
|
|
|
RestoreDC(graphics->hdc, save_state);
|
|
|
|
|
|
|
|
DeleteObject(hrgn);
|
|
|
|
|
|
|
|
return Ok;
|
2008-07-10 19:15:59 +00:00
|
|
|
}
|
|
|
|
|
2008-06-18 07:33:10 +00:00
|
|
|
GpStatus WINGDIPAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 22:04:20 +00:00
|
|
|
TRACE("(%p,%u)\n", graphics, intention);
|
|
|
|
|
2008-06-18 07:33:10 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-06-18 07:33:10 +00:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:58:27 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetClipBounds [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipGetClipBounds(GpGraphics *graphics, GpRectF *rect)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", graphics, rect);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-02-02 20:48:01 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-02-02 19:58:27 +00:00
|
|
|
return GdipGetRegionBounds(graphics->clip, graphics, rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetClipBoundsI [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipGetClipBoundsI(GpGraphics *graphics, GpRect *rect)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", graphics, rect);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-02-02 20:48:01 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-02-02 19:58:27 +00:00
|
|
|
return GdipGetRegionBoundsI(graphics->clip, graphics, rect);
|
|
|
|
}
|
|
|
|
|
2007-08-14 01:34:27 +00:00
|
|
|
/* FIXME: Compositing mode is not used anywhere except the getter/setter. */
|
|
|
|
GpStatus WINGDIPAPI GdipGetCompositingMode(GpGraphics *graphics,
|
|
|
|
CompositingMode *mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, mode);
|
|
|
|
|
2007-08-14 01:34:27 +00:00
|
|
|
if(!graphics || !mode)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-14 01:34:27 +00:00
|
|
|
*mode = graphics->compmode;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:25 +00:00
|
|
|
/* FIXME: Compositing quality is not used anywhere except the getter/setter. */
|
|
|
|
GpStatus WINGDIPAPI GdipGetCompositingQuality(GpGraphics *graphics,
|
|
|
|
CompositingQuality *quality)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, quality);
|
|
|
|
|
2007-07-14 00:51:25 +00:00
|
|
|
if(!graphics || !quality)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:25 +00:00
|
|
|
*quality = graphics->compqual;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:29 +00:00
|
|
|
/* FIXME: Interpolation mode is not used anywhere except the getter/setter. */
|
|
|
|
GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics *graphics,
|
|
|
|
InterpolationMode *mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, mode);
|
|
|
|
|
2007-07-14 00:51:29 +00:00
|
|
|
if(!graphics || !mode)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:29 +00:00
|
|
|
*mode = graphics->interpolation;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-12-11 07:32:43 +00:00
|
|
|
GpStatus WINGDIPAPI GdipGetNearestColor(GpGraphics *graphics, ARGB* argb)
|
|
|
|
{
|
2009-12-18 22:04:20 +00:00
|
|
|
FIXME("(%p, %p): stub\n", graphics, argb);
|
|
|
|
|
2008-12-11 07:32:43 +00:00
|
|
|
if(!graphics || !argb)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:18:39 +00:00
|
|
|
GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics *graphics, REAL *scale)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, scale);
|
|
|
|
|
2007-07-25 00:18:39 +00:00
|
|
|
if(!graphics || !scale)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-25 00:18:39 +00:00
|
|
|
*scale = graphics->scale;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:24:41 +00:00
|
|
|
GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics *graphics, GpUnit *unit)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, unit);
|
|
|
|
|
2007-07-24 03:24:41 +00:00
|
|
|
if(!graphics || !unit)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-24 03:24:41 +00:00
|
|
|
*unit = graphics->unit;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:33 +00:00
|
|
|
/* FIXME: Pixel offset mode is not used anywhere except the getter/setter. */
|
|
|
|
GpStatus WINGDIPAPI GdipGetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode
|
|
|
|
*mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, mode);
|
|
|
|
|
2007-07-14 00:51:33 +00:00
|
|
|
if(!graphics || !mode)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:33 +00:00
|
|
|
*mode = graphics->pixeloffset;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:13 +00:00
|
|
|
/* FIXME: Smoothing mode is not used anywhere except the getter/setter. */
|
|
|
|
GpStatus WINGDIPAPI GdipGetSmoothingMode(GpGraphics *graphics, SmoothingMode *mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, mode);
|
|
|
|
|
2007-07-14 00:51:13 +00:00
|
|
|
if(!graphics || !mode)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:13 +00:00
|
|
|
*mode = graphics->smoothing;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-11-09 11:32:26 +00:00
|
|
|
GpStatus WINGDIPAPI GdipGetTextContrast(GpGraphics *graphics, UINT *contrast)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", graphics, contrast);
|
|
|
|
|
|
|
|
if(!graphics || !contrast)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
*contrast = graphics->textcontrast;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-15 02:00:09 +00:00
|
|
|
/* FIXME: Text rendering hint is not used anywhere except the getter/setter. */
|
|
|
|
GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics *graphics,
|
|
|
|
TextRenderingHint *hint)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, hint);
|
|
|
|
|
2007-08-15 02:00:09 +00:00
|
|
|
if(!graphics || !hint)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-15 02:00:09 +00:00
|
|
|
*hint = graphics->texthint;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-08-12 20:37:09 +00:00
|
|
|
GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics *graphics, GpRectF *rect)
|
|
|
|
{
|
|
|
|
GpRegion *clip_rgn;
|
|
|
|
GpStatus stat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", graphics, rect);
|
|
|
|
|
|
|
|
if(!graphics || !rect)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
/* intersect window and graphics clipping regions */
|
|
|
|
if((stat = GdipCreateRegion(&clip_rgn)) != Ok)
|
|
|
|
return stat;
|
|
|
|
|
2009-08-26 23:03:08 +00:00
|
|
|
if((stat = get_visible_clip_region(graphics, clip_rgn)) != Ok)
|
2009-08-12 20:37:09 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* get bounds of the region */
|
|
|
|
stat = GdipGetRegionBounds(clip_rgn, graphics, rect);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
GdipDeleteRegion(clip_rgn);
|
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics *graphics, GpRect *rect)
|
|
|
|
{
|
|
|
|
GpRectF rectf;
|
|
|
|
GpStatus stat;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", graphics, rect);
|
|
|
|
|
|
|
|
if(!graphics || !rect)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if((stat = GdipGetVisibleClipBounds(graphics, &rectf)) == Ok)
|
|
|
|
{
|
|
|
|
rect->X = roundr(rectf.X);
|
|
|
|
rect->Y = roundr(rectf.Y);
|
|
|
|
rect->Width = roundr(rectf.Width);
|
|
|
|
rect->Height = roundr(rectf.Height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:18:47 +00:00
|
|
|
GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, matrix);
|
|
|
|
|
2007-07-25 00:18:47 +00:00
|
|
|
if(!graphics || !matrix)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-02-29 22:06:47 +00:00
|
|
|
*matrix = *graphics->worldtrans;
|
2007-07-25 00:18:47 +00:00
|
|
|
return Ok;
|
2007-08-15 23:21:52 +00:00
|
|
|
}
|
|
|
|
|
2008-09-05 09:56:10 +00:00
|
|
|
GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color)
|
|
|
|
{
|
|
|
|
GpSolidFill *brush;
|
|
|
|
GpStatus stat;
|
2009-08-12 20:36:54 +00:00
|
|
|
GpRectF wnd_rect;
|
2008-09-05 09:56:10 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %x)\n", graphics, color);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
if((stat = GdipCreateSolidFill(color, &brush)) != Ok)
|
|
|
|
return stat;
|
|
|
|
|
2009-08-12 20:36:54 +00:00
|
|
|
if((stat = get_graphics_bounds(graphics, &wnd_rect)) != Ok){
|
|
|
|
GdipDeleteBrush((GpBrush*)brush);
|
|
|
|
return stat;
|
2008-09-05 09:56:10 +00:00
|
|
|
}
|
2009-08-12 20:36:54 +00:00
|
|
|
|
|
|
|
GdipFillRectangle(graphics, (GpBrush*)brush, wnd_rect.X, wnd_rect.Y,
|
|
|
|
wnd_rect.Width, wnd_rect.Height);
|
2008-09-05 09:56:10 +00:00
|
|
|
|
|
|
|
GdipDeleteBrush((GpBrush*)brush);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-08-28 13:49:41 +00:00
|
|
|
GpStatus WINGDIPAPI GdipIsClipEmpty(GpGraphics *graphics, BOOL *res)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, res);
|
|
|
|
|
2008-08-28 13:49:41 +00:00
|
|
|
if(!graphics || !res)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
return GdipIsEmptyRegion(graphics->clip, graphics, res);
|
|
|
|
}
|
|
|
|
|
2008-09-26 18:34:39 +00:00
|
|
|
GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics *graphics, REAL x, REAL y, BOOL *result)
|
|
|
|
{
|
2009-08-26 23:03:11 +00:00
|
|
|
GpStatus stat;
|
|
|
|
GpRegion* rgn;
|
|
|
|
GpPointF pt;
|
|
|
|
|
|
|
|
TRACE("(%p, %.2f, %.2f, %p)\n", graphics, x, y, result);
|
2008-09-26 18:34:39 +00:00
|
|
|
|
|
|
|
if(!graphics || !result)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-08-26 23:03:11 +00:00
|
|
|
pt.X = x;
|
|
|
|
pt.Y = y;
|
|
|
|
if((stat = GdipTransformPoints(graphics, CoordinateSpaceDevice,
|
|
|
|
CoordinateSpaceWorld, &pt, 1)) != Ok)
|
|
|
|
return stat;
|
2008-09-26 18:34:39 +00:00
|
|
|
|
2009-08-26 23:03:11 +00:00
|
|
|
if((stat = GdipCreateRegion(&rgn)) != Ok)
|
|
|
|
return stat;
|
2008-09-26 18:34:39 +00:00
|
|
|
|
2009-08-26 23:03:11 +00:00
|
|
|
if((stat = get_visible_clip_region(graphics, rgn)) != Ok)
|
|
|
|
goto cleanup;
|
2008-09-26 18:34:39 +00:00
|
|
|
|
2009-08-26 23:03:11 +00:00
|
|
|
stat = GdipIsVisibleRegionPoint(rgn, pt.X, pt.Y, graphics, result);
|
2008-09-26 18:34:39 +00:00
|
|
|
|
2009-08-26 23:03:11 +00:00
|
|
|
cleanup:
|
|
|
|
GdipDeleteRegion(rgn);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics *graphics, INT x, INT y, BOOL *result)
|
|
|
|
{
|
|
|
|
return GdipIsVisiblePoint(graphics, (REAL)x, (REAL)y, result);
|
2008-09-26 18:34:39 +00:00
|
|
|
}
|
|
|
|
|
2009-08-26 23:03:13 +00:00
|
|
|
GpStatus WINGDIPAPI GdipIsVisibleRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, BOOL *result)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpRegion* rgn;
|
|
|
|
GpPointF pts[2];
|
|
|
|
|
|
|
|
TRACE("(%p %.2f %.2f %.2f %.2f %p)\n", graphics, x, y, width, height, result);
|
|
|
|
|
|
|
|
if(!graphics || !result)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
pts[0].X = x;
|
|
|
|
pts[0].Y = y;
|
|
|
|
pts[1].X = x + width;
|
|
|
|
pts[1].Y = y + height;
|
|
|
|
|
|
|
|
if((stat = GdipTransformPoints(graphics, CoordinateSpaceDevice,
|
|
|
|
CoordinateSpaceWorld, pts, 2)) != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
pts[1].X -= pts[0].X;
|
|
|
|
pts[1].Y -= pts[0].Y;
|
|
|
|
|
|
|
|
if((stat = GdipCreateRegion(&rgn)) != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
if((stat = get_visible_clip_region(graphics, rgn)) != Ok)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
stat = GdipIsVisibleRegionRect(rgn, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y, graphics, result);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
GdipDeleteRegion(rgn);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipIsVisibleRectI(GpGraphics *graphics, INT x, INT y, INT width, INT height, BOOL *result)
|
|
|
|
{
|
|
|
|
return GdipIsVisibleRect(graphics, (REAL)x, (REAL)y, (REAL)width, (REAL)height, result);
|
|
|
|
}
|
|
|
|
|
2008-07-09 07:33:40 +00:00
|
|
|
GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
|
|
|
|
GDIPCONST WCHAR* string, INT length, GDIPCONST GpFont* font,
|
|
|
|
GDIPCONST RectF* layoutRect, GDIPCONST GpStringFormat *stringFormat,
|
|
|
|
INT regionCount, GpRegion** regions)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p %s %d %p %p %p %d %p\n", graphics, debugstr_w(string),
|
|
|
|
length, font, layoutRect, stringFormat, regionCount, regions);
|
|
|
|
|
2009-12-18 22:04:20 +00:00
|
|
|
if (!(graphics && string && font && layoutRect && stringFormat && regions))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-07-09 07:33:40 +00:00
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-08-15 23:22:09 +00:00
|
|
|
/* Find the smallest rectangle that bounds the text when it is printed in rect
|
|
|
|
* according to the format options listed in format. If rect has 0 width and
|
|
|
|
* height, then just find the smallest rectangle that bounds the text when it's
|
|
|
|
* printed at location (rect->X, rect-Y). */
|
2007-08-15 23:21:52 +00:00
|
|
|
GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
|
|
|
|
GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
|
|
|
|
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, RectF *bounds,
|
|
|
|
INT *codepointsfitted, INT *linesfilled)
|
|
|
|
{
|
|
|
|
HFONT oldfont;
|
|
|
|
WCHAR* stringdup;
|
2007-08-15 23:22:09 +00:00
|
|
|
INT sum = 0, height = 0, fit, fitcpy, max_width = 0, i, j, lret, nwidth,
|
2009-07-24 21:24:19 +00:00
|
|
|
nheight, lineend;
|
2007-08-15 23:21:52 +00:00
|
|
|
SIZE size;
|
|
|
|
|
2009-05-13 19:30:00 +00:00
|
|
|
TRACE("(%p, %s, %i, %p, %s, %p, %p, %p, %p)\n", graphics,
|
|
|
|
debugstr_wn(string, length), length, font, debugstr_rectf(rect), format,
|
|
|
|
bounds, codepointsfitted, linesfilled);
|
|
|
|
|
2007-08-15 23:21:52 +00:00
|
|
|
if(!graphics || !string || !font || !rect)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-11-24 09:22:26 +00:00
|
|
|
if(linesfilled) *linesfilled = 0;
|
|
|
|
if(codepointsfitted) *codepointsfitted = 0;
|
2007-08-15 23:21:52 +00:00
|
|
|
|
2007-08-15 23:22:04 +00:00
|
|
|
if(format)
|
|
|
|
TRACE("may be ignoring some format flags: attr %x\n", format->attr);
|
|
|
|
|
2007-08-15 23:21:52 +00:00
|
|
|
if(length == -1) length = lstrlenW(string);
|
|
|
|
|
2008-09-25 09:19:23 +00:00
|
|
|
stringdup = GdipAlloc((length + 1) * sizeof(WCHAR));
|
2007-08-15 23:21:52 +00:00
|
|
|
if(!stringdup) return OutOfMemory;
|
|
|
|
|
|
|
|
oldfont = SelectObject(graphics->hdc, CreateFontIndirectW(&font->lfw));
|
|
|
|
nwidth = roundr(rect->Width);
|
2007-08-15 23:22:09 +00:00
|
|
|
nheight = roundr(rect->Height);
|
|
|
|
|
|
|
|
if((nwidth == 0) && (nheight == 0))
|
|
|
|
nwidth = nheight = INT_MAX;
|
2007-08-15 23:21:52 +00:00
|
|
|
|
|
|
|
for(i = 0, j = 0; i < length; i++){
|
|
|
|
if(!isprintW(string[i]) && (string[i] != '\n'))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
stringdup[j] = string[i];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
stringdup[j] = 0;
|
|
|
|
length = j;
|
|
|
|
|
|
|
|
while(sum < length){
|
|
|
|
GetTextExtentExPointW(graphics->hdc, stringdup + sum, length - sum,
|
|
|
|
nwidth, &fit, NULL, &size);
|
|
|
|
fitcpy = fit;
|
|
|
|
|
|
|
|
if(fit == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
for(lret = 0; lret < fit; lret++)
|
|
|
|
if(*(stringdup + sum + lret) == '\n')
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Line break code (may look strange, but it imitates windows). */
|
|
|
|
if(lret < fit)
|
2009-07-24 21:24:19 +00:00
|
|
|
lineend = fit = lret; /* this is not an off-by-one error */
|
2007-08-15 23:21:52 +00:00
|
|
|
else if(fit < (length - sum)){
|
|
|
|
if(*(stringdup + sum + fit) == ' ')
|
|
|
|
while(*(stringdup + sum + fit) == ' ')
|
|
|
|
fit++;
|
|
|
|
else
|
|
|
|
while(*(stringdup + sum + fit - 1) != ' '){
|
|
|
|
fit--;
|
|
|
|
|
|
|
|
if(*(stringdup + sum + fit) == '\t')
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(fit == 0){
|
|
|
|
fit = fitcpy;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 21:24:19 +00:00
|
|
|
lineend = fit;
|
|
|
|
while(*(stringdup + sum + lineend - 1) == ' ' ||
|
|
|
|
*(stringdup + sum + lineend - 1) == '\t')
|
|
|
|
lineend--;
|
2007-08-15 23:21:52 +00:00
|
|
|
}
|
2009-07-24 21:24:19 +00:00
|
|
|
else
|
|
|
|
lineend = fit;
|
2007-08-15 23:21:52 +00:00
|
|
|
|
2009-07-24 21:24:19 +00:00
|
|
|
GetTextExtentExPointW(graphics->hdc, stringdup + sum, lineend,
|
2007-08-15 23:21:52 +00:00
|
|
|
nwidth, &j, NULL, &size);
|
|
|
|
|
|
|
|
sum += fit + (lret < fitcpy ? 1 : 0);
|
2008-11-24 09:22:26 +00:00
|
|
|
if(codepointsfitted) *codepointsfitted = sum;
|
|
|
|
|
2007-08-15 23:21:52 +00:00
|
|
|
height += size.cy;
|
2008-11-24 09:22:26 +00:00
|
|
|
if(linesfilled) *linesfilled += size.cy;
|
2007-08-15 23:21:52 +00:00
|
|
|
max_width = max(max_width, size.cx);
|
|
|
|
|
2007-08-15 23:22:09 +00:00
|
|
|
if(height > nheight)
|
2007-08-15 23:21:52 +00:00
|
|
|
break;
|
2007-08-15 23:22:04 +00:00
|
|
|
|
|
|
|
/* Stop if this was a linewrap (but not if it was a linebreak). */
|
|
|
|
if((lret == fitcpy) && format && (format->attr & StringFormatFlagsNoWrap))
|
|
|
|
break;
|
2007-08-15 23:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bounds->X = rect->X;
|
|
|
|
bounds->Y = rect->Y;
|
|
|
|
bounds->Width = (REAL)max_width;
|
2007-08-15 23:22:09 +00:00
|
|
|
bounds->Height = (REAL) min(height, nheight);
|
2007-08-15 23:21:52 +00:00
|
|
|
|
2007-09-25 19:52:58 +00:00
|
|
|
GdipFree(stringdup);
|
2007-08-15 23:21:52 +00:00
|
|
|
DeleteObject(SelectObject(graphics->hdc, oldfont));
|
|
|
|
|
|
|
|
return Ok;
|
2007-07-25 00:18:47 +00:00
|
|
|
}
|
|
|
|
|
2008-08-28 13:34:22 +00:00
|
|
|
GpStatus WINGDIPAPI GdipResetClip(GpGraphics *graphics)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p)\n", graphics);
|
|
|
|
|
2008-08-28 13:34:22 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
return GdipSetInfinite(graphics->clip);
|
|
|
|
}
|
|
|
|
|
2008-08-06 14:36:16 +00:00
|
|
|
GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p)\n", graphics);
|
|
|
|
|
2008-08-06 14:36:16 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-08-06 14:36:16 +00:00
|
|
|
graphics->worldtrans->matrix[0] = 1.0;
|
|
|
|
graphics->worldtrans->matrix[1] = 0.0;
|
|
|
|
graphics->worldtrans->matrix[2] = 0.0;
|
|
|
|
graphics->worldtrans->matrix[3] = 1.0;
|
|
|
|
graphics->worldtrans->matrix[4] = 0.0;
|
|
|
|
graphics->worldtrans->matrix[5] = 0.0;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:37 +00:00
|
|
|
GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
|
|
|
|
{
|
2009-07-08 03:30:49 +00:00
|
|
|
return GdipEndContainer(graphics, state);
|
2007-07-14 00:51:37 +00:00
|
|
|
}
|
|
|
|
|
2007-08-14 01:34:35 +00:00
|
|
|
GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle,
|
|
|
|
GpMatrixOrder order)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %.2f, %d)\n", graphics, angle, order);
|
|
|
|
|
2007-08-14 01:34:35 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-14 01:34:35 +00:00
|
|
|
return GdipRotateMatrix(graphics->worldtrans, angle, order);
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:37 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
|
|
|
|
{
|
2009-07-08 03:30:49 +00:00
|
|
|
return GdipBeginContainer2(graphics, state);
|
2007-07-14 00:51:37 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 22:04:20 +00:00
|
|
|
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics,
|
|
|
|
GraphicsContainer *state)
|
2008-11-24 09:22:51 +00:00
|
|
|
{
|
2009-07-05 22:04:20 +00:00
|
|
|
GraphicsContainerItem *container;
|
|
|
|
GpStatus sts;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", graphics, state);
|
2008-11-24 09:22:51 +00:00
|
|
|
|
|
|
|
if(!graphics || !state)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-07-05 22:04:20 +00:00
|
|
|
sts = init_container(&container, graphics);
|
|
|
|
if(sts != Ok)
|
|
|
|
return sts;
|
|
|
|
|
|
|
|
list_add_head(&graphics->containers, &container->entry);
|
|
|
|
*state = graphics->contid = container->contid;
|
|
|
|
|
2008-11-24 09:22:51 +00:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-05-31 20:00:03 +00:00
|
|
|
GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p, %d, %p): stub\n", graphics, dstrect, srcrect, unit, state);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipBeginContainerI(GpGraphics *graphics, GDIPCONST GpRect *dstrect, GDIPCONST GpRect *srcrect, GpUnit unit, GraphicsContainer *state)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p, %d, %p): stub\n", graphics, dstrect, srcrect, unit, state);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2009-06-02 01:01:43 +00:00
|
|
|
GpStatus WINGDIPAPI GdipComment(GpGraphics *graphics, UINT sizeData, GDIPCONST BYTE *data)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %d, %p): stub\n", graphics, sizeData, data);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2009-07-08 03:30:29 +00:00
|
|
|
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsContainer state)
|
2008-11-24 09:22:51 +00:00
|
|
|
{
|
2009-07-05 22:04:20 +00:00
|
|
|
GpStatus sts;
|
|
|
|
GraphicsContainerItem *container, *container2;
|
2008-11-24 09:22:51 +00:00
|
|
|
|
2009-07-05 22:04:20 +00:00
|
|
|
TRACE("(%p, %x)\n", graphics, state);
|
|
|
|
|
|
|
|
if(!graphics)
|
2008-11-24 09:22:51 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-07-05 22:04:20 +00:00
|
|
|
LIST_FOR_EACH_ENTRY(container, &graphics->containers, GraphicsContainerItem, entry){
|
|
|
|
if(container->contid == state)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* did not find a matching container */
|
|
|
|
if(&container->entry == &graphics->containers)
|
|
|
|
return Ok;
|
|
|
|
|
2009-07-08 03:30:29 +00:00
|
|
|
sts = restore_container(graphics, container);
|
|
|
|
if(sts != Ok)
|
|
|
|
return sts;
|
|
|
|
|
2009-07-05 22:04:20 +00:00
|
|
|
/* remove all of the containers on top of the found container */
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(container, container2, &graphics->containers, GraphicsContainerItem, entry){
|
|
|
|
if(container->contid == state)
|
|
|
|
break;
|
|
|
|
list_remove(&container->entry);
|
|
|
|
delete_container(container);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_remove(&container->entry);
|
|
|
|
delete_container(container);
|
|
|
|
|
2009-07-08 03:30:29 +00:00
|
|
|
return Ok;
|
2008-11-24 09:22:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-14 01:34:38 +00:00
|
|
|
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx,
|
|
|
|
REAL sy, GpMatrixOrder order)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %.2f, %.2f, %d)\n", graphics, sx, sy, order);
|
|
|
|
|
2007-08-14 01:34:38 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-14 01:34:38 +00:00
|
|
|
return GdipScaleMatrix(graphics->worldtrans, sx, sy, order);
|
|
|
|
}
|
|
|
|
|
2008-10-22 16:03:10 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetClipGraphics(GpGraphics *graphics, GpGraphics *srcgraphics,
|
|
|
|
CombineMode mode)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %d)\n", graphics, srcgraphics, mode);
|
|
|
|
|
|
|
|
if(!graphics || !srcgraphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
return GdipCombineRegionRegion(graphics->clip, srcgraphics->clip, mode);
|
|
|
|
}
|
|
|
|
|
2007-08-14 01:34:27 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics,
|
|
|
|
CompositingMode mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d)\n", graphics, mode);
|
|
|
|
|
2007-08-14 01:34:27 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-14 01:34:27 +00:00
|
|
|
graphics->compmode = mode;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:25 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetCompositingQuality(GpGraphics *graphics,
|
|
|
|
CompositingQuality quality)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d)\n", graphics, quality);
|
|
|
|
|
2007-07-14 00:51:25 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:25 +00:00
|
|
|
graphics->compqual = quality;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:29 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics,
|
|
|
|
InterpolationMode mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d)\n", graphics, mode);
|
|
|
|
|
2007-07-14 00:51:29 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:29 +00:00
|
|
|
graphics->interpolation = mode;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:18:39 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %.2f)\n", graphics, scale);
|
|
|
|
|
2007-07-25 00:18:39 +00:00
|
|
|
if(!graphics || (scale <= 0.0))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-25 00:18:39 +00:00
|
|
|
graphics->scale = scale;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:24:41 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d)\n", graphics, unit);
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
if(unit == UnitWorld)
|
2007-07-24 03:24:41 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
graphics->unit = unit;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:33 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode
|
|
|
|
mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d)\n", graphics, mode);
|
|
|
|
|
2007-07-14 00:51:33 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:33 +00:00
|
|
|
graphics->pixeloffset = mode;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-05-06 21:03:27 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetRenderingOrigin(GpGraphics *graphics, INT x, INT y)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
TRACE("(%p,%i,%i)\n", graphics, x, y);
|
|
|
|
|
|
|
|
if (!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-07-14 00:51:13 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d)\n", graphics, mode);
|
|
|
|
|
2007-07-14 00:51:13 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-14 00:51:13 +00:00
|
|
|
graphics->smoothing = mode;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2007-07-25 00:18:47 +00:00
|
|
|
|
2008-11-09 11:38:16 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetTextContrast(GpGraphics *graphics, UINT contrast)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %d)\n", graphics, contrast);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
graphics->textcontrast = contrast;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-15 02:00:09 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics,
|
|
|
|
TextRenderingHint hint)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %d)\n", graphics, hint);
|
|
|
|
|
2007-08-15 02:00:09 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-15 02:00:09 +00:00
|
|
|
graphics->texthint = hint;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:18:47 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, matrix);
|
|
|
|
|
2007-07-25 00:18:47 +00:00
|
|
|
if(!graphics || !matrix)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-07-25 00:18:47 +00:00
|
|
|
GdipDeleteMatrix(graphics->worldtrans);
|
|
|
|
return GdipCloneMatrix(matrix, &graphics->worldtrans);
|
|
|
|
}
|
2007-08-10 01:25:31 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx,
|
|
|
|
REAL dy, GpMatrixOrder order)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %.2f, %.2f, %d)\n", graphics, dx, dy, order);
|
|
|
|
|
2007-08-10 01:25:31 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2007-08-10 01:25:31 +00:00
|
|
|
return GdipTranslateMatrix(graphics->worldtrans, dx, dy, order);
|
|
|
|
}
|
2008-04-08 21:44:41 +00:00
|
|
|
|
2009-02-02 20:33:41 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipSetClipHrgn [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipSetClipHrgn(GpGraphics *graphics, HRGN hrgn, CombineMode mode)
|
|
|
|
{
|
|
|
|
GpRegion *region;
|
|
|
|
GpStatus status;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %d)\n", graphics, hrgn, mode);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
status = GdipCreateRegionHrgn(hrgn, ®ion);
|
|
|
|
if(status != Ok)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
status = GdipSetClipRegion(graphics, region, mode);
|
|
|
|
|
|
|
|
GdipDeleteRegion(region);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-09-26 18:18:09 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetClipPath(GpGraphics *graphics, GpPath *path, CombineMode mode)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %d)\n", graphics, path, mode);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
return GdipCombineRegionPath(graphics->clip, path, mode);
|
|
|
|
}
|
|
|
|
|
2008-09-25 06:41:15 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y,
|
|
|
|
REAL width, REAL height,
|
|
|
|
CombineMode mode)
|
|
|
|
{
|
|
|
|
GpRectF rect;
|
|
|
|
|
|
|
|
TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %d)\n", graphics, x, y, width, height, mode);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
rect.X = x;
|
|
|
|
rect.Y = y;
|
|
|
|
rect.Width = width;
|
|
|
|
rect.Height = height;
|
|
|
|
|
|
|
|
return GdipCombineRegionRect(graphics->clip, &rect, mode);
|
|
|
|
}
|
|
|
|
|
2008-04-08 21:44:41 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetClipRectI(GpGraphics *graphics, INT x, INT y,
|
|
|
|
INT width, INT height,
|
2008-09-25 06:41:15 +00:00
|
|
|
CombineMode mode)
|
2008-04-08 21:44:41 +00:00
|
|
|
{
|
2008-09-25 06:41:15 +00:00
|
|
|
TRACE("(%p, %d, %d, %d, %d, %d)\n", graphics, x, y, width, height, mode);
|
2008-04-08 21:44:41 +00:00
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-09-25 06:41:15 +00:00
|
|
|
return GdipSetClipRect(graphics, (REAL)x, (REAL)y, (REAL)width, (REAL)height, mode);
|
2008-04-08 21:44:41 +00:00
|
|
|
}
|
2008-04-09 19:35:29 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region,
|
2008-08-27 19:30:59 +00:00
|
|
|
CombineMode mode)
|
2008-04-09 19:35:29 +00:00
|
|
|
{
|
2008-08-27 19:30:59 +00:00
|
|
|
TRACE("(%p, %p, %d)\n", graphics, region, mode);
|
2008-04-09 19:35:29 +00:00
|
|
|
|
2008-08-27 19:30:59 +00:00
|
|
|
if(!graphics || !region)
|
|
|
|
return InvalidParameter;
|
2008-04-09 19:35:29 +00:00
|
|
|
|
2008-08-27 19:30:59 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
return GdipCombineRegionRegion(graphics->clip, region, mode);
|
2008-04-09 19:35:29 +00:00
|
|
|
}
|
2008-04-10 19:40:21 +00:00
|
|
|
|
2008-08-24 10:45:14 +00:00
|
|
|
GpStatus WINGDIPAPI GdipSetMetafileDownLevelRasterizationLimit(GpMetafile *metafile,
|
2008-04-10 19:40:21 +00:00
|
|
|
UINT limitDpi)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 22:04:20 +00:00
|
|
|
TRACE("(%p,%u)\n", metafile, limitDpi);
|
|
|
|
|
2008-04-10 19:40:21 +00:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-04-24 16:48:17 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawPolygon(GpGraphics *graphics,GpPen *pen,GDIPCONST GpPointF *points,
|
|
|
|
INT count)
|
|
|
|
{
|
|
|
|
INT save_state;
|
|
|
|
POINT *pti;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d)\n", graphics, points, count);
|
|
|
|
|
2008-04-24 16:48:17 +00:00
|
|
|
if(!graphics || !pen || count<=0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-04-24 16:48:17 +00:00
|
|
|
pti = GdipAlloc(sizeof(POINT) * count);
|
|
|
|
|
|
|
|
save_state = prepare_dc(graphics, pen);
|
|
|
|
SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
|
|
|
|
transform_and_round_points(graphics, pti, (GpPointF*)points, count);
|
|
|
|
Polygon(graphics->hdc, pti, count);
|
|
|
|
|
|
|
|
restore_dc(graphics, save_state);
|
|
|
|
GdipFree(pti);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawPolygonI(GpGraphics *graphics,GpPen *pen,GDIPCONST GpPoint *points,
|
|
|
|
INT count)
|
|
|
|
{
|
|
|
|
GpStatus ret;
|
|
|
|
GpPointF *ptf;
|
|
|
|
INT i;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
|
|
|
|
|
2008-04-24 16:48:17 +00:00
|
|
|
if(count<=0) return InvalidParameter;
|
|
|
|
ptf = GdipAlloc(sizeof(GpPointF) * count);
|
|
|
|
|
|
|
|
for(i = 0;i < count; i++){
|
|
|
|
ptf[i].X = (REAL)points[i].X;
|
|
|
|
ptf[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GdipDrawPolygon(graphics,pen,ptf,count);
|
|
|
|
GdipFree(ptf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2008-04-28 20:10:20 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL* dpi)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, dpi);
|
|
|
|
|
2008-04-28 20:10:20 +00:00
|
|
|
if(!graphics || !dpi)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-04-28 20:10:20 +00:00
|
|
|
*dpi = (REAL)GetDeviceCaps(graphics->hdc, LOGPIXELSX);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL* dpi)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, dpi);
|
|
|
|
|
2008-04-28 20:10:20 +00:00
|
|
|
if(!graphics || !dpi)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-04-28 20:10:20 +00:00
|
|
|
*dpi = (REAL)GetDeviceCaps(graphics->hdc, LOGPIXELSY);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2008-04-29 21:28:40 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST GpMatrix *matrix,
|
|
|
|
GpMatrixOrder order)
|
|
|
|
{
|
|
|
|
GpMatrix m;
|
|
|
|
GpStatus ret;
|
|
|
|
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p, %d)\n", graphics, matrix, order);
|
|
|
|
|
2008-04-29 21:28:40 +00:00
|
|
|
if(!graphics || !matrix)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-04-29 21:28:40 +00:00
|
|
|
m = *(graphics->worldtrans);
|
|
|
|
|
2009-01-14 08:52:24 +00:00
|
|
|
ret = GdipMultiplyMatrix(&m, matrix, order);
|
2008-04-29 21:28:40 +00:00
|
|
|
if(ret == Ok)
|
|
|
|
*(graphics->worldtrans) = m;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2008-05-12 15:51:32 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, hdc);
|
|
|
|
|
2008-08-24 10:45:14 +00:00
|
|
|
if(!graphics || !hdc)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:18 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
|
|
|
*hdc = graphics->hdc;
|
|
|
|
graphics->busy = TRUE;
|
|
|
|
|
|
|
|
return Ok;
|
2008-05-12 15:51:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
|
|
|
|
{
|
2008-09-02 19:45:39 +00:00
|
|
|
TRACE("(%p, %p)\n", graphics, hdc);
|
|
|
|
|
2008-08-24 10:45:14 +00:00
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:18 +00:00
|
|
|
if(graphics->hdc != hdc || !(graphics->busy))
|
2008-08-24 10:45:14 +00:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-08-24 10:45:18 +00:00
|
|
|
graphics->busy = FALSE;
|
|
|
|
|
|
|
|
return Ok;
|
2008-05-12 15:51:32 +00:00
|
|
|
}
|
2008-05-12 15:57:28 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
|
|
|
|
{
|
2008-08-26 22:03:27 +00:00
|
|
|
GpRegion *clip;
|
|
|
|
GpStatus status;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", graphics, region);
|
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(!graphics || !region)
|
|
|
|
return InvalidParameter;
|
2008-05-12 15:57:28 +00:00
|
|
|
|
2008-08-24 10:45:23 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2008-08-26 22:03:27 +00:00
|
|
|
if((status = GdipCloneRegion(graphics->clip, &clip)) != Ok)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
/* free everything except root node and header */
|
|
|
|
delete_element(®ion->node);
|
|
|
|
memcpy(region, clip, sizeof(GpRegion));
|
2009-12-12 16:49:15 +00:00
|
|
|
GdipFree(clip);
|
2008-08-26 22:03:27 +00:00
|
|
|
|
|
|
|
return Ok;
|
2008-05-12 15:57:28 +00:00
|
|
|
}
|
2008-07-10 14:26:58 +00:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipTransformPoints(GpGraphics *graphics, GpCoordinateSpace dst_space,
|
|
|
|
GpCoordinateSpace src_space, GpPointF *points, INT count)
|
|
|
|
{
|
2009-03-23 21:34:12 +00:00
|
|
|
GpMatrix *matrix;
|
|
|
|
GpStatus stat;
|
|
|
|
REAL unitscale;
|
|
|
|
|
2008-08-25 21:58:42 +00:00
|
|
|
if(!graphics || !points || count <= 0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-03-23 21:34:12 +00:00
|
|
|
TRACE("(%p, %d, %d, %p, %d)\n", graphics, dst_space, src_space, points, count);
|
2008-07-10 14:26:58 +00:00
|
|
|
|
2009-03-23 21:34:12 +00:00
|
|
|
if (src_space == dst_space) return Ok;
|
|
|
|
|
|
|
|
stat = GdipCreateMatrix(&matrix);
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
unitscale = convert_unit(graphics->hdc, graphics->unit);
|
|
|
|
|
|
|
|
if(graphics->unit != UnitDisplay)
|
|
|
|
unitscale *= graphics->scale;
|
|
|
|
|
|
|
|
/* transform from src_space to CoordinateSpacePage */
|
|
|
|
switch (src_space)
|
|
|
|
{
|
|
|
|
case CoordinateSpaceWorld:
|
|
|
|
GdipMultiplyMatrix(matrix, graphics->worldtrans, MatrixOrderAppend);
|
|
|
|
break;
|
|
|
|
case CoordinateSpacePage:
|
|
|
|
break;
|
|
|
|
case CoordinateSpaceDevice:
|
|
|
|
GdipScaleMatrix(matrix, 1.0/unitscale, 1.0/unitscale, MatrixOrderAppend);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* transform from CoordinateSpacePage to dst_space */
|
|
|
|
switch (dst_space)
|
|
|
|
{
|
|
|
|
case CoordinateSpaceWorld:
|
|
|
|
{
|
|
|
|
GpMatrix *inverted_transform;
|
|
|
|
stat = GdipCloneMatrix(graphics->worldtrans, &inverted_transform);
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
stat = GdipInvertMatrix(inverted_transform);
|
|
|
|
if (stat == Ok)
|
|
|
|
GdipMultiplyMatrix(matrix, inverted_transform, MatrixOrderAppend);
|
|
|
|
GdipDeleteMatrix(inverted_transform);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CoordinateSpacePage:
|
|
|
|
break;
|
|
|
|
case CoordinateSpaceDevice:
|
|
|
|
GdipScaleMatrix(matrix, unitscale, unitscale, MatrixOrderAppend);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stat == Ok)
|
|
|
|
stat = GdipTransformMatrixPoints(matrix, points, count);
|
|
|
|
|
|
|
|
GdipDeleteMatrix(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
return stat;
|
2008-07-10 14:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipTransformPointsI(GpGraphics *graphics, GpCoordinateSpace dst_space,
|
|
|
|
GpCoordinateSpace src_space, GpPoint *points, INT count)
|
|
|
|
{
|
2009-05-19 20:40:43 +00:00
|
|
|
GpPointF *pointsF;
|
|
|
|
GpStatus ret;
|
|
|
|
INT i;
|
2008-07-10 14:26:58 +00:00
|
|
|
|
2009-05-19 20:40:43 +00:00
|
|
|
TRACE("(%p, %d, %d, %p, %d)\n", graphics, dst_space, src_space, points, count);
|
|
|
|
|
|
|
|
if(count <= 0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
pointsF = GdipAlloc(sizeof(GpPointF) * count);
|
|
|
|
if(!pointsF)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
pointsF[i].X = (REAL)points[i].X;
|
|
|
|
pointsF[i].Y = (REAL)points[i].Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GdipTransformPoints(graphics, dst_space, src_space, pointsF, count);
|
|
|
|
|
|
|
|
if(ret == Ok)
|
|
|
|
for(i = 0; i < count; i++){
|
|
|
|
points[i].X = roundr(pointsF[i].X);
|
|
|
|
points[i].Y = roundr(pointsF[i].Y);
|
|
|
|
}
|
|
|
|
GdipFree(pointsF);
|
|
|
|
|
|
|
|
return ret;
|
2008-07-10 14:26:58 +00:00
|
|
|
}
|
2008-11-24 09:23:03 +00:00
|
|
|
|
|
|
|
HPALETTE WINGDIPAPI GdipCreateHalftonePalette(void)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-01-30 21:07:30 +00:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipTranslateClip [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipTranslateClip(GpGraphics *graphics, REAL dx, REAL dy)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %.2f, %.2f)\n", graphics, dx, dy);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-02-02 20:48:01 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-01-30 21:07:30 +00:00
|
|
|
return GdipTranslateRegion(graphics->clip, dx, dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipTranslateClipI [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipTranslateClipI(GpGraphics *graphics, INT dx, INT dy)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %d, %d)\n", graphics, dx, dy);
|
|
|
|
|
|
|
|
if(!graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-02-02 20:48:01 +00:00
|
|
|
if(graphics->busy)
|
|
|
|
return ObjectBusy;
|
|
|
|
|
2009-01-30 21:07:30 +00:00
|
|
|
return GdipTranslateRegion(graphics->clip, (REAL)dx, (REAL)dy);
|
|
|
|
}
|
2009-06-09 20:48:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipMeasureDriverString [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipMeasureDriverString(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length,
|
|
|
|
GDIPCONST GpFont *font, GDIPCONST PointF *positions,
|
|
|
|
INT flags, GDIPCONST GpMatrix *matrix, RectF *boundingBox)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %d %p %p %d %p %p): stub\n", graphics, text, length, font, positions, flags, matrix, boundingBox);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipDrawDriverString [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length,
|
|
|
|
GDIPCONST GpFont *font, GDIPCONST GpBrush *brush,
|
|
|
|
GDIPCONST PointF *positions, INT flags,
|
|
|
|
GDIPCONST GpMatrix *matrix )
|
|
|
|
{
|
2009-06-15 09:00:03 +00:00
|
|
|
FIXME("(%p %p %d %p %p %p %d %p): stub\n", graphics, text, length, font, brush, positions, flags, matrix);
|
2009-06-09 20:48:05 +00:00
|
|
|
return NotImplemented;
|
|
|
|
}
|
2009-06-22 20:59:59 +00:00
|
|
|
|
2009-07-30 03:56:42 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipRecordMetafileI [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipRecordMetafileI(HDC hdc, EmfType type, GDIPCONST GpRect *frameRect,
|
|
|
|
MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
|
|
|
|
{
|
|
|
|
FIXME("(%p %d %p %d %p %p): stub\n", hdc, type, frameRect, frameUnit, desc, metafile);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2009-12-23 02:53:27 +00:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipIsVisibleClipEmpty [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipIsVisibleClipEmpty(GpGraphics *graphics, BOOL *res)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
GpRegion* rgn;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", graphics, res);
|
|
|
|
|
|
|
|
if((stat = GdipCreateRegion(&rgn)) != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
if((stat = get_visible_clip_region(graphics, rgn)) != Ok)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
stat = GdipIsEmptyRegion(rgn, graphics, res);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
GdipDeleteRegion(rgn);
|
|
|
|
return stat;
|
|
|
|
}
|