use gdiplus.dll directly, instead of pltgdi_xxxxxxx.dll

svn: r1756
This commit is contained in:
Matthew Flatt 2006-01-03 20:17:02 +00:00
parent b9147c1b5d
commit d955df71ba
4 changed files with 379 additions and 495 deletions

View File

@ -1,12 +1,8 @@
#include "wx_pltgdi.h"
#ifndef WX_GRAPHICS_EXPORT
# define WX_GRAPHICS_EXPORT extern
#endif
#ifndef WX_GPROC
# define WX_GPROC(x) (*x)
#endif
#define WX_GRAPHICS_EXPORT extern
#define WX_GPROC(x) x
WX_GRAPHICS_EXPORT void WX_GPROC(wxGStartup)();
WX_GRAPHICS_EXPORT void WX_GPROC(wxGShutdown)();
@ -42,9 +38,6 @@ WX_GRAPHICS_EXPORT void WX_GPROC(wxGDrawPolygon)(Graphics *g, Pen *p, PointF *pt
WX_GRAPHICS_EXPORT void WX_GPROC(wxGFillPath)(Graphics *g, Brush *b, GraphicsPath *gp);
WX_GRAPHICS_EXPORT void WX_GPROC(wxGDrawPath)(Graphics *g, Pen *p, GraphicsPath *gp);
WX_GRAPHICS_EXPORT void WX_GPROC(wxGDrawString)(Graphics *g, wchar_t *w, int len, Font *f, PointF *pos, StringFormat *fmt, COLORREF c);
WX_GRAPHICS_EXPORT void WX_GPROC(wxGMeasureString)(Graphics *g, wchar_t *w, int len, Font *f, PointF *pos, StringFormat *fmt, RectF *r);
WX_GRAPHICS_EXPORT GraphicsPath *WX_GPROC(wxGPathNew)(FillMode m);
WX_GRAPHICS_EXPORT void WX_GPROC(wxGPathRelease)(GraphicsPath *gp);
@ -72,5 +65,3 @@ WX_GRAPHICS_EXPORT void WX_GPROC(wxGPenRelease)(Pen *b);
WX_GRAPHICS_EXPORT Font *WX_GPROC(wxGFontNew)(HDC dc);
WX_GRAPHICS_EXPORT void WX_GPROC(wxGFontRelease)(Font *f);
WX_GRAPHICS_EXPORT StringFormat *WX_GPROC(wxGNewStringFormat)(int flags);

View File

@ -2,22 +2,82 @@
#ifndef _WX_PLT_GDI_H_
#define _WX_PLT_GDI_H_
#define GDIP_DECL(x) typedef struct x x
GDIP_DECL(GpGraphics);
GDIP_DECL(GpPath);
GDIP_DECL(GpPen);
GDIP_DECL(GpSolidFill);
GDIP_DECL(GpMatrix);
GDIP_DECL(GpFont);
#define GpBrush GpSolidFill
typedef int GpStatus;
typedef int GpFillMode;
typedef int GpCombineMode;
typedef int GpLineCap;
typedef int GpLineJoin;
typedef int GpPixelOffsetMode;
typedef int GpSmoothingMode;
typedef int GpUnit;
typedef UINT GraphicsState;
typedef float REAL;
#ifdef MZ_PRECISE_GC
namespace Gdiplus {
class Graphics;
class GraphicsPath;
class Pen;
class Brush;
class Matrix;
};
START_XFORM_SKIP;
#endif
#include <gdiplus.h>
using namespace Gdiplus;
class GpPointF {
public:
REAL X;
REAL Y;
};
class GpRectF {
public:
REAL X;
REAL Y;
REAL WIDTH;
REAL HEIGHT;
};
#ifdef MZ_PRECISE_GC
END_XFORM_SKIP;
#endif
#define LineCapRound 2
#define LineCapSquare 1
#define LineCapFlat 0
#define LineJoinBevel 1
#define LineJoinMiter 0
#define LineJoinRound 2
#define FillModeAlternate 0
#define FillModeWinding 1
#define CombineModeReplace 0
#define CombineModeIntersect 1
#define UnitPoint 3
#define Graphics GpGraphics
#define GraphicsPath GpPath
#define Pen GpPen
#define Brush GpSolidFill
#define Matrix GpMatrix
#define Font GpFont
#define PointF GpPointF
#define RectF GpRectF
#define FillMode GpFillMode
#define CombineMode GpCombineMode
#define LineCap GpLineCap
#define LineJoin GpLineJoin
#define PixelOffsetMode GpPixelOffsetMode
#define SmoothingMode GpSmoothingMode
#define Unit GpUnit
#endif

View File

@ -1,238 +1,328 @@
#include "wx.h"
#include "wx_graphics.h"
#include <gdiplus.h>
extern "C" __declspec(dllimport) char *scheme_get_dll_path(char *);
Bool wx_gdi_plus = FALSE;
/* ********************************************************************** */
/* Declare types to mask cast easier: */
#define ULONG_PTR ULONG *
#define INT int
#define GDIPCONST const
#define ARGB UINT
typedef void (*p_wxGStartup)();
typedef void (*p_wxGShutdown)();
typedef int GpMatrixOrder;
typedef Graphics *(*p_wxGMake)(HDC dc);
typedef void (*p_wxGRelease)(Graphics *g);
#define QualityModeHigh 2
#define SmoothingModeHighQuality QualityModeHigh
#define PixelOffsetModeHalf QualityModeHigh + 2
#define UnitWorld 0
#define MatrixOrderPrepend 0
typedef void (*p_wxGSetPageUnit)(Graphics *g, Unit u);
typedef void (*p_wxGResetClip)(Graphics *g);
typedef void (*p_wxGSetClip)(Graphics *g, GraphicsPath *gp, CombineMode m);
typedef GraphicsState (*p_wxGSave)(Graphics *g);
typedef void (*p_wxGRestore)(Graphics *g, GraphicsState s);
typedef void (*p_wxGResetTransform)(Graphics *g);
typedef void (*p_wxGTranslate)(Graphics *g, double x, double y);
typedef void (*p_wxGScale)(Graphics *g, double x, double y);
typedef void (*p_wxGDrawLine)(Graphics *g, Pen *p, double x1, double y1, double x2, double y2);
typedef void (*p_wxGDrawLines)(Graphics *g, Pen *p, PointF *pts, int n);
typedef void (*p_wxGFillRectangleColor)(Graphics *g, COLORREF c, double x, double y, double w, double h);
typedef void (*p_wxGFillRectangle)(Graphics *g, Brush *b, double x, double y, double w, double h);
typedef void (*p_wxGDrawRectangle)(Graphics *g, Pen *p, double x, double y, double w, double h);
typedef void (*p_wxGFillPie)(Graphics *g, Brush *b, double x, double y, double w, double h, double start, double span);
typedef void (*p_wxGDrawArc)(Graphics *g, Pen *p, double x, double y, double w, double h, double start, double span);
typedef void (*p_wxGFillPolygon)(Graphics *g, Brush *b, PointF *pts, int n, FillMode m);
typedef void (*p_wxGDrawPolygon)(Graphics *g, Pen *p, PointF *pts, int n);
typedef void (*p_wxGFillPath)(Graphics *g, Brush *b, GraphicsPath *gp);
typedef void (*p_wxGDrawPath)(Graphics *g, Pen *p, GraphicsPath *gp);
typedef void (*p_wxGDrawString)(Graphics *g, wchar_t *w, int len, Font *f, PointF *pos, StringFormat *fmt, COLORREF c);
typedef void (*p_wxGMeasureString)(Graphics *g, wchar_t *w, int len, Font *f, PointF *pos, StringFormat *fmt, RectF *r);
typedef GraphicsPath *(*p_wxGPathNew)(FillMode m);
typedef void (*p_wxGPathRelease)(GraphicsPath *gp);
typedef void (*p_wxGPathAddArc)(GraphicsPath *gp, double x, double y, double w, double h, double start, double span);
typedef void (*p_wxGPathAddPie)(GraphicsPath *gp, double x, double y, double w, double h, double start, double span);
typedef void (*p_wxGPathAddLine)(GraphicsPath *gp, double x1, double y1, double x2, double y2);
typedef void (*p_wxGPathAddBezier)(GraphicsPath *gp, double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4);
typedef void (*p_wxGPathAddPath)(GraphicsPath *gp, GraphicsPath *gp2, int conn);
typedef void (*p_wxGPathCloseFigure)(GraphicsPath *gp);
typedef void (*p_wxGPathTransform)(GraphicsPath *gp, Matrix *m);
typedef Matrix *(*p_wxGMatrixNew)();
typedef void (*p_wxGMatrixRelease)(Matrix *m);
typedef void (*p_wxGMatrixTranslate)(Matrix *m, double x, double y);
typedef void (*p_wxGMatrixScale)(Matrix *m, double x, double y);
typedef Brush *(*p_wxGBrushNew)(COLORREF c);
typedef void (*p_wxGBrushRelease)(Brush *b);
typedef Pen *(*p_wxGPenNew)(COLORREF c, double pw, LineCap cap, LineJoin join, int ndash, REAL *dashes, REAL offset);
typedef void (*p_wxGPenRelease)(Pen *b);
typedef Font *(*p_wxGFontNew)(HDC dc);
typedef void (*p_wxGFontRelease)(Font *f);
typedef StringFormat *(*p_wxGNewStringFormat)(int flags);
/* ********************************************************************** */
/* Declare procedure pointers: */
p_wxGStartup wxGStartup;
p_wxGShutdown wxGShutdown;
p_wxGMake wxGMake;
p_wxGRelease wxGRelease;
p_wxGSetPageUnit wxGSetPageUnit;
p_wxGResetClip wxGResetClip;
p_wxGSetClip wxGSetClip;
p_wxGSave wxGSave;
p_wxGRestore wxGRestore;
p_wxGResetTransform wxGResetTransform;
p_wxGTranslate wxGTranslate;
p_wxGScale wxGScale;
p_wxGDrawLine wxGDrawLine;
p_wxGDrawLines wxGDrawLines;
p_wxGFillRectangleColor wxGFillRectangleColor;
p_wxGFillRectangle wxGFillRectangle;
p_wxGDrawRectangle wxGDrawRectangle;
p_wxGFillPie wxGFillPie;
p_wxGDrawArc wxGDrawArc;
p_wxGFillPolygon wxGFillPolygon;
p_wxGDrawPolygon wxGDrawPolygon;
p_wxGFillPath wxGFillPath;
p_wxGDrawPath wxGDrawPath;
p_wxGDrawString wxGDrawString;
p_wxGMeasureString wxGMeasureString;
p_wxGPathNew wxGPathNew;
p_wxGPathRelease wxGPathRelease;
p_wxGPathAddArc wxGPathAddArc;
p_wxGPathAddPie wxGPathAddPie;
p_wxGPathAddLine wxGPathAddLine;
p_wxGPathAddBezier wxGPathAddBezier;
p_wxGPathAddPath wxGPathAddPath;
p_wxGPathCloseFigure wxGPathCloseFigure;
p_wxGPathTransform wxGPathTransform;
p_wxGMatrixNew wxGMatrixNew;
p_wxGMatrixRelease wxGMatrixRelease;
p_wxGMatrixTranslate wxGMatrixTranslate;
p_wxGMatrixScale wxGMatrixScale;
p_wxGBrushNew wxGBrushNew;
p_wxGBrushRelease wxGBrushRelease;
p_wxGPenNew wxGPenNew;
p_wxGPenRelease wxGPenRelease;
p_wxGFontNew wxGFontNew;
p_wxGFontRelease wxGFontRelease;
p_wxGNewStringFormat wxGNewStringFormat;
/* ********************************************************************** */
/* Init procs: */
static void GetProcs(HMODULE m)
static inline UINT32 COLORREF_ARGB(UINT c)
{
wxGStartup = (p_wxGStartup)GetProcAddress(m, "wxGStartup");
wxGShutdown = (p_wxGShutdown)GetProcAddress(m, "wxGShutdown");
wxGMake = (p_wxGMake)GetProcAddress(m, "wxGMake");
wxGRelease = (p_wxGRelease)GetProcAddress(m, "wxGRelease");
wxGSetPageUnit = (p_wxGSetPageUnit)GetProcAddress(m, "wxGSetPageUnit");
wxGResetClip = (p_wxGResetClip)GetProcAddress(m, "wxGResetClip");
wxGSetClip = (p_wxGSetClip)GetProcAddress(m, "wxGSetClip");
wxGSave = (p_wxGSave)GetProcAddress(m, "wxGSave");
wxGRestore = (p_wxGRestore)GetProcAddress(m, "wxGRestore");
wxGResetTransform = (p_wxGResetTransform)GetProcAddress(m, "wxGResetTransform");
wxGTranslate = (p_wxGTranslate)GetProcAddress(m, "wxGTranslate");
wxGScale = (p_wxGScale)GetProcAddress(m, "wxGScale");
wxGDrawLine = (p_wxGDrawLine)GetProcAddress(m, "wxGDrawLine");
wxGDrawLines = (p_wxGDrawLines)GetProcAddress(m, "wxGDrawLines");
wxGFillRectangleColor = (p_wxGFillRectangleColor)GetProcAddress(m, "wxGFillRectangleColor");
wxGFillRectangle = (p_wxGFillRectangle)GetProcAddress(m, "wxGFillRectangle");
wxGDrawRectangle = (p_wxGDrawRectangle)GetProcAddress(m, "wxGDrawRectangle");
wxGFillPie = (p_wxGFillPie)GetProcAddress(m, "wxGFillPie");
wxGDrawArc = (p_wxGDrawArc)GetProcAddress(m, "wxGDrawArc");
wxGFillPolygon = (p_wxGFillPolygon)GetProcAddress(m, "wxGFillPolygon");
wxGDrawPolygon = (p_wxGDrawPolygon)GetProcAddress(m, "wxGDrawPolygon");
wxGFillPath = (p_wxGFillPath)GetProcAddress(m, "wxGFillPath");
wxGDrawPath = (p_wxGDrawPath)GetProcAddress(m, "wxGDrawPath");
wxGDrawString = (p_wxGDrawString)GetProcAddress(m, "wxGDrawString");
wxGMeasureString = (p_wxGMeasureString)GetProcAddress(m, "wxGMeasureString");
wxGPathNew = (p_wxGPathNew)GetProcAddress(m, "wxGPathNew");
wxGPathRelease = (p_wxGPathRelease)GetProcAddress(m, "wxGPathRelease");
wxGPathAddArc = (p_wxGPathAddArc)GetProcAddress(m, "wxGPathAddArc");
wxGPathAddPie = (p_wxGPathAddPie)GetProcAddress(m, "wxGPathAddPie");
wxGPathAddLine = (p_wxGPathAddLine)GetProcAddress(m, "wxGPathAddLine");
wxGPathAddBezier = (p_wxGPathAddBezier)GetProcAddress(m, "wxGPathAddBezier");
wxGPathAddPath = (p_wxGPathAddPath)GetProcAddress(m, "wxGPathAddPath");
wxGPathCloseFigure = (p_wxGPathCloseFigure)GetProcAddress(m, "wxGPathCloseFigure");
wxGPathTransform = (p_wxGPathTransform)GetProcAddress(m, "wxGPathTransform");
wxGMatrixNew = (p_wxGMatrixNew)GetProcAddress(m, "wxGMatrixNew");
wxGMatrixRelease = (p_wxGMatrixRelease)GetProcAddress(m, "wxGMatrixRelease");
wxGMatrixTranslate = (p_wxGMatrixTranslate)GetProcAddress(m, "wxGMatrixTranslate");
wxGMatrixScale = (p_wxGMatrixScale)GetProcAddress(m, "wxGMatrixScale");
wxGBrushNew = (p_wxGBrushNew)GetProcAddress(m, "wxGBrushNew");
wxGBrushRelease = (p_wxGBrushRelease)GetProcAddress(m, "wxGBrushRelease");
wxGPenNew = (p_wxGPenNew)GetProcAddress(m, "wxGPenNew");
wxGPenRelease = (p_wxGPenRelease)GetProcAddress(m, "wxGPenRelease");
wxGFontNew = (p_wxGFontNew)GetProcAddress(m, "wxGFontNew");
wxGFontRelease = (p_wxGFontRelease)GetProcAddress(m, "wxGFontRelease");
wxGNewStringFormat = (p_wxGNewStringFormat)GetProcAddress(m, "wxGNewStringFormat");
return (0xFF000000
| GetRValue(c) << 16
| GetGValue(c) << 8
| GetBValue(c));
}
/* Typedefs */
#define GDIPLUS_PROC_DECL(name, args) typedef GpStatus (__stdcall * name ## _t) args;
#include "wx_gdiplus.inc"
#undef GDIPLUS_PROC_DECL
/* Function ptrs: */
#define GDIPLUS_PROC_DECL(name, args) static name ## _t p ## name;
#include "wx_gdiplus.inc"
#undef GDIPLUS_PROC_DECL
/* Function ptrsookup: */
void *GetGgipProcAddress(HMODULE m, char *s)
{
void *v;
v = GetProcAddress(m, s);
if (!v) {
MessageBox(NULL, s, "GDI+ lookup failed", MB_OK);
}
return v;
}
#define GDIPLUS_PROC_DECL(name, args) p ## name = (name ## _t) GetGgipProcAddress(m, #name);
static void GetProcs(HMODULE m) {
# include "wx_gdiplus.inc"
}
#define ck(x) x
/* ********************************************************************** */
void wxInitGraphicsPlus()
{
HMODULE hm;
hm = LoadLibrary("gdiplus.dll");
if (hm) {
char *s;
/* Versioning will replace the "xxxxxxx" */
s = scheme_get_dll_path("pltgdi_xxxxxxx.dll");
hm = LoadLibrary(s);
if (hm) {
GetProcs(hm);
wx_gdi_plus = TRUE;
}
GetProcs(hm);
wx_gdi_plus = TRUE;
}
}
/* ********************************************************************** */
Graphics *wxGMake(HDC dc)
{
Graphics *g;
ck(pGdipCreateFromHDC(dc, &g));
ck(pGdipSetSmoothingMode(g, SmoothingModeHighQuality));
ck(pGdipSetPixelOffsetMode(g, PixelOffsetModeHalf));
return g;
}
void wxGRelease(Graphics *g)
{
pGdipDeleteGraphics(g);
}
void wxGSetPageUnit(Graphics *g, Unit u)
{
ck(pGdipSetPageUnit(g, u));
}
GraphicsState wxGSave(Graphics *g)
{
GraphicsState s;
pGdipSaveGraphics(g, &s);
return s;
}
void wxGRestore(Graphics *g, GraphicsState s)
{
pGdipRestoreGraphics(g, s);
}
void wxGResetClip(Graphics *g)
{
ck(pGdipResetClip(g));
}
void wxGSetClip(Graphics *g, GraphicsPath *gp, CombineMode m)
{
ck(pGdipSetClipPath(g, gp, m));
}
void wxGResetTransform(Graphics *g)
{
ck(pGdipResetWorldTransform(g));
}
void wxGTranslate(Graphics *g, double x, double y)
{
ck(pGdipTranslateWorldTransform(g, x, y, MatrixOrderPrepend));
}
void wxGScale(Graphics *g, double x, double y)
{
ck(pGdipScaleWorldTransform(g, x, y, MatrixOrderPrepend));
}
void wxGDrawLine(Graphics *g, Pen *p, double x1, double y1, double x2, double y2)
{
pGdipDrawLine(g, p, (REAL)x1, (REAL)y1, (REAL)x2, (REAL)y2);
}
void wxGDrawLines(Graphics *g, Pen *p, PointF *pts, int n)
{
pGdipDrawLines(g, p, pts, n);
}
void wxGFillRectangleColor(Graphics *g, COLORREF c, double x, double y, double w, double h)
{
Brush *b;
ck(pGdipCreateSolidFill(COLORREF_ARGB(c), &b));
ck(pGdipFillRectangle(g, b, (REAL)x, (REAL)y, (REAL)w, (REAL)h));
ck(pGdipDeleteBrush(b));
}
void wxGFillRectangle(Graphics *g, Brush *b, double x, double y, double w, double h)
{
ck(pGdipFillRectangle(g, b, (REAL)x, (REAL)y, (REAL)w, (REAL)h));
}
void wxGDrawRectangle(Graphics *g, Pen *p, double x, double y, double w, double h)
{
pGdipDrawRectangle(g, p, (REAL)x, (REAL)y, (REAL)w, (REAL)h);
}
void wxGFillPie(Graphics *g, Brush *b, double x, double y, double w, double h, double start, double span)
{
pGdipFillPie(g, b, (REAL)x, (REAL)y, (REAL)w, (REAL)h, start, span);
}
void wxGDrawArc(Graphics *g, Pen *p, double x, double y, double w, double h, double start, double span)
{
pGdipDrawArc(g, p, x, y, (REAL)w, (REAL)h, (REAL)start, (REAL)span);
}
void wxGFillPolygon(Graphics *g, Brush *b, PointF *pts, int n, FillMode m)
{
pGdipFillPolygon(g, b, pts, n, m);
}
void wxGDrawPolygon(Graphics *g, Pen *p, PointF *pts, int n)
{
pGdipDrawPolygon(g, p, pts, n);
}
void wxGFillPath(Graphics *g, Brush *b, GraphicsPath *gp)
{
pGdipFillPath(g, b, gp);
}
void wxGDrawPath(Graphics *g, Pen *p, GraphicsPath *gp)
{
pGdipDrawPath(g, p, gp);
}
GraphicsPath *wxGPathNew(FillMode m)
{
GraphicsPath *p;
pGdipCreatePath(m, &p);
return p;
}
void wxGPathRelease(GraphicsPath *gp)
{
pGdipDeletePath(gp);
}
void wxGPathAddArc(GraphicsPath *gp, double x, double y, double w, double h, double start, double span)
{
pGdipAddPathArc(gp, (REAL)x, (REAL)y, (REAL)w, (REAL)h, start, span);
}
void wxGPathAddPie(GraphicsPath *gp, double x, double y, double w, double h, double start, double span)
{
pGdipAddPathPie(gp, (REAL)x, (REAL)y, (REAL)w, (REAL)h, start, span);
}
void wxGPathAddLine(GraphicsPath *gp, double x1, double y1, double x2, double y2)
{
pGdipAddPathLine(gp, (REAL)x1, (REAL)y1, (REAL)x2, (REAL)y2);
}
void wxGPathAddBezier(GraphicsPath *gp, double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4)
{
pGdipAddPathBezier(gp, (REAL)x1, (REAL)y1, (REAL)x2, (REAL)y2,
(REAL)x3, (REAL)y3, (REAL)x4, (REAL)y4);
}
void wxGPathAddPath(GraphicsPath *gp, GraphicsPath *gp2, int conn)
{
pGdipAddPathPath(gp, gp2, conn);
}
void wxGPathCloseFigure(GraphicsPath *gp)
{
pGdipClosePathFigure(gp);
}
void wxGPathTransform(GraphicsPath *gp, Matrix *m)
{
pGdipTransformPath(gp, m);
}
Matrix *wxGMatrixNew()
{
Matrix *m;
pGdipCreateMatrix(&m);
return m;
}
void wxGMatrixRelease(Matrix *m)
{
pGdipDeleteMatrix(m);
}
void wxGMatrixTranslate(Matrix *m, double x, double y)
{
pGdipTranslateMatrix(m, (REAL)x, (REAL)y, MatrixOrderPrepend);
}
void wxGMatrixScale(Matrix *m, double x, double y)
{
pGdipScaleMatrix(m, (REAL)x, (REAL)y, MatrixOrderPrepend);
}
Brush *wxGBrushNew(COLORREF c)
{
Brush *b;
pGdipCreateSolidFill(COLORREF_ARGB(c), &b);
return b;
}
void wxGBrushRelease(Brush *b)
{
pGdipDeleteBrush(b);
}
Pen *wxGPenNew(COLORREF c, double pw, LineCap cap, LineJoin join, int ndash, REAL *dashes, REAL offset)
{
Pen *p;
pGdipCreatePen1(COLORREF_ARGB(c), pw, UnitWorld, &p);
pGdipSetPenEndCap(p, cap);
pGdipSetPenLineJoin(p, join);
pGdipSetPenDashOffset(p, offset);
pGdipSetPenDashArray(p, dashes, ndash);
return p;
}
void wxGPenRelease(Pen *p)
{
pGdipDeletePen(p);
}
Font *wxGFontNew(HDC dc)
{
Font *f;
pGdipCreateFontFromDC(dc, &f);
return f;
}
void wxGFontRelease(Font *f)
{
pGdipDeleteFont(f);
}
/* ********************************************************************** */
static ULONG_PTR gdiplusToken;
typedef void (*DebugEventProc)();
typedef struct GdiplusStartupInput {
UINT32 GdiplusVersion; // Must be 1
DebugEventProc DebugEventCallback; // Ignored on free builds
BOOL SuppressBackgroundThread; // FALSE unless you're prepared to call
// the hook/unhook functions properly
BOOL SuppressExternalCodecs; // FALSE unless you want GDI+ only to use
// its internal image codecs.
} GdiplusStartupInput;
void wxGStartup()
{
GdiplusStartupInput s;
s.GdiplusVersion = 1;
s.DebugEventCallback = NULL;
s.SuppressBackgroundThread = 0;
s.SuppressExternalCodecs = 0;
pGdiplusStartup(&gdiplusToken, &s, NULL);
}
void wxGShutdown()
{
pGdiplusShutdown(gdiplusToken);
}

View File

@ -1,259 +1,2 @@
#define WX_GRAPHICS_EXPORT extern "C" __declspec(dllexport)
#define WX_GPROC(x) x
#include <windows.h>
#include "wx_graphics.h"
/* This file effectively converts the GDI+ API from C++ to C, to make
GDI+ easier to use via LoadModule() and GetProcAddress(). */
/* ********************************************************************** */
Graphics *wxGMake(HDC dc)
{
Graphics *g;
g = new Graphics(dc);
g->SetSmoothingMode(SmoothingModeHighQuality);
g->SetPixelOffsetMode(PixelOffsetModeHalf);
return g;
}
void wxGRelease(Graphics *g)
{
delete g;
}
void wxGSetPageUnit(Graphics *g, Unit u)
{
g->SetPageUnit(u);
}
GraphicsState wxGSave(Graphics *g)
{
return g->Save();
}
void wxGRestore(Graphics *g, GraphicsState s)
{
g->Restore(s);
}
void wxGResetClip(Graphics *g)
{
g->ResetClip();
}
void wxGSetClip(Graphics *g, GraphicsPath *gp, CombineMode m)
{
g->SetClip(gp, m);
}
void wxGResetTransform(Graphics *g)
{
g->ResetTransform();
}
void wxGTranslate(Graphics *g, double x, double y)
{
g->TranslateTransform(x, y);
}
void wxGScale(Graphics *g, double x, double y)
{
g->ScaleTransform(x, y);
}
void wxGDrawLine(Graphics *g, Pen *p, double x1, double y1, double x2, double y2)
{
g->DrawLine(p, (REAL)x1, (REAL)y1, (REAL)x2, (REAL)y2);
}
void wxGDrawLines(Graphics *g, Pen *p, PointF *pts, int n)
{
g->DrawLines(p, pts, n);
}
void wxGFillRectangleColor(Graphics *g, COLORREF c, double x, double y, double w, double h)
{
Color col(255, GetRValue(c), GetGValue(c), GetBValue(c));
SolidBrush b(col);
g->FillRectangle(&b, (REAL)x, (REAL)y, (REAL)w, (REAL)h);
}
void wxGFillRectangle(Graphics *g, Brush *b, double x, double y, double w, double h)
{
g->FillRectangle(b, (REAL)x, (REAL)y, (REAL)w, (REAL)h);
}
void wxGDrawRectangle(Graphics *g, Pen *p, double x, double y, double w, double h)
{
g->DrawRectangle(p, (REAL)x, (REAL)y, (REAL)w, (REAL)h);
}
void wxGFillPie(Graphics *g, Brush *b, double x, double y, double w, double h, double start, double span)
{
g->FillPie(b, (REAL)x, (REAL)y, (REAL)w, (REAL)h, start, span);
}
void wxGDrawArc(Graphics *g, Pen *p, double x, double y, double w, double h, double start, double span)
{
g->DrawArc(p, x, y, (REAL)w, (REAL)h, (REAL)start, (REAL)span);
}
void wxGFillPolygon(Graphics *g, Brush *b, PointF *pts, int n, FillMode m)
{
g->FillPolygon(b, pts, n, m);
}
void wxGDrawPolygon(Graphics *g, Pen *p, PointF *pts, int n)
{
g->DrawPolygon(p, pts, n);
}
void wxGFillPath(Graphics *g, Brush *b, GraphicsPath *gp)
{
g->FillPath(b, gp);
}
void wxGDrawPath(Graphics *g, Pen *p, GraphicsPath *gp)
{
g->DrawPath(p, gp);
}
void wxGDrawString(Graphics *g, wchar_t *w, int len, Font *f, PointF *pos, StringFormat *fmt, COLORREF c)
{
Color col(255, GetRValue(c), GetGValue(c), GetBValue(c));
SolidBrush b(col);
g->DrawString(w, len, f, *pos, fmt, &b);
}
void wxGMeasureString(Graphics *g, wchar_t *w, int len, Font *f, PointF *pos, StringFormat *fmt, RectF *r)
{
g->MeasureString(w, len, f, *pos, fmt, r);
}
GraphicsPath *wxGPathNew(FillMode m)
{
return new GraphicsPath(m);
}
void wxGPathRelease(GraphicsPath *gp)
{
delete gp;
}
void wxGPathAddArc(GraphicsPath *gp, double x, double y, double w, double h, double start, double span)
{
gp->AddArc((REAL)x, (REAL)y, (REAL)w, (REAL)h, start, span);
}
void wxGPathAddPie(GraphicsPath *gp, double x, double y, double w, double h, double start, double span)
{
gp->AddPie((REAL)x, (REAL)y, (REAL)w, (REAL)h, start, span);
}
void wxGPathAddLine(GraphicsPath *gp, double x1, double y1, double x2, double y2)
{
gp->AddLine((REAL)x1, (REAL)y1, (REAL)x2, (REAL)y2);
}
void wxGPathAddBezier(GraphicsPath *gp, double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4)
{
gp->AddBezier((REAL)x1, (REAL)y1, (REAL)x2, (REAL)y2,
(REAL)x3, (REAL)y3, (REAL)x4, (REAL)y4);
}
void wxGPathAddPath(GraphicsPath *gp, GraphicsPath *gp2, int conn)
{
gp->AddPath(gp2, conn);
}
void wxGPathCloseFigure(GraphicsPath *gp)
{
gp->CloseFigure();
}
void wxGPathTransform(GraphicsPath *gp, Matrix *m)
{
gp->Transform(m);
}
Matrix *wxGMatrixNew()
{
return new Matrix();
}
void wxGMatrixRelease(Matrix *m)
{
delete m;
}
void wxGMatrixTranslate(Matrix *m, double x, double y)
{
m->Translate((REAL)x, (REAL)y);
}
void wxGMatrixScale(Matrix *m, double x, double y)
{
m->Scale((REAL)x, (REAL)y);
}
Brush *wxGBrushNew(COLORREF c)
{
Color col(255, GetRValue(c), GetGValue(c), GetBValue(c));
return new SolidBrush(col);
}
void wxGBrushRelease(Brush *b)
{
delete b;
}
Pen *wxGPenNew(COLORREF c, double pw, LineCap cap, LineJoin join, int ndash, REAL *dashes, REAL offset)
{
Pen *p;
Color col(255, GetRValue(c), GetGValue(c), GetBValue(c));
p = new Pen(col, pw);
p->SetEndCap(cap);
p->SetLineJoin(join);
p->SetDashOffset(offset);
p->SetDashPattern(dashes, ndash);
return p;
}
void wxGPenRelease(Pen *p)
{
delete p;
}
Font *wxGFontNew(HDC dc)
{
return new Font(dc);
}
void wxGFontRelease(Font *f)
{
delete f;
}
StringFormat *wxGNewStringFormat(int flags)
{
return new StringFormat();
}
/* ********************************************************************** */
static ULONG_PTR gdiplusToken;
void wxGStartup()
{
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
}
void wxGShutdown()
{
GdiplusShutdown(gdiplusToken);
}
/* Not used anymore. */