1
// DeclarationViewWindow.cs
4
// Mike Krüger <mkrueger@novell.com>
6
// Copyright (c) 2009 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
28
using MonoDevelop.Components;
29
using System.Collections.Generic;
30
using MonoDevelop.Core;
32
namespace MonoDevelop.Ide.CodeCompletion
34
internal class DeclarationViewWindow : TooltipWindow
36
static char[] newline = {'\n'};
38
List<string> overloads = new List<string> ();
41
public int CurrentOverload {
43
return this.current_overload;
46
this.current_overload = value;
51
MonoDevelop.Components.FixedWidthWrapLabel headlabel, bodylabel;
56
public string DescriptionMarkup {
58
if (string.IsNullOrEmpty (bodylabel.Text))
59
return headlabel.Text;
60
return headlabel.Text + "\n" + bodylabel.Text;
63
if (string.IsNullOrEmpty (value)) {
64
headlabel.Markup = bodylabel.Markup = "";
65
headlabel.Visible = bodylabel.Visible = false;
68
string[] parts = value.Split (newline, 2);
69
headlabel.Markup = "<b>" + parts[0].Trim () + "</b>";
70
bodylabel.Markup = parts.Length == 2 && !string.IsNullOrEmpty (parts[1].Trim ())? "<span size=\"smaller\">" + parts[1].Trim () + "</span>" : "";
71
headlabel.Visible = !string.IsNullOrEmpty (parts[0].Trim ());
72
bodylabel.Visible = parts.Length == 2 ;
81
left.Visible = right.Visible = helpbox.Visible = value;
83
//this could go somewhere better, as long as it's after realization
84
headlabel.Visible = !string.IsNullOrEmpty (headlabel.Text);
85
bodylabel.Visible = !string.IsNullOrEmpty (bodylabel.Text);
89
public void AddOverload (string desc)
92
if (overloads.Count == 2)
93
Multiple = overloads.Count > 1;
99
if (current_overload >= 0 && current_overload < overloads.Count) {
100
DescriptionMarkup = overloads[current_overload];
101
helplabel.Markup = string.Format ("<small>" + GettextCatalog.GetString ("{0} of {1} overloads") + "</small>", current_overload + 1, overloads.Count);
105
public void OverloadLeft ()
107
if (current_overload == 0) {
108
if (overloads.Count > 0)
109
current_overload = overloads.Count - 1;
116
public void OverloadRight ()
118
if (current_overload == overloads.Count - 1) {
119
current_overload = 0;
121
if (overloads.Count > 0)
131
DescriptionMarkup = String.Empty;
132
current_overload = 0;
135
public void SetFixedWidth (int w)
138
w -= SizeRequest ().Width - headlabel.SizeRequest ().Width;
139
headlabel.MaxWidth = w > 0 ? w : 1;
141
headlabel.MaxWidth = -1;
143
bodylabel.MaxWidth = headlabel.RealWidth > 350 ? headlabel.RealWidth : 350;
147
public DeclarationViewWindow () : base ()
149
this.AllowShrink = false;
150
this.AllowGrow = false;
152
EnableTransparencyControl = true;
154
headlabel = new MonoDevelop.Components.FixedWidthWrapLabel ();
155
headlabel.Indent = -20;
156
headlabel.Wrap = Pango.WrapMode.WordChar;
157
headlabel.BreakOnCamelCasing = true;
158
headlabel.BreakOnPunctuation = true;
160
bodylabel = new MonoDevelop.Components.FixedWidthWrapLabel ();
161
bodylabel.Wrap = Pango.WrapMode.WordChar;
162
bodylabel.BreakOnCamelCasing = true;
163
bodylabel.BreakOnPunctuation = true;
165
VBox vb = new VBox (false, 0);
166
vb.PackStart (headlabel, true, true, 0);
167
vb.PackStart (bodylabel, true, true, 3);
169
left = new Arrow (ArrowType.Left, ShadowType.None);
170
right = new Arrow (ArrowType.Right, ShadowType.None);
172
HBox hb = new HBox (false, 0);
174
hb.PackStart (left, false, true, 0);
175
hb.PackStart (vb, true, true, 0);
176
hb.PackStart (right, false, true, 0);
178
helplabel = new Label (string.Empty);
179
helplabel.Xalign = 1;
181
helpbox = new VBox (false, 0);
182
helpbox.PackStart (new HSeparator (), false, true, 0);
183
helpbox.PackStart (helplabel, false, true, 0);
184
helpbox.BorderWidth = 2;
186
VBox vb2 = new VBox (false, 0);
188
vb2.PackStart (hb, true, true, 0);
189
vb2.PackStart (helpbox, false, true, 0);