This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / DataGridCell.cs
1 //
2 // System.Windows.Forms.DataGridCell.cs
3 //
4 // Author:
5 //   Dennis Hayes (dennish@raytek.com)
6 //
7 // (C) 2002 Ximian, Inc.  http://www.ximian.com
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32
33 namespace System.Windows.Forms {
34         
35         public struct DataGridCell { 
36
37                 private int rownumber;
38                 private int columnnumber;
39
40                 // -----------------------
41                 // Public Constructor
42                 // -----------------------
43
44                 /// <summary>
45                 /// 
46                 /// </summary>
47                 ///
48                 /// <remarks>
49                 ///
50                 /// </remarks>
51                 
52                 public DataGridCell (int r, int c)
53                 {
54                         rownumber = r;
55                         columnnumber = c;
56                 }
57
58                 // -----------------------
59                 // Public Shared Members
60                 // -----------------------
61
62                 /// <remarks>
63                 ///     Compares two DataGridCell objects. The return value is
64                 ///     based on the equivalence of the RowNumber and ColumnNumber properties of the two objects.
65                 /// </remarks>
66
67                 public static bool operator == (DataGridCell dgc_a, 
68                         DataGridCell dgc_b) {
69
70                         return ((dgc_a.rownumber == dgc_b.rownumber) &&
71                                 (dgc_a.columnnumber == dgc_b.columnnumber));
72                 }
73                 
74                 /// <summary>
75                 ///     Inequality Operator
76                 /// </summary>
77                 ///
78                 /// <remarks>
79                 ///     Compares two DataGridCell objects. The return value is
80                 ///     based on the equivalence of the RowNumber and ColumnNumber properties of the two objects.
81                 /// </remarks>
82                 public static bool operator != (DataGridCell dgc_a, 
83                         DataGridCell dgc_b) {
84                         return ((dgc_a.rownumber != dgc_b.rownumber) ||
85                                 (dgc_a.columnnumber != dgc_b.columnnumber));
86                 }
87                 
88                 // -----------------------
89                 // Public Instance Members
90                 // -----------------------
91
92
93                 public int RowNumber {
94                         get{
95                                 return rownumber;
96                         }
97                         set{
98                                 rownumber = value;
99                         }
100                 }
101
102                 public int ColumnNumber {
103                         get{
104                                 return columnnumber;
105                         }
106                         set{
107                                 columnnumber = value;
108                         }
109                 }
110
111                 /// <summary>
112                 ///     Equals Method
113                 /// </summary>
114                 ///
115                 /// <remarks>
116                 ///     Checks equivalence of this DataGridCell and another object.
117                 /// </remarks>
118                 
119                 public override bool Equals (object o)
120                 {
121                         if (!(o is DataGridCell))
122                                 return false;
123
124                         return (this == (DataGridCell) o);
125                 }
126
127                 /// <summary>
128                 ///     GetHashCode Method
129                 /// </summary>
130                 ///
131                 /// <remarks>
132                 ///     Calculates a hashing value.
133                 /// </remarks>
134                 
135                 public override int GetHashCode ()
136                 {
137                         return (int)( rownumber ^ columnnumber);
138                 }
139
140                 /// <summary>
141                 ///     ToString Method
142                 /// </summary>
143                 ///
144                 /// <remarks>
145                 ///     Formats the DataGridCell as a string.
146                 /// </remarks>
147                 
148                 public override string ToString ()
149                 {
150                         return String.Format ("[{0},{1}]", rownumber, columnnumber );
151                 }
152         }
153 }