/**************************************************************************\
*
* Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
*
* Module Name:
*
* GdiplusGraphics.h
*
* Abstract:
*
* Declarations for Graphics class
*
\**************************************************************************/
#ifndef _GDIPLUSGRAPHICS_H
#define _GDIPLUSGRAPHICS_H
/**
* Represent a graphics context
*/
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;
// Get a graphics context from an existing Win32 HDC or HWND
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);
}
//------------------------------------------------------------------------
// 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)
{
#ifndef DCR_USE_NEW_186764
/* temporarly set the high bit to warn that we are using the new definition for the flag */
newMode = (TextRenderingHint) (newMode | 0x0f000);
#endif // DCR_USE_NEW_186764
return SetStatus(DllExports::GdipSetTextRenderingHint(nativeGraphics,
newMode));
}
TextRenderingHint GetTextRenderingHint() const
{
TextRenderingHint hint;
SetStatus(DllExports::GdipGetTextRenderingHint(nativeGraphics,
&hint));
return hint;
}
#ifdef DCR_USE_NEW_188922
Status SetTextContrast(IN UINT contrast)
{
return SetStatus(DllExports::GdipSetTextContrast(nativeGraphics,
contrast));
}
UINT GetTextContrast() const
{
UINT contrast;
SetStatus(DllExports::GdipGetTextContrast(nativeGraphics,
&contrast));
return contrast;
}
#else
Status SetTextGammaValue(IN UINT gammaValue)
{
return SetStatus(DllExports::GdipSetTextGammaValue(nativeGraphics,
gammaValue));
}
UINT GetTextGammaValue() const
{
UINT gammaValue;
SetStatus(DllExports::GdipGetTextGammaValue(nativeGraphics,
&gammaValue));
return gammaValue;
}
#endif // DCR_USE_NEW_188922
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,