2 using System.Collections.Generic;
5 namespace FooEditEngine.Windows
7 class PrintableTextLayout : ITextLayout
9 public PrintableTextLayout(Font font)
11 this.Disposed = false;
12 this.Height = font.Height;
36 public int GetIndexFromColPostion(double x)
41 public double GetWidthFromIndex(int index)
46 public double GetColPostionFromIndex(int index)
51 public int AlignIndexToNearestCluster(int index, AlignDirection flow)
61 class PrintableTextRender : IPrintableTextRender
67 public PrintableTextRender(Font font, Graphics g)
70 this.sf = StringFormat.GenericTypographic;
71 this.sf.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
75 public event ChangedRenderResourceEventHandler ChangedRenderResource;
76 public event EventHandler ChangedRightToLeft;
78 public void BeginDraw(Graphics g)
82 this.sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
89 public ITextLayout CreateLaytout(string str)
91 return new PrintableTextLayout(this.font);
94 public float HeaderHeight { get { return this.font.Height; } }
96 public float FooterHeight { get { return this.font.Height; } }
98 const int LineNumberFiledLength = 6;
100 public double LineNemberWidth
104 int length = LineNumberFiledLength;
106 SizeF metrics = g.MeasureString("0", this.font, Int16.MaxValue, this.sf);
107 return metrics.Width * length;
111 public double FoldingWidth
119 public bool RightToLeft
125 public bool InsertMode
131 public Rectangle TextArea
141 return new Size(0, 0);
145 public void DrawCachedBitmap(Rectangle rect)
149 public void CacheContent()
153 public bool IsVaildCache()
158 public void DrawLine(Point from, Point to)
162 public void DrawString(string str, double x, double y)
164 g.DrawString(str, this.font, new SolidBrush(this.Foreground), new PointF((float)x, (float)y), this.sf);
167 public void DrawCaret(Rectangle rect, bool transparent)
171 public void DrawFoldingMark(bool expand, double x, double y)
175 public void DrawString(string str, double x, double y, StringAlignment align, Size layoutRect,StringColorType colorType = StringColorType.Forground)
177 System.Drawing.StringAlignment old = this.sf.Alignment;
179 this.sf.Alignment = System.Drawing.StringAlignment.Center;
181 g.DrawString(str, this.font, new SolidBrush(this.Foreground), new RectangleF((float)x, (float)y, (float)layoutRect.Width, (float)layoutRect.Height), this.sf);
183 this.sf.Alignment = old;
186 public void DrawOneLine(LineToIndexTable lti, int row, double x, double y, IEnumerable<Selection> SelectRanges)
188 g.DrawString(lti[row], this.font, new SolidBrush(this.Foreground), new RectangleF((float)x, (float)y, (float)this.TextArea.Width, (float)this.TextArea.Height), this.sf);
191 public void FillRectangle(Rectangle rect, FillRectType type)
195 public void FillBackground(Rectangle rect)
199 public ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges)
201 return new PrintableTextLayout(this.font);
204 public List<LineToIndexTableData> BreakLine(Document doc, LineToIndexTable layoutLineCollection, int startIndex, int endIndex, double maxwidth)
206 List<LineToIndexTableData> output = new List<LineToIndexTableData>();
208 foreach (string str in doc.GetLines(startIndex, endIndex))
210 LineToIndexTableData info;
214 info = layoutLineCollection.CreateLineToIndexTableData(startIndex, 0, true, null);
219 int fitlen, index = 0, x = 0, width;
223 SizeF metrics = g.MeasureString(str.Substring(index), this.font, new SizeF((float)maxwidth, this.font.Height + 1), this.sf, out fitlen, out linesFilled);
225 x += width = (int)metrics.Width;
227 info = layoutLineCollection.CreateLineToIndexTableData(index + startIndex, fitlen, false, null);
231 } while (index < str.Length);
233 output[output.Count - 1].LineEnd = true;
235 startIndex += str.Length;
241 public void DrawGripper(Point p, double radius)
243 //タッチには対応していないので実装する必要はない
244 throw new NotImplementedException();
247 public System.Drawing.Color Foreground
253 public int TabWidthChar
255 get { float taboffset; return (int)this.sf.GetTabStops(out taboffset)[0]; }
256 set { this.sf.SetTabStops(0,new float[]{value});}
259 public bool ShowFullSpace
265 public bool ShowHalfSpace
277 public bool ShowLineBreak