~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Refactoring/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
namespace MonoDevelop.AnalysisCore.Gui
33
33
{
34
 
        class ResultMarker : UnderlineMarker
 
34
        class ResultMarker : UnderlineTextSegmentMarker
35
35
        {
36
36
                Result result;
37
37
                
38
 
                public ResultMarker (Result result) : base (
39
 
                                GetColor (result),
40
 
                                IsOneLine (result)? (result.Region.BeginColumn) : 0,
41
 
                                IsOneLine (result)? (result.Region.EndColumn) : 0)
 
38
                public ResultMarker (Result result, TextSegment segment) : base ("", segment)
42
39
                {
43
40
                        this.result = result;
44
41
                }
56
53
                public int ColEnd   { get { return IsOneLine (result)? (result.Region.EndColumn) : 0; } }
57
54
                public string Message { get { return result.Message; } }
58
55
                
59
 
                static string GetColor (Result result)
 
56
                static Cairo.Color GetColor (TextEditor editor, Result result)
60
57
                {
61
58
                        switch (result.Level) {
62
59
                        case Severity.None:
63
 
                                return Mono.TextEditor.Highlighting.ColorScheme.DefaultString;
 
60
                                return editor.ColorStyle.PlainText.Background;
64
61
                        case Severity.Error:
65
 
                                return Mono.TextEditor.Highlighting.ColorScheme.ErrorUnderlineString;
 
62
                                return editor.ColorStyle.UnderlineError.Color;
66
63
                        case Severity.Warning:
67
 
                                return Mono.TextEditor.Highlighting.ColorScheme.WarningUnderlineString;
 
64
                                return editor.ColorStyle.UnderlineWarning.Color;
68
65
                        case Severity.Suggestion:
69
 
                                return Mono.TextEditor.Highlighting.ColorScheme.SuggestionUnderlineString;
 
66
                                return editor.ColorStyle.UnderlineSuggestion.Color;
70
67
                        case Severity.Hint:
71
 
                                return Mono.TextEditor.Highlighting.ColorScheme.HintUnderlineString;
 
68
                                return editor.ColorStyle.UnderlineHint.Color;
72
69
                        default:
73
70
                                throw new System.ArgumentOutOfRangeException ();
74
71
                        }
76
73
                
77
74
                public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
78
75
                {
79
 
                        int markerStart = LineSegment.Offset + System.Math.Max (StartCol - 1, 0);
80
 
                        int markerEnd = LineSegment.Offset + (EndCol < 1 ? LineSegment.Length : EndCol - 1);
 
76
                        if (Debugger.DebuggingService.IsDebugging)
 
77
                                return;
 
78
                        int markerStart = Segment.Offset;
 
79
                        int markerEnd = Segment.EndOffset;
81
80
                        if (markerEnd < startOffset || markerStart > endOffset) 
82
81
                                return;
83
82
                        
119
118
                                return;
120
119
                        
121
120
                        double height = editor.LineHeight / 5;
122
 
                        cr.Color = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName);
 
121
                        cr.Color = GetColor (editor, Result);
123
122
                        if (drawOverlay) {
124
123
                                cr.Rectangle (drawFrom, y, drawTo - drawFrom, editor.LineHeight);
125
 
                                var color = editor.ColorStyle.Default.CairoBackgroundColor;
 
124
                                var color = editor.ColorStyle.PlainText.Background;
126
125
                                color.A = 0.6;
127
126
                                cr.Color = color;
128
127
                                cr.Fill ();
135
134
                        }
136
135
                }
137
136
        }
 
137
 
 
138
        class GrayOutMarker : ResultMarker, IChunkMarker
 
139
        {
 
140
                public GrayOutMarker (Result result, TextSegment segment) : base (result, segment)
 
141
                {
 
142
                }
 
143
 
 
144
                public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
 
145
                {
 
146
                }
 
147
 
 
148
                #region IChunkMarker implementation
 
149
                void IChunkMarker.ChangeForeColor (TextEditor editor, Chunk chunk, ref Cairo.Color color)
 
150
                {
 
151
                        if (Debugger.DebuggingService.IsDebugging)
 
152
                                return;
 
153
                        int markerStart = Segment.Offset;
 
154
                        int markerEnd = Segment.EndOffset;
 
155
                        if (!(markerStart <= chunk.Offset && chunk.Offset < markerEnd)) 
 
156
                                return;
 
157
 
 
158
                        var bgc = editor.ColorStyle.PlainText.Background;
 
159
                        double alpha = 0.6;
 
160
                        color = new Cairo.Color (
 
161
                                color.R * alpha + bgc.R * (1.0 - alpha),
 
162
                                color.G * alpha + bgc.G * (1.0 - alpha),
 
163
                                color.B * alpha + bgc.B * (1.0 - alpha)
 
164
                        );
 
165
                }
 
166
                #endregion
 
167
        }
138
168
}