2 * Copyright (C) 2013 FooProject
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
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
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/>.
12 using System.Collections.Generic;
14 namespace FooEditEngine
20 public Point(double x, double y)
28 /// <param name="a">比較される方</param>
29 /// <param name="b">比較対象</param>
30 /// <returns>条件を満たすなら真</returns>
31 public static bool operator ==(Point a, Point b)
39 /// <param name="a">比較される方</param>
40 /// <param name="b">比較対象</param>
41 /// <returns>条件を満たすなら真</returns>
42 public static bool operator !=(Point a, Point b)
50 /// <param name="o">比較対象</param>
51 /// <returns>一致するなら真</returns>
52 public override bool Equals(object o)
55 return this.X == b.X && this.Y == b.Y;
61 /// <returns>ハッシュを返す</returns>
62 public override int GetHashCode()
64 int result = this.X.GetHashCode();
65 result ^= this.Y.GetHashCode();
69 public Point Scale(double scale)
76 public static implicit operator Point(System.Drawing.Point p)
78 return new Point(p.X, p.Y);
80 public static implicit operator System.Drawing.Point(Point p)
82 return new System.Drawing.Point((int)p.X, (int)p.Y);
84 public static implicit operator SharpDX.Vector2(Point p)
86 return new SharpDX.Vector2((float)p.X, (float)p.Y);
90 public static implicit operator Point(System.Windows.Point p)
92 return new Point(p.X, p.Y);
94 public static implicit operator System.Windows.Point(Point p)
96 return new System.Windows.Point(p.X, p.Y);
98 public static implicit operator SharpDX.Vector2(Point p)
100 return new SharpDX.Vector2((float)p.X, (float)p.Y);
104 public static implicit operator Point(Windows.Foundation.Point p)
106 return new Point(p.X, p.Y);
108 public static implicit operator Windows.Foundation.Point(Point p)
110 return new Windows.Foundation.Point(p.X, p.Y);
112 public static implicit operator SharpDX.Vector2(Point p)
114 return new SharpDX.Vector2((float)p.X, (float)p.Y);
121 public double Height;
122 public Size(double width, double height)
125 this.Height = height;
131 /// <param name="a">比較される方</param>
132 /// <param name="b">比較対象</param>
133 /// <returns>条件を満たすなら真</returns>
134 public static bool operator ==(Size a, Size b)
142 /// <param name="a">比較される方</param>
143 /// <param name="b">比較対象</param>
144 /// <returns>条件を満たすなら真</returns>
145 public static bool operator !=(Size a, Size b)
153 /// <param name="o">比較対象</param>
154 /// <returns>一致するなら真</returns>
155 public override bool Equals(object o)
158 return this.Width == b.Width && this.Height == b.Height;
164 /// <returns>ハッシュを返す</returns>
165 public override int GetHashCode()
167 int result = this.Height.GetHashCode();
168 result ^= this.Width.GetHashCode();
172 public static implicit operator Size(System.Drawing.Size p)
174 return new Size(p.Width, p.Height);
176 public static implicit operator System.Drawing.Size(Size p)
178 return new System.Drawing.Size((int)p.Width, (int)p.Height);
182 public static implicit operator Size(System.Windows.Size p)
184 return new Size(p.Width, p.Height);
186 public static implicit operator System.Windows.Size(Size p)
188 return new System.Windows.Size(p.Width, p.Height);
192 public static implicit operator Size(Windows.Foundation.Size p)
194 return new Size(p.Width, p.Height);
196 public static implicit operator Windows.Foundation.Size(Size p)
198 return new Windows.Foundation.Size(p.Width, p.Height);
204 public Point Location;
208 get { return this.Location; }
210 public Point TopRight
212 get { return new Point(this.Right, this.Location.Y); }
214 public Point BottomLeft
216 get { return new Point(this.Location.X, this.Bottom); }
218 public Point BottomRight
220 get { return new Point(this.Right, this.Bottom); }
224 get { return this.X + this.Width; }
228 get { return this.Y + this.Height; }
232 get { return this.Size.Height; }
233 set { this.Size.Height = value; }
237 get { return this.Size.Width; }
238 set { this.Size.Width = value; }
242 get { return this.Location.X; }
246 get { return this.Location.Y; }
248 public Rectangle(double x, double y, double width, double height)
250 this.Location = new Point(x, y);
251 this.Size = new Size(width, height);
253 public Rectangle(Point leftTop, Point bottomRight)
255 this.Location = leftTop;
256 this.Size = new Size(bottomRight.X - leftTop.X, bottomRight.Y - leftTop.Y);
262 public static Rectangle Empty = new Rectangle(0, 0, 0, 0);
265 /// 任意の点が領域内にあるなら真を返す
267 /// <param name="p"></param>
268 /// <returns></returns>
269 public bool IsHit(Point p)
271 if (p.X >= this.TopLeft.X &&
272 p.Y >= this.TopLeft.Y &&
273 p.X <= this.BottomRight.X &&
274 p.Y <= this.BottomRight.Y)
282 /// <param name="a">比較される方</param>
283 /// <param name="b">比較対象</param>
284 /// <returns>条件を満たすなら真</returns>
285 public static bool operator ==(Rectangle a, Rectangle b)
293 /// <param name="a">比較される方</param>
294 /// <param name="b">比較対象</param>
295 /// <returns>条件を満たすなら真</returns>
296 public static bool operator !=(Rectangle a, Rectangle b)
304 /// <param name="o">比較対象</param>
305 /// <returns>一致するなら真</returns>
306 public override bool Equals(object o)
308 Rectangle b = (Rectangle)o;
309 return this.Location.Equals(b.Location) && this.Size.Equals(b.Size);
315 /// <returns>ハッシュを返す</returns>
316 public override int GetHashCode()
318 int result = this.Location.GetHashCode();
319 result ^= this.Size.GetHashCode();
323 public static implicit operator Rectangle(System.Drawing.Rectangle p)
325 return new Rectangle(p.X,p.Y,p.Width,p.Height);
327 public static implicit operator System.Drawing.Rectangle(Rectangle p)
329 return new System.Drawing.Rectangle((int)p.X, (int)p.Y, (int)p.Width, (int)p.Height);
331 public static implicit operator SharpDX.RectangleF(Rectangle p)
333 return new SharpDX.RectangleF((float)p.X, (float)p.Y, (float)p.Width, (float)p.Height);
337 public static implicit operator Rectangle(System.Windows.Rect p)
339 return new Rectangle(p.X,p.Y,p.Width,p.Height);
341 public static implicit operator System.Windows.Rect(Rectangle p)
343 return new System.Windows.Rect(p.X, p.Y, p.Width, p.Height);
345 public static implicit operator SharpDX.RectangleF(Rectangle p)
347 return new SharpDX.RectangleF((float)p.X, (float)p.Y, (float)p.Width, (float)p.Height);
351 public static implicit operator Rectangle(Windows.Foundation.Rect p)
353 return new Rectangle(p.X, p.Y, p.Width, p.Height);
355 public static implicit operator Windows.Foundation.Rect(Rectangle p)
357 return new Windows.Foundation.Rect(p.X, p.Y, p.Width, p.Height);
359 public static implicit operator SharpDX.RectangleF(Rectangle p)
361 return new SharpDX.RectangleF((float)p.X, (float)p.Y, (float)p.Width, (float)p.Height);
368 public struct Color: IEqualityComparer<Color>
390 /// <param name="a">A成分</param>
391 /// <param name="r">R成分</param>
392 /// <param name="g">G成分</param>
393 /// <param name="b">B成分</param>
394 public Color(byte a = 255, byte r = 0, byte g = 0, byte b = 0)
405 /// <param name="x">比較される方</param>
406 /// <param name="y">比較する方</param>
407 /// <returns>等しいなら真。そうでなければ偽</returns>
408 public bool Equals(Color x, Color y)
410 return x.A == y.A && x.R == y.R && x.G == y.G && x.B == y.B;
416 /// <param name="obj">Colorオブジェクト</param>
417 /// <returns>ハッシュ</returns>
418 public int GetHashCode(Color obj)
420 return this.A ^ this.R ^ this.B ^ this.G;
426 /// <param name="o">比較対象</param>
427 /// <returns>一致するなら真</returns>
428 public override bool Equals(object o)
431 return this.Equals(this,b);
437 /// <returns>ハッシュを返す</returns>
438 public override int GetHashCode()
440 return this.GetHashCode(this);
468 class ChangedRenderRsourceEventArgs : EventArgs
470 public ResourceType type;
471 public ChangedRenderRsourceEventArgs(ResourceType type)
476 delegate void ChangedRenderResourceEventHandler(object sender, ChangedRenderRsourceEventArgs e);
477 interface ITextRender
482 bool RightToLeft { get; set; }
487 Rectangle TextArea { get; set; }
492 double LineNemberWidth { get; }
497 int TabWidthChar { get; set; }
502 bool ShowFullSpace { get; set; }
507 bool ShowHalfSpace { get; set; }
512 bool ShowTab { get; set; }
517 bool ShowLineBreak { get; set; }
525 /// 保持しているリソースに変化があったことを通知する
527 event ChangedRenderResourceEventHandler ChangedRenderResource;
530 /// RightToLeftの値が変わったことを通知する
532 event EventHandler ChangedRightToLeft;
537 /// <param name="str">文字列</param>
538 /// <param name="x">x座標</param>
539 /// <param name="y">y座標</param>
540 /// <param name="align">書式方向</param>
541 /// <param name="layoutRect">レイアウト領域</param>
542 void DrawString(string str, double x, double y, StringAlignment align, Size layoutRect,StringColorType colorType = StringColorType.Forground);
547 /// <param name="lti">LineToIndexオブジェクト</param>
548 /// <param name="row">行</param>
549 /// <param name="x">行の左上を表すX座標</param>
550 /// <param name="y">行の左上を表すY座標</param>
551 /// <param name="SelectRanges">選択領域を保持しているコレクション。選択領域の開始位置は行の先頭を0とする相対位置としてください(位置が-1の場合表示されません)</param>
552 void DrawOneLine(LineToIndexTable lti, int row, double x, double y, IEnumerable<Selection> SelectRanges);
557 /// <param name="doc">ドキュメント</param>
558 /// <param name="layoutLineCollection">レイアウトライン</param>
559 /// <param name="startIndex">開始インデックス</param>
560 /// <param name="endIndex">終了インデックス</param>
561 /// <param name="wrapwidth">折り返しの幅</param>
562 /// <returns>行のリスト</returns>
563 List<LineToIndexTableData> BreakLine(Document doc,LineToIndexTable layoutLineCollection, int startIndex, int endIndex, double wrapwidth);
568 /// <param name="str">文字列</param>
569 /// <returns>ITextLayoutオブジェクト</returns>
570 /// <param name="syntaxCollection">ハイライト関連の情報を保持しているコレクション</param>
571 /// <param name="MarkerRanges">マーカーを保持しているコレクション。マーカーの開始位置は行の先頭を0とする相対位置としてください(位置が-1の場合表示しないこと)</param>
572 ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges);
577 /// <param name="p">中心点</param>
578 /// <param name="radius">半径</param>
579 void DrawGripper(Point p, double radius);
581 interface IEditorRender : ITextRender
586 double FoldingWidth { get; }
589 /// キャッシュされたビットマップを描写する
591 /// <param name="rect">描く領域</param>
592 void DrawCachedBitmap(Rectangle rect);
597 /// <param name="from">開始座標</param>
598 /// <param name="to">修了座標</param>
599 void DrawLine(Point from, Point to);
607 /// キャッシュが存在するなら真を返し、そうでないなら偽を返す
614 /// <param name="rect"></param>
615 /// <param name="type"></param>
616 void FillRectangle(Rectangle rect,FillRectType type);
621 /// <param name="expand">展開済みなら真</param>
622 /// <param name="x">x座標</param>
623 /// <param name="y">y座標</param>
624 void DrawFoldingMark(bool expand, double x, double y);
629 /// <param name="rect">塗りつぶすべき領域</param>
630 void FillBackground(Rectangle rect);
639 interface IPrintableTextRender : ITextRender
644 float HeaderHeight { get; }
649 float FooterHeight { get; }