X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=Core%2FViewBase.cs;h=715cd1cbe36887ae3d25e38d45afb5fcb0d92535;hb=468aa38ab5a405a1fb8f0f81747750c4ebb796cc;hp=c91d38abb96dd390c23e7030e42d6b7846083795;hpb=ac396cdbca61fd714387fdedf066aa62794e3eda;p=fooeditengine%2FFooEditEngine.git
diff --git a/Core/ViewBase.cs b/Core/ViewBase.cs
index c91d38a..715cd1c 100644
--- a/Core/ViewBase.cs
+++ b/Core/ViewBase.cs
@@ -77,8 +77,7 @@ namespace FooEditEngine
{
const int SpiltCharCount = 1024;
- protected Document Document;
- protected Point2 _Src = new Point2();
+ Document _Document;
protected Rectangle _Rect;
protected double _LongestWidth;
Padding _Padding;
@@ -87,53 +86,77 @@ namespace FooEditEngine
{
this._Padding = padding;
this.Document = doc;
- this.Document.UpdateCalledAlways += new DocumentUpdateEventHandler(doc_Update);
this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByChar);
this.render = r;
this.render.ChangedRenderResource += new ChangedRenderResourceEventHandler(render_ChangedRenderResource);
this.render.ChangedRightToLeft += render_ChangedRightToLeft;
this.SrcChanged += new EventHandler((s, e) => { });
- this.PerformLayouted += new EventHandler((s, e) => { });
this.PageBoundChanged += new EventHandler((s, e) => { });
- this.Document.LineBreakChanged += (s, e) =>
+ }
+
+ public Document Document
+ {
+ get
{
- if (this.Document.LineBreak != LineBreakMethod.None)
- this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByPixelbase);
- else
- this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByChar);
- };
- this.Document.TabStopsChanged += (s, e) =>
+ return this._Document;
+ }
+ set
{
+ if(this._Document != null)
+ {
+ this._Document.UpdateCalledAlways -= new DocumentUpdateEventHandler(doc_Update);
+ this._Document.LineBreakChanged -= Document_LineBreakChanged;
+ this._Document.StatusUpdate -= Document_StatusUpdate;
+ this._Document.PerformLayouted -= _Document_PerformLayouted;
+ }
+
+ this._Document = value;
+
+ this._Document.UpdateCalledAlways += new DocumentUpdateEventHandler(doc_Update);
+ this._Document.LineBreakChanged += Document_LineBreakChanged;
+ this._Document.StatusUpdate += Document_StatusUpdate;
+ this._Document.PerformLayouted += _Document_PerformLayouted;
+
+ this.Document_LineBreakChanged(this, null);
+
+ this.Document_StatusUpdate(this, null);
+ }
+ }
+
+ private void _Document_PerformLayouted(object sender, EventArgs e)
+ {
+ CalculateLineCountOnScreen();
+ if(this.PerformLayouted != null)
+ this.PerformLayouted(this, e);
+ }
+
+ private void Document_StatusUpdate(object sender, EventArgs e)
+ {
+ if (this.render == null)
+ return;
+ if (this.render.TabWidthChar != this.Document.TabStops)
this.render.TabWidthChar = this.Document.TabStops;
- };
- this.Document.DrawLineNumberChanged += (s, e) =>
- {
- CalculateClipRect();
- };
- this.Document.RightToLeftChanged += (s, e) =>
- {
+ if (this.render.RightToLeft != this.Document.RightToLeft)
this.render.RightToLeft = this.Document.RightToLeft;
- };
- this.Document.ShowFullSpaceChanged += (s, e) =>
- {
+ if (this.render.ShowFullSpace != this.Document.ShowFullSpace)
this.render.ShowFullSpace = this.Document.ShowFullSpace;
- this._LayoutLines.ClearLayoutCache();
- };
- this.Document.ShowHalfSpaceChanged += (s, e) =>
- {
+ if (this.render.ShowHalfSpace != this.Document.ShowHalfSpace)
this.render.ShowHalfSpace = this.Document.ShowHalfSpace;
- this._LayoutLines.ClearLayoutCache();
- };
- this.Document.ShowTabChanged += (s, e) =>
- {
+ if (this.render.ShowTab != this.Document.ShowTab)
this.render.ShowTab = this.Document.ShowTab;
- this._LayoutLines.ClearLayoutCache();
- };
- this.Document.ShowLineBreakChanged += (s, e) =>
- {
+ if (this.render.ShowLineBreak != this.Document.ShowLineBreak)
this.render.ShowLineBreak = this.Document.ShowLineBreak;
- this._LayoutLines.ClearLayoutCache();
- };
+ CalculateClipRect();
+ CalculateLineCountOnScreen();
+ this._LayoutLines.ClearLayoutCache();
+ }
+
+ private void Document_LineBreakChanged(object sender, EventArgs e)
+ {
+ if (this.Document.LineBreak != LineBreakMethod.None)
+ this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByPixelbase);
+ else
+ this._LayoutLines.SpilitString = new SpilitStringEventHandler(LayoutLines_SpilitStringByChar);
}
protected LineToIndexTable _LayoutLines
@@ -146,6 +169,7 @@ namespace FooEditEngine
public event EventHandler SrcChanged;
+ [Obsolete]
public event EventHandler PerformLayouted;
public event EventHandler PageBoundChanged;
@@ -208,18 +232,17 @@ namespace FooEditEngine
public IHilighter Hilighter
{
get { return this._LayoutLines.Hilighter; }
- set { this._LayoutLines.Hilighter = value; }
+ set { this._LayoutLines.Hilighter = value; this._LayoutLines.ClearLayoutCache(); }
}
///
/// ãã¹ã¦ã®ã¬ã¤ã¢ã¦ãè¡ãç ´æ£ããå度ã¬ã¤ã¢ã¦ããããç´ã
///
+ [Obsolete]
public virtual void PerfomLayouts()
{
- this.Document.FireUpdate(new DocumentUpdateEventArgs(UpdateType.Clear, -1, -1, -1));
- this.Document.FireUpdate(new DocumentUpdateEventArgs(UpdateType.Replace, 0, 0, this.Document.Length));
- CalculateLineCountOnScreen();
- this.PerformLayouted(this, null);
+ //äºææ§ãä¿ã¤ããã«æ®ãã¦ãã
+ this.Document.PerformLayout();
}
///
@@ -262,14 +285,15 @@ namespace FooEditEngine
///
/// Draw()ã®å¯¾è±¡ã¨ãªãé åã®å·¦ä¸ã表ã
///
- public Point2 Src
+ public SrcPoint Src
{
- get { return this._Src; }
- set { this._Src = value; }
+ get { return this.Document.Src; }
+ set { this.Document.Src = value; }
}
- public virtual void Draw(Rectangle updateRect)
+ public virtual void Draw(Rectangle updateRect, bool force = false)
{
+ return;
}
public virtual bool TryScroll(double x, int row)
@@ -278,9 +302,7 @@ namespace FooEditEngine
return true;
if (row > this.LayoutLines.Count - 1)
return true;
- this._Src.X = x;
- this._Src.Row = row;
- CalculateLineCountOnScreen();
+ this.Document.Src = new SrcPoint(x, row, row * this.render.emSize.Height);
this.SrcChanged(this,null);
return false;
}
@@ -299,7 +321,10 @@ namespace FooEditEngine
{
if (disposing)
{
- this.Document.UpdateCalledAlways -= new DocumentUpdateEventHandler(this.doc_Update); //ãããããªãã¨è¤æ°ã®ãã¥ã¼ãä½æããæã«å¦ãªã¨ã©ã¼ãçºçãã
+ this._Document.UpdateCalledAlways -= new DocumentUpdateEventHandler(this.doc_Update); //ãããããªãã¨è¤æ°ã®ãã¥ã¼ãä½æããæã«å¦ãªã¨ã©ã¼ãçºçãã
+ this._Document.LineBreakChanged -= Document_LineBreakChanged;
+ this._Document.StatusUpdate -= Document_StatusUpdate;
+ this._Document.PerformLayouted -= _Document_PerformLayouted;
}
this._LayoutLines.Clear();
}
@@ -332,9 +357,7 @@ namespace FooEditEngine
void render_ChangedRightToLeft(object sender, EventArgs e)
{
- this._Src.X = 0;
- this._LayoutLines.ClearLayoutCache();
- this.CalculateClipRect();
+ this.Document.Src = new SrcPoint(0, this.Document.Src.Row, this.Src.Y);
}
void render_ChangedRenderResource(object sender, ChangedRenderRsourceEventArgs e)