2004-03-16 Mike Kestner <mkestner@ximian.com>
* gdk/Makefile.am : add new file. * gdk/Size.cs : implementation of a Size value type. svn path=/trunk/gtk-sharp/; revision=24164
This commit is contained in:
parent
7cf239155e
commit
c1878dd859
3 changed files with 107 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-03-16 Mike Kestner <mkestner@ximian.com>
|
||||
|
||||
* gdk/Makefile.am : add new file.
|
||||
* gdk/Size.cs : implementation of a Size value type.
|
||||
|
||||
2004-03-16 Mike Kestner <mkestner@ximian.com>
|
||||
|
||||
* generator/Signal.cs : remove a C.WL.
|
||||
|
|
|
@ -33,7 +33,8 @@ sources = \
|
|||
EventSetting.cs \
|
||||
EventVisibility.cs \
|
||||
EventWindowState.cs \
|
||||
Key.cs
|
||||
Key.cs \
|
||||
Size.cs
|
||||
|
||||
build_sources = $(addprefix $(srcdir)/, $(sources))
|
||||
|
||||
|
|
100
gdk/Size.cs
Normal file
100
gdk/Size.cs
Normal file
|
@ -0,0 +1,100 @@
|
|||
// Size.cs
|
||||
//
|
||||
// Author: Mike Kestner (mkestner@speakeasy.net)
|
||||
//
|
||||
// (C) 2001 Mike Kestner
|
||||
|
||||
using System;
|
||||
|
||||
namespace Gdk {
|
||||
|
||||
public struct Size {
|
||||
|
||||
int width, height;
|
||||
|
||||
public static readonly Size Empty;
|
||||
|
||||
public static Size operator + (Size sz1, Size sz2)
|
||||
{
|
||||
return new Size (sz1.Width + sz2.Width,
|
||||
sz1.Height + sz2.Height);
|
||||
}
|
||||
|
||||
public static bool operator == (Size sz_a, Size sz_b)
|
||||
{
|
||||
return ((sz_a.Width == sz_b.Width) &&
|
||||
(sz_a.Height == sz_b.Height));
|
||||
}
|
||||
|
||||
public static bool operator != (Size sz_a, Size sz_b)
|
||||
{
|
||||
return ((sz_a.Width != sz_b.Width) ||
|
||||
(sz_a.Height != sz_b.Height));
|
||||
}
|
||||
|
||||
public static Size operator - (Size sz1, Size sz2)
|
||||
{
|
||||
return new Size (sz1.Width - sz2.Width,
|
||||
sz1.Height - sz2.Height);
|
||||
}
|
||||
|
||||
public static explicit operator Point (Size sz)
|
||||
{
|
||||
return new Point (sz.Width, sz.Height);
|
||||
}
|
||||
|
||||
public Size (Point pt)
|
||||
{
|
||||
width = pt.X;
|
||||
height = pt.Y;
|
||||
}
|
||||
|
||||
public Size (int width, int height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public bool IsEmpty {
|
||||
get {
|
||||
return ((width == 0) && (height == 0));
|
||||
}
|
||||
}
|
||||
|
||||
public int Width {
|
||||
get {
|
||||
return width;
|
||||
}
|
||||
set {
|
||||
width = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Height {
|
||||
get {
|
||||
return height;
|
||||
}
|
||||
set {
|
||||
height = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is Size))
|
||||
return false;
|
||||
|
||||
return (this == (Size) o);
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return width^height;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("{{Width={0}, Height={1}}}", width, height);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue