4
// Mike Krüger <mkrueger@novell.com>
6
// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
// of this software and associated documentation files (the "Software"), to deal
10
// in the Software without restriction, including without limitation the rights
11
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
// copies of the Software, and to permit persons to whom the Software is
13
// furnished to do so, subject to the following conditions:
15
// The above copyright notice and this permission notice shall be included in
16
// all copies or substantial portions of the Software.
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
namespace Mono.TextEditor
34
public class IconMargin : Margin
37
Gdk.GC backgroundGC, seperatorGC;
41
public IconMargin (TextEditor editor)
44
layout = new Pango.Layout (editor.PangoContext);
47
public override int Width {
53
public override void Dispose ()
55
layout = layout.Kill ();
61
backgroundGC = backgroundGC.Kill ();
62
seperatorGC = seperatorGC.Kill ();
65
internal protected override void OptionsChanged ()
68
backgroundGC = new Gdk.GC (editor.GdkWindow);
69
backgroundGC.RgbFgColor = editor.ColorStyle.IconBarBg;
71
seperatorGC = new Gdk.GC (editor.GdkWindow);
72
seperatorGC.RgbFgColor = editor.ColorStyle.IconBarSeperator;
74
layout.FontDescription = editor.Options.Font;
77
layout.GetPixelSize (out tmp, out this.marginWidth);
82
internal protected override void MousePressed (MarginMouseEventArgs args)
84
base.MousePressed (args);
86
LineSegment lineSegment = args.LineSegment;
87
if (lineSegment != null && lineSegment.Markers != null) {
88
foreach (TextMarker marker in lineSegment.Markers) {
89
if (marker is IIconBarMarker)
90
((IIconBarMarker)marker).MousePress (args);
95
internal protected override void MouseReleased (MarginMouseEventArgs args)
97
base.MouseReleased (args);
99
LineSegment lineSegment = args.LineSegment;
100
if (lineSegment != null && lineSegment.Markers != null) {
101
foreach (TextMarker marker in lineSegment.Markers) {
102
if (marker is IIconBarMarker)
103
((IIconBarMarker)marker).MouseRelease (args);
108
internal protected override void Draw (Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y)
110
Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y, Width, editor.LineHeight);
112
win.DrawRectangle (backgroundGC, true, drawArea);
113
win.DrawLine (seperatorGC, x + Width - 1, drawArea.Top, x + Width - 1, drawArea.Bottom);
115
if (line < editor.Document.LineCount) {
116
LineSegment lineSegment = editor.Document.GetLine (line);
118
if (lineSegment.Markers != null) {
119
foreach (TextMarker marker in lineSegment.Markers) {
120
if (marker is IIconBarMarker)
121
((IIconBarMarker)marker).DrawIcon (editor, win, lineSegment, line, x, y, Width, editor.LineHeight);
124
if (DrawEvent != null)
125
DrawEvent (this, new BookmarkMarginDrawEventArgs (editor, win, lineSegment, line, x, y));
131
public EventHandler<BookmarkMarginDrawEventArgs> DrawEvent;
134
public class BookmarkMarginDrawEventArgs : EventArgs
138
LineSegment lineSegment;
143
public TextEditor Editor {
149
public Drawable Win {
173
public LineSegment LineSegment {
179
public BookmarkMarginDrawEventArgs (TextEditor editor, Gdk.Drawable win, LineSegment line, int lineNumber, int xPos, int yPos)
181
this.editor = editor;
183
this.lineSegment = line;
184
this.line = lineNumber;