2 * Copyright (C) 2013 FooProject
\r
3 * * 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
\r
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
\r
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
\r
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
13 namespace FooEditEngine
\r
19 public Point2(double x, int row)
\r
28 public struct TextPoint : IComparable<TextPoint>
\r
40 /// TextPointがドキュメント上のどこも指していないことを表す
\r
42 public static readonly TextPoint Null = new TextPoint(-1,-1);
\r
47 /// <param name="row">行番号</param>
\r
48 /// <param name="col">桁</param>
\r
49 public TextPoint(int row, int col)
\r
58 /// <param name="a">比較される方</param>
\r
59 /// <param name="b">比較対象</param>
\r
60 /// <returns>条件を満たすなら真</returns>
\r
61 public static bool operator <(TextPoint a, TextPoint b)
\r
63 return a.CompareTo(b) == -1;
\r
69 /// <param name="a">比較される方</param>
\r
70 /// <param name="b">比較対象</param>
\r
71 /// <returns>条件を満たすなら真</returns>
\r
72 public static bool operator <=(TextPoint a, TextPoint b)
\r
74 return a.CompareTo(b) != 1;
\r
80 /// <param name="a">比較される方</param>
\r
81 /// <param name="b">比較対象</param>
\r
82 /// <returns>条件を満たすなら真</returns>
\r
83 public static bool operator >(TextPoint a, TextPoint b)
\r
85 return a.CompareTo(b) == 1;
\r
91 /// <param name="a">比較される方</param>
\r
92 /// <param name="b">比較対象</param>
\r
93 /// <returns>条件を満たすなら真</returns>
\r
94 public static bool operator >=(TextPoint a, TextPoint b)
\r
96 return a.CompareTo(b) != -1;
\r
102 /// <param name="a">比較される方</param>
\r
103 /// <param name="b">比較対象</param>
\r
104 /// <returns>条件を満たすなら真</returns>
\r
105 public static bool operator ==(TextPoint a, TextPoint b)
\r
107 return a.Equals(b);
\r
113 /// <param name="a">比較される方</param>
\r
114 /// <param name="b">比較対象</param>
\r
115 /// <returns>条件を満たすなら真</returns>
\r
116 public static bool operator !=(TextPoint a, TextPoint b)
\r
118 return !a.Equals(b);
\r
124 /// <param name="o">比較対象</param>
\r
125 /// <returns>一致するなら真</returns>
\r
126 public override bool Equals(object o)
\r
128 TextPoint b = (TextPoint)o;
\r
129 return this.col == b.col && this.row == b.row;
\r
135 /// <returns>ハッシュを返す</returns>
\r
136 public override int GetHashCode()
\r
138 int result = this.row.GetHashCode();
\r
139 result ^= this.col.GetHashCode();
\r
143 #region IComparable<TextPoint> メンバー
\r
148 /// <param name="other">比較対象となるTextPointオブジェクト</param>
\r
149 /// <returns>相対値を返す</returns>
\r
150 public int CompareTo(TextPoint other)
\r
152 if (this.row == other.row && this.col == other.col)
\r
154 if (this.row < other.row)
\r
156 else if (this.row == other.row && this.col < other.col)
\r
168 public struct TextRectangle
\r
170 TextPoint _TopLeft;
\r
172 TextPoint _BottomRight;
\r
175 /// 矩形エリアがドキュメントのどこも指していないことを表す
\r
177 public static readonly TextRectangle Null = new TextRectangle(new TextPoint(-1,-1),new TextPoint(-1,-1));
\r
182 public TextPoint TopLeft
\r
186 return this._TopLeft;
\r
193 public TextPoint TopRight
\r
197 return new TextPoint(this._TopLeft.row, this._BottomRight.col);
\r
204 public TextPoint BottomLeft
\r
208 return new TextPoint(this._BottomRight.row, this._TopLeft.col);
\r
215 public TextPoint BottomRight
\r
219 return this._BottomRight;
\r
226 /// <param name="row">行</param>
\r
227 /// <param name="col">桁</param>
\r
228 /// <param name="height">高さ</param>
\r
229 /// <param name="width">幅</param>
\r
230 public TextRectangle(int row, int col, int height,int width)
\r
232 this._TopLeft = new TextPoint(row, col);
\r
233 this._BottomRight = new TextPoint(row + height - 1, col + width - 1);
\r
239 /// <param name="topLeft">矩形の左上</param>
\r
240 /// <param name="bottomRight">矩形の右下</param>
\r
241 public TextRectangle(TextPoint topLeft, TextPoint bottomRight)
\r
243 this._TopLeft = topLeft;
\r
244 this._BottomRight = bottomRight;
\r
250 /// <param name="a">比較される方</param>
\r
251 /// <param name="b">比較対象</param>
\r
252 /// <returns>条件を満たすなら真</returns>
\r
253 public static bool operator ==(TextRectangle a, TextRectangle b)
\r
255 return a.Equals(b);
\r
261 /// <param name="a">比較される方</param>
\r
262 /// <param name="b">比較対象</param>
\r
263 /// <returns>条件を満たすなら真</returns>
\r
264 public static bool operator !=(TextRectangle a, TextRectangle b)
\r
266 return !a.Equals(b);
\r
272 /// <param name="o">比較対象</param>
\r
273 /// <returns>一致するなら真</returns>
\r
274 public override bool Equals(object o)
\r
276 TextRectangle b = (TextRectangle)o;
\r
277 return this._TopLeft == b._TopLeft && this._BottomRight == b._BottomRight;
\r
283 /// <returns>ハッシュを返す</returns>
\r
284 public override int GetHashCode()
\r
286 int result = this._TopLeft.GetHashCode();
\r
287 result ^= this._BottomRight.GetHashCode();
\r