/**************************************************************************\
*
* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
*
* Module Name:
*
* GdiplusGraphics.h
*
* Abstract:
*
* GDI+ Graphics Object
*
\**************************************************************************/
#ifndef _GDIPLUSGRAPHICS_H
#define _GDIPLUSGRAPHICS_H
class Graphics : public GdiplusBase
{
public:
friend class Region;
friend class GraphicsPath;
friend class Image;
friend class Bitmap;
friend class Metafile;
friend class Font;
friend class FontFamily;
friend class FontCollection;
friend class CachedBitmap;
static Graphics* FromHDC(IN HDC hdc)
{
return new Graphics(hdc);
}
static Graphics* FromHDC(IN HDC hdc,
IN HANDLE hdevice)
{
return new Graphics(hdc, hdevice);
}
static Graphics* FromHWND(IN HWND hwnd,
IN BOOL icm = FALSE)
{
return new Graphics(hwnd, icm);
}
static Graphics* FromImage(IN Image *image)
{
return new Graphics(image);
}
Graphics(IN HDC hdc)
{
GpGraphics *graphics = NULL;
lastResult = DllExports::GdipCreateFromHDC(hdc, &graphics);
SetNativeGraphics(graphics);
}
Graphics(IN HDC hdc,
IN HANDLE hdevice)
{
GpGraphics *graphics = NULL;
lastResult = DllExports::GdipCreateFromHDC2(hdc, hdevice, &graphics);
SetNativeGraphics(graphics);
}
Graphics(IN HWND hwnd,
IN BOOL icm = FALSE)
{
GpGraphics *graphics = NULL;
if (icm)
{
lastResult = DllExports::GdipCreateFromHWNDICM(hwnd, &graphics);
}
else
{
lastResult = DllExports::GdipCreateFromHWND(hwnd, &graphics);
}
SetNativeGraphics(graphics);
}
Graphics(IN Image* image)
{
GpGraphics *graphics = NULL;
if (image != NULL)
{
lastResult = DllExports::GdipGetImageGraphicsContext(
image->nativeImage, &graphics);
}
SetNativeGraphics(graphics);
}
~Graphics()
{
DllExports::GdipDeleteGraphics(nativeGraphics);
}
VOID Flush(IN FlushIntention intention = FlushIntentionFlush)
{
DllExports::GdipFlush(nativeGraphics, intention);
}
//------------------------------------------------------------------------
// GDI Interop methods
//------------------------------------------------------------------------
// Locks the graphics until ReleaseDC is called
HDC GetHDC()
{
HDC hdc = NULL;
SetStatus(DllExports::GdipGetDC(nativeGraphics, &hdc));
return hdc;
}
VOID ReleaseHDC(IN HDC hdc)
{
SetStatus(DllExports::GdipReleaseDC(nativeGraphics, hdc));
}
//------------------------------------------------------------------------
// Rendering modes
//------------------------------------------------------------------------
Status SetRenderingOrigin(IN INT x, IN INT y)
{
return SetStatus(
DllExports::GdipSetRenderingOrigin(
nativeGraphics, x, y
)
);
}
Status GetRenderingOrigin(OUT INT *x, OUT INT *y) const
{
return SetStatus(
DllExports::GdipGetRenderingOrigin(
nativeGraphics, x, y
)
);
}
Status SetCompositingMode(IN CompositingMode compositingMode)
{
return SetStatus(DllExports::GdipSetCompositingMode(nativeGraphics,
compositingMode));
}
CompositingMode GetCompositingMode() const
{
CompositingMode mode;
SetStatus(DllExports::GdipGetCompositingMode(nativeGraphics,
&mode));
return mode;
}
Status SetCompositingQuality(IN CompositingQuality compositingQuality)
{
return SetStatus(DllExports::GdipSetCompositingQuality(
nativeGraphics,
compositingQuality));
}
CompositingQuality GetCompositingQuality() const
{
CompositingQuality quality;
SetStatus(DllExports::GdipGetCompositingQuality(
nativeGraphics,
&quality));
return quality;
}
Status SetTextRenderingHint(IN TextRenderingHint newMode)
{
return SetStatus(DllExports::GdipSetTextRenderingHint(nativeGraphics,
newMode));
}
TextRenderingHint GetTextRenderingHint() const
{
TextRenderingHint hint;
SetStatus(DllExports::GdipGetTextRenderingHint(nativeGraphics,
&hint));
return hint;
}
Status SetTextContrast(IN UINT contrast)
{
return SetStatus(DllExports::GdipSetTextContrast(nativeGraphics,
contrast));
}
UINT GetTextContrast() const
{
UINT contrast;
SetStatus(DllExports::GdipGetTextContrast(nativeGraphics,
&contrast));
return contrast;
}
InterpolationMode GetInterpolationMode() const
{
InterpolationMode mode = InterpolationModeInvalid;
SetStatus(DllExports::GdipGetInterpolationMode(nativeGraphics,
&mode));
return mode;
}
Status SetInterpolationMode(IN InterpolationMode interpolationMode)
{
return SetStatus(DllExports::GdipSetInterpolationMode(nativeGraphics,
interpolationMode));
}
SmoothingMode GetSmoothingMode() const
{
SmoothingMode smoothingMode = SmoothingModeInvalid;
SetStatus(DllExports::GdipGetSmoothingMode(nativeGraphics,
&smoothingMode));
return smoothingMode;
}
Status SetSmoothingMode(IN SmoothingMode smoothingMode)
{
return SetStatus(DllExports::GdipSetSmoothingMode(nativeGraphics,
smoothingMode));
}
PixelOffsetMode GetPixelOffsetMode() const
{
PixelOffsetMode pixelOffsetMode = PixelOffsetModeInvalid;
SetStatus(DllExports::GdipGetPixelOffsetMode(nativeGraphics,
&pixelOffsetMode));
return pixelOffsetMode;
}
Status SetPixelOffsetMode(IN PixelOffsetMode pixelOffsetMode)
{
return SetStatus(DllExports::GdipSetPixelOffsetMode(nativeGraphics,
pixelOffsetMode));
}
//------------------------------------------------------------------------
// Manipulate current world transform
//------------------------------------------------------------------------
Status SetTransform(IN const Matrix* matrix)
{
return SetStatus(DllExports::GdipSetWorldTransform(nativeGraphics,
matrix->nativeMatrix));
}
Status ResetTransform()
{
return SetStatus(DllExports::GdipResetWorldTransform(nativeGraphics));
}
Status MultiplyTransform(IN const Matrix* matrix,
IN MatrixOrder order = MatrixOrderPrepend)
{
return SetStatus(DllExports::GdipMultiplyWorldTransform(nativeGraphics,