// TextMarker.cs // // Author: // Mike Krüger // // Copyright (c) 2008 Novell, Inc (http://www.novell.com) // // 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 Gdk; using Mono.TextEditor.Highlighting; namespace Mono.TextEditor { public interface IExtendingTextLineMarker { double GetLineHeight (MonoTextEditor editor); void Draw (MonoTextEditor editor, Cairo.Context cr, int lineNr, Cairo.Rectangle lineArea); } public interface IActionTextLineMarker { /// /// true, if the mouse press was handled - false otherwise. /// bool MousePressed (MonoTextEditor editor, MarginMouseEventArgs args); void MouseHover (MonoTextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result); } public class TextLineMarkerHoverResult { bool isCursorSet; public bool HasCursor { get { return isCursorSet;} } Gdk.Cursor cursor; public Gdk.Cursor Cursor { get { return cursor; } set { cursor = value; isCursorSet = true; } } public string TooltipMarkup { get; set; } } [Flags] public enum TextLineMarkerFlags { None = 0, DrawsSelection = 1 } public class LineMetrics { public DocumentLine LineSegment { get; internal set; } public TextViewMargin.LayoutWrapper Layout { get; internal set; } public int SelectionStart { get; internal set; } public int SelectionEnd { get; internal set; } public int TextStartOffset { get; internal set; } public int TextEndOffset { get; internal set; } public double TextRenderStartPosition { get; internal set; } public double TextRenderEndPosition { get; internal set; } public double LineHeight { get; internal set; } public double WholeLineWidth { get; internal set; } public double LineYRenderStartPosition { get; internal set; } } public class EndOfLineMetrics { public DocumentLine LineSegment { get; internal set; } public double TextRenderEndPosition { get; internal set; } public double LineHeight { get; internal set; } public double LineYRenderStartPosition { get; internal set; } } public class TextLineMarker { DocumentLine lineSegment; public DocumentLine LineSegment { get { return lineSegment; } set { lineSegment = value; } } public virtual TextLineMarkerFlags Flags { get; set; } public object Tag { get; set; } bool isVisible = true; public virtual bool IsVisible { get { return isVisible; } set { isVisible = value; } } public TextLineMarker () { } public virtual void Draw (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics) { } public virtual ChunkStyle GetStyle (ChunkStyle baseStyle) { return baseStyle; } /// /// Draws the background of the text. /// /// true, if background was drawn, false otherwise. /// The editor. /// The cairo context. /// The y coordinate. /// The line metrics. public virtual bool DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics) { return false; } /// /// Is used to draw in the area after the visible text. /// public virtual void DrawAfterEol (MonoTextEditor textEditor, Cairo.Context cr, EndOfLineMetrics metrics) { } } }