On Tuesday 01 February 2011 09:49:46 am Iain Arnell wrote:
To fix inclusion of gdiplus.h under C++, this patch:
- adds missing class declaration for GpPen
- adds missing class declaration for CharacterRange
- fixes PenAlignment/GpPenAlignment declaration
- avoids redeclaration of PixelFormat
Simple testcase:
cat >test.cpp <<EOF #include <windows.h> #include <gdiplus.h> EOF wineg++ -c test.cpp
include/gdiplusenums.h | 2 +- include/gdiplusgpstubs.h | 2 ++ include/gdiplusimaging.h | 4 ++-- include/gdiplustypes.h | 25 +++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/include/gdiplusenums.h b/include/gdiplusenums.h index 82f20eb..dc03b29 100644 --- a/include/gdiplusenums.h +++ b/include/gdiplusenums.h @@ -734,7 +734,7 @@ typedef enum StringTrimming StringTrimming; typedef enum FontStyle FontStyle; typedef enum StringFormatFlags StringFormatFlags; typedef enum HotkeyPrefix HotkeyPrefix; -typedef enum PenAlignment GpPenAlignment; +typedef enum PenAlignment PenAlignment; typedef enum PaletteFlags PaletteFlags; typedef enum ImageCodecFlags ImageCodecFlags; typedef enum CombineMode CombineMode; diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h index 3edc1f4..5a65cd8 100644 --- a/include/gdiplusgpstubs.h +++ b/include/gdiplusgpstubs.h @@ -22,6 +22,7 @@ #ifdef __cplusplus
class GpGraphics {}; +class GpPen {}; class GpBrush {}; class GpHatch : public GpBrush {}; class GpSolidFill : public GpBrush {}; @@ -92,6 +93,7 @@ typedef WrapMode GpWrapMode; typedef Color GpColor; typedef FlushIntention GpFlushIntention; typedef CoordinateSpace GpCoordinateSpace; +typedef PenAlignment GpPenAlignment; typedef PenType GpPenType;
#endif diff --git a/include/gdiplusimaging.h b/include/gdiplusimaging.h index 42a00cb..3e9f6ee 100644 --- a/include/gdiplusimaging.h +++ b/include/gdiplusimaging.h @@ -110,7 +110,7 @@ public: UINT Width; UINT Height; INT Stride;
- PixelFormat PixelFormat;
- INT PixelFormat; /* MSDN: "PixelFormat PixelFormat;" */ VOID* Scan0; UINT_PTR Reserved;
}; @@ -177,7 +177,7 @@ typedef struct BitmapData UINT Width; UINT Height; INT Stride;
- PixelFormat PixelFormat;
- INT PixelFormat; /* MSDN: "PixelFormat PixelFormat;" */ VOID* Scan0; UINT_PTR Reserved; /* undocumented: stores the lock mode */
} BitmapData; diff --git a/include/gdiplustypes.h b/include/gdiplustypes.h index 4f97432..b84c74e 100644 --- a/include/gdiplustypes.h +++ b/include/gdiplustypes.h @@ -199,6 +199,31 @@ public: INT Height; };
+class CharacterRange +{ +public:
- CharacterRange()
- {
First = Length = 0;
- }
- CharacterRange(IN INT first, IN INT length)
- {
First = first;
Length = length;
- }
- CharacterRange& operator=(IN const CharacterRange& rhs)
- {
First = rhs.First;
Length = rhs.Length;
return *this;
- }
+public:
- INT First;
- INT Length;
+};
#else /* end of c++ typedefs */
typedef struct Point
Wouldn't be better to wrap the offending C with:
#ifdef __cplusplus extern "C" { #endif
...
#ifdef __cplusplus } #endif
On Tue, Feb 1, 2011 at 10:28 AM, Paul Chitescu paulc@voip.null.ro wrote:
On Tuesday 01 February 2011 09:49:46 am Iain Arnell wrote:
To fix inclusion of gdiplus.h under C++, this patch:
- adds missing class declaration for GpPen
- adds missing class declaration for CharacterRange
- fixes PenAlignment/GpPenAlignment declaration
- avoids redeclaration of PixelFormat
[snip the patch]
Wouldn't be better to wrap the offending C with:
#ifdef __cplusplus extern "C" { #endif
...
#ifdef __cplusplus } #endif
It's not a matter of offending C code; just that the C++ in these headers has bitrotted over the years as the code has changed.