Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>2006-02-28 20:10:26 +0300
committerPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>2006-02-28 20:10:26 +0300
commit70fdef1c23a95d9fc5525997df5cc924f6e1df0c (patch)
tree9193d7680a0378b205e3b3401b2b05c902a3b7b9 /mcs
parent9b39547d7a8dccc4462e98a95e008e43180faacf (diff)
2006-02-28 Jonathan Chambers <jonathan.chambers@ansys.com>,
Peter Dennis Bartok <pbartok@novell.com> * Font.cs: - ToLogFont: Reworked to allow running under MS runtime and to support it being called with both boxed structs and formatted classes (MS runtime PtrToStructure cannot marshal boxed value types, but Marshal.AsAny can) - Switched all usage of LOGFONTA to more generic CharSet-driven LOGFONT structure - FromLogFont: Switched to use charset-agnostic GdipCreateFontFromLogfont * gdipStructs.cs: Dropped LOGFONTA and LOGFONTW and switched to CharSet-driven LOGFONT structure (needed because of ToLogFont fix) * gdipFunctions.cs: Switched GdipGetLogFont, GdipCreateFontFromLogfont and CreateFontIndirect to use LOGFONT structure, set to be CharSet=Auto (needed because of ToLogFont fix) svn path=/trunk/mcs/; revision=57405
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ChangeLog17
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Font.cs75
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs20
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipStructs.cs74
4 files changed, 87 insertions, 99 deletions
diff --git a/mcs/class/System.Drawing/System.Drawing/ChangeLog b/mcs/class/System.Drawing/System.Drawing/ChangeLog
index 39986582e63..22ee550ff01 100644
--- a/mcs/class/System.Drawing/System.Drawing/ChangeLog
+++ b/mcs/class/System.Drawing/System.Drawing/ChangeLog
@@ -1,3 +1,20 @@
+2006-02-28 Jonathan Chambers <jonathan.chambers@ansys.com>,
+ Peter Dennis Bartok <pbartok@novell.com>
+
+ * Font.cs:
+ - ToLogFont: Reworked to allow running under MS runtime and to
+ support it being called with both boxed structs and formatted
+ classes (MS runtime PtrToStructure cannot marshal boxed value
+ types, but Marshal.AsAny can)
+ - Switched all usage of LOGFONTA to more generic CharSet-driven
+ LOGFONT structure
+ - FromLogFont: Switched to use charset-agnostic GdipCreateFontFromLogfont
+ * gdipStructs.cs: Dropped LOGFONTA and LOGFONTW and switched to
+ CharSet-driven LOGFONT structure (needed because of ToLogFont fix)
+ * gdipFunctions.cs: Switched GdipGetLogFont, GdipCreateFontFromLogfont and
+ CreateFontIndirect to use LOGFONT structure, set to be CharSet=Auto
+ (needed because of ToLogFont fix)
+
2006-02-18 Duncan Mak <duncan@novell.com>
* Graphics.cs (DrawBeziers): Patch from Alexander Olk to fix
diff --git a/mcs/class/System.Drawing/System.Drawing/Font.cs b/mcs/class/System.Drawing/System.Drawing/Font.cs
index 0f73861eeff..4f45c85b6ef 100644
--- a/mcs/class/System.Drawing/System.Drawing/Font.cs
+++ b/mcs/class/System.Drawing/System.Drawing/Font.cs
@@ -45,7 +45,7 @@ namespace System.Drawing
{
private IntPtr fontObject = IntPtr.Zero;
private string systemFontName;
- private float _size;
+ private float _size;
private void CreateFont(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical) {
Status status;
@@ -192,7 +192,7 @@ namespace System.Drawing
IntPtr hdc;
FontStyle newStyle = FontStyle.Regular;
float newSize;
- LOGFONTA lf = new LOGFONTA ();
+ LOGFONT lf = new LOGFONT ();
// Sanity. Should we throw an exception?
if (Hfont == IntPtr.Zero) {
@@ -257,9 +257,9 @@ namespace System.Drawing
if ((int) osInfo.Platform == 128 || (int) osInfo.Platform == 4) {
return fontObject;
} else {
- LOGFONTA lf = new LOGFONTA ();
+ LOGFONT lf = new LOGFONT ();
ToLogFont(lf);
- Hfont = GDIPlus.CreateFontIndirectA (ref lf);
+ Hfont = GDIPlus.CreateFontIndirect (ref lf);
}
return Hfont;
}
@@ -368,13 +368,13 @@ namespace System.Drawing
}
}
-#if NET_2_0
- internal string SysFontName {
- set {
- systemFontName = value;
- }
- }
-#endif
+#if NET_2_0
+ internal string SysFontName {
+ set {
+ systemFontName = value;
+ }
+ }
+#endif
private bool _bold;
@@ -419,17 +419,17 @@ namespace System.Drawing
}
}
-#if NET_2_0
- [Browsable(false)]
- public bool IsSystemFont {
- get {
- if (systemFontName == null)
- return false;
-
- return StringComparer.InvariantCulture.Compare (systemFontName, string.Empty) != 0;
- }
- }
-#endif
+#if NET_2_0
+ [Browsable(false)]
+ public bool IsSystemFont {
+ get {
+ if (systemFontName == null)
+ return false;
+
+ return StringComparer.InvariantCulture.Compare (systemFontName, string.Empty) != 0;
+ }
+ }
+#endif
private bool _italic;
@@ -484,14 +484,14 @@ namespace System.Drawing
}
}
-#if NET_2_0
- [Browsable(false)]
- public string SystemFontName {
- get {
- return systemFontName;
- }
- }
-#endif
+#if NET_2_0
+ [Browsable(false)]
+ public string SystemFontName {
+ get {
+ return systemFontName;
+ }
+ }
+#endif
private bool _underline;
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
@@ -541,8 +541,8 @@ namespace System.Drawing
public static Font FromLogFont (object lf, IntPtr hdc)
{
IntPtr newObject;
- LOGFONTA o = (LOGFONTA)lf;
- GDIPlus.GdipCreateFontFromLogfontA (hdc, ref o, out newObject);
+ LOGFONT o = (LOGFONT)lf;
+ GDIPlus.GdipCreateFontFromLogfont (hdc, ref o, out newObject);
return new Font (newObject, "Microsoft Sans Serif", FontStyle.Regular, 10);
}
@@ -627,19 +627,12 @@ namespace System.Drawing
public void ToLogFont (object logFont, Graphics graphics)
{
- IntPtr lf;
-
if (graphics == null) {
throw new ArgumentNullException ("graphics");
}
- lf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LOGFONTW)));
- try {
- GDIPlus.CheckStatus (GDIPlus.GdipGetLogFontW(NativeObject, graphics.NativeObject, lf));
- Marshal.PtrToStructure(lf, logFont);
- }
- finally {
- Marshal.FreeHGlobal (lf);
+ if (Marshal.SizeOf(logFont) >= Marshal.SizeOf(typeof(LOGFONT))) {
+ GDIPlus.CheckStatus (GDIPlus.GdipGetLogFont(NativeObject, graphics.NativeObject, logFont));
}
}
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
index ae4419aeacf..9a6b1fa71b4 100644
--- a/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
+++ b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
@@ -73,7 +73,7 @@ namespace System.Drawing
// Called all pending objects and claim any pending handle before
// shutting down
GC.Collect ();
- GC.WaitForPendingFinalizers ();
+ GC.WaitForPendingFinalizers ();
// This causes crashes in MS GDI+ because this call occurs before
// all managed GDI objects are finalized. When they are finalized they call
// into a shutdown GDI+ and we crash.
@@ -1371,26 +1371,24 @@ namespace System.Drawing
internal static extern Status GdipCreateFont (IntPtr fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
[DllImport("gdiplus.dll")]
internal static extern Status GdipDeleteFont (IntPtr font);
- [DllImport("gdiplus.dll", CharSet=CharSet.Ansi)]
- internal static extern Status GdipGetLogFontA(IntPtr font, IntPtr graphics, IntPtr logfontA);
- [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
- internal static extern Status GdipGetLogFontW(IntPtr font, IntPtr graphics, IntPtr logfontW);
+ [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipGetLogFont(IntPtr font, IntPtr graphics, [MarshalAs(UnmanagedType.AsAny), Out] object logfontA);
[DllImport("gdiplus.dll")]
internal static extern Status GdipCreateFontFromDC(IntPtr hdc, out IntPtr font);
- [DllImport("gdiplus.dll", SetLastError=true)]
- internal static extern Status GdipCreateFontFromLogfontA(IntPtr hdc, ref LOGFONTA lf, out IntPtr ptr);
+ [DllImport("gdiplus.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ internal static extern Status GdipCreateFontFromLogfont(IntPtr hdc, ref LOGFONT lf, out IntPtr ptr);
// These are our private functions, they exists in our own libgdiplus library, this way we
// avoid relying on wine in System.Drawing
[DllImport("gdiplus.dll")]
internal static extern Status GdipGetHfont (IntPtr font, out IntPtr Hfont);
- [DllImport("gdiplus.dll")]
- internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONTA lf);
+ [DllImport("gdiplus.dll", CharSet=CharSet.Ansi)]
+ internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf);
// This is win32/gdi, not gdiplus, but it's easier to keep in here, also see above comment
- [DllImport("gdi32.dll", EntryPoint="CreateFontIndirectA", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
- internal static extern IntPtr CreateFontIndirectA (ref LOGFONTA logfontA);
+ [DllImport("gdi32.dll", CallingConvention=CallingConvention.StdCall, CharSet = CharSet.Auto)]
+ internal static extern IntPtr CreateFontIndirect (ref LOGFONT logfont);
[DllImport("user32.dll", EntryPoint="GetDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
internal static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll", EntryPoint="ReleaseDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
index 060f6e5399e..6d9b49294bd 100644
--- a/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
+++ b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
@@ -85,28 +85,8 @@ namespace System.Drawing
internal int to;
}
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
- internal struct LOGFONTA
- {
- internal int lfHeight;
- internal uint lfWidth;
- internal uint lfEscapement;
- internal uint lfOrientation;
- internal uint lfWeight;
- internal byte lfItalic;
- internal byte lfUnderline;
- internal byte lfStrikeOut;
- internal byte lfCharSet;
- internal byte lfOutPrecision;
- internal byte lfClipPrecision;
- internal byte lfQuality;
- internal byte lfPitchAndFamily;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
- internal string lfFaceName;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- internal struct LOGFONTW
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
+ internal struct LOGFONT
{
internal int lfHeight;
internal uint lfWidth;
@@ -182,34 +162,34 @@ namespace System.Drawing
}
}
- [StructLayout(LayoutKind.Sequential)]
- internal struct IconInfo
- {
- int fIcon;
- public int xHotspot;
- public int yHotspot;
- IntPtr hbmMask;
- IntPtr hbmColor;
-
- public bool IsIcon {
- get {
- return fIcon == 1;
- }
- }
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IconInfo
+ {
+ int fIcon;
+ public int xHotspot;
+ public int yHotspot;
+ IntPtr hbmMask;
+ IntPtr hbmColor;
+
+ public bool IsIcon {
+ get {
+ return fIcon == 1;
+ }
+ }
}
- [StructLayout(LayoutKind.Sequential)]
- internal struct XColor
- {
- public int pixel;
- public ushort red, green, blue;
- public sbyte flags;
- public sbyte pad;
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XColor
+ {
+ public int pixel;
+ public ushort red, green, blue;
+ public sbyte flags;
+ public sbyte pad;
}
- [StructLayout(LayoutKind.Sequential)]
- internal struct XVisualInfo
- {
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XVisualInfo
+ {
internal IntPtr visual;
internal int visualid;
internal int screen;
@@ -219,7 +199,7 @@ namespace System.Drawing
internal uint green_mask;
internal uint blue_mask;
internal int colormap_size;
- internal int bits_per_rgb;
+ internal int bits_per_rgb;
}
}