]> O.S.I.I.S - jp/crow.git/commitdiff
crow ide toolbox, syntax tree depth and generalize node handling accross parser
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 9 Mar 2018 09:35:06 +0000 (10:35 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 9 Mar 2018 09:35:06 +0000 (10:35 +0100)
16 files changed:
Crow.csproj
Default.style
src/GraphicObjects/ColorSelector.cs
src/GraphicObjects/DockStack.cs
src/GraphicObjects/GraduatedSlider.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/HueSelector.cs
src/GraphicObjects/MDIContainer.cs [deleted file]
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/SaturationValueSelector.cs
src/GraphicObjects/ScrollingObject.cs
src/GraphicObjects/ScrollingTextBox.cs [deleted file]
src/GraphicObjects/TextRun.cs
src/IMLAttributes.cs
src/Interface.cs
src/LayoutingQueueItem.cs

index 7a0ffadaee265d9c44fb44cab2edd6653725e62b..9e474f586f9110b61f3af9d36ca5b8b04a5769ab 100644 (file)
     <Compile Include="src\IML\BindingMember.cs" />
     <Compile Include="src\CrowThread.cs" />
     <Compile Include="src\GraphicObjects\ScrollingObject.cs" />
-    <Compile Include="src\GraphicObjects\ScrollingTextBox.cs" />
     <Compile Include="src\Mono.Cairo\Antialias.cs" />
     <Compile Include="src\Mono.Cairo\Cairo.cs" />
     <Compile Include="src\Mono.Cairo\CairoDebug.cs" />
     <Compile Include="src\IML\IMLContext.cs" />
     <Compile Include="src\Mono.Cairo\MeshPattern.cs" />
     <Compile Include="src\GraphicObjects\Shape.cs" />
-    <Compile Include="src\GraphicObjects\MDIContainer.cs" />
     <Compile Include="src\IListChanged.cs" />
     <Compile Include="src\ObservableList.cs" />
     <Compile Include="src\GraphicObjects\IMLContainer.cs" />
index 51e9dfb01bc315ea02e9c4a1947288f026b99ae0..ed92e89b0d7c30a1233f9825e463a02d7282976d 100644 (file)
@@ -69,7 +69,8 @@ MessageBox {
 Slider {
        Background = "vgradient|0:Black|0.1:Gray|0.9:Gray|1:LightGray";
        Foreground = "Gray";
-       Width = "Fit";
+       Height = "10";
+       Value="5";
 }
 Splitter {
        Focusable = "true";
index e2d6cb6a829775f617708a410aedb57013476207..ee57a2621f0ebcda6e0755380e1c645835fd45c4 100644 (file)
@@ -33,6 +33,7 @@ namespace Crow
        /// <summary>
        /// simple squarred rgb color selector
        /// </summary>
+       [DesignIgnore]
        public class ColorSelector : GraphicObject
        {
                #region CTOR
index e9a5348601d533bd5dda1afd271a02932929d21d..caefb2ec3b4588b465d1e60f5dcefe4b97e06c23 100644 (file)
@@ -28,6 +28,7 @@ using Crow.IML;
 
 namespace Crow
 {
+       [DesignIgnore]
        public class DockStack : GenericStack
        {
                Docker rootDock { get { return LogicalParent as Docker; }}
index 52ba296080231c0369fc2fcaa7f5f47ccb9e7cf7..e1d4dd46e8a45f872811842542f1ea6d477b0801 100644 (file)
@@ -33,6 +33,7 @@ using System.Xml.Serialization;
 
 namespace Crow
 {
+       [DesignIgnore]
        public class GraduatedSlider : Slider
     {     
                #region CTOR
index 911ea7bd0150d7951a67f632bd291c2d8e483a60..c74913300a43c2c8313647676ec43eef5672660a 100644 (file)
@@ -425,11 +425,11 @@ namespace Crow
                public event EventHandler Disabled;
 
                #region DragAndDrop Events
-               public event EventHandler StartDrag;
-               public event EventHandler DragEnter;
-               public event EventHandler DragLeave;
-               public event EventHandler EndDrag;
-               public event EventHandler Drop;
+               public event EventHandler<DragDropEventArgs> StartDrag;
+               public event EventHandler<DragDropEventArgs> DragEnter;
+               public event EventHandler<DragDropEventArgs> DragLeave;
+               public event EventHandler<DragDropEventArgs> EndDrag;
+               public event EventHandler<DragDropEventArgs> Drop;
                #endregion
 
                /// <summary>
@@ -1242,7 +1242,9 @@ namespace Crow
                        IFace.HoverWidget = null;
                        IsDragged = true;
                        StartDrag.Raise (this, e);
+                       #if DEBUG_DRAGNDROP
                        Debug.WriteLine(this.ToString() + " : START DRAG => " + e.ToString());
+                       #endif
                }
                /// <summary>
                ///  Occured when dragging ends without dropping
@@ -1250,27 +1252,31 @@ namespace Crow
                protected virtual void onEndDrag (object sender, DragDropEventArgs e){                  
                        IsDragged = false;
                        EndDrag.Raise (this, e);
+                       #if DEBUG_DRAGNDROP
                        Debug.WriteLine(this.ToString() + " : END DRAG => " + e.ToString());
+                       #endif
                }
                protected virtual void onDragEnter (object sender, DragDropEventArgs e){
                        e.DropTarget = this;
                        DragEnter.Raise (this, e);
+                       #if DEBUG_DRAGNDROP
                        Debug.WriteLine(this.ToString() + " : DRAG Enter => " + e.ToString());
+                       #endif
                }
                protected virtual void onDragLeave (object sender, DragDropEventArgs e){                        
                        e.DropTarget = null;
                        DragLeave.Raise (this, e);
+                       #if DEBUG_DRAGNDROP
                        Debug.WriteLine(this.ToString() + " : DRAG Leave => " + e.ToString());
+                       #endif
                }
                protected virtual void onDrop (object sender, DragDropEventArgs e){                     
                        IsDragged = false;
                        Drop.Raise (this, e);
                        //e.DropTarget.onDragLeave (this, e);//raise drag leave in target
+                       #if DEBUG_DRAGNDROP
                        Debug.WriteLine(this.ToString() + " : DROP => " + e.ToString());
-               }
-               public virtual void OnDragMove(object sender, MouseMoveEventArgs e, DragDropEventArgs dde)
-               {
-
+                       #endif
                }
                public bool IsDropTarget {
                        get { return IFace.DragAndDropOperation?.DropTarget == this; }
@@ -1398,6 +1404,11 @@ namespace Crow
                        IFace.currentLQI.NewSlot = Slot;
                        Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot);
                        #endif
+                       #if DESIGN_MODE
+                       if (IFace.GetType().Name == "DesignInterface"){
+                               Debug.WriteLine ("\t\t{2}: {0} => {1}",LastSlots,Slot,this.name);
+                       }
+                       #endif
 
                        switch (layoutType) {
                        case LayoutingType.Width:
@@ -1860,6 +1871,13 @@ namespace Crow
                        Disabled.Raise (this, e);
                }
                protected virtual void onParentChanged(object sender, DataSourceChangeEventArgs e) {
+//                     if (e.NewDataSource != null) {
+//                             if (width == Measure.Inherit)
+//                                     RegisterForLayouting (LayoutingType.Width);
+//                             if (height == Measure.Inherit)
+//                                     RegisterForLayouting (LayoutingType.Height);
+//                     }
+                       
                        ParentChanged.Raise (this, e);
                        if (logicalParent == null)
                                LogicalParentChanged.Raise (this, e);
index 518ee6c4c04d7c00550599b2d76cbef3cd33c9f6..67f4ec6ee0b8a0c0381e4f97aec02c1a274a72e6 100644 (file)
@@ -31,6 +31,7 @@ using Cairo;
 
 namespace Crow
 {
+       [DesignIgnore]
        public class HueSelector : ColorSelector
        {
                #region CTOR
diff --git a/src/GraphicObjects/MDIContainer.cs b/src/GraphicObjects/MDIContainer.cs
deleted file mode 100644 (file)
index d8ce464..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// MDIContainer.cs
-//
-// Author:
-//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-
-namespace Crow
-{
-       public class MDIContainer : Group
-       {
-               #region CTOR
-               public MDIContainer () : base()
-               {
-               }
-               #endregion
-
-       }
-}
-
index b0719ef088e903fdb7ea6c75fc383df097a75a8c..668ba45284d047e8428c46b7d6ebc8e1a87cb3b4 100644 (file)
@@ -38,6 +38,7 @@ namespace Crow
        /// TemplatedControl may have 3 children (template,templateItem,content) but
        /// behave exactely as a container for layouting and drawing
        /// </summary>
+       [DesignIgnore]
        public class PrivateContainer : GraphicObject
        {
                #region CTOR
@@ -64,9 +65,8 @@ namespace Crow
                                        if (this.Contains (IFace.HoverWidget))
                                                IFace.HoverWidget = null;
                                }
-                               contentSize = new Size (0, 0);
+                               contentSize = default(Size);
                                child.LayoutChanged -= OnChildLayoutChanges;
-                               child.Dispose ();
                                this.RegisterForGraphicUpdate ();
                        }
 
@@ -75,11 +75,19 @@ namespace Crow
                        if (child != null) {
                                child.Parent = this;
                                child.LayoutChanged += OnChildLayoutChanges;
+                               child.Slot = child.LastSlots = default(Rectangle);
                                contentSize = child.Slot.Size;
                                child.RegisteredLayoutings = LayoutingType.None;
                                child.RegisterForLayouting (LayoutingType.Sizing);
                        }
                }
+               //dispose child if not null
+               protected virtual void deleteChild () {
+                       GraphicObject g = child;
+                       SetChild (null);
+                       if (g != null)
+                               g.Dispose ();
+               }
 
                #region GraphicObject Overrides
 
index d9ee0a00e5d2f4cc6501254ad8ee690438eac6ea..6f93f718348160f1404a29679f996ccbc830acef 100644 (file)
@@ -30,6 +30,7 @@ using System.Xml.Serialization;
 
 namespace Crow
 {
+       [DesignIgnore]
        public class SaturationValueSelector : ColorSelector
        {
                public SaturationValueSelector () : base(){}
index b636d993b9fc5aafb0148838ab676adeacd77c53..de4b21132df992f567ab7c1a3001718f8618921e 100644 (file)
@@ -36,6 +36,7 @@ namespace Crow
        /// <summary>
        /// generic class to build scrolling control in both directions
        /// </summary>
+       [DesignIgnore]
        public class ScrollingObject : GraphicObject
        {
                #region CTOR
diff --git a/src/GraphicObjects/ScrollingTextBox.cs b/src/GraphicObjects/ScrollingTextBox.cs
deleted file mode 100644 (file)
index d3c4276..0000000
+++ /dev/null
@@ -1,794 +0,0 @@
-//
-// ScrollingTextBox.cs
-//
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Xml.Serialization;
-using System.ComponentModel;
-using System.Collections;
-using Cairo;
-using System.Text;
-using System.Collections.Generic;
-using System.Text.RegularExpressions;
-using System.Linq;
-
-namespace Crow
-{
-       /// <summary>
-       /// Scrolling text box optimized for monospace fonts, for coding
-       /// </summary>
-       public class ScrollingTextBox : ScrollingObject
-       {
-               #region CTOR
-               protected ScrollingTextBox ():base()
-               {
-                       KeyEventsOverrides = true;
-               }
-               public ScrollingTextBox (Interface iface):base(iface){
-                       KeyEventsOverrides = true;
-               }
-               #endregion
-
-               public event EventHandler TextChanged;
-
-               public virtual void OnTextChanged(Object sender, EventArgs e)
-               {
-                       TextChanged.Raise (this, e);
-               }
-
-               #region private and protected fields
-               string lineBreak = Interface.LineBreak;
-               int visibleLines = 1;
-               List<string> lines;
-               string _text = "label";
-               Color selBackground;
-               Color selForeground;
-               Point mouseLocalPos = 0;//mouse coord in widget space
-               int _currentCol;        //0 based cursor position in string
-               int _currentLine;
-               Point _selBegin = -1;   //selection start (row,column)
-               Point _selRelease = -1; //selection end (row,column)
-
-               protected Rectangle rText;
-               protected FontExtents fe;
-               protected TextExtents te;
-               #endregion
-
-               [XmlAttributeAttribute][DefaultValue("label")]
-               public string Text
-               {
-                       get {
-                               return lines == null ?
-                                       _text : lines.Aggregate((i, j) => i + Interface.LineBreak + j);
-                       }
-                       set
-                       {
-                               if (string.Equals (value, _text, StringComparison.Ordinal))
-                                       return;
-
-                               _text = value;
-
-                               if (string.IsNullOrEmpty(_text))
-                                       _text = "";
-
-                               lines = getLines;
-                               MaxScrollY = Math.Max (0, lines.Count - visibleLines);
-
-                               OnTextChanged (this, null);
-                               RegisterForGraphicUpdate ();
-                       }
-               }
-
-
-               [XmlAttributeAttribute][DefaultValue("BlueGray")]
-               public virtual Color SelectionBackground {
-                       get { return selBackground; }
-                       set {
-                               if (value == selBackground)
-                                       return;
-                               selBackground = value;
-                               NotifyValueChanged ("SelectionBackground", selBackground);
-                               RegisterForRedraw ();
-                       }
-               }
-               [XmlAttributeAttribute][DefaultValue("White")]
-               public virtual Color SelectionForeground {
-                       get { return selForeground; }
-                       set {
-                               if (value == selForeground)
-                                       return;
-                               selForeground = value;
-                               NotifyValueChanged ("SelectionForeground", selForeground);
-                               RegisterForRedraw ();
-                       }
-               }
-               [XmlAttributeAttribute][DefaultValue(0)]
-               public int CurrentColumn{
-                       get { return _currentCol; }
-                       set {
-                               if (value == _currentCol)
-                                       return;
-                               if (value < 0)
-                                       _currentCol = 0;
-                               else if (value > lines [_currentLine].Length)
-                                       _currentCol = lines [_currentLine].Length;
-                               else
-                                       _currentCol = value;
-                               NotifyValueChanged ("CurrentColumn", _currentCol);
-                       }
-               }
-               [XmlAttributeAttribute][DefaultValue(0)]
-               public int CurrentLine{
-                       get { return _currentLine; }
-                       set {
-                               if (value == _currentLine)
-                                       return;
-                               if (value >= lines.Count)
-                                       _currentLine = lines.Count-1;
-                               else if (value < 0)
-                                       _currentLine = 0;
-                               else
-                                       _currentLine = value;
-                               //force recheck of currentCol for bounding
-                               int cc = _currentCol;
-                               _currentCol = 0;
-                               CurrentColumn = cc;
-                               NotifyValueChanged ("CurrentLine", _currentLine);
-
-                               if (CurrentLine < ScrollY)
-                                       ScrollY = CurrentLine;
-                               else if (CurrentLine >= ScrollY + visibleLines)
-                                       ScrollY = Math.Max (0, CurrentLine - visibleLines + 1);
-                       }
-               }
-               [XmlIgnore]public Point CurrentPosition {
-                       get { return new Point(CurrentColumn, CurrentLine); }
-               }
-               //TODO:using HasFocus for drawing selection cause SelBegin and Release binding not to work
-               /// <summary>
-               /// Selection begin position in char units (line, column)
-               /// </summary>
-               [XmlAttributeAttribute][DefaultValue("-1")]
-               public Point SelBegin {
-                       get { return _selBegin; }
-                       set {
-                               if (value == _selBegin)
-                                       return;
-                               _selBegin = value;
-                               System.Diagnostics.Debug.WriteLine ("SelBegin=" + _selBegin);
-                               NotifyValueChanged ("SelBegin", _selBegin);
-                               NotifyValueChanged ("SelectedText", SelectedText);
-                       }
-               }
-               /// <summary>
-               /// Selection release position in char units (line, column)
-               /// </summary>
-               [XmlAttributeAttribute][DefaultValue("-1")]
-               public Point SelRelease {
-                       get {
-                               return _selRelease;
-                       }
-                       set {
-                               if (value == _selRelease)
-                                       return;
-                               _selRelease = value;
-                               NotifyValueChanged ("SelRelease", _selRelease);
-                               NotifyValueChanged ("SelectedText", SelectedText);
-                       }
-               }
-               /// <summary>
-               /// return char at CurrentLine, CurrentColumn
-               /// </summary>
-               [XmlIgnore]protected Char CurrentChar
-               {
-                       get {
-                               return lines [CurrentLine] [CurrentColumn];
-                       }
-               }
-               /// <summary>
-               /// ordered selection start and end positions in char units
-               /// </summary>
-               [XmlIgnore]protected Point selectionStart
-               {
-                       get {
-                               return SelRelease < 0 || SelBegin.Y < SelRelease.Y ? SelBegin :
-                                       SelBegin.Y > SelRelease.Y ? SelRelease :
-                                       SelBegin.X < SelRelease.X ? SelBegin : SelRelease;
-                       }
-               }
-               [XmlIgnore]public Point selectionEnd
-               {
-                       get {
-                               return SelRelease < 0 || SelBegin.Y > SelRelease.Y ? SelBegin :
-                                       SelBegin.Y < SelRelease.Y ? SelRelease :
-                                       SelBegin.X > SelRelease.X ? SelBegin : SelRelease;
-                       }
-               }
-               [XmlIgnore]public string SelectedText
-               {
-                       get {
-
-                               if (SelRelease < 0 || SelBegin < 0)
-                                       return "";
-                               if (selectionStart.Y == selectionEnd.Y)
-                                       return lines [selectionStart.Y].Substring (selectionStart.X, selectionEnd.X - selectionStart.X);
-                               string tmp = "";
-                               tmp = lines [selectionStart.Y].Substring (selectionStart.X);
-                               for (int l = selectionStart.Y + 1; l < selectionEnd.Y; l++) {
-                                       tmp += Interface.LineBreak + lines [l];
-                               }
-                               tmp += Interface.LineBreak + lines [selectionEnd.Y].Substring (0, selectionEnd.X);
-                               return tmp;
-                       }
-               }
-               [XmlIgnore]public bool selectionIsEmpty
-               { get { return SelRelease == SelBegin; } }
-
-               List<string> getLines {
-                       get {
-                               return Regex.Split (_text, "\r\n|\r|\n|\\\\n").ToList();
-                       }
-               }
-               /// <summary>
-               /// Moves cursor one char to the left.
-               /// </summary>
-               /// <returns><c>true</c> if move succeed</returns>
-               public bool MoveLeft(){
-                       int tmp = _currentCol - 1;
-                       if (tmp < 0) {
-                               if (_currentLine == 0)
-                                       return false;
-                               CurrentLine--;
-                               CurrentColumn = int.MaxValue;
-                       } else
-                               CurrentColumn = tmp;
-                       return true;
-               }
-               /// <summary>
-               /// Moves cursor one char to the right.
-               /// </summary>
-               /// <returns><c>true</c> if move succeed</returns>
-               public bool MoveRight(){
-                       int tmp = _currentCol + 1;
-                       if (tmp > lines [_currentLine].Length){
-                               if (CurrentLine == lines.Count - 1)
-                                       return false;
-                               CurrentLine++;
-                               CurrentColumn = 0;
-                       } else
-                               CurrentColumn = tmp;
-                       return true;
-               }
-               public void GotoWordStart(){
-                       if (lines[CurrentLine].Length == 0)
-                               return;
-                       CurrentColumn--;
-                       //skip white spaces
-                       while (!char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn > 0)
-                               CurrentColumn--;
-                       while (char.IsLetterOrDigit (lines [CurrentLine] [CurrentColumn]) && CurrentColumn > 0)
-                               CurrentColumn--;
-                       if (!char.IsLetterOrDigit (this.CurrentChar))
-                               CurrentColumn++;
-               }
-               public void GotoWordEnd(){
-                       //skip white spaces
-                       if (CurrentColumn >= lines [CurrentLine].Length - 1)
-                               return;
-                       while (!char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
-                               CurrentColumn++;
-                       while (char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
-                               CurrentColumn++;
-                       if (char.IsLetterOrDigit (this.CurrentChar))
-                               CurrentColumn++;
-               }
-               public void DeleteChar()
-               {
-                       if (selectionIsEmpty) {
-                               if (CurrentColumn == 0) {
-                                       if (CurrentLine == 0 && lines.Count == 1)
-                                               return;
-                                       CurrentLine--;
-                                       CurrentColumn = lines [CurrentLine].Length;
-                                       lines [CurrentLine] += lines [CurrentLine + 1];
-                                       lines.RemoveAt (CurrentLine + 1);
-                                       OnTextChanged (this, null);
-                                       return;
-                               }
-                               CurrentColumn--;
-                               lines [CurrentLine] = lines [CurrentLine].Remove (CurrentColumn, 1);
-                       } else {
-                               int linesToRemove = selectionEnd.Y - selectionStart.Y + 1;
-                               int l = selectionStart.Y;
-
-                               if (linesToRemove > 0) {
-                                       lines [l] = lines [l].Remove (selectionStart.X, lines [l].Length - selectionStart.X) +
-                                               lines [selectionEnd.Y].Substring (selectionEnd.X, lines [selectionEnd.Y].Length - selectionEnd.X);
-                                       l++;
-                                       for (int c = 0; c < linesToRemove-1; c++)
-                                               lines.RemoveAt (l);
-                                       CurrentLine = selectionStart.Y;
-                                       CurrentColumn = selectionStart.X;
-                               } else
-                                       lines [l] = lines [l].Remove (selectionStart.X, selectionEnd.X - selectionStart.X);
-                               CurrentColumn = selectionStart.X;
-                               SelBegin = -1;
-                               SelRelease = -1;
-                       }
-                       OnTextChanged (this, null);
-               }
-
-               #region GraphicObject overrides
-               public override Font Font {
-                       get { return base.Font; }
-                       set {
-                               base.Font = value;
-
-                               using (ImageSurface img = new ImageSurface (Format.Argb32, 1, 1)) {
-                                       using (Context gr = new Context (img)) {
-                                               gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
-                                               gr.SetFontSize (Font.Size);
-
-                                               fe = gr.FontExtents;
-                                       }
-                               }
-                               MaxScrollY = 0;
-                               RegisterForGraphicUpdate ();
-                       }
-               }
-               protected override int measureRawSize(LayoutingType lt)
-               {
-                       if (lt == LayoutingType.Height)
-                               return (int)Math.Ceiling(fe.Height * lines.Count) + Margin * 2;
-
-                       string txt = _text.Replace("\t", new String (' ', Interface.TabSize));
-
-
-                       int maxChar = 0;
-                       foreach (string s in Regex.Split (txt, "\r\n|\r|\n|\\\\n")) {
-                               if (maxChar < s.Length)
-                                       maxChar = s.Length;
-                       }
-                       return (int)(fe.MaxXAdvance * maxChar) + Margin * 2;
-               }
-               public override void OnLayoutChanges (LayoutingType layoutType)
-               {
-                       base.OnLayoutChanges (layoutType);
-
-                       if (layoutType == LayoutingType.Height)
-                               updateVisibleLines ();
-               }
-               protected override void onDraw (Context gr)
-               {
-                       base.onDraw (gr);
-
-                       gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
-                       gr.SetFontSize (Font.Size);
-                       gr.FontOptions = Interface.FontRenderingOptions;
-                       gr.Antialias = Interface.Antialias;
-
-                       Rectangle cb = ClientRectangle;
-
-                       Foreground.SetAsSource (gr);
-
-                       bool selectionInProgress = false;
-
-                       #region draw text cursor
-                       if (SelBegin != SelRelease)
-                               selectionInProgress = true;
-                       else if (HasFocus){
-                               gr.SetSourceColor(Color.Red);
-                               gr.LineWidth = 2.0;
-                               double cursorX = cb.X + (CurrentColumn - ScrollX) * fe.MaxXAdvance;
-                               gr.MoveTo (0.5 + cursorX, cb.Y + (CurrentLine - ScrollY) * fe.Height);
-                               gr.LineTo (0.5 + cursorX, cb.Y + (CurrentLine + 1 - ScrollY) * fe.Height);
-                               gr.Stroke();
-                       }
-                       #endregion
-
-                       Foreground.SetAsSource (gr);
-
-                       for (int i = 0; i < visibleLines; i++) {
-                               int curL = i + ScrollY;
-                               if (curL >= lines.Count)
-                                       break;
-                               string lstr = lines[curL];
-
-                               gr.MoveTo (cb.X, cb.Y + fe.Ascent + fe.Height * i);
-                               gr.ShowText (lstr);
-                               gr.Fill ();
-
-                               if (selectionInProgress && curL >= selectionStart.Y && curL <= selectionEnd.Y) {
-
-                                       double rLineX = cb.X,
-                                       rLineY = cb.Y + i * fe.Height,
-                                       rLineW = lstr.Length * fe.MaxXAdvance;
-
-                                       System.Diagnostics.Debug.WriteLine ("sel start: " + selectionStart + " sel end: " + selectionEnd);
-                                       if (curL == selectionStart.Y) {
-                                               rLineX += (selectionStart.X - ScrollX) * fe.MaxXAdvance;
-                                               rLineW -= selectionStart.X * fe.MaxXAdvance;
-                                       }
-                                       if (curL == selectionEnd.Y)
-                                               rLineW -= (lstr.Length - selectionEnd.X) * fe.MaxXAdvance;
-
-                                       gr.Save ();
-                                       gr.Operator = Operator.Source;
-                                       gr.Rectangle (rLineX, rLineY, rLineW, fe.Height);
-                                       gr.SetSourceColor (SelectionBackground);
-                                       gr.FillPreserve ();
-                                       gr.Clip ();
-                                       gr.Operator = Operator.Over;
-                                       gr.SetSourceColor (SelectionForeground);
-                                       gr.MoveTo (cb.X, cb.Y + fe.Ascent + fe.Height * i);
-                                       gr.ShowText (lstr);
-                                       gr.Fill ();
-                                       gr.Restore ();
-                               }
-                       }
-               }
-               #endregion
-
-               #region Mouse handling
-               void updatemouseLocalPos(Point mpos){
-                       Point mouseLocalPos = mpos - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft;
-                       if (mouseLocalPos.X < 0)
-                               CurrentColumn--;
-                       else
-                               CurrentColumn = ScrollX +  (int)Math.Round (mouseLocalPos.X / fe.MaxXAdvance);
-
-                       if (mouseLocalPos.Y < 0)
-                               CurrentLine--;
-                       else
-                               CurrentLine = ScrollY + (int)Math.Floor (mouseLocalPos.Y / fe.Height);
-               }
-               public override void onMouseEnter (object sender, MouseMoveEventArgs e)
-               {
-                       base.onMouseEnter (sender, e);
-                       IFace.MouseCursor = XCursor.Text;
-               }
-               public override void onMouseLeave (object sender, MouseMoveEventArgs e)
-               {
-                       base.onMouseLeave (sender, e);
-                       IFace.MouseCursor = XCursor.Default;
-               }
-               protected override void onFocused (object sender, EventArgs e)
-               {
-                       base.onFocused (sender, e);
-
-                       //                      SelBegin = new Point(0,0);
-                       //                      SelRelease = new Point (lines.LastOrDefault ().Length, lines.Count-1);
-                       RegisterForRedraw ();
-               }
-               protected override void onUnfocused (object sender, EventArgs e)
-               {
-                       base.onUnfocused (sender, e);
-
-                       //                      SelBegin = -1;
-                       //                      SelRelease = -1;
-                       RegisterForRedraw ();
-               }
-               public override void onMouseMove (object sender, MouseMoveEventArgs e)
-               {
-                       base.onMouseMove (sender, e);
-
-                       if (!e.Mouse.IsButtonDown (MouseButton.Left))
-                               return;
-                       if (!HasFocus || SelBegin < 0)
-                               return;
-
-                       updatemouseLocalPos (e.Position);
-                       SelRelease = CurrentPosition;
-
-                       RegisterForRedraw();
-               }
-               public override void onMouseDown (object sender, MouseButtonEventArgs e)
-               {
-                       if (this.HasFocus){
-                               updatemouseLocalPos (e.Position);
-                               SelBegin = SelRelease = CurrentPosition;
-                               RegisterForRedraw();//TODO:should put it in properties
-                       }
-
-                       //done at the end to set 'hasFocus' value after testing it
-                       base.onMouseDown (sender, e);
-               }
-               public override void onMouseUp (object sender, MouseButtonEventArgs e)
-               {
-                       base.onMouseUp (sender, e);
-
-                       if (SelBegin == SelRelease)
-                               SelBegin = SelRelease = -1;
-
-                       updatemouseLocalPos (e.Position);
-                       RegisterForRedraw ();
-               }
-               public override void onMouseDoubleClick (object sender, MouseButtonEventArgs e)
-               {
-                       base.onMouseDoubleClick (sender, e);
-
-                       GotoWordStart ();
-                       SelBegin = CurrentPosition;
-                       GotoWordEnd ();
-                       SelRelease = CurrentPosition;
-                       RegisterForRedraw ();
-               }
-               #endregion
-
-               #region Keyboard handling
-               public override void onKeyDown (object sender, KeyboardKeyEventArgs e)
-               {
-                       base.onKeyDown (sender, e);
-
-                       Key key = e.Key;
-
-                       switch (key)
-                       {
-                       case Key.Back:
-                               if (CurrentPosition == 0)
-                                       return;
-                               this.DeleteChar();
-                               break;
-                       case Key.Clear:
-                               break;
-                       case Key.Delete:
-                               if (selectionIsEmpty) {
-                                       if (!MoveRight ())
-                                               return;
-                               }else if (e.Shift)
-                                       IFace.Clipboard = this.SelectedText;
-                               this.DeleteChar ();
-                               break;
-                       case Key.Enter:
-                       case Key.KeypadEnter:
-                               if (!selectionIsEmpty)
-                                       this.DeleteChar ();
-                               this.InsertLineBreak ();
-                               break;
-                       case Key.Escape:
-                               Text = "";
-                               CurrentColumn = 0;
-                               SelRelease = -1;
-                               break;
-                       case Key.Home:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = new Point (CurrentColumn, CurrentLine);
-                                       if (e.Control)
-                                               CurrentLine = 0;
-                                       CurrentColumn = 0;
-                                       SelRelease = new Point (CurrentColumn, CurrentLine);
-                                       break;
-                               }
-                               SelRelease = -1;
-                               if (e.Control)
-                                       CurrentLine = 0;
-                               CurrentColumn = 0;
-                               break;
-                       case Key.End:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = CurrentPosition;
-                                       if (e.Control)
-                                               CurrentLine = int.MaxValue;
-                                       CurrentColumn = int.MaxValue;
-                                       SelRelease = CurrentPosition;
-                                       break;
-                               }
-                               SelRelease = -1;
-                               if (e.Control)
-                                       CurrentLine = int.MaxValue;
-                               CurrentColumn = int.MaxValue;
-                               break;
-                       case Key.Insert:
-                               if (e.Shift)
-                                       this.Insert (IFace.Clipboard);
-                               else if (e.Control && !selectionIsEmpty)
-                                       IFace.Clipboard = this.SelectedText;
-                               break;
-                       case Key.Left:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = new Point(CurrentColumn, CurrentLine);
-                                       if (e.Control)
-                                               GotoWordStart ();
-                                       else if (!MoveLeft ())
-                                               return;
-                                       SelRelease = CurrentPosition;
-                                       break;
-                               }
-                               SelRelease = -1;
-                               if (e.Control)
-                                       GotoWordStart ();
-                               else
-                                       MoveLeft();
-                               break;
-                       case Key.Right:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = CurrentPosition;
-                                       if (e.Control)
-                                               GotoWordEnd ();
-                                       else if (!MoveRight ())
-                                               return;
-                                       SelRelease = CurrentPosition;
-                                       break;
-                               }
-                               SelRelease = -1;
-                               if (e.Control)
-                                       GotoWordEnd ();
-                               else
-                                       MoveRight ();
-                               break;
-                       case Key.Up:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = CurrentPosition;
-                                       CurrentLine--;
-                                       SelRelease = CurrentPosition;
-                                       break;
-                               }
-                               SelRelease = -1;
-                               CurrentLine--;
-                               break;
-                       case Key.Down:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = CurrentPosition;
-                                       CurrentLine++;
-                                       SelRelease = CurrentPosition;
-                                       break;
-                               }
-                               SelRelease = -1;
-                               CurrentLine++;
-                               break;
-                       case Key.Menu:
-                               break;
-                       case Key.NumLock:
-                               break;
-                       case Key.PageDown:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = CurrentPosition;
-                                       CurrentLine += visibleLines;
-                                       SelRelease = CurrentPosition;
-                                       break;
-                               }
-                               SelRelease = -1;                                
-                               CurrentLine += visibleLines;
-                               break;
-                       case Key.PageUp:
-                               if (e.Shift) {
-                                       if (selectionIsEmpty)
-                                               SelBegin = CurrentPosition;
-                                       CurrentLine -= visibleLines;
-                                       SelRelease = CurrentPosition;
-                                       break;
-                               }                               
-                               CurrentLine -= visibleLines;
-                               break;
-                       case Key.RWin:
-                               break;
-                       case Key.Tab:
-                               this.Insert ("\t");
-                               break;
-                       default:
-                               break;
-                       }
-                       RegisterForGraphicUpdate();
-               }
-               public override void onKeyPress (object sender, KeyPressEventArgs e)
-               {
-                       base.onKeyPress (sender, e);
-
-                       this.Insert (e.KeyChar.ToString());
-
-                       SelRelease = -1;
-                       SelBegin = -1; //new Point(CurrentColumn, SelBegin.Y);
-
-                       RegisterForGraphicUpdate();
-               }
-               #endregion
-
-
-               /// <summary> Compute x offset in cairo unit from text position </summary>
-               double GetXFromTextPointer(Context gr, Point pos)
-               {
-                       try {
-                               string l = lines [pos.Y].Substring (0, pos.X).
-                                       Replace ("\t", new String (' ', Interface.TabSize));
-                               return gr.TextExtents (l).XAdvance;
-                       } catch{
-                               return -1;
-                       }
-               }
-
-               /// <summary> line break could be '\r' or '\n' or '\r\n' </summary>
-               string detectLineBreakKind(){
-                       string strLB = "";
-
-                       if (string.IsNullOrEmpty(_text))
-                               return Interface.LineBreak;
-                       int i = 0;
-                       while ( i < _text.Length) {
-                               if (_text [i] == '\r') {
-                                       strLB += '\r';
-                                       i++;
-                               }
-                               if (i < _text.Length) {
-                                       if (_text [i] == '\r')
-                                               return "\r";
-                                       if (_text [i] == '\n')
-                                               strLB += '\n';
-                               }
-                               if (!string.IsNullOrEmpty (strLB))
-                                       return strLB;
-                               i++;
-                       }
-                       return Interface.LineBreak;
-               }
-
-               void updateVisibleLines(){
-                       visibleLines = (int)Math.Floor ((double)ClientRectangle.Height / fe.Height);
-                       MaxScrollY = Math.Max (0, lines.Count - visibleLines);
-
-                       System.Diagnostics.Debug.WriteLine ("update visible lines: " + visibleLines);
-                       System.Diagnostics.Debug.WriteLine ("update MaxScrollY: " + MaxScrollY);
-               }
-
-
-               /// <summary>
-               /// Insert new string at caret position, should be sure no line break is inside.
-               /// </summary>
-               /// <param name="str">String.</param>
-               protected void Insert(string str)
-               {
-                       if (!selectionIsEmpty)
-                               this.DeleteChar ();
-                       string[] strLines = Regex.Split (str, "\r\n|\r|\n|" + @"\\n").ToArray();
-                       lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, strLines[0]);
-                       CurrentColumn += strLines[0].Length;
-                       for (int i = 1; i < strLines.Length; i++) {
-                               InsertLineBreak ();
-                               lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, strLines[i]);
-                               CurrentColumn += strLines[i].Length;
-                       }
-                       OnTextChanged (this, null);
-                       RegisterForGraphicUpdate();
-               }
-
-               /// <summary>
-               /// Insert a line break.
-               /// </summary>
-               protected void InsertLineBreak()
-               {
-                       lines.Insert(CurrentLine + 1, lines[CurrentLine].Substring(CurrentColumn));
-                       lines [CurrentLine] = lines [CurrentLine].Substring (0, CurrentColumn);
-                       CurrentLine++;
-                       CurrentColumn = 0;
-                       OnTextChanged (this, null);
-               }
-       }
-}
\ No newline at end of file
index 69495647416fd0bc0576b1912c571b2353a3edd4..17e3b7701f871e3e30cf552d086a545300bef08a 100644 (file)
@@ -36,6 +36,7 @@ using System.ComponentModel;
 
 namespace Crow
 {
+       [DesignIgnore]
        public class TextRun : GraphicObject
        {
                #region CTOR
index 40ba5f994a6a2c42a1ea82183d0ca40b6faa011d..929fd4f8f8324adbecc43cf9473f180e83865b67 100644 (file)
@@ -27,6 +27,10 @@ using System;
 
 namespace Crow
 {
+       public class DesignIgnore : Attribute
+       {               
+       }
+
        public class DesignCategory : Attribute
        {
                public string Name { get; set; }
index 76e7771d0d056187a7f0abf0a79261582b5eff45..a3bd9fd49c7b4c63beb1952985dacdf6f4b3017b 100644 (file)
@@ -582,7 +582,7 @@ namespace Crow
                /// <summary>Layouting loop, this is the first step of the udpate and process registered
                /// Layouting queue items. Failing LQI's are requeued in this cycle until MaxTry is reached which
                /// trigger an enqueue for the next Update Cycle</summary>
-               void processLayouting(){
+               protected virtual void processLayouting(){
                        #if MEASURE_TIME
                        layoutingMeasure.StartCycle();
                        #endif
index 08810aaa62f3e88e83e07eda535969472a124002..a9ef298a5dbfc1aa6a12a49479418cffdc9825ab 100644 (file)
@@ -98,10 +98,10 @@ namespace Crow
                public void ProcessLayouting()
                {
                        GraphicObject go = Layoutable as GraphicObject;
-                       if (go == null) {
-                               Debug.WriteLine ("ERROR: processLayouting on something else than a graphic object: " + this.ToString ());
-                               return;
-                       }
+//                     if (go == null) {
+//                             Debug.WriteLine ("ERROR: processLayouting on something else than a graphic object: " + this.ToString ());
+//                             return;
+//                     }
 
                        go.parentRWLock.EnterReadLock ();