[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing Pens.cs,NONE,1.1 Point
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing Pens.cs,NONE,1.1 PointConverter.cs,NONE,1.1 RectangleConverter.cs,NONE,1.1 SizeConverter.cs,NONE,1.1 SystemPens.cs,NONE,1.1 TextureBrush.cs,NONE,1.1 ToolboxBitmapAttribute.cs,NONE,1.1 Brush.cs,1.1,1.2 Brushes.cs,1.1,1.2 ColorConverter.cs,1.1,1.2 Font.cs,1.1,1.2 FontFamily.cs,1.1,1.2 Graphics.cs,1.1,1.2 StringFormat.cs,1.1,1.2 SystemBrushes.cs,1.1,1.2 |
Date: |
Mon, 09 Jun 2003 17:25:39 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Drawing
In directory subversions:/tmp/cvs-serv18924/System.Drawing
Modified Files:
Brush.cs Brushes.cs ColorConverter.cs Font.cs FontFamily.cs
Graphics.cs StringFormat.cs SystemBrushes.cs
Added Files:
Pens.cs PointConverter.cs RectangleConverter.cs
SizeConverter.cs SystemPens.cs TextureBrush.cs
ToolboxBitmapAttribute.cs
Log Message:
Font management; texture brushes; some type converters;
system brushes and pens.
--- NEW FILE ---
/*
* Pens.cs - Implementation of the "System.Drawing.Pens" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
[...1005 lines suppressed...]
}
}
public static Pen Yellow
{
get
{
return
GetOrCreatePen(KnownColor.Yellow);
}
}
public static Pen YellowGreen
{
get
{
return
GetOrCreatePen(KnownColor.YellowGreen);
}
}
}; // class Pens
}; // namespace System.Drawing
--- NEW FILE ---
/*
* PointConverter.cs - Implementation of the
* "System.Drawing.Printing.PointConverter" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Drawing
{
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Collections;
public class PointConverter : TypeConverter
{
// Constructor.
public PointConverter() {}
// Determine if we can convert from a given type to "Point".
public override bool CanConvertFrom
(ITypeDescriptorContext context, Type
sourceType)
{
if(sourceType == typeof(String))
{
return true;
}
else
{
return base.CanConvertFrom(context,
sourceType);
}
}
// Determine if we can convert to a given type from "Point".
public override bool CanConvertTo
(ITypeDescriptorContext context, Type
destinationType)
{
if(destinationType ==
typeof(InstanceDescriptor))
{
return true;
}
else
{
return base.CanConvertTo(context,
destinationType);
}
}
// Convert from a source type to "Point".
public override Object ConvertFrom
(ITypeDescriptorContext context,
CultureInfo culture, Object value)
{
// Pass control to the base class if we weren't
given a string.
if(!(value is String))
{
return base.ConvertFrom(context,
culture, value);
}
// Extract the string and trim it.
String str = ((String)value).Trim();
if(str == String.Empty)
{
return null;
}
// Parse "x, y" components from the string.
String[] components = str.Split(',');
if(components.Length != 2)
{
throw new
ArgumentException(S._("Arg_InvalidPoint"));
}
TypeConverter converter;
converter =
TypeDescriptor.GetConverter(typeof(int));
int x =
(int)(converter.ConvertFrom(components[0]));
int y =
(int)(converter.ConvertFrom(components[1]));
return new Point(x, y);
}
// Convert from "Point" to a destination type.
[TODO]
public override Object ConvertTo
(ITypeDescriptorContext context,
CultureInfo culture, Object value,
Type destinationType)
{
Point point = (Point)value;
if(destinationType == typeof(String))
{
return String.Format("{0}, {1}",
point.X, point.Y);
}
else if(destinationType ==
typeof(InstanceDescriptor))
{
// TODO
return null;
}
else
{
return base.ConvertTo
(context, culture, value,
destinationType);
}
}
// Create an instance of this type of object.
public override Object CreateInstance
(ITypeDescriptorContext context, IDictionary
propertyValues)
{
return new Point((int)(propertyValues["X"]),
(int)(propertyValues["Y"]));
}
// Determine if creating new instances is supported.
public override bool GetCreateInstanceSupported
(ITypeDescriptorContext context)
{
return true;
}
// Get the properties for an object.
[TODO]
public override PropertyDescriptorCollection GetProperties
(ITypeDescriptorContext context, Object value,
Attribute[] attributes)
{
// TODO
return null;
}
// Determine if the "GetProperties" method is supported.
public override bool GetPropertiesSupported
(ITypeDescriptorContext context)
{
return true;
}
}; // class PointConverter
}; // namespace System.Drawing
--- NEW FILE ---
/*
* RectangleConverter.cs - Implementation of the
* "System.Drawing.Printing.RectangleConverter" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Drawing
{
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Collections;
public class RectangleConverter : TypeConverter
{
// Constructor.
public RectangleConverter() {}
// Determine if we can convert from a given type to "Rectangle".
public override bool CanConvertFrom
(ITypeDescriptorContext context, Type
sourceType)
{
if(sourceType == typeof(String))
{
return true;
}
else
{
return base.CanConvertFrom(context,
sourceType);
}
}
// Determine if we can convert to a given type from "Rectangle".
public override bool CanConvertTo
(ITypeDescriptorContext context, Type
destinationType)
{
if(destinationType ==
typeof(InstanceDescriptor))
{
return true;
}
else
{
return base.CanConvertTo(context,
destinationType);
}
}
// Convert from a source type to "Rectangle".
public override Object ConvertFrom
(ITypeDescriptorContext context,
CultureInfo culture, Object value)
{
// Pass control to the base class if we weren't
given a string.
if(!(value is String))
{
return base.ConvertFrom(context,
culture, value);
}
// Extract the string and trim it.
String str = ((String)value).Trim();
if(str == String.Empty)
{
return null;
}
// Parse "x, y, width, height" components from
the string.
String[] components = str.Split(',');
if(components.Length != 4)
{
throw new
ArgumentException(S._("Arg_InvalidRectangle"));
}
TypeConverter converter;
converter =
TypeDescriptor.GetConverter(typeof(int));
int x =
(int)(converter.ConvertFrom(components[0]));
int y =
(int)(converter.ConvertFrom(components[1]));
int width =
(int)(converter.ConvertFrom(components[2]));
int height =
(int)(converter.ConvertFrom(components[3]));
return new Rectangle(x, y, width, height);
}
// Convert from "Rectangle" to a destination type.
[TODO]
public override Object ConvertTo
(ITypeDescriptorContext context,
CultureInfo culture, Object value,
Type destinationType)
{
Rectangle rect = (Rectangle)value;
if(destinationType == typeof(String))
{
return String.Format("{0}, {1}, {2},
{3}",
rect.X, rect.Y,
rect.Width, rect.Height);
}
else if(destinationType ==
typeof(InstanceDescriptor))
{
// TODO
return null;
}
else
{
return base.ConvertTo
(context, culture, value,
destinationType);
}
}
// Create an instance of this type of object.
public override Object CreateInstance
(ITypeDescriptorContext context, IDictionary
propertyValues)
{
return new Rectangle((int)(propertyValues["X"]),
(int)(propertyValues["Y"]),
(int)(propertyValues["Width"]),
(int)(propertyValues["Height"]));
}
// Determine if creating new instances is supported.
public override bool GetCreateInstanceSupported
(ITypeDescriptorContext context)
{
return true;
}
// Get the properties for an object.
[TODO]
public override PropertyDescriptorCollection GetProperties
(ITypeDescriptorContext context, Object value,
Attribute[] attributes)
{
// TODO
return null;
}
// Determine if the "GetProperties" method is supported.
public override bool GetPropertiesSupported
(ITypeDescriptorContext context)
{
return true;
}
}; // class RectangleConverter
}; // namespace System.Drawing
--- NEW FILE ---
/*
* SizeConverter.cs - Implementation of the
* "System.Drawing.Printing.SizeConverter" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Drawing
{
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Collections;
public class SizeConverter : TypeConverter
{
// Constructor.
public SizeConverter() {}
// Determine if we can convert from a given type to "Size".
public override bool CanConvertFrom
(ITypeDescriptorContext context, Type
sourceType)
{
if(sourceType == typeof(String))
{
return true;
}
else
{
return base.CanConvertFrom(context,
sourceType);
}
}
// Determine if we can convert to a given type from "Size".
public override bool CanConvertTo
(ITypeDescriptorContext context, Type
destinationType)
{
if(destinationType ==
typeof(InstanceDescriptor))
{
return true;
}
else
{
return base.CanConvertTo(context,
destinationType);
}
}
// Convert from a source type to "Size".
public override Object ConvertFrom
(ITypeDescriptorContext context,
CultureInfo culture, Object value)
{
// Pass control to the base class if we weren't
given a string.
if(!(value is String))
{
return base.ConvertFrom(context,
culture, value);
}
// Extract the string and trim it.
String str = ((String)value).Trim();
if(str == String.Empty)
{
return null;
}
// Parse "width, height" components from the
string.
String[] components = str.Split(',');
if(components.Length != 2)
{
throw new
ArgumentException(S._("Arg_InvalidSize"));
}
TypeConverter converter;
converter =
TypeDescriptor.GetConverter(typeof(int));
int width =
(int)(converter.ConvertFrom(components[0]));
int height =
(int)(converter.ConvertFrom(components[1]));
return new Size(width, height);
}
// Convert from "Size" to a destination type.
[TODO]
public override Object ConvertTo
(ITypeDescriptorContext context,
CultureInfo culture, Object value,
Type destinationType)
{
Size size = (Size)value;
if(destinationType == typeof(String))
{
return String.Format("{0}, {1}",
size.Width, size.Height);
}
else if(destinationType ==
typeof(InstanceDescriptor))
{
// TODO
return null;
}
else
{
return base.ConvertTo
(context, culture, value,
destinationType);
}
}
// Create an instance of this type of object.
public override Object CreateInstance
(ITypeDescriptorContext context, IDictionary
propertyValues)
{
return new Size((int)(propertyValues["Width"]),
(int)(propertyValues["Height"]));
}
// Determine if creating new instances is supported.
public override bool GetCreateInstanceSupported
(ITypeDescriptorContext context)
{
return true;
}
// Get the properties for an object.
[TODO]
public override PropertyDescriptorCollection GetProperties
(ITypeDescriptorContext context, Object value,
Attribute[] attributes)
{
// TODO
return null;
}
// Determine if the "GetProperties" method is supported.
public override bool GetPropertiesSupported
(ITypeDescriptorContext context)
{
return true;
}
}; // class SizeConverter
}; // namespace System.Drawing
--- NEW FILE ---
/*
* SystemPens.cs - Implementation of the
* "System.Drawing.SystemPens" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Drawing
{
public sealed class SystemPens
{
// Internal state.
private static Pen[] systemPens;
// Cannot instantiate this class.
private SystemPens() {}
// Get a pen for a system color.
public static Pen FromSystemColor(Color c)
{
if(c.IsSystemColor)
{
return GetOrCreatePen(c.ToKnownColor());
}
else
{
throw new
ArgumentException(S._("Arg_NotSystemColor"));
}
}
// Get or create a system pen.
private static Pen GetOrCreatePen(KnownColor color)
{
lock(typeof(SystemPens))
{
if(systemPens == null)
{
systemPens = new Pen
[((int)(KnownColor.WindowText)) -
((int)(KnownColor.ActiveBorder)) + 1];
}
int index = ((int)color) -
((int)(KnownColor.ActiveBorder));
if(systemPens[index] == null)
{
systemPens[index] = new Pen(new
Color(color));
}
return systemPens[index];
}
}
// Standard system brush objects.
public static Pen ActiveBorder
{
get
{
return
GetOrCreatePen(KnownColor.ActiveBorder);
}
}
public static Pen ActiveCaption
{
get
{
return
GetOrCreatePen(KnownColor.ActiveCaption);
}
}
public static Pen ActiveCaptionText
{
get
{
return
GetOrCreatePen(KnownColor.ActiveCaptionText);
}
}
public static Pen AppWorkspace
{
get
{
return
GetOrCreatePen(KnownColor.AppWorkspace);
}
}
public static Pen Control
{
get
{
return
GetOrCreatePen(KnownColor.Control);
}
}
public static Pen ControlDark
{
get
{
return
GetOrCreatePen(KnownColor.ControlDark);
}
}
public static Pen ControlDarkDark
{
get
{
return
GetOrCreatePen(KnownColor.ControlDarkDark);
}
}
public static Pen ControlLight
{
get
{
return
GetOrCreatePen(KnownColor.ControlLight);
}
}
public static Pen ControlLightLight
{
get
{
return
GetOrCreatePen(KnownColor.ControlLightLight);
}
}
public static Pen ControlText
{
get
{
return
GetOrCreatePen(KnownColor.ControlText);
}
}
public static Pen Desktop
{
get
{
return
GetOrCreatePen(KnownColor.Desktop);
}
}
public static Pen GrayText
{
get
{
return
GetOrCreatePen(KnownColor.GrayText);
}
}
public static Pen Highlight
{
get
{
return
GetOrCreatePen(KnownColor.Highlight);
}
}
public static Pen HighlightText
{
get
{
return
GetOrCreatePen(KnownColor.HighlightText);
}
}
public static Pen HotTrack
{
get
{
return
GetOrCreatePen(KnownColor.HotTrack);
}
}
public static Pen InactiveBorder
{
get
{
return
GetOrCreatePen(KnownColor.InactiveBorder);
}
}
public static Pen InactiveCaption
{
get
{
return
GetOrCreatePen(KnownColor.InactiveCaption);
}
}
public static Pen InactiveCaptionText
{
get
{
return
GetOrCreatePen(KnownColor.InactiveCaptionText);
}
}
public static Pen Info
{
get
{
return GetOrCreatePen(KnownColor.Info);
}
}
public static Pen InfoText
{
get
{
return
GetOrCreatePen(KnownColor.InfoText);
}
}
public static Pen Menu
{
get
{
return GetOrCreatePen(KnownColor.Menu);
}
}
public static Pen MenuText
{
get
{
return
GetOrCreatePen(KnownColor.MenuText);
}
}
public static Pen ScrollBar
{
get
{
return
GetOrCreatePen(KnownColor.ScrollBar);
}
}
public static Pen Window
{
get
{
return
GetOrCreatePen(KnownColor.Window);
}
}
public static Pen WindowFrame
{
get
{
return
GetOrCreatePen(KnownColor.WindowFrame);
}
}
public static Pen WindowText
{
get
{
return
GetOrCreatePen(KnownColor.WindowText);
}
}
}; // class SystemPens
}; // namespace System.Drawing
--- NEW FILE ---
/*
* TextureBrush.cs - Implementation of the "System.Drawing.TextureBrush" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Drawing
{
using System.Drawing.Toolkit;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
public sealed class TextureBrush : Brush
{
// Internal state.
private Image image;
private RectangleF dstRect;
private WrapMode wrapMode;
private ImageAttributes imageAttr;
private Matrix transform;
// Constructors.
public TextureBrush(Image image)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
}
public TextureBrush(Image image, Rectangle dstRect)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
this.dstRect = (RectangleF)dstRect;
}
public TextureBrush(Image image, RectangleF dstRect)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
this.dstRect = dstRect;
}
public TextureBrush(Image image, WrapMode wrapMode)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
this.wrapMode = wrapMode;
}
public TextureBrush(Image image, Rectangle dstRect,
ImageAttributes imageAttr)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
this.dstRect = (RectangleF)dstRect;
this.imageAttr = imageAttr;
}
public TextureBrush(Image image, RectangleF dstRect,
ImageAttributes imageAttr)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
this.dstRect = dstRect;
this.imageAttr = imageAttr;
}
public TextureBrush(Image image, WrapMode wrapMode,
Rectangle dstRect)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
this.wrapMode = wrapMode;
this.dstRect = (RectangleF)dstRect;
}
public TextureBrush(Image image, WrapMode wrapMode,
RectangleF dstRect)
{
if(image == null)
{
throw new
ArgumentNullException("image");
}
this.image = image;
this.wrapMode = wrapMode;
this.dstRect = dstRect;
}
// Get the image associated with this texture brush.
public Image Image
{
get
{
return image;
}
}
// Get or set the transformation matrix.
public Matrix Transform
{
get
{
lock(this)
{
if(transform == null)
{
transform = new
Matrix();
}
return transform;
}
}
set
{
lock(this)
{
if(value == null)
{
Modified();
transform = new
Matrix();
}
else if(transform == null ||
!transform.Equals(value))
{
Modified();
transform = new
Matrix(value);
}
}
}
}
// Get or set the wrap mode.
public WrapMode WrapMode
{
get
{
return wrapMode;
}
set
{
lock(this)
{
if(wrapMode != value)
{
Modified();
wrapMode = value;
}
}
}
}
// Clone this brush.
public override Object Clone()
{
lock(this)
{
TextureBrush brush =
(TextureBrush)(MemberwiseClone());
brush.toolkit = null;
brush.toolkitBrush = null;
return brush;
}
}
// Multiply the transformation by an amount.
public void MultiplyTransform(Matrix matrix)
{
MultiplyTransform(matrix, MatrixOrder.Prepend);
}
public void MultiplyTransform(Matrix matrix, MatrixOrder order)
{
lock(this)
{
if(transform == null)
{
transform = new Matrix();
}
transform.Multiply(matrix, order);
Modified();
}
}
// Reset the brush transformation.
public void ResetTransform()
{
lock(this)
{
transform = new Matrix();
Modified();
}
}
// Rotate the transformation by an amount.
public void RotateTransform(float angle)
{
RotateTransform(angle, MatrixOrder.Prepend);
}
public void RotateTransform(float angle, MatrixOrder order)
{
lock(this)
{
if(transform == null)
{
transform = new Matrix();
}
transform.Rotate(angle, order);
Modified();
}
}
// Scale the transformation by an amount.
public void ScaleTransform(float sx, float sy)
{
ScaleTransform(sx, sy, MatrixOrder.Prepend);
}
public void ScaleTransform(float sx, float sy, MatrixOrder order)
{
lock(this)
{
if(transform == null)
{
transform = new Matrix();
}
transform.Scale(sx, sy, order);
Modified();
}
}
// Translate the transformation by an amount.
public void TranslateTransform(float dx, float dy)
{
TranslateTransform(dx, dy, MatrixOrder.Prepend);
}
public void TranslateTransform(float dx, float dy, MatrixOrder order)
{
lock(this)
{
if(transform == null)
{
transform = new Matrix();
}
transform.Translate(dx, dy, order);
Modified();
}
}
// Create this brush for a specific toolkit. Inner part of
"GetBrush()".
internal override IToolkitBrush CreateBrush(IToolkit toolkit)
{
return toolkit.CreateTextureBrush(this,
dstRect, imageAttr);
}
}; // class TextureBrush
}; // namespace System.Drawing
--- NEW FILE ---
/*
* ToolboxBitmapAttribute.cs - Implementation of the
* "System.Drawing.ToolboxBitmapAttribute" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Drawing
{
[AttributeUsage(AttributeTargets.Class)]
public class ToolboxBitmapAttribute : Attribute
{
// Internal state.
private String imageFile;
private Type t;
private String name;
// The default toolbox bitmap value.
public static readonly ToolboxBitmapAttribute Default =
new ToolboxBitmapAttribute((String)null);
// Constructors.
public ToolboxBitmapAttribute(String imageFile)
{
this.imageFile = imageFile;
}
public ToolboxBitmapAttribute(Type t)
{
this.t = t;
}
public ToolboxBitmapAttribute(Type t, String name)
{
this.t = t;
this.name = name;
}
// Determine if two objects are equal.
public override bool Equals(Object obj)
{
ToolboxBitmapAttribute other = (obj as
ToolboxBitmapAttribute);
if(other != null)
{
return (imageFile == other.imageFile &&
t == other.t && name ==
other.name);
}
else
{
return false;
}
}
// Get the hash code for this object.
public override int GetHashCode()
{
if(imageFile != null)
{
return imageFile.GetHashCode();
}
else if(name != null)
{
return name.GetHashCode();
}
else if(t != null)
{
return t.GetHashCode();
}
else
{
return 0;
}
}
// Get an image from this attribute.
public Image GetImage(Object component)
{
return GetImage(component, false);
}
public Image GetImage(Type type)
{
return GetImage(type, false);
}
[TODO]
public Image GetImage(Object component, bool large)
{
// TODO
return null;
}
[TODO]
public Image GetImage(Type type, bool large)
{
// TODO
return null;
}
[TODO]
public Image GetImage(Type type, String imgName, bool large)
{
// TODO
return null;
}
}; // class ToolboxBitmapAttribute
}; // namespace System.Drawing
Index: Brush.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Brush.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Brush.cs 7 Jun 2003 22:40:57 -0000 1.1
--- Brush.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 27,32 ****
{
// Internal state.
! private IToolkit toolkit;
! private IToolkitBrush toolkitBrush;
// Constructor.
--- 27,32 ----
{
// Internal state.
! internal IToolkit toolkit;
! internal IToolkitBrush toolkitBrush;
// Constructor.
Index: Brushes.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Brushes.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Brushes.cs 7 Jun 2003 22:40:57 -0000 1.1
--- Brushes.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 24,30 ****
public sealed class Brushes
{
! // Cannot instantiate this class.
private Brushes() {}
// Standard brush objects.
public static Brush Transparent
--- 24,54 ----
public sealed class Brushes
{
[...1842 lines suppressed...]
}
--- 1029,1033 ----
get
{
! return
GetOrCreateBrush(KnownColor.Yellow);
}
}
***************
*** 1012,1016 ****
get
{
! return new
SolidBrush(Color.YellowGreen);
}
}
--- 1036,1040 ----
get
{
! return
GetOrCreateBrush(KnownColor.YellowGreen);
}
}
Index: ColorConverter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/ColorConverter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ColorConverter.cs 7 Jun 2003 22:40:57 -0000 1.1
--- ColorConverter.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 24,27 ****
--- 24,28 ----
using System.ComponentModel;
+ using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Collections;
***************
*** 47,66 ****
// Determine if we can convert to a given type from "Color".
- [TODO]
public override bool CanConvertTo
(ITypeDescriptorContext context, Type
destinationType)
{
! // TODO
! return base.CanConvertTo(context,
destinationType);
}
// Convert from a source type to "Color".
- [TODO]
public override Object ConvertFrom
(ITypeDescriptorContext context,
CultureInfo culture, Object value)
{
! // TODO
! return null;
}
--- 48,204 ----
// Determine if we can convert to a given type from "Color".
public override bool CanConvertTo
(ITypeDescriptorContext context, Type
destinationType)
{
! if(destinationType ==
typeof(InstanceDescriptor))
! {
! return true;
! }
! else
! {
! return base.CanConvertTo(context,
destinationType);
! }
! }
!
! // Parse a number from a string.
! private static int ParseNumber(String str, ref int posn,
! bool
needComma, int invalid)
! {
! int value;
! char ch;
!
! // Process the comma between components if
necessary.
! if(needComma)
! {
! while(posn < str.Length &&
Char.IsWhiteSpace(str[posn]))
! {
! ++posn;
! }
! if(posn >= str.Length)
! {
! // There are no more components
in the string.
! return -1;
! }
! if(str[posn] != ',')
! {
! return invalid;
! }
! while(posn < str.Length &&
Char.IsWhiteSpace(str[posn]))
! {
! ++posn;
! }
! if(posn >= str.Length)
! {
! return invalid;
! }
! }
!
! // Extract the number and parse it.
! if(posn < (str.Length - 1) && str[posn] == '0'
&&
! (str[posn + 1] == 'x' || str[posn + 1] ==
'X'))
! {
! // Parse a hexadecimal constant.
! posn += 2;
! if(posn >= str.Length)
! {
! return invalid;
! }
! value = 0;
! while(posn < str.Length)
! {
! ch = str[posn];
! if(ch >= '0' && ch <= '9')
! {
! value = value * 16 +
(int)(ch - '0');
! }
! else if(ch >= 'A' && ch <= 'F')
! {
! value = value * 16 +
(int)(ch - 'A' + 10);
! }
! else if(ch >= 'a' && ch <= 'f')
! {
! value = value * 16 +
(int)(ch - 'a' + 10);
! }
! else
! {
! break;
! }
! ++posn;
! }
! return value;
! }
! else if(posn < str.Length &&
! str[posn] >= '0' && str[posn]
<= '9')
! {
! // Parse a decimal constant.
! value = (int)(str[posn] - '0');
! ++posn;
! while(posn < str.Length &&
! str[posn] >= '0' && str[posn]
<= '9')
! {
! value = value * 10 +
(int)(str[posn] - '0');
! ++posn;
! }
! return value;
! }
! else
! {
! // Don't know what this is.
! return invalid;
! }
}
// Convert from a source type to "Color".
public override Object ConvertFrom
(ITypeDescriptorContext context,
CultureInfo culture, Object value)
{
! // Pass control to the base class if we weren't
given a string.
! if(!(value is String))
! {
! return base.ConvertFrom(context,
culture, value);
! }
!
! // Extract the string and trim it.
! String str = ((String)value).Trim();
! if(str == String.Empty)
! {
! return Color.Empty;
! }
!
! // Try parsing as a named color.
! Color color = Color.FromName(str);
! if(!(color.IsEmpty))
! {
! return color;
! }
!
! // Parse "[A,] R, G, B" components from the
string.
! int[] numbers = new int [4];
! int posn = 0;
! numbers[0] = ParseNumber(str, ref posn, false,
256);
! numbers[1] = ParseNumber(str, ref posn, true,
256);
! numbers[2] = ParseNumber(str, ref posn, true,
256);
! numbers[3] = ParseNumber(str, ref posn, true,
256);
! if(numbers[0] == -1 || numbers[1] == -1 ||
numbers[2] == -1 ||
! numbers[0] >= 256 || numbers[1] >= 256 ||
! numbers[2] >= 256 || numbers[3] >= 256 ||
! posn < str.Length)
! {
! throw new
ArgumentException(S._("Arg_InvalidColor"));
! }
! if(numbers[3] == -1)
! {
! return
Color.FromArgb((byte)(numbers[0]),
!
(byte)(numbers[1]),
!
(byte)(numbers[2]));
! }
! else
! {
! return
Color.FromArgb((byte)(numbers[0]),
!
(byte)(numbers[1]),
!
(byte)(numbers[2]),
!
(byte)(numbers[3]));
! }
}
***************
*** 72,77 ****
Type destinationType)
{
! // TODO
! return null;
}
--- 210,246 ----
Type destinationType)
{
! Color color = (Color)value;
! if(destinationType == typeof(String))
! {
! if(color.IsKnownColor)
! {
! return
color.ToKnownColor().ToString();
! }
! else if(color.A == 0xFF)
! {
! return String.Format("{0}, {1},
{2}",
!
(int)(color.R),
!
(int)(color.G),
!
(int)(color.B));
! }
! else
! {
! return String.Format("{0}, {1},
{2}, {3}",
!
(int)(color.A),
!
(int)(color.R),
!
(int)(color.G),
!
(int)(color.B));
! }
! }
! else if(destinationType ==
typeof(InstanceDescriptor))
! {
! // TODO
! return null;
! }
! else
! {
! return base.ConvertTo
! (context, culture, value,
destinationType);
! }
}
Index: Font.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Font.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Font.cs 7 Jun 2003 22:40:57 -0000 1.1
--- Font.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 117,120 ****
--- 117,126 ----
gdiVerticalFont = false;
}
+ private Font(IToolkitFont font)
+ {
+ this.toolkit = toolkit;
+ this.toolkitFont = font;
+ // TODO: load the font information from the
IToolkitFont
+ }
// Destructor.
***************
*** 172,177 ****
get
{
! // TODO: convert "Size" into the
expected value.
! return 0;
}
}
--- 178,182 ----
get
{
! return (int)(Math.Ceiling(GetHeight()));
}
}
***************
*** 196,201 ****
get
{
! // TODO: get from fontFamily object.
! return null;
}
}
--- 201,205 ----
get
{
! return fontFamily.Name;
}
}
***************
*** 214,219 ****
get
{
! // TODO: convert "Size" into the
expected value.
! return 0.0f;
}
}
--- 218,262 ----
get
{
! float adjust;
! switch(unit)
! {
! case GraphicsUnit.World:
! case GraphicsUnit.Pixel:
! {
! adjust = 72.0f /
Graphics.DefaultScreenDpi;
! }
! break;
!
! case GraphicsUnit.Display:
! {
! adjust = 72.0f / 75.0f;
! }
! break;
!
! case GraphicsUnit.Point:
! {
! return size;
! }
! // Not reached.
!
! case GraphicsUnit.Inch:
! {
! adjust = 72.0f;
! }
! break;
!
! case GraphicsUnit.Document:
! {
! adjust = 72.0f / 300.0f;
! }
! break;
!
! case GraphicsUnit.Millimeter:
! {
! adjust = 72.0f / (75.0f
/ 25.4f);
! }
! break;
! }
! return size * adjust;
}
}
***************
*** 311,327 ****
// Extract the active font from a native device context.
- [TODO]
public static Font FromHdc(IntPtr hdc)
{
! // TODO
! return null;
}
// Convert a native font handle into a font object.
- [TODO]
public static Font FromHfont(IntPtr hfont)
{
! // TODO
! return null;
}
--- 354,384 ----
// Extract the active font from a native device context.
public static Font FromHdc(IntPtr hdc)
{
! IToolkitFont font;
! font =
ToolkitManager.Toolkit.GetFontFromHdc(hdc);
! if(font != null)
! {
! return new Font(font);
! }
! else
! {
! return null;
! }
}
// Convert a native font handle into a font object.
public static Font FromHfont(IntPtr hfont)
{
! IToolkitFont font;
! font =
ToolkitManager.Toolkit.GetFontFromHfont(hfont);
! if(font != null)
! {
! return new Font(font);
! }
! else
! {
! return null;
! }
}
***************
*** 331,367 ****
return FromLogFont(lf, IntPtr.Zero);
}
- [TODO]
public static Font FromLogFont(Object lf, IntPtr hdc)
{
! // TODO
! return null;
}
// Get the height of this font.
- [TODO]
public float GetHeight()
{
! // TODO
! return 0.0f;
}
- [TODO]
public float GetHeight(Graphics graphics)
{
! // TODO
! return 0.0f;
}
- [TODO]
public float GetHeight(float dpi)
{
! // TODO
! return 0.0f;
}
// Convert this object into a native font handle.
- [TODO]
public IntPtr ToHfont()
{
! // TODO
! return IntPtr.Zero;
}
--- 388,490 ----
return FromLogFont(lf, IntPtr.Zero);
}
public static Font FromLogFont(Object lf, IntPtr hdc)
{
! IToolkitFont font;
! font =
ToolkitManager.Toolkit.GetFontFromLogFont(lf, hdc);
! if(font != null)
! {
! return new Font(font);
! }
! else
! {
! return null;
! }
}
// Get the height of this font.
public float GetHeight()
{
! return GetHeight(Graphics.DefaultGraphics);
}
public float GetHeight(Graphics graphics)
{
! if(graphics == null)
! {
! throw new
ArgumentNullException("graphics");
! }
!
! // Get the font size in raw pixels.
! int pixels = graphics.GetLineSpacing(this);
!
! // If the graphics object uses pixels (the most
common case),
! // then return the pixel value directly.
! if(graphics.IsPixelUnits())
! {
! return (float)pixels;
! }
!
! // Convert the pixel value back into points.
! float points =
! ((float)pixels) /
(Graphics.DefaultScreenDpi / 72.0f);
!
! // Convert the points into the graphics
object's unit.
! switch(graphics.PageUnit)
! {
! case GraphicsUnit.World:
! case GraphicsUnit.Pixel:
! {
! points *=
(Graphics.DefaultScreenDpi / 72.0f);
! }
! break;
!
! case GraphicsUnit.Display:
! {
! points *= (75.0f / 72.0f);
! }
! break;
!
! case GraphicsUnit.Point: break;
!
! case GraphicsUnit.Inch:
! {
! points /= 72.0f;
! }
! break;
!
! case GraphicsUnit.Document:
! {
! points *= (300.0f / 72.0f);
! }
! break;
!
! case GraphicsUnit.Millimeter:
! {
! points *= (25.4f / 72.0f);
! }
! break;
! }
! return points;
}
public float GetHeight(float dpi)
{
! if(unit == GraphicsUnit.World || unit ==
GraphicsUnit.Pixel)
! {
! return
GetHeight(Graphics.DefaultGraphics);
! }
! else
! {
! return
fontFamily.GetLineSpacing(fontStyle) *
! (size /
fontFamily.GetEmHeight(fontStyle)) * dpi;
! }
}
// Convert this object into a native font handle.
public IntPtr ToHfont()
{
! if(toolkitFont == null)
! {
! GetFont(ToolkitManager.Toolkit);
! }
! return toolkitFont.GetHfont();
}
***************
*** 371,378 ****
ToLogFont(lf, null);
}
- [TODO]
public void ToLogFont(Object lf, Graphics graphics)
{
! // TODO
}
--- 494,523 ----
ToLogFont(lf, null);
}
public void ToLogFont(Object lf, Graphics graphics)
{
! IToolkitGraphics g;
! if(graphics != null)
! {
! g = graphics.ToolkitGraphics;
! }
! else
! {
! g = null;
! }
! lock(this)
! {
! if(toolkitFont == null)
! {
! if(g != null)
! {
! GetFont(g.Toolkit);
! }
! else
! {
!
GetFont(ToolkitManager.Toolkit);
! }
! }
! toolkitFont.ToLogFont(lf, g);
! }
}
Index: FontFamily.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/FontFamily.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FontFamily.cs 7 Jun 2003 22:40:57 -0000 1.1
--- FontFamily.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 23,26 ****
--- 23,27 ----
using System.Drawing.Text;
+ using System.Drawing.Toolkit;
public sealed class FontFamily : MarshalByRefObject, IDisposable
***************
*** 30,33 ****
--- 31,39 ----
private String name;
private FontCollection fontCollection;
+ private FontStyle metricsStyle;
+ private int ascent;
+ private int descent;
+ private int emHeight;
+ private int lineSpacing;
// Constructors.
***************
*** 36,39 ****
--- 42,46 ----
this.genericFamily = genericFamily;
this.fontCollection = null;
+ this.metricsStyle = (FontStyle)(-1);
switch(genericFamily)
{
***************
*** 67,70 ****
--- 74,78 ----
this.name = name;
this.fontCollection = fontCollection;
+ this.metricsStyle = (FontStyle)(-1);
// Intuit the generic family based on common
font names.
***************
*** 165,198 ****
}
// Get the cell ascent for a particular style.
- [TODO]
public int GetCellAscent(FontStyle style)
{
! // TODO
! return 0;
}
// Get the cell descent for a particular style.
- [TODO]
public int GetCellDescent(FontStyle style)
{
! // TODO
! return 0;
}
// Get the em height for a particular style.
- [TODO]
public int GetEmHeight(FontStyle style)
{
! // TODO
! return 0;
}
// Get a list of all font families with a specified graphics context.
- [TODO]
public static FontFamily[] GetFamilies(Graphics graphics)
{
! // TODO
! return null;
}
--- 173,222 ----
}
+ // Get the font family metrics.
+ private void GetMetrics(FontStyle style)
+ {
+ if(style != metricsStyle)
+ {
+
ToolkitManager.Toolkit.GetFontFamilyMetrics
+ (genericFamily, name, style,
+ out ascent, out descent,
+ out emHeight, out lineSpacing);
+ metricsStyle = style;
+ }
+ }
+
// Get the cell ascent for a particular style.
public int GetCellAscent(FontStyle style)
{
! GetMetrics(style);
! return ascent;
}
// Get the cell descent for a particular style.
public int GetCellDescent(FontStyle style)
{
! GetMetrics(style);
! return descent;
}
// Get the em height for a particular style.
public int GetEmHeight(FontStyle style)
{
! GetMetrics(style);
! return emHeight;
}
// Get a list of all font families with a specified graphics context.
public static FontFamily[] GetFamilies(Graphics graphics)
{
! if(graphics != null)
! {
! return
ToolkitManager.Toolkit.GetFontFamilies
! (graphics.ToolkitGraphics);
! }
! else
! {
! return
ToolkitManager.Toolkit.GetFontFamilies(null);
! }
}
***************
*** 204,212 ****
// Get the line spacing for a particular style.
- [TODO]
public int GetLineSpacing(FontStyle style)
{
! // TODO
! return 0;
}
--- 228,235 ----
// Get the line spacing for a particular style.
public int GetLineSpacing(FontStyle style)
{
! GetMetrics(style);
! return lineSpacing;
}
Index: Graphics.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/Graphics.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Graphics.cs 7 Jun 2003 22:40:57 -0000 1.1
--- Graphics.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 38,41 ****
--- 38,45 ----
private GraphicsUnit pageUnit;
internal GraphicsContainer stackTop;
+ internal static Graphics defaultGraphics;
+
+ // Default DPI for the screen.
+ internal const float DefaultScreenDpi = 96.0f;
// Constructor.
***************
*** 163,167 ****
else
{
! return 75.0f;
}
}
--- 167,171 ----
else
{
! return DefaultScreenDpi;
}
}
***************
*** 180,184 ****
else
{
! return 75.0f;
}
}
--- 184,188 ----
else
{
! return DefaultScreenDpi;
}
}
***************
*** 1140,1176 ****
// Draw a string.
- [TODO]
public void DrawString(String s, Font font, Brush brush, PointF point)
{
! // TODO
}
- [TODO]
public void DrawString(String s, Font font, Brush brush,
RectangleF layoutRectangle)
{
! // TODO
}
- [TODO]
public void DrawString(String s, Font font, Brush brush,
PointF point, StringFormat
format)
{
! // TODO
}
- [TODO]
public void DrawString(String s, Font font, Brush brush,
RectangleF layoutRectangle,
StringFormat format)
{
! // TODO
}
- [TODO]
public void DrawString(String s, Font font, Brush brush, float x, float
y)
{
! // TODO
}
- [TODO]
public void DrawString(String s, Font font, Brush brush,
float x, float y,
StringFormat format)
{
! // TODO
}
--- 1144,1197 ----
// Draw a string.
public void DrawString(String s, Font font, Brush brush, PointF point)
{
! DrawString(s, font, brush, point.X, point.Y,
null);
}
public void DrawString(String s, Font font, Brush brush,
RectangleF layoutRectangle)
{
! DrawString(s, font, brush, layoutRectangle,
null);
}
public void DrawString(String s, Font font, Brush brush,
PointF point, StringFormat
format)
{
! DrawString(s, font, brush, point.X, point.Y,
format);
}
public void DrawString(String s, Font font, Brush brush,
RectangleF layoutRectangle,
StringFormat format)
{
! if(s == null || s.Length == 0)
! {
! return;
! }
! Point[] rect = ConvertRectangle
! (layoutRectangle.X, layoutRectangle.Y,
! layoutRectangle.Width,
layoutRectangle.Height);
! lock(this)
! {
! SelectFont(font);
! SelectBrush(brush);
! ToolkitGraphics.DrawString(s, rect,
format);
! }
}
public void DrawString(String s, Font font, Brush brush, float x, float
y)
{
! DrawString(s, font, brush, x, y, null);
}
public void DrawString(String s, Font font, Brush brush,
float x, float y,
StringFormat format)
{
! if(s == null || s.Length == 0)
! {
! return;
! }
! int dx, dy;
! ConvertPoint(x, y, out dx, out dy);
! lock(this)
! {
! SelectFont(font);
! SelectBrush(brush);
! ToolkitGraphics.DrawString(s, dx, dy,
format);
! }
}
***************
*** 1827,1870 ****
// Measure the size of a string.
- [TODO]
public SizeF MeasureString(String text, Font font)
{
! // TODO
! return SizeF.Empty;
}
- [TODO]
public SizeF MeasureString(String text, Font font, int width)
{
! // TODO
! return SizeF.Empty;
}
- [TODO]
public SizeF MeasureString(String text, Font font, SizeF layoutArea)
{
! // TODO
! return SizeF.Empty;
}
- [TODO]
public SizeF MeasureString(String text, Font font,
int width,
StringFormat format)
{
! // TODO
! return SizeF.Empty;
}
- [TODO]
public SizeF MeasureString(String text, Font font,
PointF origin,
StringFormat format)
{
! // TODO
! return SizeF.Empty;
}
- [TODO]
public SizeF MeasureString(String text, Font font,
SizeF layoutArea,
StringFormat format)
{
! // TODO
! return SizeF.Empty;
}
- [TODO]
public SizeF MeasureString(String text, Font font,
SizeF layoutArea,
StringFormat format,
--- 1848,1883 ----
// Measure the size of a string.
public SizeF MeasureString(String text, Font font)
{
! return MeasureString(text, font, new
SizeF(0.0f, 0.0f), null);
}
public SizeF MeasureString(String text, Font font, int width)
{
! return MeasureString
! (text, font, new SizeF(width,
999999.0f), null);
}
public SizeF MeasureString(String text, Font font, SizeF layoutArea)
{
! return MeasureString(text, font, layoutArea,
null);
}
public SizeF MeasureString(String text, Font font,
int width,
StringFormat format)
{
! return MeasureString
! (text, font, new SizeF(width,
999999.0f), format);
}
public SizeF MeasureString(String text, Font font,
PointF origin,
StringFormat format)
{
! return MeasureString
! (text, font, new SizeF(0.0f, 0.0f),
format);
}
public SizeF MeasureString(String text, Font font,
SizeF layoutArea,
StringFormat format)
{
! int charactersFitted, linesFilled;
! return MeasureString(text, font, layoutArea,
format,
! out
charactersFitted, out linesFilled);
}
public SizeF MeasureString(String text, Font font,
SizeF layoutArea,
StringFormat format,
***************
*** 1872,1877 ****
out int linesFilled)
{
! // TODO
! return SizeF.Empty;
}
--- 1885,1904 ----
out int linesFilled)
{
! if(text == null || text == String.Empty)
! {
! charactersFitted = 0;
! linesFilled = 0;
! return new SizeF(0.0f, 0.0f);
! }
! Point[] rect = ConvertRectangle
! (0.0f, 0.0f, layoutArea.Width,
layoutArea.Height);
! lock(this)
! {
! SelectFont(font);
! Size size =
ToolkitGraphics.MeasureString
! (text, rect, format,
! out charactersFitted, out
linesFilled);
! return new
SizeF(ConvertSizeBack(size.Width, size.Height));
! }
}
***************
*** 2372,2377 ****
case GraphicsUnit.Millimeter:
{
! adjustX = DpiX / 24.5f;
! adjustY = DpiY / 24.5f;
}
break;
--- 2399,2404 ----
case GraphicsUnit.Millimeter:
{
! adjustX = DpiX / 25.4f;
! adjustY = DpiY / 25.4f;
}
break;
***************
*** 2447,2452 ****
case GraphicsUnit.Millimeter:
{
! adjustX = DpiX / 24.5f;
! adjustY = DpiY / 24.5f;
}
break;
--- 2474,2479 ----
case GraphicsUnit.Millimeter:
{
! adjustX = DpiX / 25.4f;
! adjustY = DpiY / 25.4f;
}
break;
***************
*** 2543,2548 ****
}
// Get the toolkit graphics object underlying this object.
! private IToolkitGraphics ToolkitGraphics
{
get
--- 2570,2658 ----
}
+ // Convert a size value from device co-ordinates to graphics units.
+ private SizeF ConvertSizeBack(int width, int height)
+ {
+ float newX, newY, adjustX, adjustY;
+
+ // Bail out early if the context is using pixel
units.
+ if(IsPixelUnits())
+ {
+ return new SizeF((float)width,
(float)height);
+ }
+
+ // Apply the page unit to get page co-ordinates.
+ newX = (float)width;
+ newY = (float)height;
+ switch(pageUnit)
+ {
+ case GraphicsUnit.World:
+ case GraphicsUnit.Pixel:
+ default:
+ {
+ adjustX = 1.0f;
+ adjustY = 1.0f;
+ }
+ break;
+
+ case GraphicsUnit.Display:
+ {
+ adjustX = DpiX / 75.0f;
+ adjustY = DpiY / 75.0f;
+ }
+ break;
+
+ case GraphicsUnit.Point:
+ {
+ adjustX = DpiX / 72.0f;
+ adjustY = DpiY / 72.0f;
+ }
+ break;
+
+ case GraphicsUnit.Inch:
+ {
+ adjustX = DpiX;
+ adjustY = DpiY;
+ }
+ break;
+
+ case GraphicsUnit.Document:
+ {
+ adjustX = DpiX / 300.0f;
+ adjustY = DpiY / 300.0f;
+ }
+ break;
+
+ case GraphicsUnit.Millimeter:
+ {
+ adjustX = DpiX / 25.4f;
+ adjustY = DpiY / 25.4f;
+ }
+ break;
+ }
+ newX /= adjustX;
+ newY /= adjustY;
+
+ // Apply the inverse of the page scale factor.
+ if(pageScale != 1.0f)
+ {
+ newX /= pageScale;
+ newY /= pageScale;
+ }
+
+ // Apply the inverse of the world transform.
+ if(transform != null)
+ {
+ transform.TransformSizeBack
+ (newX, newY, out adjustX, out
adjustY);
+ return new SizeF(adjustX, adjustY);
+ }
+ else
+ {
+ return new SizeF(newX, newY);
+ }
+ }
+
// Get the toolkit graphics object underlying this object.
! internal IToolkitGraphics ToolkitGraphics
{
get
***************
*** 2556,2559 ****
--- 2666,2687 ----
}
+ // Get the default graphics object for the current toolkit.
+ internal static Graphics DefaultGraphics
+ {
+ get
+ {
+ lock(typeof(Graphics))
+ {
+ if(defaultGraphics == null)
+ {
+ defaultGraphics = new
Graphics
+
(ToolkitManager.Toolkit.GetDefaultGraphics());
+
defaultGraphics.PageUnit = GraphicsUnit.Pixel;
+ }
+ return defaultGraphics;
+ }
+ }
+ }
+
// Select a pen into the toolkit graphics object.
private void SelectPen(Pen pen)
***************
*** 2567,2571 ****
throw new
ObjectDisposedException("graphics");
}
- IToolkit toolkit = graphics.Toolkit;
IToolkitPen tpen = pen.GetPen(graphics.Toolkit);
tpen.Select(graphics);
--- 2695,2698 ----
***************
*** 2587,2594 ****
--- 2714,2758 ----
}
+ // Select a font into the toolkit graphics object.
+ private void SelectFont(Font font)
+ {
+ if(font == null)
+ {
+ throw new ArgumentNullException("font");
+ }
+ if(graphics == null)
+ {
+ throw new
ObjectDisposedException("graphics");
+ }
+ IToolkitFont tfont =
font.GetFont(graphics.Toolkit);
+ tfont.Select(graphics);
+ }
+
// Update the clipping region within the IToolkitGraphics object.
private void UpdateClip()
{
// TODO
+ }
+
+ // Determine if this graphics object is using 1-to-1 pixel mappings.
+ internal bool IsPixelUnits()
+ {
+ if((pageUnit == GraphicsUnit.Pixel ||
+ pageUnit == GraphicsUnit.World) &&
+ transform == null && pageScale == 1.0f)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ // Get the line spacing of a font, in pixels.
+ internal int GetLineSpacing(Font font)
+ {
+ lock(this)
+ {
+ SelectFont(font);
+ return ToolkitGraphics.GetLineSpacing();
+ }
}
Index: StringFormat.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/StringFormat.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** StringFormat.cs 7 Jun 2003 22:40:57 -0000 1.1
--- StringFormat.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 23,30 ****
using System.Drawing.Toolkit;
! public class StringFormat
{
! // TODO
}; // class StringFormat
--- 23,224 ----
using System.Drawing.Toolkit;
+ using System.Drawing.Text;
! public sealed class StringFormat
! : MarshalByRefObject, ICloneable, IDisposable
{
! // Internal state.
! private StringFormatFlags options;
! private int language;
! private StringAlignment alignment;
! private StringDigitSubstitute digitMethod;
! private HotkeyPrefix hotkeyPrefix;
! private StringAlignment lineAlignment;
! private StringTrimming trimming;
! private CharacterRange[] ranges;
! private float firstTabOffset;
! private float[] tabStops;
! private static StringFormat genericDefault = new StringFormat();
! private static StringFormat genericTypographic = new StringFormat();
!
! // Constructors.
! public StringFormat() {}
! public StringFormat(StringFormat format)
! {
! if(format == null)
! {
! throw new
ArgumentNullException("format");
! }
! this.options = format.options;
! this.language = format.language;
! this.alignment = format.alignment;
! this.digitMethod = format.digitMethod;
! this.hotkeyPrefix = format.hotkeyPrefix;
! this.lineAlignment = format.lineAlignment;
! this.trimming = format.trimming;
! this.ranges = ranges;
! this.firstTabOffset = format.firstTabOffset;
! this.tabStops = tabStops;
! }
! public StringFormat(StringFormatFlags options)
! {
! this.options = options;
! }
! public StringFormat(StringFormatFlags options, int language)
! {
! this.options = options;
! this.language = language;
! }
!
! // Destructor.
! ~StringFormat()
! {
! // Nothing to do here in this implementation.
! }
!
! // Get or set this object's properties.
! public StringAlignment Alignment
! {
! get
! {
! return alignment;
! }
! set
! {
! alignment = value;
! }
! }
! public int DigitSubstitutionLanguage
! {
! get
! {
! return language;
! }
! }
! public StringDigitSubstitute DigitSubstitutionMethod
! {
! get
! {
! return digitMethod;
! }
! set
! {
! digitMethod = value;
! }
! }
! public StringFormatFlags FormatFlags
! {
! get
! {
! return options;
! }
! set
! {
! options = value;
! }
! }
! public HotkeyPrefix HotkeyPrefix
! {
! get
! {
! return hotkeyPrefix;
! }
! set
! {
! hotkeyPrefix = value;
! }
! }
! public StringAlignment LineAlignment
! {
! get
! {
! return lineAlignment;
! }
! set
! {
! lineAlignment = value;
! }
! }
! public StringTrimming Trimming
! {
! get
! {
! return trimming;
! }
! set
! {
! trimming = value;
! }
! }
!
! // Get the generic default string format.
! public static StringFormat GenericDefault
! {
! get
! {
! return genericDefault;
! }
! }
!
! // Get the generic typographic string format.
! public static StringFormat GenericTypographic
! {
! get
! {
! return genericTypographic;
! }
! }
!
! // Clone this object.
! public Object Clone()
! {
! return new StringFormat(this);
! }
!
! // Dispose of this object.
! public void Dispose()
! {
! // Nothing to do here in this implementation.
! }
!
! // Get tab stop information for this format.
! public float[] GetTopStops(out float firstTabOffset)
! {
! if(this.tabStops == null)
! {
! this.firstTabOffset = 8.0f;
! this.tabStops = new float [] {8.0f};
! }
! firstTabOffset = this.firstTabOffset;
! return this.tabStops;
! }
!
! // Set the digit substitution properties.
! public void SetDigitSubstitution
! (int language, StringDigitSubstitute substitute)
! {
! this.language = language;
! this.digitMethod = digitMethod;
! }
!
! // Set the measurable character ranges.
! public void SetMeasurableCharacterRanges(CharacterRange[] ranges)
! {
! this.ranges = ranges;
! }
!
! // Set the tab stops for this format.
! public void SetTabStops(float firstTabOffset, float[] tabStops)
! {
! this.firstTabOffset = firstTabOffset;
! this.tabStops = tabStops;
! }
!
! // Convert this object into a string.
! public override String ToString()
! {
! return "[StringFormat, FormatFlags=" +
! options.ToString() + "]";
! }
}; // class StringFormat
Index: SystemBrushes.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Drawing/SystemBrushes.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SystemBrushes.cs 7 Jun 2003 22:40:57 -0000 1.1
--- SystemBrushes.cs 9 Jun 2003 21:25:37 -0000 1.2
***************
*** 25,28 ****
--- 25,31 ----
public sealed class SystemBrushes
{
+ // Internal state.
+ private static Brush[] systemBrushes;
+
// Cannot instantiate this class.
private SystemBrushes() {}
***************
*** 31,35 ****
public static Brush FromSystemColor(Color c)
{
! return new SolidBrush(c);
}
--- 34,66 ----
public static Brush FromSystemColor(Color c)
{
! if(c.IsSystemColor)
! {
! return
GetOrCreateBrush(c.ToKnownColor());
! }
! else
! {
! throw new
ArgumentException(S._("Arg_NotSystemColor"));
! }
! }
!
! // Get or create a system brush.
! private static Brush GetOrCreateBrush(KnownColor color)
! {
! lock(typeof(SystemBrushes))
! {
! if(systemBrushes == null)
! {
! systemBrushes = new Brush
!
[((int)(KnownColor.WindowText)) -
!
((int)(KnownColor.ActiveBorder)) + 1];
! }
! int index = ((int)color) -
((int)(KnownColor.ActiveBorder));
! if(systemBrushes[index] == null)
! {
! systemBrushes[index]
! = new SolidBrush(new
Color(color));
! }
! return systemBrushes[index];
! }
}
***************
*** 39,43 ****
get
{
! return new
SolidBrush(SystemColors.ActiveBorder);
}
}
--- 70,74 ----
get
{
! return
GetOrCreateBrush(KnownColor.ActiveBorder);
}
}
***************
*** 46,50 ****
get
{
! return new
SolidBrush(SystemColors.ActiveCaption);
}
}
--- 77,81 ----
get
{
! return
GetOrCreateBrush(KnownColor.ActiveCaption);
}
}
***************
*** 53,57 ****
get
{
! return new
SolidBrush(SystemColors.ActiveCaptionText);
}
}
--- 84,88 ----
get
{
! return
GetOrCreateBrush(KnownColor.ActiveCaptionText);
}
}
***************
*** 60,64 ****
get
{
! return new
SolidBrush(SystemColors.AppWorkspace);
}
}
--- 91,95 ----
get
{
! return
GetOrCreateBrush(KnownColor.AppWorkspace);
}
}
***************
*** 67,71 ****
get
{
! return new
SolidBrush(SystemColors.Control);
}
}
--- 98,102 ----
get
{
! return
GetOrCreateBrush(KnownColor.Control);
}
}
***************
*** 74,78 ****
get
{
! return new
SolidBrush(SystemColors.ControlDark);
}
}
--- 105,109 ----
get
{
! return
GetOrCreateBrush(KnownColor.ControlDark);
}
}
***************
*** 81,85 ****
get
{
! return new
SolidBrush(SystemColors.ControlDarkDark);
}
}
--- 112,116 ----
get
{
! return
GetOrCreateBrush(KnownColor.ControlDarkDark);
}
}
***************
*** 88,92 ****
get
{
! return new
SolidBrush(SystemColors.ControlLight);
}
}
--- 119,123 ----
get
{
! return
GetOrCreateBrush(KnownColor.ControlLight);
}
}
***************
*** 95,99 ****
get
{
! return new
SolidBrush(SystemColors.ControlLightLight);
}
}
--- 126,130 ----
get
{
! return
GetOrCreateBrush(KnownColor.ControlLightLight);
}
}
***************
*** 102,106 ****
get
{
! return new
SolidBrush(SystemColors.ControlText);
}
}
--- 133,137 ----
get
{
! return
GetOrCreateBrush(KnownColor.ControlText);
}
}
***************
*** 109,113 ****
get
{
! return new
SolidBrush(SystemColors.Desktop);
}
}
--- 140,144 ----
get
{
! return
GetOrCreateBrush(KnownColor.Desktop);
}
}
***************
*** 116,120 ****
get
{
! return new
SolidBrush(SystemColors.GrayText);
}
}
--- 147,151 ----
get
{
! return
GetOrCreateBrush(KnownColor.GrayText);
}
}
***************
*** 123,127 ****
get
{
! return new
SolidBrush(SystemColors.Highlight);
}
}
--- 154,158 ----
get
{
! return
GetOrCreateBrush(KnownColor.Highlight);
}
}
***************
*** 130,134 ****
get
{
! return new
SolidBrush(SystemColors.HighlightText);
}
}
--- 161,165 ----
get
{
! return
GetOrCreateBrush(KnownColor.HighlightText);
}
}
***************
*** 137,141 ****
get
{
! return new
SolidBrush(SystemColors.HotTrack);
}
}
--- 168,172 ----
get
{
! return
GetOrCreateBrush(KnownColor.HotTrack);
}
}
***************
*** 144,148 ****
get
{
! return new
SolidBrush(SystemColors.InactiveBorder);
}
}
--- 175,179 ----
get
{
! return
GetOrCreateBrush(KnownColor.InactiveBorder);
}
}
***************
*** 151,155 ****
get
{
! return new
SolidBrush(SystemColors.InactiveCaption);
}
}
--- 182,186 ----
get
{
! return
GetOrCreateBrush(KnownColor.InactiveCaption);
}
}
***************
*** 158,162 ****
get
{
! return new
SolidBrush(SystemColors.InactiveCaptionText);
}
}
--- 189,193 ----
get
{
! return
GetOrCreateBrush(KnownColor.InactiveCaptionText);
}
}
***************
*** 165,169 ****
get
{
! return new
SolidBrush(SystemColors.Info);
}
}
--- 196,200 ----
get
{
! return
GetOrCreateBrush(KnownColor.Info);
}
}
***************
*** 172,176 ****
get
{
! return new
SolidBrush(SystemColors.InfoText);
}
}
--- 203,207 ----
get
{
! return
GetOrCreateBrush(KnownColor.InfoText);
}
}
***************
*** 179,183 ****
get
{
! return new
SolidBrush(SystemColors.Menu);
}
}
--- 210,214 ----
get
{
! return
GetOrCreateBrush(KnownColor.Menu);
}
}
***************
*** 186,190 ****
get
{
! return new
SolidBrush(SystemColors.MenuText);
}
}
--- 217,221 ----
get
{
! return
GetOrCreateBrush(KnownColor.MenuText);
}
}
***************
*** 193,197 ****
get
{
! return new
SolidBrush(SystemColors.ScrollBar);
}
}
--- 224,228 ----
get
{
! return
GetOrCreateBrush(KnownColor.ScrollBar);
}
}
***************
*** 200,204 ****
get
{
! return new
SolidBrush(SystemColors.Window);
}
}
--- 231,235 ----
get
{
! return
GetOrCreateBrush(KnownColor.Window);
}
}
***************
*** 207,211 ****
get
{
! return new
SolidBrush(SystemColors.WindowFrame);
}
}
--- 238,242 ----
get
{
! return
GetOrCreateBrush(KnownColor.WindowFrame);
}
}
***************
*** 214,218 ****
get
{
! return new
SolidBrush(SystemColors.WindowText);
}
}
--- 245,249 ----
get
{
! return
GetOrCreateBrush(KnownColor.WindowText);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing Pens.cs,NONE,1.1 PointConverter.cs,NONE,1.1 RectangleConverter.cs,NONE,1.1 SizeConverter.cs,NONE,1.1 SystemPens.cs,NONE,1.1 TextureBrush.cs,NONE,1.1 ToolboxBitmapAttribute.cs,NONE,1.1 Brush.cs,1.1,1.2 Brushes.cs,1.1,1.2 ColorConverter.cs,1.1,1.2 Font.cs,1.1,1.2 FontFamily.cs,1.1,1.2 Graphics.cs,1.1,1.2 StringFormat.cs,1.1,1.2 SystemBrushes.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing/Printing PrinterUnitConvert.cs,1.1,1.2
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp FontStyle.cs,1.1,1.2 XsharpSupport.c,1.3,1.4
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/System.Drawing/Printing PrinterUnitConvert.cs,1.1,1.2
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp FontStyle.cs,1.1,1.2 XsharpSupport.c,1.3,1.4
- Index(es):