From 27c3f3b0ce2bb10803683473dcaa59b886b8a736 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 25 Nov 2008 18:17:30 +0000 Subject: [PATCH] Obsoleted old implementation and added compatibility layer to the new ITextPrinter. --- .../Utilities/Fonts/DisplayListTextHandle.cs | 1 + .../Utilities/Fonts/DisplayListTextPrinter.cs | 1 + Source/Utilities/Fonts/Glyph.cs | 1 + .../Utilities/Fonts/IPrinterImplementation.cs | 1 + Source/Utilities/Fonts/TextHandle.cs | 14 ++++++++++-- Source/Utilities/Fonts/TextureFont.cs | 5 +++-- Source/Utilities/Fonts/VboTextPrinter.cs | 2 ++ Source/Utilities/Graphics/ITextPrinter.cs | 9 ++++++++ Source/Utilities/Graphics/TextPrinter.cs | 22 +++++++++++++++++++ 9 files changed, 52 insertions(+), 4 deletions(-) diff --git a/Source/Utilities/Fonts/DisplayListTextHandle.cs b/Source/Utilities/Fonts/DisplayListTextHandle.cs index 192c8c7d..c1a00ebf 100644 --- a/Source/Utilities/Fonts/DisplayListTextHandle.cs +++ b/Source/Utilities/Fonts/DisplayListTextHandle.cs @@ -11,6 +11,7 @@ using OpenTK.Graphics.OpenGL; namespace OpenTK.Graphics { + [Obsolete()] class DisplayListTextHandle : TextHandle { public DisplayListTextHandle(int handle) : base(handle) { } diff --git a/Source/Utilities/Fonts/DisplayListTextPrinter.cs b/Source/Utilities/Fonts/DisplayListTextPrinter.cs index 5958dc35..835f9f1a 100644 --- a/Source/Utilities/Fonts/DisplayListTextPrinter.cs +++ b/Source/Utilities/Fonts/DisplayListTextPrinter.cs @@ -16,6 +16,7 @@ namespace OpenTK.Graphics /// /// Provides text printing through OpenGL 1.1 Display Lists. /// + [Obsolete()] class DisplayListTextPrinter : ITextPrinterImplementation { #region IPrinter Members diff --git a/Source/Utilities/Fonts/Glyph.cs b/Source/Utilities/Fonts/Glyph.cs index c64acfe5..d124e2cc 100644 --- a/Source/Utilities/Fonts/Glyph.cs +++ b/Source/Utilities/Fonts/Glyph.cs @@ -16,6 +16,7 @@ namespace OpenTK.Graphics /// /// Represents a single character of a specific Font. /// + [Obsolete] struct Glyph : IPackable { char character; diff --git a/Source/Utilities/Fonts/IPrinterImplementation.cs b/Source/Utilities/Fonts/IPrinterImplementation.cs index c849ed1f..0f901f10 100644 --- a/Source/Utilities/Fonts/IPrinterImplementation.cs +++ b/Source/Utilities/Fonts/IPrinterImplementation.cs @@ -15,6 +15,7 @@ namespace OpenTK.Graphics /// /// Defines the interface for TextPrinter implementations. /// + [Obsolete("Use ITextOutputProvider instead")] public interface ITextPrinterImplementation { /// diff --git a/Source/Utilities/Fonts/TextHandle.cs b/Source/Utilities/Fonts/TextHandle.cs index fdb48f7b..321ff14a 100644 --- a/Source/Utilities/Fonts/TextHandle.cs +++ b/Source/Utilities/Fonts/TextHandle.cs @@ -13,17 +13,27 @@ namespace OpenTK.Graphics /// /// Represents a handle to cached text. /// - public abstract class TextHandle : IDisposable + [Obsolete("Use TextPrinter.Print instead")] + public class TextHandle : IDisposable { + internal string Text; + internal System.Drawing.Font GdiPFont; + /// /// Constructs a new TextHandle, /// /// - public TextHandle(int handle) + internal TextHandle(int handle) { Handle = handle; } + internal TextHandle(string text, System.Drawing.Font font) + { + Text = text; + GdiPFont = font; + } + private int handle; protected TextureFont font; protected bool disposed; diff --git a/Source/Utilities/Fonts/TextureFont.cs b/Source/Utilities/Fonts/TextureFont.cs index 6d30ce9f..dee839de 100644 --- a/Source/Utilities/Fonts/TextureFont.cs +++ b/Source/Utilities/Fonts/TextureFont.cs @@ -21,11 +21,12 @@ namespace OpenTK.Graphics { using Graphics = System.Drawing.Graphics; using PixelFormat = OpenTK.Graphics.PixelFormat; -using System.Text.RegularExpressions; + using System.Text.RegularExpressions; + [Obsolete("Use System.Drawing.Font instead")] public class TextureFont : IFont { - Font font; + internal Font font; Dictionary loaded_glyphs = new Dictionary(64); Bitmap bmp; diff --git a/Source/Utilities/Fonts/VboTextPrinter.cs b/Source/Utilities/Fonts/VboTextPrinter.cs index 3c4a5731..f6c37a0a 100644 --- a/Source/Utilities/Fonts/VboTextPrinter.cs +++ b/Source/Utilities/Fonts/VboTextPrinter.cs @@ -17,6 +17,7 @@ namespace OpenTK.Graphics /// /// Provides text printing through OpenGL 1.5 vertex buffer objects. /// + [Obsolete] class VboTextPrinter : ITextPrinterImplementation { static int allocated_handles; @@ -84,6 +85,7 @@ namespace OpenTK.Graphics /// /// Contains the necessary information to print text through the VboTextPrinter implementation. /// + [Obsolete] class VboTextHandle : TextHandle { public VboTextHandle(int handle) : base(handle) { } diff --git a/Source/Utilities/Graphics/ITextPrinter.cs b/Source/Utilities/Graphics/ITextPrinter.cs index c39b46bf..717b2870 100644 --- a/Source/Utilities/Graphics/ITextPrinter.cs +++ b/Source/Utilities/Graphics/ITextPrinter.cs @@ -25,5 +25,14 @@ namespace OpenTK.Graphics TextExtents Measure(string text, Font font); TextExtents Measure(string text, Font font, TextPrinterOptions options); TextExtents Measure(string text, Font font, TextPrinterOptions options, RectangleF layoutRectangle); + + [Obsolete("Use TextPrinter.Print instead")] + void Draw(TextHandle handle); + + [Obsolete("Use TextPrinter.Print instead")] + void Draw(string text, TextureFont font); + + [Obsolete("Use TextPrinter.Print instead")] + void Prepare(string text, TextureFont font, out TextHandle handle); } } diff --git a/Source/Utilities/Graphics/TextPrinter.cs b/Source/Utilities/Graphics/TextPrinter.cs index 056c7a81..86d5d8a2 100644 --- a/Source/Utilities/Graphics/TextPrinter.cs +++ b/Source/Utilities/Graphics/TextPrinter.cs @@ -177,6 +177,28 @@ namespace OpenTK.Graphics #endregion + #region Obsolete + + [Obsolete("Use TextPrinter.Print instead")] + public void Draw(TextHandle handle) + { + Print(handle.Text, handle.GdiPFont); + } + + [Obsolete("Use TextPrinter.Print instead")] + public void Draw(string text, TextureFont font) + { + Print(text, font.font); + } + + [Obsolete("Use TextPrinter.Print instead")] + public void Prepare(string text, TextureFont font, out TextHandle handle) + { + handle = new TextHandle(text, font.font); + } + + #endregion + #endregion #region Private Members