Пример #1
0
GpStatus WINGDIPAPI
GdipSetPenColor (GpPen *pen, ARGB argb)
{
	GpStatus status;
	GpSolidFill *brush;
	GpBrushType type;

	if (!pen)
		return InvalidParameter;

	GdipGetBrushType (pen->brush, &type);
	if (type == BrushTypeSolidColor) {
		ARGB brushColor;
		GdipGetSolidFillColor ((GpSolidFill *) pen->brush, &brushColor);

		// Nothing to do.
		if (brushColor == argb)
			return Ok;
	}

	// Override the brush and set it to a solid fill.
	status = GdipCreateSolidFill (argb, &brush);
	if (status != Ok)
		return status;

	pen->color = argb;
	pen->brush = (GpBrush *) brush;
	pen->changed = TRUE;

	return Ok;
}
Пример #2
0
GpStatus WINGDIPAPI GdipGetPenColor(GpPen *pen, ARGB *argb)
{
    TRACE("(%p, %p)\n", pen, argb);

    if(!pen || !argb)
        return InvalidParameter;

    if(pen->brush->bt != BrushTypeSolidColor)
        return NotImplemented;

    return GdipGetSolidFillColor(((GpSolidFill*)pen->brush), argb);
}
Пример #3
0
static void test_brushfill(void)
{
    GpStatus status;
    GpPen *pen;
    GpBrush *brush, *brush2;
    GpBrushType type;
    ARGB color = 0;

    /* default solid */
    GdipCreatePen1(0xdeadbeef, 4.5, UnitWorld, &pen);
    status = GdipGetPenBrushFill(pen, &brush);
    expect(Ok, status);
    GdipGetBrushType(brush, &type);
    expect(BrushTypeSolidColor, type);
    GdipGetPenColor(pen, &color);
    expect(0xdeadbeef, color);
    GdipDeleteBrush(brush);

    /* color controlled by brush */
    GdipCreateSolidFill(0xabaddeed, (GpSolidFill**)&brush);
    status = GdipSetPenBrushFill(pen, brush);
    expect(Ok, status);
    GdipGetPenColor(pen, &color);
    expect(0xabaddeed, color);
    GdipDeleteBrush(brush);
    color = 0;

    /* get returns a clone, not a reference */
    GdipGetPenBrushFill(pen, &brush);
    GdipSetSolidFillColor((GpSolidFill*)brush, 0xbeadfeed);
    GdipGetPenBrushFill(pen, &brush2);
    ok(brush != brush2, "Expected to get a clone, not a copy of the reference\n");
    GdipGetSolidFillColor((GpSolidFill*)brush2, &color);
    expect(0xabaddeed, color);
    GdipDeleteBrush(brush);
    GdipDeleteBrush(brush2);

    /* brush cannot be NULL */
    status = GdipSetPenBrushFill(pen, NULL);
    expect(InvalidParameter, status);

    GdipDeletePen(pen);
}
Пример #4
0
// coverity[+alloc : arg-*3]
GpStatus WINGDIPAPI
GdipCreatePen2 (GpBrush *brush, REAL width, GpUnit unit, GpPen **pen)
{
	GpPen *result;
	GpStatus status;
	GpBrushType type;
	ARGB color;

	if (!gdiplusInitialized)
		return GdiplusNotInitialized;

	if (!brush || !pen || unit > UnitCairoPoint || unit == UnitDisplay)
		return InvalidParameter;

	result = gdip_pen_new ();
	if (!result) {
		*pen = NULL;
		return OutOfMemory;
	}

	result->width = width;
	result->unit = unit;
	result->own_brush = TRUE;

	/* The user supplied brush can be disposed, we must clone it to ensure
	 * it's valid when we need to set the pen. */
	status = GdipCloneBrush (brush, &result->brush);
	if (status != Ok) {
		GdipDeletePen (result);
		*pen = NULL;
		return status;
	}

	GdipGetBrushType (brush, &type);
	if (type == BrushTypeSolidColor) {
		GdipGetSolidFillColor ((GpSolidFill *) brush, &color);
		result->color = color;
	}

	*pen = result;
	return Ok;
}
Пример #5
0
GpStatus WINGDIPAPI
GdipSetPenBrushFill (GpPen *pen, GpBrush *brush)
{
	GpBrushType type;

	if (!pen || !brush)
		return InvalidParameter;

	GdipGetBrushType (brush, &type);
	if (type == BrushTypeSolidColor)
		GdipGetSolidFillColor ((GpSolidFill *) brush, &pen->color);
	else
		pen->color = 0;

	if (pen->own_brush && pen->brush)
		GdipDeleteBrush (pen->brush);

	pen->brush = brush;
	pen->changed = TRUE;
	pen->own_brush = FALSE;

	return Ok;
}