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
12 using System.Collections.Generic;
\r
14 namespace FooEditEngine
\r
20 public Point(double x, double y)
\r
28 /// <param name="a">比較される方</param>
\r
29 /// <param name="b">比較対象</param>
\r
30 /// <returns>条件を満たすなら真</returns>
\r
31 public static bool operator ==(Point a, Point b)
\r
39 /// <param name="a">比較される方</param>
\r
40 /// <param name="b">比較対象</param>
\r
41 /// <returns>条件を満たすなら真</returns>
\r
42 public static bool operator !=(Point a, Point b)
\r
44 return !a.Equals(b);
\r
50 /// <param name="o">比較対象</param>
\r
51 /// <returns>一致するなら真</returns>
\r
52 public override bool Equals(object o)
\r
55 return this.X == b.X && this.Y == b.Y;
\r
61 /// <returns>ハッシュを返す</returns>
\r
62 public override int GetHashCode()
\r
64 int result = this.X.GetHashCode();
\r
65 result ^= this.Y.GetHashCode();
\r
69 public Point Scale(double scale)
\r
76 public static implicit operator Point(System.Drawing.Point p)
\r
78 return new Point(p.X, p.Y);
\r
80 public static implicit operator System.Drawing.Point(Point p)
\r
82 return new System.Drawing.Point((int)p.X, (int)p.Y);
\r
84 public static implicit operator SharpDX.Vector2(Point p)
\r
86 return new SharpDX.Vector2((float)p.X, (float)p.Y);
\r
90 public static implicit operator Point(System.Windows.Point p)
\r
92 return new Point(p.X, p.Y);
\r
94 public static implicit operator System.Windows.Point(Point p)
\r
96 return new System.Windows.Point(p.X, p.Y);
\r
98 public static implicit operator SharpDX.Vector2(Point p)
\r
100 return new SharpDX.Vector2((float)p.X, (float)p.Y);
\r
104 public static implicit operator Point(Windows.Foundation.Point p)
\r
106 return new Point(p.X, p.Y);
\r
108 public static implicit operator Windows.Foundation.Point(Point p)
\r
110 return new Windows.Foundation.Point(p.X, p.Y);
\r
112 public static implicit operator SharpDX.Vector2(Point p)
\r
114 return new SharpDX.Vector2((float)p.X, (float)p.Y);
\r
120 public double Width;
\r
121 public double Height;
\r
122 public Size(double width, double height)
\r
124 this.Width = width;
\r
125 this.Height = height;
\r
131 /// <param name="a">比較される方</param>
\r
132 /// <param name="b">比較対象</param>
\r
133 /// <returns>条件を満たすなら真</returns>
\r
134 public static bool operator ==(Size a, Size b)
\r
136 return a.Equals(b);
\r
142 /// <param name="a">比較される方</param>
\r
143 /// <param name="b">比較対象</param>
\r
144 /// <returns>条件を満たすなら真</returns>
\r
145 public static bool operator !=(Size a, Size b)
\r
147 return !a.Equals(b);
\r
153 /// <param name="o">比較対象</param>
\r
154 /// <returns>一致するなら真</returns>
\r
155 public override bool Equals(object o)
\r
158 return this.Width == b.Width && this.Height == b.Height;
\r
164 /// <returns>ハッシュを返す</returns>
\r
165 public override int GetHashCode()
\r
167 int result = this.Height.GetHashCode();
\r
168 result ^= this.Width.GetHashCode();
\r
172 public static implicit operator Size(System.Drawing.Size p)
\r
174 return new Size(p.Width, p.Height);
\r
176 public static implicit operator System.Drawing.Size(Size p)
\r
178 return new System.Drawing.Size((int)p.Width, (int)p.Height);
\r
182 public static implicit operator Size(System.Windows.Size p)
\r
184 return new Size(p.Width, p.Height);
\r
186 public static implicit operator System.Windows.Size(Size p)
\r
188 return new System.Windows.Size(p.Width, p.Height);
\r
192 public static implicit operator Size(Windows.Foundation.Size p)
\r
194 return new Size(p.Width, p.Height);
\r
196 public static implicit operator Windows.Foundation.Size(Size p)
\r
198 return new Windows.Foundation.Size(p.Width, p.Height);
\r
204 public Point Location;
\r
206 public Point TopLeft
\r
208 get { return this.Location; }
\r
210 public Point TopRight
\r
212 get { return new Point(this.Right, this.Location.Y); }
\r
214 public Point BottomLeft
\r
216 get { return new Point(this.Location.X, this.Bottom); }
\r
218 public Point BottomRight
\r
220 get { return new Point(this.Right, this.Bottom); }
\r
222 public double Right
\r
224 get { return this.X + this.Width; }
\r
226 public double Bottom
\r
228 get { return this.Y + this.Height; }
\r
230 public double Height
\r
232 get { return this.Size.Height; }
\r
233 set { this.Size.Height = value; }
\r
235 public double Width
\r
237 get { return this.Size.Width; }
\r
238 set { this.Size.Width = value; }
\r
242 get { return this.Location.X; }
\r
246 get { return this.Location.Y; }
\r
248 public Rectangle(double x, double y, double width, double height)
\r
250 this.Location = new Point(x, y);
\r
251 this.Size = new Size(width, height);
\r
253 public Rectangle(Point leftTop, Point bottomRight)
\r
255 this.Location = leftTop;
\r
256 this.Size = new Size(bottomRight.X - leftTop.X, bottomRight.Y - leftTop.Y);
\r
262 public static Rectangle Empty = new Rectangle(0, 0, 0, 0);
\r
265 /// 任意の点が領域内にあるなら真を返す
\r
267 /// <param name="p"></param>
\r
268 /// <returns></returns>
\r
269 public bool IsHit(Point p)
\r
271 if (p.X >= this.TopLeft.X &&
\r
272 p.Y >= this.TopLeft.Y &&
\r
273 p.X <= this.BottomRight.X &&
\r
274 p.Y <= this.BottomRight.Y)
\r
282 /// <param name="a">比較される方</param>
\r
283 /// <param name="b">比較対象</param>
\r
284 /// <returns>条件を満たすなら真</returns>
\r
285 public static bool operator ==(Rectangle a, Rectangle b)
\r
287 return a.Equals(b);
\r
293 /// <param name="a">比較される方</param>
\r
294 /// <param name="b">比較対象</param>
\r
295 /// <returns>条件を満たすなら真</returns>
\r
296 public static bool operator !=(Rectangle a, Rectangle b)
\r
298 return !a.Equals(b);
\r
304 /// <param name="o">比較対象</param>
\r
305 /// <returns>一致するなら真</returns>
\r
306 public override bool Equals(object o)
\r
308 Rectangle b = (Rectangle)o;
\r
309 return this.Location.Equals(b.Location) && this.Size.Equals(b.Size);
\r
315 /// <returns>ハッシュを返す</returns>
\r
316 public override int GetHashCode()
\r
318 int result = this.Location.GetHashCode();
\r
319 result ^= this.Size.GetHashCode();
\r
323 public static implicit operator Rectangle(System.Drawing.Rectangle p)
\r
325 return new Rectangle(p.X,p.Y,p.Width,p.Height);
\r
327 public static implicit operator System.Drawing.Rectangle(Rectangle p)
\r
329 return new System.Drawing.Rectangle((int)p.X, (int)p.Y, (int)p.Width, (int)p.Height);
\r
331 public static implicit operator SharpDX.RectangleF(Rectangle p)
\r
333 return new SharpDX.RectangleF((float)p.X, (float)p.Y, (float)p.Width, (float)p.Height);
\r
337 public static implicit operator Rectangle(System.Windows.Rect p)
\r
339 return new Rectangle(p.X,p.Y,p.Width,p.Height);
\r
341 public static implicit operator System.Windows.Rect(Rectangle p)
\r
343 return new System.Windows.Rect(p.X, p.Y, p.Width, p.Height);
\r
345 public static implicit operator SharpDX.RectangleF(Rectangle p)
\r
347 return new SharpDX.RectangleF((float)p.X, (float)p.Y, (float)p.Width, (float)p.Height);
\r
351 public static implicit operator Rectangle(Windows.Foundation.Rect p)
\r
353 return new Rectangle(p.X, p.Y, p.Width, p.Height);
\r
355 public static implicit operator Windows.Foundation.Rect(Rectangle p)
\r
357 return new Windows.Foundation.Rect(p.X, p.Y, p.Width, p.Height);
\r
359 public static implicit operator SharpDX.RectangleF(Rectangle p)
\r
361 return new SharpDX.RectangleF((float)p.X, (float)p.Y, (float)p.Width, (float)p.Height);
\r
368 public struct Color: IEqualityComparer<Color>
\r
390 /// <param name="a">A成分</param>
\r
391 /// <param name="r">R成分</param>
\r
392 /// <param name="g">G成分</param>
\r
393 /// <param name="b">B成分</param>
\r
394 public Color(byte a = 255, byte r = 0, byte g = 0, byte b = 0)
\r
405 /// <param name="x">比較される方</param>
\r
406 /// <param name="y">比較する方</param>
\r
407 /// <returns>等しいなら真。そうでなければ偽</returns>
\r
408 public bool Equals(Color x, Color y)
\r
410 return x.A == y.A && x.R == y.R && x.G == y.G && x.B == y.B;
\r
416 /// <param name="obj">Colorオブジェクト</param>
\r
417 /// <returns>ハッシュ</returns>
\r
418 public int GetHashCode(Color obj)
\r
420 return this.A ^ this.R ^ this.B ^ this.G;
\r
426 /// <param name="o">比較対象</param>
\r
427 /// <returns>一致するなら真</returns>
\r
428 public override bool Equals(object o)
\r
430 Color b = (Color)o;
\r
431 return this.Equals(this,b);
\r
437 /// <returns>ハッシュを返す</returns>
\r
438 public override int GetHashCode()
\r
440 return this.GetHashCode(this);
\r
443 enum AlignDirection
\r
463 enum StringColorType
\r
468 class ChangedRenderRsourceEventArgs : EventArgs
\r
470 public ResourceType type;
\r
471 public ChangedRenderRsourceEventArgs(ResourceType type)
\r
476 delegate void ChangedRenderResourceEventHandler(object sender, ChangedRenderRsourceEventArgs e);
\r
477 interface ITextRender
\r
482 bool RightToLeft { get; set; }
\r
487 Rectangle TextArea { get; set; }
\r
492 double LineNemberWidth { get; }
\r
497 int TabWidthChar { get; set; }
\r
502 Size emSize { get; }
\r
505 /// 保持しているリソースに変化があったことを通知する
\r
507 event ChangedRenderResourceEventHandler ChangedRenderResource;
\r
510 /// RightToLeftの値が変わったことを通知する
\r
512 event EventHandler ChangedRightToLeft;
\r
517 /// <param name="str">文字列</param>
\r
518 /// <param name="x">x座標</param>
\r
519 /// <param name="y">y座標</param>
\r
520 /// <param name="align">書式方向</param>
\r
521 /// <param name="layoutRect">レイアウト領域</param>
\r
522 void DrawString(string str, double x, double y, StringAlignment align, Size layoutRect,StringColorType colorType = StringColorType.Forground);
\r
527 /// <param name="lti">LineToIndexオブジェクト</param>
\r
528 /// <param name="row">行</param>
\r
529 /// <param name="x">行の左上を表すX座標</param>
\r
530 /// <param name="y">行の左上を表すY座標</param>
\r
531 /// <param name="SelectRanges">選択領域を保持しているコレクション。選択領域の開始位置は行の先頭を0とする相対位置としてください(位置が-1の場合表示されません)</param>
\r
532 void DrawOneLine(LineToIndexTable lti, int row, double x, double y, IEnumerable<Selection> SelectRanges);
\r
537 /// <param name="doc">ドキュメント</param>
\r
538 /// <param name="layoutLineCollection">レイアウトライン</param>
\r
539 /// <param name="startIndex">開始インデックス</param>
\r
540 /// <param name="endIndex">終了インデックス</param>
\r
541 /// <param name="wrapwidth">折り返しの幅</param>
\r
542 /// <returns>行のリスト</returns>
\r
543 List<LineToIndexTableData> BreakLine(Document doc,LineToIndexTable layoutLineCollection, int startIndex, int endIndex, double wrapwidth);
\r
548 /// <param name="str">文字列</param>
\r
549 /// <returns>ITextLayoutオブジェクト</returns>
\r
550 /// <param name="syntaxCollection">ハイライト関連の情報を保持しているコレクション</param>
\r
551 /// <param name="MarkerRanges">マーカーを保持しているコレクション。マーカーの開始位置は行の先頭を0とする相対位置としてください(位置が-1の場合表示しないこと)</param>
\r
552 ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges);
\r
554 interface IEditorRender : ITextRender
\r
559 double FoldingWidth { get; }
\r
562 /// キャッシュされたビットマップを描写する
\r
564 /// <param name="rect">描く領域</param>
\r
565 void DrawCachedBitmap(Rectangle rect);
\r
570 /// <param name="from">開始座標</param>
\r
571 /// <param name="to">修了座標</param>
\r
572 void DrawLine(Point from, Point to);
\r
577 void CacheContent();
\r
580 /// キャッシュが存在するなら真を返し、そうでないなら偽を返す
\r
582 bool IsVaildCache();
\r
587 /// <param name="rect"></param>
\r
588 /// <param name="type"></param>
\r
589 void FillRectangle(Rectangle rect,FillRectType type);
\r
594 /// <param name="expand">展開済みなら真</param>
\r
595 /// <param name="x">x座標</param>
\r
596 /// <param name="y">y座標</param>
\r
597 void DrawFoldingMark(bool expand, double x, double y);
\r
602 /// <param name="rect">塗りつぶすべき領域</param>
\r
603 void FillBackground(Rectangle rect);
\r
606 enum StringAlignment
\r
612 interface IPrintableTextRender : ITextRender
\r
617 float HeaderHeight { get; }
\r
622 float FooterHeight { get; }
\r