1 // Gdk.Point.cs - Gdk Point class customizations
2 //
3 // Authors:
4 //	Jasper van Putten <Jaspervp@gmx.net>
5 //	Martin Willemoes Hansen <mwh@sysrq.dk>
6 //	Ben Maurer <bmaurer@novell.com>
7 // Contains lots of c&p from System.Drawing
8 //
9 // Copyright (c) 2002 Jasper van Putten
10 // Copyright (c) 2003 Martin Willemoes Hansen
11 // Copyright (c) 2005 Novell, Inc
12 //
13 // This code is inserted after the automatically generated code.
14 //
15 // This program is free software; you can redistribute it and/or
16 // modify it under the terms of version 2 of the Lesser GNU General
17 // Public License as published by the Free Software Foundation.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 // Lesser General Public License for more details.
23 //
24 // You should have received a copy of the GNU Lesser General Public
25 // License along with this program; if not, write to the
26 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 // Boston, MA 02111-1307, USA.
28 
29 namespace Gdk {
30 
31 	using System;
32 
33 	public partial struct Point {
34 
ToStringGdk.Point35 		public override string ToString ()
36 		{
37 			return String.Format ("({0},{1})", X, Y);
38 		}
39 
PointGdk.Point40 		public Point (int x, int y)
41 		{
42 			this.X = x;
43 			this.Y = y;
44 		}
45 
PointGdk.Point46 		public Point (Size sz)
47 		{
48 			this.X = sz.Width;
49 			this.Y = sz.Height;
50 		}
51 
OffsetGdk.Point52 		public void Offset (int dx, int dy)
53 		{
54 			X += dx;
55 			Y += dy;
56 		}
57 
58 		public bool IsEmpty {
59 			get {
60 				return ((X == 0) && (Y == 0));
61 			}
62 		}
63 
operator SizeGdk.Point64 		public static explicit operator Size (Point pt)
65 		{
66 			return new Size (pt.X, pt.Y);
67 		}
68 
operator +Gdk.Point69 		public static Point operator + (Point pt, Size sz)
70 		{
71 			return new Point (pt.X + sz.Width, pt.Y + sz.Height);
72 		}
73 
operator -Gdk.Point74 		public static Point operator - (Point pt, Size sz)
75 		{
76 			return new Point (pt.X - sz.Width, pt.Y - sz.Height);
77 		}
78 
operator ==Gdk.Point79 		public static bool operator == (Point pt_a, Point pt_b)
80 		{
81 			return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
82 		}
83 
operator !=Gdk.Point84 		public static bool operator != (Point pt_a, Point pt_b)
85 		{
86 			return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
87 		}
88 	}
89 }
90 
91